[coreboot] r3691 - trunk/payloads/libpayload/curses

svn at coreboot.org svn at coreboot.org
Thu Oct 23 14:22:25 CEST 2008


Author: oxygene
Date: 2008-10-23 14:22:24 +0200 (Thu, 23 Oct 2008)
New Revision: 3691

Modified:
   trunk/payloads/libpayload/curses/keyboard.c
Log:
make escape code handling for serial terminal more robust

Signed-off-by: Patrick Georgi <patrick.georgi at coresystems.de>
Acked-by: Marc Jones <marc.jones at amd.com>

Modified: trunk/payloads/libpayload/curses/keyboard.c
===================================================================
--- trunk/payloads/libpayload/curses/keyboard.c	2008-10-22 22:30:17 UTC (rev 3690)
+++ trunk/payloads/libpayload/curses/keyboard.c	2008-10-23 12:22:24 UTC (rev 3691)
@@ -50,21 +50,24 @@
    do the cooking in here, but we should probably eventually
    pass it to dedicated vt100 code */
 
-static int getkeyseq(char *buffer, int len)
+static int getkeyseq(char *buffer, int len, int max)
 {
 	int i;
 
-	for(i = 0; i < 75; i++) {
-		if (serial_havechar())
-			break;
-		mdelay(1);
-	}
+	while (1) {
+		for(i = 0; i < 75; i++) {
+			if (serial_havechar())
+				break;
+			mdelay(1);
+		}
 
-	if (i == 75)
-		return len;
+		if (i == 75)
+			return len;
 
-	buffer[len++] = serial_getchar();
-	return getkeyseq(buffer, len);
+		buffer[len++] = serial_getchar();
+		if (len == max)
+			return len;
+	}
 }
 
 static struct {
@@ -99,7 +102,7 @@
 static int handle_escape(void)
 {
 	char buffer[5];
-	int len = getkeyseq(buffer, 0);
+	int len = getkeyseq(buffer, 0, sizeof(buffer));
 	int i, t;
 
 	if (len == 0)





More information about the coreboot mailing list