0
|
1 ********************************************************************
|
|
2 * ACIAPAK - RS-232 Pak driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
201
|
8 * 10 From Tandy OS-9 Level One VR 02.00.00
|
0
|
9
|
|
10 nam ACIAPAK
|
|
11 ttl RS-232 Pak driver
|
|
12
|
|
13 * Disassembled 98/08/23 20:25:56 by Disasm v1.6 (C) 1988 by RML
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use scfdefs
|
|
18 endc
|
|
19
|
|
20 tylg set Drivr+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $01
|
201
|
23 edition set 10
|
0
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
|
27 rmb V.SCF SCF storage requirements
|
|
28 u001D rmb 1
|
|
29 u001E rmb 1
|
|
30 u001F rmb 1
|
|
31 u0020 rmb 1
|
|
32 u0021 rmb 1
|
|
33 u0022 rmb 1
|
|
34 u0023 rmb 1
|
|
35 u0024 rmb 1
|
|
36 u0025 rmb 2
|
|
37 u0027 rmb 1
|
|
38 u0028 rmb 1
|
|
39 u0029 rmb 1
|
|
40 u002A rmb 1
|
|
41 u002B rmb 1
|
|
42 orgDFIRQ rmb 2
|
|
43 u002E rmb 2
|
|
44 u0030 rmb 2
|
|
45 u0032 rmb 25
|
|
46 u004B rmb 34
|
|
47 u006D rmb 17
|
|
48 u007E rmb 2
|
|
49 u0080 rmb 128
|
|
50 size equ .
|
|
51 fcb $03
|
|
52
|
|
53 name fcs /ACIAPAK/
|
|
54 fcb $0A
|
|
55
|
|
56 start lbra Init
|
|
57 lbra Read
|
|
58 lbra Write
|
|
59 lbra GetStat
|
|
60 lbra SetStat
|
|
61 lbra Term
|
|
62
|
|
63 IRQPckt fcb $00,$80,$0a
|
|
64
|
|
65 * Driver supplied D.FIRQ routine
|
|
66 FIRQRtn tst ,s
|
|
67 bmi L003B
|
|
68 leas -$01,s
|
|
69 pshs y,x,dp,b,a
|
|
70 lda $08,s
|
|
71 stu $07,s
|
|
72 ora #$80
|
|
73 pshs a
|
|
74 L003B jmp [>D.SvcIRQ]
|
|
75
|
|
76 * Init
|
|
77 *
|
|
78 * Entry:
|
|
79 * Y = address of device descriptor
|
|
80 * U = address of device memory area
|
|
81 *
|
|
82 * Exit:
|
|
83 * CC = carry set on error
|
|
84 * B = error code
|
|
85 *
|
|
86 Init ldx V.PORT,u
|
|
87 stb $01,x
|
|
88 ldd <IT.COL,y get column size
|
|
89 std <u002A,u
|
|
90 ldd <IT.PAR,y get parity/baud rate
|
|
91 lbsr L01CF
|
|
92 ldd V.PORT,u
|
|
93 addd #$0001
|
|
94 leax >IRQPckt,pcr
|
|
95 leay >L024E,pcr
|
|
96 os9 F$IRQ
|
|
97 bcs L0085
|
|
98 pshs cc
|
|
99 orcc #IntMasks
|
|
100 ldd <D.FIRQ get current D.FIRQ vector
|
|
101 std <orgDFIRQ,u save it off locally
|
|
102 leax >FIRQRtn,pcr get our D.FIRQ routine
|
|
103 stx <D.FIRQ and put it in system global vector
|
|
104 lda >PIA.U8+3
|
|
105 anda #$FC
|
|
106 ora #$01
|
|
107 sta >PIA.U8+3
|
|
108 lda >PIA.U8+2
|
|
109 puls cc
|
|
110 lda #$03
|
|
111 sta >MPI.Slct
|
|
112 clrb
|
|
113 L0085 rts
|
|
114
|
|
115 L0086 orcc #IntMasks
|
|
116 lda ,x
|
|
117 lda ,x
|
|
118 lda $01,x
|
|
119 ldb $01,x
|
|
120 ldb >PIA.U8+2
|
|
121 ldb $01,x
|
|
122 bmi L00FB
|
|
123 lda #$02
|
|
124 sta <u0022,u
|
|
125 clra
|
|
126 andb #$60
|
|
127 std <u0023,u
|
|
128 clrb
|
|
129 std <u001D,u
|
|
130 std <u0020,u
|
|
131 sta <u001F,u
|
|
132 std <u0025,u
|
|
133 andcc #^IntMasks
|
|
134 rts
|
|
135
|
|
136 * Read
|
|
137 *
|
|
138 * Entry:
|
|
139 * Y = address of path descriptor
|
|
140 * U = address of device memory area
|
|
141 *
|
|
142 * Exit:
|
|
143 * A = character read
|
|
144 * CC = carry set on error
|
|
145 * B = error code
|
|
146 *
|
|
147 L00B2 bsr L00FF
|
|
148 Read lda <u0023,u
|
|
149 ble L00CC
|
|
150 ldb <u001F,u
|
|
151 cmpb #$0A
|
|
152 bhi L00CC
|
|
153 ldb V.XON,u
|
|
154 orb #$80
|
|
155 stb <u0023,u
|
|
156 ldb #$05
|
|
157 lbsr L037D
|
|
158 L00CC tst <u0025,u
|
|
159 bne L00FB
|
|
160 ldb <u001E,u
|
|
161 leax <u002E,u
|
|
162 orcc #IntMasks
|
|
163 cmpb <u001D,u
|
|
164 beq L00B2
|
|
165 abx
|
|
166 lda ,x
|
|
167 dec <u001F,u
|
|
168 incb
|
|
169 cmpb #$4F
|
|
170 bls L00EA
|
|
171 clrb
|
|
172 L00EA stb <u001E,u
|
|
173 ldb V.ERR,u
|
|
174 beq L015E
|
|
175 stb <PD.ERR,y
|
|
176 clr V.ERR,u
|
|
177 comb
|
|
178 ldb #E$Read
|
|
179 bra L015F
|
|
180 L00FB comb
|
|
181 ldb #E$NotRdy
|
|
182 rts
|
|
183 L00FF pshs x,b,a
|
|
184 lda V.BUSY,u
|
|
185 sta V.WAKE,u
|
|
186 andcc #^IntMasks
|
|
187 ldx #$0000
|
|
188 os9 F$Sleep
|
|
189 ldx <D.Proc
|
|
190 ldb <P$Signal,x
|
|
191 beq L0118
|
|
192 cmpb #$03
|
|
193 bls L012E
|
|
194 L0118 clra
|
|
195 lda P$State,x
|
|
196 bita #Condem
|
|
197 bne L012E
|
|
198 ldb #$DC
|
|
199 lda V.ERR,u
|
|
200 bita #$20
|
|
201 bne L0129
|
|
202 puls pc,x,b,a
|
|
203 L0129 inc <PD.PST,y
|
|
204 clr V.ERR,u
|
|
205 L012E leas $06,s
|
|
206 coma
|
|
207 rts
|
|
208
|
|
209 * Write
|
|
210 *
|
|
211 * Entry:
|
|
212 * A = character to write
|
|
213 * Y = address of path descriptor
|
|
214 * U = address of device memory area
|
|
215 *
|
|
216 * Exit:
|
|
217 * CC = carry set on error
|
|
218 * B = error code
|
|
219 *
|
|
220 L0132 bsr L00FF
|
|
221 Write leax <u007E,u
|
|
222 ldb <u0020,u
|
|
223 abx
|
|
224 sta ,x
|
|
225 incb
|
|
226 cmpb #$81
|
|
227 bls L0143
|
|
228 clrb
|
|
229 L0143 orcc #IntMasks
|
|
230 cmpb <u0021,u
|
|
231 beq L0132
|
|
232 stb <u0020,u
|
|
233 lda <u0022,u
|
|
234 beq L015E
|
|
235 anda #$FD
|
|
236 sta <u0022,u
|
|
237 bne L015E
|
|
238 ldb #$05
|
|
239 lbsr L037D
|
|
240 L015E clrb
|
|
241 L015F andcc #^IntMasks
|
|
242 rts
|
|
243
|
|
244 * GetStat
|
|
245 *
|
|
246 * Entry:
|
|
247 * A = function code
|
|
248 * Y = address of path descriptor
|
|
249 * U = address of device memory area
|
|
250 *
|
|
251 * Exit:
|
|
252 * CC = carry set on error
|
|
253 * B = error code
|
|
254 *
|
|
255 GetStat ldx PD.RGS,y
|
|
256 cmpa #SS.Ready
|
|
257 bne L0171
|
|
258 ldb <u001F,u
|
|
259 beq L00FB
|
|
260 stb R$B,x
|
|
261 L016F clrb
|
|
262 rts
|
|
263 L0171 cmpa #SS.EOF
|
|
264 beq L016F
|
|
265 cmpa #SS.ScSiz
|
|
266 beq L0184
|
|
267 cmpa #SS.ComSt
|
|
268 bne L0191
|
|
269 ldd <u0028,u
|
|
270 std R$Y,x
|
|
271 bra L016F
|
|
272 L0184 clra
|
|
273 ldb <u002A,u
|
|
274 std R$X,x
|
|
275 ldb <u002B,u
|
|
276 std R$Y,x
|
|
277 bra L016F
|
|
278 L0191 comb
|
|
279 ldb #E$UnkSvc
|
|
280 rts
|
|
281
|
|
282 * SetStat
|
|
283 *
|
|
284 * Entry:
|
|
285 * A = function code
|
|
286 * Y = address of path descriptor
|
|
287 * U = address of device memory area
|
|
288 *
|
|
289 * Exit:
|
|
290 * CC = carry set on error
|
|
291 * B = error code
|
|
292 *
|
|
293 SetStat ldx PD.RGS,y
|
|
294 cmpa #SS.SSig
|
|
295 bne L01B2
|
|
296 lda PD.CPR,y
|
|
297 ldb R$X+1,x
|
|
298 orcc #IntMasks
|
|
299 tst <u001F,u
|
|
300 bne L01AB
|
|
301 std <u0025,u
|
|
302 bra L015E
|
|
303 L01AB andcc #^IntMasks
|
|
304 os9 F$Send
|
|
305 clrb
|
|
306 rts
|
|
307 L01B2 cmpa #SS.Open
|
|
308 beq L01FA
|
|
309 cmpa #SS.Close
|
|
310 beq L020A
|
|
311 cmpa #SS.Relea
|
|
312 bne L01C9
|
|
313 lda PD.CPR,y
|
|
314 cmpa <u0025,u
|
|
315 bne L016F
|
|
316 clr <u0025,u
|
|
317 rts
|
|
318 L01C9 cmpa #SS.ComSt
|
|
319 bne L0191
|
|
320 ldd R$Y,x
|
|
321 L01CF std <u0028,u
|
|
322 andb #$E0
|
|
323 pshs b
|
|
324 ldb <u0029,u
|
|
325 andb #$07
|
|
326 leax <L01F2,pcr
|
|
327 ldb b,x
|
|
328 orb ,s+
|
|
329 anda #$E0
|
|
330 sta V.TYPE,u
|
|
331 ldx V.PORT,u
|
|
332 lda $02,x
|
|
333 anda #$1F
|
|
334 ora V.TYPE,u
|
|
335 std $02,x
|
|
336 bra L0227
|
|
337 L01F2 fdb $1316,$1718,$1a1c,$1e1f
|
|
338 L01FA ldb #$09
|
|
339 lda R$Y+1,x
|
|
340 cmpa #$01
|
|
341 bne L0227
|
|
342 orcc #IntMasks
|
|
343 lbsr L037D
|
|
344 lbra L0086
|
|
345 L020A lda R$Y+1,x
|
|
346 bne L0227
|
|
347 ldb #$0B
|
|
348 lda <u0028,u
|
|
349 bita #$10
|
|
350 beq L0218
|
|
351 L0217 clrb
|
|
352 L0218 pshs b
|
|
353 bsr L022C
|
|
354 bcs L0217
|
|
355 puls b
|
|
356 orcc #IntMasks
|
|
357 lbsr L037D
|
|
358 andcc #^IntMasks
|
|
359 L0227 clrb
|
|
360 rts
|
|
361
|
|
362 L0229 lbsr L00FF
|
|
363 L022C ldb <u0020,u
|
|
364 orcc #IntMasks
|
|
365 cmpb <u0021,u
|
|
366 bne L0229
|
|
367 rts
|
|
368
|
|
369 * Term
|
|
370 *
|
|
371 * Entry:
|
|
372 * U = address of device memory area
|
|
373 *
|
|
374 * Exit:
|
|
375 * CC = carry set on error
|
|
376 * B = error code
|
|
377 *
|
|
378 Term ldx <D.Proc
|
|
379 lda P$ID,x
|
|
380 sta V.BUSY,u
|
|
381 sta V.LPRC,u
|
|
382 bsr L0217
|
|
383 ldd <orgDFIRQ,u get saved D.FIRQ vector
|
|
384 std <D.FIRQ and put it back in system global
|
|
385 ldx #$0000
|
|
386 os9 F$IRQ deinstall IRQ svc routine
|
|
387 clrb
|
|
388 rts
|
|
389
|
|
390 * ISR
|
|
391 L024E ldb >PIA.U8+2
|
|
392 ldx V.PORT,u
|
|
393 sta <u0027,u
|
|
394 tfr a,b
|
|
395 andb #$60
|
|
396 cmpb <u0024,u
|
|
397 beq L0299
|
|
398 tfr b,a
|
|
399 eorb <u0024,u
|
|
400 sta <u0024,u
|
|
401 lda <u0027,u
|
|
402 bitb #$20
|
|
403 beq L028C
|
|
404 bita #$20
|
|
405 beq L028C
|
|
406 lda <u0028,u
|
|
407 bita #$10
|
|
408 beq L02EC
|
|
409 ldx <V.PDLHd,u
|
|
410 beq L0286
|
|
411 L027E inc <$3F,x
|
|
412 ldx <$3D,x
|
|
413 bne L027E
|
|
414 L0286 lda #$20
|
|
415 bsr L02F6
|
|
416 bra L02E1
|
|
417 L028C bitb #$40
|
|
418 beq L02EC
|
|
419 bita #$40
|
|
420 lbne L03AF
|
|
421 lbra L039E
|
|
422 L0299 bita #$08
|
|
423 bne L02FB
|
|
424 bita #$10
|
|
425 beq L02EC
|
|
426 lda <u0023,u
|
|
427 bpl L02B6
|
|
428 anda #$7F
|
|
429 sta ,x
|
|
430 eora V.XON,u
|
|
431 sta <u0023,u
|
|
432 lda <u0022,u
|
|
433 bne L02DC
|
|
434 bra L02EC
|
|
435 L02B6 leay <u007E,u
|
|
436 ldb <u0021,u
|
|
437 cmpb <u0020,u
|
|
438 beq L02D4
|
|
439 clra
|
|
440 lda d,y
|
|
441 incb
|
|
442 cmpb #$81
|
|
443 bls L02CA
|
|
444 clrb
|
|
445 L02CA stb <u0021,u
|
|
446 sta ,x
|
|
447 cmpb <u0020,u
|
|
448 bne L02E1
|
|
449 L02D4 lda <u0022,u
|
|
450 ora #$02
|
|
451 sta <u0022,u
|
|
452 L02DC ldb #$09
|
|
453 lbsr L037F
|
|
454 L02E1 ldb #$01
|
|
455 lda V.WAKE,u
|
|
456 L02E5 beq L02EC
|
|
457 clr V.WAKE,u
|
|
458 L02E9 os9 F$Send
|
|
459 L02EC ldx V.PORT,u
|
|
460 lda $01,x
|
|
461 lbmi L024E
|
|
462 clrb
|
|
463 rts
|
|
464 L02F6 ora V.ERR,u
|
|
465 sta V.ERR,u
|
|
466 rts
|
|
467 L02FB bita #$07
|
|
468 beq L030F
|
|
469 tfr a,b
|
|
470 tst ,x
|
|
471 anda #$07
|
|
472 bsr L02F6
|
|
473 lda $02,x
|
|
474 sta $01,x
|
|
475 sta $02,x
|
|
476 bra L02EC
|
|
477 L030F lda ,x
|
|
478 beq L032A
|
|
479 cmpa V.INTR,u
|
|
480 beq L038D
|
|
481 cmpa V.QUIT,u
|
|
482 beq L0391
|
|
483 cmpa V.PCHR,u
|
|
484 beq L0385
|
|
485 cmpa V.XON,u
|
|
486 beq L039E
|
|
487 cmpa <V.XOFF,u
|
|
488 lbeq L03AF
|
|
489 L032A leax <u002E,u
|
|
490 ldb <u001D,u
|
|
491 abx
|
|
492 sta ,x
|
|
493 incb
|
|
494 cmpb #$4F
|
|
495 bls L0339
|
|
496 clrb
|
|
497 L0339 cmpb <u001E,u
|
|
498 bne L0344
|
|
499 lda #$04
|
|
500 bsr L02F6
|
|
501 bra L02E1
|
|
502 L0344 stb <u001D,u
|
|
503 inc <u001F,u
|
|
504 tst <u0025,u
|
|
505 beq L0357
|
|
506 ldd <u0025,u
|
|
507 clr <u0025,u
|
|
508 bra L02E9
|
|
509 L0357 lda <V.XOFF,u
|
|
510 beq L02E1
|
|
511 ldb <u001F,u
|
|
512 cmpb #$46
|
|
513 lbcs L02E1
|
|
514 ldb <u0023,u
|
|
515 lbne L02E1
|
|
516 anda #$7F
|
|
517 sta <V.XOFF,u
|
|
518 ora #$80
|
|
519 sta <u0023,u
|
|
520 ldb #$05
|
|
521 bsr L037D
|
|
522 lbra L02E1
|
|
523 L037D ldx V.PORT,u
|
|
524 L037F orb V.TYPE,u
|
|
525 stb $02,x
|
|
526 clrb
|
|
527 rts
|
|
528 L0385 ldx V.DEV2,u
|
|
529 beq L032A
|
|
530 sta $08,x
|
|
531 bra L032A
|
|
532 L038D ldb #$03
|
|
533 bra L0393
|
|
534 L0391 ldb #$02
|
|
535 L0393 pshs a
|
|
536 lda V.LPRC,u
|
|
537 lbsr L02E5
|
|
538 puls a
|
|
539 bra L032A
|
|
540 L039E lda <u0022,u
|
|
541 anda #$FE
|
|
542 sta <u0022,u
|
|
543 bne L03AC
|
|
544 ldb #$05
|
|
545 bsr L037F
|
|
546 L03AC lbra L02EC
|
|
547 L03AF lda <u0022,u
|
|
548 bne L03B8
|
|
549 ldb #$09
|
|
550 bsr L037F
|
|
551 L03B8 ora #$01
|
|
552 sta <u0022,u
|
|
553 bra L03AC
|
|
554
|
|
555 emod
|
|
556 eom equ *
|
|
557 end
|
|
558
|