1 * ***********************************************************
  2 * *                                                         *
  3 * * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  4 * *                                                         *
  5 * * Copyright (c) 1972 by Massachusetts Institute of        *
  6 * * Technology and Honeywell Information Systems, Inc.      *
  7 * *                                                         *
  8 * ***********************************************************
  9 
 10           ttl       multics/mcs trace package
 11           ttls      multics/mcs trace package
 12           lbl       ,trace
 13           pcc       off
 14           pmc       off
 15           editp     on
 16           detail    on
 17           rem
 18 ************************************************************************
 19 *
 20 *         trace
 21 *
 22 *         this routine is the interface for all trace calls
 23 *         made by other mcs routines. it does memory tracing
 24 *         directly and calls printer_trace to do any
 25 *         required printer tracing. the module number
 26 *         and a tracing type are always supplied by the
 27 *         caller.
 28 *
 29 *         memory tracing involves putting entries in a circular
 30 *         trace buffer which is printed by the various
 31 *         fnp dumping programs.
 32 *
 33 *         printer tracing is done under control of the
 34 *         processor switches and a switch word passed in
 35 *         the call. the printer_trace module need not
 36 *         be loaded, and the printer is an
 37 *         optional part of the configuration.
 38 *
 39 *         buffer tracing is a special form of printer
 40 *         tracing which causes buffers to be dumped
 41 *         to the printer
 42 *
 43 *   coded november 1974 by robert s. coren
 44 *   modified 1979 june 10 by art beattie to put trace data at high end
 45 *     of memory.
 46 *
 47 ************************************************************************
 48           rem
 49           rem
 50           pmc       save,on
 51           systm
 52           rem
 53           comreg
 54           ttls      macros, symdefs, etc.
 55 mpy       macro
 56           mpf       #1
 57           lrl       1
 58           endm
 59           rem
 60           rem
 61           symdef    trac
 62           symdef    trace     memory and printer tracing
 63           symdef    traceb    buffer tracing
 64           symdef    nxtrce    pointer to next entry in trace buffer
 65           symdef    endtrc    pointer to last word in trace buffer
 66           rem
 67           symref    simclk
 68           symref    ptrace
 69           symref    ptrabf
 70           symref    mvpgtg    move data paging target
 71           symref    setptw    virtualize absolute address and set ptw
 72           rem
 73           rem
 74           rem
 75           rem
 76 trac      null
 77           start     trac,8
 78           pmc       restore
 79           ttls      trace -- entry for memory and printer tracing
 80           rem
 81 ************************************************************************
 82 *
 83 *   trace is used for memory and printer tracing (other than buffer
 84 *   tracing). if bit corresponding to calling module in trace enable mask
 85 *   is off, tracing will not occur.
 86 *
 87 *   calling sequence:
 88 *
 89 *         tsy       addr-*,*
 90 *         vfd       6/count,12/type     count = number of data words
 91 *         vfd       6/modnum,12/switch
 92 * addr    ind       trace
 93 *         bss       count     data words
 94 *         ---                 return point
 95 *
 96 *   printer tracing will be done only if all "on" bits
 97 *   in modnum-switch word are on in processor switches, and "switch" is
 98 *   non-zero
 99 *
100 ************************************************************************
101           rem
102           rem
103 trace     subr      tra,(inh,q,x1,x2,x3)
104           rem
105           lda       trace-*,* get count-type word
106           lrl       12        separate items
107           qrl       6         and store them locally
108           staq      count-*
109           aos       trace-*   bump to modnum-switch word
110           lda       trace-*,*
111           lrl       12        treat it similarly
112           qrl       6
113           staq      modsw-*
114           rem
115           szn       a.a006-*,*          (.crtsw) is tracing disabled?
116           tnz       trabak-*  yes
117           rem
118           iaa       -1        get module number - 1
119           ora       l.a007-*  combine with shift template
120           sta       trashf-*  put it in shift instruction
121           ila       1
122           als       17        get high-order bit alone in a
123 trashf    arl       **        (modified above)
124           rem                 now we have bt corresponding to modnum
125           cana      a.a001-*,*          (.crtra) is mask bit on?
126           tze       trabak-*  if not, skip the whole thing
127           orsa      switch-*  hang on to bit
128           rem                 we will now do memory trace
129           lda       a.a010-*,*          (.crpte,*) remember current page table word
130           sta       tsvpte-*
131           rem
132           ldx1      nxtrce-*  get next available spot in trace table
133           cx1a
134           ldi       l.a001-*  (=o024000) inhibit overflow for this
135           ada       count-*   add data count
136           iaa       2         and two words for header
137           cmpa      endtrc-*  room for this entry?
138           tnc       tra010-*  yes
139           cx1a                no. copy address to a
140           tsy       a.a009-*,*          (setptw) virtualize absolute address
141           cax1                put it in original register
142           lda       l.a002-*  (525250) else put in end marker
143           sta       0,1
144           ila       1         make sure we make wraparound check
145           sta       wrap-*
146           rem
147           ldx1      a.a002-*,*          (.crtrb) physical beginning of table
148           cx1a
149           sta       nxtrce-*  is new next pointer
150           ada       count-*
151           iaa       3         for header and end marker
152           tra       tra020-*
153           rem
154 tra010    null                a contains pointer to end of next entry already
155           iaa       1         except for end marker
156 tra020    null                have we ever wrapped around table?
157           szn       wrap-*
158           tze       tra030-*  no, skip overwrite test
159           rem
160           rem                 will we overwrite more than one entry?
161           cmpa      a.a003-*,*          (.crtrc) oldest complete entry
162           tnc       tra030-*  will not be overwritten
163           rem                 fall through if it will, we must update .crtrc
164           sta       temp3-*   save pointer to next free word
165           ldq       a.a003-*,*          (.crtrc)
166 tra025    null
167           cqa                 copy address to a
168           tsy       a.a009-*,*          (setptw) virtualize absolute address
169           cax2                put it in x2
170           lda       0,2       get first word of entry
171           iana      63        isolate word count
172           iaa       2
173           sta       temp1-*
174           adq       temp1-*   bump pointer
175           cqa                 copy address to a
176           tsy       a.a009-*,*          (setptw) virtualize absolute address
177           cax2                put it in x2
178           lda       0,2       does it now point to physical end?
179           cmpa      l.a002-*  (525250)
180           tze       tra028-*  yes, start at beginning again
181           rem                 else see if we've gone far enough
182           cmpq      temp3-*   is start of next entry in the clear?
183           tnc       tra025-*  no, we will overwrite it too
184           tra       tra029-*  else store new value
185 tra028    null
186           ldq       a.a002-*,*          (.crtrb)
187           stz       wrap-*    don't test for overwrite again until
188           rem                 new entries wrap around
189 tra029    null
190           stq       a.a003-*,*          (.crtrc)
191           rem
192 tra030    null                ready to make new entry
193           ldq       count-*   get data count
194           iaq       3         2 words of header and end marker
195           stq       memlen-*  save length of trace entry
196           rem                 first put in new end marker
197           ldx1      a.a008-*  x1 points to beginning of new entry
198           ldx3      a.a008-*
199           adcx3     count-*
200           lda       l.a003-*  (=o525252) logical end marker
201           sta       2,3       include 2 words for header
202           rem
203           lda       modsw-*   get modnum
204           als       6
205           ora       ttype-*   and type
206           als       6
207           ora       count-*   and count
208           sta       0,1       this is entry header word
209           rem                 get time now
210           lda       a.a005-*,*          (itmb) interval timer
211           sta       ttime+1-* store as 36-bit quantity
212           ldaq      a.a004-*,*          (simclk)
213           sbaq      ttime-*   subract saved interval timer
214           stq       1,1       put it in trace entry (low-order 18 bits only)
215           iacx1     2         point to data area
216           ldx2      trace-*   point to input data
217           iacx2     2
218           stx2      datap-*   save data pointer for possible printer tracing
219           ldq       count-*   get count of data words
220           tze       tra050-*  if any
221           rem
222 tra040    null
223           lda       0,2       copy data word into
224           sta       0,1       temporary storage
225           iacx1     1
226           iacx2     1         bump pointers
227           iaq       -1        decrement count
228           tnz       tra040-*  get next word if any
229           rem
230 *
231 *  move data from temporary storage to trace data buffer
232           rem
233 tra050    null
234           ldx2      a.a008-*  source address
235           ldx3      nxtrce-*  target address
236           ldq       memlen-*  length of move
237           tsy       a.a007-*,*          (mvpgtg)
238 *
239 *  restore cpu page table entry
240 *
241           lda       tsvpte-*  previous value
242           sta       a.a010-*,*          (.crpte,*) is restored
243           rem
244           lda       nxtrce-*  update pointer
245           ada       count-*   data count
246           iaa       2         2 word header
247           sta       nxtrce-*  marker is overwritten by next entry
248           rem
249           rem                 now find out if we're supposed to do
250           rem                 printer tracing
251           rem
252           ldx2      a.a014-*,*          (.criom) get ptr to iom table
253           szn       lpch*2,2  is a printer configured?
254           tze       trabak-*  no, don't try tracing
255           rem
256           lda       switch-*  get switch word
257           cana      l.a004-*  (=o007777) are switches all zero?
258           tze       trabak-*  yes, no printer tracing
259           rem                 else read processor switches to find out
260           sel       swch      if specified ones are on
261           stex      procsw-*
262           rem
263           ana       procsw-*  are all relevant switches on?
264           cmpa      switch-*  these will compare equal if so
265           tnz       trabak-*  if they aren't don't print
266           rem
267           lda       modsw-*   get module sw for ptrace
268           ldq       ttype-*   and the type too
269           ldx2      datap-*   get ptr to data
270           tsy       a.a015-*,*          (ptrace) do actual printer tracing
271           rem
272 trabak    null                return from trace
273           rem                 "tsy" word now points 2 words past call
274           lda       count-*
275           asa       trace-*   bump it over data and address of trace routine
276           aos       trace-*
277           aos       trace-*
278           return    trace     goodbye
279           ttls      traceb -- entry for buffer tracing
280           rem
281 ************************************************************************
282 *
283 *   traceb is used to print the contents of a buffer on the printer
284 *
285 *   calling sequence:
286 *
287 *         ldx3      bufadr-*  address of buffer
288 *         tsy       addr-*,*
289 *         vfd       6/modnum,12/size    size of buffer is in words
290 *addr     ind       traceb
291 *         ---                 return point
292 *
293 *   if the printer is configured, the call will be passed on to trabf
294 *   to do the work, otherwise traceb just returns.
295 *
296 ************************************************************************
297           rem
298 traceb    subr      trc,(inh,q,x1,x2,x3)
299           rem
300           ldx2      a.a014-*,*          (.criom) get ptr to iom table
301           szn       lpch*2,2  printer configured?
302           tze       trcbak-*  no, just return
303           lda       traceb-*,*          get modnum/size word
304           tsy       a.a013-*,*          (ptrabf)
305           rem
306 trcbak    null
307           aos       traceb-*  bump return pointer past arguments
308           aos       traceb-*
309           return    traceb
310           ttls      trace symbols
311           rem
312 a.a001    ind       .crtra    trace enable mask
313 a.a002    ind       .crtrb    base of trace table
314 a.a003    ind       .crtrc    pointer to oldest valid entry in trace table
315 a.a004    ind       simclk    next timer interrupt time
316 a.a005    ind       itmb      interval timer
317 a.a006    ind       .crtsw    global trace control switch
318 a.a007    ind       mvpgtg    move data paging target
319 a.a008    ind       trctmp    temporary storage for trace data
320 a.a009    ind       setptw    virtualize absolute address and set ptw
321 a.a010    ind       .crpte,*  page table entry for ptw
322 a.a013    ind       ptrabf    real buffer tracing subroutine
323 a.a014    ind       .criom
324 a.a015    ind       ptrace
325           rem
326 l.a001    oct       024000    inhibit overflow & interrupt
327 l.a002    oct       525250    tag for physical end of trace table
328 l.a003    oct       525252    tag for logical end of trace table
329 l.a004    oct       007777    mask for switches
330 l.a007    arl       0         model for "arl" instruction
331           rem
332 memlen    oct       0
333           rem
334           even
335 count     bss       1         count of data words passed
336 ttype     bss       1         trace type
337 modsw     bss       1         module number
338 switch    bss       1         printer tracing switch(es)
339           rem
340           even
341 ttime     oct       0,0       interval timer value saved as 36-bit number
342 tsvpte    oct       0         save-store for ptw on entry to trace
343           rem
344 nxtrce    oct       0         pointer to next available entry in trace buffer
345           rem                 table (initialized to point to base)
346 endtrc    oct       0         end of table addr
347           rem
348 wrap      oct       0         flag indicating that the trace buffer has
349           rem                 wrapped around
350           rem
351 procsw    bss       1         word for reading processor switches
352 temp1     bss       1         a temporary
353 temp3     bss       1         another one
354 datap     bss       1         address of current data word
355           rem
356 trctmp    bss       32        storage to copy data into before copying into
357           rem                   trace data buffer
358           end