diff options
Diffstat (limited to 'sys/arch/amiga/stand/boot')
34 files changed, 3414 insertions, 0 deletions
diff --git a/sys/arch/amiga/stand/boot/Makefile b/sys/arch/amiga/stand/boot/Makefile new file mode 100644 index 00000000000..4dc2b872c9d --- /dev/null +++ b/sys/arch/amiga/stand/boot/Makefile @@ -0,0 +1,102 @@ +# $OpenBSD: Makefile,v 1.1 1997/01/16 09:26:21 niklas Exp $ + +NOPROG= installboot +MAN=installboot.8 + +SUBDIR=aout2bb txlt + +TXLT=txlt/txlt + +OBJS = configure.o main.o +OBJS += console.o xd.o + +# libsa library replacements: +OBJS += alloc.o printf.o twiddle.o + +# libkern replacements: +OBJS += bcopy.o bzero.o ashrdi3.o muldi3.o + +# machine language startup code: +OBJS += startit.o + +SRCS = installboot.sh configure.c main.c console.c xd.c +SRCS+= twiddle.c +SRCS+= bbstart.s libstubs.s alloc.s printf.s startit.s +SRCS+= bcopy.s bzero.c ashrdi3.s muldi3.s + +CLEANFILES = $(OBJS) $(BOOTBLOCKS) x.out xxstart.s f.out fdstart.s + +S= ${.CURDIR}/../../../.. +INCPATH=-I${.CURDIR} -I${.CURDIR}/../.. -I${S} -I${S}/lib/libsa +COPTIM= -O2 -fomit-frame-pointer -fno-function-cse -Wa,-l -m68060 -Wa,-m68030 +CFLAGS = ${COPTIM} ${INCPATH} ${DEFS} +COPTS += -Wall -Wstrict-prototypes + +BOOTBLOCKS=xxboot # XXX fdboot is too large at the moment. + +.s.o: ; $(CC) $(CAFLAGS) $(COPTS) -x assembler-with-cpp -o $*.o -c $*.s + +#libs: + +.include "${.CURDIR}/libsa/Makefile.inc" +LIBSA= ${SA_LIB} + +# libstubs should really be a library, but we don't care for now. +LIBS= ${LIBSA} ${LIBKERN} libstubs.o + +all: $(BOOTBLOCKS) installboot + +$(OBJS): txlt + +xxstart.s: bbstart.s + cpp bbstart.s > $@ + +fdstart.s: bbstart.s + cpp -DAUTOLOAD=8192 bbstart.s > $@ + +x.out: xxstart.o $(OBJS) $(LIBS) + $(LD) $(LDFLAGS) -r -dc -e _start -o x.out xxstart.o $(OBJS) $(LIBS) + size x.out + +f.out: fdstart.o $(OBJS) $(LIBS) + $(LD) $(LDFLAGS) -r -dc -e _start -o f.out fdstart.o $(OBJS) $(LIBS) + size f.out + + +$(BOOTBLOCKS): aout2bb + +xxboot: x.out + rm -f $@ + aout2bb/aout2bb x.out $@ || nm -u x.out + +fdboot: f.out + rm -f $@ + aout2bb/aout2bb -F f.out $@ || nm -u f.out + +clean:: + rm -f $(OBJS) fdstart.[os] xxstart.[os] f.out x.out installboot + +install: all maninstall + install -o $(BINOWN) -g $(BINGRP) $(BOOTBLOCKS) /usr/mdec + install -o $(BINOWN) -g $(BINGRP) installboot /usr/sbin + +ci: + ci -l $(SRCS) Makefile + +tar: + (cd ..; tar \ + --exclude '*.o' --exclude RCS --exclude .depend \ + --exclude '*.out' --exclude fdstart.s --exclude xxstart.s \ + --exclude aout2bb/aout2bb --exclude libsa.a \ + -czvf boot.tar.gz boot) + +test: xxtest fdtest + +xxtest: xxboot + dd if=$? of=/dev/rsd1e bs=8192 count=1 + +fdtest: fdboot + dd if=$? of=/dev/rfd0a bs=8192 count=1 + +.include <bsd.prog.mk> +.include "Makefile.txlt" diff --git a/sys/arch/amiga/stand/boot/Makefile.txlt b/sys/arch/amiga/stand/boot/Makefile.txlt new file mode 100644 index 00000000000..714c912dd7e --- /dev/null +++ b/sys/arch/amiga/stand/boot/Makefile.txlt @@ -0,0 +1,12 @@ +# $OpenBSD: Makefile.txlt,v 1.1 1997/01/16 09:26:22 niklas Exp $ +# $NetBSD: Makefile.txlt,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + +AFLAGS += -m68060 -m68030 -l +CAFLAGS += -Wa,-l -Wa,-m68030 +#CFLAGS += -ffixed-a4 +# -ffixed-a5 + +.c.o: + $(CC) $(CFLAGS) -S $< -o $*.s + $(TXLT) < $*.s | $(AS) $(AFLAGS) -o $*.o + rm $*.s diff --git a/sys/arch/amiga/stand/boot/alloc.s b/sys/arch/amiga/stand/boot/alloc.s new file mode 100644 index 00000000000..4d7879cc6dc --- /dev/null +++ b/sys/arch/amiga/stand/boot/alloc.s @@ -0,0 +1,60 @@ +/* + * $OpenBSD: alloc.s,v 1.1 1997/01/16 09:26:23 niklas Exp $ + * $NetBSD: alloc.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Memory allocation through exec library. + */ + + .globl _SysBase + .globl _alloc +_alloc: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),d0 + movl #0x50001,d1 | MEMF_CLEAR|MEMF_REVERSE|MEMF_PUBLIC for now. + jsr a6@(-0xc6) + movl sp@+,a6 + rts + + .globl _free +_free: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + movl sp@(12),d0 + jsr a6@(-0xd2) + movl sp@+,a6 + rts + diff --git a/sys/arch/amiga/stand/boot/amigagraph.h b/sys/arch/amiga/stand/boot/amigagraph.h new file mode 100644 index 00000000000..7d3c619b3a0 --- /dev/null +++ b/sys/arch/amiga/stand/boot/amigagraph.h @@ -0,0 +1,80 @@ +/* + * $OpenBSD: amigagraph.h,v 1.1 1997/01/16 09:26:24 niklas Exp $ + * $NetBSD: amigagraph.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef AMIGA_GRAPH_H +#define AMIGA_GRAPH_H + +#define SA_Title 0x80000028 +#define SA_Colors 0x80000029 + +#define SA_Sysfont 0x8000002C +#define SA_Type 0x8000002D + +#define SA_DisplayID 0x80000032 +#define SA_ShowTitle 0x80000036 +#define SA_Quiet 0x80000038 +#define SA_AutoScroll 0x80000039 +#define SA_Pens 0x8000003A + +#define PUBLICSCREEN 2 +#define CUSTOMSCREEN 0xF + +#define WA_Left 0x80000064 +#define WA_Top 0x80000065 +#define WA_Width 0x80000066 +#define WA_Height 0x80000067 +#define WA_DetailPen 0x80000068 +#define WA_BlockPen 0x80000069 +#define WA_IDCMP 0x8000006A +#define WA_Flags 0x8000006B +#define WA_Gadgets 0x8000006C +#define WA_Checkmark 0x8000006D +#define WA_Title 0x8000006E +#define WA_ScreenTitle 0x8000006F +#define WA_CustomScreen 0x80000070 +#define WA_SuperBitMap 0x80000071 +#define WA_MinWidth 0x80000072 +#define WA_MinHeight 0x80000073 +#define WA_MaxWidth 0x80000074 +#define WA_MaxHeight 0x80000075 +#define WA_Backdrop 0x80000085 +#define WA_Borderless 0x80000088 +#define WA_Activate 0x80000089 +#define WA_AutoAdjust 0x80000090 + +struct Window { + u_int8_t dum1[136]; +}; +#endif AMIGA_GRAPH_H diff --git a/sys/arch/amiga/stand/boot/amigaio.h b/sys/arch/amiga/stand/boot/amigaio.h new file mode 100644 index 00000000000..bc94f0f6454 --- /dev/null +++ b/sys/arch/amiga/stand/boot/amigaio.h @@ -0,0 +1,79 @@ +/* + * $OpenBSD: amigaio.h,v 1.1 1997/01/16 09:26:25 niklas Exp $ + * $NetBSD: amigaio.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * This describes the IO parameter block used by many standard + * Amiga OS device drivers. + */ +#ifndef AMIGA_IO_H +#define AMIGA_IO_H + +struct AmigaIO { + u_int8_t dum0[28]; + u_int16_t cmd; + u_int8_t flags; + int8_t err; + u_int32_t actual, /* transferred */ + length; /* please transfer this much */ + void *buf; /* data buffer */ + u_int32_t offset; /* offset for block devices */ +}; + +struct TimerIO { + u_int8_t dum0[28]; + u_int16_t cmd; + u_int8_t flags; + int8_t err; + u_int32_t secs, + usec; +}; + +/* flags */ +#define QuickIO 0x1 + +/* commands */ +#define Cmd_Rst 0x1 +#define Cmd_Rd 0x2 +#define Cmd_Wr 0x3 +#define Cmd_Upd 0x4 +#define Cmd_Clr 0x5 +#define Cmd_Stp 0x6 +#define Cmd_Strt 0x7 +#define Cmd_Flsh 0x8 + +#define Cmd_Addtimereq 0x9 + +#endif /* AMIGA_IO_H */ diff --git a/sys/arch/amiga/stand/boot/amigatypes.h b/sys/arch/amiga/stand/boot/amigatypes.h new file mode 100644 index 00000000000..bbdb6d0ee41 --- /dev/null +++ b/sys/arch/amiga/stand/boot/amigatypes.h @@ -0,0 +1,84 @@ +/* + * $OpenBSD: amigatypes.h,v 1.1 1997/01/16 09:26:26 niklas Exp $ + * $NetBSD: amigatypes.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _AMIGA_TYPES_H_ +#define _AMIGA_TYPES_H_ + +/* Dummy structs, used only as abstract pointers */ + +struct Library; +struct TextAttr; +struct Gadget; +struct BitMap; +struct NewScreen; +struct MemNode; + +/* real structs */ + +struct TagItem {u_int32_t item; void * data;}; + +struct Library { + u_int8_t Dmy1[20]; + u_int16_t Version, Revision; + u_int8_t Dmy2[34-24]; +}; + +struct MemHead { + struct MemHead *next; + u_int8_t Dmy1[ 9- 4]; + u_int8_t Pri; + u_int8_t Dmy2[ 14- 10]; + u_int16_t Attribs; + u_int32_t First, Lower, Upper, Free; +}; + +struct ExecBase { + struct Library LibNode; + u_int8_t Dmy1[296-34]; + u_int16_t AttnFlags; /* 296 */ + u_int8_t Dmy2[300-298]; /* 298 */ + void *ResModules; /* 300 */ + u_int8_t Dmy3[322-304]; /* 304 */ + struct MemHead *MemLst; /* 322 */ + /* + * XXX: actually, its a longer List base, but we only need to + * search it once. + */ + u_int8_t Dmy4[568-326]; /* 326 */ + u_int32_t EClockFreq; /* 330 */ + u_int8_t Dmy5[632-334]; +}; + +#endif /* _AMIGA_TYPES_H */ diff --git a/sys/arch/amiga/stand/boot/aout2bb/Makefile b/sys/arch/amiga/stand/boot/aout2bb/Makefile new file mode 100644 index 00000000000..7e03937714d --- /dev/null +++ b/sys/arch/amiga/stand/boot/aout2bb/Makefile @@ -0,0 +1,14 @@ +# $OpenBSD: Makefile,v 1.1 1997/01/16 09:26:47 niklas Exp $ + +PROG=aout2bb +SRCS=aout2bb.c chksum.c +NOMAN=notyet +INCLUDES=aout2bb.h chksum.h + +COPTS += -Wall -Wstrict-prototypes -g + + +ci: + ci -l $(SRCS) $(INCLUDES) Makefile + +.include <bsd.prog.mk> diff --git a/sys/arch/amiga/stand/boot/aout2bb/aout2bb.c b/sys/arch/amiga/stand/boot/aout2bb/aout2bb.c new file mode 100644 index 00000000000..3ef98391ecf --- /dev/null +++ b/sys/arch/amiga/stand/boot/aout2bb/aout2bb.c @@ -0,0 +1,340 @@ +/* + * $OpenBSD: aout2bb.c,v 1.1 1997/01/16 09:26:48 niklas Exp $ + * $NetBSD: aout2bb.c,v 1.2 1996/12/31 22:39:58 veego Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <sys/types.h> + +#include <err.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include <sys/mman.h> /* of the machine we're running on */ +#include <machine/endian.h> /* of the machine we're running on */ + +#include <sys/exec_aout.h> /* TARGET */ + +#include "aout2bb.h" +#include "chksum.h" + +void usage __P((void)); +int intcmp(const void *, const void *); +int main(int argc, char *argv[]); + +#ifdef DEBUG +#define dprintf(x) printf x +#else +#define dprintf(x) +#endif + +#define BBSIZE 8192 + +char *progname; +u_int8_t buffer[BBSIZE]; +u_int32_t relbuf[BBSIZE/sizeof(u_int32_t)]; + /* can't have more relocs than that*/ + +int +intcmp(i, j) + const void *i, *j; +{ + int r; + + r = (*(u_int32_t *)i) < (*(u_int32_t *)j); + + return 2*r-1; +} + +int +main(argc, argv) + int argc; + char *argv[]; +{ + int ifd, ofd; + u_int mid, flags, magic; + caddr_t image; + struct exec *eh; + struct relocation_info_m68k *rpi; + u_int32_t *lptr; + int i, delta; + u_int8_t *rpo; + u_int32_t oldaddr, addrdiff; + u_int32_t tsz, dsz, bsz, trsz, drsz, entry, relver; + int sumsize = 16; + int c; + + + progname = argv[0]; + + /* insert getopt here, if needed */ + while ((c = getopt(argc, argv, "F")) != -1) + switch(c) { + case 'F': + sumsize = 2; + break; + default: + usage(); + } + argv += optind; + argc -= optind; + + if (argc < 2) + usage(); + + ifd = open(argv[0], O_RDONLY, 0); + if (ifd < 0) + err(1, "Can't open %s", argv[0]); + + image = mmap(0, 65536, PROT_READ, MAP_FILE|MAP_PRIVATE, ifd, 0); + if (image == 0) + err(1, "Can't mmap %s", argv[1]); + + eh = (struct exec *)image; /* XXX endianness */ + + magic = N_GETMAGIC(*eh); + if (magic != OMAGIC) + errx(1, "%s isn't an OMAGIC file, but 0%o", argv[0], magic); + + flags = N_GETFLAG(*eh); + if (flags != 0) + errx(1, "%s has strange exec flags 0x%x", argv[0], flags); + + mid = N_GETMID(*eh); + switch(mid) { + case MID_M68K: + break; + default: + errx(1, "%s has strange machine id 0x%x (%d)", argv[0], mid, + mid); + } + + tsz = ntohl(eh->a_text); + dsz = ntohl(eh->a_data); + bsz = ntohl(eh->a_bss); + trsz = ntohl(eh->a_trsize); + drsz = ntohl(eh->a_drsize); + entry = ntohl(eh->a_entry); + + dprintf(("tsz = 0x%x, dsz = 0x%x, bsz = 0x%x, total 0x%x, entry=0x%x\n", + tsz, dsz, bsz, tsz+dsz+bsz, entry)); + + if ((trsz+drsz)==0) + errx(1, "%s has no relocation records.\n", argv[0]); + + dprintf(("%d text relocs, %d data relocs\n", trsz/8, drsz/8)); + if (entry != 12) + errx(1, "%s: entry point 0x%04x is not 0x000c\n", argv[0], + entry); + + /* + * We have one contiguous area allocated by the ROM to us. + */ + if (tsz+dsz+bsz > BBSIZE) + errx(1, "%s: resulting image too big\n", argv[0]); + + memset(buffer, sizeof(buffer), 0); + memcpy(buffer, image + N_TXTOFF(*eh), tsz+dsz); + + /* + * Hm. This tool REALLY should understand more than one + * relocator version. For now, check that the relocator at + * the image start does understand what we output. + */ + relver = ntohl(*(u_int32_t *)(image+0x24)); + switch (relver) { + default: + errx(1, "%s: unrecognized relocator version %d\n", + argv[0], relver); + /*NOTREACHED*/ + + case RELVER_RELATIVE_BYTES: + rpo = buffer + BBSIZE - 1; + delta = -1; + break; + + case RELVER_RELATIVE_BYTES_FORWARD: + rpo = buffer + tsz + dsz; + delta = +1; + *(u_int16_t *)(buffer + 14) = htons(tsz + dsz); + break; + } + + + + i = 0; + + for (rpi = (struct relocation_info_m68k *)(image+N_TRELOFF(*eh)); + (caddr_t)rpi < image+N_TRELOFF(*eh)+trsz; rpi++) { + + NTOHL(((u_int32_t *)rpi)[0]); + NTOHL(((u_int32_t *)rpi)[1]); + + dprintf(("0x%08x 0x%08x %c\n", *(u_int32_t *)rpi, + ((u_int32_t *)rpi)[1], rpi->r_extern ? 'U' : ' ')); + + if (rpi->r_extern) + errx(1, "code accesses unresolved symbol"); + if (rpi->r_copy) + errx(1, "code accesses r_copy symbol"); + if (rpi->r_jmptable) + errx(1, "code accesses r_jmptable symbol"); + if (rpi->r_relative) + errx(1, "code accesses r_relative symbol"); + if (rpi->r_baserel) + errx(1, "code accesses r_baserel symbol"); + + /* + * We don't worry about odd sized symbols which are pc + * relative, so test for pcrel first: + */ + + if (rpi->r_pcrel) + continue; + + if (rpi->r_length != 2) + errx(1, "code accesses size %d symbol", rpi->r_length); + + relbuf[i++] = rpi->r_address; + } + + for (rpi = (struct relocation_info_m68k *)(image+N_DRELOFF(*eh)); + (caddr_t)rpi < image+N_DRELOFF(*eh)+drsz; rpi++) { + + NTOHL(((u_int32_t *)rpi)[0]); + NTOHL(((u_int32_t *)rpi)[1]); + + dprintf(("0x%08x 0x%08x %c\n", *(u_int32_t *)rpi, + ((u_int32_t *)rpi)[1], rpi->r_extern ? 'U' : ' ')); + + if (rpi->r_extern) + errx(1, "data accesses unresolved symbol"); + if (rpi->r_copy) + errx(1, "data accesses r_copy symbol"); + if (rpi->r_jmptable) + errx(1, "data accesses r_jmptable symbol"); + if (rpi->r_relative) + errx(1, "data accesses r_relative symbol"); + if (rpi->r_baserel) + errx(1, "data accesses r_baserel symbol"); + + /* + * We don't worry about odd sized symbols which are pc + * relative, so test for pcrel first: + */ + + if (rpi->r_pcrel) + continue; + + if (rpi->r_length != 2) + errx(1, "data accesses size %d symbol", rpi->r_length); + + + relbuf[i++] = rpi->r_address + tsz; + } + printf("%d absolute reloc%s found, ", i, i==1?"":"s"); + + if (i > 1) + heapsort(relbuf, i, 4, intcmp); + + oldaddr = 0; + + for (--i; i>=0; --i) { + dprintf(("0x%04x: ", relbuf[i])); + lptr = (u_int32_t *)&buffer[relbuf[i]]; + addrdiff = relbuf[i] - oldaddr; + dprintf(("(0x%04x, 0x%04x): ", *lptr, addrdiff)); + if (addrdiff > 255) { + *rpo = 0; + if (delta > 0) { + ++rpo; + *rpo++ = (relbuf[i] >> 8) & 0xff; + *rpo++ = relbuf[i] & 0xff; + dprintf(("%02x%02x%02x\n", + rpo[-3], rpo[-2], rpo[-1])); + } else { + *--rpo = relbuf[i] & 0xff; + *--rpo = (relbuf[i] >> 8) & 0xff; + --rpo; + dprintf(("%02x%02x%02x\n", + rpo[0], rpo[1], rpo[2])); + } + } else { + *rpo = addrdiff; + dprintf(("%02x\n", *rpo)); + rpo += delta; + } + + oldaddr = relbuf[i]; + + if (delta < 0 ? rpo <= buffer+tsz+dsz + : rpo >= buffer + BBSIZE) + errx(1, "Relocs don't fit."); + } + *rpo = 0; rpo += delta; + *rpo = 0; rpo += delta; + *rpo = 0; rpo += delta; + + printf("using %d bytes.\n", delta > 0 ? + rpo-buffer-tsz-dsz : buffer+BBSIZE-rpo); + /* + * RELOCs must fit into the bss area. + */ + if (delta < 0 ? rpo <= buffer+tsz+dsz + : rpo >= buffer + BBSIZE) + errx(1, "Relocs don't fit."); + + ((u_int32_t *)buffer)[1] = 0; + ((u_int32_t *)buffer)[1] = + (0xffffffff - chksum((u_int32_t *)buffer, sumsize * 512 / 4)); + + ofd = open(argv[1], O_CREAT|O_WRONLY, 0644); + if (ofd < 0) + err(1, "Can't open %s", argv[1]); + + if (write(ofd, buffer, BBSIZE) != BBSIZE) + err(1, "Writing output file"); + + exit(0); +} + +void +usage() +{ + fprintf(stderr, "Usage: %s [-F] bootprog bootprog.bin\n", + progname); + exit(1); + /* NOTREACHED */ +} diff --git a/sys/arch/amiga/stand/boot/aout2bb/aout2bb.h b/sys/arch/amiga/stand/boot/aout2bb/aout2bb.h new file mode 100644 index 00000000000..59627748c24 --- /dev/null +++ b/sys/arch/amiga/stand/boot/aout2bb/aout2bb.h @@ -0,0 +1,71 @@ +/* + * $OpenBSD: aout2bb.h,v 1.1 1997/01/16 09:26:49 niklas Exp $ + * $NetBSD: aout2bb.h,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Relocator version definitions for aout to Amiga bootblock converter. + */ + +/* + * All the tables are at the end of the bootblock, with logical start at the + * end. + */ + +/* + * The following formats are for a length of 8 kBytes only. + */ + +/* + * Absolute words in Motorola byte order, end of table marked by 0x0000 + */ +#define RELVER_ABSOLUTE_WORDS 0 + +/* + * Unsigned bytes relative to previous address to relocate; first one to 0. + * If the difference is >255, the logical next two bytes (in Motorola byte + * order) give the absolute address to relocate. + */ +#define RELVER_RELATIVE_BYTES 1 + +/* + * Same as above, but with the bytes stored in forward direction beginning + * with the __relocation_bytes symbol + */ +#define RELVER_RELATIVE_BYTES_FORWARD 2 + +/* + * loader can autoload + */ + +#define RELFLAG_SELFLOADING 0x10 diff --git a/sys/arch/amiga/stand/boot/aout2bb/chksum.c b/sys/arch/amiga/stand/boot/aout2bb/chksum.c new file mode 100644 index 00000000000..1a857e69016 --- /dev/null +++ b/sys/arch/amiga/stand/boot/aout2bb/chksum.c @@ -0,0 +1,85 @@ +/* + * $OpenBSD: chksum.c,v 1.1 1997/01/16 09:26:50 niklas Exp $ + * $NetBSD: chksum.c,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> + +#include "chksum.h" + +u_int32_t +chksum(block, size) + u_int32_t *block; + int size; +{ + u_int32_t sum, lastsum; + int i; + + sum = 0; + + for (i=0; i<size; i++) { + lastsum = sum; + sum += block[i]; + if (sum < lastsum) + ++sum; + } + + return sum; +} + +#ifdef TESTSUM +u_int32_t myblock[8192]; + +int +main(int argc, char *argb[]) { + int bbsize; + u_int32_t cks, cks1; + + bbsize=atol(argb[1]); + bbsize *= (512 / sizeof (u_int32_t)); + + if (4*bbsize != read(0, myblock, sizeof(u_int32_t)*bbsize)) { + fprintf(stderr, "short read\n"); + exit(1); + } + fprintf(stderr, "Cksum field = 0x%x, ", myblock[1]); + cks = chksum(myblock, bbsize); + fprintf(stderr, "cksum = 0x%x\n", cks); + myblock[1] += 0xFFFFFFFF - cks; + fprintf(stderr, "New cksum field = 0x%x, ", myblock[1]); + cks1 = chksum(myblock, bbsize); + fprintf(stderr, "cksum = 0x%x\n", cks1); +} +#endif diff --git a/sys/arch/amiga/stand/boot/aout2bb/chksum.h b/sys/arch/amiga/stand/boot/aout2bb/chksum.h new file mode 100644 index 00000000000..34fddcf8cca --- /dev/null +++ b/sys/arch/amiga/stand/boot/aout2bb/chksum.h @@ -0,0 +1,39 @@ +/* + * $OpenBSD: chksum.h,v 1.1 1997/01/16 09:26:51 niklas Exp $ + * $NetBSD: chksum.h,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define CHKSUMOFFS 1 + +u_int32_t chksum __P((u_int32_t *, int)); + diff --git a/sys/arch/amiga/stand/boot/ashrdi3.s b/sys/arch/amiga/stand/boot/ashrdi3.s new file mode 100644 index 00000000000..419d66e588d --- /dev/null +++ b/sys/arch/amiga/stand/boot/ashrdi3.s @@ -0,0 +1,50 @@ +/* $OpenBSD: ashrdi3.s,v 1.1 1997/01/16 09:26:27 niklas Exp $ +/* $NetBSD: ashrdi3.s,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Slow but small ashrdi3. + */ + + .text + .even + .globl ___ashrdi3 +___ashrdi3: + movl d2,sp@- | 0 reg, 1 pc, 2..4 parameters + movml sp@(8),d0-d2 + jra L2 +L1: + asrl #1,d0 + roxrl #1,d1 +L2: + dbra d2,L1 + + movl sp@+,d2 + rts diff --git a/sys/arch/amiga/stand/boot/bbstart.s b/sys/arch/amiga/stand/boot/bbstart.s new file mode 100644 index 00000000000..c2512311142 --- /dev/null +++ b/sys/arch/amiga/stand/boot/bbstart.s @@ -0,0 +1,185 @@ +/* + * $OpenBSD: bbstart.s,v 1.1 1997/01/16 09:26:28 niklas Exp $ + * $NetBSD: bbstart.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "aout2bb/aout2bb.h" + +#define LVOAllocMem -0x0c6 +#define LVODoIO -0x1c8 +#define LVOCacheClearU -0x27c + +#define IOcmd 28 +#define IOerr 31 +#define IOlen 36 +#define IObuf 40 +#define IOoff 44 + +#define Cmd_Rd 2 + + .globl _configure + .globl _pain + + .text +Lzero: .asciz "DOS" | "DOS type" + /* + * We put the relocator version here, for aout2bb, which replaces + * it with the bootblock checksum. + */ +Chksum: .long RELVER_RELATIVE_BYTES_FORWARD +Filesz: .long 8192 | dummy + +/* + * Entry point from Kickstart. + * A1 points to an IOrequest, A6 points to ExecBase, we have a stack. + * _must_ be at offset 12. + */ + .globl _start +_start: +#ifdef AUTOLOAD + jra Lautoload +#else + jra Lrelocate +#endif + +Lreltab: + .word 0 | aout2bb puts the reloc table address here + +#ifdef AUTOLOAD +/* + * autoload + */ +Lautoload: + movl a6,sp@- |SysBase + movl a1,sp@- |IORequest + + movl #AUTOLOAD,d0 |Howmuch + movl d0,a1@(IOlen) | for the actual read... + movl #0x10001,d1 |MEMF_CLEAR|MEMF_PUBLIC + jsr a6@(LVOAllocMem) + movl sp@+,a1 |IORequest + movl sp@+,a6 |SysBase + orl d0,d0 + jne Lgotmem + movql #1,d0 + rts + +Lgotmem: + movl d0,sp@- |Address + movl a1@(IOoff),sp@- |Old offset + movl a1,sp@- + movl a6,sp@- + +/* we've set IOlen above */ + movl d0,a1@(IObuf) + movw #Cmd_Rd,a1@(IOcmd) + jsr a6@(LVODoIO) + + movl sp@+,a6 + movl sp@+,a1 + movl sp@+,a1@(IOoff) + + tstb a1@(IOerr) + jne Lioerr + addl #Lrelocate-Lzero,sp@ + + movl a6,sp@- + jsr a6@(LVOCacheClearU) + movl sp@+,a6 + rts +Lioerr: + movql #1,d0 + addql #4,sp + rts +#endif + +/* + * Relocate ourselves, at the same time clearing the relocation table + * (in case it overlaps with BSS). + * + * Register usage: + * A2: points into the reloc table, located at our end. + * A0: pointer to the longword to relocate. + * D0: word offset of longword to relocate + * D1: points to our start. + * + * Table has relative byte offsets, if a byte offset is zero, it is + * followed by an absolute word offset. If this is zero, too, table + * end is reached. + */ + +Lrelocate: + lea pc@(Lzero),a0 + movl a0,d1 + movw pc@(Lreltab),a2 + addl d1,a2 + jra Loopend + +Loopw: + clrw a2@+ + movl d1,a0 | for a variant with relative words, erase this line +Loopb: + addl d0,a0 + addl d1,a0@ +Loopend: + movq #0,d0 + movb a2@,d0 + clrb a2@+ | bfclr a2@+{0:8} is still two shorts + tstb d0 | we could save one short by using casb d0,d0,a2@+ + jne Loopb + + movw a2@,d0 + jne Loopw + +Lendtab: + movl a6,sp@- + jsr a6@(LVOCacheClearU) + movl sp@+,a6 + +/* We are relocated. Now it is safe to initialize _SysBase: */ + + movl a6,_SysBase + + movl a1,sp@- + bsr _configure + addql #4,sp + tstl d0 + jne Lerr + + bsr _pain + +Lerr: + movq #1,d0 + rts + + .comm _SysBase,4 diff --git a/sys/arch/amiga/stand/boot/bcopy.s b/sys/arch/amiga/stand/boot/bcopy.s new file mode 100644 index 00000000000..afb8fc4d4e5 --- /dev/null +++ b/sys/arch/amiga/stand/boot/bcopy.s @@ -0,0 +1,64 @@ +/* $OpenBSD: bcopy.s,v 1.1 1997/01/16 09:26:29 niklas Exp $ */ + +/* + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Small but possibly slow bcopy/memcpy combo. + */ + .text + .even +.globl _bcopy,_memcpy + +_memcpy: + movel sp@(4),a0 + movel sp@(8),a1 + jra Lcpy +_bcopy: + movel sp@(4),a1 + movel sp@(8),a0 +Lcpy: + movel sp@(12),d0 + jeq L1 + cmpl a1,a0 + jcc L3 +L4: + moveb a1@+,a0@+ + subql #1,d0 + jne L4 + rts +L3: + addl d0,a1 + addl d0,a0 +L9: + moveb a1@-,a0@- + subql #1,d0 + jne L9 +L1: + rts diff --git a/sys/arch/amiga/stand/boot/bzero.c b/sys/arch/amiga/stand/boot/bzero.c new file mode 100644 index 00000000000..11192df59a5 --- /dev/null +++ b/sys/arch/amiga/stand/boot/bzero.c @@ -0,0 +1,50 @@ +/* + * $OpenBSD: bzero.c,v 1.1 1997/01/16 09:26:30 niklas Exp $ + * $NetBSD: bzero.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Lightweight bzero. + */ + +#include <sys/types.h> +#include <string.h> + +void +bzero(p, len) + void *p; + size_t len; +{ + char *s = p; + while (len > 0) { + *s++ = 0; + --len; + } +} diff --git a/sys/arch/amiga/stand/boot/configure.c b/sys/arch/amiga/stand/boot/configure.c new file mode 100644 index 00000000000..05288594a21 --- /dev/null +++ b/sys/arch/amiga/stand/boot/configure.c @@ -0,0 +1,47 @@ +/* + * $OpenBSD: configure.c,v 1.1 1997/01/16 09:26:31 niklas Exp $ + * $NetBSD: configure.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <sys/types.h> + +#include "stand.h" +#include "samachdep.h" + +int +configure(aio) +void *aio; +{ + xdinit(aio); + return (consinit()); +} diff --git a/sys/arch/amiga/stand/boot/console.c b/sys/arch/amiga/stand/boot/console.c new file mode 100644 index 00000000000..d30af457d36 --- /dev/null +++ b/sys/arch/amiga/stand/boot/console.c @@ -0,0 +1,185 @@ +/* + * $OpenBSD: console.c,v 1.1 1997/01/16 09:26:32 niklas Exp $ + * $NetBSD: console.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Bootblock support routines for Intuition console support. + */ + +#include <sys/types.h> + +#include <stand.h> +#include "samachdep.h" + +#include "amigatypes.h" +#include "amigagraph.h" +#include "amigaio.h" +#include "libstubs.h" + +const u_int32_t screentags[] = { + SA_Type, CUSTOMSCREEN, + SA_DisplayID, 0x8000, + SA_ShowTitle, 0, + SA_Quiet, 1, + 0 +}; + +u_int32_t windowtags[] = { + WA_CustomScreen, 0L, + WA_Borderless, 1L, + WA_Backdrop, 1L, + WA_Activate, 1L, + 0 +}; + +struct AmigaIO *cnior; +struct TimerIO *tmior; +struct MsgPort *cnmp; + +u_int16_t timelimit; + +int +consinit() { + struct Screen *s = 0; + struct Window *w = 0; + + IntuitionBase = OpenLibrary("intuition.library", 36L); + if (IntuitionBase == 0) + goto err; + + s = OpenScreenTagList(0, screentags); + if (!s) + goto err; + + windowtags[1] = (u_int32_t)s; + w = OpenWindowTagList(0, windowtags); + if (!w) + goto err; + + cnmp = CreateMsgPort(); + + if (!cnmp) + goto err; + + cnior = (struct AmigaIO *)CreateIORequest(cnmp, sizeof(struct AmigaIO)); + if (!cnior) + goto err; + + cnior->buf = (void *)w; + if (OpenDevice("console.device", 0, cnior, 0)) + goto err; + + tmior = (struct TimerIO *)CreateIORequest(cnmp, sizeof(struct TimerIO)); + if (!tmior) + goto err; + + if (OpenDevice("timer.device", 0, (struct AmigaIO*)tmior, 0)) + goto err; + + return 0; + +err: +#ifdef notyet + if (tmior) + DeleteIORequest(tmior); + + if (cnior) + DeleteIORequest(cnior); + + if (cnmp) + DeleteMsgPort(cnmp); + + if (w) + CloseWindow(w); + + if (s) + CloseScreen(s); + if (IntuitionBase) + CloseLibrary(IntuitionBase); +#endif + + return 1; +} + +void +putchar(c) + char c; +{ + cnior->length = 1; + cnior->buf = &c; + cnior->cmd = Cmd_Wr; + (void)DoIO(cnior); +} + +void +puts(s) + char *s; +{ + cnior->length = -1; + cnior->buf = s; + cnior->cmd = Cmd_Wr; + (void)DoIO(cnior); +} + +int +getchar() +{ + struct AmigaIO *ior; + char c = -1; + + cnior->length = 1; + cnior->buf = &c; + cnior->cmd = Cmd_Rd; + + SendIO(cnior); + + if (timelimit) { + tmior->cmd = Cmd_Addtimereq; + tmior->secs = timelimit; + tmior->usec = 2; /* Paranoid */ + SendIO((struct AmigaIO *)tmior); + + ior = WaitPort(cnmp); + if (ior == cnior) + AbortIO((struct AmigaIO *)tmior); + else /* if (ior == tmior) */ { + AbortIO(cnior); + c = '\n'; + } + WaitIO((struct AmigaIO *)tmior); + timelimit = 0; + } + (void)WaitIO(cnior); + return c; +} diff --git a/sys/arch/amiga/stand/boot/installboot.8 b/sys/arch/amiga/stand/boot/installboot.8 new file mode 100644 index 00000000000..b3c1f2c7c03 --- /dev/null +++ b/sys/arch/amiga/stand/boot/installboot.8 @@ -0,0 +1,122 @@ +.\" $OpenBSD: installboot.8,v 1.1 1997/01/16 09:26:33 niklas Exp $ +.\" $NetBSD: installboot.8,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ +.\" +.\" Copyright (c) 1995 Paul Kranenburg +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Paul Kranenburg. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 29, 1996 +.Dt INSTALLBOOT 8 +.Os +.Sh NAME +.Nm installboot +.Nd install a bootstrap on an FFS filesystem partition +.Sh SYNOPSIS +.Nm installboot +.Ar bootblock +.Ar device +.Sh DESCRIPTION +.Nm installboot +copies the bootblock to a bootable partition. The +bootstrap is written into the bootblock area on the partition, right +in front of the superblock, and hence limited in size to +8192 bytes. +.Pp +The bootstrap resides in the first few blocks on the partition +.Pq as specified by Commodore-Amiga Inc. +The bootstrap is loaded into memory by the ROM from bootable devices: +RDB devices, where the partition is marked as bootable, or (not on the +DraCo) floppy disks in Amiga format (880K/1760k). +.Pp +In presence of more than one bootable partiton/floppy disk, the partition +is chosen by the bootpriority (from the RDB), which can be overridden by +the operator from the boot menu (on Amiga machines, hold down the outer +mouse buttons during boot; on DraCo machines, press the left mouse button +when prompted). +.Pp +On RDB devices, the whole bootblock is loaded by the ROM. The number of +boot blocks in the RDB partition entry must be correct. +.Pp +On floppy disks, the ROM always loads the first two blocks (1024 bytes), +and the bootblock allocates memory and loads the whole bootblock on startup. +.Pp +After receiving control, the bootblock uses the stand-alone +filesystem code in +.Dq libsa.a +to load the kernel from the filesystem on the partition it was started from. +The code for the boot program can be found in +.Pa /usr/mdec/fdboot +.Pq floppy disk code +or +.Pa /usr/mdec/xxboot +.Pq generic RDB disk code . +.Pp +The arguments are: +.Bl -tag -width bootblock +.It Ar bootblock +The file containing the bootblock (normally /usr/mdec/xxboot for RDB devices). +.It Ar device +The name of the character special device specifying the partition on which the +bootstrap is to be installed. +.El +.Sh EXAMPLES +The following command will install the +boot program in the bootblock area on +.Dq sd0a : +.Bd -literal -offset indent +installboot /usr/mdec/xxboot /dev/rsd0a +.Ed +.Sh CAVEATS +If +.Nm +is used on the whole disk partition, the RDB will be overwritten. +.Pp +Some third-party accellerator boards are not auto-configuring. You won't +be able to use their memory when booting from the bootblock after a cold +start. +.Pp +Some third-party disk controllers don't support bootblock booting. +.Pp +Phase 5 68060 boards don't set the SysBase->AttnFlags bit for the 68060 +CPU (a patch program which is called during AmigaOS startup does this). +Currently, +.Tn OpenBSD +is not able to detect this condition, and will fail. +.Sh BUGS +There is currently no easy way to edit the RDB from within +.Tn OpenBSD. +.Pp +As normal dd is used to install the bootblock, you can only install onto +your currently used root (or any other mounted) partiton from single-user +mode, or while otherwise running in insecure mode. +.Sh "SEE ALSO" +.Xr dd 1 +.Sh HISTORY +The +.Nm +command first appeared in +.Nx 1.3 diff --git a/sys/arch/amiga/stand/boot/installboot.sh b/sys/arch/amiga/stand/boot/installboot.sh new file mode 100644 index 00000000000..642e941e734 --- /dev/null +++ b/sys/arch/amiga/stand/boot/installboot.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# $OpenBSD: installboot.sh,v 1.1 1997/01/16 09:26:34 niklas Exp $ +# $NetBSD: installboot.sh,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + +# compatibility with old installboot program +# +# @(#)installboot.sh 8.1 (Berkeley) 6/10/93 +# +if [ $# != 2 ] +then + echo "Usage: installboot bootprog device" + exit 1 +fi +if [ ! -f $1 ] +then + echo "Usage: installboot bootprog device" + echo "${1}: bootprog must be a regular file" + exit 1 +fi +if [ ! -c $2 ] +then + echo "Usage: installboot bootprog device" + echo "${2}: device must be a char special file" + exit 1 +fi +#/sbin/disklabel -B -b $1 $2 +dd if=$1 of=$2 bs=512 count=16 +exit $? diff --git a/sys/arch/amiga/stand/boot/libsa/Makefile b/sys/arch/amiga/stand/boot/libsa/Makefile new file mode 100644 index 00000000000..f6a3ee7fa06 --- /dev/null +++ b/sys/arch/amiga/stand/boot/libsa/Makefile @@ -0,0 +1,46 @@ +# $OpenBSD: Makefile,v 1.1 1997/01/16 09:26:53 niklas Exp $ +# $NetBSD: Makefile,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + +LIB= sa + +DIR_SA = ${.CURDIR}/../../../../../lib/libsa +DIR_KERN = ${.CURDIR}/../../../../../lib/libkern +DIR_KERN_MD = ${.CURDIR}/../../../../../lib/libkern/arch/$(MACHINE_ARCH) + +TXLT = ${.CURDIR}/../txlt/txlt + +.PATH: $(DIR_SA) $(DIR_KERN) $(DIR_KERN_MD) + +CFLAGS+=-DSTANDALONE -DINSECURE ${DEBUGFLAGS} +# -DCOMPAT_UFS +CFLAGS+=-I${.CURDIR}/../../../../.. -I${.CURDIR}/../../../../../lib/libsa +CFLAGS+=-O2 -fomit-frame-pointer -fno-function-cse -m68060 -Wa,-l -Wa,-m68030 +CFLAGS+=$(COPTS) + +# stand routines +SRCS= gets.c +# memcpy.c bcopy.c strerror.c + +# io routines +SRCS+= close.c lseek.c open.c read.c dev.c + +# dev.c stat.c + +# boot filesystems +SRCS+= ufs.c + +# kernlib routines +SRCS+= strlen.S strcmp.S +#$(DIR_KERN)/bcmp.c + + +#ashrdi3.c bzero.S muldi3.S + +NOPROFILE= +NOPIC= +OBJMACHINE= + +install: + +.include <bsd.lib.mk> +.include "../Makefile.txlt" diff --git a/sys/arch/amiga/stand/boot/libsa/Makefile.inc b/sys/arch/amiga/stand/boot/libsa/Makefile.inc new file mode 100644 index 00000000000..35aeea68879 --- /dev/null +++ b/sys/arch/amiga/stand/boot/libsa/Makefile.inc @@ -0,0 +1,24 @@ +# $OpenBSD: Makefile.inc,v 1.1 1997/01/16 09:26:54 niklas Exp $ +# $NetBSD: Makefile.inc,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + +# NOTE: $S must correspond to the top of the 'sys' tree + +SA_DIR= $S/arch/amiga/stand/boot/libsa + +.if exists($(SA_DIR)/obj.${MACHINE}) +SA_LIBDIR= $(SA_DIR)/obj.${MACHINE} +.else +SA_LIBDIR= $(SA_DIR) +.endif + +SA_LIB= $(SA_LIBDIR)/libsa.a + +$(SA_LIB): .NOTMAIN __always_make_sa_lib + @echo making sure the stand-alone library is up to date... + @(cd $(SA_DIR) ; make) + +clean:: .NOTMAIN __always_make_sa_lib + @echo cleaning the stand-alone library objects + @(cd $(SA_DIR) ; make clean) + +__always_make_sa_lib: .NOTMAIN diff --git a/sys/arch/amiga/stand/boot/libstubs.h b/sys/arch/amiga/stand/boot/libstubs.h new file mode 100644 index 00000000000..73d93ef9b22 --- /dev/null +++ b/sys/arch/amiga/stand/boot/libstubs.h @@ -0,0 +1,94 @@ +/* + * $OpenBSD: libstubs.h,v 1.1 1997/01/16 09:26:35 niklas Exp $ + * $NetBSD: libstubs.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "amigaio.h" +#include "amigagraph.h" +#include "amigatypes.h" +#include <sys/types.h> + +extern struct ExecBase *SysBase; +extern struct Library *IntuitionBase; +extern struct Library *ExpansionBase; + +void *AllocMem (size_t, u_int32_t); +void FreeMem (void *, size_t); + +struct Library *OpenLibrary (const char *, u_int32_t); +void CloseLibrary (struct Library *); +struct MsgPort *CreateMsgPort(void); +void *CreateIORequest(struct MsgPort *, u_int32_t); +void DeleteIORequest(void *); +void DeleteMsgPort(struct MsgPort *); + +u_int8_t DoIO(struct AmigaIO *); +void SendIO(struct AmigaIO *); +struct AmigaIO *CheckIO(struct AmigaIO *); +void *WaitPort(struct MsgPort *); +void AbortIO(struct AmigaIO *); +u_int8_t WaitIO(struct AmigaIO *); + +int OpenDevice(const char *, u_int32_t, struct AmigaIO *, u_int32_t); + +void *FindResident(const char *); +void *OpenResource(const char *); + +u_int32_t CachePreDMA(u_int32_t, u_int32_t *, int); +#define DMAF_Continue 2 +#define DMAF_NoModify 4 +#define DMAF_ReadFromRAM 8 + +void Forbid(void); +void Permit(void); + +struct Screen *OpenScreenTagList(struct NewScreen *, const u_int32_t *); +struct Screen *OpenScreenTag(struct NewScreen *, ...); +struct Window *OpenWindowTagList(struct Window *, const u_int32_t *); +struct Window *OpenWindowTag(struct Window *, ...); + +#ifdef nomore +u_int32_t mytime(void); +#endif + +struct cfdev *FindConfigDev(struct cfdev *, int, int); + +#ifndef DOINLINES +void CacheClearU(void); +#else +#define LibCallNone(lib, what) \ + asm("movl a6,sp@-; movl %0,a6; " what "; movl sp@+,a6" :: \ + "r"(lib) : "d0", "d1", "a0", "a1") + +#define CacheClearU() LibCallNone(SysBase, "jsr a6@(-0x27c)") +#endif diff --git a/sys/arch/amiga/stand/boot/libstubs.s b/sys/arch/amiga/stand/boot/libstubs.s new file mode 100644 index 00000000000..d1dbe36e6c4 --- /dev/null +++ b/sys/arch/amiga/stand/boot/libstubs.s @@ -0,0 +1,269 @@ +/* + * $OpenBSD: libstubs.s,v 1.1 1997/01/16 09:26:36 niklas Exp $ + * $NetBSD: libstubs.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Exec.library functions. + */ + .comm _SysBase,4 + + .globl _OpenLibrary +_OpenLibrary: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + movl sp@(12),d0 + jsr a6@(-0x228) + movl sp@+,a6 + rts +#ifdef notyet + .globl _CloseLibrary +_CloseLibrary: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x19e) + movl sp@+,a6 + rts +#endif + .globl _CreateIORequest +_CreateIORequest: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + movl sp@(12),d0 + jsr a6@(-0x28e) + movl sp@+,a6 + rts + + .globl _CreateMsgPort +_CreateMsgPort: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + jsr a6@(-0x29a) + movl sp@+,a6 + rts + +#ifdef notyet + .globl _DeleteMsgPort +_DeleteMsgPort: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + jsr a6@(-0x2a0) + movl sp@+,a6 + rts + + .globl _DeleteIORequest +_DeleteIORequest: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + jsr a6@(-0x294) + movl sp@+,a6 + rts +#endif + + .globl _OpenDevice +_OpenDevice: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + movl sp@(12),d0 + movl sp@(16),a1 + movl sp@(20),d1 + jsr a6@(-0x1bc) + movl sp@+,a6 + rts + + .globl _DoIO +_DoIO: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1c8) + movl sp@+,a6 + rts +#ifdef nomore + .globl _CheckIO +_CheckIO: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1d4) + movl sp@+,a6 + rts +#endif + .globl _WaitIO +_WaitIO: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1da) + movl sp@+,a6 + rts + + .globl _SendIO +_SendIO: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1ce) + movl sp@+,a6 + rts + + .globl _AbortIO +_AbortIO: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1e0) + movl sp@+,a6 + rts + + .globl _WaitPort +_WaitPort: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + jsr a6@(-0x180) + movl sp@+,a6 + rts + +#ifndef DOINLINES + .globl _CacheClearU +_CacheClearU: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + jsr a6@(-0x27c) + movl sp@+,a6 + rts +#endif + .globl _CachePreDMA +_CachePreDMA: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a0 + movl sp@(12),a1 + movl sp@(16),d0 + jsr a6@(-0x2fa) + movl sp@+,a6 + rts + + .globl _FindResident +_FindResident: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x60) + movl sp@+,a6 + rts + + .globl _OpenResource +_OpenResource: + movl a6,sp@- + movl pc@(_SysBase:w),a6 + movl sp@(8),a1 + jsr a6@(-0x1f2) + movl sp@+,a6 + rts +#ifdef notyet + .globl _Forbid +_Forbid: + movl a6,sp@- + movl pc@(_SysBase:W),a6 + jsr a6@(-0x84) + movl sp@+,a6 + rts + + .globl _Permit +_Permit: + movl a6,sp@- + movl pc@(_SysBase:W),a6 + jsr a6@(-0x8a) + movl sp@+,a6 + rts +#endif + +/* + * Intuition.library functions. + */ + + .comm _IntuitionBase,4 + + .globl _OpenScreenTagList +_OpenScreenTagList: + movl a6,sp@- + movl pc@(_IntuitionBase:w),a6 + movl sp@(8),a0 + movl sp@(12),a1 + jsr a6@(-0x264) + movl sp@+,a6 + rts + + .globl _OpenWindowTagList +_OpenWindowTagList: + movl a6,sp@- + movl pc@(_IntuitionBase:w),a6 + movl sp@(8),a0 + movl sp@(12),a1 + jsr a6@(-0x25e) + movl sp@+,a6 + rts +#ifdef nomore + .globl _mytime +_mytime: + movl a6,sp@- + movl pc@(_IntuitionBase:w),a6 + subql #8,sp + movl sp,a0 + lea sp@(4),a1 + jsr a6@(-0x54) + movl sp@+,d0 + addql #4,sp + movl sp@+,a6 + rts +#endif + .comm _ExpansionBase,4 + .globl _FindConfigDev +_FindConfigDev: + movl a6,sp@- + movl _ExpansionBase,a6 + movl sp@(8),a0 + movl sp@(12),d0 + movl sp@(16),d1 + jsr a6@(-0x48) + movl sp@+,a6 + rts diff --git a/sys/arch/amiga/stand/boot/main.c b/sys/arch/amiga/stand/boot/main.c new file mode 100644 index 00000000000..431468423bf --- /dev/null +++ b/sys/arch/amiga/stand/boot/main.c @@ -0,0 +1,566 @@ +/* + * $OpenBSD: main.c,v 1.1 1997/01/16 09:26:38 niklas Exp $ + * $NetBSD: main.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * + * Copyright (c) 1996 Ignatios Souvatzis + * Copyright (c) 1994 Michael L. Hitch + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael L. Hitch. + * 4. The name of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <sys/cdefs.h> +#include <sys/reboot.h> +#include <sys/types.h> + +#include <sys/exec_aout.h> + +#include <amiga/cfdev.h> +#include <amiga/memlist.h> +#include <include/cpu.h> + +#include "saerrno.h" +#include "stand.h" + +#include "libstubs.h" +#include "samachdep.h" + +#define __LDPGSZ 8192 +#define __PGSZ 8192 + +#define DRACOREVISION (*(u_int8_t *)0x02000009) +#define DRACOMMUMARGIN 0x200000 +#define DRACOZ2OFFSET 0x3000000 +#define DRACOZ2MAX 0x1000000 + +#define EXECMIN 36 + +void startit __P((void *, u_long, u_long, void *, u_long, u_long, int, void *, + int, int, u_long, u_long, int)); +void startit_end __P((void)); +int get_cpuid __P((u_int32_t *)); + +/* + * Kernel startup interface version + * 1: first version of loadbsd + * 2: needs esym location passed in a4 + * 3: load kernel image into fastmem rather than chipmem + * MAX: highest version with backward compatibility. + */ + +#define KERNEL_STARTUP_VERSION 3 +#define KERNEL_STARTUP_VERSION_MAX 9 + +static long get_number(char **); + +const char version[] = "2.0"; +char default_command[] = "openbsd -Sn2"; + +int +pain() +{ + long int io = 0; + char linebuf[128]; + char *kernel_name = default_command; + char *path = default_command; + int boothowto = RB_AUTOBOOT; + u_int32_t cpuid = 0; + int amiga_flags = 0; + u_int32_t I_flag = 0; + int k_flag = 0; + int p_flag = 0; + int Z_flag = 0; + int m_value = 0; + int S_flag = 0; + int t_flag = 0; + long stringsz; + + u_int32_t fmem = 0x0; + int fmemsz = 0x0; + int cmemsz = 0x0; + int eclock = SysBase->EClockFreq; + /* int skip_chipmem = 0; */ + + void (*start_it)(void *, u_long, u_long, void *, u_long, u_long, int, + void *, int, int, u_long, u_long, int) = startit; + + caddr_t kp; + u_int16_t *kvers; + struct exec *eh; + int textsz, ksize; + void *esym = 0; + int32_t *nkcd; + struct cfdev *cd, *kcd; + struct boot_memseg *kmemseg; + struct boot_memseg *memseg; + struct MemHead *mh; + u_int32_t from, size, vfrom, vsize; + int contflag, mapped1to1; + + int ncd, nseg; + char c; + + extern u_int16_t timelimit; + + /* + * we need V36 for: EClock, RDB Bootblocks, CacheClearU + */ + + if (SysBase->LibNode.Version < EXECMIN) { + printf("Exec V%ld, need V%ld\n", + (long)SysBase->LibNode.Version, (long)EXECMIN); + goto out; + } + + printf("\2337mOpenBSD/Amiga bootblock %s\2330m\n%s :- ", + version, kernel_name); + + timelimit = 3; + gets(linebuf); + + if (*linebuf == 'q') + return 1; + + if (*linebuf) + path = linebuf; + + /* + * parse boot command for path name and process any options + */ + while ((c = *path)) { + while (c == ' ') + c = *++path; + if (c == '-') { + while ((c = *++path) && c != ' ') { + switch (c) { + case 'a': /* multi-user state */ + boothowto &= ~RB_SINGLE; + break; + case 'b': /* ask for root device */ + boothowto |= RB_ASKNAME; + break; + case 'c': /* force machine model */ + cpuid = get_number(&path) << 16; + break; + case 'k': /* Reserve first 4M fastmem */ + k_flag++; + break; + case 'm': /* Force fastmem size */ + m_value = get_number(&path) * 1024; + break; + case 'n': /* non-contiguous memory */ + amiga_flags |= + (get_number(&path) & 3) << 1; + break; + case 'p': /* Select fastmem by priority */ + p_flag++; + break; + case 's': /* single-user state */ + boothowto |= RB_SINGLE; + break; + case 't': /* test flag */ + t_flag = 1; + break; + case 'A': /* enable AGA modes */ + amiga_flags |= 1; + break; + case 'D': /* enter Debugger */ + boothowto |= RB_KDB; + break; + case 'I': /* inhibit sync negotiation */ + I_flag = get_number(&path); + break; + case 'K': /* remove 1st 4MB fastmem */ + break; + case 'S': /* include debug symbols */ + S_flag = 1; + break; + case 'Z': /* force chip memory load */ + Z_flag = 1; + break; + } + } + } else { + kernel_name = path; + while ((c = *++path) && c != ' ') + ; + if (c) + *path++ = 0; + } + } + while ((c = *kernel_name) && c == ' ') + ++kernel_name; + path = kernel_name; + while ((c = *path) && c != ' ') + ++path; + if (c) + *path = 0; + + if (get_cpuid(&cpuid)) + goto out; + + ExpansionBase = OpenLibrary("expansion.library", 0); + if (!ExpansionBase) { + printf("can't open %s\n", "expansion.library"); + return 1; + } + + for (ncd=0, cd=0; (cd = FindConfigDev(cd, -1, -1)); ncd++) + /* nothing */; + + /* find memory list */ + + memseg = (struct boot_memseg *)alloc(16*sizeof(struct boot_memseg)); + + /* Forbid(); */ + + nseg = 0; + mh = SysBase->MemLst; + vfrom = mh->Lower & -__PGSZ; + vsize = (mh->Upper - vfrom) & -__PGSZ; + contflag = mapped1to1 = 0; + + do { + size = vsize; + + if (SysBase->LibNode.Version > 36) { + from = CachePreDMA(vfrom, &size, contflag); + contflag = DMAF_Continue; + mapped1to1 = (from == vfrom); + vsize -= size; + vfrom += size; + } else { + from = vfrom; + vsize = 0; + } + +#if DEBUG_MEMORY_LIST + printf("%lx %lx %lx %ld/%lx %lx\n", + (long)from, (long)size, + (long)mh->Attribs, (long)mh->Pri, + (long)vfrom, (long)vsize); +#endif + /* Insert The Evergrowing Kludge List Here: */ + + /* a) dont load kernel over DraCo MMU table */ + + if (((cpuid >> 24) == 0x7D) && + ((from & -DRACOMMUMARGIN) == 0x40000000) && + (size >= DRACOMMUMARGIN)) { + + memseg[nseg].ms_start = from & -DRACOMMUMARGIN; + memseg[nseg].ms_size = DRACOMMUMARGIN; + memseg[nseg].ms_attrib = mh->Attribs; + memseg[nseg].ms_pri = mh->Pri; + + size -= DRACOMMUMARGIN - (from & (DRACOMMUMARGIN - 1)); + from += DRACOMMUMARGIN - (from & (DRACOMMUMARGIN - 1)); + ++nseg; + } + + if ((mh->Attribs & (MEMF_CHIP|MEMF_FAST)) == MEMF_CHIP) { + size += from; + cmemsz = size;; + from = 0; + } else if ((fmemsz < size) && mapped1to1) { + fmem = from; + fmemsz = size; + } + + memseg[nseg].ms_start = from; + memseg[nseg].ms_size = size; + memseg[nseg].ms_attrib = mh->Attribs; + memseg[nseg].ms_pri = mh->Pri; + + if (vsize == 0) { + mh = mh->next; + contflag = 0; + if (mh->next) { + vfrom = mh->Lower & -__PGSZ; + vsize = (mh->Upper & -__PGSZ) - vfrom; + } + } + } while ((++nseg <= 16) && vsize); + + /* Permit(); */ + + printf("Loading %s: ", kernel_name); + io = open(kernel_name, 0); + if (io < 0) + goto err; + + eh = alloc(sizeof(*eh)); + if (!eh) { + errno = ENOMEM; + goto err; + } + if (read(io, eh, sizeof(*eh)) != sizeof(*eh)) { + errno = ENOEXEC; + goto err; + } + + if ((N_GETMAGIC(*eh) != NMAGIC) || (N_GETMID(*eh) != MID_M68K)) { + errno = ENOEXEC; + goto err; + } + + textsz = (eh->a_text + __LDPGSZ - 1) & (-__LDPGSZ); + esym = 0; + + ksize = textsz + eh->a_data + eh->a_bss + + sizeof(*nkcd) + ncd*sizeof(*cd) + + sizeof(*nkcd) + nseg * sizeof(struct boot_memseg); + + if (S_flag && eh->a_syms) { + if (lseek(io, eh->a_text+ eh->a_data+ eh->a_syms, SEEK_CUR) + <= 0 + || read(io, &stringsz, 4) != 4 + || lseek(io, sizeof(*eh), SEEK_SET) < 0) + goto err; + ksize += eh->a_syms + 4 + ((stringsz + 3) & ~3); + } + + kp = alloc(ksize + 256 + ((u_char *)startit_end - (u_char *)startit)); + if (kp == 0) { + errno = ENOMEM; + goto err; + } + + printf("%ld", eh->a_text); + if (read(io, kp, eh->a_text) != eh->a_text) + goto err; + + printf("+%ld", eh->a_data); + if (read(io, kp + textsz, eh->a_data) != eh->a_data) + goto err; + + printf("+%ld", eh->a_bss); + + kvers = (u_short *)(kp + eh->a_entry - 2); + + if (*kvers > KERNEL_STARTUP_VERSION_MAX && *kvers != 0x4e73) { + printf("\nnewer bootblock required: %ld\n", (long)*kvers); + goto freeall; + } +#if 0 + if (*kvers > KERNEL_STARTUP_VERSION) + printf("\nKernel V%ld newer than bootblock V%ld\n", + (long)*kvers, (long)KERNEL_STARTUP_VERSION); +#endif + nkcd = (int *)(kp + textsz + eh->a_data + eh->a_bss); + if (*kvers != 0x4e73 && *kvers > 1 && S_flag && eh->a_syms) { + *nkcd++ = eh->a_syms; + printf("+[%ld", eh->a_syms); + if (read(io, (char *)nkcd, eh->a_syms) != eh->a_syms) + goto err; + nkcd = (int *)((char *)nkcd + eh->a_syms); + printf("+%ld]", stringsz); + if (read(io, (char *)nkcd, stringsz) != stringsz) + goto err; + nkcd = (int*)((char *)nkcd + ((stringsz + 3) & ~3)); + esym = (char *)(textsz + eh->a_data + eh->a_bss + + eh->a_syms + 4 + ((stringsz + 3) & ~3)); + } + putchar('\n'); + + *nkcd = ncd; + kcd = (struct cfdev *)(nkcd + 1); + + while ((cd = FindConfigDev(cd, -1, -1))) { + *kcd = *cd; + if (((cpuid >> 24) == 0x7D) && + ((u_long)kcd->addr < 0x1000000)) { + kcd->addr += 0x3000000; + } + ++kcd; + } + + nkcd = (u_int32_t *)kcd; + *nkcd = nseg; + + kmemseg = (struct boot_memseg *)(nkcd + 1); + + while (nseg-- > 0) + *kmemseg++ = *memseg++; + + if (*kvers > 2 && Z_flag == 0) { + /* + * Kernel supports direct load to fastmem, and the -Z + * option was not specified. Copy startup code to end + * of kernel image and set start_it. + */ + if ((u_int32_t)kp < fmem) { + errno = EFBIG; + goto err; + } + memcpy(kp + ksize + 256, (char *)startit, + (char *)startit_end - (char *)startit); + CacheClearU(); + (caddr_t)start_it = kp + ksize + 256; + printf("*** Loading from %08lx to Fastmem %08lx ***\n", + (u_long)kp, (u_long)fmem); + /* sleep(2); */ + } else { + /* + * Either the kernel doesn't suppport loading directly to + * fastmem or the -Z flag was given. Verify kernel image + * fits into chipmem. + */ + if (ksize >= cmemsz) { + printf("Kernel size %d exceeds Chip Memory of %d\n", + ksize, cmemsz); + return 20; + } + Z_flag = 1; + printf("*** Loading from %08lx to Chipmem ***\n", (u_long)kp); + } + +#if 0 + printf("would start(kp=0x%lx, ksize=%ld, entry=0x%lx,\n" + "fmem=0x%lx, fmemsz=%ld, cmemsz=%ld\n" + "boothow=0x%lx, esym=0x%lx, cpuid=0x%lx, eclock=%ld\n" + "amigaflags=0x%lx, I_flags=0x%lx, Zflag=%ld, ok?\n", + (u_long)kp, (u_long)ksize, eh->a_entry, + (u_long)fmem, (u_long)fmemsz, (u_long)cmemsz, + (u_long)boothowto, (u_long)esym, (u_long)cpuid, (u_long)eclock, + (u_long)amiga_flags, (u_long)I_flag, (u_long)(Z_flag == 0)); +#endif + timelimit = 2; + (void)getchar(); + + start_it(kp, ksize, eh->a_entry, (void *)fmem, fmemsz, cmemsz, + boothowto, esym, cpuid, eclock, amiga_flags, I_flag, Z_flag == 0); + /*NOTREACHED*/ + +freeall: + free(kp, ksize); + free(eh, sizeof(*eh)); +err: + printf("\nError %ld\n", (long)errno); + close(io); +out: + timelimit = 10; + (void)getchar(); + return 1; +} + +static +long get_number(ptr) +char **ptr; +{ + long value = 0; + int base = 10; + char *p = *ptr; + char c; + char sign = 0; + + c = *++p; + while (c == ' ') + c = *++p; + if (c == '-') { + sign = -1; + c = *++p; + } + if (c == '$') { + base = 16; + c = *++p; + } else if (c == '0') { + c = *++p; + if ((c & 0xdf) == 'X') { + base = 16; + c = *++p; + } + } + while (c) { + if (c >= '0' && c <= '9') + c -= '0'; + else { + c = (c & 0xdf) - 'A' + 10; + if (base != 16 || c < 10 || c > 15) + break; + } + value = value * base + c; + c = *++p; + } + *ptr = p - 1; +#ifdef TEST + fprintf(stderr, "get_number: got %c0x%x", + sign ? '-' : '+', value); +#endif + return (sign ? -value : value); +} + +/* + * Try to determine the machine ID by searching the resident module list + * for modules only present on specific machines. (Thanks, Bill!) + */ + +int +get_cpuid(cpuid) + u_int32_t *cpuid; +{ + *cpuid |= SysBase->AttnFlags; /* get FPU and CPU flags */ + if (*cpuid & 0xffff0000) { + if ((*cpuid >> 24) == 0x7D) + return 0; + + switch (*cpuid >> 16) { + case 500: + case 600: + case 1000: + case 1200: + case 2000: + case 3000: + case 4000: + return 0; + default: + printf("Amiga %ld ???\n", + (long)(*cpuid >> 16)); + return(1); + } + } + if (FindResident("A4000 Bonus") || FindResident("A4000 bonus") + || FindResident("A1000 Bonus")) + *cpuid |= 4000 << 16; + else if (FindResident("A3000 Bonus") || FindResident("A3000 bonus") + || (SysBase->LibNode.Version == 36)) + *cpuid |= 3000 << 16; + else if (OpenResource("card.resource")) { + /* Test for AGA? */ + *cpuid |= 1200 << 16; + } else if (OpenResource("draco.resource")) { + *cpuid |= (32000 | DRACOREVISION) << 16; + } + /* + * Nothing found, it's probably an A2000 or A500 + */ + if ((*cpuid >> 16) == 0) + *cpuid |= 2000 << 16; + + return 0; +} diff --git a/sys/arch/amiga/stand/boot/muldi3.s b/sys/arch/amiga/stand/boot/muldi3.s new file mode 100644 index 00000000000..d2003ff5a4d --- /dev/null +++ b/sys/arch/amiga/stand/boot/muldi3.s @@ -0,0 +1,63 @@ +/* $OpenBSD: muldi3.s,v 1.1 1997/01/16 09:26:39 niklas Exp $ +/* $NetBSD: muldi3.s,v 1.1.1.1 1996/11/29 23:36:30 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Slow but small muldi3. + * Beware... the multiplicand is unsigned (but should be enough for + * usage by ufs.c :-) + */ + + .text + .even + .globl ___muldi3 +___muldi3: + movml d2/d3/d4/d5/d6,sp@- | 0..4 regs, 5 pc, 6..9 parameters + movml sp@(24),d2-d5 +| movl sp@(24),d2 +| movl sp@(28),d3 +| movl sp@(32),d4 +| movl sp@(36),d5 + movq #0,d0 + movq #0,d1 + movq #63,d6 +L4: + asrl #1,d2 + roxrl #1,d3 + jcc L5 + addl d5,d1 + addxl d4,d0 +L5: + addl d5,d5 + addxl d4,d4 +L7: + dbra d6,L4 + movml sp@+,d2/d3/d4/d5/d6 + rts diff --git a/sys/arch/amiga/stand/boot/printf.s b/sys/arch/amiga/stand/boot/printf.s new file mode 100644 index 00000000000..a49a597342a --- /dev/null +++ b/sys/arch/amiga/stand/boot/printf.s @@ -0,0 +1,76 @@ +/* + * $OpenBSD: printf.s,v 1.1 1997/01/16 09:26:40 niklas Exp $ + * $NetBSD: printf.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * printf calling exec's RawDoFmt + * Beware! You have to explicitly use %ld etc. for 32bit integers! + */ + .text + .globl _printf + .globl _putchar, _SysBase + +Lputch: + movl d0,sp@- + bsr _putchar + addql #4,sp + rts + +_printf: + movml #0x0032,sp@- + lea pc@(Lputch:w),a2 + lea sp@(20),a1 + movl sp@(16),a0 + movl pc@(_SysBase:w),a6 + jsr a6@(-0x20a) + movml sp@+, #0x4c00 + rts +#if 0 +Lstorech: + movb d0, a3@+ + rts + + .globl _sprintf +_sprintf: + movml #0x0032,sp@- + movl sp@(16),a3 + lea pc@(Lstorech:w),a2 + lea sp@(24),a1 + movl sp@(20),a0 + movl pc@(_SysBase:w),a6 + jsr a6@(-0x20a) + movml sp@+, #0x4c00 + rts +#endif diff --git a/sys/arch/amiga/stand/boot/samachdep.h b/sys/arch/amiga/stand/boot/samachdep.h new file mode 100644 index 00000000000..57ca2285ef9 --- /dev/null +++ b/sys/arch/amiga/stand/boot/samachdep.h @@ -0,0 +1,51 @@ +/* + * $OpenBSD: samachdep.h,v 1.1 1997/01/16 09:26:41 niklas Exp $ + * $NetBSD: samachdep.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _SA_MACHDEP_H_ +#define _SA_MACHDEP_H_ + +/* "hardware" init: */ + +int configure(void *); +int pain(void); + +/* console functions not declared MI: */ + +int consinit(void); +void puts(char *); + +void xdinit(void *); + +#endif diff --git a/sys/arch/amiga/stand/boot/startit.s b/sys/arch/amiga/stand/boot/startit.s new file mode 100644 index 00000000000..a8dd10c9c2f --- /dev/null +++ b/sys/arch/amiga/stand/boot/startit.s @@ -0,0 +1,235 @@ +/* $OpenBSD: startit.s,v 1.1 1997/01/16 09:26:41 niklas Exp $ */ +/* $NetBSD: startit.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ */ + +/* + * Copyright (c) 1996 Ignatios Souvatzis + * Copyright (c) 1994 Michael L. Hitch + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael L. Hitch. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * + * From: $NetBSD: startit.s,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + */ + + .set ABSEXECBASE,4 + + .text + + .globl _startit + .globl _startit_end + +_startit: +#if TESTONAMIGA + movew #0x999,0xdff180 | gray +#endif + movel sp,a3 + movel 4:w,a6 + lea pc@(start_super:w),a5 + jmp a6@(-0x1e) | supervisor-call + +start_super: +#if TESTONAMIGA + movew #0x900,0xdff180 | dark red +#endif + movew #0x2700,sr + + | the BSD kernel wants values into the following registers: + | a0: fastmem-start + | d0: fastmem-size + | d1: chipmem-size + | d3: Amiga specific flags + | d4: E clock frequency + | d5: AttnFlags (cpuid) + | d7: boothowto + | a4: esym location + | a2: Inhibit sync flags + | All other registers zeroed for possible future requirements. + + lea pc@(_startit:w),sp | make sure we have a good stack *** + + movel a3@(4),a1 | loaded kernel + movel a3@(8),d2 | length of loaded kernel +| movel a3@(12),sp | entry point in stack pointer + movel a3@(12),a6 | entry point *** + movel a3@(16),a0 | fastmem-start + movel a3@(20),d0 | fastmem-size + movel a3@(24),d1 | chipmem-size + movel a3@(28),d7 | boothowto + movel a3@(32),a4 | esym + movel a3@(36),d5 | cpuid + movel a3@(40),d4 | E clock frequency + movel a3@(44),d3 | Amiga flags + movel a3@(48),a2 | Inhibit sync flags + movel a3@(52),d6 | Load to fastmem flag + subl a5,a5 | target, load to 0 + + cmpb #0x7D,a3@(36) | is it DraCo? + beq nott | yes, switch off MMU later + + | no, it is an Amiga: + +#if TESTONAMIGA + movew #0xf00,0xdff180 |red +#endif +| moveb #0,0x200003c8 +| moveb #63,0x200003c9 +| moveb #0,0x200003c9 +| moveb #0,0x200003c9 + + movew #(1<<9),0xdff096 | disable DMA on Amigas. + +| ------ mmu off start ----- + + btst #3,d5 | AFB_68040,SysBase->AttnFlags + beq not040 + +| Turn off 68040/060 MMU + + subl a3,a3 + .word 0x4e7b,0xb003 | movec a3,tc + .word 0x4e7b,0xb806 | movec a3,urp + .word 0x4e7b,0xb807 | movec a3,srp + .word 0x4e7b,0xb004 | movec a3,itt0 + .word 0x4e7b,0xb005 | movec a3,itt1 + .word 0x4e7b,0xb006 | movec a3,dtt0 + .word 0x4e7b,0xb007 | movec a3,dtt1 + bra nott + +not040: + lea pc@(zero:w),a3 + pmove a3@,tc | Turn off MMU + lea pc@(nullrp:w),a3 + pmove a3@,crp | Turn off MMU some more + pmove a3@,srp | Really, really, turn off MMU + +| Turn off 68030 TT registers + + btst #2,d5 | AFB_68030,SysBase->AttnFlags + beq nott | Skip TT registers if not 68030 + lea pc@(zero:w),a3 + .word 0xf013,0x0800 | pmove a3@,tt0 (gas only knows about 68851 ops..) + .word 0xf013,0x0c00 | pmove a3@,tt1 (gas only knows about 68851 ops..) + +nott: +| ---- mmu off end ---- +#if TESTONAMIGA + movew #0xf60,0xdff180 | orange +#endif +| moveb #0,0x200003c8 +| moveb #63,0x200003c9 +| moveb #24,0x200003c9 +| moveb #0,0x200003c9 + +| ---- copy kernel start ---- + + tstl d6 | Can we load to fastmem? + beq L0 | No, leave destination at 0 + movl a0,a5 | Move to start of fastmem chunk + addl a0,a6 | relocate kernel entry point +L0: + movl a1@+,a5@+ + subl #4,d2 + bcc L0 + + lea pc@(ckend:w),a1 + movl a5,sp@- + pea pc@(_startit_end:w) +L1: + movl a1@+,a5@+ + cmpl sp@,a1 + bcs L1 + addql #4,sp + + btst #3,d5 + jeq L2 + .word 0xf4f8 +L2: movql #0,d2 | switch off cache to ensure we use + movec d2,cacr | valid kernel data + +#if TESTONAMIGA + movew #0xFF0,0xdff180 | yellow +#endif +| moveb #0,0x200003c8 +| moveb #63,0x200003c9 +| moveb #0,0x200003c9 +| moveb #0,0x200003c9 + + rts + +| ---- copy kernel end ---- + +ckend: +#if TESTONAMIGA + movew #0x0ff,0xdff180 | petrol +#endif +| moveb #0,0x200003c8 +| moveb #0,0x200003c9 +| moveb #63,0x200003c9 +| moveb #63,0x200003c9 + + movl d5,d2 + roll #8,d2 + cmpb #0x7D,d2 + jne noDraCo + +| DraCo: switch off MMU now: + + subl a3,a3 + .word 0x4e7b,0xb003 | movec a3,tc + .word 0x4e7b,0xb806 | movec a3,urp + .word 0x4e7b,0xb807 | movec a3,srp + .word 0x4e7b,0xb004 | movec a3,itt0 + .word 0x4e7b,0xb005 | movec a3,itt1 + .word 0x4e7b,0xb006 | movec a3,dtt0 + .word 0x4e7b,0xb007 | movec a3,dtt1 + +noDraCo: + moveq #0,d2 | zero out unused registers + moveq #0,d6 | (might make future compatibility + movel d6,a1 | would have known contents) + movel d6,a3 + movel d6,a5 + movel a6,sp | entry point into stack pointer + movel d6,a6 + +#if TESTONAMIGA + movew #0x0F0,0xdff180 | green +#endif +| moveb #0,0x200003c8 +| moveb #0,0x200003c9 +| moveb #63,0x200003c9 +| moveb #0,0x200003c9 + + jmp sp@ | jump to kernel entry point + + +| A do-nothing MMU root pointer (includes the following long as well) + +nullrp: .long 0x7fff0001 +zero: .long 0 + +_startit_end: diff --git a/sys/arch/amiga/stand/boot/test.s b/sys/arch/amiga/stand/boot/test.s new file mode 100644 index 00000000000..e5abdd9d4bb --- /dev/null +++ b/sys/arch/amiga/stand/boot/test.s @@ -0,0 +1,7 @@ + .text + .globl _start +_start: + lea pc@(bla),a0 + movq #1,d0 + rts + .globl bla diff --git a/sys/arch/amiga/stand/boot/twiddle.c b/sys/arch/amiga/stand/boot/twiddle.c new file mode 100644 index 00000000000..bd07e47cb57 --- /dev/null +++ b/sys/arch/amiga/stand/boot/twiddle.c @@ -0,0 +1,52 @@ +/* $OpenBSD: twiddle.c,v 1.1 1997/01/16 09:26:44 niklas Exp $ */ +/* $NetBSD: twiddle.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)printf.c 8.1 (Berkeley) 6/11/93 + */ + +/* From: $NetBSD: twiddle.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ */ + +#include "stand.h" + +const static char chars[4] = {'|', '/', '-', '\\'}; + +void +twiddle() +{ + static short int pos; + + putchar(chars[pos++ & 3]); + putchar('\b'); +} diff --git a/sys/arch/amiga/stand/boot/txlt/Makefile b/sys/arch/amiga/stand/boot/txlt/Makefile new file mode 100644 index 00000000000..8a13db5974c --- /dev/null +++ b/sys/arch/amiga/stand/boot/txlt/Makefile @@ -0,0 +1,10 @@ +# $OpenBSD: Makefile,v 1.1 1997/01/16 09:26:55 niklas Exp $ + +PROG=txlt +NOMAN=noman +LDADD=-ll +CLEANFILES+=txlt.c + +install: + +.include <bsd.prog.mk> diff --git a/sys/arch/amiga/stand/boot/txlt/txlt.l b/sys/arch/amiga/stand/boot/txlt/txlt.l new file mode 100644 index 00000000000..a9156778644 --- /dev/null +++ b/sys/arch/amiga/stand/boot/txlt/txlt.l @@ -0,0 +1,19 @@ + void munchit(char *); +%% +\..*\n printf("%s", yytext); +pea[ ][_A-Za-z][A-Za-z0-9_]*$ {printf("pea");munchit(yytext+3);} +\ [_A-Za-z][A-Za-z0-9_]*/\, munchit(yytext); +. putchar(*yytext); +%% +void +munchit(s) + char *s; +{ + putchar(*s++); + if (!strncmp(s, "fp", 2) || + !strncmp(s, "sp", 2) || + ((*s == 'a') || (*s == 'd')) && ((s[1]-'0')<=7)) + printf("%s", s); + else + printf("pc@(%s)",s); +} diff --git a/sys/arch/amiga/stand/boot/xd.c b/sys/arch/amiga/stand/boot/xd.c new file mode 100644 index 00000000000..b3831842c60 --- /dev/null +++ b/sys/arch/amiga/stand/boot/xd.c @@ -0,0 +1,157 @@ +/* + * $OpenBSD: xd.c,v 1.1 1997/01/16 09:26:45 niklas Exp $ + * $NetBSD: xd.c,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis. + * Copyright (c) 1995 Waldi Ravens. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Waldi Ravens. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/types.h> + +#include <stand.h> +#include <ufs.h> + + +#include "samachdep.h" +#include "amigaio.h" +#include "libstubs.h" + +static int xdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); +static int xdopen __P((struct open_file *, ...)); +static int xdclose __P((struct open_file *)); +static int xdioctl __P((struct open_file *, u_long, void *)); + +static u_int32_t aio_base; +static struct AmigaIO *aio_save; + +static struct devsw devsw[] = { + { "xd", xdstrategy, xdopen, xdclose, xdioctl } +}; + +struct fs_ops file_system[] = { + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, +}; + +int nfsys = sizeof(file_system)/sizeof(struct fs_ops); + + + +/* called from configure */ + +void +xdinit(aio) + void *aio; +{ + aio_save = aio; + aio_base = aio_save->offset; +} + +/* + * Kernel ist loaded from device and partition the kickstart + * menu or boot priority has chosen: + */ + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + f->f_devdata = aio_save; + f->f_dev = &devsw[0]; + *file = (char *)fname; + return 0; +} + +/* tell kickstart to do the real work */ + +static int +xdstrategy (devd, flag, dblk, size, buf, rsize) + void *devd; + int flag; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct AmigaIO *aio = (struct AmigaIO *)devd; + + if (flag != F_READ) + return EIO; + + aio->cmd = Cmd_Rd; + aio->length = size; + aio->offset = aio_base + (dblk << 9); + aio->buf = buf; + +#ifdef XDDEBUG + printf("strategy called: %ld(%ld), %ld, 0x%lx\n", + (long)dblk, (long)aio->offset, (long)size, (unsigned long)buf); +#endif + + DoIO(aio); + +#ifdef XDDEBUG + printf("strategy got err %ld, rsize %ld\n", aio->err, aio->actual); +#endif + + if (aio->err) { + *rsize = 0; + return EIO; + } + + *rsize = aio->actual; + return 0; +} + + +/* nothing do do for these: */ + +static int +xdopen(f) + struct open_file *f; +{ + return 0; +} + +static int +xdclose(f) + struct open_file *f; +{ + return 0; +} + +static int +xdioctl (f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return EIO; +} diff --git a/sys/arch/amiga/stand/boot/xd.h b/sys/arch/amiga/stand/boot/xd.h new file mode 100644 index 00000000000..c50a64bb174 --- /dev/null +++ b/sys/arch/amiga/stand/boot/xd.h @@ -0,0 +1,48 @@ +/* + * $OpenBSD: xd.h,v 1.1 1997/01/16 09:26:45 niklas Exp $ + * $NetBSD: xd.h,v 1.1.1.1 1996/11/29 23:36:29 is Exp $ + * + * Copyright (c) 1996 Ignatios Souvatzis + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Ignatios Souvatzis + * for the NetBSD project. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * Prototypes for eXec disks: + */ + +#ifndef _XD_H_ +#define _XD_H_ + +#include <sys/types.h> + +void xdinit (void *); +int xdstrategy (void *, int, daddr_t, size_t, void *, size_t *); + +#endif |