From 48e9eb89fa52eeb193f7e687bbb7f4e152235b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Tue, 13 May 2014 12:57:26 +0300 Subject: [PATCH] libpayload: Fix to properly disable serial console MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With coreboot builds with serial console disabled, there is no CB_TAG_SERIAL entry in coreboot tables. We ended up with lib_sysinfo.serial == NULL and serial_hardware_is_present == 1. Change-Id: I9a2fc0b55bf77769f2f2bfbb2b5476bee8083f7d Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/5723 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan Reviewed-by: Patrick Georgi Reviewed-by: Paul Menzel --- payloads/libpayload/drivers/serial.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c index a4cd6d013a..0d2964b771 100644 --- a/payloads/libpayload/drivers/serial.c +++ b/payloads/libpayload/drivers/serial.c @@ -34,7 +34,7 @@ #define IOBASE lib_sysinfo.serial->baseaddr #define MEMBASE (phys_to_virt(IOBASE)) -static int serial_hardware_is_present = 1; +static int serial_hardware_is_present = 0; static int serial_is_mem_mapped = 0; static uint8_t serial_read_reg(int offset) @@ -105,7 +105,8 @@ void serial_init(void) #ifdef CONFIG_IO_ADDRESS_SPACE if ((inb(IOBASE + 0x05) == 0xFF) && (inb(IOBASE + 0x06) == 0xFF)) { - serial_hardware_is_present = 0; + printf("IO space mapped serial not present."); + return; } #else printf("IO space mapped serial not supported."); @@ -118,12 +119,14 @@ void serial_init(void) #endif console_add_input_driver(&consin); console_add_output_driver(&consout); + serial_hardware_is_present = 1; } void serial_putchar(unsigned int c) { - if (serial_hardware_is_present) - while ((serial_read_reg(0x05) & 0x20) == 0) ; + if (!serial_hardware_is_present) + return; + while ((serial_read_reg(0x05) & 0x20) == 0) ; serial_write_reg(c, 0x00); }