added 48 sect eagle to device table
[unix-history] / usr / src / sys / vax / stand / boot.c
CommitLineData
b5d17f4d 1/* boot.c 4.8 82/07/15 */
b7e60356
BJ
2
3#include "../h/param.h"
b7e60356 4#include "../h/inode.h"
06254255 5#include "../h/fs.h"
b7e60356
BJ
6#include "../h/vm.h"
7#include <a.out.h>
8#include "saio.h"
06254255 9#include "../h/reboot.h"
b7e60356 10
8da76047
BJ
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 */
18char devname[][2] = {
19 'h','p', /* 0 = hp */
20 0,0, /* 1 = ht */
21 'u','p', /* 2 = up */
a0761322 22 'h','k', /* 3 = hk */
3486ee81
BJ
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 */
ab569e06 29 'u', 't', /* 10 = ut */
8da76047
BJ
30};
31
32char line[100] = "xx(0,0)vmunix";
b7e60356 33
a889f9b7
BJ
34int retry = 0;
35
b7e60356
BJ
36main()
37{
8da76047 38 register howto, devtype; /* howto=r11, devtype=r10 */
a889f9b7 39 int io;
b7e60356 40
610c6f01
BJ
41#ifdef lint
42 howto = 0; devtype = 0;
43#endif
b7e60356 44 printf("\nBoot\n");
0bd37f37 45#ifdef JUSTASK
aaa709c3 46 howto = RB_ASKNAME|RB_SINGLE;
0bd37f37 47#else
8da76047
BJ
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];
a0761322 53 } else
8da76047 54 howto = RB_SINGLE|RB_ASKNAME;
8da76047 55 }
0bd37f37 56#endif
8da76047
BJ
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)
a889f9b7 65 copyunix(howto, io);
8da76047
BJ
66 if (++retry > 2)
67 howto = RB_SINGLE|RB_ASKNAME;
68 }
b7e60356
BJ
69}
70
a889f9b7
BJ
71/*ARGSUSED*/
72copyunix(howto, io)
73 register howto, io;
b7e60356
BJ
74{
75 struct exec x;
76 register int i;
77 char *addr;
78
79 i = read(io, (char *)&x, sizeof x);
06254255
KM
80 if (i != sizeof x ||
81 (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410))
b7e60356
BJ
82 _stop("Bad format\n");
83 printf("%d", x.a_text);
b5d17f4d 84 if (x.a_magic == 0413 && lseek(io, 0x400, 0) == -1)
06254255 85 goto shread;
b7e60356
BJ
86 if (read(io, (char *)0, x.a_text) != x.a_text)
87 goto shread;
88 addr = (char *)x.a_text;
06254255
KM
89 if (x.a_magic == 0413 || x.a_magic == 0410)
90 while ((int)addr & CLOFSET)
91 *addr++ = 0;
b7e60356
BJ
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();
104shread:
105 _stop("Short read\n");
106}