1: /*
2: * Copyright (c) 1982, 1986 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: *
6: * @(#)bootrl.c 7.1 (Berkeley) 6/5/86
7: */
8:
9: #include "../h/param.h"
10: #include "../h/inode.h"
11: #include "../h/fs.h"
12: #include "../h/vm.h"
13: #include <a.out.h>
14: #include "saio.h"
15: #include "../h/reboot.h"
16:
17: char bootprog[20] = "rl(0,0)boot";
18:
19: /*
20: * Boot program... arguments passed in r10 and r11
21: * are passed through to the full boot program.
22: */
23:
24: main()
25: {
26: register unsigned howto, devtype; /* howto=r11, devtype=r10 */
27: int io, unit, partition;
28: register char *cp;
29:
30: #ifdef lint
31: howto = 0; devtype = 0;
32: #endif
33: unit = (devtype >> B_UNITSHIFT) & B_UNITMASK;
34: unit += 8 * ((devtype >> B_ADAPTORSHIFT) & B_ADAPTORMASK);
35: partition = (devtype >> B_PARTITIONSHIFT) & B_PARTITIONMASK;
36: cp = bootprog + 3;
37: if (unit >= 10)
38: *cp++ = unit / 10 + '0';
39: *cp++ = unit % 10 + '0';
40: *cp++ = ',';
41: if (partition >= 10)
42: *cp++ = partition / 10 + '0';
43: *cp++ = partition % 10 + '0';
44: bcopy((caddr_t) ")boot", cp, 6);
45: printf("loading %s\n", bootprog);
46: io = open(bootprog, 0);
47: if (io >= 0)
48: copyunix(howto, devtype, io);
49: _stop("boot failed\n");
50: }
51:
52: /*ARGSUSED*/
53: copyunix(howto, devtype, io)
54: register howto, devtype, io; /* howto=r11, devtype=r10 */
55: {
56: struct exec x;
57: register int i;
58: char *addr;
59:
60: i = read(io, (char *)&x, sizeof x);
61: if (i != sizeof x ||
62: (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410))
63: _stop("Bad format\n");
64: if ((x.a_magic == 0413 || x.a_magic == 0410) &&
65: lseek(io, 0x400, 0) == -1)
66: goto shread;
67: if (read(io, (char *)0, x.a_text) != x.a_text)
68: goto shread;
69: addr = (char *)x.a_text;
70: if (x.a_magic == 0413 || x.a_magic == 0410)
71: while ((int)addr & CLOFSET)
72: *addr++ = 0;
73: if (read(io, addr, x.a_data) != x.a_data)
74: goto shread;
75: addr += x.a_data;
76: x.a_bss += 128*512; /* slop */
77: for (i = 0; i < x.a_bss; i++)
78: *addr++ = 0;
79: x.a_entry &= 0x7fffffff;
80: (*((int (*)()) x.a_entry))();
81: return;
82: shread:
83: _stop("Short read\n");
84: }
Defined functions
main
defined in line
24;
never used
Defined variables