This is an automated email from Gerrit.

Alamy Liu ([email protected]) just uploaded a new patch set to Gerrit, which 
you can find at http://openocd.zylin.com/3307

-- gerrit

commit d4061fee4836e6d72b37db37ea91956be0bc5212
Author: Alamy Liu <[email protected]>
Date:   Wed Oct 7 11:38:07 2015 -0700

    armv8: rename armv8_reg_current to armv8_get_reg_by_num()
    
    There is no such complicated register mapping in ARMv8.
    "armv8_get_reg_by_num" is more meaningful.
    
    Change-Id: Ie2009229b76d39f30f6883b67686582cff7b5903
    Signed-off-by: Alamy Liu <[email protected]>

diff --git a/src/target/aarch64.c b/src/target/aarch64.c
index 1c07e79..b89dc44 100644
--- a/src/target/aarch64.c
+++ b/src/target/aarch64.c
@@ -1751,10 +1751,10 @@ static int aarch64_write_apb_ab_memory(struct target 
*target,
         * It will be restored automatically when exiting
         * debug mode
         */
-       reg = armv8_reg_current(arm, 1);
+       reg = armv8_get_reg_by_num(arm, 1);
        reg->dirty = true;
 
-       reg = armv8_reg_current(arm, 0);
+       reg = armv8_get_reg_by_num(arm, 0);
        reg->dirty = true;
 
        /*  clear any abort  */
@@ -1900,10 +1900,10 @@ static int aarch64_read_apb_ab_memory(struct target 
*target,
         * It will be restored automatically when exiting
         * debug mode
         */
-       reg = armv8_reg_current(arm, 1);
+       reg = armv8_get_reg_by_num(arm, 1);
        reg->dirty = true;
 
-       reg = armv8_reg_current(arm, 0);
+       reg = armv8_get_reg_by_num(arm, 0);
        reg->dirty = true;
 
        /*  clear any abort  */
diff --git a/src/target/arm.h b/src/target/arm.h
index d8360ca..1a2fe85 100644
--- a/src/target/arm.h
+++ b/src/target/arm.h
@@ -242,7 +242,8 @@ int arm_blank_check_memory(struct target *target,
 
 void arm_set_cpsr(struct arm *arm, uint32_t cpsr);
 struct reg *arm_reg_current(struct arm *arm, unsigned regnum);
-struct reg *armv8_reg_current(struct arm *arm, unsigned regnum);
+struct reg *armv8_get_reg_by_num(struct arm *arm, unsigned regnum);
+#define        armv8_reg_current       armv8_get_reg_by_num    /* depreciated 
*/
 
 extern struct reg arm_gdb_dummy_fp_reg;
 extern struct reg arm_gdb_dummy_fps_reg;
diff --git a/src/target/arm_dpm.c b/src/target/arm_dpm.c
index fe22f25..7484073 100644
--- a/src/target/arm_dpm.c
+++ b/src/target/arm_dpm.c
@@ -390,7 +390,7 @@ int arm_dpm_read_current_registers_64(struct arm_dpm *dpm)
                return retval;
 
        /* read X0 first (it's used for scratch), then CPSR */
-       r = arm->core_cache->reg_list + 0;
+       r = armv8_get_reg_by_num(arm, 0);
        if (!r->valid) {
                retval = dpm_read_reg(dpm, r, 0);
                if (retval != ERROR_OK)
@@ -422,7 +422,7 @@ LOG_DEBUG("instr64 = 0x%08x, CPSR = 0x%08x", instr, cpsr);
 
        /* REVISIT we can probably avoid reading R1..R14, saving time... */
        for (unsigned i = 1; i < arm->core_cache->num_regs; i++) {
-               r = armv8_reg_current(arm, i);
+               r = armv8_get_reg_by_num(arm, i);
                if (r->valid)
                        continue;
 
diff --git a/src/target/armv8.c b/src/target/armv8.c
index bb3f85a..03bf205 100644
--- a/src/target/armv8.c
+++ b/src/target/armv8.c
@@ -728,11 +728,26 @@ struct reg_cache *armv8_build_reg_cache(struct target 
*target)
        return cache;
 }
 
-struct reg *armv8_reg_current(struct arm *arm, unsigned regnum)
+/*
+ * Returns handle to the register currently mapped to a given number.
+ *
+ * \param arm This core's state and registers are used.
+ * \param regnum From <AARCH64_X0..AARCH64_REG_NUM) corresponding to
+ *   X0..X30: General Registers
+ *   SP     : Stack pointer
+ *   PC     : Program counter
+ *   PSTATE : Processor state (SPSR)
+ *
+ * WARNING: This function does NOT consider AArch32 state ... yet.
+ */
+struct reg *armv8_get_reg_by_num(struct arm *arm, unsigned regnum)
 {
        struct reg *r;
 
-       if (regnum > 33)
+       /* reg_list is allocated in armv8_build_reg_cache()
+        * make sure we don't have a violation accessing to the array
+        */
+       if (regnum >= arm->core_cache->num_regs)
                return NULL;
 
        r = arm->core_cache->reg_list + regnum;
@@ -761,7 +776,7 @@ int armv8_get_gdb_reg_list(struct target *target,
                *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
 
                for (i = 0; i < *reg_list_size; i++)
-                               (*reg_list)[i] = armv8_reg_current(arm, i);
+                               (*reg_list)[i] = armv8_get_reg_by_num(arm, i);
 
                return ERROR_OK;
                break;

-- 

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to