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 " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
 13 "
 14 "         device_control
 15 "
 16 "         Dispatcher to appropriate dim on device type.
 17 "         The entries read, write, and run are transfered to via
 18 "         a tsx7.
 19 "         Index registers x2,x3,x4,x7 must be preserved.
 20 "
 21 " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " "
 22 
 23 " Modified 2/6/74 by N. I. Morris
 24 " Modified 4/8/74 by S. H.Webber to meter reads and writes per device
 25 " Modified 6/6/74 by B. Greenberg for unified page_wait strategy.
 26 " Modified 12/11/74 by B. Greenberg for cme.notify_requested and new cme/ptw protocol
 27 " Modified 02/28/75 by BSG for NSS
 28 " Modified 06/21/79 by BSG for stack 0 sharing
 29 " Modified 1/80 by R.J.C. Kissel to eliminate a builtin constant
 30 " Modified 03/29/81, W. Olin Sibert, to conditionalize Page Multilevel
 31 " Modified 03/03/82 by J. Bongiovanni to remove Page Multilevel, and for new PVTE
 32 " Modified 6/21/82 by E. N. Kittlitz to move core map.
 33 
 34           include   pxss_page_stack
 35           include   aste
 36           include   pvte
 37           include   add_type
 38           include   stack_frame
 39           include   stack_header
 40           include   page_info
 41           include   sst
 42           include   ptw
 43           include   cmp
 44           include   apte
 45           include   fs_dev_types
 46 "^L
 47 
 48           name      device_control
 49 
 50           segdef    dev_read,dev_write,time_out,run,init,pwait,esd_reset
 51           segdef    disk_offlinep
 52           entry     ptl_waitlock
 53           segdef    check_ckdv,ckdv_from_pvtx
 54           entry     pwait_return
 55 " ^L
 56 init:
 57           push      "gonna call out.
 58           ldq       ap|2,*    get pvtx
 59           stq       pvtx
 60 
 61           tsx0      get_device_type     get from pvt
 62 
 63           short_call disk_init$disk_init(ap|0)
 64           return
 65 
 66 
 67 
 68 esd_reset:                    "this entry is called to flush out all dim I/O reqs.
 69                               " note this works elegantly at ESD time, but does not
 70                               "extend easily to fault recover time.
 71           push                "for callouts
 72           epp       sst,sst$
 73           stz       sst|sst.ptl         somebody has to do this.
 74           short_call disk_control$esd_reset_locks
 75 
 76           tsx7      core_queue_man$clearout
 77           return
 78 
 79 
 80 dev_read:
 81           tsx0      get_device_type     get it from pvt
 82           aos       sst$+sst.reads-1,al
 83 
 84 
 85           eppap     dctl$disk_read
 86           tra       call_join           go call the dim
 87 
 88 dev_write:
 89           tsx0      get_device_type
 90           aos       sst$+sst.writes-1,al
 91           aos       sst$+sst.wtct
 92 
 93           eppap     dctl$disk_write
 94 
 95 call_join:
 96           eppbp     inter               pick up flag saying to interrupt
 97           spribp    arg+8
 98           eppbp     pvtx
 99           spribp    arg+2
100           eppbp     core_add
101           spribp    arg+4
102           eppbp     devadd
103           spribp    arg+6
104           fld       =4b24,dl            4 arguments
105           ora       4,dl                all arg acceptable to PL1
106           staq      arg
107           eppbp     ap|0                can't use ap to call
108           call      bp|0(arg)
109           eppbp     sst$+0,2            restore bp to point into SST
110           epbpbb    bp|0                restore bb to point to base of sst
111           tra       0,7
112 
113 
114 
115 
116 pwait:                        "entry to wait for any page control event
117 push:     push                "no more  frame-avoiding m-mouse
118           tsx6      page_fault$init_savex_bb
119 pwait_retry:
120           lda       ap|2,*              get event in a
121           cana      -1,du               global event?
122           tnz       await_tc
123 
124           als       18                  move to upper
125           lda       sst|0,au            get ptw
126           cana      ptw.os,dl           see if event still there
127           tze       .ret_long           return if no longer o/s
128           arl       2                   get core map index
129           eaa       cme.devadd,au       set to get devadd
130           ldq       cme.notify_requested,dl set notify bit in cme
131           orsq      sst|sst.cmp,*au     .. as we came here to wait.
132           lda       sst|sst.cmp,*au     get devadd word
133 
134 await_tc:
135           lda       ap|2,*              get argument
136           eppap     pds$apt_ptr,*       get apt ptr
137           sta       ap|apte.wait_event  put it where it can get notified.
138 
139           tsx7      page_fault$unlock_ptl
140                                         "clear postqueue, perhaps notify
141 
142 
143           tra       pxss$waitp
144 
145 ptl_waitlock:                           "contract of this entry:
146                     " 1. Who tras to me is in his stack frame, with its own return ptr valid.
147                     " 2. Who tras to me has masked to sys_level and wired the (pds) stack.
148                     " 3. I shall execute a full Multics return (to prev frame) when
149                     "    and only when I have the PTL locked.
150 
151                     "It is NOT necessary to stx6 init_savex here.
152 
153           push                "Establish page control frame.
154 pwait_return:
155           epp3      sst$                don't forget!
156           tsx7      core_queue_man$trylock_ptl
157            tra      pxss$dvctl_retry_ptlwait
158                               "patch to tra *-1 if too obscure
159 
160 .ret_long:return
161 
162 
163 
164 time_out:                               "entry to call to make sure disks havn't stopped
165           save
166           tsx7      page_fault$lock_ptl lock the page table lock
167           tsx6      page_fault$init_savex  init x7 save stack
168           tsx7      run                 call run on each device
169           tsx7      page_fault$unlock_ptl  unlock the page table lock
170           return
171 
172 run:
173           tsx6      page_fault$savex
174           tsx7      core_queue_man$run_core_queue
175           tsx6      pc_trace$running    trace the fact that we called run
176 
177           eppap     =v18/0,18/4,18/0,18/0
178           call      disk_control$disk_run
179           tra       page_fault$unsavex
180 
181 
182 
183 disk_offlinep:
184           tsx0      get_device_type
185           lda       lb|pvte.device_inoperative_word
186           cana      pvte.device_inoperative,dl
187           tze       1,7
188           tra       0,7
189 
190 get_device_type:
191           ldq       pvtx
192           tmoz      page_error$bad_device_id
193           mpy       pvte_size,dl        index the pvt
194           epplb     pvt$array
195           epplb     lb|-pvte_size,ql    address the PVTE
196           lda       lb|pvte.device_type_word
197           arl       pvte.device_type_shift
198           tze       page_error$bad_device_id
199           cmpa      fs_dev.max_dev_type,dl
200           tpnz      page_error$bad_device_id
201           tra       0,0
202 
203 
204 
205 check_ckdv:
206           lda       page_fault$cme_devadd,*4 what device is this?
207           lda       ast|aste.pvtx_word,3
208           arl       aste.pvtx_shift
209           ana       aste.pvtx_mask,dl   get disk's pvtx
210 ckdv_from_pvtx:
211           lrl       36                  move to x
212           mpy       pvte_size,dl
213           eppap     pvt$array
214           eppap     ap|-pvte_size,ql    address the PVTE
215           lda       ap|pvte.check_read_incomplete_word
216           cana      pvte.check_read_incomplete,dl are we checking this dev?
217           tnz       0,7
218           tra       1,7                 no
219           end