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