0
|
1 ********************************************************************
|
|
2 * XACIA - Enhanced 6551 driver
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 10 Bruce Isted distribution version BRI
|
|
9
|
|
10 nam XACIA
|
|
11 ttl Enhanced 6551 driver
|
|
12
|
|
13 ifp1
|
|
14 use defsfile
|
|
15 endc
|
|
16
|
|
17 * miscellaneous definitions
|
|
18 DCDStBit equ %00100000 DCD status bit for SS.CDSta call
|
|
19 DSRStBit equ %01000000 DSR status bit for SS.CDSta call
|
|
20 Edtn equ 10
|
|
21 Vrsn equ 1
|
|
22
|
|
23 * conditional assembly flags
|
|
24 *A6551 set true 6551 SACIA version
|
|
25 *A6552 set false 65C52 DACIA version
|
|
26 SlpBreak set TkPerSec/2+1 line Break duration
|
|
27 SlpHngUp set TkPerSec/4+1 hang up (drop DTR) duration
|
|
28
|
|
29 ifeq A6552-true
|
|
30 nam DACIA
|
|
31 ttl 65C52 Dual ACIA driver
|
|
32 else
|
|
33
|
|
34 ifeq A6551-true
|
|
35 nam SACIA
|
|
36 ttl 6551 Single ACIA driver
|
|
37 endc
|
|
38 endc
|
|
39
|
|
40 ifeq A6552-true
|
|
41 * 65C52 register definitions
|
|
42 org 0
|
|
43 ISReg rmb 1 IRQ Status (read only)
|
|
44 IEReg equ ISReg IRQ Enable (write only)
|
|
45 CSReg rmb 1 Control Status (read only)
|
|
46 CFReg equ CSReg Control/Format (write only)
|
|
47 CDReg rmb 1 Compare Data (write only, unused in this driver)
|
|
48 TBReg equ CDReg Transmit Break (write only)
|
|
49 DataReg rmb 1 receive/transmit Data (read Rx / write Tx)
|
|
50
|
|
51 * IRQ Status/Enable bit definitions
|
|
52 ISE.IRQ equ %10000000 IRQ occurred/enable
|
|
53 ISE.TxE equ %01000000 Tx data register Empty
|
|
54 ISE.CTS equ %00100000 CTS transition
|
|
55 ISE.DCD equ %00010000 DCD transition
|
|
56 ISE.DSR equ %00001000 DSR transition
|
|
57 ISE.FOB equ %00000100 Rx data Framing or Overrun error, or Break
|
|
58 ISE.Par equ %00000010 Rx data Parity error
|
|
59 ISE.RxF equ %00000001 Rx data register Full
|
|
60
|
|
61 ISE.Errs equ ISE.FOB!ISE.Par IRQ Status error bits
|
|
62 ISE.Flip equ $00 all ISR bits active when set
|
|
63 ISE.Mask equ ISE.CTS!ISE.DCD!ISE.DSR!ISE.FOB!ISE.Par!ISE.RxF active IRQs
|
|
64
|
|
65 * Control Status bit definitions
|
|
66 CS.Frame equ %10000000 framing error (set=error)
|
|
67 CS.TxE equ %01000000 Tx data empty (set=empty)
|
|
68 CS.CTS equ %00100000 CTS input (set=disabled)
|
|
69 CS.DCD equ %00010000 DCD input (set=disabled)
|
|
70 CS.DSR equ %00001000 DSR input (set=disabled)
|
|
71 CS.Break equ %00000100 Rx line break (set=received break)
|
|
72 CS.DTR equ %00000010 DTR output (set=disabled)
|
|
73 CS.RTS equ %00000001 RTS output (set=disabled)
|
|
74
|
|
75 * Control bit definitions
|
|
76 C.TBRCDR equ %01000000 Tx Break/Compare Data register access (set=Tx Break)
|
|
77 C.StpBit equ %00100000 stop bits (set=two, clear=one)
|
|
78 C.Echo equ %00010000 local echo (set=activated)
|
|
79 C.Baud equ %00001111 see baud rate table below
|
|
80
|
|
81 * baud rate table
|
|
82 org 0
|
|
83 BR.00050 rmb 1 50 baud (not supported)
|
|
84 BR.00110 rmb 1 109.92 baud
|
|
85 BR.00135 rmb 1 134.58 baud (not supported)
|
|
86 BR.00150 rmb 1 150 baud (not supported)
|
|
87 BR.00300 rmb 1 300 baud
|
|
88 BR.00600 rmb 1 600 baud
|
|
89 BR.01200 rmb 1 1200 baud
|
|
90 BR.01800 rmb 1 1800 baud (not supported)
|
|
91 BR.02400 rmb 1 2400 baud
|
|
92 BR.03600 rmb 1 3600 baud (not supported)
|
|
93 BR.04800 rmb 1 4800 baud
|
|
94 BR.07200 rmb 1 7200 baud (not supported)
|
|
95 BR.09600 rmb 1 9600 baud
|
|
96 BR.19200 rmb 1 19200 baud
|
|
97 BR.38400 rmb 1 38400 baud
|
|
98 BR.ExClk rmb 1 external Rx and Tx clocks (not supported)
|
|
99
|
|
100 * Format bit definitions
|
|
101 F.Slct equ %10000000 register select (set=Format, clear=Control)
|
|
102 F.DatBit equ %01100000 see data bit table below
|
|
103 F.Par equ %00011100 see parity table below
|
|
104 F.DTR equ %00000010 DTR output (set=disabled)
|
|
105 F.RTS equ %00000001 RTS output (set=disabled)
|
|
106
|
|
107 * data bit table
|
|
108 DB.5 equ %00000000 five data bits per character
|
|
109 DB.6 equ %00100000 six data bits per character
|
|
110 DB.7 equ %01000000 seven data bits per character
|
|
111 DB.8 equ %01100000 eight data bits per character
|
|
112
|
|
113 * parity table
|
|
114 Par.None equ %00000000
|
|
115 Par.Odd equ %00000100
|
|
116 Par.Even equ %00001100
|
|
117 Par.Mark equ %00010100
|
|
118 Par.Spac equ %00011100
|
|
119
|
|
120 * Transmit Break bit definitions
|
|
121 TB.Brk equ %00000010 Tx break control (set=transmit continuous line Break)
|
|
122 TB.Par equ %00000001 parity check (set=parity bit to ISE.Par, clear=normal)
|
|
123 else
|
|
124
|
|
125 ifeq A6551-true
|
|
126 * 6551 register definitions
|
|
127 org 0
|
|
128 DataReg rmb 1 receive/transmit Data (read Rx / write Tx)
|
|
129 StatReg rmb 1 status (read only)
|
|
130 PRstReg equ StatReg programmed reset (write only)
|
|
131 CmdReg rmb 1 command (read/write)
|
|
132 CtlReg rmb 1 control (read/write)
|
|
133
|
|
134 * Status bit definitions
|
|
135 Stat.IRQ equ %10000000 IRQ occurred
|
|
136 Stat.DSR equ %01000000 DSR level (clear = active)
|
|
137 Stat.DCD equ %00100000 DCD level (clear = active)
|
|
138 Stat.TxE equ %00010000 Tx data register Empty
|
|
139 Stat.RxF equ %00001000 Rx data register Full
|
|
140 Stat.Ovr equ %00000100 Rx data Overrun error
|
|
141 Stat.Frm equ %00000010 Rx data Framing error
|
|
142 Stat.Par equ %00000001 Rx data Parity error
|
|
143
|
|
144 Stat.Err equ Stat.Ovr!Stat.Frm!Stat.Par Status error bits
|
|
145 Stat.Flp equ $00 all Status bits active when set
|
|
146 Stat.Msk equ Stat.IRQ!Stat.RxF active IRQs
|
|
147
|
|
148 * Control bit definitions
|
|
149 Ctl.Stop equ %10000000 stop bits (set=two, clear=one)
|
|
150 Ctl.DBit equ %01100000 see data bit table below
|
|
151 Ctl.RxCS equ %00010000 Rx clock source (set=baud rate, clear=external)
|
|
152 Ctl.Baud equ %00001111 see baud rate table below
|
|
153
|
|
154 * data bit table
|
|
155 DB.8 equ %00000000 eight data bits per character
|
|
156 DB.7 equ %00100000 seven data bits per character
|
|
157 DB.6 equ %01000000 six data bits per character
|
|
158 DB.5 equ %01100000 five data bits per character
|
|
159
|
|
160 * baud rate table
|
|
161 org $00
|
|
162 BR.ExClk rmb 1 16x external clock (not supported)
|
|
163 org $11
|
|
164 BR.00050 rmb 1 50 baud (not supported)
|
|
165 BR.00075 rmb 1 75 baud (not supported)
|
|
166 BR.00110 rmb 1 109.92 baud
|
|
167 BR.00135 rmb 1 134.58 baud (not supported)
|
|
168 BR.00150 rmb 1 150 baud (not supported)
|
|
169 BR.00300 rmb 1 300 baud
|
|
170 BR.00600 rmb 1 600 baud
|
|
171 BR.01200 rmb 1 1200 baud
|
|
172 BR.01800 rmb 1 1800 baud (not supported)
|
|
173 BR.02400 rmb 1 2400 baud
|
|
174 BR.03600 rmb 1 3600 baud (not supported)
|
|
175 BR.04800 rmb 1 4800 baud
|
|
176 BR.07200 rmb 1 7200 baud (not supported)
|
|
177 BR.09600 rmb 1 9600 baud
|
|
178 BR.19200 rmb 1 19200 baud
|
|
179
|
|
180 * Command bit definitions
|
|
181 Cmd.Par equ %11100000 see parity table below
|
|
182 Cmd.Echo equ %00010000 local echo (set=activated)
|
|
183 Cmd.TIRB equ %00001100 see Tx IRQ/RTS/Break table below
|
|
184 Cmd.RxI equ %00000010 Rx IRQ (set=disabled)
|
|
185 Cmd.DTR equ %00000001 DTR output (set=enabled)
|
|
186
|
|
187 * parity table
|
|
188 Par.None equ %00000000
|
|
189 Par.Odd equ %00100000
|
|
190 Par.Even equ %01100000
|
|
191 Par.Mark equ %10100000
|
|
192 Par.Spac equ %11100000
|
|
193
|
|
194 * Tx IRQ/RTS/Break table
|
|
195 TIRB.Off equ %00000000 RTS & Tx IRQs disabled
|
|
196 TIRB.On equ %00000100 RTS & Tx IRQs enabled
|
|
197 TIRB.RTS equ %00001000 RTS enabled, Tx IRQs disabled
|
|
198 TIRB.Brk equ %00001100 RTS enabled, Tx IRQs disabled, Tx line Break
|
|
199 endc
|
|
200 endc
|
|
201
|
|
202 * V.ERR bit definitions
|
|
203 DCDLstEr equ %00100000 DCD lost error
|
|
204 OvrFloEr equ %00000100 Rx data overrun or Rx buffer overflow error
|
|
205 FrmingEr equ %00000010 Rx data framing error
|
|
206 ParityEr equ %00000001 Rx data parity error
|
|
207
|
|
208 * FloCtlRx bit definitions
|
|
209 FCRxSend equ %10000000 send flow control character
|
|
210 FCRxSent equ %00010000 Rx disabled due to XOFF sent
|
|
211 FCRxDTR equ %00000010 Rx disabled due to DTR
|
|
212 FCRxRTS equ %00000001 Rx disabled due to RTS
|
|
213
|
|
214 * FloCtlTx bit definitions
|
|
215 FCTxXOff equ %10000000 due to XOFF received
|
|
216 FCTxBrk equ %00000010 due to currently transmitting Break
|
|
217
|
|
218 * Wrk.Type bit definitions
|
|
219 Parity equ %11100000 parity bits
|
|
220 MdmKill equ %00010000 modem kill option
|
|
221 RxSwFlow equ %00001000 Rx data software (XON/XOFF) flow control
|
|
222 TxSwFlow equ %00000100 Tx data software (XON/XOFF) flow control
|
|
223 RTSFlow equ %00000010 CTS/RTS hardware flow control
|
|
224 DSRFlow equ %00000001 DSR/DTR hardware flow control
|
|
225
|
|
226 * Wrk.Baud bit definitions
|
|
227 StopBits equ %10000000 number of stop bits code
|
|
228 WordLen equ %01100000 word length code
|
|
229 BaudRate equ %00001111 baud rate code
|
|
230
|
|
231 * Wrk.XTyp bit definitions
|
|
232 SwpDCDSR equ %10000000 swap DCD+DSR bits (valid for 6551 only)
|
|
233 ForceDTR equ %01000000 don't drop DTR in term routine
|
|
234 RxBufPag equ %00001111 input buffer page count
|
|
235
|
|
236 * static data area definitions
|
|
237 org V.SCF allow for SCF manager data area
|
|
238
|
|
239 ifeq A6552-true
|
|
240 Cpy.CR rmb 1 Control register copy (MUST immediately precede Cpy.FR)
|
|
241 Cpy.FR rmb 1 Format register copy (MUST immediately follow Cpy.CR)
|
|
242 Cpy.ISR rmb 1 IRQ Status register copy (MUST immediately precede Cpy.CSR)
|
|
243 Cpy.CSR rmb 1 Control Status register copy (MUST immediately follow Cpy.ISR)
|
|
244 else
|
|
245
|
|
246 ifeq A6551-true
|
|
247 Cpy.Stat rmb 1 Status register copy
|
|
248 CpyDCDSR rmb 1 DSR+DCD status copy
|
|
249 Mask.DCD rmb 1 DCD status bit mask (MUST immediately precede Mask.DSR)
|
|
250 Mask.DSR rmb 1 DSR status bit mask (MUST immediately follow Mask.DCD)
|
|
251 endc
|
|
252 endc
|
|
253
|
|
254 CDSigPID rmb 1 process ID for CD signal
|
|
255 CDSigSig rmb 1 CD signal code
|
|
256 FloCtlRx rmb 1 Rx flow control flags
|
|
257 FloCtlTx rmb 1 Tx flow control flags
|
|
258 RxBufEnd rmb 2 end of Rx buffer
|
|
259 RxBufGet rmb 2 Rx buffer output pointer
|
|
260 RxBufMax rmb 2 Send XOFF (if enabled) at this point
|
|
261 RxBufMin rmb 2 Send XON (if XOFF sent) at this point
|
|
262 RxBufPtr rmb 2 pointer to Rx buffer
|
|
263 RxBufPut rmb 2 Rx buffer input pointer
|
|
264 RxBufSiz rmb 2 Rx buffer size
|
|
265 RxDatLen rmb 2 current length of data in Rx buffer
|
|
266 SigSent rmb 1 keyboard abort/interrupt signal already sent
|
|
267 SSigPID rmb 1 SS.SSig process ID
|
|
268 SSigSig rmb 1 SS.SSig signal code
|
|
269 WritFlag rmb 1 initial write attempt flag
|
|
270 Wrk.Type rmb 1 type work byte (MUST immediately precede Wrk.Baud)
|
|
271 Wrk.Baud rmb 1 baud work byte (MUST immediately follow Wrk.Type)
|
|
272 Wrk.XTyp rmb 1 extended type work byte
|
|
273 RxBufDSz equ 256-. default Rx buffer gets remainder of page...
|
|
274 RxBuff rmb RxBufDSz default Rx buffer
|
|
275 MemSize equ .
|
|
276
|
|
277 mod ModSize,ModName,Drivr+Objct,ReEnt+Vrsn,ModEntry,MemSize
|
|
278
|
|
279 fcb UPDAT. access mode(s)
|
|
280
|
|
281 ifeq A6552-true
|
|
282 ModName fcs "DACIA"
|
|
283 else
|
|
284
|
|
285 ifeq A6551-true
|
|
286 ModName fcs "SACIA"
|
|
287 endc
|
|
288 endc
|
|
289
|
|
290 fcb Edtn
|
|
291
|
|
292 SlotSlct fcb MPI.Slot selected MPI slot
|
|
293
|
|
294 ModEntry equ *
|
|
295 lbra Init
|
|
296 lbra Read
|
|
297 lbra Writ
|
|
298 lbra GStt
|
|
299 lbra SStt
|
|
300 lbra Term
|
|
301
|
|
302 IRQPckt equ *
|
|
303
|
|
304 ifeq A6552-true
|
|
305 Pkt.Flip fcb ISE.Flip D.Poll flip byte
|
|
306 Pkt.Mask fcb ISE.Mask D.Poll mask byte
|
|
307 else
|
|
308
|
|
309 ifeq A6551-true
|
|
310 Pkt.Flip fcb Stat.Flp flip byte
|
|
311 Pkt.Mask fcb Stat.Msk mask byte
|
|
312 endc
|
|
313 endc
|
|
314
|
|
315 fcb $0A priority
|
|
316
|
|
317 BaudTabl equ *
|
|
318
|
|
319 ifeq A6552-true
|
|
320 fcb BR.00110,BR.00300,BR.00600
|
|
321 fcb BR.01200,BR.02400,BR.04800
|
|
322 fcb BR.09600,BR.19200,BR.38400
|
|
323 else
|
|
324
|
|
325 ifeq A6551-true
|
|
326 fcb BR.00110,BR.00300,BR.00600
|
|
327 fcb BR.01200,BR.02400,BR.04800
|
|
328 fcb BR.09600,BR.19200
|
|
329 endc
|
|
330 endc
|
|
331
|
|
332
|
|
333 * NOTE: SCFMan has already cleared all device memory except for V.PAGE and
|
|
334 * V.PORT. Zero-default variables are: CDSigPID, CDSigSig, Wrk.XTyp.
|
|
335 Init equ *
|
|
336 clrb default to no error...
|
|
337 pshs cc,b,dp save IRQ/Carry status, dummy B, system DP
|
|
338 lbsr SetDP go set our DP
|
|
339 pshs y save descriptor pointer
|
|
340 ldd <V.PORT base hardware address
|
|
341
|
|
342 ifeq A6552-true
|
|
343 else
|
|
344
|
|
345 ifeq A6551-true
|
|
346 addd #1 point to 6551 status address
|
|
347 endc
|
|
348 endc
|
|
349
|
|
350 leax IRQPckt,pcr
|
|
351 leay IRQSvc,pcr
|
|
352 os9 F$IRQ
|
|
353 puls y recover descriptor pointer
|
|
354 lbcs ErrExit go report error...
|
|
355 ldb M$Opt,y get option size
|
|
356 cmpb #IT.XTYP-IT.DTP room for extended type byte?
|
|
357 bls DfltInfo no, go use defaults...
|
|
358
|
|
359 ifeq A6552-true
|
|
360 else
|
|
361
|
|
362 ifeq A6551-true
|
|
363 ldd #Stat.DCD*256+Stat.DSR default (unswapped) DCD+DSR masks
|
|
364 tst IT.XTYP,y check extended type byte for swapped DCD & DSR bits
|
|
365 bpl NoSwap no, go skip swapping them...
|
|
366 exg a,b swap to DSR+DCD masks
|
|
367 NoSwap std <Mask.DCD save DCD+DSR (or DSR+DCD) masks
|
|
368 endc
|
|
369 endc
|
|
370
|
|
371 lda IT.XTYP,y get extended type byte
|
|
372 sta <Wrk.XTyp save it
|
|
373 anda #RxBufPag clear all but Rx buffer page count bits
|
|
374 beq DfltInfo none, go use defaults...
|
|
375 clrb make data size an even number of pages
|
|
376 pshs u save data pointer
|
|
377 os9 F$SRqMem get extended buffer
|
|
378 tfr u,x copy address
|
|
379 puls u recover data pointer
|
|
380 lbcs TermExit error, go remove IRQ entry and exit...
|
|
381 bra SetRxBuf
|
|
382
|
|
383 DfltInfo ldd #RxBufDSz default Rx buffer size
|
|
384 leax RxBuff,u default Rx buffer address
|
|
385 SetRxBuf std <RxBufSiz save Rx buffer size
|
|
386 stx <RxBufPtr save Rx buffer address
|
|
387 stx <RxBufGet set initial Rx buffer input address
|
|
388 stx <RxBufPut set initial Rx buffer output address
|
|
389 leax d,x point to end of Rx buffer
|
|
390 stx <RxBufEnd save Rx buffer end address
|
|
391 subd #80 characters available in Rx buffer
|
|
392 std <RxBufMax set auto-XOFF threshold
|
|
393 ldd #10 characters remaining in Rx buffer
|
|
394 std <RxBufMin set auto-XON threshold after auto-XOFF
|
|
395
|
|
396 ifeq A6552-true
|
|
397 ldd #C.TBRCDR*256+(F.Slct!F.DTR!F.RTS) [A]=control, [B]=format register
|
|
398 sta <Cpy.CR save control register copy
|
|
399 lda <Wrk.XTyp
|
|
400 anda #ForceDTR forced DTR?
|
|
401 beq NoDTR no, don't enable DTR yet
|
|
402 andb #^F.DTR clear (enable) DTR bit
|
|
403 NoDTR stb <Cpy.FR save format register copy
|
|
404 else
|
|
405
|
|
406 ifeq A6551-true
|
|
407 ldb #TIRB.RTS default command register
|
|
408 lda <Wrk.XTyp
|
|
409 anda #ForceDTR forced DTR?
|
|
410 beq NoDTR no, don't enable DTR yet
|
|
411 orb #Cmd.DTR set (enable) DTR bit
|
|
412 NoDTR ldx <V.PORT get port address
|
|
413 stb CmdReg,x set new command register
|
|
414 endc
|
|
415 endc
|
|
416
|
|
417 ldd IT.PAR,y [A] = IT.PAR, [B] = IT.BAU from descriptor
|
|
418 lbsr SetPort go save it and set up control/format registers
|
|
419 orcc #IntMasks disable IRQs while setting up hardware
|
|
420 lda >PIA1Base+3 get PIA CART* input control register
|
|
421 anda #$FC clear PIA CART* control bits
|
|
422 sta >PIA1Base+3 disable PIA CART* FIRQs
|
|
423 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ
|
|
424 lda #$01 GIME CART* IRQ bit
|
|
425 ora >D.IRQER mask in current GIME IRQ enables
|
|
426 sta >D.IRQER save GIME CART* IRQ enable shadow register
|
|
427 sta >IrqEnR enable GIME CART* IRQs
|
|
428
|
|
429 ifeq A6552-true
|
|
430 lda #ISE.IRQ!ISE.Mask DACIA IRQ enables
|
|
431 sta IEReg,x enable DACIA IRQs for this port ([X]=V.PORT from SetPort)
|
|
432 ldb ISReg,x ensure old CTS, DCD, and DSR transition IRQ flags are clear
|
|
433 ldb DataReg,x ensure old error and Rx data IRQ flags are clear
|
|
434 ldb ISReg,x ... again
|
|
435 ldb DataReg,x ... and again
|
|
436 ldd ISReg,x get new IRQ and Control status registers
|
|
437 eora Pkt.Flip,pcr flip bits per D.Poll
|
|
438 anda Pkt.Mask,pcr any IRQ(s) still pending?
|
|
439 lbne NRdyErr yes, go report error... (device not plugged in?)
|
|
440 std <Cpy.ISR save new IRQ and Control status register copies
|
|
441 else
|
|
442
|
|
443 ifeq A6551-true
|
|
444 lda StatReg,x ensure old IRQ flags are clear
|
|
445 lda DataReg,x ensure old error and Rx data IRQ flags are clear
|
|
446 lda StatReg,x ... again
|
|
447 lda DataReg,x ... and again
|
|
448 lda StatReg,x get new Status register contents
|
|
449 sta <Cpy.Stat save Status copy
|
|
450 tfr a,b copy it...
|
|
451 eora Pkt.Flip,pcr flip bits per D.Poll
|
|
452 anda Pkt.Mask,pcr any IRQ(s) still pending?
|
|
453 lbne NRdyErr yes, go report error... (device not plugged in?)
|
|
454 andb #Stat.DSR!Stat.DCD clear all but DSR+DCD status
|
|
455 stb <CpyDCDSR save new DCD+DSR status copy
|
|
456 endc
|
|
457 endc
|
|
458
|
|
459 lda SlotSlct,pcr get MPI slot select value
|
|
460 bmi NoSelect no MPI slot select, go on...
|
|
461 sta >MPI.Slct set MPI slot select register
|
|
462 NoSelect puls cc,b,dp,pc recover IRQ/Carry status, dummy B, system DP, return
|
|
463
|
|
464
|
|
465 Term equ *
|
|
466 clrb default to no error...
|
|
467 pshs cc,b,dp save IRQ/Carry status, dummy B, system DP
|
|
468 lbsr SetDP go set our DP
|
|
469
|
|
470 ifeq A6552-true
|
|
471 lda #^ISE.IRQ disable all DACIA IRQs
|
|
472 ldx <V.PORT
|
|
473 sta IEReg,x disable DACIA IRQs for this port
|
|
474 lda <Cpy.FR get format register copy
|
|
475 ora #F.DTR!F.RTS set (disable) DTR and RTS bits
|
|
476 ldb <Wrk.XTyp get extended type byte
|
|
477 andb #ForceDTR forced DTR?
|
|
478 beq KeepDTR no, go leave DTR disabled...
|
|
479 anda #^F.DTR clear (enable) DTR bit
|
|
480 KeepDTR sta CFReg,x set DTR and RTS enable/disable
|
|
481 else
|
|
482
|
|
483 ifeq A6551-true
|
|
484 ldx <V.PORT
|
|
485 lda CmdReg,x get current Command register contents
|
|
486 anda #^(Cmd.TIRB!Cmd.DTR) disable Tx IRQs, RTS, and DTR
|
|
487 ora #Cmd.RxI disable Rx IRQs
|
|
488 ldb <Wrk.XTyp get extended type byte
|
|
489 andb #ForceDTR forced DTR?
|
|
490 beq KeepDTR no, go leave DTR disabled...
|
|
491 ora #Cmd.DTR set (enable) DTR bit
|
|
492 KeepDTR sta CmdReg,x set DTR and RTS enable/disable
|
|
493 endc
|
|
494 endc
|
|
495
|
|
496 ldd <RxBufSiz get Rx buffer size
|
|
497 tsta less than 256 bytes?
|
|
498 beq TermExit yes, no system memory to return...
|
|
499 pshs u save data pointer
|
|
500 ldu <RxBufPtr get address of system memory
|
|
501 os9 F$SRtMem
|
|
502 puls u recover data pointer
|
|
503 TermExit ldd <V.PORT base hardware address is status register
|
|
504
|
|
505 ifeq A6552-true
|
|
506 else
|
|
507
|
|
508 ifeq A6551-true
|
|
509 addd #1 point to 6551 status register
|
|
510 endc
|
|
511 endc
|
|
512
|
|
513 ldx #$0000 remove IRQ table entry
|
|
514 leay IRQSvc,pcr
|
|
515 puls cc recover IRQ/Carry status
|
|
516 os9 F$IRQ
|
|
517 puls a,dp,pc restore dummy A, system DP, return
|
|
518
|
|
519
|
|
520 ReadSlp ldd >D.Proc process descriptor address
|
|
521 sta <V.WAKE save MSB for IRQ service routine
|
|
522 tfr d,x copy process descriptor address
|
|
523 ldb P$State,x get process state flag
|
|
524 orb #Suspend set suspend flag
|
|
525 stb P$State,x put process in suspend state
|
|
526 lbsr Sleep1 go suspend process...
|
|
527 ldx >D.Proc process descriptor address
|
|
528 ldb P$Signal,x pending signal for this process?
|
|
529 beq ChkState no, go check process state...
|
|
530 cmpb #S$Intrpt do we honor signal?
|
|
531 bls ErrExit yes, go do it...
|
|
532 ChkState ldb P$State,x get process state
|
|
533 bitb #Condem we be dead?
|
|
534 bne PrAbtErr yes, go do it...
|
|
535 ldb <V.WAKE true interrupt?
|
|
536 bne ReadSlp no, go suspend again...
|
|
537 ReadLoop puls cc,b,dp recover IRQ/Carry status, dummy B, system DP
|
|
538
|
|
539 Read equ *
|
|
540 clrb default to no errors...
|
|
541 pshs cc,b,dp save IRQ/Carry status, dummy B, system DP
|
|
542 lbsr SetDP go set our DP
|
|
543 orcc #IntMasks disable IRQs while checking Rx flow control
|
|
544 lda <FloCtlRx get Rx flow control flags
|
|
545 beq ReadChar none, go get Rx character...
|
|
546 ldx <RxDatLen get Rx data count again
|
|
547 cmpx <RxBufMin at or below XON level?
|
|
548 bhi ReadChar no, go get Rx character...
|
|
549 ldx <V.PORT
|
|
550 bita #FCRxSent Rx disabled due to XOFF sent?
|
|
551 beq ChkHWHS no, go check hardware handshake(s)...
|
|
552 ldb <FloCtlTx get Tx flow control flags
|
|
553 bitb #FCTxBrk currently transmitting line Break?
|
|
554 bne ReadLoop yes, go skip XON this time...
|
|
555
|
|
556 ifeq A6552-true
|
|
557 ldb CSReg,x get new Control Status register
|
|
558 bitb #CS.TxE Tx data register empty?
|
|
559 beq ReadLoop no, go skip XON this time...
|
|
560 ldb <V.XON
|
|
561 stb DataReg,x write XON character
|
|
562 ChkHWHS bita #FCRxDTR!FCRxRTS Rx disabled due to DTR or RTS?
|
|
563 beq RxFloClr no, go clear Rx flow control flag(s)...
|
|
564 ldb <Cpy.FR get Format register copy
|
|
565 andb #^(F.DTR!F.RTS) clear (enable) DTR and RTS bits
|
|
566 stb <Cpy.FR save Format register copy
|
|
567 stb CFReg,x set Format register
|
|
568 else
|
|
569
|
|
570 ifeq A6551-true
|
|
571 ldb StatReg,x get new Status register
|
|
572 bitb #Stat.TxE Tx data register empty?
|
|
573 beq ReadLoop no, go skip XON this time...
|
|
574 ldb <V.XON
|
|
575 stb DataReg,x write XON character
|
|
576 ChkHWHS bita #FCRxDTR!FCRxRTS Rx disabled due to DTR or RTS?
|
|
577 beq RxFloClr no, go clear Rx flow control flag(s)...
|
|
578 ldb CmdReg,x get current Command register contents
|
|
579 andb #^Cmd.TIRB clear Tx IRQ/RTS/Break control bits
|
|
580 orb #TIRB.RTS!Cmd.DTR enable RTS and DTR, disable Tx IRQs
|
|
581 stb CmdReg,x set Command register
|
|
582 endc
|
|
583 endc
|
|
584
|
|
585 RxFloClr clr <FloCtlRx clear Rx flow control flags
|
|
586 ReadChar ldb <V.ERR get accumulated errors, if any
|
|
587 stb PD.ERR,y set/clear error(s) in path descriptor
|
|
588 bne ReprtErr error(s), go report it/them...
|
|
589 ldx <RxDatLen get Rx buffer count
|
|
590 beq ReadSlp none, go sleep while waiting for new Rx data...
|
|
591 leax -1,x less character we're about to grab
|
|
592 stx <RxDatLen save new Rx data count
|
|
593 ldx <RxBufGet current Rx buffer pickup position
|
|
594 lda ,x+ get Rx character, set up next pickup position
|
|
595 cmpx <RxBufEnd end of Rx buffer?
|
|
596 blo SetPckUp no, go keep pickup pointer
|
|
597 ldx <RxBufPtr get Rx buffer start address
|
|
598 SetPckUp stx <RxBufGet set new Rx data pickup pointer
|
|
599 puls cc,b,dp,pc recover IRQ/Carry status, dummy B, system DP, return
|
|
600
|
|
601
|
|
602 PrAbtErr ldb #E$PrcAbt
|
|
603 bra ErrExit
|
|
604
|
|
605 ReprtErr clr <V.ERR clear error status
|
|
606 bitb #DCDLstEr DCD lost error?
|
|
607 bne HngUpErr yes, go report it...
|
|
608 ldb #E$Read
|
|
609 ErrExit puls cc restore IRQ enable and Carry status
|
|
610 coma error, set Carry
|
|
611 puls a,dp,pc restore dummy A (or Tx character), system DP, return
|
|
612
|
|
613 HngUpErr ldb #E$HangUp
|
|
614 lda #PST.DCD DCD lost flag
|
|
615 sta PD.PST,y set path status flag
|
|
616 bra ErrExit
|
|
617
|
|
618 NRdyErr ldb #E$NotRdy
|
|
619 bra ErrExit
|
|
620
|
|
621 UnSvcErr ldb #E$UnkSvc
|
|
622 bra ErrExit
|
|
623
|
|
624
|
|
625 WritLoop lda <WritFlag first pass through for this Tx character?
|
|
626 beq WritFast yes, don't sleep yet...
|
|
627 lbsr Sleep1 go sleep for balance of tick...
|
|
628 WritFast inc <WritFlag set "initial write attempt" flag
|
|
629 puls cc,a,dp recover IRQ/Carry status, Tx character, system DP
|
|
630
|
|
631 Writ equ *
|
|
632 clrb default to no error...
|
|
633 pshs cc,a,dp save IRQ/Carry status, Tx character, system DP
|
|
634 lbsr SetDP go set our DP
|
|
635 ldx <V.PORT
|
|
636 orcc #IntMasks disable IRQs during error and Tx disable checks
|
|
637 ldb <V.ERR get accumulated errors, if any
|
|
638 andb #DCDLstEr DCD lost error? (ignore other errors, if any)
|
|
639 stb PD.ERR,y set/clear error(s) in path descriptor
|
|
640 bne ReprtErr DCD lost error, go report it...
|
|
641
|
|
642 ifeq A6552-true
|
|
643 ldb <Cpy.CSR get copy of control status register
|
|
644 bitb #CS.CTS Tx disabled due to CTS?
|
|
645 bne WritLoop yes, go sleep a while...
|
|
646 lda <Wrk.Type get software/hardware handshake enables
|
|
647 bita #DSRFlow DSR/DTR handshake enabled?
|
|
648 beq ChkTxFlo no, go check Tx flow control
|
|
649 bitb #CS.DSR Tx disabled due to DSR?
|
|
650 bne WritLoop yes, go sleep a while...
|
|
651 else
|
|
652
|
|
653 ifeq A6551-true
|
|
654 lda <Wrk.Type get software/hardware handshake enables
|
|
655 bita #DSRFlow DSR/DTR handshake enabled?
|
|
656 beq ChkTxFlo no, go check Tx flow control
|
|
657 ldb <Cpy.Stat get copy of status register
|
|
658 bitb <Mask.DSR Tx disabled due to DSR?
|
|
659 bne WritLoop yes, go sleep a while...
|
|
660 endc
|
|
661 endc
|
|
662
|
|
663 ChkTxFlo ldb <FloCtlTx get Tx flow control flags
|
|
664 bitb #FCTxBrk currently transmitting line Break?
|
|
665 bne WritLoop yes, go sleep a while...
|
|
666 bita #TxSwFlow Tx software flow control enabled?
|
|
667 beq ChkRxFlo no, go check pending Rx flow control
|
|
668 bitb #FCTxXOff Tx disabled due to received XOFF?
|
|
669 bne WritLoop yes, go sleep a while...
|
|
670 ChkRxFlo bita #RxSwFlow Rx software flow control enabled?
|
|
671 beq ChkTxE no, go check Tx register empty
|
|
672 ldb <FloCtlRx get Rx flow control flags
|
|
673 bitb #FCRxSend XON/XOFF Rx flow control pending?
|
|
674 bne WritLoop yes, go sleep a while...
|
|
675 ChkTxE lda 1,s get Tx character
|
|
676
|
|
677 ifeq A6552-true
|
|
678 ldb CSReg,x get new control status register
|
|
679 bitb #CS.TxE Tx register empty?
|
|
680 beq WritLoop no, go sleep a while...
|
|
681 sta DataReg,x write Tx character
|
|
682 else
|
|
683
|
|
684 ifeq A6551-true
|
|
685 ldb StatReg,x get new status register
|
|
686 bitb #Stat.TxE Tx register empty?
|
|
687 beq WritLoop no, go sleep a while...
|
|
688 sta DataReg,x write Tx character
|
|
689 endc
|
|
690 endc
|
|
691
|
|
692 clr <WritFlag clear "initial write attempt" flag
|
|
693 puls cc,a,dp,pc recover IRQ/Carry status, Tx character, system DP, return
|
|
694
|
|
695
|
|
696 GStt equ *
|
|
697 clrb default to no error...
|
|
698 pshs cc,b,dp save IRQ/Carry status, dummy B, system DP
|
|
699 lbsr SetDP go set our DP
|
|
700 ldx PD.RGS,y caller's register stack pointer
|
|
701 cmpa #SS.EOF
|
|
702 beq GSExitOK yes, SCF devices never return EOF
|
|
703 cmpa #SS.Ready
|
|
704 bne GetScSiz
|
|
705 ldd <RxDatLen get Rx data length
|
|
706 beq NRdyErr none, go report error
|
|
707 tsta more than 255 bytes?
|
|
708 beq SaveLen no, keep Rx data available
|
|
709 ldb #255 yes, just use 255
|
|
710 SaveLen stb R$B,x set Rx data available in caller's [B]
|
|
711 GSExitOK puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
712
|
|
713 GetScSiz cmpa #SS.ScSiz
|
|
714 bne GetComSt
|
|
715 ldu PD.DEV,y
|
|
716 ldu V$DESC,u
|
|
717 clra
|
|
718 ldb IT.COL,u
|
|
719 std R$X,x
|
|
720 ldb IT.ROW,u
|
|
721 std R$Y,x
|
|
722 puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
723
|
|
724 GetComSt cmpa #SS.ComSt
|
|
725 lbne UnSvcErr no, go report error
|
|
726 ldd <Wrk.Type
|
|
727 std R$Y,x
|
|
728 clra default to DCD and DSR enabled
|
|
729
|
|
730 ifeq A6552-true
|
|
731 ldb <Cpy.CSR get current status
|
|
732 bitb #CS.DCD DCD bit set (disabled)?
|
|
733 else
|
|
734
|
|
735 ifeq A6551-true
|
|
736 ldb <CpyDCDSR get current DSR+DCD status
|
|
737 bitb <Mask.DCD DCD bit set (disabled)?
|
|
738 endc
|
|
739 endc
|
|
740
|
|
741 beq CheckDSR no, go check DSR status
|
|
742 ora #DCDStBit
|
|
743
|
|
744 ifeq A6552-true
|
|
745 CheckDSR bitb #CS.DSR DSR bit set (disabled)?
|
|
746 else
|
|
747
|
|
748 ifeq A6551-true
|
|
749 CheckDSR bitb <Mask.DSR DSR bit set (disabled)?
|
|
750 endc
|
|
751 endc
|
|
752
|
|
753 beq SaveCDSt no, go set DCD/DSR status
|
|
754 ora #DSRStBit
|
|
755 SaveCDSt sta R$B,x set 6551 ACIA style DCD/DSR status in caller's [B]
|
|
756 puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
757
|
|
758
|
|
759 BreakSlp ldx #SlpBreak SS.Break duration
|
|
760 bra TimedSlp
|
|
761 HngUpSlp ldx #SlpHngUp SS.HngUp duration
|
|
762 bra TimedSlp
|
|
763 Sleep1 ldx #1 give up balance of tick
|
|
764 TimedSlp pshs cc save IRQ enable status
|
|
765 andcc #Intmasks enable IRQs
|
|
766 os9 F$Sleep
|
|
767 puls cc,pc restore IRQ enable status, return
|
|
768
|
|
769
|
|
770 SStt equ *
|
|
771 clrb default to no error...
|
|
772 pshs cc,b,dp save IRQ/Carry status, dummy B, system DP
|
|
773 lbsr SetDP go set our DP
|
|
774 ldx PD.RGS,y
|
|
775 cmpa #SS.HngUp
|
|
776 bne SetBreak
|
|
777
|
|
778 ifeq A6552-true
|
|
779 lda #F.DTR set (disable) DTR bit
|
|
780 ldx <V.PORT
|
|
781 orcc #IntMasks disable IRQs while setting Format register
|
|
782 ora <Cpy.FR mask in Format register copy
|
|
783 sta <Cpy.FR save Format register copy
|
|
784 sta CFReg,x set new Format register
|
|
785 bsr HngUpSlp go sleep for a while...
|
|
786 lda #^(F.DTR!F.RTS) clear (enable) DTR and RTS bits
|
|
787 FRegClr ldx <V.PORT
|
|
788 anda <Cpy.FR mask in Format register copy
|
|
789 ldb <FloCtlRx get Rx flow control flags
|
|
790 bitb #FCRxDTR Rx disabled due to DTR?
|
|
791 beq LeaveDTR no, go leave DTR enabled
|
|
792 ora #F.DTR set (disable) DTR bit
|
|
793 LeaveDTR bitb #FCRxRTS Rx disabled due to RTS?
|
|
794 beq LeaveRTS no, go leave RTS enabled
|
|
795 ora #F.RTS set (disable) RTS bit
|
|
796 LeaveRTS sta <Cpy.FR save Format register copy
|
|
797 sta CFReg,x set new Format register
|
|
798 else
|
|
799
|
|
800 ifeq A6551-true
|
|
801 lda #^Cmd.DTR cleared (disabled) DTR bit
|
|
802 ldx <V.PORT
|
|
803 orcc #IntMasks disable IRQs while setting Command register
|
|
804 anda CmdReg,x mask in current Command register contents
|
|
805 sta CmdReg,x set new Command register
|
|
806 bsr HngUpSlp go sleep for a while...
|
|
807 BreakClr lda #^(Cmd.TIRB!Cmd.DTR) clear (disable) DTR and RTS control bits
|
|
808 FRegClr ldx <V.PORT
|
|
809 anda CmdReg,x mask in current Command register
|
|
810 ldb <FloCtlRx get Rx flow control flags
|
|
811 bitb #FCRxDTR Rx disabled due to DTR?
|
|
812 bne LeaveDTR yes, go leave DTR disabled
|
|
813 ora #Cmd.DTR set (enable) DTR bit
|
|
814 LeaveDTR bitb #FCRxRTS Rx disabled due to RTS?
|
|
815 bne LeaveRTS yes, go leave RTS disabled
|
|
816 ora #TIRB.RTS enable RTS output
|
|
817 LeaveRTS ldb <FloCtlTx get Tx flow control flags
|
|
818 bitb #FCTxBrk currently transmitting line Break?
|
|
819 beq NotTxBrk no, go leave RTS alone...
|
|
820 ora #TIRB.Brk set Tx Break bits
|
|
821 NotTxBrk sta CmdReg,x set new Command register
|
|
822 endc
|
|
823 endc
|
|
824
|
|
825 puls cc,b,dp,pc restore IRQ/Carry status, dummy B, system DP, return
|
|
826
|
|
827 SetBreak cmpa #SS.Break Tx line break?
|
|
828 bne SetSSig
|
|
829
|
|
830 ifeq A6552-true
|
|
831 ldy <V.PORT
|
|
832 ldd #FCTxBrk*256+TB.Brk [A]=flow control flag, [B]=Tx break enable
|
|
833 orcc #Intmasks disable IRQs while messing with flow control flags
|
|
834 ora <FloCtlTx set Tx break flag bit
|
|
835 sta <FloCtlTx save Tx flow control flags
|
|
836 stb TBReg,y start Tx line break
|
|
837 bsr BreakSlp go sleep for a while...
|
|
838 anda #^FCTxBrk clear Tx break flag bit
|
|
839 sta <FloCtlTx save Tx flow control flags
|
|
840 clr TBReg,y end Tx line break
|
|
841 puls cc,b,dp,pc restore IRQ/Carry status, dummy B, system DP, return
|
|
842 else
|
|
843
|
|
844 ifeq A6551-true
|
|
845 ldy <V.PORT
|
|
846 ldd #FCTxBrk*256+TIRB.Brk [A]=flow control flag, [B]=Tx break enable
|
|
847 orcc #Intmasks disable IRQs while messing with flow control flags
|
|
848 ora <FloCtlTx set Tx break flag bit
|
|
849 sta <FloCtlTx save Tx flow control flags
|
|
850 orb CmdReg,y set Tx line break bits
|
|
851 stb CmdReg,y start Tx line break
|
|
852 bsr BreakSlp go sleep for a while...
|
|
853 anda #^FCTxBrk clear Tx break flag bit
|
|
854 sta <FloCtlTx save Tx flow control flags
|
|
855 bra BreakClr go restore RTS output to previous...
|
|
856 endc
|
|
857 endc
|
|
858
|
|
859 SetSSig cmpa #SS.SSig
|
|
860 bne SetRelea
|
|
861 lda PD.CPR,y current process ID
|
|
862 ldb R$X+1,x LSB of [X] is signal code
|
|
863 orcc #IntMasks disable IRQs while checking Rx data length
|
|
864 ldx <RxDatLen
|
|
865 bne RSendSig
|
|
866 std <SSigPID
|
|
867 puls cc,b,dp,pc restore IRQ/Carry status, dummy B, system DP, return
|
|
868 RSendSig puls cc restore IRQ/Carry status
|
|
869 os9 F$Send
|
|
870 puls a,dp,pc restore dummy A, system DP, return
|
|
871
|
|
872 SetRelea cmpa #SS.Relea
|
|
873 bne SetCDSig
|
|
874 leax SSigPID,u point to Rx data signal process ID
|
|
875 bsr ReleaSig go release signal...
|
|
876 puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
877
|
|
878 SetCDSig cmpa #SS.CDSig set DCD signal?
|
|
879 bne SetCDRel
|
|
880 lda PD.CPR,y current process ID
|
|
881 ldb R$X+1,x LSB of [X] is signal code
|
|
882 std <CDSigPID
|
|
883 puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
884
|
|
885 SetCDRel cmpa #SS.CDRel release DCD signal?
|
|
886 bne SetComSt
|
|
887 CDRelSig leax CDSigPID,u point to DCD signal process ID
|
|
888 bsr ReleaSig go release signal...
|
|
889 puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
890
|
|
891 SetComSt cmpa #SS.ComSt
|
|
892 bne SetOpen
|
|
893 ldd R$Y,x caller's [Y] contains ACIAPAK format type/baud info
|
|
894 bsr SetPort go save it and set up control/format registers
|
|
895 ReturnOK puls cc,b,dp,pc restore Carry status, dummy B, system DP, return
|
|
896
|
|
897 SetOpen cmpa #SS.Open
|
|
898 bne SetClose
|
|
899 lda R$Y+1,x get LSB of caller's [Y]
|
|
900 deca real SS.Open from SCF? (SCF sets LSB of [Y] = 1)
|
|
901 bne ReturnOK no, go do nothing but return OK...
|
|
902
|
|
903 ifeq A6552-true
|
|
904 lda #^(F.DTR!F.RTS) clear (enable) DTR and RTS bits
|
|
905 else
|
|
906
|
|
907 ifeq A6551-true
|
|
908 lda #TIRB.RTS enabled DTR and RTS outputs
|
|
909 endc
|
|
910 endc
|
|
911
|
|
912 orcc #IntMasks disable IRQs while setting Format register
|
|
913 lbra FRegClr go enable DTR and RTS (if not disabled due to Rx flow control)
|
|
914
|
|
915 SetClose cmpa #SS.Close
|
|
916 lbne UnSvcErr no, go report error...
|
|
917 lda R$Y+1,x real SS.Close from SCF? (SCF sets LSB of [Y] = 0)
|
|
918 bne ReturnOK no, go do nothing but return OK...
|
|
919 leax SSigPID,u point to Rx data signal process ID
|
|
920 bsr ReleaSig go release signal...
|
|
921 bra CDRelSig go release DCD signal, return from there...
|
|
922
|
|
923 ReleaSig pshs cc save IRQ enable status
|
|
924 orcc #IntMasks disable IRQs while releasing signal
|
|
925 lda PD.CPR,y get current process ID
|
|
926 suba ,x same as signal process ID?
|
|
927 bne NoReleas no, go return...
|
|
928 sta ,x clear this signal's process ID
|
|
929 NoReleas puls cc,pc restore IRQ enable status, return
|
|
930
|
|
931 ifeq A6552-true
|
|
932 SetPort pshs cc save IRQ enable and Carry status
|
|
933 orcc #IntMasks disable IRQs while setting up DACIA registers
|
|
934 std <Wrk.Type save type/baud in data area
|
|
935 lsra *shift parity bits into
|
|
936 lsra *position for 65C52's
|
|
937 lsra *format register
|
|
938 anda #F.Par clear all except parity bits
|
|
939 pshs a save parity temporarily
|
|
940 comb translate word length bits to 65C52's word length code
|
|
941 andb #F.DatBit clear all except word length bits
|
|
942 orb ,s+ mask in parity and clean up stack
|
|
943 lda <Wrk.Baud get baud information
|
|
944 anda #BaudRate clear all but baud rate bits
|
|
945 leax BaudTabl,pcr
|
|
946 lda a,x get baud rate setting
|
|
947 pshs a save it temporarily
|
|
948 lda <Wrk.Baud get stop bit(s) information
|
|
949 lsra *shift stop bit into position
|
|
950 lsra *for 65C52's control register
|
|
951 anda #C.StpBit clear all except stop bit code
|
|
952 ora ,s+ mask in baud rate and clean up stack
|
|
953 pshs d save stopbits/baudrate and wordlength/parity temporarily
|
|
954 ldd <Cpy.CR get old control/format register copies
|
|
955 anda #^(C.StpBit!C.Baud) clear stop bit and baud rate code bits
|
|
956 ora ,s+ mask in stop bit(s) and baud rate
|
|
957 andb #^(F.DatBit!F.Par) clear word length and parity code bits
|
|
958 orb ,s+ mask in word length and parity
|
|
959 ldx <V.PORT get port address
|
|
960 std <Cpy.CR save control/format register copies
|
|
961 sta CFReg,x set control register
|
|
962 stb CFReg,x set format register
|
|
963 puls cc,pc recover IRQ enable and Carry status, return...
|
|
964 else
|
|
965
|
|
966 ifeq A6551-true
|
|
967 SetPort pshs cc save IRQ enable and Carry status
|
|
968 orcc #IntMasks disable IRQs while setting up ACIA registers
|
|
969 std <Wrk.Type save type/baud in data area
|
|
970 leax BaudTabl,pcr
|
|
971 andb #BaudRate clear all but baud rate bits
|
|
972 ldb b,x get baud rate setting
|
|
973 pshs b save it temporarily
|
|
974 ldb <Wrk.Baud get baud info again
|
|
975 andb #^(Ctl.RxCS!Ctl.Baud) clear clock source + baud rate code bits
|
|
976 orb ,s+ mask in clock source + baud rate and clean up stack
|
|
977 ldx <V.PORT get port address
|
|
978 anda #Cmd.Par clear all except parity bits
|
|
979 pshs a save new command register contents temporarily
|
|
980 lda CmdReg,x get current command register contents
|
|
981 anda #^Cmd.Par clear parity control bits
|
|
982 ora ,s+ mask in new parity
|
|
983 std CmdReg,x set command+control registers
|
|
984 puls cc,pc recover IRQ enable and Carry status, return...
|
|
985 endc
|
|
986 endc
|
|
987
|
|
988 SetDP pshs u save our data pointer
|
|
989 puls dp set our DP
|
|
990 leas 1,s clean up stack
|
|
991 rts
|
|
992
|
|
993 AccumErr ora <V.ERR
|
|
994 sta <V.ERR
|
|
995 rts
|
|
996
|
|
997
|
|
998 ifeq A6552-true
|
|
999 IRQSvc equ *
|
|
1000 pshs dp save system DP
|
|
1001 bsr SetDP go set our DP
|
|
1002 ldx <V.PORT
|
|
1003 ldb CSReg,x get current Control/Status register
|
|
1004 std <Cpy.ISR save ISR (from D.Poll check) and CSR copies
|
|
1005 bita #ISE.FOB!ISE.Par FRM/OVR/BRK or Parity error?
|
|
1006 beq ChkRDRF no, go check Rx data
|
|
1007 tst DataReg,x read Rx data register to clear DACIA error flags
|
|
1008 bitb #CS.Break Rx line break?
|
|
1009 beq ChkParty no, go check if parity error...
|
|
1010 lda <V.QUIT default to keyboard quit ("Break") code
|
|
1011 bra RxBreak go pretend we've received V.QUIT character...
|
|
1012
|
|
1013 ChkParty anda #ISE.Par parity error?
|
|
1014 beq ChkFrame no, go check framing error
|
|
1015 lda #ParityEr mark parity error
|
|
1016 ChkFrame bitb #CS.Frame framing error?
|
|
1017 beq ChkOvRun no, go check overrun error...
|
|
1018 ora #FrmingEr mark Framing error
|
|
1019 ChkOvRun tsta any other error flag(s) set?
|
|
1020 bne SaveErrs yes, go save them...
|
|
1021 ora #OvrFloEr must be overrun error, mark it
|
|
1022 SaveErrs bsr AccumErr go save accumulated errors...
|
|
1023 lbra ChkTrDCD go check if DCD transition...
|
|
1024
|
|
1025 ChkRDRF bita #ISE.RxF Rx data?
|
|
1026 lbeq ChkTrDCD no, go check DCD transition
|
|
1027 lda DataReg,x get Rx data
|
|
1028 RxBreak beq SavRxDat its a null, go save it...
|
|
1029 clr <SigSent clear signal sent flag
|
|
1030 cmpa <V.INTR interrupt?
|
|
1031 bne Chk.Quit no, go on...
|
|
1032 ldb #S$Intrpt
|
|
1033 bra SendSig
|
|
1034 Chk.Quit cmpa <V.QUIT abort?
|
|
1035 bne Chk.PChr no, go on...
|
|
1036 ldb #S$Abort
|
|
1037 SendSig pshs a save Rx data
|
|
1038 lda <V.LPRC get last process' ID
|
|
1039 os9 F$Send
|
|
1040 puls a recover Rx data
|
|
1041 stb <SigSent set signal sent flag
|
|
1042 bra SavRxDat go save Rx data...
|
|
1043 Chk.PChr cmpa <V.PCHR pause?
|
|
1044 bne Chk.Flow no, go on...
|
|
1045 ldx <V.DEV2 attached device defined?
|
|
1046 beq SavRxDat no, go save Rx data...
|
|
1047 sta V.PAUS,x yes, pause attached device
|
|
1048 bra SavRxDat go save Rx data...
|
|
1049 Chk.Flow ldb <Wrk.Type
|
|
1050 bitb #TxSwFlow Tx data software flow control enabled?
|
|
1051 beq SavRxDat no, go save Rx data...
|
|
1052 cmpa <V.XON XON?
|
|
1053 bne Chk.XOff no, go on...
|
|
1054 ldb #^FCTxXOff clear XOFF received bit
|
|
1055 andb <FloCtlTx clear software Tx flow control flag
|
|
1056 bra SetTxFlo go save new Tx flow control flags...
|
|
1057 Chk.XOff cmpa <V.XOFF XOFF?
|
|
1058 bne SavRxDat no, go save Rx data...
|
|
1059 ldb #FCTxXOff set XOFF received bit
|
|
1060 orb <FloCtlTx set software Tx flow control flag
|
|
1061 SetTxFlo stb <FloCtlTx save new Tx flow control flags
|
|
1062 lbra ChkTrDCD go check DCD transition...
|
|
1063 SavRxDat ldb <FloCtlRx get Rx flow control flags
|
|
1064 andb #^FCRxSend clear possible pending XOFF flag
|
|
1065 stb <FloCtlRx save Rx flow control flags
|
|
1066 ldy <RxBufPut get Rx buffer input pointer
|
|
1067 ldx <RxDatLen Rx get Rx buffer data length
|
|
1068 cmpx <RxBufSiz Rx buffer already full?
|
|
1069 blo NotOvFlo no, go skip overflow error...
|
|
1070 lda #OvrFloEr mark Rx buffer overflow
|
|
1071 lbsr AccumErr go save accumulated errors...
|
|
1072 bra DisRxFlo go ensure Rx is disabled (if possible)
|
|
1073 NotOvFlo sta ,y+ save Rx data
|
|
1074 cmpy <RxBufEnd end of Rx buffer?
|
|
1075 blo SetLayDn no, go keep laydown pointer
|
|
1076 ldy <RxBufPtr get Rx buffer start address
|
|
1077 SetLayDn sty <RxBufPut set new Rx data laydown pointer
|
|
1078 leax 1,x one more byte in Rx buffer
|
|
1079 stx <RxDatLen save new Rx data length
|
|
1080 cmpx <RxBufMax at or past maximum (XOFF) fill point?
|
|
1081 blo SgnlRxD no, go check Rx data signal...
|
|
1082 DisRxFlo lda <Wrk.XTyp
|
|
1083 ldb <Cpy.FR get Format register copy
|
|
1084 bita #ForceDTR forced DTR?
|
|
1085 bne DisRxRTS yes, go check RTS disable...
|
|
1086 lda <Wrk.Type
|
|
1087 bita #DSRFlow DSR/DTR flow control enabled?
|
|
1088 beq DisRxRTS no, go check RTS disable
|
|
1089 lda <FloCtlRx get Rx flow control flags
|
|
1090 ora #FCRxDTR mark Rx disabled by DTR
|
|
1091 sta <FloCtlRx save new Rx flow control flags
|
|
1092 orb #F.DTR set (disable) DTR bit
|
|
1093 DisRxRTS lda <Wrk.Type
|
|
1094 bita #RTSFlow CTS/RTS flow control enabled?
|
|
1095 beq NewRxFlo no, go set new Rx flow control...
|
|
1096 lda <FloCtlRx get Rx flow control flags
|
|
1097 ora #FCRxRTS mark Rx disabled by RTS
|
|
1098 sta <FloCtlRx save new Rx flow control flags
|
|
1099 orb #F.RTS set (disable) RTS bit
|
|
1100 NewRxFlo ldx <V.PORT
|
|
1101 stb <Cpy.FR save Format register copy
|
|
1102 stb CFReg,x set/clear DTR and RTS in Format register
|
|
1103 lda <Wrk.Type
|
|
1104 bita #RxSwFlow Rx data software flow control enabled?
|
|
1105 beq SgnlRxD no, go check Rx data signal...
|
|
1106 lda <V.XOFF XOFF character defined?
|
|
1107 beq SgnlRxD no, go check Rx data signal...
|
|
1108 ldb <FloCtlRx get Rx flow control flags
|
|
1109 bitb #FCRxSent XOFF already sent?
|
|
1110 bne SgnlRxD yes, go check Rx data signal...
|
|
1111 orb #FCRxSend set send XOFF flag
|
|
1112 stb <FloCtlRx set new Rx flow control flags
|
|
1113 ldb <Cpy.CSR get Control status register copy
|
|
1114 bitb #CS.TxE Tx data register empty?
|
|
1115 beq SgnlRxD no, go skip XOFF this time...
|
|
1116 sta DataReg,x write XOFF character
|
|
1117 ldb #FCRxSent set XOFF sent flag
|
|
1118 orb <FloCtlRx mask in current Rx flow control flags
|
|
1119 andb #^FCRxSend clear send XOFF flag
|
|
1120 stb <FloCtlRx save new flow control flags
|
|
1121 SgnlRxD ldb <SigSent already sent abort/interrupt signal?
|
|
1122 bne ChkTrDCD yes, go check DCD transition...
|
|
1123 lda <SSigPID Rx data signal process ID?
|
|
1124 beq ChkTrDCD none, go check DCD transition...
|
|
1125 ldb <SSigSig Rx data signal code
|
|
1126 clr <SSigPID clear Rx data signal
|
|
1127 os9 F$Send
|
|
1128
|
|
1129 ChkTrDCD ldd <Cpy.ISR get IRQ and Control Status copies
|
|
1130 bita #ISE.DCD DCD transition?
|
|
1131 beq CkSuspnd no, go check for suspended process...
|
|
1132 bitb #CS.DCD DCD disabled now?
|
|
1133 beq SgnlDCD no, go check DCD signal...
|
|
1134 lda <Wrk.Type
|
|
1135 bita #MdmKill modem kill enabled?
|
|
1136 beq SgnlDCD no, go on...
|
|
1137 ldx <V.PDLHd path descriptor list header
|
|
1138 beq StCDLost no list, go set DCD lost error...
|
|
1139 lda #PST.DCD DCD lost flag
|
|
1140 PDListLp sta PD.PST,x set path status flag
|
|
1141 ldx PD.PLP,x get next path descriptor in list
|
|
1142 bne PDListLp not end of list, go do another...
|
|
1143 StCDLost lda #DCDLstEr DCD lost error flag
|
|
1144 lbsr AccumErr go save accumulated errors...
|
|
1145 SgnlDCD lda <CDSigPID get process ID, send a DCD signal?
|
|
1146 beq CkSuspnd no, go check for suspended process...
|
|
1147 ldb <CDSigSig get DCD signal code
|
|
1148 clr <CDSigPID clear DCD signal
|
|
1149 os9 F$Send
|
|
1150
|
|
1151 CkSuspnd clrb clear Carry (for exit) and LSB of process descriptor address
|
|
1152 lda <V.WAKE anybody waiting? ([D]=process descriptor address)
|
|
1153 beq IRQExit no, go return...
|
|
1154 stb <V.WAKE mark I/O done
|
|
1155 tfr d,x copy process descriptor pointer
|
|
1156 lda P$State,x get state flags
|
|
1157 anda #^Suspend clear suspend state
|
|
1158 sta P$State,x save state flags
|
|
1159 IRQExit puls dp,pc recover system DP, return...
|
|
1160 else
|
|
1161
|
|
1162 ifeq A6551-true
|
|
1163 IRQSvc equ *
|
|
1164 pshs dp save system DP
|
|
1165 bsr SetDP go set our DP
|
|
1166 ldx <V.PORT
|
|
1167 ldb StatReg,x get current Status register contents
|
|
1168 stb <Cpy.Stat save Status register copy
|
|
1169 bitb #Stat.Err error(s)?
|
|
1170 beq ChkRDRF no, go check Rx data
|
|
1171 tst DataReg,x read Rx data register to clear ACIA error flags
|
|
1172 bitb #Stat.Frm framing error (assume Rx line Break)?
|
|
1173 beq ChkParty no, go check if parity error...
|
|
1174 lda <V.QUIT default to keyboard quit ("Break") code
|
|
1175 bra RxBreak go pretend we've received V.QUIT character...
|
|
1176
|
|
1177 ChkParty clra clear old IRQ status
|
|
1178 bitb #Stat.Par parity error?
|
|
1179 beq ChkOvRun no, go check overrun error...
|
|
1180 ora #ParityEr mark parity error
|
|
1181 ChkOvRun bita #Stat.Ovr overrun error?
|
|
1182 beq SaveErrs no, go save errors...
|
|
1183 ora #OvrFloEr mark overrun error
|
|
1184 SaveErrs bsr AccumErr go save accumulated errors...
|
|
1185 lbra ChkTrDCD go check if DCD transition...
|
|
1186
|
|
1187 ChkRDRF bitb #Stat.RxF Rx data?
|
|
1188 lbeq ChkTrDCD no, go check DCD transition
|
|
1189 lda DataReg,x get Rx data
|
|
1190 RxBreak beq SavRxDat its a null, go save it...
|
|
1191 clr <SigSent clear signal sent flag
|
|
1192 cmpa <V.INTR interrupt?
|
|
1193 bne Chk.Quit no, go on...
|
|
1194 ldb #S$Intrpt
|
|
1195 bra SendSig
|
|
1196 Chk.Quit cmpa <V.QUIT abort?
|
|
1197 bne Chk.PChr no, go on...
|
|
1198 ldb #S$Abort
|
|
1199 SendSig pshs a save Rx data
|
|
1200 lda <V.LPRC get last process' ID
|
|
1201 os9 F$Send
|
|
1202 puls a recover Rx data
|
|
1203 stb <SigSent set signal sent flag
|
|
1204 bra SavRxDat go save Rx data...
|
|
1205 Chk.PChr cmpa <V.PCHR pause?
|
|
1206 bne Chk.Flow no, go on...
|
|
1207 ldx <V.DEV2 attached device defined?
|
|
1208 beq SavRxDat no, go save Rx data...
|
|
1209 sta V.PAUS,x yes, pause attached device
|
|
1210 bra SavRxDat go save Rx data...
|
|
1211 Chk.Flow ldb <Wrk.Type
|
|
1212 bitb #TxSwFlow Tx data software flow control enabled?
|
|
1213 beq SavRxDat no, go save Rx data...
|
|
1214 cmpa <V.XON XON?
|
|
1215 bne Chk.XOff no, go on...
|
|
1216 ldb #^FCTxXOff clear XOFF received bit
|
|
1217 andb <FloCtlTx clear software Tx flow control flag
|
|
1218 bra SetTxFlo go save new Tx flow control flags...
|
|
1219 Chk.XOff cmpa <V.XOFF XOFF?
|
|
1220 bne SavRxDat no, go save Rx data...
|
|
1221 ldb #FCTxXOff set XOFF received bit
|
|
1222 orb <FloCtlTx set software Tx flow control flag
|
|
1223 SetTxFlo stb <FloCtlTx save new Tx flow control flags
|
|
1224 lbra ChkTrDCD go check DCD transition...
|
|
1225 SavRxDat ldb <FloCtlRx get Rx flow control flags
|
|
1226 andb #^FCRxSend clear possible pending XOFF flag
|
|
1227 stb <FloCtlRx save Rx flow control flags
|
|
1228 ldy <RxBufPut get Rx buffer input pointer
|
|
1229 ldx <RxDatLen Rx get Rx buffer data length
|
|
1230 cmpx <RxBufSiz Rx buffer already full?
|
|
1231 blo NotOvFlo no, go skip overflow error...
|
|
1232 lda #OvrFloEr mark Rx buffer overflow
|
|
1233 lbsr AccumErr go save accumulated errors...
|
|
1234 bra DisRxFlo go ensure Rx is disabled (if possible)
|
|
1235 NotOvFlo sta ,y+ save Rx data
|
|
1236 cmpy <RxBufEnd end of Rx buffer?
|
|
1237 blo SetLayDn no, go keep laydown pointer
|
|
1238 ldy <RxBufPtr get Rx buffer start address
|
|
1239 SetLayDn sty <RxBufPut set new Rx data laydown pointer
|
|
1240 leax 1,x one more byte in Rx buffer
|
|
1241 stx <RxDatLen save new Rx data length
|
|
1242 cmpx <RxBufMax at or past maximum fill point?
|
|
1243 blo SgnlRxD no, go check Rx data signal...
|
|
1244 DisRxFlo ldx <V.PORT
|
|
1245 lda <Wrk.XTyp
|
|
1246 ldb CmdReg,x get current Command register contents
|
|
1247 bita #ForceDTR forced DTR?
|
|
1248 bne DisRxRTS yes, go check RTS disable...
|
|
1249 lda <Wrk.Type
|
|
1250 bita #DSRFlow DSR/DTR flow control enabled?
|
|
1251 beq DisRxRTS no, go check RTS disable
|
|
1252 lda <FloCtlRx get Rx flow control flags
|
|
1253 ora #FCRxDTR mark Rx disabled by DTR
|
|
1254 sta <FloCtlRx save new Rx flow control flags
|
|
1255 andb #^Cmd.DTR clear (disable) DTR bit
|
|
1256 DisRxRTS lda <Wrk.Type
|
|
1257 bita #RTSFlow CTS/RTS flow control enabled?
|
|
1258 beq NewRxFlo no, go set new Rx flow control...
|
|
1259 lda <FloCtlTx get Tx flow control flags
|
|
1260 bita #FCTxBrk currently transmitting line Break?
|
|
1261 bne NewRxFlo yes, go set new Rx flow control...
|
|
1262 lda <FloCtlRx get Rx flow control flags
|
|
1263 ora #FCRxRTS mark Rx disabled by RTS
|
|
1264 sta <FloCtlRx save new Rx flow control flags
|
|
1265 andb #^Cmd.TIRB clear Tx IRQ/RTS/Break control bits (disable RTS)
|
|
1266 NewRxFlo stb CmdReg,x set/clear DTR and RTS in Command register
|
|
1267 lda <Wrk.Type
|
|
1268 bita #RxSwFlow Rx software flow control enabled?
|
|
1269 beq SgnlRxD no, go check Rx data signal...
|
|
1270 lda <V.XOFF XOFF character defined?
|
|
1271 beq SgnlRxD no, go check Rx data signal...
|
|
1272 ldb <FloCtlRx get Rx flow control flags
|
|
1273 bitb #FCRxSent XOFF already sent?
|
|
1274 bne SgnlRxD yes, go check Rx data signal...
|
|
1275 orb #FCRxSend set send XOFF flag
|
|
1276 stb <FloCtlRx set new Rx flow control flags
|
|
1277 ldb StatReg,x get new Status register
|
|
1278 bitb #Stat.TxE Tx data register empty?
|
|
1279 beq SgnlRxD no, go skip XOFF this time...
|
|
1280 sta DataReg,x write XOFF character
|
|
1281 ldb #FCRxSent set XOFF sent flag
|
|
1282 orb <FloCtlRx mask in current Rx flow control flags
|
|
1283 andb #^FCRxSend clear send XOFF flag
|
|
1284 stb <FloCtlRx save new flow control flags
|
|
1285 SgnlRxD ldb <SigSent already sent abort/interrupt signal?
|
|
1286 bne ChkTrDCD yes, go check DCD transition...
|
|
1287 lda <SSigPID Rx data signal process ID?
|
|
1288 beq ChkTrDCD none, go check DCD transition...
|
|
1289 ldb <SSigSig Rx data signal code
|
|
1290 clr <SSigPID clear Rx data signal
|
|
1291 os9 F$Send
|
|
1292
|
|
1293 ChkTrDCD ldx <V.PORT
|
|
1294 lda <Cpy.Stat get Status register copy
|
|
1295 tfr a,b copy it...
|
|
1296 eora <CpyDCDSR mark changes from old DSR+DCD status copy
|
|
1297 andb #Stat.DSR!Stat.DCD clear all but DSR+DCD status
|
|
1298 stb <CpyDCDSR save new DSR+DCD status copy
|
|
1299 bita <Mask.DCD DCD transition?
|
|
1300 beq CkSuspnd no, go check for suspended process...
|
|
1301 bitb <Mask.DCD DCD disabled now?
|
|
1302 beq SgnlDCD no, go check DCD signal...
|
|
1303 lda <Wrk.Type
|
|
1304 bita #MdmKill modem kill enabled?
|
|
1305 beq SgnlDCD no, go on...
|
|
1306 ldx <V.PDLHd path descriptor list header
|
|
1307 beq StCDLost no list, go set DCD lost error...
|
|
1308 lda #PST.DCD DCD lost flag
|
|
1309 PDListLp sta PD.PST,x set path status flag
|
|
1310 ldx PD.PLP,x get next path descriptor in list
|
|
1311 bne PDListLp not end of list, go do another...
|
|
1312 StCDLost lda #DCDLstEr DCD lost error flag
|
|
1313 lbsr AccumErr go save accumulated errors...
|
|
1314 SgnlDCD lda <CDSigPID get process ID, send a DCD signal?
|
|
1315 beq CkSuspnd no, go check for suspended process...
|
|
1316 ldb <CDSigSig get DCD signal code
|
|
1317 clr <CDSigPID clear DCD signal
|
|
1318 os9 F$Send
|
|
1319
|
|
1320 CkSuspnd clrb clear Carry (for exit) and LSB of process descriptor address
|
|
1321 lda <V.WAKE anybody waiting? ([D]=process descriptor address)
|
|
1322 beq IRQExit no, go return...
|
|
1323 stb <V.WAKE mark I/O done
|
|
1324 tfr d,x copy process descriptor pointer
|
|
1325 lda P$State,x get state flags
|
|
1326 anda #^Suspend clear suspend state
|
|
1327 sta P$State,x save state flags
|
|
1328 IRQExit puls dp,pc recover system DP, return...
|
|
1329 endc
|
|
1330 endc
|
|
1331
|
|
1332
|
|
1333 emod
|
|
1334 ModSize equ *
|
|
1335 end
|
|
1336
|