summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2008-10-23 12:22:24 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2008-10-23 12:22:24 +0000
commitc4f294f33f24b92d03e2663b954fd8426925c18b (patch)
treef5e23902312541220e22e19ea8d2ee11828720bb /payloads/libpayload/curses
parentc811a1c6aef38f53fadc4d51b17c56116d2baaac (diff)
make escape code handling for serial terminal more robust
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Marc Jones <marc.jones@amd.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3691 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/curses')
-rw-r--r--payloads/libpayload/curses/keyboard.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/payloads/libpayload/curses/keyboard.c b/payloads/libpayload/curses/keyboard.c
index 45bd4442fe..ead4313a98 100644
--- a/payloads/libpayload/curses/keyboard.c
+++ b/payloads/libpayload/curses/keyboard.c
@@ -50,21 +50,24 @@ static int _halfdelay = 0;
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 struct {
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)