From d1bc331855caab351a70676b5085787292a45fea Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Wed, 22 Jun 2011 16:39:19 -0700 Subject: [PATCH] Extend coreboot table entry for serial ports Add information about memory mapped/io mapped base addresses. and fix up libpayload to use the same structures Signed-off-by: Stefan Reinauer Change-Id: I5f7b5eda6063261b9acb7a46310172d4a5471dfb Reviewed-on: http://review.coreboot.org/261 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- payloads/libpayload/arch/i386/coreboot.c | 4 +++- payloads/libpayload/arch/powerpc/coreboot.c | 4 +++- payloads/libpayload/include/coreboot_tables.h | 16 ++++++++++++---- src/arch/x86/boot/coreboot_table.c | 15 +++++++++++++-- src/console/uart8250mem_console.c | 5 +++++ src/include/boot/coreboot_tables.h | 5 ++++- src/include/uart8250.h | 1 + 7 files changed, 41 insertions(+), 9 deletions(-) diff --git a/payloads/libpayload/arch/i386/coreboot.c b/payloads/libpayload/arch/i386/coreboot.c index e3c944d44..bdef4e85d 100644 --- a/payloads/libpayload/arch/i386/coreboot.c +++ b/payloads/libpayload/arch/i386/coreboot.c @@ -77,7 +77,9 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info) { struct cb_serial *ser = (struct cb_serial *)ptr; - info->ser_ioport = ser->ioport; + if (ser->type != CB_SERIAL_TYPE_IO_MAPPED) + return; + info->ser_ioport = ser->baseaddr; } #ifdef CONFIG_NVRAM diff --git a/payloads/libpayload/arch/powerpc/coreboot.c b/payloads/libpayload/arch/powerpc/coreboot.c index ee1842c82..7da87ed2f 100644 --- a/payloads/libpayload/arch/powerpc/coreboot.c +++ b/payloads/libpayload/arch/powerpc/coreboot.c @@ -77,7 +77,9 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info) static void cb_parse_serial(unsigned char *ptr, struct sysinfo_t *info) { struct cb_serial *ser = (struct cb_serial *)ptr; - info->ser_ioport = ser->ioport; + if (ser->type != CB_SERIAL_TYPE_IO_MAPPED) + return; + info->ser_ioport = ser->baseaddr; } #ifdef CONFIG_NVRAM diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index c4dc1158a..d342c992c 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -60,9 +60,13 @@ struct cb_memory_range { u32 type; }; -#define CB_MEM_RAM 1 -#define CB_MEM_RESERVED 2 -#define CB_MEM_TABLE 16 +#define CB_MEM_RAM 1 +#define CB_MEM_RESERVED 2 +#define CB_MEM_ACPI 3 +#define CB_MEM_NVS 4 +#define CB_MEM_UNUSABLE 5 +#define CB_MEM_VENDOR_RSVD 6 +#define CB_MEM_TABLE 16 struct cb_memory { u32 tag; @@ -110,7 +114,11 @@ struct cb_string { struct cb_serial { u32 tag; u32 size; - u16 ioport; +#define CB_SERIAL_TYPE_IO_MAPPED 1 +#define CB_SERIAL_TYPE_MEMORY_MAPPED 2 + u32 type; + u32 baseaddr; + u32 baud; }; #define CB_TAG_CONSOLE 0x00010 diff --git a/src/arch/x86/boot/coreboot_table.c b/src/arch/x86/boot/coreboot_table.c index cdfc0c1d8..78ff97d21 100644 --- a/src/arch/x86/boot/coreboot_table.c +++ b/src/arch/x86/boot/coreboot_table.c @@ -112,7 +112,19 @@ static struct lb_serial *lb_serial(struct lb_header *header) serial = (struct lb_serial *)rec; serial->tag = LB_TAG_SERIAL; serial->size = sizeof(*serial); - serial->ioport = CONFIG_TTYS0_BASE; + serial->type = LB_SERIAL_TYPE_IO_MAPPED; + serial->baseaddr = CONFIG_TTYS0_BASE; + serial->baud = CONFIG_TTYS0_BAUD; + return serial; +#elif CONFIG_CONSOLE_SERIAL8250MEM + struct lb_record *rec; + struct lb_serial *serial; + rec = lb_new_record(header); + serial = (struct lb_serial *)rec; + serial->tag = LB_TAG_SERIAL; + serial->size = sizeof(*serial); + serial->type = LB_SERIAL_TYPE_MEMORY_MAPPED; + serial->baseaddr = uartmem_getbaseaddr(); serial->baud = CONFIG_TTYS0_BAUD; return serial; #else @@ -131,7 +143,6 @@ static void add_console(struct lb_header *header, u16 consoletype) console->size = sizeof(*console); console->type = consoletype; } - #endif static void lb_console(struct lb_header *header) diff --git a/src/console/uart8250mem_console.c b/src/console/uart8250mem_console.c index e622ad090..923df99df 100644 --- a/src/console/uart8250mem_console.c +++ b/src/console/uart8250mem_console.c @@ -28,6 +28,11 @@ static void uartmem_init(void) uart_bar = uart_mem_init(); } +u32 uartmem_getbaseaddr(void) +{ + return uart_bar; +} + static void uartmem_tx_byte(unsigned char data) { if (!uart_bar) diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index 983b03f60..45ba3af11 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -146,7 +146,10 @@ struct lb_string { struct lb_serial { uint32_t tag; uint32_t size; - uint16_t ioport; +#define LB_SERIAL_TYPE_IO_MAPPED 1 +#define LB_SERIAL_TYPE_MEMORY_MAPPED 2 + uint32_t type; + uint32_t baseaddr; uint32_t baud; }; diff --git a/src/include/uart8250.h b/src/include/uart8250.h index 4a0217921..3c8ea0929 100644 --- a/src/include/uart8250.h +++ b/src/include/uart8250.h @@ -146,6 +146,7 @@ void uart8250_mem_tx_byte(unsigned base_port, unsigned char data); void uart8250_mem_tx_flush(unsigned base_port); void uart8250_mem_init(unsigned base_port, unsigned divisor); u32 uart_mem_init(void); +u32 uartmem_getbaseaddr(void); /* and special init for OXPCIe based cards */ void oxford_init(void); -- 2.25.1