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