1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  6         *                                                         *
  7         * Copyright (c) 1972 by Massachusetts Institute of        *
  8         * Technology and Honeywell Information Systems, Inc.      *
  9         *                                                         *
 10         *********************************************************** */
 11 
 12 /* format: style4,delnl,insnl,indattr,ifthen,dclind10 */
 13 shutdown:
 14      procedure ();
 15 
 16 /* Procedure to stop the system in preparation for File System Shutdown.
 17    This can be called only from the Initializer. After setting CPU
 18    required to the bootload CPU, it stops all CPUs and disables traffic
 19    control. It calls shutdown_file_system, switching stacks along the
 20    way to inzr_stk0.
 21 
 22    This is called only during normal shutdown.  During emergency shutdown,
 23    shutdown_file_system is called directly.
 24 
 25    For the new Storage System, Bernard Greenberg, 10/20/75
 26    For demountable volumes, BSG 03/26/76
 27    For new flags in flagbox, 9/30/76 by Noel I. Morris
 28    For shutdown with downed drives, BSG 02/26/77
 29    For shutdown which doesn't give up, W. Olin Sibert, 05/18/81
 30    For set_procs_required, J. Bongiovanni, October 1981
 31    To remove Page Multilevel, C. Hornig, December 1981.
 32    To remove File System shutdown, J. Bongiovanni, March 1982
 33    To shutdown scavenger, J. Bongiovanni, September 1982
 34    To call stop_cpu$shutdown instead of stop_cpu, Chris Jones, April 1984
 35 */
 36 
 37 
 38 /****^  HISTORY COMMENTS:
 39   1) change(86-09-23,Beattie), approve(86-08-11,MCR7517),
 40      audit(86-10-23,Fawcett), install(86-11-03,MR12.0-1206):
 41      No BOS support for MR12.
 42                                                    END HISTORY COMMENTS */
 43 
 44 
 45 dcl       pds$processid          bit (36) aligned external;
 46 
 47 dcl       condition_             entry (char (*), entry);
 48 dcl       disk_emergency$test_all_drives
 49                                  entry;
 50 dcl       scavenger$shutdown     entry;
 51 dcl       set_procs_required     entry (bit (8) aligned, fixed bin (35));
 52 dcl       stop_cpu$shutdown      ext entry (fixed bin (2), fixed bin (35));
 53 dcl       switch_shutdown_file_system
 54                                  entry;
 55 dcl       syserr                 entry options (variable);
 56 dcl       syserr$error_code      entry options (variable);
 57 dcl       tc_shutdown            ext entry;
 58 
 59 dcl       tc_data$initializer_id bit (36) aligned external;
 60 
 61 dcl       code                   fixed bin (35);
 62 dcl       i                      fixed bin (2);
 63 dcl       cpu_mask               bit (8) aligned;
 64 
 65 dcl       LETTERS                char (8) internal static options (constant) init ("ABCDEFGH");
 66 dcl       my_name                char (8) internal static options (constant) init ("shutdown");
 67 
 68 dcl       (null, stackbaseptr, substr)
 69                                  builtin;
 70 
 71 /*^L*/
 72 
 73           if pds$processid ^= tc_data$initializer_id then
 74                return;                                      /* Only initializer can perform shutdown (trad.) */
 75 
 76 
 77           stackbaseptr () -> stack_header.stack_begin_ptr -> stack_frame.prev_sp = null ();
 78                                                             /* Guarantee that we shall never leave ring zero again */
 79 
 80           call condition_ ("any_other", shutdown_failed);   /* Don't let anything untoward happen, either */
 81 
 82 /* Now stop all CPU's other than the bootload one we are returning to */
 83 
 84           cpu_mask = "0"b;
 85           substr (cpu_mask, scs$bos_processor_tag + 1, 1) = "1"b;
 86           call set_procs_required (cpu_mask, code);
 87           if code ^= 0 then                                 /* Couldn't run on bootload CPU */
 88                call syserr$error_code (CRASH, code, "^a: Cannot run on CPU ^a (bootload CPU). Dump and try ESD.", my_name,
 89                     substr (LETTERS, scs$bos_processor_tag + 1, 1));
 90 
 91           do i = 0 to 7;
 92                if i ^= scs$bos_processor_tag then do;
 93                     if scs$processor_data (i).online then do;
 94                          call stop_cpu$shutdown (i, code);
 95                          if code ^= 0 then
 96                               call syserr (ANNOUNCE, "^a: Could not stop CPU ^a.", my_name, substr (LETTERS, i + 1, 1));
 97                     end;
 98                end;
 99           end;
100 
101 /* Determine downed drives. Done in wired_shutdown in ESD case */
102 
103           call disk_emergency$test_all_drives;
104 
105 /* Now stop other processes */
106 
107           call tc_shutdown;
108 
109 /*  After traffic control is shut down, reset any scavenges in progress  */
110 
111           call scavenger$shutdown;
112 
113 /* Switch stacks to inzr_stk0 and shutdown File System */
114 
115           call switch_shutdown_file_system;
116 
117 /*^L*/
118 
119 shutdown_failed:
120      proc (a_mcptr, a_condition, a_coptr, a_infoptr, a_continue) options (non_quick);
121 
122 dcl       a_mcptr                pointer parameter;
123 dcl       a_condition            char (*) parameter;
124 dcl       a_coptr                pointer parameter;
125 dcl       a_infoptr              pointer parameter;
126 dcl       a_continue             bit (1) aligned parameter;
127 
128 /* This procedure is called if any signallable faults occur in shutdown,
129    and simply crashes the system, in the hope that an ESD will be more
130    successful. */
131 
132           do while ("1"b);
133                call syserr (CRASH,
134                     "^a: Condition ^a signalled during shutdown. Normal shutdown failed. Get a dump, and try an ESD.",
135                     my_name, a_condition);
136           end;
137 
138      end shutdown_failed;
139 
140 %page;
141 %include scs;
142 %page;
143 %include stack_frame;
144 %page;
145 %include stack_header;
146 %page;
147 %include syserr_constants;
148 
149 /*^L*/
150 
151 /* BEGIN MESSAGE DOCUMENTATION
152 
153    Message:
154    shutdown: Could not stop CPU TAG.
155 
156    S: $info
157 
158    T: System shutdown.
159 
160    M: Shutdown stops all but the bootload processor. The CPU whose
161    tag is TAG could not be stopped.
162 
163    A: $note
164    If shutdown fails, put all CPU's other than the
165    bootload processor in step, return to BCE manually, and
166    attempt an ESD.
167 
168    Message:
169    shutdown: Condition CCCC signalled during shutdown. Normal shutdown
170    failed. Get a dump, and try an ESD.
171 
172    S: $crash
173 
174    T: System shutdown
175 
176    M: During the attempt to shut down the system, an unexpected condition
177    has been signalled. This may result from hardware problems, or a logic
178    error in the supervisor. The system crashes and returns to BCE, whereupon
179    an ESD should be attempted in order to finish flushing Multics
180    information from main memory. Because of the difference in implementation
181    between normal shutdown and ESD, it is possible that ESD will not
182    encounter the same problem, and instead be successful.
183 
184    Message:
185    shutdown: Cannot run on CPU X (bootload CPU). Dump and try ESD. ERRORMESSAGE
186 
187    S: $crash
188 
189    T: System shutdown
190 
191    M: During an attempt to shut down the system, the system could not run
192    on the bootload CPU. This problem may be due to hardware or software
193    problems.  The system will attempt to crash, which it may not complete.
194 
195    A: If the system does not complete its attempt to crash, it should
196    be crashed manually. It may be necessary to change the bootload CPU
197    manually. This can be done by putting all CPUs into STEP mode, manually
198    assigning an interrupt mask to the new bootload CPU from the bootload SCU
199    maintenance panel, taking only the new bootload CPU out of STEP mode, and
200    doing an EXECUTE SWITCHES on that CPU.  Once the system has crashed
201    successfully, an ESD should be attempted.  This will most likely succeed.
202 
203    END MESSAGE DOCUMENTATION */
204 
205      end;