Commit | Line | Data |
---|---|---|
23055b9b KT |
1 | #include "/sys/nsys/param.h" |
2 | #include "/sys/nsys/user.h" | |
3 | #include "/sys/nsys/systm.h" | |
4 | #include "/sys/nsys/proc.h" | |
5 | #include "/sys/nsys/text.h" | |
6 | #include "/sys/nsys/inode.h" | |
7 | ||
8 | #define KISA 0172340 | |
9 | #define UISD 0177600 | |
10 | #define UISA 0177640 | |
11 | #define RO 02 | |
12 | #define RW 06 | |
13 | #define WO 04 | |
14 | #define ED 010 | |
15 | struct { | |
16 | int integ; | |
17 | }; | |
18 | struct { | |
19 | int r[8]; | |
20 | }; | |
21 | int icode[] | |
22 | { | |
23 | 0104413, | |
24 | 0000014, | |
25 | 0000010, | |
26 | 0000777, | |
27 | 0000014, | |
28 | 0000000, | |
29 | 0062457, | |
30 | 0061564, | |
31 | 0064457, | |
32 | 0064556, | |
33 | 0000164, | |
34 | -1 | |
35 | }; | |
36 | ||
37 | main() | |
38 | { | |
39 | extern schar; | |
40 | extern char end[], data[], etext[]; | |
41 | int i, i1, *p; | |
42 | ||
43 | /* | |
44 | * zero and free all of core | |
45 | */ | |
46 | ||
47 | UISA->r[0] = KISA->r[6] + USIZE; | |
48 | UISD->r[0] = 6; | |
49 | for(; fubyte(0) >= 0; UISA->r[0]++) { | |
50 | clearseg(UISA->r[0]); | |
51 | mfree(coremap, 1, UISA->r[0]); | |
52 | } | |
53 | mfree(swapmap, NSWAP, SWPLO); | |
54 | ||
55 | /* | |
56 | * set up system process | |
57 | */ | |
58 | ||
59 | proc[0].p_addr = KISA->r[6]; | |
60 | proc[0].p_size = USIZE; | |
61 | proc[0].p_stat = SRUN; | |
62 | proc[0].p_flag =| SLOAD|SSYS; | |
63 | u.u_procp = &proc[0]; | |
64 | ||
65 | /* | |
66 | * set up 'known' i-nodes | |
67 | */ | |
68 | ||
69 | sureg(); | |
70 | LKS->integ = 0115; | |
71 | cinit(); | |
72 | binit(); | |
73 | iinit(); | |
74 | rootdir = iget(ROOTDEV, ROOTINO); | |
75 | rootdir->i_flag =& ~ILOCK; | |
76 | u.u_cdir = iget(ROOTDEV, ROOTINO); | |
77 | u.u_cdir->i_flag =& ~ILOCK; | |
78 | ||
79 | /* | |
80 | * make init process | |
81 | * enter scheduling loop | |
82 | * with system process | |
83 | */ | |
84 | ||
85 | if(newproc()) { | |
86 | expand(USIZE+1); | |
87 | u.u_uisa[0] = USIZE; | |
88 | u.u_uisd[0] = 6; | |
89 | sureg(); | |
90 | for(i=0; icode[i] != -1; i++) | |
91 | suword(i*2, icode[i]); | |
92 | return; | |
93 | } | |
94 | sched(); | |
95 | } | |
96 | ||
97 | sureg() | |
98 | { | |
99 | register *up, *rp, a; | |
100 | ||
101 | a = u.u_procp->p_addr; | |
102 | up = &u.u_uisa[0]; | |
103 | rp = &UISA->r[0]; | |
104 | while(rp < &UISA->r[8]) | |
105 | *rp++ = *up++ + a; | |
106 | if((up=u.u_procp->p_textp) != NULL) | |
107 | a =- up->x_caddr; | |
108 | up = &u.u_uisd[0]; | |
109 | rp = &UISD->r[0]; | |
110 | while(rp < &UISD->r[8]) { | |
111 | *rp = *up++; | |
112 | if((*rp++ & WO) == 0) | |
113 | rp[(UISA-UISD)/2-1] =- a; | |
114 | } | |
115 | } | |
116 | ||
117 | estabur(nt, nd, ns) | |
118 | { | |
119 | register a, *ap, *dp; | |
120 | ||
121 | if(nseg(nt)+nseg(nd)+nseg(ns) > 8 || nt+nd+ns > MAXMEM) { | |
122 | u.u_error = ENOMEM; | |
123 | return(-1); | |
124 | } | |
125 | a = 0; | |
126 | ap = &u.u_uisa[0]; | |
127 | dp = &u.u_uisd[0]; | |
128 | while(nt >= 128) { | |
129 | *dp++ = (127<<8) | RO; | |
130 | *ap++ = a; | |
131 | a =+ 128; | |
132 | nt =- 128; | |
133 | } | |
134 | if(nt) { | |
135 | *dp++ = ((nt-1)<<8) | RO; | |
136 | *ap++ = a; | |
137 | a =+ nt; | |
138 | } | |
139 | a = USIZE; | |
140 | while(nd >= 128) { | |
141 | *dp++ = (127<<8) | RW; | |
142 | *ap++ = a; | |
143 | a =+ 128; | |
144 | nd =- 128; | |
145 | } | |
146 | if(nd) { | |
147 | *dp++ = ((nd-1)<<8) | RW; | |
148 | *ap++ = a; | |
149 | a =+ nd; | |
150 | } | |
151 | while(ap < &u.u_uisa[8]) { | |
152 | *dp++ = 0; | |
153 | *ap++ = 0; | |
154 | } | |
155 | a =+ ns; | |
156 | while(ns >= 128) { | |
157 | a =- 128; | |
158 | ns =- 128; | |
159 | *--dp = (127<<8) | RW; | |
160 | *--ap = a; | |
161 | } | |
162 | if(ns) { | |
163 | *--dp = ((128-ns)<<8) | RW | ED; | |
164 | *--ap = a-128; | |
165 | } | |
166 | sureg(); | |
167 | return(0); | |
168 | } | |
169 | ||
170 | nseg(n) | |
171 | { | |
172 | ||
173 | return((n+127)>>7); | |
174 | } |