0
|
1 ********************************************************************
|
|
2 * IOMan - OS-9 Level One V2 I/O Manager module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
1499
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
0
|
8 * ------------------------------------------------------------------
|
1499
|
9 * 11 ????/??/??
|
|
10 * From Tandy OS-9 Level One VR 02.00.00
|
|
11 *
|
|
12 * 12 2002/05/11 Boisy G. Pitre
|
|
13 * I/O Queue sort bug and I$Attach static storage premature deallocation
|
|
14 * bug fixed.
|
0
|
15
|
|
16 nam IOMan
|
|
17 ttl OS-9 Level One V2 I/O Manager module
|
|
18
|
|
19 ifp1
|
|
20 use defsfile
|
253
|
21 use scfdefs
|
0
|
22 endc
|
|
23
|
|
24 tylg set Systm+Objct
|
|
25 atrv set ReEnt+rev
|
1287
|
26 rev set $00
|
75
|
27 * edition 11 = Stock OS-9 Level One Vr. 2.00 IOMan
|
|
28 * edition 12 = IO Queue sort bug fixed, IAttach bug fixed
|
|
29 edition equ 12
|
0
|
30
|
|
31 mod eom,name,tylg,atrv,IOManEnt,size
|
|
32
|
|
33 size equ .
|
|
34
|
|
35 name fcs /IOMan/
|
|
36 fcb edition
|
|
37
|
|
38 * IOMan is called from OS9p2
|
|
39 IOManEnt equ *
|
|
40 * allocate device and polling tables
|
79
|
41 ldx <D.Init get pointer to init module
|
|
42 lda PollCnt,x grab number of polling entries
|
|
43 ldb #POLSIZ and size per entry
|
|
44 mul D = size of all entries in bytes
|
|
45 pshs b,a save off
|
|
46 lda DevCnt,x get device table count in init mod
|
|
47 ldb #DEVSIZ get size per dev table entry
|
|
48 mul D = size of all entires in bytes
|
|
49 pshs b,a save off
|
|
50 addd 2,s add devsize to polsiz
|
|
51 addd #$0018 add in ???
|
|
52 addd #$00FF bring up to next page
|
0
|
53 clrb
|
79
|
54 os9 F$SRqMem ask for the memory
|
|
55 bcs Crash crash if we can't get it
|
0
|
56 * clear allocated mem
|
79
|
57 leax ,u point to dev table
|
0
|
58 L0033 clr ,x+
|
|
59 subd #$0001
|
|
60 bhi L0033
|
79
|
61 stu <D.PolTbl U = pointer to polling table
|
|
62 ldd ,s++ get dev table size
|
|
63 leax d,u point X past polling table to dev table
|
|
64 stx <D.DevTbl save off X to system vars
|
|
65 addd ,s++ grab poll table size
|
0
|
66 leax d,u
|
|
67 stx <D.CLTB
|
|
68 ldx <D.PthDBT
|
|
69 os9 F$All64
|
|
70 bcs Crash
|
|
71 stx <D.PthDBT
|
|
72 os9 F$Ret64
|
79
|
73 leax >DPoll,pcr get address of IRQ poll routine
|
|
74 stx <D.Poll save in statics
|
0
|
75 * install I/O system calls
|
79
|
76 leay <IOCalls,pcr point to I/O calls
|
|
77 os9 F$SSvc install them
|
|
78 rts return to OS9p2
|
0
|
79
|
|
80 Crash jmp [>$FFFE]
|
|
81
|
|
82 IOCalls fcb $7F
|
|
83 fdb UsrIO-*-2
|
|
84
|
|
85 fcb F$Load
|
|
86 fdb FLoad-*-2
|
|
87
|
|
88 fcb F$PErr
|
|
89 fdb FPErr-*-2
|
|
90
|
|
91 fcb F$IOQu+$80
|
|
92 fdb FIOQu-*-2
|
|
93
|
|
94 fcb $FF
|
|
95 fdb SysIO-*-2
|
|
96
|
|
97 fcb F$IRQ+$80
|
|
98 fdb FIRQ-*-2
|
|
99
|
|
100 fcb F$IODel+$80
|
|
101 fdb FIODel-*-2
|
|
102
|
|
103 fcb $80
|
|
104
|
|
105 FIODel ldx R$X,u
|
|
106 ldu <D.Init
|
|
107 ldb DevCnt,u get device count
|
|
108 ldu <D.DevTbl
|
|
109 L0083 ldy V$DESC,u
|
|
110 beq L0094
|
|
111 cmpx V$DESC,u
|
|
112 beq L009B
|
|
113 cmpx V$DRIV,u
|
|
114 beq L009B
|
|
115 cmpx V$FMGR,u
|
|
116 beq L009B
|
|
117 L0094 leau DEVSIZ,u
|
|
118 decb
|
|
119 bne L0083
|
|
120 clrb
|
|
121 rts
|
|
122 L009B comb
|
|
123 ldb #E$ModBsy
|
|
124 rts
|
|
125
|
|
126 UsrIODis fdb IAttach-UsrIODis
|
|
127 fdb IDetach-UsrIODis
|
|
128 fdb IDup-UsrIODis
|
|
129 fdb IUsrCall-UsrIODis
|
|
130 fdb IUsrCall-UsrIODis
|
|
131 fdb IMakDir-UsrIODis
|
|
132 fdb IChgDir-UsrIODis
|
|
133 fdb IDelete-UsrIODis
|
|
134 fdb UISeek-UsrIODis
|
|
135 fdb UIRead-UsrIODis
|
|
136 fdb UIWrite-UsrIODis
|
|
137 fdb UIRead-UsrIODis
|
|
138 fdb UIWrite-UsrIODis
|
|
139 fdb UIGetStt-UsrIODis
|
|
140 fdb UISeek-UsrIODis
|
|
141 fdb UIClose-UsrIODis
|
|
142 fdb IDeletX-UsrIODis
|
|
143
|
|
144 SysIODis fdb IAttach-SysIODis
|
|
145 fdb IDetach-SysIODis
|
|
146 fdb SIDup-SysIODis
|
|
147 fdb ISysCall-SysIODis
|
|
148 fdb ISysCall-SysIODis
|
|
149 fdb IMakDir-SysIODis
|
|
150 fdb IChgDir-SysIODis
|
|
151 fdb IDelete-SysIODis
|
|
152 fdb SISeek-SysIODis
|
|
153 fdb SIRead-SysIODis
|
|
154 fdb SIWrite-SysIODis
|
|
155 fdb SIRead-SysIODis
|
|
156 fdb SIWrite-SysIODis
|
|
157 fdb SIGetStt-SysIODis
|
|
158 fdb SISeek-SysIODis
|
|
159 fdb SIClose-SysIODis
|
|
160 fdb IDeletX-SysIODis
|
|
161
|
79
|
162
|
|
163 * Entry to User and System I/O dispatch table
|
|
164 * B = I/O system call code
|
0
|
165 UsrIO leax <UsrIODis,pcr
|
|
166 bra IODsptch
|
|
167 SysIO leax <SysIODis,pcr
|
79
|
168 IODsptch cmpb #I$DeletX compare with last I/O call
|
|
169 bhi L00FA branch if greater
|
0
|
170 pshs b
|
79
|
171 lslb multiply by 2
|
|
172 ldd b,x offset
|
|
173 leax d,x get address of routine
|
0
|
174 puls b
|
79
|
175 jmp ,x jump to it!
|
|
176 L00FA comb we get here if illegal I/O code
|
0
|
177 ldb #E$UnkSvc
|
|
178 rts
|
|
179
|
|
180 IAttach ldb #$11
|
|
181 L0100 clr ,-s
|
|
182 decb
|
|
183 bpl L0100
|
|
184 stu <$10,s caller regs
|
|
185 lda R$A,u
|
|
186 sta $09,s device mode
|
|
187 ldx R$X,u
|
|
188 lda #Devic+0
|
|
189 os9 F$Link link to device desc.
|
|
190 bcs L0139
|
|
191 stu $04,s address of mod hdr
|
|
192 ldy <$10,s get caller regs
|
|
193 stx R$X,y save updated ptr
|
|
194 ldd M$Port+1,u get port addr
|
|
195 std $0C,s save on stack
|
|
196 ldd M$PDev,u get driver name
|
|
197 leax d,u point X to driver name
|
|
198 lda #Drivr+0
|
|
199 os9 F$Link link to driver
|
|
200 bcs L0139
|
|
201 stu ,s save driver addr on stack
|
|
202 ldu $04,s get addr of dev desc.
|
|
203 ldd M$FMgr,u get file mgr name
|
|
204 leax d,u point X to fmgr name
|
|
205 lda #FlMgr+0
|
|
206 os9 F$Link link to fmgr
|
|
207 L0139 bcc L0149
|
|
208 * error on attach, so detach
|
|
209 L013B stb <$11,s save fmgr addr on stack
|
|
210 leau ,s point U to S
|
|
211 os9 I$Detach
|
|
212 leas <$11,s clean up stack
|
|
213 comb
|
|
214 puls pc,b return to caller
|
|
215 L0149 stu $06,s save fmgr addr
|
|
216 ldx <D.Init
|
|
217 ldb DevCnt,x
|
|
218 lda DevCnt,x
|
|
219 ldu D.DevTbl
|
|
220 L0153 ldx V$DESC,u get desc addr
|
|
221 beq L0188
|
|
222 cmpx $04,s same?
|
|
223 bne L016E branch if not
|
|
224 ldx V$STAT,u get stat
|
|
225 bne L016C branch if zero
|
|
226 pshs a
|
|
227 lda V$USRS,u get user count
|
|
228 beq L0168
|
|
229 os9 F$IOQu
|
|
230 L0168 puls a
|
|
231 bra L0153
|
|
232 L016C stu $0E,s save dev entry on stack
|
|
233 L016E ldx V$DESC,u get dev desc ptr
|
|
234 ldy M$Port+1,x
|
|
235 cmpy $0C,s compare to port addr on stack
|
|
236 bne L0188
|
|
237 ldx V$DRIV,u
|
|
238 cmpx ,s compare to driver addr on stack
|
|
239 bne L0188
|
|
240 ldx V$STAT,u get static
|
|
241 stx $02,s save static on stack
|
|
242 tst V$USRS,u test user count
|
|
243 beq L0188 branch if zero
|
|
244 sta $0A,s store on stack
|
|
245 L0188 leau DEVSIZ,u go to next entry
|
|
246 decb decrement count
|
|
247 bne L0153 go back to loop if not zero
|
|
248 ldu $0E,s get dev entry off stack
|
|
249 lbne L01E6
|
|
250 ldu D.DevTbl
|
|
251 L0195 ldx V$DESC,u get dev desc ptr
|
|
252 beq L01A6 branch if zero
|
|
253 leau DEVSIZ,u
|
|
254 deca
|
|
255 bne L0195 continue loop
|
|
256 ldb #E$DevOvf device table overflow
|
|
257 bra L013B
|
|
258 L01A2 ldb #E$BMode bad mode
|
|
259 bra L013B
|
|
260 L01A6 ldx $02,s get static storage off stack
|
|
261 lbne L01DD
|
|
262 stu $0E,s save off dev entry on stack
|
|
263 ldx ,s get driver addr off stack
|
|
264 ldd M$Mem,x get memory requirement
|
|
265 addd #$00FF round up to next page
|
|
266 clrb
|
|
267 os9 F$SRqMem
|
|
268 lbcs L013B
|
|
269 stu $02,s save off on stack
|
|
270 L01BF clr ,u+ clear static mem
|
|
271 subd #$0001
|
|
272 bhi L01BF
|
|
273 ldd $0C,s get port addr off stack
|
|
274 ldu $02,s get static storage ptr
|
|
275 clr V.PAGE,u
|
|
276 std V.PORT,u save addr
|
|
277 ldy $04,s get dev desc addr
|
|
278 ldx ,s get driver addr
|
|
279 ldd M$Exec,x get driver exec
|
|
280 jsr d,x call Init routine
|
|
281 lbcs L013B
|
|
282 ldu $0E,s get dev entry
|
|
283 L01DD ldb #$08 copy 8 bytes from stack to dev entry
|
|
284 L01DF lda b,s
|
|
285 sta b,u
|
|
286 decb
|
|
287 bpl L01DF
|
|
288 L01E6 ldx V$DESC,u get dev desc
|
|
289 ldb M$Revs,x
|
|
290 lda $09,s get device mode off stack
|
|
291 anda M$Mode,x AND mode with desc mode
|
|
292 ldx V$DRIV,u get driver ptr
|
|
293 anda M$Mode,x AND mode with driver mode
|
|
294 cmpa $09,s compare with passed mode
|
|
295 lbne L01A2 branch if error
|
|
296 inc V$USRS,u else inc user count of dev entry
|
|
297 bne L01FE branch if not overflow from 255->0
|
|
298 dec V$USRS,u else dec
|
|
299 L01FE ldx <$10,s get caller regs
|
|
300 stu R$U,x
|
|
301 leas <$12,s restore stack
|
|
302 clrb
|
|
303 rts
|
|
304
|
|
305 IDetach ldu R$U,u
|
|
306 ldx V$DESC,u
|
75
|
307 IFEQ edition-11
|
|
308 * Note: the following lines constitute a bug that can, in certain
|
|
309 * circumstances, wipe out a device's static storage out from
|
|
310 * underneath it.
|
0
|
311 ldb V$USRS,u get user count
|
|
312 bne L0218 branch if not zero
|
|
313 pshs u,b
|
|
314 ldu V$STAT,u
|
|
315 pshs u
|
|
316 bra L0254
|
75
|
317 ELSE
|
|
318 tst V$USRS,u
|
|
319 beq IDetach2
|
|
320 ENDC
|
0
|
321 L0218 lda #255
|
|
322 cmpa V$USRS,u 255 users?
|
|
323 lbeq L0283 branch if so
|
|
324 dec V$USRS,u else dec user count
|
|
325 lbne L0271 branch if dec not 0
|
75
|
326 IDetach2
|
0
|
327 ldx <D.Init
|
|
328 ldb DevCnt,x
|
|
329 pshs u,b
|
|
330 ldx V$STAT,u
|
|
331 clr V$STAT,u
|
|
332 clr V$STAT+1,u
|
|
333 ldy <D.DevTbl
|
|
334 L0235 cmpx V$STAT,y
|
|
335 beq L0267
|
|
336 leay DEVSIZ,y
|
|
337 decb
|
|
338 bne L0235
|
|
339 ldy <D.Proc
|
|
340 ldb P$ID,y
|
|
341 stb V$USRS,u
|
|
342 ldy V$DESC,u
|
|
343 ldu V$DRIV,u
|
|
344 exg x,u X pts to driver, U pts to static
|
|
345 ldd M$Exec,x
|
|
346 leax d,x
|
|
347 pshs u
|
|
348 jsr $0F,x call term routine
|
|
349 L0254 puls u
|
|
350 ldx 1,s get U from stack (dev entry to detach)
|
|
351 ldx V$DRIV,x
|
|
352 ldd M$Mem,x get memory requirements
|
|
353 addd #$00FF round up to next page
|
|
354 clrb
|
|
355 os9 F$SRtMem return mem
|
|
356 ldx 1,s get U from stack (dev entry to detach)
|
|
357 ldx V$DESC,x get dev desc ptr
|
|
358 L0267 puls u,b get U,B
|
|
359 ldx V$DESC,u
|
|
360 clr V$DESC,u
|
|
361 clr V$DESC+1,u
|
|
362 clr V$USRS,u
|
|
363 L0271 ldy V$DRIV,u
|
|
364 ldu V$FMGR,u
|
|
365 os9 F$UnLink unlink file manager
|
|
366 leau ,y
|
|
367 os9 F$UnLink unlink driver
|
|
368 leau ,x
|
|
369 os9 F$UnLink unlink descriptor
|
|
370 L0283 lbsr L04D9
|
|
371 clrb
|
|
372 rts
|
|
373
|
|
374 * user state I$Dup
|
79
|
375 IDup bsr FindPath look for a free path
|
|
376 bcs IDupRTS branch if error
|
|
377 pshs x,a else save of
|
|
378 lda R$A,u get path to dup
|
|
379 lda a,x point to path to dup
|
0
|
380 bsr L02A1
|
|
381 bcs L029D
|
|
382 puls x,b
|
79
|
383 stb R$A,u save off new path to caller's A
|
0
|
384 sta b,x
|
|
385 rts
|
|
386 L029D puls pc,x,a
|
|
387
|
|
388 * system state I$Dup
|
|
389 SIDup lda R$A,u
|
79
|
390 L02A1 lbsr FindPDsc find path descriptor
|
|
391 bcs IDupRTS exit if error
|
|
392 inc PD.CNT,y else increment path count
|
0
|
393 IDupRTS rts
|
|
394
|
|
395
|
79
|
396 * Find next free path position in current proc
|
|
397 * Exit: X = Ptr to proc's path table
|
|
398 * A = Free path number (valid if carry clear)
|
|
399 *
|
|
400 FindPath ldx <D.Proc get ptr to current proc desc
|
|
401 leax <P$PATH,x point X to proc's path table
|
|
402 clra start from 0
|
|
403 L02AF tst a,x this path free?
|
|
404 beq L02BC branch if so...
|
|
405 inca else try next path...
|
|
406 cmpa #NumPaths are we at the end?
|
|
407 bcs L02AF branch if not
|
|
408 comb else path table is full
|
0
|
409 ldb #E$PthFul
|
|
410 rts
|
|
411 L02BC andcc #^Carry
|
|
412 rts
|
|
413
|
|
414 IUsrCall bsr FindPath
|
|
415 bcs L02D1
|
|
416 pshs u,x,a
|
|
417 bsr ISysCall
|
|
418 puls u,x,a
|
|
419 bcs L02D1
|
|
420 ldb R$A,u
|
|
421 stb a,x
|
|
422 sta R$A,u
|
|
423 L02D1 rts
|
|
424
|
|
425 ISysCall pshs b
|
|
426 ldb R$A,u
|
|
427 bsr L0349
|
|
428 bcs L02E6
|
|
429 puls b
|
|
430 lbsr CallFMgr
|
|
431 bcs L02F5
|
|
432 lda PD.PD,y
|
|
433 sta R$A,u
|
|
434 rts
|
|
435 L02E6 puls pc,a
|
|
436
|
|
437 * make directory
|
|
438 IMakDir pshs b
|
|
439 ldb #DIR.+WRITE.
|
|
440 L02EC bsr L0349
|
|
441 bcs L02E6
|
|
442 puls b
|
|
443 lbsr CallFMgr
|
|
444 L02F5 pshs b,cc
|
|
445 ldu PD.DEV,y
|
|
446 os9 I$Detach
|
|
447 lda PD.PD,y
|
|
448 ldx <D.PthDBT
|
|
449 os9 F$Ret64
|
|
450 puls pc,b,cc
|
|
451
|
|
452 * change directory
|
|
453 IChgDir pshs b
|
|
454 ldb R$A,u
|
|
455 orb #DIR.
|
|
456 bsr L0349
|
|
457 bcs L02E6
|
|
458 puls b
|
|
459 lbsr CallFMgr
|
|
460 bcs L02F5
|
|
461 ldu <D.Proc
|
|
462 ldb PD.MOD,y
|
|
463 bitb #PWRIT.+PREAD.+UPDAT.
|
|
464 beq L0329
|
|
465 ldx PD.DEV,y
|
|
466 stx <P$DIO,u
|
|
467 inc V$USRS,x
|
|
468 bne L0329
|
|
469 dec V$USRS,x
|
|
470 L0329 bitb #PEXEC.+EXEC.
|
|
471 beq L0338
|
|
472 ldx PD.DEV,y
|
|
473 stx <P$DIO+6,u
|
|
474 inc V$USRS,x
|
|
475 bne L0338
|
|
476 dec V$USRS,x
|
|
477 L0338 clrb
|
|
478 bra L02F5
|
|
479
|
|
480 IDelete pshs b
|
|
481 ldb #$02
|
|
482 bra L02EC
|
|
483
|
|
484 IDeletX ldb #$87
|
|
485 pshs b
|
|
486 ldb $01,u
|
|
487 bra L02EC
|
|
488
|
|
489 * create path descriptor and initialize
|
|
490 * Entry:
|
|
491 * B = path mode
|
|
492 L0349 pshs u
|
|
493 ldx <D.PthDBT
|
|
494 os9 F$All64
|
|
495 bcs L03A8
|
|
496 inc PD.CNT,y
|
|
497 stb PD.MOD,y
|
|
498 ldx R$X,u
|
|
499 L0358 lda ,x+
|
|
500 cmpa #$20
|
|
501 beq L0358
|
|
502 leax -1,x
|
|
503 stx R$X,u
|
|
504 ldb PD.MOD,y
|
|
505 cmpa #PDELIM
|
|
506 beq L037E
|
|
507 ldx <D.Proc
|
|
508 bitb #PEXEC.+EXEC.
|
|
509 beq L0373
|
|
510 ldx <P$DIO+6,x
|
|
511 bra L0376
|
|
512 L0373 ldx <P$DIO,x
|
|
513 L0376 beq L03AA
|
|
514 ldx V$DESC,x
|
|
515 ldd M$Name,x
|
|
516 leax d,x
|
|
517 L037E pshs y
|
|
518 os9 F$PrsNam
|
|
519 puls y
|
|
520 bcs L03AA
|
|
521 lda PD.MOD,y
|
|
522 os9 I$Attach
|
|
523 stu PD.DEV,y
|
|
524 bcs L03AC
|
|
525 ldx V$DESC,u
|
|
526 leax <M$Opt,x
|
|
527 ldb ,x+
|
|
528 leau <PD.DTP,y
|
|
529 cmpb #$20
|
|
530 bls L03A4
|
|
531 ldb #$1F
|
|
532 L03A0 lda ,x+
|
|
533 sta ,u+
|
|
534 L03A4 decb
|
|
535 bpl L03A0
|
|
536 clrb
|
|
537 L03A8 puls pc,u
|
|
538 L03AA ldb #E$BPNam
|
|
539 L03AC pshs b
|
|
540 lda ,y
|
|
541 ldx <D.PthDBT
|
|
542 os9 F$Ret64
|
|
543 puls b
|
|
544 coma
|
|
545 bra L03A8
|
|
546 L03BA lda $01,u
|
|
547 cmpa #$10
|
|
548 bcc L03CB
|
|
549 ldx <D.Proc
|
|
550 leax <$26,x
|
|
551 andcc #^Carry
|
|
552 lda a,x
|
|
553 bne L03CE
|
|
554 L03CB comb
|
|
555 ldb #E$BPNum
|
|
556 L03CE rts
|
|
557
|
|
558 UISeek bsr L03BA
|
|
559 bcc GetPDsc
|
|
560 rts
|
|
561
|
|
562 SISeek lda R$A,u
|
|
563 GetPDsc bsr FindPDsc
|
|
564 lbcc CallFMgr
|
|
565 rts
|
|
566
|
|
567 UIRead bsr L03BA
|
|
568 bcc L03E4
|
|
569 rts
|
|
570
|
|
571 SIRead lda R$A,u
|
|
572 L03E4 pshs b
|
|
573 ldb #$05
|
|
574 L03E8 bsr FindPDsc
|
|
575 bcs L040B
|
|
576 bitb $01,y
|
|
577 beq L0409
|
|
578 ldd $06,u
|
|
579 beq L03F8
|
|
580 addd $04,u
|
|
581 bcs L03FD
|
|
582 L03F8 puls b
|
|
583 lbra CallFMgr
|
|
584 L03FD ldb #$F4
|
|
585 lda ,s
|
|
586 bita #$02
|
|
587 beq L040B
|
|
588 ldb #$F5
|
|
589 bra L040B
|
|
590 L0409 ldb #E$BMode
|
|
591 L040B com ,s+
|
|
592 rts
|
|
593
|
|
594 UIWrite bsr L03BA
|
|
595 bcc L0415
|
|
596 rts
|
|
597
|
|
598 SIWrite lda R$A,u
|
|
599 L0415 pshs b
|
|
600 ldb #$02
|
|
601 bra L03E8
|
|
602
|
|
603
|
79
|
604 * Find path descriptor of path passed in A
|
|
605 * Entry:
|
|
606 * A = path to find
|
0
|
607 * Exit:
|
79
|
608 * Y = addr of path desc (if no error)
|
0
|
609 FindPDsc pshs x
|
|
610 ldx <D.PthDBT
|
|
611 os9 F$Find64
|
|
612 puls x
|
|
613 lbcs L03CB
|
|
614 L0428 rts
|
|
615
|
|
616 UIGetStt lbsr L03BA
|
|
617 bcc L0431
|
|
618 rts
|
|
619
|
|
620 SIGetStt lda R$A,u
|
|
621 L0431 pshs b,a
|
|
622 lda R$B,u
|
|
623 sta 1,s place in B on stack
|
|
624 puls a get A
|
|
625 bsr GetPDsc
|
|
626 puls a A holds func code
|
|
627 pshs b,cc
|
|
628 ldb <PD.DTP,y
|
|
629 cmpb #DT.NFM
|
|
630 beq L044D
|
|
631 tsta test func code
|
|
632 beq GSOpt
|
|
633 cmpa #SS.DevNm
|
|
634 beq GSDevNm
|
|
635 L044D puls pc,b,cc
|
|
636 GSOpt leax <PD.DTP,y
|
|
637 L0452 ldy R$X,u
|
|
638 ldb #32
|
|
639 L0457 lda ,x+ copy 32 bytes from X to Y
|
|
640 sta ,y+
|
|
641 decb
|
|
642 bne L0457
|
|
643 leas 2,s fix stack
|
|
644 clrb
|
|
645 rts
|
|
646 * get device name
|
|
647 GSDevNm ldx PD.DEV,y
|
|
648 ldx V$DESC,x
|
|
649 ldd M$Name,x
|
|
650 leax d,x
|
|
651 bra L0452
|
|
652
|
|
653 UIClose lbsr L03BA
|
|
654 bcs L0428
|
|
655 pshs b
|
|
656 ldb R$A,u
|
|
657 clr b,x
|
|
658 puls b
|
|
659 bra L047D
|
|
660
|
|
661 SIClose lda R$A,u
|
|
662 L047D bsr FindPDsc
|
|
663 bcs L0428
|
|
664 dec PD.CNT,y
|
|
665 tst PD.CPR,y
|
|
666 bne L0489
|
|
667 bsr CallFMgr
|
|
668 L0489 tst PD.CNT,y
|
|
669 bne L0428
|
|
670 lbra L02F5
|
|
671
|
|
672 L0490 os9 F$IOQu
|
|
673 comb
|
|
674 ldb <P$Signal,x
|
|
675 bne L04A4
|
|
676 L0499 ldx <D.Proc
|
|
677 ldb P$ID,x
|
|
678 clra
|
|
679 lda PD.CPR,y
|
|
680 bne L0490
|
|
681 stb PD.CPR,y
|
|
682 L04A4 rts
|
|
683
|
|
684 * B = entry point into FMgr
|
|
685 * Y = path desc
|
|
686 CallFMgr pshs u,y,x,b
|
|
687 bsr L0499
|
|
688 bcs L04C1
|
|
689 stu PD.RGS,y
|
|
690 lda <PD.DTP,y
|
|
691 ldx PD.DEV,y
|
|
692 ldx V$FMGR,x
|
|
693 ldd M$Exec,x
|
|
694 leax d,x
|
|
695 ldb ,s
|
|
696 subb #$83 subtract offset from B
|
|
697 lda #$03 size of one entry
|
|
698 mul compute
|
|
699 jsr d,x branch into file manager
|
|
700 L04C1 pshs b,cc
|
|
701 bsr L04D9
|
|
702 ldy $05,s get path desc off stack
|
|
703 lda <PD.DTP,y
|
|
704 ldx <D.Proc
|
|
705 lda P$ID,x
|
|
706 cmpa PD.CPR,y
|
|
707 bne L04D5
|
|
708 clr PD.CPR,y
|
|
709 L04D5 puls b,cc
|
|
710 puls pc,u,y,x,a
|
|
711
|
|
712 L04D9 pshs y,x
|
|
713 ldy <D.Proc
|
|
714 lda <P$IOQN,y
|
|
715 beq L04F3
|
|
716 clr <P$IOQN,y
|
|
717 ldb #S$Wake
|
|
718 os9 F$Send
|
|
719 ldx <D.PrcDBT
|
|
720 os9 F$Find64
|
|
721 clr <P$IOQP,y
|
|
722 L04F3 clrb
|
|
723 puls pc,y,x
|
|
724
|
|
725 * IRQ install routine
|
|
726 FIRQ ldx R$X,u
|
|
727 ldb ,x B = flip byte
|
|
728 ldx 1,x X = mask/priority
|
|
729 clra
|
|
730 pshs cc
|
|
731 pshs x,b
|
|
732 ldx <D.Init
|
|
733 ldb PollCnt,x
|
|
734 ldx <D.PolTbl
|
|
735 ldy R$X,u
|
|
736 beq RmvIRQEn
|
|
737 tst 1,s mask byte
|
|
738 beq L0572
|
|
739 decb dec poll table count
|
|
740 lda #POLSIZ
|
|
741 mul
|
|
742 leax d,x point to last entry in table
|
|
743 lda Q$MASK,x
|
|
744 bne L0572
|
|
745 orcc #FIRQMask+IRQMask
|
|
746 L051C ldb 2,s get priority byte
|
|
747 cmpb -1,x compare with prev entry's prior
|
|
748 bcs L052F
|
|
749 ldb #POLSIZ else copy prev entry
|
|
750 L0524 lda ,-x
|
|
751 sta POLSIZ,x
|
|
752 decb
|
|
753 bne L0524
|
|
754 cmpx <D.PolTbl
|
|
755 bhi L051C
|
|
756 L052F ldd R$D,u get dev stat reg
|
|
757 std Q$POLL,x save it
|
|
758 ldd ,s++ get flip/mask
|
|
759 sta Q$FLIP,x save flip
|
|
760 stb Q$MASK,x save mask
|
|
761 ldb ,s+ get priority
|
|
762 stb Q$PRTY,x save priority
|
|
763 ldd R$Y,u get IRQ svc addr
|
|
764 std Q$SERV,x save
|
|
765 ldd R$U,u get IRQ svc mem ptr
|
|
766 std Q$STAT,x save
|
|
767 puls pc,cc
|
|
768 * remove IRQ poll entry
|
|
769 RmvIRQEn leas 4,s clean stack
|
|
770 ldy R$U,u
|
|
771 L054C cmpy Q$STAT,x
|
|
772 beq L0558
|
|
773 leax POLSIZ,x
|
|
774 decb
|
|
775 bne L054C
|
|
776 clrb
|
|
777 rts
|
|
778 L0558 pshs b,cc
|
|
779 orcc #FIRQMask+IRQMask
|
|
780 bra L0565
|
|
781 L055E ldb POLSIZ,x
|
|
782 stb ,x+
|
|
783 deca
|
|
784 bne L055E
|
|
785 L0565 lda #POLSIZ
|
|
786 dec 1,s dec count
|
|
787 bne L055E
|
|
788 L056B clr ,x+
|
|
789 deca
|
|
790 bne L056B
|
|
791 puls pc,a,cc
|
|
792 L0572 leas 4,s clean stack
|
|
793 L0574 comb
|
|
794 ldb #E$Poll
|
|
795 rts
|
|
796
|
|
797 * IRQ polling routine
|
|
798 DPoll ldy <D.PolTbl
|
|
799 ldx <D.Init
|
|
800 ldb PollCnt,x
|
|
801 bra L0586
|
|
802 L0581 leay POLSIZ,y
|
|
803 decb
|
|
804 beq L0574
|
|
805 L0586 lda [Q$POLL,y]
|
|
806 eora Q$FLIP,y
|
|
807 bita Q$MASK,y
|
|
808 beq L0581
|
|
809 ldu Q$STAT,y
|
|
810 pshs y,b
|
|
811 jsr [<Q$SERV,y]
|
|
812 puls y,b
|
|
813 bcs L0581
|
|
814 rts
|
|
815
|
|
816 * load a module
|
|
817 FLoad pshs u
|
|
818 ldx R$X,u
|
|
819 bsr L05BC
|
|
820 bcs L05BA
|
|
821 inc $02,u increment link count
|
|
822 ldy ,u get mod header addr
|
|
823 ldu ,s get caller regs
|
|
824 stx R$X,u
|
|
825 sty R$U,u
|
|
826 lda M$Type,y
|
|
827 ldb M$Revs,y
|
|
828 std R$D,u
|
|
829 ldd M$Exec,y
|
|
830 leax d,y
|
|
831 stx R$Y,u
|
|
832 L05BA puls pc,u
|
|
833
|
|
834 L05BC lda #EXEC.
|
|
835 os9 I$Open
|
|
836 bcs L0632
|
|
837 leas -$0A,s make room on stack
|
|
838 ldu #$0000
|
|
839 pshs u,y,x
|
|
840 sta 6,s save path
|
|
841 L05CC ldd 4,s get U (caller regs) from stack
|
|
842 bne L05D2
|
|
843 stu 4,s
|
|
844 L05D2 lda 6,s get path
|
|
845 leax 7,s point to place on stack
|
|
846 ldy #M$IDSize read M$IDSize bytes
|
|
847 os9 I$Read
|
|
848 bcs L061E
|
|
849 ldd ,x
|
|
850 cmpd #M$ID12
|
|
851 bne L061C
|
|
852 ldd $09,s get module size
|
|
853 os9 F$SRqMem allocate mem
|
|
854 bcs L061E
|
|
855 ldb #M$IDSize
|
|
856 L05F0 lda ,x+ copy over first M$IDSize bytes
|
|
857 sta ,u+
|
|
858 decb
|
|
859 bne L05F0
|
|
860 lda $06,s get path
|
|
861 leax ,u point X at updated U
|
|
862 ldu $09,s get module size
|
|
863 leay -M$IDSize,u subtract count
|
|
864 os9 I$Read
|
|
865 leax -M$IDSize,x
|
|
866 bcs L060B
|
|
867 os9 F$VModul validate module
|
|
868 bcc L05CC
|
|
869 L060B pshs u,b
|
|
870 leau ,x point U at memory allocated
|
|
871 ldd M$Size,x
|
|
872 os9 F$SRtMem return mem
|
|
873 puls u,b
|
|
874 cmpb #E$KwnMod
|
|
875 beq L05CC
|
|
876 bra L061E
|
|
877 L061C ldb #E$BMID
|
|
878 L061E puls u,y,x
|
|
879 lda ,s get path
|
|
880 stb ,s save error code
|
|
881 os9 I$Close close path
|
|
882 ldb ,s
|
|
883 leas $0A,s clear up stack
|
|
884 cmpu #$0000
|
|
885 bne L0632
|
|
886 coma
|
|
887 L0632 rts
|
|
888
|
|
889
|
|
890 ErrHead fcc /ERROR #/
|
|
891 ErrNum equ *-ErrHead
|
253
|
892 fcb $2F,$3A,$30,C$CR
|
0
|
893 ErrLen equ *-ErrHead
|
|
894
|
|
895 FPErr ldx <D.Proc
|
|
896 lda <P$PATH+2,x get stderr path
|
|
897 beq L0674
|
|
898 leas -ErrLen,s make room on stack
|
|
899 * copy error message to stack
|
|
900 leax <ErrHead,pcr
|
|
901 leay ,s
|
|
902 L064C lda ,x+
|
|
903 sta ,y+
|
253
|
904 cmpa #C$CR
|
0
|
905 bne L064C
|
|
906 ldb R$B,u get error #
|
|
907 L0656 inc ErrNum+0,s
|
|
908 subb #$64
|
|
909 bcc L0656
|
|
910 L065C dec ErrNum+1,s
|
|
911 addb #$0A
|
|
912 bcc L065C
|
|
913 addb #$30
|
|
914 stb ErrNum+2,s
|
|
915 ldx <D.Proc
|
|
916 leax ,s point to error message
|
|
917 ldu <D.Proc
|
|
918 lda <P$PATH+2,u
|
|
919 os9 I$WritLn write message
|
|
920 leas ErrLen,s fix up stack
|
|
921 L0674 rts
|
|
922
|
|
923 FIOQu ldy <D.Proc
|
|
924 L0678 lda <P$IOQN,y
|
|
925 beq L06A0
|
|
926 cmpa R$A,u
|
|
927 bne L0699
|
|
928 clr <P$IOQN,y
|
|
929 ldx <D.PrcDBT
|
|
930 os9 F$Find64
|
|
931 lbcs L070F
|
|
932 clr <P$IOQP,y
|
|
933 ldb #S$Wake
|
|
934 os9 F$Send
|
|
935 ldu <D.Proc
|
|
936 bra L06AB
|
|
937 L0699 ldx <D.PrcDBT
|
|
938 os9 F$Find64
|
|
939 bcc L0678
|
|
940 L06A0 lda R$A,u
|
|
941 ldu <D.Proc
|
|
942 ldx <D.PrcDBT
|
|
943 os9 F$Find64
|
|
944 bcs L070F
|
|
945 L06AB leax ,y X = proc desc
|
|
946 lda <P$IOQN,y
|
|
947 beq L06D1
|
|
948 ldx <D.PrcDBT
|
|
949 os9 F$Find64
|
|
950 bcs L070F
|
|
951 ldb P$Age,u
|
|
952
|
75
|
953 ifeq edition-11
|
0
|
954
|
|
955 * Note: the following line is a bug
|
|
956 cmpd P$Age,y
|
|
957
|
|
958 else
|
|
959
|
|
960 cmpb P$Age,y
|
|
961
|
|
962 endc
|
|
963
|
|
964 bls L06AB
|
|
965 ldb ,u
|
|
966 stb <P$IOQN,x
|
|
967 ldb P$ID,x
|
|
968 stb <P$IOQP,u
|
|
969 clr <P$IOQP,y
|
|
970 exg y,u
|
|
971 bra L06AB
|
|
972 L06D1 lda P$ID,u
|
|
973 sta <P$IOQN,y
|
|
974 lda P$ID,y
|
|
975 sta <P$IOQP,u
|
|
976 ldx #$0000
|
|
977 os9 F$Sleep
|
|
978 ldu <D.Proc
|
|
979 lda <P$IOQP,u
|
|
980 beq L070C
|
|
981 ldx <D.PrcDBT
|
|
982 os9 F$Find64
|
|
983 bcs L070C
|
|
984 lda <P$IOQN,y
|
|
985 beq L070C
|
|
986 lda <P$IOQN,u
|
|
987 sta <P$IOQN,y
|
|
988 beq L070C
|
|
989 clr <P$IOQN,u
|
|
990 ldx <D.PrcDBT
|
|
991 os9 F$Find64
|
|
992 bcs L070C
|
|
993 lda <P$IOQP,u
|
|
994 sta <P$IOQP,y
|
|
995 L070C clr <P$IOQP,u
|
|
996 L070F rts
|
|
997
|
|
998 emod
|
|
999 eom equ *
|
|
1000 end
|