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