1 /* boot.c 4.1 11/09/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 #ifdef JUSTASK 36 howto = RB_ASKNAME|RB_SINGLE; 37 #else 38 if ((howto&RB_ASKNAME)==0) { 39 if (devtype>=0 && devtype<sizeof(devname)/2 40 && devname[devtype][0]) { 41 line[0] = devname[devtype][0]; 42 line[1] = devname[devtype][1]; 43 } else { 44 printf("DID YOU MEAN ``BOOT ANY?'' (Bad devtype (r10=%x))\n", devtype); 45 howto = RB_SINGLE|RB_ASKNAME; 46 } 47 } 48 #endif 49 retry = 0; 50 for (;;) { 51 if (howto & RB_ASKNAME) { 52 printf(": "); 53 gets(line); 54 } else 55 printf(": %s\n", line); 56 io = open(line, 0); 57 if (io >= 0) 58 copyunix(howto, io); 59 if (++retry > 2) 60 howto = RB_SINGLE|RB_ASKNAME; 61 } 62 } 63 64 copyunix(howto, io) 65 register howto, io; 66 { 67 struct exec x; 68 register int i; 69 char *addr; 70 71 i = read(io, (char *)&x, sizeof x); 72 if (i != sizeof x || x.a_magic != 0410) 73 _stop("Bad format\n"); 74 printf("%d", x.a_text); 75 if (read(io, (char *)0, x.a_text) != x.a_text) 76 goto shread; 77 addr = (char *)x.a_text; 78 while ((int)addr & CLOFSET) 79 *addr++ = 0; 80 printf("+%d", x.a_data); 81 if (read(io, addr, x.a_data) != x.a_data) 82 goto shread; 83 addr += x.a_data; 84 printf("+%d", x.a_bss); 85 x.a_bss += 128*512; /* slop */ 86 for (i = 0; i < x.a_bss; i++) 87 *addr++ = 0; 88 x.a_entry &= 0x7fffffff; 89 printf(" start 0x%x\n", x.a_entry); 90 (*((int (*)()) x.a_entry))(); 91 _exit(); 92 shread: 93 _stop("Short read\n"); 94 } 95