From da9ab46d974745125fe7d8b29ce43336c3586cd5 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 3 Dec 2013 21:25:35 -0800 Subject: [PATCH] serial: Separate the serial hardware init and the serial console init. You might want to use the serial hardware for something other than a console, or you might want to intercede in the serial stream to wrap it in another protocol. This is what you'd do to send output to GDB while using it to debug the payload. BUG=None TEST=Built and booted on nyan and saw that there was serial output. Built for pit. BRANCH=None Change-Id: I2218c0dbb988dacb64e5bdaf5d92138828eff8b6 Signed-off-by: Gabe Black Reviewed-on: https://chromium-review.googlesource.com/179559 Reviewed-by: Ronald Minnich Reviewed-by: David Hendricks Commit-Queue: Gabe Black Tested-by: Gabe Black --- payloads/libpayload/drivers/serial.c | 9 +++++++++ payloads/libpayload/include/libpayload.h | 1 + payloads/libpayload/libc/console.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c index c0867e9739..3daf46082c 100644 --- a/payloads/libpayload/drivers/serial.c +++ b/payloads/libpayload/drivers/serial.c @@ -119,6 +119,15 @@ void serial_init(void) #ifdef CONFIG_LP_SERIAL_SET_SPEED serial_hardware_init(CONFIG_LP_SERIAL_BAUD_RATE, 8, 0, 1); #endif +} + +void serial_console_init(void) +{ + if (!lib_sysinfo.serial) + return; + + serial_init(); + console_add_input_driver(&consin); console_add_output_driver(&consout); } diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 8f1173371c..c63d91b1bc 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -164,6 +164,7 @@ int keyboard_set_layout(char *country); * @{ */ void serial_init(void); +void serial_console_init(void); void serial_putchar(unsigned int c); int serial_havechar(void); int serial_getchar(void); diff --git a/payloads/libpayload/libc/console.c b/payloads/libpayload/libc/console.c index cfaac58130..e4957bdb6f 100644 --- a/payloads/libpayload/libc/console.c +++ b/payloads/libpayload/libc/console.c @@ -52,7 +52,7 @@ void console_init(void) video_console_init(); #endif #ifdef CONFIG_LP_SERIAL_CONSOLE - serial_init(); + serial_console_init(); #endif #ifdef CONFIG_LP_PC_KEYBOARD keyboard_init();