Commit | Line | Data |
---|---|---|
ab569e06 | 1 | /* boot.c 4.6 81/12/01 */ |
b7e60356 BJ |
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" | |
8da76047 | 11 | #include <sys/reboot.h> |
b7e60356 | 12 | |
8da76047 BJ |
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 */ | |
a0761322 | 24 | 'h','k', /* 3 = hk */ |
3486ee81 BJ |
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 */ | |
ab569e06 | 31 | 'u', 't', /* 10 = ut */ |
8da76047 BJ |
32 | }; |
33 | ||
34 | char line[100] = "xx(0,0)vmunix"; | |
b7e60356 | 35 | |
a889f9b7 BJ |
36 | int retry = 0; |
37 | ||
b7e60356 BJ |
38 | main() |
39 | { | |
8da76047 | 40 | register howto, devtype; /* howto=r11, devtype=r10 */ |
a889f9b7 | 41 | int io; |
b7e60356 | 42 | |
610c6f01 BJ |
43 | #ifdef lint |
44 | howto = 0; devtype = 0; | |
45 | #endif | |
b7e60356 | 46 | printf("\nBoot\n"); |
0bd37f37 | 47 | #ifdef JUSTASK |
aaa709c3 | 48 | howto = RB_ASKNAME|RB_SINGLE; |
0bd37f37 | 49 | #else |
8da76047 BJ |
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]; | |
a0761322 | 55 | } else |
8da76047 | 56 | howto = RB_SINGLE|RB_ASKNAME; |
8da76047 | 57 | } |
0bd37f37 | 58 | #endif |
8da76047 BJ |
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) | |
a889f9b7 | 67 | copyunix(howto, io); |
8da76047 BJ |
68 | if (++retry > 2) |
69 | howto = RB_SINGLE|RB_ASKNAME; | |
70 | } | |
b7e60356 BJ |
71 | } |
72 | ||
a889f9b7 BJ |
73 | /*ARGSUSED*/ |
74 | copyunix(howto, io) | |
75 | register howto, io; | |
b7e60356 BJ |
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 | } |