From 3f0aecd3b54bbac26f8cfcad46aa68a70d5f0921 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 12 Aug 1996 21:31:07 +0000 Subject: [PATCH] Fix two minor oddities introduced by my yesterday's patches: . preserve a multi-char sequence in a small static buffer inside pccngetc(), so it won't be clobbered later (used to happen when breaking into DDB user Ctrl-Alt-ESC), and . simplify the ``keystroke is present'' determination in sgetc(), thus making pccncheck() actually working without waiting for a keystroke. --- sys/i386/isa/pcvt/pcvt_drv.c | 16 ++++++++++++---- sys/i386/isa/pcvt/pcvt_kbd.c | 8 +++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 977d86ee415f..debb60facf4d 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -1207,7 +1207,8 @@ int pccngetc(Dev_t dev) { register int s; - static u_char *cp; + static u_char *cp, cbuf[4]; /* Temp buf for multi-char key sequence. */ + register u_char c; #ifdef XSERVER @@ -1233,14 +1234,21 @@ pccngetc(Dev_t dev) cp = sgetc(0); kbd_polling = 0; splx(s); + c = *cp++; + if (c && *cp) { + /* Preserve the multi-char sequence for the next call. */ + bcopy(cp, cbuf, 3); /* take care for a trailing '\0' */ + cp = cbuf; + } else + cp = 0; #if ! (PCVT_FREEBSD >= 201) /* this belongs to cons.c */ - if (*cp == '\r') - *cp = '\n'; + if (c == '\r') + c = '\n'; #endif /* ! (PCVT_FREEBSD >= 201) */ - return (*cp++); + return c; } #if PCVT_FREEBSD >= 200 diff --git a/sys/i386/isa/pcvt/pcvt_kbd.c b/sys/i386/isa/pcvt/pcvt_kbd.c index e39b04ed5e94..14f83d763234 100644 --- a/sys/i386/isa/pcvt/pcvt_kbd.c +++ b/sys/i386/isa/pcvt/pcvt_kbd.c @@ -935,10 +935,9 @@ sgetc(int noblock) /* see if there is data from the keyboard available either from */ /* the keyboard fifo or from the 8042 keyboard controller */ - if ((noblock && pcvt_kbd_count) || - ((!noblock || kbd_polling) && (inb(CONTROLLER_CTRL) & STATUS_OUTPBF))) + if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) { - if (!noblock || kbd_polling) /* source = 8042 */ + if (!pcvt_kbd_count) /* source = 8042 */ { PCVT_KBD_DELAY(); /* 7 us delay */ dt = inb(CONTROLLER_DATA); /* get from obuf */ @@ -1245,8 +1244,7 @@ sgetc(int noblock) /* see if there is data from the keyboard available either from */ /* the keyboard fifo or from the 8042 keyboard controller */ - if ((noblock && pcvt_kbd_count) || - ((!noblock || kbd_polling) && (inb(CONTROLLER_CTRL) & STATUS_OUTPBF))) + if (pcvt_kbd_count || (inb(CONTROLLER_CTRL) & STATUS_OUTPBF)) { if (!noblock || kbd_polling) /* source = 8042 */ {