1*1466Sbill /* boot.c 1.2 10/16/80 */ 2315Sbill 3315Sbill #include "../h/param.h" 4315Sbill #include "../h/ino.h" 5315Sbill #include "../h/inode.h" 6315Sbill #include "../h/filsys.h" 7315Sbill #include "../h/dir.h" 8315Sbill #include "../h/vm.h" 9315Sbill #include <a.out.h> 10315Sbill #include "saio.h" 11*1466Sbill #include <sys/reboot.h> 12315Sbill 13*1466Sbill /* 14*1466Sbill * Boot program... arguments passed in r10 and r11 determine 15*1466Sbill * whether boot stops to ask for system name and which device 16*1466Sbill * boot comes from. 17*1466Sbill */ 18315Sbill 19*1466Sbill /* Types in r10 specifying major device */ 20*1466Sbill char devname[][2] = { 21*1466Sbill 'h','p', /* 0 = hp */ 22*1466Sbill 0,0, /* 1 = ht */ 23*1466Sbill 'u','p', /* 2 = up */ 24*1466Sbill 'r','k', /* 3 = rk */ 25*1466Sbill }; 26*1466Sbill 27*1466Sbill char line[100] = "xx(0,0)vmunix"; 28*1466Sbill 29315Sbill main() 30315Sbill { 31*1466Sbill register howto, devtype; /* howto=r11, devtype=r10 */ 32*1466Sbill int io, retry; 33315Sbill 34315Sbill printf("\nBoot\n"); 35*1466Sbill if ((howto&RB_ASKNAME)==0) { 36*1466Sbill if (devtype>=0 && devtype<sizeof(devname)/2 37*1466Sbill && devname[devtype][0]) { 38*1466Sbill line[0] = devname[devtype][0]; 39*1466Sbill line[1] = devname[devtype][1]; 40*1466Sbill } else { 41*1466Sbill printf("DID YOU MEAN ``BOOT ANY?'' (Bad devtype (r10=%x))\n", devtype); 42*1466Sbill howto = RB_SINGLE|RB_ASKNAME; 43*1466Sbill } 44*1466Sbill } 45*1466Sbill retry = 0; 46*1466Sbill for (;;) { 47*1466Sbill if (howto & RB_ASKNAME) { 48*1466Sbill printf(": "); 49*1466Sbill gets(line); 50*1466Sbill } else 51*1466Sbill printf(": %s\n", line); 52*1466Sbill io = open(line, 0); 53*1466Sbill if (io >= 0) 54*1466Sbill copyunix(howto, io); 55*1466Sbill if (++retry > 2) 56*1466Sbill howto = RB_SINGLE|RB_ASKNAME; 57*1466Sbill } 58315Sbill } 59315Sbill 60*1466Sbill copyunix(howto, io) 61*1466Sbill register howto, io; 62315Sbill { 63315Sbill struct exec x; 64315Sbill register int i; 65315Sbill char *addr; 66315Sbill 67315Sbill i = read(io, (char *)&x, sizeof x); 68315Sbill if (i != sizeof x || x.a_magic != 0410) 69315Sbill _stop("Bad format\n"); 70315Sbill printf("%d", x.a_text); 71315Sbill if (read(io, (char *)0, x.a_text) != x.a_text) 72315Sbill goto shread; 73315Sbill addr = (char *)x.a_text; 74315Sbill while ((int)addr & CLOFSET) 75315Sbill *addr++ = 0; 76315Sbill printf("+%d", x.a_data); 77315Sbill if (read(io, addr, x.a_data) != x.a_data) 78315Sbill goto shread; 79315Sbill addr += x.a_data; 80315Sbill printf("+%d", x.a_bss); 81315Sbill x.a_bss += 128*512; /* slop */ 82315Sbill for (i = 0; i < x.a_bss; i++) 83315Sbill *addr++ = 0; 84315Sbill x.a_entry &= 0x7fffffff; 85315Sbill printf(" start 0x%x\n", x.a_entry); 86315Sbill (*((int (*)()) x.a_entry))(); 87315Sbill _exit(); 88315Sbill shread: 89315Sbill _stop("Short read\n"); 90315Sbill } 91