summaryrefslogtreecommitdiff
path: root/payloads
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-04-17 15:41:18 -0700
committerFurquan Shaikh <furquan@google.com>2017-04-19 19:19:56 +0200
commit342f5f836c4c375d551087eab4c45fe904eef278 (patch)
tree2d0f5a865bba25f9872448aba46c003826e0c882 /payloads
parent22b22b698860165a9bcebe6b691257f3fdedba85 (diff)
downloadcoreboot-342f5f836c4c375d551087eab4c45fe904eef278.tar.xz
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: I46f1b6715ccf6418f5b2c741bf90db2ece26a60d Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/19345 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'payloads')
-rw-r--r--payloads/libpayload/drivers/keyboard.c3
-rw-r--r--payloads/libpayload/drivers/serial/8250.c2
-rw-r--r--payloads/libpayload/libc/console.c3
3 files changed, 4 insertions, 4 deletions
diff --git a/payloads/libpayload/drivers/keyboard.c b/payloads/libpayload/drivers/keyboard.c
index 23c87803a8..056aa24957 100644
--- a/payloads/libpayload/drivers/keyboard.c
+++ b/payloads/libpayload/drivers/keyboard.c
@@ -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);
}
diff --git a/payloads/libpayload/drivers/serial/8250.c b/payloads/libpayload/drivers/serial/8250.c
index 1fcf36dee6..9327304248 100644
--- a/payloads/libpayload/drivers/serial/8250.c
+++ b/payloads/libpayload/drivers/serial/8250.c
@@ -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)
diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c
index caeb582945..b57fc47bf6 100644
--- a/payloads/libpayload/libc/console.c
+++ b/payloads/libpayload/libc/console.c
@@ -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;
}