From 6343bf7f5df8a9805c9a49049d308495e5bfdfdb Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 11 Nov 2017 01:39:35 +0000 Subject: [PATCH] z80pack: work around emulation not emulating baud rates --- Kernel/dev/z80pack/devtty.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Kernel/dev/z80pack/devtty.c b/Kernel/dev/z80pack/devtty.c index 60d8d1cf..38a76eef 100644 --- a/Kernel/dev/z80pack/devtty.c +++ b/Kernel/dev/z80pack/devtty.c @@ -71,22 +71,33 @@ void tty_sleeping(uint8_t minor) } /* Called every timer tick */ +/* This looks a bit odd but we have the classic emulator problem of the + serial ports suddenly being empty then getting blasted with data from + an unrealistic fifo running at what is effectively MHz+ speeds. So we + gate the number of bytes we allow per clock to simulate a real baud rate + (in this case 100Hz 80 chars ~= 9600 baud input) */ void tty_pollirq(void) { unsigned char c; /* sdcc bug workaround */ - while(tty1stat) { + unsigned char l; + + l = 80; + while(tty1stat && l--) { c = tty1data; tty_inproc(1, c); } - while(tty2stat & 1) { + l = 80; + while((tty2stat & 1) &&& l--) { c = tty2data; tty_inproc(2, c); } - while(tty3stat & 1) { + l = 80; + while((tty3stat & 1) && l--) { c = tty3data; tty_inproc(3, c); } - while(tty4stat & 1) { + l = 80; + while((tty4stat & 1) && l--) { c = tty4data; tty_inproc(4, c); } -- 2.34.1