# 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
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}
-/* $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
#include <machine/prom.h>
#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;
char *strtab;
int strtablen;
#if 0
-struct nlist *nlp, *enlp;
+struct nlist *nlp, *enlp;
#endif
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;
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);
}
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);
}
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;
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;
#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);
#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;
-/* $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
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
-extern struct mvmeprom_args *bugargs;
+extern struct mvmeprom_args bugargs;
int errno;
struct bugsc_softc {
short dev;
} bugsc_softc[1];
-static struct disklabel sdlabel;
-
int
devopen(f, fname, file)
struct open_file *f;
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.
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;
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();
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
#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);
-/* $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 $";
-# $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"
all: ${OBJS}
bugcrt.o: bugcrt.c
- ${CC} ${CFLAGS} -c -O ${.ALLSRC}
+ ${CC} ${CFLAGS} -c ${.ALLSRC}
${LD} -x -r ${.TARGET}
mv a.out ${.TARGET}
-CFLAGS+=-fomit-frame-pointer
#include <sys/types.h>
#include <machine/prom.h>
-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");
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 */
}
-CFLAGS+=-fomit-frame-pointer
#include <sys/types.h>
#include <machine/prom.h>
-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");
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 */
}