Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5341
-gerrit
commit f3e263d360f082cf878592233e12ba47e5af8bb9 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Wed Feb 26 15:19:04 2014 +0200
console: Simplify the enable rules
Consoles on CBMEM and USB have somewhat complex rules and dependencies when they can be active. Use simple variables to test which stage of boot is being built for each console.
Change-Id: I2489e7731d07ca7d5dd2ea8b6501c73f05d6edd8 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/console/console.c | 62 ++++++++++--------------------------- src/include/console/cbmem_console.h | 23 +++++++++++--- src/include/console/ne2k.h | 15 +++++++++ src/include/console/qemu_debugcon.h | 11 +++++++ src/include/console/spkmodem.h | 11 +++++++ src/include/console/uart.h | 14 +++++++++ src/include/console/usb.h | 16 ++++++++++ 7 files changed, 102 insertions(+), 50 deletions(-)
diff --git a/src/console/console.c b/src/console/console.c index f66cd3f..cd72596 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -27,59 +27,31 @@
void console_hw_init(void) { -#if CONFIG_CONSOLE_SERIAL - uart_init(); -#endif -#if CONFIG_CONSOLE_NE2K - ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT); -#endif -#if CONFIG_CONSOLE_CBMEM && !defined(__BOOT_BLOCK__) && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)) - cbmemc_init(); -#endif -#if CONFIG_SPKMODEM - spkmodem_init(); -#endif -#if CONFIG_CONSOLE_USB && (CONFIG_USBDEBUG_IN_ROMSTAGE || !defined(__PRE_RAM__)) - usbdebug_init(); -#endif -#if CONFIG_CONSOLE_QEMU_DEBUGCON - qemu_debugcon_init(); -#endif + __cbmemc_init(); + __spkmodem_init(); + __qemu_debugcon_init(); + + __uart_init(); + __ne2k_init(); + __usbdebug_init(); }
void console_tx_byte(unsigned char byte) { -#if CONFIG_CONSOLE_SERIAL - uart_tx_byte(byte); -#endif -#if CONFIG_CONSOLE_USB && (CONFIG_USBDEBUG_IN_ROMSTAGE || !defined(__PRE_RAM__)) - usb_tx_byte(0, byte); -#endif -#if CONFIG_CONSOLE_NE2K - ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT); -#endif -#if CONFIG_CONSOLE_CBMEM && !defined(__BOOT_BLOCK__) && (CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__)) - cbmemc_tx_byte(byte); -#endif -#if CONFIG_SPKMODEM - spkmodem_tx_byte(byte); -#endif -#if CONFIG_CONSOLE_QEMU_DEBUGCON - qemu_debugcon_tx_byte(byte); -#endif + __cbmemc_tx_byte(byte); + __spkmodem_tx_byte(byte); + __qemu_debugcon_tx_byte(byte); + + __uart_tx_byte(byte); + __ne2k_tx_byte(byte); + __usb_tx_byte(byte); }
void console_tx_flush(void) { -#if CONFIG_CONSOLE_SERIAL - uart_tx_flush(); -#endif -#if CONFIG_CONSOLE_NE2K - ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT); -#endif -#if CONFIG_CONSOLE_USB && (CONFIG_USBDEBUG_IN_ROMSTAGE || !defined(__PRE_RAM__)) - usb_tx_flush(0); -#endif + __uart_tx_flush(); + __ne2k_tx_flush(); + __usb_tx_flush(); }
void console_tx_nibble(unsigned nibble) diff --git a/src/include/console/cbmem_console.h b/src/include/console/cbmem_console.h index 4f4a54f..a7f48c9 100644 --- a/src/include/console/cbmem_console.h +++ b/src/include/console/cbmem_console.h @@ -19,14 +19,27 @@ #ifndef _CONSOLE_CBMEM_CONSOLE_H_ #define _CONSOLE_CBMEM_CONSOLE_H_
-#if CONFIG_EARLY_CBMEM_INIT || !defined(__PRE_RAM__) +#include <arch/rules.h> +#include <stdint.h> + void cbmemc_init(void); -void cbmemc_reinit(void); void cbmemc_tx_byte(unsigned char data); + +#if CONFIG_CONSOLE_CBMEM +void cbmemc_reinit(void); +#else +static inline void cbmemc_reinit(void) {} +#endif + +#define __CBMEM_CONSOLE_ENABLE__ CONFIG_CONSOLE_CBMEM && \ + ((ENV_ROMSTAGE && CONFIG_EARLY_CBMEM_INIT) || ENV_RAMSTAGE) + +#if __CBMEM_CONSOLE_ENABLE__ +static inline void __cbmemc_init(void) { cbmemc_init(); } +static inline void __cbmemc_tx_byte(u8 data) { cbmemc_tx_byte(data); } #else -#define cbmemc_init() -#define cbmemc_reinit() -#define cbmemc_tx_byte(x) +static inline void __cbmemc_init(void) {} +static inline void __cbmemc_tx_byte(u8 data) {} #endif
#endif diff --git a/src/include/console/ne2k.h b/src/include/console/ne2k.h index cb3c1ec..508b5e5 100644 --- a/src/include/console/ne2k.h +++ b/src/include/console/ne2k.h @@ -19,6 +19,10 @@
#ifndef _NE2K_H__ #define _NE2K_H__ + +#include <arch/rules.h> +#include <stdint.h> + void ne2k_append_data(unsigned char *d, int len, unsigned int base); int ne2k_init(unsigned int eth_nic_base); void ne2k_transmit(unsigned int eth_nic_base); @@ -26,4 +30,15 @@ void ne2k_transmit(unsigned int eth_nic_base); #ifndef __ROMCC__ #define ne2k_append_data_byte(d, base) ne2k_append_data(&d, 1, base) #endif + +#if CONFIG_CONSOLE_NE2K && (ENV_ROMSTAGE || ENV_RAMSTAGE) +static inline void __ne2k_init(void) { ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT); } +static inline void __ne2k_tx_byte(u8 data) { ne2k_append_data_byte(data, CONFIG_CONSOLE_NE2K_IO_PORT); } +static inline void __ne2k_tx_flush(void) { ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT); } +#else +static inline void __ne2k_init(void) {} +static inline void __ne2k_tx_byte(u8 data) {} +static inline void __ne2k_tx_flush(void) {} +#endif + #endif /* _NE2K_H */ diff --git a/src/include/console/qemu_debugcon.h b/src/include/console/qemu_debugcon.h index 63b1455..8988e9e 100644 --- a/src/include/console/qemu_debugcon.h +++ b/src/include/console/qemu_debugcon.h @@ -1,7 +1,18 @@ #ifndef _QEMU_DEBUGCON_H_ #define _QEMU_DEBUGCON_H_
+#include <arch/rules.h> +#include <stdint.h> + void qemu_debugcon_init(void); void qemu_debugcon_tx_byte(unsigned char data);
+#if CONFIG_CONSOLE_QEMU_DEBUGCON && (ENV_ROMSTAGE || ENV_RAMSTAGE) +static inline void __qemu_debugcon_init(void) { qemu_debugcon_init(); } +static inline void __qemu_debugcon_tx_byte(u8 data) { qemu_debugcon_tx_byte(data); } +#else +static inline void __qemu_debugcon_init(void) {} +static inline void __qemu_debugcon_tx_byte(u8 data) {} +#endif + #endif diff --git a/src/include/console/spkmodem.h b/src/include/console/spkmodem.h index 450dbe8..dbc1843 100644 --- a/src/include/console/spkmodem.h +++ b/src/include/console/spkmodem.h @@ -1,7 +1,18 @@ #ifndef SPKMODEM_H #define SPKMODEM_H 1
+#include <arch/rules.h> +#include <stdint.h> + void spkmodem_init(void); void spkmodem_tx_byte(unsigned char c);
+#if CONFIG_SPKMODEM && (ENV_ROMSTAGE || ENV_RAMSTAGE) +static inline void __spkmodem_init(void) { spkmodem_init(); } +static inline void __spkmodem_tx_byte(u8 data) { spkmodem_tx_byte(data); } +#else +static inline void __spkmodem_init(void) {} +static inline void __spkmodem_tx_byte(u8 data) {} +#endif + #endif diff --git a/src/include/console/uart.h b/src/include/console/uart.h index 05cc432..5e778f0 100644 --- a/src/include/console/uart.h +++ b/src/include/console/uart.h @@ -20,6 +20,7 @@ #ifndef CONSOLE_UART_H #define CONSOLE_UART_H
+#include <arch/rules.h> #include <stdint.h>
/* Return the clock frequency UART uses as reference clock for @@ -53,4 +54,17 @@ static inline void *uart_platform_baseptr(int idx)
void oxford_remap(unsigned int new_base);
+#define __CONSOLE_SERIAL_ENABLE__ CONFIG_CONSOLE_SERIAL && \ + (ENV_ROMSTAGE || ENV_RAMSTAGE || (ENV_SMM && CONFIG_DEBUG_SMI)) + +#if __CONSOLE_SERIAL_ENABLE__ +static inline void __uart_init(void) { uart_init(); } +static inline void __uart_tx_byte(u8 data) { uart_tx_byte(data); } +static inline void __uart_tx_flush(void) { uart_tx_flush(); } +#else +static inline void __uart_init(void) {} +static inline void __uart_tx_byte(u8 data) {} +static inline void __uart_tx_flush(void) {} +#endif + #endif /* CONSOLE_UART_H */ diff --git a/src/include/console/usb.h b/src/include/console/usb.h index 9591135..e64e43e 100644 --- a/src/include/console/usb.h +++ b/src/include/console/usb.h @@ -21,6 +21,9 @@ #ifndef _CONSOLE_USB_H_ #define _CONSOLE_USB_H_
+#include <arch/rules.h> +#include <stdint.h> + int usbdebug_init(void);
void usb_tx_byte(int idx, unsigned char data); @@ -28,4 +31,17 @@ void usb_tx_flush(int idx); unsigned char usb_rx_byte(int idx); int usb_can_rx_byte(int idx);
+#define __CONSOLE_USB_ENABLE__ CONFIG_CONSOLE_USB && \ + ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE) + +#if __CONSOLE_USB_ENABLE__ +static inline void __usbdebug_init(void) { usbdebug_init(); } +static inline void __usb_tx_byte(u8 data) { usb_tx_byte(0, data); } +static inline void __usb_tx_flush(void) { usb_tx_flush(0); } +#else +static inline void __usbdebug_init(void) {} +static inline void __usb_tx_byte(u8 data) {} +static inline void __usb_tx_flush(void) {} +#endif + #endif /* _CONSOLE_USB_H_ */