Research V7 development
[unix-history] / usr / src / cmd / standalone / boot.c
CommitLineData
a570deab
KT
1#include <sys/param.h>
2#include <sys/ino.h>
3#include <sys/inode.h>
4#include <sys/filsys.h>
5#include <sys/dir.h>
6#include <saio.h>
7
8
9char line[100];
10
11main()
12{
13int i;
14 segflag = 2;
15
16
17 printf("Boot\n");
18 do {
19 printf(": "); gets(line);
20 i = open(line,0);
21 } while (i < 0);
22
23
24 copyunix(i);
25
26}
27
28
29copyunix(io)
30register io;
31{
32register addr,s;
33long phys;
34unsigned txtsiz,datsiz,bsssiz;
35int magic;
36
37
38 lseek(io, (off_t)0, 0);
39 magic = getw(io);
40 txtsiz = getw(io);
41 datsiz = getw(io);
42 bsssiz = getw(io);
43
44
45 switch (magic) {
46 case 0411:
47 setseg(0);
48 lseek(io, (long)(020+txtsiz), 0);
49
50 for(addr=0; addr!=datsiz; addr+=2) {
51 mtpi(getw(io),addr);
52 }
53
54 clrseg(addr,bsssiz);
55
56 phys = (long)datsiz + (long)bsssiz + 63L;
57 phys =/ 64;
58 setseg((int)phys);
59
60 lseek(io, 020L, 0);
61
62 for(addr=0; addr!=txtsiz; addr+=2) {
63 mtpi(getw(io),addr);
64 }
65 return;
66 case 0407:
67 setseg(0);
68 /*
69 * space over the header. We do this instead of seeking
70 * because the input might be a tape which doesn't know
71 * how to seek.
72 */
73 getw(io); getw(io); getw(io); getw(io);
74 phys = txtsiz+datsiz;
75 for (addr = 0; addr != phys; addr += 2)
76 mtpi(getw(io),addr);
77 clrseg(addr, bsssiz);
78 return;
79 default:
80 printf("Can't load %o files\n", magic);
81 exit(1);
82 }
83}