From ba92592f134cd184c75fad0f61b966593f4fcf54 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 19 Jan 2019 16:27:52 +0000 Subject: [PATCH] tiny68k: TTY driver fixes --- Kernel/platform-tiny68k/devtty.c | 39 ++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/Kernel/platform-tiny68k/devtty.c b/Kernel/platform-tiny68k/devtty.c index 21ca2d82..9b221a8b 100644 --- a/Kernel/platform-tiny68k/devtty.c +++ b/Kernel/platform-tiny68k/devtty.c @@ -58,28 +58,31 @@ tcflag_t *termios_mask[NUM_DEV_TTY + 1] = { console_mask }; -/* Output for the system console (kprintf etc) */ -void kputchar(char c) -{ - if (c == '\n') - tty_putc(1, '\r'); - tty_putc(1, c); -} - static volatile uint8_t *uart_base = (volatile uint8_t *)0xFFF000; #define GETB(x) (uart_base[(x)]) #define PUTB(x,y) uart_base[(x)] = (y) +/* Output for the system console (kprintf etc). Polled. */ +void kputchar(char c) +{ + if (c == '\n') { + while(!(GETB(UART_SRA) & 4)); + PUTB(UART_THRA, '\r'); + } + while(!(GETB(UART_SRA) & 4)); + PUTB(UART_THRA, c); +} + ttyready_t tty_writeready(uint8_t minor) { - uint8_t c = GETB(0x10 * minor + UART_SRA); - return (c & 2) ? TTY_READY_NOW : TTY_READY_SOON; /* TX DATA empty */ + uint8_t c = GETB(0x10 * (minor - 1) + UART_SRA); + return (c & 4) ? TTY_READY_NOW : TTY_READY_SOON; /* TX DATA empty */ } void tty_putc(uint8_t minor, unsigned char c) { - PUTB(0x10 * minor + UART_THRA, c); + PUTB(0x10 * (minor - 1) + UART_THRA, c); } void tty_setup(uint8_t minor, uint8_t flags) @@ -100,25 +103,24 @@ void tty_data_consumed(uint8_t minor) { } -/* Currently run off the timer */ static void tty_interrupt(uint8_t r) { - if (r & 0x01) { + if (r & 0x02) { r = GETB(UART_RHRA); tty_inproc(1,r); } - if (r & 0x02) { + if (r & 0x01) { if (sleeping & 2) tty_outproc(1); } if (r & 0x04) { /* How to clear break int ? */ } - if (r & 0x10) { + if (r & 0x20) { r = GETB(UART_RHRB); tty_inproc(2,r); } - if (r & 0x20) { + if (r & 0x10) { if (sleeping & 4) tty_outproc(2); } @@ -131,8 +133,11 @@ void platform_interrupt(void) { uint8_t r = GETB(UART_ISR); tty_interrupt(r); - if (r & 0x08) + if (r & 0x08) { + /* Ack the interrupt */ + GETB(UART_STOPCTR); timer_interrupt(); + } /* and 0x80 is the GPIO */ } -- 2.34.1