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 #
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
167 ld a,M_MPBT ;No MP Mode, X16
168 bit PARODD,(ix+o.iflags)
179 or a,M_RE+M_TE+M_RTS0+M_EFR ;Rx/Tx enable
185 ld hl,rtxisvjmp0 ;rx/tx int vector
186 ld (ivtab + IV$ASCI0),hl ;
192 ld hl,rtxisvjmp1 ;rx/tx int vector
193 ld (ivtab + IV$ASCI1),hl ;
203 ;--------------------------------------------------------------
216 ;--------------------------------------------------------------
217 ; Get the current serial port settings.
237 ld a,(hl) ;get baudrate index
251 ;--------------------------------------------------------------
252 ; Set the current serial port settings.
277 ld (hl),a ;set baudrate index
288 ;--------------------------------------------------------------
289 ; Allow the output buffer to drain
293 ;--------------------------------------------------------------
294 ; Allow the output buffer to drain, discard pending input
298 ;--------------------------------------------------------------
299 ; Sending a break (250ms .. 500ms)
303 ;--------------------------------------------------------------
304 ; arg is timeinterval in 0.1sec
308 ;--------------------------------------------------------------
313 ;--------------------------------------------------------------
318 ;--------------------------------------------------------------
319 ; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)
323 ;--------------------------------------------------------------
324 ; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)
328 ;--------------------------------------------------------------
329 ; Get the number of bytes in the input buffer.
333 ;--------------------------------------------------------------
334 ; Get the number of bytes in the output buffer.
338 ;--------------------------------------------------------------
339 ; get the status of modem bits.
343 ;--------------------------------------------------------------
344 ; set the indicated modem bits.
348 ;--------------------------------------------------------------
349 ; clear the indicated modem bits.
353 ;--------------------------------------------------------------
354 ; set the status of modem bits.
358 ;--------------------------------------------------------------
359 ; Get the status of the CLOCAL flag in the c_cflag field
363 ;--------------------------------------------------------------
364 ; Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.
371 ;--------------------------------------------------------------
374 ld c,stat0 ;Disable rx/tx interrupts
378 ld c,cntla0 ;Disable receiver and transmitter
379 ld a,M_RTS0+M_EFR ;RTS/CKA1
382 ;--------------------------------------------------------------
389 ;--------------------------------------------------------------
390 ; output to asci0/1 register
392 ; c: register address
400 cp astc0l ;astc0/1 are 16 bit
411 ;--------------------------------------------------------------
443 ; factor index baudrate orig. cp/m
444 dw 19200/150 ; 0 19200 -
445 dw 28800/150 ; 1 28800 50
446 dw 38400/150 ; 2 38400 75
447 dw 57600/150 ; 3 57600 110
448 dw 11520/15 ; 4 115200 134.5
459 dw 19200/150 ;15 19200
462 ;--------------------------------------------------------------
467 db 1,stat0,0 ;Disable rx/tx interrupts
468 ;Enable baud rate generator
469 db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS
471 init_br_off equ $ - initab0
473 db 1,cntlb0,M_MPBT ;No MP Mode, X16
474 db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
478 db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
479 db 1,asext1,M_BRGMOD ;Enable baud rate generator
480 db 2,astc1l,low 3, high 3
481 db 1,cntlb1,M_MPBT ;No MP Mode, X16
482 db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
486 ;--------------------------------------------------------------
496 ;--------------------------------------------------------------
505 ;--------------------------------------------------------------
506 ; Get an input character
517 and ~M_RTS0 ;assert RTS
518 or M_EFR ;don't reset error flags
526 ;--------------------------------------------------------------
527 ; Get an input character
536 ;--------------------------------------------------------------
546 ;--------------------------------------------------------------
556 ;--------------------------------------------------------------
557 ; put character in c in buffer
559 ; returns output char in a
573 ;--------------------------------------------------------------
574 ; put character in c in buffer
576 ; returns output char in a
591 ;--------------------------------------------------------------
601 ;--------------------------------------------------------------
602 ; ASCI 0 Transmit/Receive interupt routines
610 in0 a,(stat0) ;receive flag set?
611 jp p,rxtxi0_1 ;RDRF == Bit 7
612 and M_OVRN+M_PERR+M_FE
632 ;todo: break detection
633 ;todo: parity, framing overrun error
636 ld e,(ix+oint.fflags)
645 ld a,c ;increment buffer in pointer
652 jr z,rxtxi0_lp1 ;skip if buffer is full
666 set RTS0,d ;RTS inactive
686 ld a,(ix+o.out_idx) ;
687 cp (ix+o.in_idx) ;if index.in == index.out
688 jr z,?0ti_2 ; buffer empty
703 res TIE,e ;disable tx-int
711 ;--------------------------------------------------------------
712 ; ASCI 1 Transmit/Receive interupt routines
716 in0 e,(stat1) ;receive flag set? 5
719 in0 d,(rdr1) ;todo: break detection 9
720 bit FE,e ;framing error?
735 jr z,$+5 ;skip if buffer is full
748 ld a,(ix+o.out_idx) ;
749 cp (ix+o.in_idx) ;if index.in == index.out
750 jr z,??ti_2 ; buffer empty
764 res TIE,e ;disable tx-int