diff options
author | Jason Wessel <jason.wessel@windriver.com> | 2010-08-05 10:22:21 -0400 |
---|---|---|
committer | Jason Wessel <jason.wessel@windriver.com> | 2010-08-05 10:22:21 -0400 |
commit | 22eeef4bb2a7fd225089c0044060ed1fbf091958 (patch) | |
tree | b669e367963a9d0d6f331f28a157415dffa997a2 /arch/arm | |
parent | 0896a9becdea36b2da21709b5e73ba47ae6481ea (diff) |
kgdb,arm: Individual register get/set for arm
Implement the ability to individually get and set registers for kdb
and kgdb for arm.
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
CC: Russell King <linux@arm.linux.org.uk>
CC: linux-arm-kernel@lists.infradead.org
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/include/asm/kgdb.h | 6 | ||||
-rw-r--r-- | arch/arm/kernel/kgdb.c | 90 |
2 files changed, 50 insertions, 46 deletions
diff --git a/arch/arm/include/asm/kgdb.h b/arch/arm/include/asm/kgdb.h index 67af4b841984..08265993227f 100644 --- a/arch/arm/include/asm/kgdb.h +++ b/arch/arm/include/asm/kgdb.h | |||
@@ -70,11 +70,11 @@ extern int kgdb_fault_expected; | |||
70 | #define _GP_REGS 16 | 70 | #define _GP_REGS 16 |
71 | #define _FP_REGS 8 | 71 | #define _FP_REGS 8 |
72 | #define _EXTRA_REGS 2 | 72 | #define _EXTRA_REGS 2 |
73 | #define GDB_MAX_REGS (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS) | 73 | #define DBG_MAX_REG_NUM (_GP_REGS + (_FP_REGS * 3) + _EXTRA_REGS) |
74 | 74 | ||
75 | #define KGDB_MAX_NO_CPUS 1 | 75 | #define KGDB_MAX_NO_CPUS 1 |
76 | #define BUFMAX 400 | 76 | #define BUFMAX 400 |
77 | #define NUMREGBYTES (GDB_MAX_REGS << 2) | 77 | #define NUMREGBYTES (DBG_MAX_REG_NUM << 2) |
78 | #define NUMCRITREGBYTES (32 << 2) | 78 | #define NUMCRITREGBYTES (32 << 2) |
79 | 79 | ||
80 | #define _R0 0 | 80 | #define _R0 0 |
@@ -93,7 +93,7 @@ extern int kgdb_fault_expected; | |||
93 | #define _SPT 13 | 93 | #define _SPT 13 |
94 | #define _LR 14 | 94 | #define _LR 14 |
95 | #define _PC 15 | 95 | #define _PC 15 |
96 | #define _CPSR (GDB_MAX_REGS - 1) | 96 | #define _CPSR (DBG_MAX_REG_NUM - 1) |
97 | 97 | ||
98 | /* | 98 | /* |
99 | * So that we can denote the end of a frame for tracing, | 99 | * So that we can denote the end of a frame for tracing, |
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c index c868a8864117..cf846cade354 100644 --- a/arch/arm/kernel/kgdb.c +++ b/arch/arm/kernel/kgdb.c | |||
@@ -13,54 +13,58 @@ | |||
13 | #include <linux/kgdb.h> | 13 | #include <linux/kgdb.h> |
14 | #include <asm/traps.h> | 14 | #include <asm/traps.h> |
15 | 15 | ||
16 | /* Make a local copy of the registers passed into the handler (bletch) */ | 16 | struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = |
17 | void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs) | ||
18 | { | 17 | { |
19 | int regno; | 18 | { "r0", 4, offsetof(struct pt_regs, ARM_r0)}, |
20 | 19 | { "r1", 4, offsetof(struct pt_regs, ARM_r1)}, | |
21 | /* Initialize all to zero. */ | 20 | { "r2", 4, offsetof(struct pt_regs, ARM_r2)}, |
22 | for (regno = 0; regno < GDB_MAX_REGS; regno++) | 21 | { "r3", 4, offsetof(struct pt_regs, ARM_r3)}, |
23 | gdb_regs[regno] = 0; | 22 | { "r4", 4, offsetof(struct pt_regs, ARM_r4)}, |
23 | { "r5", 4, offsetof(struct pt_regs, ARM_r5)}, | ||
24 | { "r6", 4, offsetof(struct pt_regs, ARM_r6)}, | ||
25 | { "r7", 4, offsetof(struct pt_regs, ARM_r7)}, | ||
26 | { "r8", 4, offsetof(struct pt_regs, ARM_r8)}, | ||
27 | { "r9", 4, offsetof(struct pt_regs, ARM_r9)}, | ||
28 | { "r10", 4, offsetof(struct pt_regs, ARM_r10)}, | ||
29 | { "fp", 4, offsetof(struct pt_regs, ARM_fp)}, | ||
30 | { "ip", 4, offsetof(struct pt_regs, ARM_ip)}, | ||
31 | { "sp", 4, offsetof(struct pt_regs, ARM_sp)}, | ||
32 | { "lr", 4, offsetof(struct pt_regs, ARM_lr)}, | ||
33 | { "pc", 4, offsetof(struct pt_regs, ARM_pc)}, | ||
34 | { "f0", 12, -1 }, | ||
35 | { "f1", 12, -1 }, | ||
36 | { "f2", 12, -1 }, | ||
37 | { "f3", 12, -1 }, | ||
38 | { "f4", 12, -1 }, | ||
39 | { "f5", 12, -1 }, | ||
40 | { "f6", 12, -1 }, | ||
41 | { "f7", 12, -1 }, | ||
42 | { "fps", 4, -1 }, | ||
43 | { "cpsr", 4, offsetof(struct pt_regs, ARM_cpsr)}, | ||
44 | }; | ||
24 | 45 | ||
25 | gdb_regs[_R0] = kernel_regs->ARM_r0; | 46 | char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) |
26 | gdb_regs[_R1] = kernel_regs->ARM_r1; | 47 | { |
27 | gdb_regs[_R2] = kernel_regs->ARM_r2; | 48 | if (regno >= DBG_MAX_REG_NUM || regno < 0) |
28 | gdb_regs[_R3] = kernel_regs->ARM_r3; | 49 | return NULL; |
29 | gdb_regs[_R4] = kernel_regs->ARM_r4; | 50 | |
30 | gdb_regs[_R5] = kernel_regs->ARM_r5; | 51 | if (dbg_reg_def[regno].offset != -1) |
31 | gdb_regs[_R6] = kernel_regs->ARM_r6; | 52 | memcpy(mem, (void *)regs + dbg_reg_def[regno].offset, |
32 | gdb_regs[_R7] = kernel_regs->ARM_r7; | 53 | dbg_reg_def[regno].size); |
33 | gdb_regs[_R8] = kernel_regs->ARM_r8; | 54 | else |
34 | gdb_regs[_R9] = kernel_regs->ARM_r9; | 55 | memset(mem, 0, dbg_reg_def[regno].size); |
35 | gdb_regs[_R10] = kernel_regs->ARM_r10; | 56 | return dbg_reg_def[regno].name; |
36 | gdb_regs[_FP] = kernel_regs->ARM_fp; | ||
37 | gdb_regs[_IP] = kernel_regs->ARM_ip; | ||
38 | gdb_regs[_SPT] = kernel_regs->ARM_sp; | ||
39 | gdb_regs[_LR] = kernel_regs->ARM_lr; | ||
40 | gdb_regs[_PC] = kernel_regs->ARM_pc; | ||
41 | gdb_regs[_CPSR] = kernel_regs->ARM_cpsr; | ||
42 | } | 57 | } |
43 | 58 | ||
44 | /* Copy local gdb registers back to kgdb regs, for later copy to kernel */ | 59 | int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) |
45 | void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs) | ||
46 | { | 60 | { |
47 | kernel_regs->ARM_r0 = gdb_regs[_R0]; | 61 | if (regno >= DBG_MAX_REG_NUM || regno < 0) |
48 | kernel_regs->ARM_r1 = gdb_regs[_R1]; | 62 | return -EINVAL; |
49 | kernel_regs->ARM_r2 = gdb_regs[_R2]; | 63 | |
50 | kernel_regs->ARM_r3 = gdb_regs[_R3]; | 64 | if (dbg_reg_def[regno].offset != -1) |
51 | kernel_regs->ARM_r4 = gdb_regs[_R4]; | 65 | memcpy((void *)regs + dbg_reg_def[regno].offset, mem, |
52 | kernel_regs->ARM_r5 = gdb_regs[_R5]; | 66 | dbg_reg_def[regno].size); |
53 | kernel_regs->ARM_r6 = gdb_regs[_R6]; | 67 | return 0; |
54 | kernel_regs->ARM_r7 = gdb_regs[_R7]; | ||
55 | kernel_regs->ARM_r8 = gdb_regs[_R8]; | ||
56 | kernel_regs->ARM_r9 = gdb_regs[_R9]; | ||
57 | kernel_regs->ARM_r10 = gdb_regs[_R10]; | ||
58 | kernel_regs->ARM_fp = gdb_regs[_FP]; | ||
59 | kernel_regs->ARM_ip = gdb_regs[_IP]; | ||
60 | kernel_regs->ARM_sp = gdb_regs[_SPT]; | ||
61 | kernel_regs->ARM_lr = gdb_regs[_LR]; | ||
62 | kernel_regs->ARM_pc = gdb_regs[_PC]; | ||
63 | kernel_regs->ARM_cpsr = gdb_regs[_CPSR]; | ||
64 | } | 68 | } |
65 | 69 | ||
66 | void | 70 | void |