[coreboot-gerrit] New patch to review for coreboot: f7e4817 console: Centralized enable
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Tue Mar 4 18:01:34 CET 2014
Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5341
-gerrit
commit f7e4817fd19d00cee5fc7473f4c5c994886dd65a
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Sat Jan 25 14:35:24 2014 +0200
console: Centralized enable
Change-Id: I2489e7731d07ca7d5dd2ea8b6501c73f05d6edd8
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
src/console/console.c | 62 ++++++++++---------------------------
src/include/console/cbmem_console.h | 20 +++++++++---
src/include/console/ne2k.h | 14 +++++++++
src/include/console/qemu_debugcon.h | 10 ++++++
src/include/console/spkmodem.h | 10 ++++++
src/include/console/uart.h | 15 ++++++++-
src/include/console/usb.h | 15 +++++++++
7 files changed, 96 insertions(+), 50 deletions(-)
diff --git a/src/console/console.c b/src/console/console.c
index f3d0f78..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 69332aa..dccd46b 100644
--- a/src/include/console/cbmem_console.h
+++ b/src/include/console/cbmem_console.h
@@ -19,14 +19,26 @@
#ifndef _CONSOLE_CBMEM_CONSOLE_H_
#define _CONSOLE_CBMEM_CONSOLE_H_
-#if CONFIG_CACHE_AS_RAM || !defined(__PRE_RAM__)
+#include <console/streams.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
-#define cbmemc_init()
#define cbmemc_reinit()
-#define cbmemc_tx_byte(x)
+#endif
+
+#define __CBMEM_CONSOLE_ENABLE__ CONFIG_CONSOLE_CBMEM && \
+ (ENV_ROMSTAGE && CONFIG_EARLY_CBMEM_INIT || ENV_RAMSTAGE)
+
+#if __CBMEM_CONSOLE_ENABLE__
+#define __cbmemc_init() cbmemc_init()
+#define __cbmemc_tx_byte(x) cbmemc_tx_byte(x)
+#else
+#define __cbmemc_init()
+#define __cbmemc_tx_byte(x)
#endif
#endif
diff --git a/src/include/console/ne2k.h b/src/include/console/ne2k.h
index cb3c1ec..539b5c0 100644
--- a/src/include/console/ne2k.h
+++ b/src/include/console/ne2k.h
@@ -19,6 +19,9 @@
#ifndef _NE2K_H__
#define _NE2K_H__
+
+#include <console/streams.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 +29,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)
+#define __ne2k_init() ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT)
+#define __ne2k_tx_byte(x) ne2k_append_data_byte(x, CONFIG_CONSOLE_NE2K_IO_PORT)
+#define __ne2k_tx_flush() ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT)
+#else
+#define __ne2k_init()
+#define __ne2k_tx_byte(x)
+#define __ne2k_tx_flush()
+#endif
+
#endif /* _NE2K_H */
diff --git a/src/include/console/qemu_debugcon.h b/src/include/console/qemu_debugcon.h
index 63b1455..da6bc3c 100644
--- a/src/include/console/qemu_debugcon.h
+++ b/src/include/console/qemu_debugcon.h
@@ -1,7 +1,17 @@
#ifndef _QEMU_DEBUGCON_H_
#define _QEMU_DEBUGCON_H_
+#include <console/streams.h>
+
void qemu_debugcon_init(void);
void qemu_debugcon_tx_byte(unsigned char data);
+#if CONFIG_CONSOLE_QEMU_DEBUGCON && (ENV_ROMSTAGE || ENV_RAMSTAGE)
+#define __qemu_debugcon_init qemu_debugcon_init()
+#define __qemu_debugcon_tx_byte(x) qemu_debugcon_tx_byte(x)
+#else
+#define __qemu_debugcon_init()
+#define __qemu_debugcon_tx_byte(x)
+#endif
+
#endif
diff --git a/src/include/console/spkmodem.h b/src/include/console/spkmodem.h
index 450dbe8..879a60a 100644
--- a/src/include/console/spkmodem.h
+++ b/src/include/console/spkmodem.h
@@ -1,7 +1,17 @@
#ifndef SPKMODEM_H
#define SPKMODEM_H 1
+#include <console/streams.h>
+
void spkmodem_init(void);
void spkmodem_tx_byte(unsigned char c);
+#if CONFIG_SPKMODEM && (ENV_ROMSTAGE || ENV_RAMSTAGE)
+#define __spkmodem_init() spkmodem_init()
+#define __spkmodem_tx_byte(x) spkmodem_tx_byte(x)
+#else
+#define __spkmodem_init()
+#define __spkmodem_tx_byte(x)
+#endif
+
#endif
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 48d4309..566791a 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -20,7 +20,7 @@
#ifndef CONSOLE_UART_H
#define CONSOLE_UART_H
-#include <stdint.h>
+#include <console/streams.h>
/* Return the clock frequency UART uses as reference clock for
* baudrate generator. */
@@ -48,4 +48,17 @@ unsigned int uart_platform_base(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__
+#define __uart_init() uart_init()
+#define __uart_tx_byte(x) uart_tx_byte(x);
+#define __uart_tx_flush() uart_tx_flush()
+#else
+#define __uart_init()
+#define __uart_tx_byte(x)
+#define __uart_tx_flush()
+#endif
+
#endif /* CONSOLE_UART_H */
diff --git a/src/include/console/usb.h b/src/include/console/usb.h
index 9591135..31059cb 100644
--- a/src/include/console/usb.h
+++ b/src/include/console/usb.h
@@ -21,6 +21,8 @@
#ifndef _CONSOLE_USB_H_
#define _CONSOLE_USB_H_
+#include <console/streams.h>
+
int usbdebug_init(void);
void usb_tx_byte(int idx, unsigned char data);
@@ -28,4 +30,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__
+#define __usbdebug_init() usbdebug_init()
+#define __usb_tx_byte(x) usb_tx_byte(0, x)
+#define __usb_tx_flush() usb_tx_flush(0)
+#else
+#define __usbdebug_init()
+#define __usb_tx_byte(x)
+#define __usb_tx_flush()
+#endif
+
#endif /* _CONSOLE_USB_H_ */
More information about the coreboot-gerrit
mailing list