[coreboot] Patch set updated for coreboot: 58f58a2 USBDEBUG: buffer up to 8 bytes

Sven Schnelle (svens@stackframe.org) gerrit at coreboot.org
Thu Jul 26 14:42:16 CEST 2012


Sven Schnelle (svens at stackframe.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1357

-gerrit

commit 58f58a25e95d773b1ab454d2d1acbc27dfb143d4
Author: Sven Schnelle <svens at stackframe.org>
Date:   Thu Jul 26 14:31:40 2012 +0200

    USBDEBUG: buffer up to 8 bytes
    
    EHCI debug allows to send message with 8 bytes length, but
    we're only sending one byte in each transaction. Buffer up
    to 8 bytes to speed up debug output.
    
    Change-Id: I9dbb406833c4966c3afbd610e1b13a8fa3d62f39
    Signed-off-by: Sven Schnelle <svens at stackframe.org>
---
 src/arch/x86/lib/romstage_console.c |    5 ++++-
 src/console/usbdebug_console.c      |    9 +++++++--
 src/cpu/x86/smm/smiutil.c           |    7 ++++---
 src/include/usbdebug.h              |    5 ++++-
 src/lib/usbdebug.c                  |   33 ++++++++++++++++++++++++++-------
 5 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c
index 25eda9b..af2944d 100644
--- a/src/arch/x86/lib/romstage_console.c
+++ b/src/arch/x86/lib/romstage_console.c
@@ -44,7 +44,7 @@ static void console_tx_byte(unsigned char byte)
 	uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
 #endif
 #if CONFIG_USBDEBUG
-	usbdebug_tx_byte(byte);
+	usbdebug_tx_byte(0, byte);
 #endif
 #if CONFIG_CONSOLE_NE2K
 	ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
@@ -65,6 +65,9 @@ static void console_tx_flush(void)
 #if CONFIG_CONSOLE_NE2K
 	ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
 #endif
+#if CONFIG_USBDEBUG
+	usbdebug_tx_flush(0);
+#endif
 }
 
 int do_printk(int msg_level, const char *fmt, ...)
diff --git a/src/console/usbdebug_console.c b/src/console/usbdebug_console.c
index a624b9d..58a62b8 100644
--- a/src/console/usbdebug_console.c
+++ b/src/console/usbdebug_console.c
@@ -55,8 +55,7 @@ static void dbgp_init(void)
 
 static void dbgp_tx_byte(unsigned char data)
 {
-	if (dbg_info.ehci_debug)
-		dbgp_bulk_write_x(&dbg_info, (char*)&data, 1);
+	usbdebug_tx_byte(&dbg_info, data);
 }
 
 static unsigned char dbgp_rx_byte(void)
@@ -69,6 +68,11 @@ static unsigned char dbgp_rx_byte(void)
 	return data;
 }
 
+static void dbgp_tx_flush(void)
+{
+	usbdebug_tx_flush(&dbg_info);
+}
+
 static int dbgp_tst_byte(void)
 {
 	return (int)dbg_info.ehci_debug;
@@ -77,6 +81,7 @@ static int dbgp_tst_byte(void)
 static const struct console_driver usbdebug_direct_console __console = {
 	.init     = dbgp_init,
 	.tx_byte  = dbgp_tx_byte,
+	.tx_flush = dbgp_tx_flush,
 	.rx_byte  = dbgp_rx_byte,
 	.tst_byte = dbgp_tst_byte,
 };
diff --git a/src/cpu/x86/smm/smiutil.c b/src/cpu/x86/smm/smiutil.c
index 9cd63ed..1d2c86f 100644
--- a/src/cpu/x86/smm/smiutil.c
+++ b/src/cpu/x86/smm/smiutil.c
@@ -32,8 +32,9 @@ static u32 serial8250mem_base_address = 0;
 
 void console_tx_flush(void)
 {
-	// the tx_byte functions take care of the flush.
-	// if not, this should be implemented.
+#if CONFIG_USBDEBUG
+	usbdebug_tx_flush(0);
+#endif
 }
 
 void console_tx_byte(unsigned char byte)
@@ -49,7 +50,7 @@ void console_tx_byte(unsigned char byte)
 	uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
 #endif
 #if CONFIG_USBDEBUG
-	usbdebug_tx_byte(byte);
+	usbdebug_tx_byte(0, byte);
 #endif
 #if CONFIG_CONSOLE_NE2K
 	ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
diff --git a/src/include/usbdebug.h b/src/include/usbdebug.h
index a7ab21f..8caf361 100644
--- a/src/include/usbdebug.h
+++ b/src/include/usbdebug.h
@@ -30,6 +30,8 @@ struct ehci_debug_info {
         u32 devnum;
         u32 endpoint_out;
         u32 endpoint_in;
+        char buf[8];
+        u8 bufidx;
 };
 
 #ifndef __ROMCC__
@@ -41,7 +43,8 @@ void set_ehci_debug(unsigned ehci_debug);
 unsigned get_ehci_debug(void);
 void set_debug_port(unsigned port);
 int early_usbdebug_init(void);
-void usbdebug_tx_byte(unsigned char data);
+void usbdebug_tx_byte(struct ehci_debug_info *info, unsigned char data);
+void usbdebug_tx_flush(struct ehci_debug_info *info);
 int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *info);
 #endif
 #endif
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index 800ee52..fd23426 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -377,7 +377,7 @@ int usbdebug_init(unsigned ehci_bar, unsigned offset, struct ehci_debug_info *in
 			HC_LENGTH(read32((unsigned long)&ehci_caps->hc_capbase)));
 	ehci_debug = (struct ehci_dbg_port *)(ehci_bar + offset);
 	info->ehci_debug = (void *)0;
-
+	info->bufidx = 0;
 try_next_time:
 	port_map_tried = 0;
 
@@ -573,15 +573,34 @@ int early_usbdebug_init(void)
 	return usbdebug_init(CONFIG_EHCI_BAR, CONFIG_EHCI_DEBUG_OFFSET, dbg_info);
 }
 
-void usbdebug_tx_byte(unsigned char data)
+void usbdebug_tx_byte(struct ehci_debug_info *dbg_info, unsigned char data)
 {
-	struct ehci_debug_info *dbg_info;
 
-	/* "Find" dbg_info structure in Cache */
-	dbg_info = (struct ehci_debug_info *)
-	    (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
+	if (!dbg_info) {
+		/* "Find" dbg_info structure in Cache */
+		dbg_info = (struct ehci_debug_info *)
+		    (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
+	}
 
 	if (dbg_info->ehci_debug) {
-		dbgp_bulk_write_x(dbg_info, (char*)&data, 1);
+		dbg_info->buf[dbg_info->bufidx++] = data;
+		if (dbg_info->bufidx >= 8) {
+			dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx);
+			dbg_info->bufidx = 0;
+		}
+	}
+}
+
+void usbdebug_tx_flush(struct ehci_debug_info *dbg_info)
+{
+	if (!dbg_info) {
+		/* "Find" dbg_info structure in Cache */
+		dbg_info = (struct ehci_debug_info *)
+		    (CONFIG_DCACHE_RAM_BASE + CONFIG_DCACHE_RAM_SIZE - sizeof(struct ehci_debug_info));
+	}
+
+	if (dbg_info->ehci_debug && dbg_info->bufidx > 0) {
+		dbgp_bulk_write_x(dbg_info, dbg_info->buf, dbg_info->bufidx);
+		dbg_info->bufidx = 0;
 	}
 }




More information about the coreboot mailing list