diff options
author | David S. Miller <davem@davemloft.net> | 2008-04-29 05:38:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-29 05:38:50 -0400 |
commit | e2fdd7fd99dd68b77caaf2a2272b75b5da890de7 (patch) | |
tree | d2b6d3a9b50e4d2ced793430d2b1414f790666a3 /include | |
parent | 4d7ffa49909a830f5f926a3280731d01e29f31fb (diff) |
sparc: Add kgdb support.
Current limitations:
1) On SMP single stepping has some fundamental issues,
shared with other sw single-step architectures such
as mips and arm.
2) On 32-bit sparc we don't support SMP kgdb yet. That
requires some reworking of the IPI mechanisms and
infrastructure on that platform.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sparc/head.h | 11 | ||||
-rw-r--r-- | include/asm-sparc/kgdb.h | 116 | ||||
-rw-r--r-- | include/asm-sparc/system.h | 2 | ||||
-rw-r--r-- | include/asm-sparc64/kgdb.h | 1 | ||||
-rw-r--r-- | include/asm-sparc64/system.h | 5 | ||||
-rw-r--r-- | include/asm-sparc64/ttable.h | 6 |
6 files changed, 53 insertions, 88 deletions
diff --git a/include/asm-sparc/head.h b/include/asm-sparc/head.h index fcdba5116339..e6532c3e09c9 100644 --- a/include/asm-sparc/head.h +++ b/include/asm-sparc/head.h | |||
@@ -52,6 +52,17 @@ | |||
52 | nop; \ | 52 | nop; \ |
53 | nop; | 53 | nop; |
54 | 54 | ||
55 | #ifdef CONFIG_KGDB | ||
56 | #define KGDB_TRAP(num) \ | ||
57 | b kgdb_trap_low; \ | ||
58 | rd %psr,%l0; \ | ||
59 | nop; \ | ||
60 | nop; | ||
61 | #else | ||
62 | #define KGDB_TRAP(num) \ | ||
63 | BAD_TRAP(num) | ||
64 | #endif | ||
65 | |||
55 | /* The Get Condition Codes software trap for userland. */ | 66 | /* The Get Condition Codes software trap for userland. */ |
56 | #define GETCC_TRAP \ | 67 | #define GETCC_TRAP \ |
57 | b getcc_trap_handler; mov %psr, %l0; nop; nop; | 68 | b getcc_trap_handler; mov %psr, %l0; nop; nop; |
diff --git a/include/asm-sparc/kgdb.h b/include/asm-sparc/kgdb.h index d120adfb429f..b6ef301d05bf 100644 --- a/include/asm-sparc/kgdb.h +++ b/include/asm-sparc/kgdb.h | |||
@@ -1,94 +1,38 @@ | |||
1 | /* $Id: kgdb.h,v 1.8 1998/01/07 06:33:44 baccala Exp $ | ||
2 | * kgdb.h: Defines and declarations for serial line source level | ||
3 | * remote debugging of the Linux kernel using gdb. | ||
4 | * | ||
5 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | ||
6 | */ | ||
7 | #ifndef _SPARC_KGDB_H | 1 | #ifndef _SPARC_KGDB_H |
8 | #define _SPARC_KGDB_H | 2 | #define _SPARC_KGDB_H |
9 | 3 | ||
10 | #ifndef __ASSEMBLY__ | 4 | #ifdef CONFIG_SPARC32 |
11 | /* To init the kgdb engine. */ | 5 | #define BUFMAX 2048 |
12 | extern void set_debug_traps(void); | 6 | #else |
13 | 7 | #define BUFMAX 4096 | |
14 | /* To enter the debugger explicitly. */ | 8 | #endif |
15 | extern void breakpoint(void); | 9 | |
16 | 10 | enum regnames { | |
17 | /* For convenience we define the format of a kgdb trap breakpoint | 11 | GDB_G0, GDB_G1, GDB_G2, GDB_G3, GDB_G4, GDB_G5, GDB_G6, GDB_G7, |
18 | * frame here also. | 12 | GDB_O0, GDB_O1, GDB_O2, GDB_O3, GDB_O4, GDB_O5, GDB_SP, GDB_O7, |
19 | */ | 13 | GDB_L0, GDB_L1, GDB_L2, GDB_L3, GDB_L4, GDB_L5, GDB_L6, GDB_L7, |
20 | struct kgdb_frame { | 14 | GDB_I0, GDB_I1, GDB_I2, GDB_I3, GDB_I4, GDB_I5, GDB_FP, GDB_I7, |
21 | unsigned long globals[8]; | 15 | GDB_F0, |
22 | unsigned long outs[8]; | 16 | GDB_F31 = GDB_F0 + 31, |
23 | unsigned long locals[8]; | 17 | #ifdef CONFIG_SPARC32 |
24 | unsigned long ins[8]; | 18 | GDB_Y, GDB_PSR, GDB_WIM, GDB_TBR, GDB_PC, GDB_NPC, |
25 | unsigned long fpregs[32]; | 19 | GDB_FSR, GDB_CSR, |
26 | unsigned long y; | 20 | #else |
27 | unsigned long psr; | 21 | GDB_F32 = GDB_F0 + 32, |
28 | unsigned long wim; | 22 | GDB_F62 = GDB_F32 + 15, |
29 | unsigned long tbr; | 23 | GDB_PC, GDB_NPC, GDB_STATE, GDB_FSR, GDB_FPRS, GDB_Y, |
30 | unsigned long pc; | 24 | #endif |
31 | unsigned long npc; | ||
32 | unsigned long fpsr; | ||
33 | unsigned long cpsr; | ||
34 | }; | 25 | }; |
35 | #endif /* !(__ASSEMBLY__) */ | ||
36 | |||
37 | /* Macros for assembly usage of the kgdb breakpoint frame. */ | ||
38 | #define KGDB_G0 0x000 | ||
39 | #define KGDB_G1 0x004 | ||
40 | #define KGDB_G2 0x008 | ||
41 | #define KGDB_G4 0x010 | ||
42 | #define KGDB_G6 0x018 | ||
43 | #define KGDB_I0 0x020 | ||
44 | #define KGDB_I2 0x028 | ||
45 | #define KGDB_I4 0x030 | ||
46 | #define KGDB_I6 0x038 | ||
47 | #define KGDB_Y 0x100 | ||
48 | #define KGDB_PSR 0x104 | ||
49 | #define KGDB_WIM 0x108 | ||
50 | #define KGDB_TBR 0x10c | ||
51 | #define KGDB_PC 0x110 | ||
52 | #define KGDB_NPC 0x114 | ||
53 | |||
54 | #define SAVE_KGDB_GLOBALS(reg) \ | ||
55 | std %g0, [%reg + STACKFRAME_SZ + KGDB_G0]; \ | ||
56 | std %g2, [%reg + STACKFRAME_SZ + KGDB_G2]; \ | ||
57 | std %g4, [%reg + STACKFRAME_SZ + KGDB_G4]; \ | ||
58 | std %g6, [%reg + STACKFRAME_SZ + KGDB_G6]; | ||
59 | |||
60 | #define SAVE_KGDB_INS(reg) \ | ||
61 | std %i0, [%reg + STACKFRAME_SZ + KGDB_I0]; \ | ||
62 | std %i2, [%reg + STACKFRAME_SZ + KGDB_I2]; \ | ||
63 | std %i4, [%reg + STACKFRAME_SZ + KGDB_I4]; \ | ||
64 | std %i6, [%reg + STACKFRAME_SZ + KGDB_I6]; | ||
65 | |||
66 | #define SAVE_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \ | ||
67 | st %reg_y, [%reg + STACKFRAME_SZ + KGDB_Y]; \ | ||
68 | st %reg_psr, [%reg + STACKFRAME_SZ + KGDB_PSR]; \ | ||
69 | st %reg_wim, [%reg + STACKFRAME_SZ + KGDB_WIM]; \ | ||
70 | st %reg_tbr, [%reg + STACKFRAME_SZ + KGDB_TBR]; \ | ||
71 | st %reg_pc, [%reg + STACKFRAME_SZ + KGDB_PC]; \ | ||
72 | st %reg_npc, [%reg + STACKFRAME_SZ + KGDB_NPC]; | ||
73 | 26 | ||
74 | #define LOAD_KGDB_GLOBALS(reg) \ | 27 | #ifdef CONFIG_SPARC32 |
75 | ld [%reg + STACKFRAME_SZ + KGDB_G1], %g1; \ | 28 | #define NUMREGBYTES ((GDB_CSR + 1) * 4) |
76 | ldd [%reg + STACKFRAME_SZ + KGDB_G2], %g2; \ | 29 | #else |
77 | ldd [%reg + STACKFRAME_SZ + KGDB_G4], %g4; \ | 30 | #define NUMREGBYTES ((GDB_Y + 1) * 8) |
78 | ldd [%reg + STACKFRAME_SZ + KGDB_G6], %g6; | 31 | #endif |
79 | 32 | ||
80 | #define LOAD_KGDB_INS(reg) \ | 33 | extern void arch_kgdb_breakpoint(void); |
81 | ldd [%reg + STACKFRAME_SZ + KGDB_I0], %i0; \ | ||
82 | ldd [%reg + STACKFRAME_SZ + KGDB_I2], %i2; \ | ||
83 | ldd [%reg + STACKFRAME_SZ + KGDB_I4], %i4; \ | ||
84 | ldd [%reg + STACKFRAME_SZ + KGDB_I6], %i6; | ||
85 | 34 | ||
86 | #define LOAD_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \ | 35 | #define BREAK_INSTR_SIZE 4 |
87 | ld [%reg + STACKFRAME_SZ + KGDB_Y], %reg_y; \ | 36 | #define CACHE_FLUSH_IS_SAFE 1 |
88 | ld [%reg + STACKFRAME_SZ + KGDB_PSR], %reg_psr; \ | ||
89 | ld [%reg + STACKFRAME_SZ + KGDB_WIM], %reg_wim; \ | ||
90 | ld [%reg + STACKFRAME_SZ + KGDB_TBR], %reg_tbr; \ | ||
91 | ld [%reg + STACKFRAME_SZ + KGDB_PC], %reg_pc; \ | ||
92 | ld [%reg + STACKFRAME_SZ + KGDB_NPC], %reg_npc; | ||
93 | 37 | ||
94 | #endif /* !(_SPARC_KGDB_H) */ | 38 | #endif /* _SPARC_KGDB_H */ |
diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h index 4e08210cd4c2..b4b024445fc9 100644 --- a/include/asm-sparc/system.h +++ b/include/asm-sparc/system.h | |||
@@ -94,6 +94,8 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr, | |||
94 | } while(0) | 94 | } while(0) |
95 | #endif | 95 | #endif |
96 | 96 | ||
97 | extern void flushw_all(void); | ||
98 | |||
97 | /* | 99 | /* |
98 | * Flush windows so that the VM switch which follows | 100 | * Flush windows so that the VM switch which follows |
99 | * would not pull the stack from under us. | 101 | * would not pull the stack from under us. |
diff --git a/include/asm-sparc64/kgdb.h b/include/asm-sparc64/kgdb.h new file mode 100644 index 000000000000..aa6532fd3a13 --- /dev/null +++ b/include/asm-sparc64/kgdb.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-sparc/kgdb.h> | |||
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h index 53eae091a171..6897ac31be41 100644 --- a/include/asm-sparc64/system.h +++ b/include/asm-sparc64/system.h | |||
@@ -180,12 +180,13 @@ do { if (test_thread_flag(TIF_PERFCTR)) { \ | |||
180 | "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ | 180 | "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ |
181 | "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ | 181 | "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ |
182 | "ldx [%%g6 + %9], %%g4\n\t" \ | 182 | "ldx [%%g6 + %9], %%g4\n\t" \ |
183 | "brz,pt %%o7, 1f\n\t" \ | 183 | "brz,pt %%o7, switch_to_pc\n\t" \ |
184 | " mov %%g7, %0\n\t" \ | 184 | " mov %%g7, %0\n\t" \ |
185 | "sethi %%hi(ret_from_syscall), %%g1\n\t" \ | 185 | "sethi %%hi(ret_from_syscall), %%g1\n\t" \ |
186 | "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \ | 186 | "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \ |
187 | " nop\n\t" \ | 187 | " nop\n\t" \ |
188 | "1:\n\t" \ | 188 | ".globl switch_to_pc\n\t" \ |
189 | "switch_to_pc:\n\t" \ | ||
189 | : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \ | 190 | : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \ |
190 | "=r" (__local_per_cpu_offset) \ | 191 | "=r" (__local_per_cpu_offset) \ |
191 | : "0" (task_thread_info(next)), \ | 192 | : "0" (task_thread_info(next)), \ |
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h index d3cc4eff39a6..1b55538b944f 100644 --- a/include/asm-sparc64/ttable.h +++ b/include/asm-sparc64/ttable.h | |||
@@ -175,6 +175,12 @@ | |||
175 | #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) | 175 | #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | #ifdef CONFIG_KGDB | ||
179 | #define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl) | ||
180 | #else | ||
181 | #define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl) | ||
182 | #endif | ||
183 | |||
178 | #define SUN4V_ITSB_MISS \ | 184 | #define SUN4V_ITSB_MISS \ |
179 | ldxa [%g0] ASI_SCRATCHPAD, %g2; \ | 185 | ldxa [%g0] ASI_SCRATCHPAD, %g2; \ |
180 | ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \ | 186 | ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \ |