]> git.sur5r.net Git - openocd/commitdiff
armv7m: remove magic numbers for number of core registers
authorSpencer Oliver <spen@spen-soft.co.uk>
Mon, 17 Mar 2014 14:04:25 +0000 (14:04 +0000)
committerPaul Fertser <fercerpav@gmail.com>
Sat, 29 Mar 2014 07:47:48 +0000 (07:47 +0000)
Change-Id: I4296b812f0211011ccf3da8d203545dfba493903
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/2053
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/target/armv7m.c
src/target/armv7m.h

index 130504c90b0f51987690fe02273f59bddbc7102b..58cec58875d9225033eec22358715f70500b76da 100644 (file)
@@ -52,7 +52,7 @@ static char *armv7m_exception_strings[] = {
 };
 
 /* PSP is used in some thread modes */
-const int armv7m_psp_reg_map[17] = {
+const int armv7m_psp_reg_map[ARMV7M_NUM_CORE_REGS] = {
        ARMV7M_R0, ARMV7M_R1, ARMV7M_R2, ARMV7M_R3,
        ARMV7M_R4, ARMV7M_R5, ARMV7M_R6, ARMV7M_R7,
        ARMV7M_R8, ARMV7M_R9, ARMV7M_R10, ARMV7M_R11,
@@ -61,7 +61,7 @@ const int armv7m_psp_reg_map[17] = {
 };
 
 /* MSP is used in handler and some thread modes */
-const int armv7m_msp_reg_map[17] = {
+const int armv7m_msp_reg_map[ARMV7M_NUM_CORE_REGS] = {
        ARMV7M_R0, ARMV7M_R1, ARMV7M_R2, ARMV7M_R3,
        ARMV7M_R4, ARMV7M_R5, ARMV7M_R6, ARMV7M_R7,
        ARMV7M_R8, ARMV7M_R9, ARMV7M_R10, ARMV7M_R11,
@@ -250,7 +250,7 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[],
        if (reg_class == REG_CLASS_ALL)
                *reg_list_size = ARMV7M_NUM_REGS;
        else
-               *reg_list_size = 17;
+               *reg_list_size = ARMV7M_NUM_CORE_REGS;
 
        *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
        if (*reg_list == NULL)
index 92bada0a7bc7dd5a816db3a4c892b9800390e578..575912fc9a136894a0e8f0054e8974f6b2415a9b 100644 (file)
@@ -135,6 +135,8 @@ enum {
        FPv4_SP,
 };
 
+#define ARMV7M_NUM_CORE_REGS (ARMV7M_xPSR + 1)
+
 #define ARMV7M_COMMON_MAGIC 0x2A452A45
 
 struct armv7m_common {