|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)bootxx.c 7.4 (Berkeley) 2/4/88 ! 7: */ ! 8: ! 9: #include "param.h" ! 10: #include "inode.h" ! 11: #include "fs.h" ! 12: #include "vm.h" ! 13: #include "reboot.h" ! 14: #include <a.out.h> ! 15: #include "saio.h" ! 16: ! 17: char bootprog[] = "boot"; ! 18: extern unsigned opendev; ! 19: ! 20: /* ! 21: * Boot program... arguments passed in r10 and r11 ! 22: * are passed through to the full boot program. ! 23: */ ! 24: ! 25: main() ! 26: { ! 27: register unsigned howto, devtype; /* howto=r11, devtype=r10 */ ! 28: int io, unit, partition; ! 29: register char *cp; ! 30: ! 31: #ifdef lint ! 32: howto = 0; devtype = 0; devtype = devtype; ! 33: #endif ! 34: printf("loading %s\n", bootprog); ! 35: io = open(bootprog, 0); ! 36: if (io >= 0) ! 37: copyunix(howto, opendev, io); ! 38: _stop("boot failed\n"); ! 39: } ! 40: ! 41: /*ARGSUSED*/ ! 42: copyunix(howto, devtype, io) ! 43: register howto, devtype, io; /* howto=r11, devtype=r10 */ ! 44: { ! 45: struct exec x; ! 46: register int i; ! 47: char *addr; ! 48: ! 49: i = read(io, (char *)&x, sizeof x); ! 50: if (i != sizeof x || N_BADMAG(x)) ! 51: _stop("Bad format\n"); ! 52: if ((x.a_magic == ZMAGIC || x.a_magic == NMAGIC) && ! 53: lseek(io, 0x400, L_SET) == -1) ! 54: goto shread; ! 55: if (read(io, (char *)0, x.a_text) != x.a_text) ! 56: goto shread; ! 57: addr = (char *)x.a_text; ! 58: if (x.a_magic == ZMAGIC || x.a_magic == NMAGIC) ! 59: while ((int)addr & CLOFSET) ! 60: *addr++ = 0; ! 61: if (read(io, addr, x.a_data) != x.a_data) ! 62: goto shread; ! 63: addr += x.a_data; ! 64: x.a_bss += 128*512; /* slop */ ! 65: for (i = 0; i < x.a_bss; i++) ! 66: *addr++ = 0; ! 67: x.a_entry &= 0x7fffffff; ! 68: (*((int (*)()) x.a_entry))(); ! 69: return; ! 70: shread: ! 71: _stop("Short read\n"); ! 72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.