Module Name:    src
Committed By:   tsutsui
Date:           Fri Oct 12 18:01:53 UTC 2012

Modified Files:
        src/sys/arch/x68k/stand/libsa: consio.c

Log Message:
Fix a bug in check_getchar() (called from awaitkey_1sec()).
It didn't clear input key data when non ASCII keys (CTRL, OPT.1 etc)
were pressed so it couldn't detect further key inputs and
"any other key for boot menu" interrupt during boot didn't work
in that case.

The problem was tracked by Y.Sugahara,
and tested on X68030 and XM6i by me.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x68k/stand/libsa/consio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x68k/stand/libsa/consio.c
diff -u src/sys/arch/x68k/stand/libsa/consio.c:1.9 src/sys/arch/x68k/stand/libsa/consio.c:1.10
--- src/sys/arch/x68k/stand/libsa/consio.c:1.9	Sun Jul 17 20:54:49 2011
+++ src/sys/arch/x68k/stand/libsa/consio.c	Fri Oct 12 18:01:53 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: consio.c,v 1.9 2011/07/17 20:54:49 joerg Exp $	*/
+/*	$NetBSD: consio.c,v 1.10 2012/10/12 18:01:53 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2001 MINOURA Makoto.
@@ -103,10 +103,21 @@ putchar(int c)
 int
 check_getchar(void)
 {
+	int keycode;
 
 	switch (x68k_console_device) {
 	case ITE:
-		return IOCS_B_KEYSNS() & 0xff;
+		while ((keycode = IOCS_B_KEYSNS()) != 0) {
+			keycode &= 0xff;
+			if (keycode != 0) {
+				/* valid ASCII code */
+				return keycode;
+			}
+			/* discard non ASCII keys (CTRL, OPT.1 etc) */
+			(void)IOCS_B_KEYINP();
+		} 
+		/* no input */
+		return 0;
 	case SERIAL:
 		return IOCS_ISNS232C() & 0xff;
 	}

Reply via email to