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           name      wire_stack
 12 
 13 
 14 " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
 15 "
 16 " Calling Sequence:
 17 "         call wire_stack
 18 "
 19 " This procedure is designed to be called only from PL/1 programs
 20 " through the use of the validate option.
 21 "
 22 " wire_stack performs the following steps:
 23 "         1. If the current stack is the PRDS, or if this is too
 24 "            early in initialization, return.  Too early in
 25 "            initialization means before the SCS is set up, as this
 26 "            is when the masking mechanism is operative.
 27 "         2. A stack frame for wire_stack is created which
 28 "            overlays the caller's stack frame.
 29 "         3. The memory mask is set to sys_level.
 30 "         4. The current and next pages of the stack are wired down.
 31 "         5. A cleanup condition is established.
 32 "         6. A new stack frame is manfactured for the caller.
 33 "         7. The caller is returned to in his new frame.
 34 "
 35 " The steps above are undone either when the caller returns
 36 " or when a non-local goto occurs.
 37 "
 38 "
 39 " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
 40 
 41 
 42 " ^L
 43 
 44           segref    scs,faults_initialized
 45           segref    scs,read_mask,mask_ptr,sys_level
 46           segref    prds,processor_tag
 47           segref    tc_data,system_shutdown
 48           segref    privileged_mode_ut,wire_and_mask,unwire_unmask
 49           segref    condition_,condition_
 50 
 51           link      prds_link,<prds>|0
 52 
 53 
 54           tempd     ptp                 pointer to stack's page table
 55           tempd     save_mask           previous memory controller mask
 56           tempd     label(2)            label for cleanup condition
 57           tempd     arglist(5)          argument list for call to condition_
 58 
 59 " ^L
 60 
 61           include   stack_header
 62 
 63           include   stack_frame
 64 
 65           include   scs
 66 " ^L
 67 
 68           entry     wire_stack
 69 
 70 wire_stack:
 71 
 72 " Ignore this call if on the PRDS or if too early in initialization
 73 
 74           epaq      sp|0                segment # of stack in AU
 75           eax0      0,au                place in X0
 76           cmpx0     lp|prds_link        are we on the prds?
 77           tze       .rt                 if so, just return
 78           ldq       prds$processor_tag
 79           lda       scs$processor_data,ql         get data for this CPU
 80           cana      processor_data.online+processor_data.offline,du   early initialization?
 81           tze       .rt                           yes, ignore call
 82 
 83 " Ignore this call if masked down.
 84 
 85           inhibit   on        <+><+><+><+><+><+><+><+><+><+><+><+>
 86           lxl1      processor_tag       CPU tag in X1
 87           lprpab    mask_ptr,1          get pointer for masking
 88           xec       read_mask,1         read system controller mask
 89           eraq      sys_level           masked to sys level?
 90           anaq      =v16/-1,20/,16/-1,20/  ..
 91           tze       .rt                 if so, ignore the call
 92           inhibit   off       <-><-><-><-><-><-><-><-><-><-><-><->
 93 
 94 " Make stack frame for wire_stack.
 95 
 96           eppap     sp|stack_frame.min_length     establish stack frame for wire stack
 97           sprisp    ap|stack_frame.prev_sp        leave only the bare minimum of old frame
 98           eppsp     ap|0                          caller's old frame will be rethreaded later
 99           adwpap    push                          ap -> new frame for caller
100           spriap    sp|stack_frame.next_sp        set pointer to next frame
101           eppbb     sb|stack_header.stack_end_ptr,*  save stack end ptr in bb
102           spriap    sb|stack_header.stack_end_ptr set pointer to new end of stack
103           sprilp    sp|stack_frame.lp_ptr         save linkage pointer
104 
105 " Call privileged_mode_ut$wire_and_mask to do the work.
106 
107           eppbp     save_mask           bp -> place for saved controller mask
108           spribp    arglist+2           ..
109           eppbp     ptp                 bp -> place for page table pointer
110           spribp    arglist+4           ..
111           ldaq      =v18/4,18/4         set arglist header
112           staq      arglist             ..
113 
114           call      wire_and_mask(arglist) wire and mask
115 
116 " Set up argument list and call condition_.
117 
118           szn       faults_initialized  have faults been initialized yet?
119           tze       create_frame        if not, skip call to condition_
120 
121           szn       system_shutdown     are we shutting down?
122           tnz       create_frame        if so, don't establish condition
123 
124           link      cleanup_link,<*text>|[cleanup_handler]
125           eppap     lp|cleanup_link,*   make label for cleanup handler
126           spriap    label               ..
127           sprisp    label+2             ..
128 
129           eppap     lp|condition_name   ap -> character string
130           spriap    arglist+2           set up argument list
131           eppap     label               ap -> label
132           spriap    arglist+4           ..
133           eppap     lp|condition_name_desc set up descriptor list
134           spriap    arglist+6           ..
135           eppap     lp|label_desc       ..
136           spriap    arglist+8           ..
137           ldaq      =v18/4,18/4,18/4    set argument list header
138           staq      arglist             ..
139 
140           sprilp    sp|stack_frame.lp_ptr  be careful to save linkage pair
141 
142           call      condition_(arglist)  establish the condition
143 
144           epplp     sp|stack_frame.lp_ptr,*       restore the linkage pair now
145 
146 " Create new stack frame for caller.
147 
148 create_frame:
149           eppbp     sb|stack_header.stack_end_ptr,*  bp -> caller's new frame
150           eppap     sp|stack_frame.prev_sp,*      ap -> caller's old frame
151           mlr       (pr),(pr)                     copy the stack frame header
152           desc9a    ap|0,stack_frame.min_length*4
153           desc9a    bp|0,stack_frame.min_length*4
154 
155           eax1      bb|0                          X1 contains offset of original end ptr
156           sblx1     sp|stack_frame.prev_sp+1      compute length of caller's frame
157 
158           sprisp    ap|stack_frame.next_sp        set next sp in old frame
159           sprisp    bp|stack_frame.prev_sp        set last sp in new frame
160           eppap     bp|0,1                        compute next sp for new frame
161           spriap    bp|stack_frame.next_sp        and set it
162           spriap    sb|stack_header.stack_end_ptr save new stack end ptr
163 
164 " Fill in wire_stack's frame with vital info.
165 
166           link      return_link,<*text>|[return]
167           eppap     lp|return_link,*    ap -> return entry
168           spriap    sp|stack_frame.return_ptr     set return control double info
169           sprilp    sp|stack_frame.lp_ptr         save pointer so return op will work
170 
171 " Switch to new frame and return to caller.
172 
173           eppsp     bp|0                sp -> new frame
174           sprisp    sp|12               doctor the stored prs
175 
176 .rt:
177           eppap     sp|stack_frame.operator_ptr,* restore pr to operators
178           rtcd      sp|stack_frame.return_ptr     return to caller
179 
180 
181 " ^L
182 
183           entry     return
184 
185 return:                                 "normal return from caller
186           eppbp     sp|0                bp -> stack frame
187           tsx7      undo                unwire and unmask
188 
189           inhibit   on        <+><+><+><+><+><+><+><+><+><+><+><+>
190           eppsp     sp|stack_frame.prev_sp,*      sp -> caller's old frame
191           return                        " return to caller's caller
192           inhibit   off       <-><-><-><-><-><-><-><-><-><-><-><->
193 
194 
195           entry     cleanup_handler
196 
197 cleanup_handler:                        "invoked by non-local goto
198 push:     push
199 
200           ldx0      ap|0                2 * number of args in X0
201           eppbp     ap|2,0*             grab display pointer
202           tsx7      undo                clean things up
203 
204           return                        return to the unwinder
205 
206 
207 " Subroutine to perform unwiring and unmasking.
208 
209 undo:
210           eppap     bp|save_mask        ap -> save mask
211           spriap    bp|arglist+2        ..
212           eppap     bp|ptp              ap -> page table pointer
213           spriap    bp|arglist+4        ..
214           ldaq      =v18/4,18/4         set arglist header
215           staq      bp|arglist          ..
216 
217           call      unwire_unmask(bp|arglist) unwire and unmask
218 
219           tra       0,7                 return to caller
220 
221 
222 " ^L
223 
224           even
225 
226 null:
227           its       -1,1                null pointer
228 
229 
230           use       internal_static
231           join      /link/internal_static
232 
233 condition_name:
234           aci       "cleanup"
235 
236 condition_name_desc:
237           vfd       o18/10121,18/7
238 
239 label_desc:
240           vfd       o18/172
241 
242 
243           end