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