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
This commit is contained in:
parent
c811a1c6ae
commit
c4f294f33f
|
@ -50,10 +50,11 @@ static int _halfdelay = 0;
|
||||||
do the cooking in here, but we should probably eventually
|
do the cooking in here, but we should probably eventually
|
||||||
pass it to dedicated vt100 code */
|
pass it to dedicated vt100 code */
|
||||||
|
|
||||||
static int getkeyseq(char *buffer, int len)
|
static int getkeyseq(char *buffer, int len, int max)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
for(i = 0; i < 75; i++) {
|
for(i = 0; i < 75; i++) {
|
||||||
if (serial_havechar())
|
if (serial_havechar())
|
||||||
break;
|
break;
|
||||||
|
@ -64,7 +65,9 @@ static int getkeyseq(char *buffer, int len)
|
||||||
return len;
|
return len;
|
||||||
|
|
||||||
buffer[len++] = serial_getchar();
|
buffer[len++] = serial_getchar();
|
||||||
return getkeyseq(buffer, len);
|
if (len == max)
|
||||||
|
return len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -99,7 +102,7 @@ static struct {
|
||||||
static int handle_escape(void)
|
static int handle_escape(void)
|
||||||
{
|
{
|
||||||
char buffer[5];
|
char buffer[5];
|
||||||
int len = getkeyseq(buffer, 0);
|
int len = getkeyseq(buffer, 0, sizeof(buffer));
|
||||||
int i, t;
|
int i, t;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
|
|
Loading…
Reference in New Issue