aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/kgdb.c
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-08-05 10:22:21 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-08-05 10:22:21 -0400
commit22eeef4bb2a7fd225089c0044060ed1fbf091958 (patch)
treeb669e367963a9d0d6f331f28a157415dffa997a2 /arch/arm/kernel/kgdb.c
parent0896a9becdea36b2da21709b5e73ba47ae6481ea (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/kernel/kgdb.c')
-rw-r--r--arch/arm/kernel/kgdb.c90
1 files changed, 47 insertions, 43 deletions
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) */ 16struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
17void 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; 46char *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 */ 59int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
45void 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
66void 70void