Commit | Line | Data |
---|---|---|
8ae0e4b4 KM |
1 | /* |
2 | * Copyright (c) 1982 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 | * @(#)bootxx.c 6.2 (Berkeley) %G% | |
7 | */ | |
b6c81d5e RE |
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 | ||
48bd94ac | 17 | char bootprog[] = "xx(0,0)boot"; |
b6c81d5e RE |
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 howto, devtype; /* howto=r11, devtype=r10 */ | |
27 | int io; | |
28 | ||
29 | #ifdef lint | |
30 | howto = 0; devtype = 0; | |
31 | #endif | |
32 | printf("loading %s", bootprog); | |
33 | io = open(bootprog, 0); | |
34 | if (io >= 0) | |
35 | copyunix(howto, devtype, io); | |
36 | printf("boot failed"); | |
37 | _exit(); | |
38 | } | |
39 | ||
40 | /*ARGSUSED*/ | |
41 | copyunix(howto, devtype, io) | |
42 | register howto, devtype, io; /* howto=r11, devtype=r10 */ | |
43 | { | |
44 | struct exec x; | |
45 | register int i; | |
46 | char *addr; | |
47 | ||
48 | i = read(io, (char *)&x, sizeof x); | |
49 | if (i != sizeof x || | |
50 | (x.a_magic != 0407 && x.a_magic != 0413 && x.a_magic != 0410)) | |
51 | _stop("Bad format\n"); | |
52 | if ((x.a_magic == 0413 || x.a_magic == 0410) && | |
53 | lseek(io, 0x400, 0) == -1) | |
54 | goto shread; | |
55 | if (read(io, (char *)0, x.a_text) != x.a_text) | |
56 | goto shread; | |
57 | addr = (char *)x.a_text; | |
58 | if (x.a_magic == 0413 || x.a_magic == 0410) | |
59 | while ((int)addr & CLOFSET) | |
60 | *addr++ = 0; | |
61 | if (read(io, addr, x.a_data) != x.a_data) | |
62 | goto shread; | |
63 | addr += x.a_data; | |
64 | x.a_bss += 128*512; /* slop */ | |
65 | for (i = 0; i < x.a_bss; i++) | |
66 | *addr++ = 0; | |
67 | x.a_entry &= 0x7fffffff; | |
68 | (*((int (*)()) x.a_entry))(); | |
69 | _exit(); | |
70 | shread: | |
71 | _stop("Short read\n"); | |
72 | } |