[coreboot-gerrit] New patch to review for coreboot: 1c13148 usbdebug: Split to USB host/device

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Wed Feb 12 06:19:04 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/5197

-gerrit

commit 1c1314868101a34c71a9bbaa107222913fc115cf
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sun Feb 9 23:35:39 2014 +0200

    usbdebug: Split to USB host/device
    
    Top-level interface to console over USB mut not require low-level
    details of ECHI debug port internals.
    
    Change-Id: If3ca3b1f479e3f20976cd4abd8f5e682a58d5650
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/drivers/usb/Makefile.inc |  4 +--
 src/drivers/usb/console.c    | 64 ++++++++++++++++++++++++++++++++++++++++++++
 src/drivers/usb/ehci_debug.c | 63 ++-----------------------------------------
 src/drivers/usb/ehci_debug.h | 22 +++++++++++++++
 4 files changed, 90 insertions(+), 63 deletions(-)

diff --git a/src/drivers/usb/Makefile.inc b/src/drivers/usb/Makefile.inc
index 043ebe1..bab6737 100644
--- a/src/drivers/usb/Makefile.inc
+++ b/src/drivers/usb/Makefile.inc
@@ -1,3 +1,3 @@
-romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += ehci_debug.c pci_ehci.c
+romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += ehci_debug.c pci_ehci.c console.c
 
-ramstage-$(CONFIG_USBDEBUG) += ehci_debug.c pci_ehci.c
+ramstage-$(CONFIG_USBDEBUG) += ehci_debug.c pci_ehci.c console.c
diff --git a/src/drivers/usb/console.c b/src/drivers/usb/console.c
new file mode 100644
index 0000000..c47610a
--- /dev/null
+++ b/src/drivers/usb/console.c
@@ -0,0 +1,64 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2006 Eric Biederman (ebiederm at xmission.com)
+ * Copyright (C) 2007 AMD
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include <console/console.h>
+#include <console/usb.h>
+#include "ehci_debug.h"
+
+void usbdebug_tx_byte(struct dbgp_pipe *pipe, unsigned char data)
+{
+	if (!dbgp_try_get(pipe))
+		return;
+	pipe->buf[pipe->bufidx++] = data;
+	if (pipe->bufidx >= 8) {
+		dbgp_bulk_write_x(pipe, pipe->buf, pipe->bufidx);
+		pipe->bufidx = 0;
+	}
+	dbgp_put(pipe);
+}
+
+void usbdebug_tx_flush(struct dbgp_pipe *pipe)
+{
+	if (!dbgp_try_get(pipe))
+		return;
+	if (pipe->bufidx > 0) {
+		dbgp_bulk_write_x(pipe, pipe->buf, pipe->bufidx);
+		pipe->bufidx = 0;
+	}
+	dbgp_put(pipe);
+}
+
+unsigned char usbdebug_rx_byte(struct dbgp_pipe *pipe)
+{
+	unsigned char data = 0xff;
+	if (!dbgp_try_get(pipe))
+		return 0xff;
+	while (pipe->bufidx >= pipe->buflen) {
+		pipe->buflen = 0;
+		pipe->bufidx = 0;
+		int count = dbgp_bulk_read_x(pipe, pipe->buf, 8);
+		if (count>0)
+			pipe->buflen = count;
+	}
+	data = pipe->buf[pipe->bufidx++];
+	dbgp_put(pipe);
+	return data;
+}
diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c
index beb553e..c60fbaa 100644
--- a/src/drivers/usb/ehci_debug.c
+++ b/src/drivers/usb/ehci_debug.c
@@ -31,25 +31,6 @@
 #include "usb_ch9.h"
 #include "ehci.h"
 
-
-#define DBGP_EP_VALID		(1<<0)
-#define DBGP_EP_ENABLED		(1<<1)
-#define DBGP_EP_BUSY		(1<<2)
-#define DBGP_EP_STATMASK	(DBGP_EP_VALID | DBGP_EP_ENABLED)
-
-struct dbgp_pipe
-{
-	u8 devnum;
-	u8 endpoint;
-	u8 pid;
-	u8 status;
-	int timeout;
-
-	u8 bufidx;
-	u8 buflen;
-	char buf[8];
-};
-
 #define DBGP_MAX_ENDPOINTS	4
 #define DBGP_SETUP_EP0		0	/* Compulsory endpoint 0. */
 #define DBGP_CONSOLE_EPOUT	1
@@ -852,7 +833,7 @@ static int dbgp_enabled(void)
 }
 #endif
 
-static int dbgp_try_get(struct dbgp_pipe *pipe)
+int dbgp_try_get(struct dbgp_pipe *pipe)
 {
 	struct dbgp_pipe *globals = &dbgp_ehci_info()->ep_pipe[DBGP_SETUP_EP0];
 	if (!dbgp_ep_is_active(pipe) || (globals->status & DBGP_EP_BUSY))
@@ -862,53 +843,13 @@ static int dbgp_try_get(struct dbgp_pipe *pipe)
 	return 1;
 }
 
-static void dbgp_put(struct dbgp_pipe *pipe)
+void dbgp_put(struct dbgp_pipe *pipe)
 {
 	struct dbgp_pipe *globals = &dbgp_ehci_info()->ep_pipe[DBGP_SETUP_EP0];
 	globals->status &= ~DBGP_EP_BUSY;
 	pipe->status &= ~DBGP_EP_BUSY;
 }
 
-void usbdebug_tx_byte(struct dbgp_pipe *pipe, unsigned char data)
-{
-	if (!dbgp_try_get(pipe))
-		return;
-	pipe->buf[pipe->bufidx++] = data;
-	if (pipe->bufidx >= 8) {
-		dbgp_bulk_write_x(pipe, pipe->buf, pipe->bufidx);
-		pipe->bufidx = 0;
-	}
-	dbgp_put(pipe);
-}
-
-void usbdebug_tx_flush(struct dbgp_pipe *pipe)
-{
-	if (!dbgp_try_get(pipe))
-		return;
-	if (pipe->bufidx > 0) {
-		dbgp_bulk_write_x(pipe, pipe->buf, pipe->bufidx);
-		pipe->bufidx = 0;
-	}
-	dbgp_put(pipe);
-}
-
-unsigned char usbdebug_rx_byte(struct dbgp_pipe *pipe)
-{
-	unsigned char data = 0xff;
-	if (!dbgp_try_get(pipe))
-		return 0xff;
-	while (pipe->bufidx >= pipe->buflen) {
-		pipe->buflen = 0;
-		pipe->bufidx = 0;
-		int count = dbgp_bulk_read_x(pipe, pipe->buf, 8);
-		if (count>0)
-			pipe->buflen = count;
-	}
-	data = pipe->buf[pipe->bufidx++];
-	dbgp_put(pipe);
-	return data;
-}
-
 #if !defined(__PRE_RAM__) && !defined(__SMM__)
 void usbdebug_re_enable(unsigned ehci_base)
 {
diff --git a/src/drivers/usb/ehci_debug.h b/src/drivers/usb/ehci_debug.h
index 2e549d2..c470ad6 100644
--- a/src/drivers/usb/ehci_debug.h
+++ b/src/drivers/usb/ehci_debug.h
@@ -27,4 +27,26 @@ void usbdebug_disable(void);
 int ehci_debug_hw_enable(unsigned *base, unsigned *dbg_offset);
 void ehci_debug_select_port(unsigned int port);
 
+
+#define DBGP_EP_VALID		(1<<0)
+#define DBGP_EP_ENABLED		(1<<1)
+#define DBGP_EP_BUSY		(1<<2)
+#define DBGP_EP_STATMASK	(DBGP_EP_VALID | DBGP_EP_ENABLED)
+
+struct dbgp_pipe
+{
+	u8 devnum;
+	u8 endpoint;
+	u8 pid;
+	u8 status;
+	int timeout;
+
+	u8 bufidx;
+	u8 buflen;
+	char buf[8];
+};
+
+void dbgp_put(struct dbgp_pipe *pipe);
+int dbgp_try_get(struct dbgp_pipe *pipe);
+
 #endif /* _EHCI_DEBUG_H_ */



More information about the coreboot-gerrit mailing list