aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sh/kernel/kgdb_stub.c45
-rw-r--r--include/asm-sh/kgdb.h12
2 files changed, 5 insertions, 52 deletions
diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c
index edd1ec214e6d..27f64b92aff0 100644
--- a/arch/sh/kernel/kgdb_stub.c
+++ b/arch/sh/kernel/kgdb_stub.c
@@ -150,13 +150,6 @@ struct kgdb_regs trap_registers;
150char kgdb_in_gdb_mode; 150char kgdb_in_gdb_mode;
151char in_nmi; /* Set during NMI to prevent reentry */ 151char in_nmi; /* Set during NMI to prevent reentry */
152int kgdb_nofault; /* Boolean to ignore bus errs (i.e. in GDB) */ 152int kgdb_nofault; /* Boolean to ignore bus errs (i.e. in GDB) */
153int kgdb_enabled = 1; /* Default to enabled, cmdline can disable */
154
155/* Exposed for user access */
156struct task_struct *kgdb_current;
157unsigned int kgdb_g_imask;
158int kgdb_trapa_val;
159int kgdb_excode;
160 153
161/* Default values for SCI (can override via kernel args in setup.c) */ 154/* Default values for SCI (can override via kernel args in setup.c) */
162#ifndef CONFIG_KGDB_DEFPORT 155#ifndef CONFIG_KGDB_DEFPORT
@@ -640,7 +633,6 @@ static void do_single_step(void)
640 633
641 /* Flush and return */ 634 /* Flush and return */
642 kgdb_flush_icache_range((long) addr, (long) addr + 2); 635 kgdb_flush_icache_range((long) addr, (long) addr + 2);
643 return;
644} 636}
645 637
646/* Undo a single step */ 638/* Undo a single step */
@@ -815,14 +807,10 @@ static void set_regs_msg(void)
815/* 807/*
816 * Bring up the ports.. 808 * Bring up the ports..
817 */ 809 */
818static int kgdb_serial_setup(void) 810static int __init kgdb_serial_setup(void)
819{ 811{
820 extern int kgdb_console_setup(struct console *co, char *options);
821 struct console dummy; 812 struct console dummy;
822 813 return kgdb_console_setup(&dummy, 0);
823 kgdb_console_setup(&dummy, 0);
824
825 return 0;
826} 814}
827#else 815#else
828#define kgdb_serial_setup() 0 816#define kgdb_serial_setup() 0
@@ -833,22 +821,6 @@ static void kgdb_command_loop(const int excep_code, const int trapa_value)
833{ 821{
834 int sigval; 822 int sigval;
835 823
836 if (excep_code == NMI_VEC) {
837#ifndef CONFIG_KGDB_NMI
838 printk(KERN_NOTICE "KGDB: Ignoring unexpected NMI?\n");
839 return;
840#else /* CONFIG_KGDB_NMI */
841 if (!kgdb_enabled) {
842 kgdb_enabled = 1;
843 kgdb_init();
844 }
845#endif /* CONFIG_KGDB_NMI */
846 }
847
848 /* Ignore if we're disabled */
849 if (!kgdb_enabled)
850 return;
851
852 /* Enter GDB mode (e.g. after detach) */ 824 /* Enter GDB mode (e.g. after detach) */
853 if (!kgdb_in_gdb_mode) { 825 if (!kgdb_in_gdb_mode) {
854 /* Do serial setup, notify user, issue preemptive ack */ 826 /* Do serial setup, notify user, issue preemptive ack */
@@ -959,18 +931,10 @@ static void handle_exception(struct pt_regs *regs)
959 931
960 /* Get excode for command loop call, user access */ 932 /* Get excode for command loop call, user access */
961 asm("stc r2_bank, %0":"=r"(excep_code)); 933 asm("stc r2_bank, %0":"=r"(excep_code));
962 kgdb_excode = excep_code;
963
964 /* Other interesting environment items for reference */
965 asm("stc r6_bank, %0":"=r"(kgdb_g_imask));
966 kgdb_current = current;
967 kgdb_trapa_val = trapa_value;
968 934
969 /* Act on the exception */ 935 /* Act on the exception */
970 kgdb_command_loop(excep_code, trapa_value); 936 kgdb_command_loop(excep_code, trapa_value);
971 937
972 kgdb_current = NULL;
973
974 /* Copy back the (maybe modified) registers */ 938 /* Copy back the (maybe modified) registers */
975 for (count = 0; count < 16; count++) 939 for (count = 0; count < 16; count++)
976 regs->regs[count] = trap_registers.regs[count]; 940 regs->regs[count] = trap_registers.regs[count];
@@ -994,11 +958,8 @@ asmlinkage void kgdb_handle_exception(unsigned long r4, unsigned long r5,
994} 958}
995 959
996/* Initialise the KGDB data structures and serial configuration */ 960/* Initialise the KGDB data structures and serial configuration */
997int kgdb_init(void) 961int __init kgdb_init(void)
998{ 962{
999 if (!kgdb_enabled)
1000 return 1;
1001
1002 in_nmi = 0; 963 in_nmi = 0;
1003 kgdb_nofault = 0; 964 kgdb_nofault = 0;
1004 stepped_opcode = 0; 965 stepped_opcode = 0;
diff --git a/include/asm-sh/kgdb.h b/include/asm-sh/kgdb.h
index 74bd0953e5ce..5334e86ccad6 100644
--- a/include/asm-sh/kgdb.h
+++ b/include/asm-sh/kgdb.h
@@ -19,8 +19,6 @@
19#include <asm/ptrace.h> 19#include <asm/ptrace.h>
20#include <asm/cacheflush.h> 20#include <asm/cacheflush.h>
21 21
22struct console;
23
24/* Same as pt_regs but has vbr in place of syscall_nr */ 22/* Same as pt_regs but has vbr in place of syscall_nr */
25struct kgdb_regs { 23struct kgdb_regs {
26 unsigned long regs[16]; 24 unsigned long regs[16];
@@ -35,10 +33,7 @@ struct kgdb_regs {
35 33
36/* State info */ 34/* State info */
37extern char kgdb_in_gdb_mode; 35extern char kgdb_in_gdb_mode;
38extern int kgdb_done_init;
39extern int kgdb_enabled;
40extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */ 36extern int kgdb_nofault; /* Ignore bus errors (in gdb mem access) */
41extern int kgdb_halt; /* Execute initial breakpoint at startup */
42extern char in_nmi; /* Debounce flag to prevent NMI reentry*/ 37extern char in_nmi; /* Debounce flag to prevent NMI reentry*/
43 38
44/* SCI */ 39/* SCI */
@@ -59,6 +54,7 @@ extern kgdb_debug_hook_t *kgdb_debug_hook;
59extern kgdb_bus_error_hook_t *kgdb_bus_err_hook; 54extern kgdb_bus_error_hook_t *kgdb_bus_err_hook;
60 55
61/* Console */ 56/* Console */
57struct console;
62void kgdb_console_write(struct console *co, const char *s, unsigned count); 58void kgdb_console_write(struct console *co, const char *s, unsigned count);
63extern int kgdb_console_setup(struct console *, char *); 59extern int kgdb_console_setup(struct console *, char *);
64 60
@@ -69,11 +65,7 @@ extern void longjmp(jmp_buf __jmpb, int __retval);
69extern int setjmp(jmp_buf __jmpb); 65extern int setjmp(jmp_buf __jmpb);
70 66
71/* Forced breakpoint */ 67/* Forced breakpoint */
72#define breakpoint() \ 68#define breakpoint() __asm__ __volatile__("trapa #0x3c")
73do { \
74 if (kgdb_enabled) \
75 __asm__ __volatile__("trapa #0x3c"); \
76} while (0)
77 69
78/* KGDB should be able to flush all kernel text space */ 70/* KGDB should be able to flush all kernel text space */
79#if defined(CONFIG_CPU_SH4) 71#if defined(CONFIG_CPU_SH4)