1 /* boot.c 4.6 81/12/01 */ 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 'h','k', /* 3 = hk */ 25 0,0, /* 4 = sw */ 26 0,0, /* 5 = tm */ 27 0,0, /* 6 = ts */ 28 0,0, /* 7 = mt */ 29 0,0, /* 8 = tu */ 30 'r','a', /* 9 = ra */ 31 'u', 't', /* 10 = ut */ 32 }; 33 34 char line[100] = "xx(0,0)vmunix"; 35 36 int retry = 0; 37 38 main() 39 { 40 register howto, devtype; /* howto=r11, devtype=r10 */ 41 int io; 42 43 #ifdef lint 44 howto = 0; devtype = 0; 45 #endif 46 printf("\nBoot\n"); 47 #ifdef JUSTASK 48 howto = RB_ASKNAME|RB_SINGLE; 49 #else 50 if ((howto&RB_ASKNAME)==0) { 51 if (devtype>=0 && devtype<sizeof(devname)/2 52 && devname[devtype][0]) { 53 line[0] = devname[devtype][0]; 54 line[1] = devname[devtype][1]; 55 } else 56 howto = RB_SINGLE|RB_ASKNAME; 57 } 58 #endif 59 for (;;) { 60 if (howto & RB_ASKNAME) { 61 printf(": "); 62 gets(line); 63 } else 64 printf(": %s\n", line); 65 io = open(line, 0); 66 if (io >= 0) 67 copyunix(howto, io); 68 if (++retry > 2) 69 howto = RB_SINGLE|RB_ASKNAME; 70 } 71 } 72 73 /*ARGSUSED*/ 74 copyunix(howto, io) 75 register howto, io; 76 { 77 struct exec x; 78 register int i; 79 char *addr; 80 81 i = read(io, (char *)&x, sizeof x); 82 if (i != sizeof x || x.a_magic != 0410) 83 _stop("Bad format\n"); 84 printf("%d", x.a_text); 85 if (read(io, (char *)0, x.a_text) != x.a_text) 86 goto shread; 87 addr = (char *)x.a_text; 88 while ((int)addr & CLOFSET) 89 *addr++ = 0; 90 printf("+%d", x.a_data); 91 if (read(io, addr, x.a_data) != x.a_data) 92 goto shread; 93 addr += x.a_data; 94 printf("+%d", x.a_bss); 95 x.a_bss += 128*512; /* slop */ 96 for (i = 0; i < x.a_bss; i++) 97 *addr++ = 0; 98 x.a_entry &= 0x7fffffff; 99 printf(" start 0x%x\n", x.a_entry); 100 (*((int (*)()) x.a_entry))(); 101 _exit(); 102 shread: 103 _stop("Short read\n"); 104 } 105