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>
This commit is contained in:
Kyösti Mälkki 2014-05-13 12:57:26 +03:00
parent 0890a825f3
commit 48e9eb89fa
1 changed files with 7 additions and 4 deletions

View File

@ -34,7 +34,7 @@
#define IOBASE lib_sysinfo.serial->baseaddr #define IOBASE lib_sysinfo.serial->baseaddr
#define MEMBASE (phys_to_virt(IOBASE)) #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 int serial_is_mem_mapped = 0;
static uint8_t serial_read_reg(int offset) static uint8_t serial_read_reg(int offset)
@ -105,7 +105,8 @@ void serial_init(void)
#ifdef CONFIG_IO_ADDRESS_SPACE #ifdef CONFIG_IO_ADDRESS_SPACE
if ((inb(IOBASE + 0x05) == 0xFF) && if ((inb(IOBASE + 0x05) == 0xFF) &&
(inb(IOBASE + 0x06) == 0xFF)) { (inb(IOBASE + 0x06) == 0xFF)) {
serial_hardware_is_present = 0; printf("IO space mapped serial not present.");
return;
} }
#else #else
printf("IO space mapped serial not supported."); printf("IO space mapped serial not supported.");
@ -118,12 +119,14 @@ void serial_init(void)
#endif #endif
console_add_input_driver(&consin); console_add_input_driver(&consin);
console_add_output_driver(&consout); console_add_output_driver(&consout);
serial_hardware_is_present = 1;
} }
void serial_putchar(unsigned int c) void serial_putchar(unsigned int c)
{ {
if (serial_hardware_is_present) if (!serial_hardware_is_present)
while ((serial_read_reg(0x05) & 0x20) == 0) ; return;
while ((serial_read_reg(0x05) & 0x20) == 0) ;
serial_write_reg(c, 0x00); serial_write_reg(c, 0x00);
} }