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/5343
-gerrit
commit b63b6221e6a20d780fd0f66f4e3173b40227a017 Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Sun Jan 26 22:51:48 2014 +0200
console: Add console for GDB
Change-Id: I90e05e8132889e788b92e055ee191f35add43bbc Signed-off-by: Kyösti Mälkki kyosti.malkki@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 | 7 +++++++ src/include/console/usb.h | 10 ++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/src/arch/x86/lib/c_start.S b/src/arch/x86/lib/c_start.S index 01ffa7c..839f259 100644 --- a/src/arch/x86/lib/c_start.S +++ b/src/arch/x86/lib/c_start.S @@ -84,6 +84,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 550004e..cac7449 100644 --- a/src/include/console/streams.h +++ b/src/include/console/streams.h @@ -47,6 +47,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 d51bf2a..0a85213 100644 --- a/src/include/console/uart.h +++ b/src/include/console/uart.h @@ -61,4 +61,11 @@ void oxford_remap(unsigned int new_base); #define __uart_tx_flush() #endif
+#if 0 /* CONFIG_GDB_STUB_SERIAL && (ENV_ROMSTAGE || ENV_RAMSTAGE) */ +#define __gdb_hw_init() uart_init(CONFIG_GDB_PORT) +#define __gdb_tx_byte(x) uart_tx_byte(CONFIG_GDB_PORT, x); +#define __gdb_tx_flush() uart_tx_flush(CONFIG_GDB_PORT) +#define __gdb_rx_byte() uart_rx_byte(CONFIG_GDB_PORT) +#endif + #endif /* CONSOLE_UART_H */ diff --git a/src/include/console/usb.h b/src/include/console/usb.h index 31059cb..8c81e49 100644 --- a/src/include/console/usb.h +++ b/src/include/console/usb.h @@ -33,6 +33,9 @@ int usb_can_rx_byte(int idx); #define __CONSOLE_USB_ENABLE__ CONFIG_CONSOLE_USB && \ (ENV_ROMSTAGE && CONFIG_USBDEBUG_IN_ROMSTAGE || ENV_RAMSTAGE)
+#define __GDB_STUB_USB_ENABLE__ 0 /* CONFIG_GDB_STUB_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) @@ -43,4 +46,11 @@ int usb_can_rx_byte(int idx); #define __usb_tx_flush() #endif
+#if __GDB_STUB_USB_ENABLE__ +#define __gdb_hw_init() usbdebug_init() +#define __gdb_tx_byte(x) usb_tx_byte(0, x) +#define __gdb_tx_flush() usb_tx_flush(0) +#define __gdb_rx_byte() usb_rx_byte(0) +#endif + #endif /* _CONSOLE_USB_H_ */