From e7a2b839cb0075e1dcf6328a8afb507956e6ef9a Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 11 Jun 2001 11:48:58 +0000 Subject: Support for GDB console for the Ocelot. --- arch/mips/config.in | 1 + arch/mips/defconfig-atlas | 1 + arch/mips/defconfig-ddb5476 | 1 + arch/mips/defconfig-ddb5477 | 1 + arch/mips/defconfig-decstation | 1 + arch/mips/defconfig-ev64120 | 1 + arch/mips/defconfig-ev96100 | 1 + arch/mips/defconfig-it8172 | 1 + arch/mips/defconfig-malta | 1 + arch/mips/defconfig-ocelot | 1 + arch/mips/defconfig-pb1000 | 1 + arch/mips/gt64120/momenco_ocelot/irq.c | 3 +++ arch/mips/kernel/gdb-stub.c | 47 ++++++++++++++++++++++++++++++++++ 13 files changed, 61 insertions(+) diff --git a/arch/mips/config.in b/arch/mips/config.in index 186d36346..e9a077e3b 100644 --- a/arch/mips/config.in +++ b/arch/mips/config.in @@ -492,6 +492,7 @@ if [ "$CONFIG_MODULES" = "y" ]; then fi if [ "$CONFIG_SERIAL" = "y" -o "$CONFIG_AU1000_UART" = "y" ]; then bool 'Remote GDB kernel debugging' CONFIG_REMOTE_DEBUG + dep_bool 'Console output to GDB' CONFIG_GDB_CONSOLE $CONFIG_REMOTE_DEBUG fi if [ "$CONFIG_SERIAL" = "y" ]; then bool 'Low-level debugging' CONFIG_LL_DEBUG diff --git a/arch/mips/defconfig-atlas b/arch/mips/defconfig-atlas index 2c739d374..4942a084b 100644 --- a/arch/mips/defconfig-atlas +++ b/arch/mips/defconfig-atlas @@ -482,6 +482,7 @@ CONFIG_MSDOS_PARTITION=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-ddb5476 b/arch/mips/defconfig-ddb5476 index d1f2703fe..d51ac4e8f 100644 --- a/arch/mips/defconfig-ddb5476 +++ b/arch/mips/defconfig-ddb5476 @@ -553,6 +553,7 @@ CONFIG_FONT_8x16=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-ddb5477 b/arch/mips/defconfig-ddb5477 index c48c6b910..660f73040 100644 --- a/arch/mips/defconfig-ddb5477 +++ b/arch/mips/defconfig-ddb5477 @@ -444,6 +444,7 @@ CONFIG_MSDOS_PARTITION=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set CONFIG_LL_DEBUG=y # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-decstation b/arch/mips/defconfig-decstation index 5377a15cf..e50e936e9 100644 --- a/arch/mips/defconfig-decstation +++ b/arch/mips/defconfig-decstation @@ -478,6 +478,7 @@ CONFIG_ULTRIX_PARTITION=y CONFIG_CROSSCOMPILE=y # CONFIG_MIPS_FPE_MODULE is not set # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-ev64120 b/arch/mips/defconfig-ev64120 index 38f5e310e..2382390c9 100644 --- a/arch/mips/defconfig-ev64120 +++ b/arch/mips/defconfig-ev64120 @@ -459,6 +459,7 @@ CONFIG_MSDOS_PARTITION=y CONFIG_CROSSCOMPILE=y # CONFIG_MIPS_FPE_MODULE is not set # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-ev96100 b/arch/mips/defconfig-ev96100 index 692c410dc..1e9a9dd7a 100644 --- a/arch/mips/defconfig-ev96100 +++ b/arch/mips/defconfig-ev96100 @@ -449,6 +449,7 @@ CONFIG_MSDOS_PARTITION=y CONFIG_CROSSCOMPILE=y # CONFIG_MIPS_FPE_MODULE is not set # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-it8172 b/arch/mips/defconfig-it8172 index c69a210e6..3cf7e23bc 100644 --- a/arch/mips/defconfig-it8172 +++ b/arch/mips/defconfig-it8172 @@ -584,6 +584,7 @@ CONFIG_MSDOS_PARTITION=y CONFIG_CROSSCOMPILE=y # CONFIG_MIPS_FPE_MODULE is not set # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-malta b/arch/mips/defconfig-malta index c41368745..37070db89 100644 --- a/arch/mips/defconfig-malta +++ b/arch/mips/defconfig-malta @@ -508,6 +508,7 @@ CONFIG_MSDOS_PARTITION=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-ocelot b/arch/mips/defconfig-ocelot index ca08241b9..e0626c3e0 100644 --- a/arch/mips/defconfig-ocelot +++ b/arch/mips/defconfig-ocelot @@ -446,6 +446,7 @@ CONFIG_MSDOS_PARTITION=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_LL_DEBUG is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/defconfig-pb1000 b/arch/mips/defconfig-pb1000 index e0f3befa2..6c0b2b03a 100644 --- a/arch/mips/defconfig-pb1000 +++ b/arch/mips/defconfig-pb1000 @@ -443,5 +443,6 @@ CONFIG_SGI_PARTITION=y # CONFIG_CROSSCOMPILE=y # CONFIG_REMOTE_DEBUG is not set +# CONFIG_GDB_CONSOLE is not set # CONFIG_MAGIC_SYSRQ is not set # CONFIG_MIPS_UNCACHED is not set diff --git a/arch/mips/gt64120/momenco_ocelot/irq.c b/arch/mips/gt64120/momenco_ocelot/irq.c index d93b86a7b..c6c01b0d3 100644 --- a/arch/mips/gt64120/momenco_ocelot/irq.c +++ b/arch/mips/gt64120/momenco_ocelot/irq.c @@ -155,6 +155,9 @@ void momenco_ocelot_irq_setup(void) printk("start kgdb ...\n"); set_debug_traps(); breakpoint(); /* you may move this line to whereever you want :-) */ +#ifdef CONFIG_GDB_CONSOLE + register_gdb_console(); +#endif } #endif } diff --git a/arch/mips/kernel/gdb-stub.c b/arch/mips/kernel/gdb-stub.c index f86da1881..0a961dd47 100644 --- a/arch/mips/kernel/gdb-stub.c +++ b/arch/mips/kernel/gdb-stub.c @@ -126,6 +126,8 @@ #include #include #include +#include +#include #include #include @@ -402,6 +404,7 @@ void set_debug_traps(void) for (ht = hard_trap_info; ht->tt && ht->signo; ht++) set_except_vector(ht->tt, trap_low); + putDebugChar('+'); /* 'hello world' */ /* * In case GDB is started before us, ack any packets * (presumably "$?#xx") sitting there. @@ -955,3 +958,47 @@ void adel(void) lw $9,0($8) "); } + +#ifdef CONFIG_GDB_CONSOLE + +void gdb_puts(const char *str) +{ + int l = strlen(str); + char outbuf[18]; + + outbuf[0]='O'; + + while(l) { + int i = (l>8)?8:l; + mem2hex((char *)str, &outbuf[1], i, 0); + outbuf[(i*2)+1]=0; + putpacket(outbuf); + str += i; + l -= i; + } +} + +static kdev_t gdb_console_dev(struct console *con) +{ + return MKDEV(1, 3); /* /dev/null */ +} + +static void gdb_console_write(struct console *con, const char *s, unsigned n) +{ + gdb_puts(s); +} + +static struct console gdb_console = { + name: "gdb", + write: gdb_console_write, + device: gdb_console_dev, + flags: CON_PRINTBUFFER, + index: -1 +}; + +__init void register_gdb_console(void) +{ + register_console(&gdb_console); +} + +#endif -- cgit v1.2.3