UPSTREAM: libpayload/libc/console: Flush input driver buffer on init

When console input driver registers itself, perform flush of input
buffer to avoid interpreting any stale key presses before libpayload
is run.

keyboard.c: Remove the redundant buffer flush.
8250.c: Ensure that serial_hardware_is_present is set before call to
add input driver.

BUG=b:37273808
TEST=Verified that any key presses in serial console before payload is
up do not have any effect after the payload starts running.

Change-Id: I473423c4d5f701dbe16e490c49e910816c9af6a0
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 342f5f836c
Original-Change-Id: I46f1b6715ccf6418f5b2c741bf90db2ece26a60d
Original-Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/19345
Original-Tested-by: build bot (Jenkins)
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/482972
This commit is contained in:
Furquan Shaikh 2017-04-17 15:41:18 -07:00 committed by chrome-bot
parent 0db9fbeba0
commit bf9d8daf91
3 changed files with 4 additions and 4 deletions

View file

@ -310,9 +310,6 @@ void keyboard_init(void)
if (inb(0x64) == 0xFF)
return;
/* Empty keyboard buffer */
while (keyboard_havechar()) keyboard_getchar();
console_add_input_driver(&cons);
}

View file

@ -137,10 +137,10 @@ void serial_console_init(void)
return;
serial_init();
serial_hardware_is_present = 1;
console_add_input_driver(&consin);
console_add_output_driver(&consout);
serial_hardware_is_present = 1;
}
void serial_putchar(unsigned int c)

View file

@ -76,6 +76,9 @@ void console_add_input_driver(struct console_input_driver *in)
/* Check if this driver was already added to the console list */
if (input_driver_exists(in))
return;
/* Flush out the driver input buffer. */
while (in->havekey())
in->getchar();
in->next = console_in;
console_in = in;
}