3 ; Interrupt drivers for ASCI0 and ASCI1
8 extrn ff_empty,ff_get,ff_full,ff_put
9 extrn ff_puth,ff_cnt,ff_gech
11 extrn isv_sw,ijphl,add_hla,div32_r
22 m2b mbxon_bit,mb$xon$xoff
24 ;-----------------------------------------------------
34 db 0 ;absolute device #
47 oint.iflags equ as0_dev+o.iflags-s0.inbuf
48 oint.fflags equ as0_dev+o.fflags-s0.inbuf
49 mkbuf s0.rx_id, s0.inbuf, s0.rx_len
50 mkbuf s0.tx_id, s0.outbuf,s0.tx_len
59 db 0 ;absolute device #
67 mkbuf s1.rx_id, s1.inbuf, s1.rx_len
68 mkbuf s1.tx_id, s1.outbuf,s1.tx_len
76 dw func_tcinit ;(00h) CP/M 3 DEVINI function
77 dw func_tcgeta ;(01h) Get the current serial port settings.
78 dw func_tcseta ;(02h) Set the current serial port settings.
79 dw func_tcsetaw ;(03h) Allow the output buffer to drain
80 dw func_tcsetaf ;(04h) Allow the output buffer to drain, discard pending input
81 dw func_tcsbrk ;(05h) Sending a break (250ms .. 500ms)
82 dw func_tcsbrkp ;(06h) arg is timeinterval in 0.1sec
83 dw func_tiocsbrk ;(07h) Turn break on
84 dw func_tioccbrk ;(08h) Turn break off
85 dw func_tcxonc ;(09h) Software flow control (TCOOFF, TCOON, TCIOFF, TCION)
86 dw func_tcflsh ;(0Ah) Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)
87 dw func_fionread ;(0Bh) Get the number of bytes in the input buffer.
88 dw func_tiocoutq ;(0Ch) Get the number of bytes in the output buffer.
89 dw func_tiocmget ;(0Dh) get the status of modem bits.
90 dw func_tiocmbis ;(0Eh) set the indicated modem bits.
91 dw func_tiocmbic ;(0Fh) clear the indicated modem bits.
92 dw func_tiocmset ;(10h) set the status of modem bits.
93 dw func_tiocgsoftcar ;(11h) Get the status of the CLOCAL flag in the c_cflag field
94 dw func_tiocssoftcar ;(12h) Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.
96 IOCTL_MAX equ ($-ioctl_ftab)/2
100 ;--------------------------------------------------------------
104 ; de: ioctl arg pointer
105 ; hl: ptr to driver local data
129 ;--------------------------------------------------------------
130 ; CP/M 3 DEVINI function
131 ; Init Serial I/O for input and output (ASCI 0/1)
137 ld c,asext0 ;Enable baud rate generator
138 ld a,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS +M_BREAKEN
139 bit CCTS_OFLOW,(ix+o.fflags)
149 ld a,(hl) ;get baudrate index
160 ld a,M_MPBT ;No MP Mode, X16
161 bit PARODD,(ix+o.iflags)
172 or a,M_RE+M_TE+M_RTS0+M_EFR ;Rx/Tx enable
178 ld hl,rtxisvjmp0 ;rx/tx int vector
179 ld (ivtab + IV$ASCI0),hl ;
185 ld hl,rtxisvjmp1 ;rx/tx int vector
186 ld (ivtab + IV$ASCI1),hl ;
196 ;--------------------------------------------------------------
209 ;--------------------------------------------------------------
210 ; Get the current serial port settings.
230 ld a,(hl) ;get baudrate index
244 ;--------------------------------------------------------------
245 ; Set the current serial port settings.
270 ld (hl),a ;set baudrate index
281 ;--------------------------------------------------------------
282 ; Allow the output buffer to drain
286 ;--------------------------------------------------------------
287 ; Allow the output buffer to drain, discard pending input
291 ;--------------------------------------------------------------
292 ; Sending a break (250ms .. 500ms)
296 ;--------------------------------------------------------------
297 ; arg is timeinterval in 0.1sec
301 ;--------------------------------------------------------------
306 ;--------------------------------------------------------------
311 ;--------------------------------------------------------------
312 ; Software flow control (TCOOFF, TCOON, TCIOFF, TCION)
316 ;--------------------------------------------------------------
317 ; Flush input/output buffer (TCIFLUSH, TCOFLUSH, TCIOFLUSH)
321 ;--------------------------------------------------------------
322 ; Get the number of bytes in the input buffer.
326 ;--------------------------------------------------------------
327 ; Get the number of bytes in the output buffer.
331 ;--------------------------------------------------------------
332 ; get the status of modem bits.
336 ;--------------------------------------------------------------
337 ; set the indicated modem bits.
341 ;--------------------------------------------------------------
342 ; clear the indicated modem bits.
346 ;--------------------------------------------------------------
347 ; set the status of modem bits.
351 ;--------------------------------------------------------------
352 ; Get the status of the CLOCAL flag in the c_cflag field
356 ;--------------------------------------------------------------
357 ; Set the CLOCAL flag when *argp is nonzero, and clear it otherwise.
364 ;--------------------------------------------------------------
367 ld c,stat0 ;Disable rx/tx interrupts
371 ld c,cntla0 ;Disable receiver and transmitter
372 ld a,M_RTS0+M_EFR ;RTS/CKA1
375 ;--------------------------------------------------------------
382 ;--------------------------------------------------------------
383 ; output to asci0/1 register
385 ; c: register address
393 cp astc0l ;astc0/1 are 16 bit
404 ;--------------------------------------------------------------
436 ; factor index baudrate orig. cp/m
437 dw 19200/150 ; 0 19200 -
438 dw 28800/150 ; 1 28800 50
439 dw 38400/150 ; 2 38400 75
440 dw 57600/150 ; 3 57600 110
441 dw 11520/15 ; 4 115200 134.5
452 dw 19200/150 ;15 19200
455 ;--------------------------------------------------------------
460 db 1,stat0,0 ;Disable rx/tx interrupts
461 ;Enable baud rate generator
462 db 1,asext0,M_BRGMOD+M_DCD0DIS ; +M_CTS0DIS
464 init_br_off equ $ - initab0
466 db 1,cntlb0,M_MPBT ;No MP Mode, X16
467 db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
471 db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
472 db 1,asext1,M_BRGMOD ;Enable baud rate generator
473 db 2,astc1l,low 3, high 3
474 db 1,cntlb1,M_MPBT ;No MP Mode, X16
475 db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
479 ;--------------------------------------------------------------
489 ;--------------------------------------------------------------
498 ;--------------------------------------------------------------
499 ; Get an input character
510 and ~M_RTS0 ;assert RTS
511 or M_EFR ;don't reset error flags
519 ;--------------------------------------------------------------
520 ; Get an input character
529 ;--------------------------------------------------------------
539 ;--------------------------------------------------------------
549 ;--------------------------------------------------------------
550 ; put character in c in buffer
552 ; returns output char in a
566 ;--------------------------------------------------------------
567 ; put character in c in buffer
569 ; returns output char in a
584 ;--------------------------------------------------------------
594 ;--------------------------------------------------------------
595 ; ASCI 0 Transmit/Receive interupt routines
603 in0 a,(stat0) ;receive flag set?
604 jp p,rxtxi0_1 ;RDRF == Bit 7
605 and M_OVRN+M_PERR+M_FE
625 ;todo: break detection
626 ;todo: parity, framing overrun error
629 ld e,(ix+oint.fflags)
638 ld a,c ;increment buffer in pointer
645 jr z,rxtxi0_lp1 ;skip if buffer is full
659 set RTS0,d ;RTS inactive
679 ld a,(ix+o.out_idx) ;
680 cp (ix+o.in_idx) ;if index.in == index.out
681 jr z,?0ti_2 ; buffer empty
696 res TIE,e ;disable tx-int
704 ;--------------------------------------------------------------
705 ; ASCI 1 Transmit/Receive interupt routines
709 in0 e,(stat1) ;receive flag set? 5
712 in0 d,(rdr1) ;todo: break detection 9
713 bit FE,e ;framing error?
728 jr z,$+5 ;skip if buffer is full
741 ld a,(ix+o.out_idx) ;
742 cp (ix+o.in_idx) ;if index.in == index.out
743 jr z,??ti_2 ; buffer empty
757 res TIE,e ;disable tx-int