Hello all Cortex_A8 fans !

Please test the following patch that hopefully corrects some insane errors in Thumb state handling. (Yes I wrote it myself, but it seems UBoot for BeagleBoard does not use Thumb Mode)

Best regards
Magnus

Index: src/target/cortex_a8.c
===================================================================
--- src/target/cortex_a8.c	(revision 2663)
+++ src/target/cortex_a8.c	(working copy)
@@ -451,7 +458,6 @@
 	/* get pointers to arch-specific information */
 	armv4_5_common_t *armv4_5 = target->arch_info;
 	armv7a_common_t *armv7a = armv4_5->arch_info;
-	cortex_a8_common_t *cortex_a8 = armv7a->arch_info;
 	swjdp_common_t *swjdp = &armv7a->swjdp_info;
 
 //	breakpoint_t *breakpoint = NULL;
@@ -499,7 +505,7 @@
 	/* Make sure that the Armv7 gdb thumb fixups does not
 	 * kill the return address
 	 */
-	if (!(cortex_a8->cpudbg_dscr & (1 << 5)))
+	if (armv7a->core_state == ARMV7A_STATE_ARM)
 	{
 		resume_pc &= 0xFFFFFFFC;
 	}
@@ -631,7 +636,8 @@
 	dap_ap_select(swjdp, swjdp_debugap);
 	LOG_DEBUG("cpsr: %8.8" PRIx32, cpsr);
 
-	armv4_5->core_mode = cpsr & 0x3F;
+	armv4_5->core_mode = cpsr & 0x1F;
+	armv7a->core_state = (cpsr & 0x20)?ARMV7A_STATE_THUMB:ARMV7A_STATE_ARM;
 
 	for (i = 0; i <= ARM_PC; i++)
 	{
@@ -650,8 +656,7 @@
 	ARMV7A_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, 16).dirty = 0;
 
 	/* Fixup PC Resume Address */
-	/* TODO Her we should use arch->core_state */
-	if (cortex_a8->cpudbg_dscr & (1 << 5))
+	if (armv7a->core_state == ARMV7A_STATE_THUMB)
 	{
 		// T bit set for Thumb or ThumbEE state
 		regfile[ARM_PC] -= 4;
@@ -736,7 +741,6 @@
 	/* get pointers to arch-specific information */
 	armv4_5_common_t *armv4_5 = target->arch_info;
 	armv7a_common_t *armv7a = armv4_5->arch_info;
-	cortex_a8_common_t *cortex_a8 = armv7a->arch_info;
 	breakpoint_t *breakpoint = NULL;
 	breakpoint_t stepbreakpoint;
 
@@ -778,7 +782,7 @@
 
 	/* Setup single step breakpoint */
 	stepbreakpoint.address = address;
-	stepbreakpoint.length = (cortex_a8->cpudbg_dscr & (1 << 5)) ? 2 : 4;
+	stepbreakpoint.length = (armv7a->core_state == ARMV7A_STATE_THUMB) ? 2 : 4;
 	stepbreakpoint.type = BKPT_HARD;
 	stepbreakpoint.set = 0;
 
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to