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