z80sio: Fix a bug in the linc80 logic and add macros for non fixed common cases
authorAlan Cox <alan@linux.intel.com>
Sat, 9 Mar 2019 19:41:58 +0000 (19:41 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 9 Mar 2019 19:41:58 +0000 (19:41 +0000)
Kernel/dev/z80sio.s
Kernel/platform-linc80/devtty.c
Kernel/platform-linc80/linc80.s

index 458c60a..8eef01e 100644 (file)
@@ -20,7 +20,7 @@ sio'X'_rx:
 sio'X'_tx:
        .ds     128
 
-       .area _COMMONMEM
+       .area _SERIALDATA
 sio'X'_error:
        .db     0
 sio'X'_rxover:
@@ -54,6 +54,7 @@ sio'X'_rxe:
 ;
 sio'X'_txd:
        push af
+       switch
        ld a,(_sio'X'_txl)
        or a
        jr z, tx_'X'_none
@@ -70,6 +71,7 @@ sio'X'_txd:
 tx_'X'_none:
        ld a,#0x28
        out (CP),a              ; silence tx interrupt
+       switchback
        pop af
        ei
        RET
@@ -79,6 +81,7 @@ tx_'X'_none:
 sio'X'_rx_ring:
        push af
        push hl
+       switch
 sio'X'_rx_next:
        in a,(DP)               ; read ASAP
        ld l,a
@@ -106,6 +109,7 @@ sio'X'_rx_next:
        in a,(CP)               ; RR 0
        rra
        jr c, sio'X'_rx_next
+       switchback
        pop hl
        pop af
        ei
@@ -114,6 +118,8 @@ sio'X'_rx_next:
        ld a,(sio'X'_error)
        or #0x20                ; Fake an RX overflow bit
        ld (sio'X'_rxover),a
+       switchback
+       pop hl
        pop af
        ei
        RET
@@ -124,6 +130,7 @@ sio'X'_status:
        ; CTS or DCD change
        push af
        push hl
+       switch
        ; RR0
        in a,(CP)
        ld (_sio'X'_state),a
@@ -135,6 +142,7 @@ no_dcd_drop_'X':
        ; Clear the latched values
        ld a,#0x10
        out (CP),a
+       switchback
        pop hl
        pop af
        ei
@@ -147,6 +155,7 @@ sio'X'_special:
        ; Parity, RX Overrun, Framing
        ; Probably want to record them, but we at least must clean up
        push af
+       switch
        ld a,#1
        out (CP),a              ; RR1 please
        in a,(CP)               ; clear events
@@ -154,6 +163,7 @@ sio'X'_special:
        ; Clear the latched values
        ld a,#0x30
        out (CP),a
+       switchback
        pop af
        ei
        RET
@@ -168,6 +178,7 @@ sio'X'_special:
 ;      128 byte ring buffer aligned to upper half (rx is in lower)
 ;
 _sio'X'_txqueue:
+       switch
        ld a,(_sio'X'_txl)
        or a
        jr z, sio'X'_direct_maybe       ; if can tx now then do
@@ -182,10 +193,12 @@ sio'X'_queue:
        set 7,l
        ld (sio'X'_txe),hl
        ld l,#0
+       switchback
        ret
 tx'X'_overflow:
        ; some kind of flag for error
        ld l,#1
+       switchback
        ret
 sio'X'_direct_maybe:
        ; check RR
@@ -197,18 +210,19 @@ sio'X'_direct_maybe:
        ; bypass the queue and kickstart the interrupt machine
        ld a,l
        out (DP),a
+       switchback
        ld l,#0
        ret
        ; Call with DI
 
-_sio'X'_flow_control_off:
+sio'X'_flow_control_off:
        ld a,#5
        out(CP),a               ; WR 5
        ld a,(_sio'X'_wr5)
        out (CP),a              ; Turn off RTS
        ret
 
-_sio'X'_flow_control_on:
+sio'X'_flow_control_on:
        ld a,#5
        out(CP),a               ; WR 5
        ld a,(_sio'X'_wr5)
@@ -216,12 +230,25 @@ _sio'X'_flow_control_on:
        out (CP),a              ; Turn off RTS
        ret
 
+_sio'X'_flow_control_off:
+       switch
+       call sio'X'_flow_control_off
+       switchback
+       ret
+
+_sio'X'_flow_control_on:
+       switch
+       call sio'X'_flow_control_on
+       switchback
+       ret
+
        ; DI required
        ; Returns char in L
        ;
        ; Caller responsible for making post buffer fetch decisions about
        ; RTS
 _sio'X'_rx_get:
+       switch
        ld a,(_sio'X'_rxl)
        or a
        ret z
@@ -234,15 +261,27 @@ _sio'X'_rx_get:
        ld (sio'X'_rxe),hl
        scf
        ld l,a
+       switchback
        ret
 
        ; DI required
 _sio'X'_error_get:
+       switch
        ld hl,#sio'X'_error
        ld a,(hl)
        ld (hl),#0
        ld l,a
+       switchback
        ret
 
+.endm
+
+.macro _sio_read
 
+_sio_read:
+       switch
+       ld a,(hl)
+       ld l,a
+       switchback
+       ret
 .endm
index 21b5734..4bf1e75 100644 (file)
@@ -143,9 +143,9 @@ void tty_sleeping(uint8_t minor)
 
 ttyready_t tty_writeready(uint8_t minor)
 {
-       if (minor == 1 && sio_txl[1] == 255)
+       if (minor == 1 && sio_txl[1] >= 127)
                return TTY_READY_SOON;
-       if (minor == 2 && sio_txl[0] == 255)
+       if (minor == 2 && sio_txl[0] >= 127)
                return TTY_READY_SOON;
        return TTY_READY_NOW;
 }
index cbb5a61..697ac34 100644 (file)
@@ -325,6 +325,18 @@ _siob_txl:
 
 sio_ports a
 sio_ports b
+
+       .area _COMMONMEM
+
+;
+;      Our data is fixed in common so nothing is needed
+;
+.macro switch
+.endm
+
+.macro switchback
+.endm
+
 sio_handler_im2        a, SIOA_C, SIOA_D, reti
 sio_handler_im2 b, SIOB_C, SIOB_D, reti