summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers/serial.c
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2014-05-13 12:57:26 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-05-17 14:56:06 +0200
commit48e9eb89fa52eeb193f7e687bbb7f4e152235b79 (patch)
treee4c901e5f8d89136b8838edbeaaae87b700c17db /payloads/libpayload/drivers/serial.c
parent0890a825f3870f135447055c40b342bc6e3b0da7 (diff)
libpayload: Fix to properly disable serial console
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 <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/5723 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'payloads/libpayload/drivers/serial.c')
-rw-r--r--payloads/libpayload/drivers/serial.c11
1 files 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);
}