1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 init_clocks:
43 procedure (success);
44
45
46
47 declare success bit (1) aligned parameter;
48
49
50
51 declare me char (11) init ("init_clocks") static options (constant);
52 declare time_format char (41) int static options (constant)
53 init ("^dn, ^mn ^Z9dm, ^9999yc ^Z9Hd:^MH:^SM ^za");
54
55
56
57 declare bce_query entry options (variable);
58 declare bce_query$yes_no entry options (variable);
59 declare com_err_ entry options (variable);
60 declare convert_date_to_binary_
61 entry (char (*), fixed bin (71), fixed bin (35));
62 declare date_time_$format entry (char (*), fixed bin (71), char (*), char (*)) returns (char (250) var);
63 declare date_time_$set_time_defaults
64 entry ();
65 declare ioa_ entry () options (variable);
66 declare privileged_mode_ut$sscr
67 entry (fixed bin (3), fixed bin (6), fixed bin (71));
68 declare read_disk entry (fixed bin, fixed bin, ptr, fixed bin (35));
69
70
71
72 declare TIME fixed bin (71);
73 declare bootload_scu fixed bin (3);
74 declare code fixed bin (35);
75 declare line char (80);
76 declare time_correction fixed bin (71);
77 declare time_string char (64) var;
78 declare zone char (4);
79 declare 1 rpv_label aligned like label;
80
81
82
83 declare disk_config_deck$ external static;
84 declare pvt$root_pvtx fixed bin external static;
85 declare sys_info$clock_ bit (3) aligned external static;
86 declare sys_info$first_reasonable_time
87 fixed bin (71) external static;
88 declare sys_info$last_reasonable_time
89 fixed bin (71) external static;
90 declare sys_info$time_correction_constant
91 fixed bin (71) aligned external static;
92 declare sys_info$time_zone char (4) aligned external static;
93
94
95
96 declare (addr, addrel, bin, clock, divide, fixed, hbound, lbound, rtrim, size, substr, unspec)
97 builtin;
98 %page;
99 success = "0"b;
100
101 call find_zone;
102
103 bootload_scu = fixed (sys_info$clock_, 3);
104
105 TIME = clock ();
106
107 call read_rpv_label ();
108 time_string = date_time_$format (time_format, label.time_unmounted, zone, "");
109 call ioa_ ("System was last shutdown at:^/^a", time_string);
110
111 call check_time;
112 line = "xxx";
113 do while (^(line = "n" | line = "no"));
114 call bce_query (line, "Is this correct? ");
115 if line = "y" | line = "yes"
116 then do;
117 call set_defaults;
118 call check_rpv;
119 success = "1"b;
120 return;
121 end;
122 else if line = "abort"
123 then return;
124 end;
125
126 CHECK_TIME:
127 call bce_query (line, "Enter time: ");
128 if line = "abort"
129 then do;
130 ABORT:
131 success = "0"b;
132 return;
133 end;
134
135 call set_defaults;
136
137 call convert_date_to_binary_ (line, TIME, code);
138
139 if code ^= 0
140 then do;
141 call com_err_ (code, me, "^a", rtrim (line));
142 go to CHECK_TIME;
143 end;
144
145 if scs$controller_data (bootload_scu).type < "0010"b
146 then do;
147 call ioa_ ("SCU Switches (octal): ^w ^w", substr (unspec (TIME), 1, 36), substr (unspec (TIME), 37));
148
149 call bce_query (line, "Enter anything after the switches have been set. ");
150 TIME = clock ();
151 end;
152
153 call check_time;
154 line = "xxx";
155 do while (^(line = "n" | line = "no"));
156 call bce_query (line, "Is this correct? ");
157 if line = "y" | line = "yes"
158 then do;
159 if scs$controller_data (bootload_scu).type < "0010"b
160 then ;
161 else call set_clocks;
162 call check_rpv;
163 success = "1"b;
164 return;
165 end;
166 else if line = "abort"
167 then return;
168 end;
169 go to CHECK_TIME;
170 %page;
171
172 set_defaults:
173 proc;
174 sys_info$time_zone = zone;
175 sys_info$time_correction_constant = time_correction;
176 call date_time_$set_time_defaults ();
177 end set_defaults;
178
179 set_clocks:
180 proc;
181
182 declare controllerx fixed bin (3);
183
184 do controllerx = lbound (scs$controller_data, 1) to hbound (scs$controller_data, 1);
185 if bin (scs$controller_data (controllerx).type, 4) >= 0010b & scs$controller_data (controllerx).online
186 then call privileged_mode_ut$sscr (controllerx, SC_ETC, TIME);
187 end;
188 return;
189 end;
190
191 find_zone:
192 proc;
193
194
195
196
197 declare idx fixed bin;
198 declare lang_index fixed bin;
199 declare zone_index fixed bin;
200
201 cardp = addr (disk_config_deck$);
202 config_max_cards = divide (4096 - 1, size (config_card), 17, 0);
203
204
205 do idx = 1 to config_max_cards while (config_card.word ^= FREE_CARD_WORD & config_card.word ^= CLOK_CARD_WORD);
206 cardp = addrel (cardp, size (config_card));
207 end;
208
209 if idx <= config_max_cards
210 then if config_card.word = CLOK_CARD_WORD
211 then do;
212 clok_cardp = cardp;
213 zone = clok_card.zone;
214 do lang_index = 1 to ti_zone.number_lang;
215 do zone_index = 1 to ti_zone.number_zone;
216 if ti_zone.short (lang_index, zone_index) = clok_card.zone
217 then go to found_zone;
218 end;
219 end;
220 call com_err_ (0, me, "The zone named on the CLOK card is not in time_info_");
221 goto ABORT;
222 found_zone:
223 time_correction = ti_zone.delta (lang_index, zone_index);
224 end;
225 else go to no_clok;
226 else do;
227 no_clok:
228 call com_err_ (0, me, "No clok card in config deck.");
229 go to ABORT;
230 end;
231 return;
232 end;
233
234 check_time:
235 proc;
236
237 time_string = date_time_$format (time_format, TIME, zone, "");
238 call ioa_ ("Current system time is: ^a.", time_string);
239 if TIME <= sys_info$first_reasonable_time | TIME >= sys_info$last_reasonable_time | TIME < label.time_unmounted
240 then do;
241 call ioa_ ("This is clearly incorrect.");
242 go to CHECK_TIME;
243 end;
244 return;
245 end;
246 %page;
247 check_rpv:
248 proc;
249
250
251
252 dcl yes_no bit (1) aligned;
253
254 if label.time_unmounted <= sys_info$first_reasonable_time
255 | label.time_unmounted >= sys_info$last_reasonable_time
256 then return;
257
258 if clock () < label.time_unmounted
259 then do;
260 call bce_query$yes_no (yes_no,
261 "The current time is *before* the last shutdown time recorded in the RPV.
262 Are you sure the time is correct? ");
263 if ^yes_no
264 then go to CHECK_TIME;
265 end;
266
267 if clok_card.boot_delta ^= -1 & clock () > label.time_unmounted + clok_card.boot_delta * 3600 * 1000000
268 then do;
269 call bce_query$yes_no (yes_no, "The current time is more than the supplied boot_delta hours beyond the
270 unmounted time recorded in the RPV label. Is this correct? ");
271 if ^yes_no
272 then go to CHECK_TIME;
273
274 if (divide (clock () - label.time_unmounted, 3600 * 1000000, 17, 0) > 12) then do;
275 call bce_query$yes_no (yes_no, "The current time I'm using is more than 12 hours
276 after the last shutdown time recorded in the RPV label.
277 Are you sure this is correct? ");
278 if ^yes_no then
279 goto CHECK_TIME;
280 end;
281 end;
282 return;
283 end;
284 %skip;
285 read_rpv_label:
286 proc;
287
288 labelp = addr (rpv_label);
289 call read_disk (pvt$root_pvtx, LABEL_ADDR, labelp, code);
290 if code ^= 0
291 then do;
292 call com_err_ (code, me, "RPV label");
293 go to ABORT;
294 end;
295 return;
296
297 end read_rpv_label;
298 %page;
299 %include config_deck;
300 %page;
301 %include config_clok_card;
302 %page;
303 %include disk_pack;
304 %page;
305 %include fs_vol_label;
306 %page;
307 %include scr;
308 %page;
309 %include scs;
310 %page;
311 %include time_names;
312 end init_clocks;