Title: [8470] trunk/arch/blackfin: Support the debug assert instruction, which allows the gdb simulator
Revision
8470
Author
rgetz
Date
2010-03-16 10:40:17 -0400 (Tue, 16 Mar 2010)

Log Message

Support the debug assert instruction, which allows the gdb simulator
test cases which use this instruction to be tested on the hardware (as
userspace applications).

Modified Paths

Added Paths

Diff

Modified: trunk/arch/blackfin/Kconfig.debug (8469 => 8470)


--- trunk/arch/blackfin/Kconfig.debug	2010-03-16 14:28:44 UTC (rev 8469)
+++ trunk/arch/blackfin/Kconfig.debug	2010-03-16 14:40:17 UTC (rev 8470)
@@ -264,4 +264,13 @@
 	help
 	  Run some self tests of the isram driver code at boot.
 
+config BFIN_PSEUDO_DBGA
+	bool "Support dbg assert instruction"
+	default n
+	help
+	  This option allows the kernel to emulate some pseudo instructions which
+	  allow simulator test cases to be run on the hardware.
+
+	  Most people should say N here.
+
 endmenu

Added: trunk/arch/blackfin/include/asm/pseudo_instructions.h (0 => 8470)


--- trunk/arch/blackfin/include/asm/pseudo_instructions.h	                        (rev 0)
+++ trunk/arch/blackfin/include/asm/pseudo_instructions.h	2010-03-16 14:40:17 UTC (rev 8470)
@@ -0,0 +1 @@
+extern bool execute_pseudodbg_assert(struct pt_regs *fp, unsigned int opcode);

Modified: trunk/arch/blackfin/kernel/Makefile (8469 => 8470)


--- trunk/arch/blackfin/kernel/Makefile	2010-03-16 14:28:44 UTC (rev 8469)
+++ trunk/arch/blackfin/kernel/Makefile	2010-03-16 14:40:17 UTC (rev 8470)
@@ -32,6 +32,7 @@
 obj-$(CONFIG_EARLY_PRINTK)           += shadow_console.o
 obj-$(CONFIG_STACKTRACE)             += stacktrace.o
 obj-$(CONFIG_DEBUG_VERBOSE)          += trace.o
+obj-$(CONFIG_BFIN_PSEUDO_DBGA)       += pseudodgba.o
 
 # the kgdb test puts code into L2 and without linker
 # relaxation, we need to force long calls to/from it

Added: trunk/arch/blackfin/kernel/pseudodgba.c (0 => 8470)


--- trunk/arch/blackfin/kernel/pseudodgba.c	                        (rev 0)
+++ trunk/arch/blackfin/kernel/pseudodgba.c	2010-03-16 14:40:17 UTC (rev 8470)
@@ -0,0 +1,58 @@
+/* The fake debug assert instructions
+ *
+ * Copyright 2004-2009 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later
+ */
+
+#include <linux/ptrace.h>
+
+#define PseudoDbg_Assert_opcode         0xf0000000
+#define PseudoDbg_Assert_expected_bits  0
+#define PseudoDbg_Assert_expected_mask  0xffff
+#define PseudoDbg_Assert_regtest_bits   16
+#define PseudoDbg_Assert_regtest_mask   0x7
+#define PseudoDbg_Assert_grp_bits       19
+#define PseudoDbg_Assert_grp_mask       0x7
+#define PseudoDbg_Assert_dbgop_bits     22
+#define PseudoDbg_Assert_dbgop_mask     0x3
+#define PseudoDbg_Assert_dontcare_bits  24
+#define PseudoDbg_Assert_dontcare_mask  0x7
+#define PseudoDbg_Assert_code_bits      27
+#define PseudoDbg_Assert_code_mask      0x1f
+
+bool execute_pseudodbg_assert(struct pt_regs *fp, unsigned int opcode)
+{
+	int expected = ((opcode >> PseudoDbg_Assert_expected_bits) & PseudoDbg_Assert_expected_mask);
+	int dbgop    = ((opcode >> (PseudoDbg_Assert_dbgop_bits)) & PseudoDbg_Assert_dbgop_mask);
+	int grp      = ((opcode >> (PseudoDbg_Assert_grp_bits)) & PseudoDbg_Assert_grp_mask);
+	int regtest  = ((opcode >> (PseudoDbg_Assert_regtest_bits)) & PseudoDbg_Assert_regtest_mask);
+	long *value = &fp->r0;
+
+	if ((opcode & 0xFF000000) != PseudoDbg_Assert_opcode)
+		return false;
+
+	if (grp != 0)
+		return false;
+
+	value -= regtest;
+
+	if (dbgop == 0 || dbgop == 2) {
+		/* DBGA ( regs_lo , uimm16 ) */
+		/* DBGAL ( regs , uimm16 ) */
+		if (expected != (*value & 0xFFFF)) {
+			pr_notice("DBGA (R%i.L,%x) failure, got %x\n", regtest, expected, (unsigned int)(*value & 0xFFFF));
+			return false;
+		}
+
+	} else if (dbgop == 1 || dbgop == 3) {
+		/* DBGA ( regs_hi , uimm16 ) */
+		/* DBGAH ( regs , uimm16 ) */
+		if (expected != ((*value >> 16) & 0xFFFF)) {
+			pr_notice("DBGA (R%i.H,%x) failure, got %x\n", regtest, expected, (unsigned int)((*value >> 16) & 0xFFFF));
+			return false;
+		}
+	}
+
+	return true;
+}

Modified: trunk/arch/blackfin/kernel/traps.c (8469 => 8470)


--- trunk/arch/blackfin/kernel/traps.c	2010-03-16 14:28:44 UTC (rev 8469)
+++ trunk/arch/blackfin/kernel/traps.c	2010-03-16 14:40:17 UTC (rev 8470)
@@ -14,6 +14,9 @@
 #include <linux/irq.h>
 #include <asm/trace.h>
 #include <asm/fixed_code.h>
+#ifdef CONFIG_BFIN_PSEUDO_DBGA
+#include <asm/pseudo_instructions.h>
+#endif
 
 #ifdef CONFIG_KGDB
 # include <linux/kgdb.h>
@@ -66,6 +69,9 @@
 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
 	int j;
 #endif
+#ifdef CONFIG_BFIN_PSEUDO_DBGA
+	int opcode;
+#endif
 	unsigned int cpu = raw_smp_processor_id();
 	const char *strerror = NULL;
 	int sig = 0;
@@ -198,6 +204,19 @@
 			}
 		}
 #endif
+#ifdef CONFIG_BFIN_PSEUDO_DBGA
+		/*
+		 * Support for the fake instructions, if the instruction fails,
+		 * then just execute a illegal opcode failure (like normal).
+		 * Don't support these instructions inside the kernel
+		 */
+		if (!kernel_mode_regs(fp) && get_instruction(&opcode, (unsigned short *)fp->pc)) {
+			if (execute_pseudodbg_assert(fp, opcode)) {
+				fp->pc += 4;
+				goto traps_done;
+			}
+		}
+#endif
 		info.si_code = ILL_ILLOPC;
 		sig = SIGILL;
 		strerror = KERN_NOTICE EXC_0x21(KERN_NOTICE);
_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to