rc2014 series: tty static buffers, basis for nice wakeups
authorAlan Cox <alan@linux.intel.com>
Sat, 19 Jan 2019 21:30:51 +0000 (21:30 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 19 Jan 2019 21:30:51 +0000 (21:30 +0000)
Kernel/platform-rc2014-tiny/devtty.c
Kernel/platform-rc2014/devtty.c
Kernel/platform-sc108/devtty.c

index eca0f0a..9510bb5 100644 (file)
@@ -6,8 +6,10 @@
 #include <devtty.h>
 #include <rc2014.h>
 
-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);
 }
index 25e6c90..ae96538 100644 (file)
@@ -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);
 }
index abf995e..acf5ae5 100644 (file)
@@ -6,8 +6,10 @@
 #include <devtty.h>
 #include <rc2014.h>
 
-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);
 }