[coreboot-gerrit] Patch set updated for coreboot: 944db97 console: Add console for GDB
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Mon Apr 7 05:41:40 CEST 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/5343
-gerrit
commit 944db975f29a25b8b19dd717a032c6c839e7b4b3
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Fri Apr 4 15:05:28 2014 +0300
console: Add console for GDB
Change-Id: I90e05e8132889e788b92e055ee191f35add43bbc
Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
src/arch/x86/lib/c_start.S | 1 +
src/arch/x86/lib/exception.c | 13 +++++++++++--
src/console/console.c | 24 ++++++++++++++++++++++++
src/include/console/streams.h | 6 ++++++
src/include/console/uart.h | 8 ++++++++
src/include/console/usb.h | 15 +++++++++++++--
6 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/src/arch/x86/lib/c_start.S b/src/arch/x86/lib/c_start.S
index faea22d..675a09c 100644
--- a/src/arch/x86/lib/c_start.S
+++ b/src/arch/x86/lib/c_start.S
@@ -86,6 +86,7 @@ _start:
post_code(POST_PRE_HARDWAREMAIN) /* post fe */
#if CONFIG_GDB_WAIT
+ call gdb_hw_init
call gdb_stub_breakpoint
#endif
call main
diff --git a/src/arch/x86/lib/exception.c b/src/arch/x86/lib/exception.c
index 9756949..f64b2e7 100644
--- a/src/arch/x86/lib/exception.c
+++ b/src/arch/x86/lib/exception.c
@@ -1,4 +1,5 @@
#include <console/console.h>
+#include <console/streams.h>
#include <string.h>
#if CONFIG_GDB_STUB
@@ -217,12 +218,17 @@ static char out_buffer[BUFMAX];
static inline void stub_putc(int ch)
{
- console_tx_byte(ch);
+ gdb_tx_byte(ch);
+}
+
+static inline void stub_flush(void)
+{
+ gdb_tx_flush();
}
static inline int stub_getc(void)
{
- return console_rx_byte();
+ return gdb_rx_byte();
}
static int hex(char ch)
@@ -322,9 +328,11 @@ static int get_packet(char *buffer)
if (checksum != xmitcsum) {
stub_putc('-'); /* failed checksum */
+ stub_flush();
}
else {
stub_putc('+'); /* successful transfer */
+ stub_flush();
}
}
} while(checksum != xmitcsum);
@@ -353,6 +361,7 @@ static void put_packet(char *buffer)
stub_putc('#');
stub_putc(hexchars[checksum >> 4]);
stub_putc(hexchars[checksum % 16]);
+ stub_flush();
} while ((stub_getc() & 0x7f) != '+');
diff --git a/src/console/console.c b/src/console/console.c
index cd72596..396ca07 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -54,6 +54,30 @@ void console_tx_flush(void)
__usb_tx_flush();
}
+
+#if CONFIG_GDB_STUB && !defined(__SMM__)
+void gdb_hw_init(void)
+{
+ __gdb_hw_init();
+}
+
+void gdb_tx_byte(unsigned char byte)
+{
+ __gdb_tx_byte(byte);
+}
+
+void gdb_tx_flush(void)
+{
+ __gdb_tx_flush();
+}
+
+unsigned char gdb_rx_byte(void)
+{
+ return __gdb_rx_byte();
+}
+#endif
+
+
void console_tx_nibble(unsigned nibble)
{
unsigned char digit;
diff --git a/src/include/console/streams.h b/src/include/console/streams.h
index 9d4d3fc..fb168da 100644
--- a/src/include/console/streams.h
+++ b/src/include/console/streams.h
@@ -22,6 +22,12 @@ void console_hw_init(void);
void console_tx_byte(unsigned char byte);
void console_tx_flush(void);
+/* For remote GDB debugging. */
+void gdb_hw_init(void);
+void gdb_tx_byte(unsigned char byte);
+void gdb_tx_flush(void);
+unsigned char gdb_rx_byte(void);
+
/* Helpers for ROMCC console. */
void console_tx_nibble(unsigned nibble);
void console_tx_hex8(unsigned char value);
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 5a9cce3..db1109c 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -67,4 +67,12 @@ static inline void __uart_tx_byte(u8 data) {}
static inline void __uart_tx_flush(void) {}
#endif
+#if 0 && CONFIG_GDB_STUB && (ENV_ROMSTAGE || ENV_RAMSTAGE)
+#define CONFIG_UART_FOR_GDB 0
+static inline void __gdb_hw_init(void) { uart_init(CONFIG_UART_FOR_GDB); }
+static inline void __gdb_tx_byte(u8 data) { uart_tx_byte(CONFIG_UART_FOR_GDB, data); }
+static inline void __gdb_tx_flush(void) { uart_tx_flush(CONFIG_UART_FOR_GDB); }
+static inline u8 __gdb_rx_byte(void) { return uart_rx_byte(CONFIG_UART_FOR_GDB); }
+#endif
+
#endif /* CONSOLE_UART_H */
diff --git a/src/include/console/usb.h b/src/include/console/usb.h
index e64e43e..42887a8 100644
--- a/src/include/console/usb.h
+++ b/src/include/console/usb.h
@@ -34,14 +34,25 @@ int usb_can_rx_byte(int idx);
#define __CONSOLE_USB_ENABLE__ CONFIG_CONSOLE_USB && \
((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE)
+#define USB_PIPE_FOR_CONSOLE 0
+#define USB_PIPE_FOR_GDB 0
+
#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); }
+static inline void __usb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_CONSOLE, data); }
+static inline void __usb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_CONSOLE); }
#else
static inline void __usbdebug_init(void) {}
static inline void __usb_tx_byte(u8 data) {}
static inline void __usb_tx_flush(void) {}
#endif
+#if 0 && CONFIG_GDB_STUB_USB && \
+ ((ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE) || ENV_RAMSTAGE)
+static inline void __gdb_hw_init(void) { usbdebug_init(); }
+static inline void __gdb_tx_byte(u8 data) { usb_tx_byte(USB_PIPE_FOR_GDB, data); }
+static inline void __gdb_tx_flush(void) { usb_tx_flush(USB_PIPE_FOR_GDB); }
+static inline u8 __gdb_rx_byte(void) { return usb_rx_byte(USB_PIPE_FOR_GDB); }
+#endif
+
#endif /* _CONSOLE_USB_H_ */
More information about the coreboot-gerrit
mailing list