From: Alan Cox Date: Sat, 19 Jan 2019 21:30:51 +0000 (+0000) Subject: rc2014 series: tty static buffers, basis for nice wakeups X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7ce62b4cdc1aba8dc4783ca4f975b0c5197068a5;p=FUZIX.git rc2014 series: tty static buffers, basis for nice wakeups --- diff --git a/Kernel/platform-rc2014-tiny/devtty.c b/Kernel/platform-rc2014-tiny/devtty.c index eca0f0a8..9510bb54 100644 --- a/Kernel/platform-rc2014-tiny/devtty.c +++ b/Kernel/platform-rc2014-tiny/devtty.c @@ -6,8 +6,10 @@ #include #include -char tbuf1[TTYSIZ]; -char tbuf2[TTYSIZ]; +static char tbuf1[TTYSIZ]; +static char tbuf2[TTYSIZ]; + +static uint8_t sleeping; uint8_t ser_type = 1; @@ -154,8 +156,9 @@ void tty_pollirq_sio(void) if (ca & 2) SIOA_C = 2 << 5; /* Output pending */ - if (ca & 4) { + if ((ca & 4) && (sleeping & 2)) { tty_outproc(1); + sleeping &= ~2; SIOA_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } /* Carrier changed */ @@ -171,8 +174,9 @@ void tty_pollirq_sio(void) tty_inproc(2, SIOB_D); progress = 1; } - if (cb & 4) { + if ((cb & 4) && (sleeping & 4)) { tty_outproc(2); + sleeping &= ~4; SIOB_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } if ((cb ^ old_cb) & 8) { @@ -214,6 +218,7 @@ void tty_putc(uint8_t minor, unsigned char c) /* We will need this for SIO once we implement flow control signals */ void tty_sleeping(uint8_t minor) { + sleeping |= (1 << minor); } /* Be careful here. We need to peek at RR but we must be sure nobody else @@ -262,7 +267,9 @@ void tty_data_consumed(uint8_t minor) /* kernel writes to system console -- never sleep! */ void kputchar(char c) { - tty_putc(TTYDEV - 512, c); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); if (c == '\n') tty_putc(TTYDEV - 512, '\r'); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); + tty_putc(TTYDEV - 512, c); } diff --git a/Kernel/platform-rc2014/devtty.c b/Kernel/platform-rc2014/devtty.c index 25e6c904..ae965385 100644 --- a/Kernel/platform-rc2014/devtty.c +++ b/Kernel/platform-rc2014/devtty.c @@ -8,8 +8,10 @@ #include "vfd-term.h" #include "vfd-debug.h" -char tbuf1[TTYSIZ]; -char tbuf2[TTYSIZ]; +static char tbuf1[TTYSIZ]; +static char tbuf2[TTYSIZ]; + +static uint8_t sleeping; uint8_t ser_type = 1; @@ -156,8 +158,9 @@ void tty_pollirq_sio(void) if (ca & 2) SIOA_C = 2 << 5; /* Output pending */ - if (ca & 4) { + if ((ca & 4) && (sleeping & 2)) { tty_outproc(1); + sleeping &= ~2; SIOA_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } /* Carrier changed */ @@ -173,8 +176,9 @@ void tty_pollirq_sio(void) tty_inproc(2, SIOB_D); progress = 1; } - if (cb & 4) { + if ((cb & 4) && (sleeping & 4)) { tty_outproc(2); + sleeping &= ~4; SIOB_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } if ((cb ^ old_cb) & 8) { @@ -194,8 +198,9 @@ void tty_pollirq_acia(void) if (ca & 1) { tty_inproc(1, ACIA_D); } - if (ca & 2) { + if ((ca & 2) && sleeping) { tty_outproc(1); + sleeping = 0; } } @@ -218,9 +223,9 @@ void tty_putc(uint8_t minor, unsigned char c) } } -/* We will need this for SIO once we implement flow control signals */ void tty_sleeping(uint8_t minor) { + sleeping |= (1 << minor); } /* Be careful here. We need to peek at RR but we must be sure nobody else @@ -269,7 +274,9 @@ void tty_data_consumed(uint8_t minor) /* kernel writes to system console -- never sleep! */ void kputchar(char c) { - tty_putc(TTYDEV - 512, c); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); if (c == '\n') tty_putc(TTYDEV - 512, '\r'); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); + tty_putc(TTYDEV - 512, c); } diff --git a/Kernel/platform-sc108/devtty.c b/Kernel/platform-sc108/devtty.c index abf995ee..acf5ae5a 100644 --- a/Kernel/platform-sc108/devtty.c +++ b/Kernel/platform-sc108/devtty.c @@ -6,8 +6,10 @@ #include #include -char tbuf1[TTYSIZ]; -char tbuf2[TTYSIZ]; +static char tbuf1[TTYSIZ]; +static char tbuf2[TTYSIZ]; + +static uint8_t sleeping; uint8_t ser_type = 2; @@ -154,8 +156,9 @@ void tty_pollirq_sio(void) if (ca & 2) SIOA_C = 2 << 5; /* Output pending */ - if (ca & 4) { + if ((ca & 4) && (sleeping & 2)) { tty_outproc(1); + sleeping &= ~2; SIOA_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } /* Carrier changed */ @@ -171,8 +174,9 @@ void tty_pollirq_sio(void) tty_inproc(2, SIOB_D); progress = 1; } - if (cb & 4) { + if ((cb & 4) && (sleeping & 4)) { tty_outproc(2); + sleeping &= ~4; SIOB_C = 5 << 3; // reg 0 CMD 5 - reset transmit interrupt pending } if ((cb ^ old_cb) & 8) { @@ -193,8 +197,9 @@ void tty_pollirq_acia(void) ca = ACIA_D; tty_inproc(1, ca); } - if (ca & 2) { -// We don't use IRQ driven tty_outproc(1); + if ((ca & 2) && sleeping) { + tty_outproc(1); + sleeping = 0; } } @@ -266,7 +271,9 @@ void tty_data_consumed(uint8_t minor) /* kernel writes to system console -- never sleep! */ void kputchar(char c) { - tty_putc(TTYDEV - 512, c); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); if (c == '\n') tty_putc(TTYDEV - 512, '\r'); + while(tty_writeready(TTYDEV - 512) != TTY_READY_NOW); + tty_putc(TTYDEV - 512, c); }