From: deraadt Date: Wed, 6 Dec 1995 10:54:54 +0000 (+0000) Subject: various changes to once again shrink the bootblocks to a useable size. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=794a0830fa2f86263af15acb9202268b427ee816;p=openbsd various changes to once again shrink the bootblocks to a useable size. --- diff --git a/sys/arch/mvme68k/stand/bootsd/Makefile b/sys/arch/mvme68k/stand/bootsd/Makefile index 2f23f3f4f57..779cbea0989 100644 --- a/sys/arch/mvme68k/stand/bootsd/Makefile +++ b/sys/arch/mvme68k/stand/bootsd/Makefile @@ -1,5 +1,5 @@ # from: @(#)Makefile 8.1 (Berkeley) 6/10/93 -# $Id: Makefile,v 1.1.1.1 1995/10/18 10:44:12 deraadt Exp $ +# $Id: Makefile,v 1.2 1995/12/06 10:54:54 deraadt Exp $ RELOC=0x3F0000 @@ -31,11 +31,18 @@ all: ${ALL} devopen.o machdep.o: Makefile bootsd.bug: ${OBJS} ${BUGCRT} ${LIBS} - ${LD} -s -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ + ${LD} -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ @size bootsd.bug bootsd sdboot: bootsd.bug ${WRTVID} - ${WRTVID} bootsd.bug + cp bootsd.bug bootsd.bin + strip bootsd.bin + @if [ `size bootsd.bin | awk 'BEGIN {getline} {print $$1+$$2;}'` -gt 7168 ];\ + then\ + echo BOOTBLOCKS ARE TOO BIG;\ + fail;\ + fi + ${WRTVID} bootsd.bin install: install -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} diff --git a/sys/arch/mvme68k/stand/bootsd/boot.c b/sys/arch/mvme68k/stand/bootsd/boot.c index b9d476e49f2..b10b16b5f75 100644 --- a/sys/arch/mvme68k/stand/bootsd/boot.c +++ b/sys/arch/mvme68k/stand/bootsd/boot.c @@ -1,4 +1,4 @@ -/* $Id: boot.c,v 1.4 1995/11/07 08:50:34 deraadt Exp $ */ +/* $Id: boot.c,v 1.5 1995/12/06 10:54:55 deraadt Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -71,9 +71,8 @@ #include #include "stand.h" -void reset_twiddle __P((void)); void copyunix __P((int io, char *addr)); -void parse_args __P((struct mvmeprom_args *pargs)); +void parse_args __P((void)); int debug; int netif_debug; @@ -87,7 +86,7 @@ u_long esym; char *strtab; int strtablen; #if 0 -struct nlist *nlp, *enlp; +struct nlist *nlp, *enlp; #endif struct kernel { @@ -102,11 +101,10 @@ struct kernel { u_int end_loaded; } kernel; -struct mvmeprom_args *bugargs; +extern struct mvmeprom_args bugargs; int -main(pp) - struct mvmeprom_args *pp; +main() { struct exec x; char *file; @@ -115,17 +113,16 @@ main(pp) printf(">> OpenBSD sdboot [%s]\n", version); - bugargs = pp; - parse_args(pp); + parse_args(); file = kernel.kname; - if ((io = open(file, 0)) < 0) { + io = open(file, 0); + if (io < 0) { printf("Can't open %s: %s\n", file, strerror(errno)); mvmeprom_return(); } i = read(io, (char *)&x, sizeof(x)); - if (i != sizeof(x) || - N_BADMAG(x)) { + if (i != sizeof(x) || N_BADMAG(x)) { printf("Bad format\n"); return (0); } @@ -133,9 +130,7 @@ main(pp) addr = (void *)(x.a_entry & ~0x0FFF); lseek(io, 0, SEEK_SET); - reset_twiddle(); - - printf("booting %s load address 0x%x\n", file, addr); + /*printf("load %s to 0x%x\n", file, addr);*/ copyunix(io, addr); return (0); } @@ -146,18 +141,16 @@ copyunix(io, addr) int io; char *addr; { - struct exec x; - int i; void (*entry)() = (void (*)())addr; + struct exec x; + int i, cnt; i = read(io, (char *)&x, sizeof(x)); - if (i != sizeof(x) || - N_BADMAG(x)) { + if (i != sizeof(x) || N_BADMAG(x)) { printf("Bad format\n"); return; } - reset_twiddle(); printf("%x", x.a_text); if (N_GETMAGIC(x) == ZMAGIC) { kernel.entry = entry = (void *)x.a_entry; @@ -169,12 +162,10 @@ copyunix(io, addr) if (N_GETMAGIC(x) == NMAGIC) while ((int)addr & CLOFSET) *addr++ = 0; - reset_twiddle(); printf("+%x", x.a_data); if (read(io, addr, x.a_data) != x.a_data) goto shread; addr += x.a_data; - reset_twiddle(); printf("+%x", x.a_bss); for (i = 0; i < x.a_bss; i++) *addr++ = 0; @@ -191,25 +182,17 @@ copyunix(io, addr) #if 0 enlp = (struct nlist *)(strtab = addr); #endif - reset_twiddle(); if (read(io, &strtablen, sizeof(int)) != sizeof(int)) goto shread; - reset_twiddle(); bcopy(&strtablen, addr, sizeof(int)); if (i = strtablen) { i -= sizeof(int); addr += sizeof(int); - { - int cnt; - cnt = read(io, addr, i); - if (cnt != i) - /* - goto shread; - */printf("symwarn"); - } - reset_twiddle(); + cnt = read(io, addr, i); + if (cnt != i) + printf("symwarn"); /* goto shread; */ addr += i; } printf("%x]", i); @@ -256,115 +239,62 @@ printf("end_loaded %x\n",kernel.end_loaded); #endif printf("start at 0x%x\n", (int)entry); -#if 0 - if (kernel.bflags & RB_HALT) { - mvmeprom_return(); - } -#endif if (((u_long)entry &0xf) == 0x2) { - (entry)(bugargs, &kernel); + (entry)(&bugargs, &kernel); } else { - /* is type fixing anything like price fixing? */ - typedef (* kernel_start)(int, int, void *,void *, void *); - kernel_start addr; - addr = (void *)entry; - (addr)(kernel.bflags,0,kernel.esym,kernel.smini,kernel.emini); + /* is type fixing anything like price fixing? */ + typedef (* kernel_start) __P((int, int, void *,void *, void *)); + kernel_start addr; + addr = (void *)entry; + (addr)(kernel.bflags, 0, kernel.esym, kernel.smini, kernel.emini); } return; -shread: - printf("Short read\n"); -} -#define NO_TWIDDLE_FUNC - -#ifndef NO_TWIDDLE_FUNC -static int tw_on; -static int tw_pos; -static char tw_chars[] = "|/-\\"; -#endif - -void -reset_twiddle() -{ -#ifndef NO_TWIDDLE_FUNC - if (tw_on) - putchar('\b'); - tw_on = 0; - tw_pos = 0; -#endif -} -#ifndef NO_TWIDDLE_FUNC -void -twiddle() -{ - if (tw_on) - putchar('\b'); - else - tw_on = 1; - putchar(tw_chars[tw_pos++]); - tw_pos %= (sizeof(tw_chars) - 1); +shread: + printf("short read\n"); } -#endif -#if 0 -void -_rtt() -{ - mvmeprom_return(); -} -#endif +struct flags { + char c; + short bit; +} bf[] = { + { 'a', RB_ASKNAME }, + { 'b', RB_HALT }, + { 'y', RB_NOSYM }, + { 'd', RB_KDB }, + { 'm', RB_MINIROOT }, + { 'r', RB_DFLTROOT }, + { 's', RB_SINGLE }, +}; void -parse_args(pargs) - struct mvmeprom_args *pargs; +parse_args() { - char *ptr = pargs->arg_start; - char *name = "/bsd"; + char *name = "/bsd", *ptr; + int i, howto = 0; char c; - int howto = 0; - if (pargs->arg_start != pargs->arg_end) { + if (bugargs.arg_start == bugargs.arg_end) { + ptr = bugargs.arg_start; while (c = *ptr) { while (c == ' ') c = *++ptr; - if (!c) + if (c == '\0') return; - if (c == '-') - while ((c = *++ptr) && c != ' ') { - if (c == 'a') - howto |= RB_ASKNAME; - else if (c == 'b') - howto |= RB_HALT; - else if (c == 'y') - howto |= RB_NOSYM; - else if (c == 'd') - howto |= RB_KDB; - else if (c == 'm') - howto |= RB_MINIROOT; - else if (c == 'r') - howto |= RB_DFLTROOT; - else if (c == 's') - howto |= RB_SINGLE; - } - else { + if (c != '-') { name = ptr; - while ((c = *++ptr) && c != ' '); + while ((c = *++ptr) && c != ' ') + ; if (c) *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++) + if (bf[i].c == c) + howto |= bf[i].bit; } } -#if 0 - if (RB_NOSYM & howto) printf("RB_NOSYM\n\r"); - if (RB_AUTOBOOT & howto) printf("RB_AUTOBOOT\n\r"); - if (RB_SINGLE & howto) printf("RB_SINGLE\n\r"); - if (RB_NOSYNC & howto) printf("RB_NOSYNC\n\r"); - if (RB_HALT & howto) printf("RB_HALT\n\r"); - if (RB_DFLTROOT & howto) printf("RB_DFLTROOT\n\r"); - if (RB_KDB & howto) printf("RB_KDB\n\r"); - if (RB_RDONLY & howto) printf("RB_RDONLY\n\r"); - if (RB_DUMP & howto) printf("RB_DUMP\n\r"); - if (RB_MINIROOT & howto) printf("RB_MINIROOT\n\r"); -#endif } kernel.bflags = howto; kernel.kname = name; diff --git a/sys/arch/mvme68k/stand/bootsd/bugdev.c b/sys/arch/mvme68k/stand/bootsd/bugdev.c index 65b9287ce65..82776ab4c3a 100644 --- a/sys/arch/mvme68k/stand/bootsd/bugdev.c +++ b/sys/arch/mvme68k/stand/bootsd/bugdev.c @@ -1,4 +1,4 @@ -/* $Id: bugdev.c,v 1.3 1995/11/07 08:50:35 deraadt Exp $ */ +/* $Id: bugdev.c,v 1.4 1995/12/06 10:54:55 deraadt Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -47,7 +47,7 @@ struct devsw devsw[] = { }; int ndevs = (sizeof(devsw)/sizeof(devsw[0])); -extern struct mvmeprom_args *bugargs; +extern struct mvmeprom_args bugargs; int errno; struct bugsc_softc { @@ -58,8 +58,6 @@ struct bugsc_softc { short dev; } bugsc_softc[1]; -static struct disklabel sdlabel; - int devopen(f, fname, file) struct open_file *f; @@ -70,8 +68,9 @@ devopen(f, fname, file) int error, i, dn = 0, pn = 0; char *dev, *cp; static char iobuf[MAXBSIZE]; + struct disklabel sdlabel; - dev = bugargs->arg_start; + dev = bugargs.arg_start; /* * Extract partition # from boot device string. @@ -96,14 +95,8 @@ devopen(f, fname, file) return (EINVAL); cputobsdlabel(&sdlabel, (struct cpu_disklabel *)iobuf); - if (0) { - printf("WARNING: no label\n"); - /* XXX set some default label */ - return (EINVAL); - } else { - pp->poff = sdlabel.d_partitions[pn].p_offset; - pp->psize = sdlabel.d_partitions[pn].p_size; - } + pp->poff = sdlabel.d_partitions[pn].p_offset; + pp->psize = sdlabel.d_partitions[pn].p_size; f->f_dev = devsw; f->f_devdata = (void *)pp; @@ -126,8 +119,6 @@ bugscstrategy(devdata, func, dblk, size, buf, rsize) struct mvmeprom_dskio dio; register struct bugsc_softc *pp = (struct bugsc_softc *)devdata; daddr_t blk = dblk + pp->poff; - int error = 0; - short status = 0; twiddle(); @@ -150,15 +141,9 @@ bugscstrategy(devdata, func, dblk, size, buf, rsize) printf("rsize %d status %x\n", *rsize, dio.status); #endif - switch (dio.status) { - case 0: - error = 0; - break; - default: - error = EIO; - break; - } - return (error); + if (dio.status) + return (EIO); + return (0); } int @@ -170,8 +155,8 @@ bugscopen(f) #endif f->f_devdata = (void *)bugsc_softc; - bugsc_softc[0].ctrl = bugargs->ctrl_lun; - bugsc_softc[0].dev = bugargs->dev_lun; + bugsc_softc[0].ctrl = (short)bugargs.ctrl_lun; + bugsc_softc[0].dev = (short)bugargs.dev_lun; printf("using mvmebug ctrl %d dev %d\n", bugsc_softc[0].ctrl, bugsc_softc[0].dev); return (0); diff --git a/sys/arch/mvme68k/stand/bootsd/version.c b/sys/arch/mvme68k/stand/bootsd/version.c index a24a3e1bf3a..c30b7d2320e 100644 --- a/sys/arch/mvme68k/stand/bootsd/version.c +++ b/sys/arch/mvme68k/stand/bootsd/version.c @@ -1,9 +1,8 @@ -/* $Id: version.c,v 1.2 1995/11/07 08:50:37 deraadt Exp $ */ +/* $Id: version.c,v 1.3 1995/12/06 10:54:56 deraadt Exp $ */ /* - * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. - * - * 1.1 + * make a random change to this file when you want the bootblock + * revision to increase. like change this x to a y, or something. */ -char *version = "$Revision: 1.2 $"; +char *version = "$Revision: 1.3 $"; diff --git a/sys/arch/mvme68k/stand/bugcrt/Makefile b/sys/arch/mvme68k/stand/bugcrt/Makefile index ddec528cd28..6348eb31d5d 100644 --- a/sys/arch/mvme68k/stand/bugcrt/Makefile +++ b/sys/arch/mvme68k/stand/bugcrt/Makefile @@ -1,6 +1,6 @@ -# $Id: Makefile,v 1.1.1.1 1995/10/18 10:44:45 deraadt Exp $ +# $Id: Makefile,v 1.2 1995/12/06 10:55:03 deraadt Exp $ -CFLAGS+=-I${.CURDIR}/../../include +CFLAGS+=-I${.CURDIR}/../../include -O2 .include "${MACHINE_ARCH}/Makefile.inc" @@ -13,7 +13,7 @@ CLEANFILES+=a.out all: ${OBJS} bugcrt.o: bugcrt.c - ${CC} ${CFLAGS} -c -O ${.ALLSRC} + ${CC} ${CFLAGS} -c ${.ALLSRC} ${LD} -x -r ${.TARGET} mv a.out ${.TARGET} diff --git a/sys/arch/mvme68k/stand/bugcrt/m68k/Makefile.inc b/sys/arch/mvme68k/stand/bugcrt/m68k/Makefile.inc index f44c6aa6c1d..e69de29bb2d 100644 --- a/sys/arch/mvme68k/stand/bugcrt/m68k/Makefile.inc +++ b/sys/arch/mvme68k/stand/bugcrt/m68k/Makefile.inc @@ -1 +0,0 @@ -CFLAGS+=-fomit-frame-pointer diff --git a/sys/arch/mvme68k/stand/bugcrt/m68k/bugcrt.c b/sys/arch/mvme68k/stand/bugcrt/m68k/bugcrt.c index 1737f837ced..dae7b3667dc 100644 --- a/sys/arch/mvme68k/stand/bugcrt/m68k/bugcrt.c +++ b/sys/arch/mvme68k/stand/bugcrt/m68k/bugcrt.c @@ -1,16 +1,14 @@ #include #include -struct mvmeprom_args bugargs; +struct mvmeprom_args bugargs = { 1 }; /* not in BSS */ asm (".text"); asm (".long 0x003ffff8"); asm (".long _start"); -extern int edata; -extern int end; start() { - register int dev_lun asm ("d0"); + register int dev_lun asm ("d0"); register int ctrl_lun asm ("d1"); register int flags asm ("d4"); register int ctrl_addr asm ("a0"); @@ -18,22 +16,20 @@ start() register int conf_blk asm ("a2"); register char *arg_start asm ("a5"); register char *arg_end asm ("a6"); + extern int edata, end; - register struct mvmeprom_args *bugarea; - - bugarea = &bugargs; - bugarea->dev_lun = dev_lun; - bugarea->ctrl_lun = ctrl_lun; - bugarea->flags = flags; - bugarea->ctrl_addr = ctrl_addr; - bugarea->entry = entry; - bugarea->conf_blk = conf_blk; - bugarea->arg_start = arg_start; - bugarea->arg_end = arg_end; + bugargs.dev_lun = dev_lun; + bugargs.ctrl_lun = ctrl_lun; + bugargs.flags = flags; + bugargs.ctrl_addr = ctrl_addr; + bugargs.entry = entry; + bugargs.conf_blk = conf_blk; + bugargs.arg_start = arg_start; + bugargs.arg_end = arg_end; *arg_end = 0; bzero(&edata, (int)&end-(int)&edata); - main(bugarea); + main(); mvmeprom_return(); /* NOTREACHED */ } diff --git a/sys/arch/mvme68k/stand/bugcrt/m88k/Makefile.inc b/sys/arch/mvme68k/stand/bugcrt/m88k/Makefile.inc index f44c6aa6c1d..e69de29bb2d 100644 --- a/sys/arch/mvme68k/stand/bugcrt/m88k/Makefile.inc +++ b/sys/arch/mvme68k/stand/bugcrt/m88k/Makefile.inc @@ -1 +0,0 @@ -CFLAGS+=-fomit-frame-pointer diff --git a/sys/arch/mvme68k/stand/bugcrt/m88k/bugcrt.c b/sys/arch/mvme68k/stand/bugcrt/m88k/bugcrt.c index c9ffa7ddad7..711b4fe2035 100644 --- a/sys/arch/mvme68k/stand/bugcrt/m88k/bugcrt.c +++ b/sys/arch/mvme68k/stand/bugcrt/m88k/bugcrt.c @@ -1,15 +1,14 @@ #include #include -struct bugargs bugargs; +struct mvmeprom_args bugargs = { 1 }; /* not BSS */ + asm (".text"); asm (".long 0x003ffff8"); asm (".long _start"); -extern int edata; -extern int end; start() { - register int dev_lun asm ("r2"); + register int dev_lun asm ("r2"); register int ctrl_lun asm ("r3"); register int flags asm ("r4"); register int ctrl_addr asm ("r5"); @@ -17,22 +16,20 @@ start() register int conf_blk asm ("r7"); register char *arg_start asm ("r8"); register char *arg_end asm ("r9"); + extern int edata, end; - register struct mvmeprom_args *bugarea; - - bugarea = &bugargs; - bugarea->dev_lun = dev_lun; - bugarea->ctrl_lun = ctrl_lun; - bugarea->flags = flags; - bugarea->ctrl_addr = ctrl_addr; - bugarea->entry = entry; - bugarea->conf_blk = conf_blk; - bugarea->arg_start = arg_start; - bugarea->arg_end = arg_end; + bugargs.dev_lun = dev_lun; + bugargs.ctrl_lun = ctrl_lun; + bugargs.flags = flags; + bugargs.ctrl_addr = ctrl_addr; + bugargs.entry = entry; + bugargs.conf_blk = conf_blk; + bugargs.arg_start = arg_start; + bugargs.arg_end = arg_end; *arg_end = 0; bzero(&edata, (int)&edata - (int)&end); - main(bugarea); + main(); mvmeprom_return(); /* NOTREACHED */ }