diff options
author | Paul Mundt <lethal@linux-sh.org> | 2012-04-10 00:42:56 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-04-10 00:42:56 -0400 |
commit | fd03e81812a8fb6121773226a4e0c702926077ae (patch) | |
tree | 348d78917b2aa6118bd7392ef3d6153e2552dff9 /arch/sh/kernel/kgdb.c | |
parent | 14f087d839d9bd3f90ad69d4b3fde7d236c156b1 (diff) |
sh: kgdb: Individual register get/set support.
This updates sh following the generic kgdb changes adding support
for individual register get/set for kgdb/kdb use.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/kgdb.c')
-rw-r--r-- | arch/sh/kernel/kgdb.c | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/arch/sh/kernel/kgdb.c b/arch/sh/kernel/kgdb.c index 93458880acad..d25b5ed68b24 100644 --- a/arch/sh/kernel/kgdb.c +++ b/arch/sh/kernel/kgdb.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * SuperH KGDB support | 2 | * SuperH KGDB support |
3 | * | 3 | * |
4 | * Copyright (C) 2008 - 2009 Paul Mundt | 4 | * Copyright (C) 2008 - 2012 Paul Mundt |
5 | * | 5 | * |
6 | * Single stepping taken from the old stub by Henry Bell and Jeremy Siegel. | 6 | * Single stepping taken from the old stub by Henry Bell and Jeremy Siegel. |
7 | * | 7 | * |
@@ -164,36 +164,60 @@ static void undo_single_step(struct pt_regs *linux_regs) | |||
164 | stepped_opcode = 0; | 164 | stepped_opcode = 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs) | 167 | struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { |
168 | { | 168 | { "r0", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[0]) }, |
169 | int i; | 169 | { "r1", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[1]) }, |
170 | { "r2", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[2]) }, | ||
171 | { "r3", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[3]) }, | ||
172 | { "r4", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[4]) }, | ||
173 | { "r5", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[5]) }, | ||
174 | { "r6", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[6]) }, | ||
175 | { "r7", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[7]) }, | ||
176 | { "r8", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[8]) }, | ||
177 | { "r9", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[9]) }, | ||
178 | { "r10", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[10]) }, | ||
179 | { "r11", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[11]) }, | ||
180 | { "r12", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[12]) }, | ||
181 | { "r13", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[13]) }, | ||
182 | { "r14", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[14]) }, | ||
183 | { "r15", GDB_SIZEOF_REG, offsetof(struct pt_regs, regs[15]) }, | ||
184 | { "pc", GDB_SIZEOF_REG, offsetof(struct pt_regs, pc) }, | ||
185 | { "pr", GDB_SIZEOF_REG, offsetof(struct pt_regs, pr) }, | ||
186 | { "sr", GDB_SIZEOF_REG, offsetof(struct pt_regs, sr) }, | ||
187 | { "gbr", GDB_SIZEOF_REG, offsetof(struct pt_regs, gbr) }, | ||
188 | { "mach", GDB_SIZEOF_REG, offsetof(struct pt_regs, mach) }, | ||
189 | { "macl", GDB_SIZEOF_REG, offsetof(struct pt_regs, macl) }, | ||
190 | { "vbr", GDB_SIZEOF_REG, -1 }, | ||
191 | }; | ||
170 | 192 | ||
171 | for (i = 0; i < 16; i++) | 193 | int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) |
172 | gdb_regs[GDB_R0 + i] = regs->regs[i]; | 194 | { |
195 | if (regno < 0 || regno >= DBG_MAX_REG_NUM) | ||
196 | return -EINVAL; | ||
173 | 197 | ||
174 | gdb_regs[GDB_PC] = regs->pc; | 198 | if (dbg_reg_def[regno].offset != -1) |
175 | gdb_regs[GDB_PR] = regs->pr; | 199 | memcpy((void *)regs + dbg_reg_def[regno].offset, mem, |
176 | gdb_regs[GDB_SR] = regs->sr; | 200 | dbg_reg_def[regno].size); |
177 | gdb_regs[GDB_GBR] = regs->gbr; | ||
178 | gdb_regs[GDB_MACH] = regs->mach; | ||
179 | gdb_regs[GDB_MACL] = regs->macl; | ||
180 | 201 | ||
181 | __asm__ __volatile__ ("stc vbr, %0" : "=r" (gdb_regs[GDB_VBR])); | 202 | return 0; |
182 | } | 203 | } |
183 | 204 | ||
184 | void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs) | 205 | char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs) |
185 | { | 206 | { |
186 | int i; | 207 | if (regno >= DBG_MAX_REG_NUM || regno < 0) |
208 | return NULL; | ||
187 | 209 | ||
188 | for (i = 0; i < 16; i++) | 210 | if (dbg_reg_def[regno].size != -1) |
189 | regs->regs[GDB_R0 + i] = gdb_regs[GDB_R0 + i]; | 211 | memcpy(mem, (void *)regs + dbg_reg_def[regno].offset, |
212 | dbg_reg_def[regno].size); | ||
213 | |||
214 | switch (regno) { | ||
215 | case GDB_VBR: | ||
216 | __asm__ __volatile__ ("stc vbr, %0" : "=r" (mem)); | ||
217 | break; | ||
218 | } | ||
190 | 219 | ||
191 | regs->pc = gdb_regs[GDB_PC]; | 220 | return dbg_reg_def[regno].name; |
192 | regs->pr = gdb_regs[GDB_PR]; | ||
193 | regs->sr = gdb_regs[GDB_SR]; | ||
194 | regs->gbr = gdb_regs[GDB_GBR]; | ||
195 | regs->mach = gdb_regs[GDB_MACH]; | ||
196 | regs->macl = gdb_regs[GDB_MACL]; | ||
197 | } | 221 | } |
198 | 222 | ||
199 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) | 223 | void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p) |