diff options
author | Gabe Black <gabeblack@google.com> | 2012-08-28 16:38:34 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2012-11-07 18:30:40 +0100 |
commit | 5ab20054d3c6e637fbcde46a08d2a3c0891bf658 (patch) | |
tree | ed807af3ab376af09f2f34607551ac487cc0e859 | |
parent | 54c800a50c2c052ce13e29bedc608e180fddc70b (diff) | |
download | coreboot-5ab20054d3c6e637fbcde46a08d2a3c0891bf658.tar.xz |
Update the way serial info is read from the coreboot tables.
This information is now stored in a structure instead of in a few seperate
fields. libpayload hadn't been updated to reflect the new layout or to consume
the new information intelligently.
Change-Id: Ice3486ffcdcdbe1f16f9c84515120c591d8dc882
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: http://review.coreboot.org/1724
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Tested-by: build bot (Jenkins)
-rw-r--r-- | payloads/libpayload/arch/i386/coreboot.c | 5 | ||||
-rw-r--r-- | payloads/libpayload/drivers/serial.c | 25 | ||||
-rw-r--r-- | payloads/libpayload/include/sysinfo.h | 3 |
3 files changed, 19 insertions, 14 deletions
diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c index 06acc17b1d..8500d41f51 100644 --- a/payloads/libpayload/arch/i386/coreboot.c +++ b/payloads/libpayload/arch/i386/coreboot.c @@ -75,10 +75,7 @@ static void cb_parse_memory(void *ptr, struct sysinfo_t *info) static void cb_parse_serial(void *ptr, struct sysinfo_t *info) { - struct cb_serial *ser = ptr; - if (ser->type != CB_SERIAL_TYPE_IO_MAPPED) - return; - info->ser_ioport = ser->baseaddr; + info->serial = ((struct cb_serial *)ptr); } static void cb_parse_version(void *ptr, struct sysinfo_t *info) diff --git a/payloads/libpayload/drivers/serial.c b/payloads/libpayload/drivers/serial.c index 0f79b52c89..c0200af00c 100644 --- a/payloads/libpayload/drivers/serial.c +++ b/payloads/libpayload/drivers/serial.c @@ -31,8 +31,8 @@ #include <libpayload-config.h> #include <libpayload.h> -#define IOBASE lib_sysinfo.ser_ioport -#define MEMBASE (phys_to_virt(lib_sysinfo.ser_base)) +#define IOBASE lib_sysinfo.serial->baseaddr +#define MEMBASE (phys_to_virt(lib_sysinfo.serial->baseaddr)) #define DIVISOR(x) (115200 / x) #ifdef CONFIG_SERIAL_SET_SPEED @@ -96,15 +96,11 @@ static struct console_output_driver consout = { void serial_init(void) { - pcidev_t oxpcie_dev; - if (pci_find_device(0x1415, 0xc158, &oxpcie_dev)) { - lib_sysinfo.ser_base = pci_read_resource(oxpcie_dev, 0) + 0x1000; - } else { - lib_sysinfo.ser_base = 0; - } + if (!lib_sysinfo.serial) + return; #ifdef CONFIG_SERIAL_SET_SPEED - if (lib_sysinfo.ser_base) + if (lib_sysinfo.serial->type == CB_SERIAL_TYPE_MEMORY_MAPPED) serial_mem_hardware_init(IOBASE, CONFIG_SERIAL_BAUD_RATE, 8, 0, 1); else serial_io_hardware_init(IOBASE, CONFIG_SERIAL_BAUD_RATE, 8, 0, 1); @@ -152,7 +148,10 @@ static int serial_mem_getchar(void) void serial_putchar(unsigned int c) { - if (lib_sysinfo.ser_base) + if (!lib_sysinfo.serial) + return; + + if (lib_sysinfo.serial->type == CB_SERIAL_TYPE_MEMORY_MAPPED) serial_mem_putchar(c); else serial_io_putchar(c); @@ -160,6 +159,9 @@ void serial_putchar(unsigned int c) int serial_havechar(void) { + if (!lib_sysinfo.serial) + return 0; + if (lib_sysinfo.ser_base) return serial_mem_havechar(); else @@ -168,6 +170,9 @@ int serial_havechar(void) int serial_getchar(void) { + if (!lib_sysinfo.serial) + return -1; + if (lib_sysinfo.ser_base) return serial_mem_getchar(); else diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index 778dfe9414..cce934f42f 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -33,8 +33,11 @@ /* Allow a maximum of 16 memory range definitions. */ #define SYSINFO_MAX_MEM_RANGES 16 +struct cb_serial; + struct sysinfo_t { unsigned int cpu_khz; + struct cb_serial *serial; unsigned short ser_ioport; unsigned long ser_base; // for mmapped serial |