From dcb5f4212b85ce9ecb710e0f8ed926ba7a1bcb35 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 4 Aug 2015 13:43:35 +0200 Subject: [PATCH] devkbd: poll pc keyboard before blocking on kbd.q the keyboard stops sending interrupts when its fifo gets full, which can happen on boot when keys get mashed while interrupts are still disabled. to work arround this, call the keyboard interrupt handler when kbd.q is starved before blocking. --- sys/src/9/pc/devkbd.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/src/9/pc/devkbd.c b/sys/src/9/pc/devkbd.c index 9ce1a4895..bf43d85ba 100644 --- a/sys/src/9/pc/devkbd.c +++ b/sys/src/9/pc/devkbd.c @@ -277,6 +277,14 @@ i8042auxenable(void (*putc)(int, int)) iunlock(&i8042lock); } +static void +kbdpoll(void) +{ + if(nokbd || qlen(kbd.q) > 0) + return; + i8042intr(0, 0); +} + static Chan * kbdattach(char *spec) { @@ -324,20 +332,22 @@ kbdclose(Chan *c) static Block* kbdbread(Chan *c, long n, ulong off) { - if(c->qid.path == Qscancode) + if(c->qid.path == Qscancode){ + kbdpoll(); return qbread(kbd.q, n); - else - return devbread(c, n, off); + } + return devbread(c, n, off); } static long kbdread(Chan *c, void *a, long n, vlong) { - if(c->qid.path == Qscancode) + if(c->qid.path == Qscancode){ + kbdpoll(); return qread(kbd.q, a, n); + } if(c->qid.path == Qdir) return devdirread(c, a, n, kbdtab, nelem(kbdtab), devgen); - error(Egreg); return 0; }