2 ; Interrupt drivers for ASCI0 and ASCI1
7 extrn ff_empty,ff_get,ff_full,ff_put
8 extrn ff_puth,ff_cnt,ff_gech
10 extrn isv_sw,ijphl,add_hla,div32_r
21 m2b mbxon_bit,mb$xon$xoff
23 ;-----------------------------------------------------
33 db 0 ;absolute device #
36 db M_CREAD+M_CRTS_IFLOW+M_CCTS_OFLOW ;fflags
46 oint.iflags equ as0_dev+o.iflags-s0.inbuf
47 oint.fflags equ as0_dev+o.fflags-s0.inbuf
48 mkbuf s0.rx_id, s0.inbuf, s0.rx_len
49 mkbuf s0.tx_id, s0.outbuf,s0.tx_len
58 db 0 ;absolute device #
66 mkbuf s1.rx_id, s1.inbuf, s1.rx_len
67 mkbuf s1.tx_id, s1.outbuf,s1.tx_len
75 dw func_tcinit ;(00h) CP/M 3 DEVINI function
76 dw func_tcgeta ;(01h) Get the current serial port settings.
77 dw func_tcseta ;(02h) Set the current serial port settings.
78 dw func_tcsetaw ;(03h) Allow the output buffer to drain
79 dw func_tcsetaf ;(04h) Allow the output buffer to drain, discard pending input
80 dw func_tcsbrk ;(05h) Sending a break (250ms .. 500ms)
81 dw func_tcsbrkp ;(06h) arg is timeinterval in 0.1sec
82 dw func_tiocsbrk ;(07h) Turn break on
83 dw func_tioccbrk ;(08h) Turn break off
84 dw func_tcxonc ;(09h) Software flow control (TCOOFF, TCOON, TCIOFF, TCION)
85 dw func_tcflsh ;(0Ah) Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)
86 dw func_fionread ;(0Bh) Get the number of bytes in the input buffer.
87 dw func_tiocoutq ;(0Ch) Get the number of bytes in the output buffer.
88 dw func_tiocmget ;(0Dh) get the status of modem bits.
89 dw func_tiocmbis ;(0Eh) set the indicated modem bits.
90 dw func_tiocmbic ;(0Fh) clear the indicated modem bits.
91 dw func_tiocmset ;(10h) set the status of modem bits.
92 dw func_tiocgsoftcar ;(11h) Get the status of the CLOCAL flag in the c_cflag field
93 dw func_tiocssoftcar ;(12h) Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.
95 IOCTL_MAX equ ($-ioctl_ftab)/2
99 ;--------------------------------------------------------------
103 ; de: ioctl arg pointer
104 ; hl: ptr to driver local data
136 ;--------------------------------------------------------------
137 ; CP/M 3 DEVINI function
138 ; Init Serial I/O for input and output (ASCI 0/1)
144 ld c,asext0 ;Enable baud rate generator
145 ld a,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS +M_BREAKEN
146 bit CCTS_OFLOW,(ix+o.fflags)
156 ld a,(hl) ;get baudrate index
162 ld a,M_MPBT ;No MP Mode, X16
163 bit PARODD,(ix+o.iflags)
174 or a,M_RE+M_TE+M_RTS0+M_EFR ;Rx/Tx enable
180 ld hl,rtxisvjmp0 ;rx/tx int vector
181 ld (ivtab + IV$ASCI0),hl ;
187 ld hl,rtxisvjmp1 ;rx/tx int vector
188 ld (ivtab + IV$ASCI1),hl ;
198 ;--------------------------------------------------------------
211 ;--------------------------------------------------------------
212 ; Get the current serial port settings.
229 ld a,(hl) ;get baudrate index
241 ;--------------------------------------------------------------
242 ; Set the current serial port settings.
264 ld (hl),a ;set baudrate index
273 ;--------------------------------------------------------------
274 ; Allow the output buffer to drain
278 ;--------------------------------------------------------------
279 ; Allow the output buffer to drain, discard pending input
283 ;--------------------------------------------------------------
284 ; Sending a break (250ms .. 500ms)
288 ;--------------------------------------------------------------
289 ; arg is timeinterval in 0.1sec
293 ;--------------------------------------------------------------
298 ;--------------------------------------------------------------
303 ;--------------------------------------------------------------
304 ; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)
308 ;--------------------------------------------------------------
309 ; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)
313 ;--------------------------------------------------------------
314 ; Get the number of bytes in the input buffer.
318 ;--------------------------------------------------------------
319 ; Get the number of bytes in the output buffer.
323 ;--------------------------------------------------------------
324 ; get the status of modem bits.
328 ;--------------------------------------------------------------
329 ; set the indicated modem bits.
333 ;--------------------------------------------------------------
334 ; clear the indicated modem bits.
338 ;--------------------------------------------------------------
339 ; set the status of modem bits.
343 ;--------------------------------------------------------------
344 ; Get the status of the CLOCAL flag in the c_cflag field
348 ;--------------------------------------------------------------
349 ; Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.
356 ;--------------------------------------------------------------
366 ;--------------------------------------------------------------
369 ld c,stat0 ;Disable rx/tx interrupts
373 ld c,cntla0 ;Disable receiver and transmitter
374 ld a,M_RTS0+M_EFR ;RTS/CKA1
377 ;--------------------------------------------------------------
383 and ~M_RTS0 ;Activate RTS
391 ;--------------------------------------------------------------
392 ; output to asci0/1 register
394 ; c: register address
408 ;--------------------------------------------------------------
409 ; output 16 bit value to asci0/1 register
411 ; c: register address
428 ;--------------------------------------------------------------
460 ; factor index baudrate orig. cp/m
461 dw 19200/150 ; 0 19200 -
462 dw 28800/150 ; 1 28800 50
463 dw 38400/150 ; 2 38400 75
464 dw 57600/150 ; 3 57600 110
465 dw 11520/15 ; 4 115200 134.5
476 dw 19200/150 ;15 19200
479 ;--------------------------------------------------------------
484 db 1,stat0,0 ;Disable rx/tx interrupts
485 ;Enable baud rate generator
486 db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS
488 init_br_off equ $ - initab0
490 db 1,cntlb0,M_MPBT ;No MP Mode, X16
491 db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
495 db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
496 db 1,asext1,M_BRGMOD ;Enable baud rate generator
497 db 2,astc1l,low 3, high 3
498 db 1,cntlb1,M_MPBT ;No MP Mode, X16
499 db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
503 ;--------------------------------------------------------------
513 ;--------------------------------------------------------------
522 ;--------------------------------------------------------------
523 ; Get an input character
552 bit CRTS_IFLOW,(ix+oint.fflags)
556 and ~M_RTS0 ;assert RTS
557 or M_EFR ;don't reset error flags
565 ;--------------------------------------------------------------
566 ; Get an input character
575 ;--------------------------------------------------------------
585 ;--------------------------------------------------------------
595 ;--------------------------------------------------------------
596 ; put character in c in buffer
598 ; returns output char in a
612 ;--------------------------------------------------------------
613 ; put character in c in buffer
615 ; returns output char in a
630 ;--------------------------------------------------------------
641 ;--------------------------------------------------------------
642 ; ASCI 0/1 Transmit/Receive interupt routines
652 in0 a,(stat&dev) ;receive flag set?
653 jp p,txi&dev ;RDRF == Bit 7
654 and M_OVRN+M_PERR+M_FE
673 ;todo: break detection
674 ;todo: parity, framing overrun error
676 ld e,(ix+oint.fflags)
683 ld a,c ;increment buffer in pointer
690 jr z,rxtxi&dev&_lp1 ;skip if buffer is full
705 set RTS0,d ;RTS inactive
725 ld hl,s&dev&.outbuf+o.in_idx ;[in]
730 jr z,txi&dev&_empty ;
737 ld a,(s&dev&.outbuf+o.mask) ;
739 ld (s&dev&.outbuf+o.out_idx),a ;
744 res TIE,e ;disable tx-int
745 out0 (stat&dev),e ; 5
753 ;--------------------------------------------------------------
754 ; ASCI 0 Transmit/Receive interupt routines
759 ;--------------------------------------------------------------
760 ; ASCI 1 Transmit/Receive interupt routines