1 /* bootxx.c 6.1 83/07/29 */ 2 3 #include "../h/param.h" 4 #include "../h/inode.h" 5 #include "../h/fs.h" 6 #include "../h/vm.h" 7 #include <a.out.h> 8 #include "saio.h" 9 #include "../h/reboot.h" 10 11 char bootprog[] = "xx(0,0)boot"; 12 13 /* 14 * Boot program... arguments passed in r10 and r11 15 * are passed through to the full boot program. 16 */ 17 18 main() 19 { 20 register howto, devtype; /* howto=r11, devtype=r10 */ 21 int io; 22 23 #ifdef lint 24 howto = 0; devtype = 0; 25 #endif 26 printf("loading %s", bootprog); 27 io = open(bootprog, 0); 28 if (io >= 0) 29 copyunix(howto, devtype, io); 30 printf("boot failed"); 31 _exit(); 32 } 33 34 /*ARGSUSED*/ 35 copyunix(howto, devtype, io) 36 register howto, devtype, io; /* howto=r11, devtype=r10 */ 37 { 38 struct exec x; 39 register int i; 40 char *addr; 41 42 i = read(io, (char *)&x, sizeof x); 43 if (i != sizeof x || 44 (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410)) 45 _stop("Bad format\n"); 46 if ((x.a_magic == 0413 || x.a_magic == 0410) && 47 lseek(io, 0x400, 0) == -1) 48 goto shread; 49 if (read(io, (char *)0, x.a_text) != x.a_text) 50 goto shread; 51 addr = (char *)x.a_text; 52 if (x.a_magic == 0413 || x.a_magic == 0410) 53 while ((int)addr & CLOFSET) 54 *addr++ = 0; 55 if (read(io, addr, x.a_data) != x.a_data) 56 goto shread; 57 addr += x.a_data; 58 x.a_bss += 128*512; /* slop */ 59 for (i = 0; i < x.a_bss; i++) 60 *addr++ = 0; 61 x.a_entry &= 0x7fffffff; 62 (*((int (*)()) x.a_entry))(); 63 _exit(); 64 shread: 65 _stop("Short read\n"); 66 } 67