1
2
3
4
5
6
7
8
9
10
11
12
13 segment_loader:
14 proc;
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 dcl header_area (1000) fixed bin (35);
37
38 dcl header_ptr ptr;
39 dcl type fixed bin (17);
40 dcl count fixed bin (17);
41 dcl seg_ptr ptr;
42 dcl text_ptr ptr;
43 dcl text_no fixed bin (18);
44 dcl link_ptr ptr;
45 dcl seg_number fixed bin (18);
46 dcl expect_link bit (1) aligned;
47 dcl expect_defs bit (1) aligned;
48 dcl control_ptr ptr;
49 dcl last_sltep ptr;
50 dcl tsdw fixed bin (71);
51 dcl reading_sdw fixed bin (71);
52 dcl ptp ptr;
53
54 dcl 1 control_word aligned,
55 ( 2 type fixed bin (17),
56 2 count fixed bin (17)
57 ) unaligned;
58
59
60 dcl as_linkage$ external static;
61 dcl ws_linkage$ external static;
62 dcl ai_linkage$ external static;
63 dcl wi_linkage$ external static;
64
65 dcl slt$ external static;
66
67 dcl 1 lot$ ext like lot;
68
69 dcl definitions_$ ext;
70
71 dcl make_sdw entry (fixed bin (18), fixed bin (71), ptr, ptr);
72 dcl pc_wired$write entry (ptr, fixed bin, fixed bin);
73 dcl pmut$swap_sdw entry (ptr, ptr);
74 dcl sdw_util_$set_access entry (pointer, bit (4) unaligned);
75 dcl slt_manager$build_entry
76 entry (ptr) returns (ptr);
77 dcl syserr entry options (variable);
78 dcl disk_reader entry (ptr, fixed bin (17));
79
80 dcl (addr, addrel, baseno, bin, mod, null, rel, size)
81 builtin;
82 ^L
83
84 expect_defs = "0"b;
85 expect_link = "0"b;
86
87 sltp = addr (slt$);
88 lotp = addr (lot$);
89 definitions_ptr = addr (definitions_$);
90
91 header_ptr = addr (header_area);
92
93 control_ptr = addr (control_word);
94
95
96
97 loop:
98 call read_control_word (type, count);
99 if type = 2
100 then go to collection;
101 else if type ^= 0
102 then call syserr (CRASH, "segment_loader: unknown control type ^d", type);
103
104
105
106 if count > size (header_area)
107 then
108 call syserr (CRASH, "segment_loader: bad header size ^d", count);
109
110
111 call disk_reader (header_ptr, count);
112
113 call read_control_word (type, count);
114 if type ^= 1
115 then
116 call syserr (CRASH, "segment_loader: unexpected control type ^d", type);
117
118 if header_ptr -> slte.link_sect
119 then do;
120 if ^expect_link
121 then
122 call syserr (CRASH, "segment_loader: Unexpected linkage.");
123 expect_link = "0"b;
124 expect_defs = "1"b;
125
126 if last_sltep -> slte.combine_link
127 then do;
128 if last_sltep -> slte.link_sect_wired
129 then
130 if last_sltep -> slte.init_seg
131 then
132 hclsp = addr (wi_linkage$);
133
134 else
135 hclsp = addr (ws_linkage$);
136
137 else
138 if last_sltep -> slte.init_seg
139 then
140 hclsp = addr (ai_linkage$);
141
142 else
143 hclsp = addr (as_linkage$);
144
145
146 seg_ptr = hclsp -> hc_linkage_seg.next_free_ptr;
147
148 hclsp -> hc_linkage_seg.next_free_ptr = addrel (seg_ptr, count + mod (count, 2));
149
150
151 call disk_reader (seg_ptr, count);
152
153 end;
154
155 else
156 call load_segment;
157
158 link_ptr = seg_ptr;
159 lot.lp (text_no) = link_ptr;
160 link_ptr -> linkage_header.segment_number = text_no;
161
162 end;
163
164 else if header_ptr -> slte.defs
165 then do;
166 if ^expect_defs
167 then
168 call syserr (CRASH, "segment_loader: Unexpected defs.");
169 expect_defs = "0"b;
170
171 seg_ptr = definitions.next_free_ptr;
172 definitions.next_free_ptr = addrel (seg_ptr, count);
173
174
175 call disk_reader (seg_ptr, count);
176
177 definitions.dot (text_no).offset = bin (rel (seg_ptr), 18);
178 definitions.dot (text_no).length = count;
179
180
181 link_ptr -> linkage_header.def_ptr = seg_ptr;
182
183 end;
184
185 else do;
186 if expect_link | expect_defs
187 then
188 call syserr (CRASH, "segment_loader: Missing linkage or defs.");
189 expect_link = header_ptr -> slte.link_provided;
190
191
192 call load_segment;
193 text_ptr = seg_ptr;
194 text_no = bin (baseno (text_ptr), 18);
195 end;
196
197 last_sltep = sltep;
198
199 go to loop;
200
201
202
203 collection:
204 call read_control_word (type, count);
205
206 return;
207 %page;
208
209
210 load_segment:
211 proc;
212
213 seg_ptr = slt_manager$build_entry (header_ptr);
214 if seg_ptr = null ()
215 then call syserr (CRASH, "segment_loader: error from slt_manager$build_entry");
216
217 seg_number = bin (baseno (seg_ptr), 15);
218
219 sltep = addr (slt.seg (seg_number));
220
221 call make_sdw (seg_number, tsdw, astep, ptp);
222 if astep = null ()
223 then return;
224
225 reading_sdw = tsdw;
226 call sdw_util_$set_access (addr (reading_sdw), "1010"b);
227
228 call pmut$swap_sdw (seg_ptr, addr (reading_sdw));
229
230 aste.gtpd = "1"b;
231
232 call disk_reader (seg_ptr, count);
233
234 call pmut$swap_sdw (seg_ptr, addr (tsdw));
235
236 call pc_wired$write (astep, 0, -1);
237
238 aste.gtpd = "0"b;
239
240 return;
241
242
243 end load_segment;
244 ^L
245
246
247
248 read_control_word:
249 proc (type, count);
250
251 dcl type fixed bin (17),
252 count fixed bin (17);
253
254
255 call disk_reader (control_ptr, 1);
256
257 type = control_word.type;
258 count = control_word.count;
259
260 return;
261
262
263 end read_control_word;
264
265 %page; %include hc_linkage_seg; %include hc_definitions_seg;
266 %page; %include aste;
267 %page; %include slt;
268 %page; %include slte;
269 %page; %include object_link_dcls;
270 %page; %include lot;
271 %page; %include syserr_constants;
272
273 ^L
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353 end segment_loader;