aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/kernel/pseudodbg.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/kernel/pseudodbg.c')
-rw-r--r--arch/blackfin/kernel/pseudodbg.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/arch/blackfin/kernel/pseudodbg.c b/arch/blackfin/kernel/pseudodbg.c
new file mode 100644
index 000000000000..4474b8db3501
--- /dev/null
+++ b/arch/blackfin/kernel/pseudodbg.c
@@ -0,0 +1,73 @@
1/* The fake debug assert instructions
2 *
3 * Copyright 2010 Analog Devices Inc.
4 *
5 * Licensed under the GPL-2 or later
6 */
7
8#include <linux/types.h>
9#include <linux/kernel.h>
10#include <linux/ptrace.h>
11
12#define PseudoDbg_Assert_opcode 0xf0000000
13#define PseudoDbg_Assert_expected_bits 0
14#define PseudoDbg_Assert_expected_mask 0xffff
15#define PseudoDbg_Assert_regtest_bits 16
16#define PseudoDbg_Assert_regtest_mask 0x7
17#define PseudoDbg_Assert_grp_bits 19
18#define PseudoDbg_Assert_grp_mask 0x7
19#define PseudoDbg_Assert_dbgop_bits 22
20#define PseudoDbg_Assert_dbgop_mask 0x3
21#define PseudoDbg_Assert_dontcare_bits 24
22#define PseudoDbg_Assert_dontcare_mask 0x7
23#define PseudoDbg_Assert_code_bits 27
24#define PseudoDbg_Assert_code_mask 0x1f
25
26bool execute_pseudodbg_assert(struct pt_regs *fp, unsigned int opcode)
27{
28 int expected = ((opcode >> PseudoDbg_Assert_expected_bits) & PseudoDbg_Assert_expected_mask);
29 int dbgop = ((opcode >> (PseudoDbg_Assert_dbgop_bits)) & PseudoDbg_Assert_dbgop_mask);
30 int grp = ((opcode >> (PseudoDbg_Assert_grp_bits)) & PseudoDbg_Assert_grp_mask);
31 int regtest = ((opcode >> (PseudoDbg_Assert_regtest_bits)) & PseudoDbg_Assert_regtest_mask);
32 long *value = &fp->r0;
33
34 if ((opcode & 0xFF000000) != PseudoDbg_Assert_opcode)
35 return false;
36
37 /* Only do Dregs and Pregs for now */
38 if (grp > 1)
39 return false;
40
41 /*
42 * Unfortunately, the pt_regs structure is not laid out the same way as the
43 * hardware register file, so we need to do some fix ups.
44 */
45 if (grp == 0 || (grp == 1 && regtest < 6))
46 value -= (regtest + 8 * grp);
47 else if (grp == 1 && regtest == 6)
48 value = &fp->usp;
49 else if (grp == 1 && regtest == 7)
50 value = &fp->fp;
51
52 if (dbgop == 0 || dbgop == 2) {
53 /* DBGA ( regs_lo , uimm16 ) */
54 /* DBGAL ( regs , uimm16 ) */
55 if (expected != (*value & 0xFFFF)) {
56 pr_notice("DBGA (%s%i.L,0x%x) failure, got 0x%x\n", grp ? "P" : "R",
57 regtest, expected, (unsigned int)(*value & 0xFFFF));
58 return false;
59 }
60
61 } else if (dbgop == 1 || dbgop == 3) {
62 /* DBGA ( regs_hi , uimm16 ) */
63 /* DBGAH ( regs , uimm16 ) */
64 if (expected != ((*value >> 16) & 0xFFFF)) {
65 pr_notice("DBGA (%s%i.H,0x%x) failure, got 0x%x\n", grp ? "P" : "R",
66 regtest, expected, (unsigned int)((*value >> 16) & 0xFFFF));
67 return false;
68 }
69 }
70
71 fp->pc += 4;
72 return true;
73}