1 /* boot.c 1.2 10/16/80 */ 2 3 #include "../h/param.h" 4 #include "../h/ino.h" 5 #include "../h/inode.h" 6 #include "../h/filsys.h" 7 #include "../h/dir.h" 8 #include "../h/vm.h" 9 #include <a.out.h> 10 #include "saio.h" 11 #include <sys/reboot.h> 12 13 /* 14 * Boot program... arguments passed in r10 and r11 determine 15 * whether boot stops to ask for system name and which device 16 * boot comes from. 17 */ 18 19 /* Types in r10 specifying major device */ 20 char devname[][2] = { 21 'h','p', /* 0 = hp */ 22 0,0, /* 1 = ht */ 23 'u','p', /* 2 = up */ 24 'r','k', /* 3 = rk */ 25 }; 26 27 char line[100] = "xx(0,0)vmunix"; 28 29 main() 30 { 31 register howto, devtype; /* howto=r11, devtype=r10 */ 32 int io, retry; 33 34 printf("\nBoot\n"); 35 if ((howto&RB_ASKNAME)==0) { 36 if (devtype>=0 && devtype<sizeof(devname)/2 37 && devname[devtype][0]) { 38 line[0] = devname[devtype][0]; 39 line[1] = devname[devtype][1]; 40 } else { 41 printf("DID YOU MEAN ``BOOT ANY?'' (Bad devtype (r10=%x))\n", devtype); 42 howto = RB_SINGLE|RB_ASKNAME; 43 } 44 } 45 retry = 0; 46 for (;;) { 47 if (howto & RB_ASKNAME) { 48 printf(": "); 49 gets(line); 50 } else 51 printf(": %s\n", line); 52 io = open(line, 0); 53 if (io >= 0) 54 copyunix(howto, io); 55 if (++retry > 2) 56 howto = RB_SINGLE|RB_ASKNAME; 57 } 58 } 59 60 copyunix(howto, io) 61 register howto, io; 62 { 63 struct exec x; 64 register int i; 65 char *addr; 66 67 i = read(io, (char *)&x, sizeof x); 68 if (i != sizeof x || x.a_magic != 0410) 69 _stop("Bad format\n"); 70 printf("%d", x.a_text); 71 if (read(io, (char *)0, x.a_text) != x.a_text) 72 goto shread; 73 addr = (char *)x.a_text; 74 while ((int)addr & CLOFSET) 75 *addr++ = 0; 76 printf("+%d", x.a_data); 77 if (read(io, addr, x.a_data) != x.a_data) 78 goto shread; 79 addr += x.a_data; 80 printf("+%d", x.a_bss); 81 x.a_bss += 128*512; /* slop */ 82 for (i = 0; i < x.a_bss; i++) 83 *addr++ = 0; 84 x.a_entry &= 0x7fffffff; 85 printf(" start 0x%x\n", x.a_entry); 86 (*((int (*)()) x.a_entry))(); 87 _exit(); 88 shread: 89 _stop("Short read\n"); 90 } 91