diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-11-27 07:31:20 -0500 |
---|---|---|
committer | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-12-07 08:54:40 -0500 |
commit | 8dfe8f29cd371affcc3c6b35658dc4bd95ee7b61 (patch) | |
tree | dc1919ab3638bf01694ad8d23745d76046879cf7 /arch/avr32/kernel | |
parent | 320516b78bf197fbf7a38ddab09e9dab75741bae (diff) |
[AVR32] Clean up OCD register usage
Generate a new set of OCD register definitions in asm/ocd.h and rename
__mfdr() and __mtdr() to ocd_read() and ocd_write() respectively.
The bitfield definitions are a lot more complete now, and they are
entirely based on bit numbers, not masks. This is because OCD
registers are frequently accessed from assembly code, where bit
numbers are a lot more useful (can be fed directly to sbr, bfins,
etc.)
Bitfields that consist of more than one bit have two definitions:
_START, which indicates the number of the first bit, and _SIZE, which
indicates the number of bits. These directly correspond to the
parameters taken by the bfextu, bfexts and bfins instructions.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Diffstat (limited to 'arch/avr32/kernel')
-rw-r--r-- | arch/avr32/kernel/entry-avr32b.S | 14 | ||||
-rw-r--r-- | arch/avr32/kernel/kprobes.c | 14 | ||||
-rw-r--r-- | arch/avr32/kernel/process.c | 4 | ||||
-rw-r--r-- | arch/avr32/kernel/ptrace.c | 34 | ||||
-rw-r--r-- | arch/avr32/kernel/traps.c | 2 |
5 files changed, 35 insertions, 33 deletions
diff --git a/arch/avr32/kernel/entry-avr32b.S b/arch/avr32/kernel/entry-avr32b.S index cc2a9b76a344..d7b93f12d8f7 100644 --- a/arch/avr32/kernel/entry-avr32b.S +++ b/arch/avr32/kernel/entry-avr32b.S | |||
@@ -270,8 +270,8 @@ syscall_exit_work: | |||
270 | lsl r3, 1 | 270 | lsl r3, 1 |
271 | sbr r3, 30 | 271 | sbr r3, 30 |
272 | sbr r3, 0 | 272 | sbr r3, 0 |
273 | mtdr DBGREG_BWA2A, r2 | 273 | mtdr OCD_BWA2A, r2 |
274 | mtdr DBGREG_BWC2A, r3 | 274 | mtdr OCD_BWC2A, r3 |
275 | rjmp syscall_exit_cont | 275 | rjmp syscall_exit_cont |
276 | 276 | ||
277 | 277 | ||
@@ -521,8 +521,8 @@ fault_exit_work: | |||
521 | lsl r3, 1 | 521 | lsl r3, 1 |
522 | sbr r3, 30 | 522 | sbr r3, 30 |
523 | sbr r3, 0 | 523 | sbr r3, 0 |
524 | mtdr DBGREG_BWA2A, r2 | 524 | mtdr OCD_BWA2A, r2 |
525 | mtdr DBGREG_BWC2A, r3 | 525 | mtdr OCD_BWC2A, r3 |
526 | rjmp fault_resume_user | 526 | rjmp fault_resume_user |
527 | 527 | ||
528 | /* If we get a debug trap from privileged context we end up here */ | 528 | /* If we get a debug trap from privileged context we end up here */ |
@@ -636,9 +636,9 @@ debug_resume_user: | |||
636 | 636 | ||
637 | 3: bld r1, TIF_SINGLE_STEP | 637 | 3: bld r1, TIF_SINGLE_STEP |
638 | brcc debug_restore_all | 638 | brcc debug_restore_all |
639 | mfdr r2, DBGREG_DC | 639 | mfdr r2, OCD_DC |
640 | sbr r2, DC_SS_BIT | 640 | sbr r2, OCD_DC_SS_BIT |
641 | mtdr DBGREG_DC, r2 | 641 | mtdr OCD_DC, r2 |
642 | rjmp debug_restore_all | 642 | rjmp debug_restore_all |
643 | 643 | ||
644 | .set rsr_int0, SYSREG_RSR_INT0 | 644 | .set rsr_int0, SYSREG_RSR_INT0 |
diff --git a/arch/avr32/kernel/kprobes.c b/arch/avr32/kernel/kprobes.c index 20b1c9d8f945..799ba89b07a8 100644 --- a/arch/avr32/kernel/kprobes.c +++ b/arch/avr32/kernel/kprobes.c | |||
@@ -70,9 +70,9 @@ static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | |||
70 | 70 | ||
71 | BUG_ON(!(sysreg_read(SR) & SYSREG_BIT(SR_D))); | 71 | BUG_ON(!(sysreg_read(SR) & SYSREG_BIT(SR_D))); |
72 | 72 | ||
73 | dc = __mfdr(DBGREG_DC); | 73 | dc = ocd_read(DC); |
74 | dc |= DC_SS; | 74 | dc |= 1 << OCD_DC_SS_BIT; |
75 | __mtdr(DBGREG_DC, dc); | 75 | ocd_write(DC, dc); |
76 | 76 | ||
77 | /* | 77 | /* |
78 | * We must run the instruction from its original location | 78 | * We must run the instruction from its original location |
@@ -91,9 +91,9 @@ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs) | |||
91 | 91 | ||
92 | pr_debug("resuming execution at PC=%08lx\n", regs->pc); | 92 | pr_debug("resuming execution at PC=%08lx\n", regs->pc); |
93 | 93 | ||
94 | dc = __mfdr(DBGREG_DC); | 94 | dc = ocd_read(DC); |
95 | dc &= ~DC_SS; | 95 | dc &= ~(1 << OCD_DC_SS_BIT); |
96 | __mtdr(DBGREG_DC, dc); | 96 | ocd_write(DC, dc); |
97 | 97 | ||
98 | *p->addr = BREAKPOINT_INSTRUCTION; | 98 | *p->addr = BREAKPOINT_INSTRUCTION; |
99 | flush_icache_range((unsigned long)p->addr, | 99 | flush_icache_range((unsigned long)p->addr, |
@@ -261,7 +261,7 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) | |||
261 | int __init arch_init_kprobes(void) | 261 | int __init arch_init_kprobes(void) |
262 | { | 262 | { |
263 | printk("KPROBES: Enabling monitor mode (MM|DBE)...\n"); | 263 | printk("KPROBES: Enabling monitor mode (MM|DBE)...\n"); |
264 | __mtdr(DBGREG_DC, DC_MM | DC_DBE); | 264 | ocd_write(DC, (1 << OCD_DC_MM_BIT) | (1 << OCD_DC_DBE_BIT)); |
265 | 265 | ||
266 | /* TODO: Register kretprobe trampoline */ | 266 | /* TODO: Register kretprobe trampoline */ |
267 | return 0; | 267 | return 0; |
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c index f42a1d57cc72..9d6dac8af7a2 100644 --- a/arch/avr32/kernel/process.c +++ b/arch/avr32/kernel/process.c | |||
@@ -55,8 +55,8 @@ void machine_power_off(void) | |||
55 | 55 | ||
56 | void machine_restart(char *cmd) | 56 | void machine_restart(char *cmd) |
57 | { | 57 | { |
58 | __mtdr(DBGREG_DC, DC_DBE); | 58 | ocd_write(DC, (1 << OCD_DC_DBE_BIT)); |
59 | __mtdr(DBGREG_DC, DC_RES); | 59 | ocd_write(DC, (1 << OCD_DC_RES_BIT)); |
60 | while (1) ; | 60 | while (1) ; |
61 | } | 61 | } |
62 | 62 | ||
diff --git a/arch/avr32/kernel/ptrace.c b/arch/avr32/kernel/ptrace.c index 9e16b8a447f2..0de9a6eeb5bb 100644 --- a/arch/avr32/kernel/ptrace.c +++ b/arch/avr32/kernel/ptrace.c | |||
@@ -159,7 +159,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
159 | request, child->pid, addr, data); | 159 | request, child->pid, addr, data); |
160 | 160 | ||
161 | pr_debug("ptrace: Enabling monitor mode...\n"); | 161 | pr_debug("ptrace: Enabling monitor mode...\n"); |
162 | __mtdr(DBGREG_DC, __mfdr(DBGREG_DC) | DC_MM | DC_DBE); | 162 | ocd_write(DC, ocd_read(DC) | (1 << OCD_DC_MM_BIT) |
163 | | (1 << OCD_DC_DBE_BIT)); | ||
163 | 164 | ||
164 | switch (request) { | 165 | switch (request) { |
165 | /* Read the word at location addr in the child process */ | 166 | /* Read the word at location addr in the child process */ |
@@ -240,7 +241,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
240 | break; | 241 | break; |
241 | } | 242 | } |
242 | 243 | ||
243 | pr_debug("sys_ptrace returning %d (DC = 0x%08lx)\n", ret, __mfdr(DBGREG_DC)); | 244 | pr_debug("sys_ptrace returning %d (DC = 0x%08lx)\n", |
245 | ret, ocd_read(DC)); | ||
244 | return ret; | 246 | return ret; |
245 | } | 247 | } |
246 | 248 | ||
@@ -276,11 +278,11 @@ asmlinkage void do_debug_priv(struct pt_regs *regs) | |||
276 | unsigned long dc, ds; | 278 | unsigned long dc, ds; |
277 | unsigned long die_val; | 279 | unsigned long die_val; |
278 | 280 | ||
279 | ds = __mfdr(DBGREG_DS); | 281 | ds = ocd_read(DS); |
280 | 282 | ||
281 | pr_debug("do_debug_priv: pc = %08lx, ds = %08lx\n", regs->pc, ds); | 283 | pr_debug("do_debug_priv: pc = %08lx, ds = %08lx\n", regs->pc, ds); |
282 | 284 | ||
283 | if (ds & DS_SSS) | 285 | if (ds & (1 << OCD_DS_SSS_BIT)) |
284 | die_val = DIE_SSTEP; | 286 | die_val = DIE_SSTEP; |
285 | else | 287 | else |
286 | die_val = DIE_BREAKPOINT; | 288 | die_val = DIE_BREAKPOINT; |
@@ -288,14 +290,14 @@ asmlinkage void do_debug_priv(struct pt_regs *regs) | |||
288 | if (notify_die(die_val, "ptrace", regs, 0, 0, SIGTRAP) == NOTIFY_STOP) | 290 | if (notify_die(die_val, "ptrace", regs, 0, 0, SIGTRAP) == NOTIFY_STOP) |
289 | return; | 291 | return; |
290 | 292 | ||
291 | if (likely(ds & DS_SSS)) { | 293 | if (likely(ds & (1 << OCD_DS_SSS_BIT))) { |
292 | extern void itlb_miss(void); | 294 | extern void itlb_miss(void); |
293 | extern void tlb_miss_common(void); | 295 | extern void tlb_miss_common(void); |
294 | struct thread_info *ti; | 296 | struct thread_info *ti; |
295 | 297 | ||
296 | dc = __mfdr(DBGREG_DC); | 298 | dc = ocd_read(DC); |
297 | dc &= ~DC_SS; | 299 | dc &= ~(1 << OCD_DC_SS_BIT); |
298 | __mtdr(DBGREG_DC, dc); | 300 | ocd_write(DC, dc); |
299 | 301 | ||
300 | ti = current_thread_info(); | 302 | ti = current_thread_info(); |
301 | set_ti_thread_flag(ti, TIF_BREAKPOINT); | 303 | set_ti_thread_flag(ti, TIF_BREAKPOINT); |
@@ -303,8 +305,8 @@ asmlinkage void do_debug_priv(struct pt_regs *regs) | |||
303 | /* The TLB miss handlers don't check thread flags */ | 305 | /* The TLB miss handlers don't check thread flags */ |
304 | if ((regs->pc >= (unsigned long)&itlb_miss) | 306 | if ((regs->pc >= (unsigned long)&itlb_miss) |
305 | && (regs->pc <= (unsigned long)&tlb_miss_common)) { | 307 | && (regs->pc <= (unsigned long)&tlb_miss_common)) { |
306 | __mtdr(DBGREG_BWA2A, sysreg_read(RAR_EX)); | 308 | ocd_write(BWA2A, sysreg_read(RAR_EX)); |
307 | __mtdr(DBGREG_BWC2A, 0x40000001 | (get_asid() << 1)); | 309 | ocd_write(BWC2A, 0x40000001 | (get_asid() << 1)); |
308 | } | 310 | } |
309 | 311 | ||
310 | /* | 312 | /* |
@@ -329,22 +331,22 @@ asmlinkage void do_debug(struct pt_regs *regs) | |||
329 | { | 331 | { |
330 | unsigned long dc, ds; | 332 | unsigned long dc, ds; |
331 | 333 | ||
332 | ds = __mfdr(DBGREG_DS); | 334 | ds = ocd_read(DS); |
333 | pr_debug("do_debug: pc = %08lx, ds = %08lx\n", regs->pc, ds); | 335 | pr_debug("do_debug: pc = %08lx, ds = %08lx\n", regs->pc, ds); |
334 | 336 | ||
335 | if (test_thread_flag(TIF_BREAKPOINT)) { | 337 | if (test_thread_flag(TIF_BREAKPOINT)) { |
336 | pr_debug("TIF_BREAKPOINT set\n"); | 338 | pr_debug("TIF_BREAKPOINT set\n"); |
337 | /* We're taking care of it */ | 339 | /* We're taking care of it */ |
338 | clear_thread_flag(TIF_BREAKPOINT); | 340 | clear_thread_flag(TIF_BREAKPOINT); |
339 | __mtdr(DBGREG_BWC2A, 0); | 341 | ocd_write(BWC2A, 0); |
340 | } | 342 | } |
341 | 343 | ||
342 | if (test_thread_flag(TIF_SINGLE_STEP)) { | 344 | if (test_thread_flag(TIF_SINGLE_STEP)) { |
343 | pr_debug("TIF_SINGLE_STEP set, ds = 0x%08lx\n", ds); | 345 | pr_debug("TIF_SINGLE_STEP set, ds = 0x%08lx\n", ds); |
344 | if (ds & DS_SSS) { | 346 | if (ds & (1 << OCD_DS_SSS_BIT)) { |
345 | dc = __mfdr(DBGREG_DC); | 347 | dc = ocd_read(DC); |
346 | dc &= ~DC_SS; | 348 | dc &= ~(1 << OCD_DC_SS_BIT); |
347 | __mtdr(DBGREG_DC, dc); | 349 | ocd_write(DC, dc); |
348 | 350 | ||
349 | clear_thread_flag(TIF_SINGLE_STEP); | 351 | clear_thread_flag(TIF_SINGLE_STEP); |
350 | ptrace_break(current, regs); | 352 | ptrace_break(current, regs); |
diff --git a/arch/avr32/kernel/traps.c b/arch/avr32/kernel/traps.c index 8a7caf8e7b45..870c075e6314 100644 --- a/arch/avr32/kernel/traps.c +++ b/arch/avr32/kernel/traps.c | |||
@@ -39,7 +39,7 @@ void NORET_TYPE die(const char *str, struct pt_regs *regs, long err) | |||
39 | printk("FRAME_POINTER "); | 39 | printk("FRAME_POINTER "); |
40 | #endif | 40 | #endif |
41 | if (current_cpu_data.features & AVR32_FEATURE_OCD) { | 41 | if (current_cpu_data.features & AVR32_FEATURE_OCD) { |
42 | unsigned long did = __mfdr(DBGREG_DID); | 42 | unsigned long did = ocd_read(DID); |
43 | printk("chip: 0x%03lx:0x%04lx rev %lu\n", | 43 | printk("chip: 0x%03lx:0x%04lx rev %lu\n", |
44 | (did >> 1) & 0x7ff, | 44 | (did >> 1) & 0x7ff, |
45 | (did >> 12) & 0x7fff, | 45 | (did >> 12) & 0x7fff, |