Skip to content

Commit 3d71884

Browse files
committed
cortexar: fixed CPSR mapping for GDB
Prerequisite to further work on resuming from a load to RAM.
1 parent a8a5a02 commit 3d71884

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/target/cortexar.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ typedef struct cortexar_priv {
194194
#define CORTEXAR_CPSR_MODE_SYS 0x0000001fU
195195
#define CORTEXAR_CPSR_THUMB (1U << 5U)
196196

197+
/* CPSR remap position for GDB XML mapping */
198+
#define CORTEXAR_CPSR_GDB_REMAP_POS 25U
199+
197200
/* Banked register offsets for when using using the DB{0,3} interface */
198201
enum {
199202
CORTEXAR_BANKED_DTRTX,
@@ -1257,7 +1260,7 @@ static void *cortexar_reg_ptr(target_s *const target, const size_t reg)
12571260
if (reg < 16U)
12581261
return &priv->core_regs.r[reg];
12591262
/* cpsr */
1260-
if (reg == 16U)
1263+
if (reg == CORTEXAR_CPSR_GDB_REMAP_POS)
12611264
return &priv->core_regs.cpsr;
12621265
/* Check if the core has a FPU first */
12631266
if (!(target->target_options & TOPT_FLAVOUR_FLOAT))
@@ -1274,7 +1277,7 @@ static void *cortexar_reg_ptr(target_s *const target, const size_t reg)
12741277
static size_t cortexar_reg_width(const size_t reg)
12751278
{
12761279
/* r0-r15, cpsr, fpcsr */
1277-
if (reg < CORTEXAR_GENERAL_REG_COUNT || reg == 33U)
1280+
if (reg < CORTEXAR_GENERAL_REG_COUNT || reg == CORTEXAR_CPSR_GDB_REMAP_POS || reg == 33U)
12781281
return 4U;
12791282
/* d0-d15 */
12801283
return 8U;
@@ -1758,6 +1761,11 @@ static size_t cortexar_build_target_description(char *const buffer, size_t max_l
17581761
const char *const name = cortexr_spr_names[i];
17591762
const gdb_reg_type_e type = cortexr_spr_types[i];
17601763

1764+
/*
1765+
* Create tag for each register In the case of CPSR, remap it to 25 so it aligns
1766+
* with the target description XML string above. CORTEXAR_CPSR_GDB_REMAP_POS is
1767+
* used for this mapping elsewhere in the logic.
1768+
*/
17611769
offset += snprintf(buffer + offset, print_size, "<reg name=\"%s\" bitsize=\"32\"%s%s/>", name,
17621770
gdb_reg_type_strings[type], i == 3U ? " regnum=\"25\"" : "");
17631771
}

0 commit comments

Comments
 (0)