ARM: use <target/arm.h> not armv4_5.h
[openocd.git] / src / target / arm_dpm.c
index df9bd958f8772ccdfdfce29ab93d8112c6f67b86..bd9c5d1613c7c08257d7131b532c362cd645c823 100644 (file)
 #include "config.h"
 #endif
 
-#include "armv4_5.h"           /* REVISIT to become arm.h */
+#include "arm.h"
 #include "arm_dpm.h"
 #include <jtag/jtag.h>
 #include "register.h"
 #include "breakpoints.h"
 #include "target_type.h"
+#include "arm_opcodes.h"
 
 
 /**
@@ -102,13 +103,13 @@ static int dpm_mcr(struct target *target, int cpnum,
 /* Toggles between recorded core mode (USR, SVC, etc) and a temporary one.
  * Routines *must* restore the original mode before returning!!
  */
-static int dpm_modeswitch(struct arm_dpm *dpm, enum armv4_5_mode mode)
+static int dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode)
 {
        int retval;
        uint32_t cpsr;
 
        /* restore previous mode */
-       if (mode == ARMV4_5_MODE_ANY)
+       if (mode == ARM_MODE_ANY)
                cpsr = buf_get_u32(dpm->arm->cpsr->value, 0, 32);
 
        /* else force to the specified mode */
@@ -329,7 +330,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
                        retval = dpm->bpwp_disable(dpm, 16 + i);
                else
                        retval = dpm->bpwp_enable(dpm, 16 + i,
-                                       wp->address, dwp->control);
+                                       wp->address & ~3, dwp->control);
 
                if (retval != ERROR_OK)
                        LOG_ERROR("%s: can't %s HW watchpoint %d",
@@ -348,7 +349,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
         * actually find anything to do...
         */
        do {
-               enum armv4_5_mode mode = ARMV4_5_MODE_ANY;
+               enum arm_mode mode = ARM_MODE_ANY;
 
                did_write = false;
 
@@ -370,7 +371,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
 
                        /* may need to pick and set a mode */
                        if (!did_write) {
-                               enum armv4_5_mode tmode;
+                               enum arm_mode tmode;
 
                                did_write = true;
                                mode = tmode = r->mode;
@@ -382,10 +383,10 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
                                         * we "know" core mode is accurate
                                         * since we haven't changed it yet
                                         */
-                                       if (arm->core_mode == ARMV4_5_MODE_FIQ
-                                                       && ARMV4_5_MODE_ANY
+                                       if (arm->core_mode == ARM_MODE_FIQ
+                                                       && ARM_MODE_ANY
                                                                != mode)
-                                               tmode = ARMV4_5_MODE_USR;
+                                               tmode = ARM_MODE_USR;
                                        break;
                                case 16:
                                        /* SPSR */
@@ -394,7 +395,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
                                }
 
                                /* REVISIT error checks */
-                               if (tmode != ARMV4_5_MODE_ANY)
+                               if (tmode != ARM_MODE_ANY)
                                        retval = dpm_modeswitch(dpm, tmode);
                        }
                        if (r->mode != mode)
@@ -412,7 +413,7 @@ int arm_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp)
         * or it's dirty.  Must write PC to ensure the return address is
         * defined, and must not write it before CPSR.
         */
-       retval = dpm_modeswitch(dpm, ARMV4_5_MODE_ANY);
+       retval = dpm_modeswitch(dpm, ARM_MODE_ANY);
        arm->cpsr->dirty = false;
 
        retval = dpm_write_reg(dpm, &cache->reg_list[15], 15);
@@ -427,21 +428,21 @@ done:
        return retval;
 }
 
-/* Returns ARMV4_5_MODE_ANY or temporary mode to use while reading the
+/* Returns ARM_MODE_ANY or temporary mode to use while reading the
  * specified register ... works around flakiness from ARM core calls.
  * Caller already filtered out SPSR access; mode is never MODE_SYS
  * or MODE_ANY.
  */
-static enum armv4_5_mode dpm_mapmode(struct arm *arm,
-               unsigned num, enum armv4_5_mode mode)
+static enum arm_mode dpm_mapmode(struct arm *arm,
+               unsigned num, enum arm_mode mode)
 {
-       enum armv4_5_mode amode = arm->core_mode;
+       enum arm_mode amode = arm->core_mode;
 
        /* don't switch if the mode is already correct */
-       if (amode == ARMV4_5_MODE_SYS)
-                amode = ARMV4_5_MODE_USR;
+       if (amode == ARM_MODE_SYS)
+                amode = ARM_MODE_USR;
        if (mode == amode)
-               return ARMV4_5_MODE_ANY;
+               return ARM_MODE_ANY;
 
        switch (num) {
        /* don't switch for non-shadowed registers (r0..r7, r15/pc, cpsr) */
@@ -451,7 +452,7 @@ static enum armv4_5_mode dpm_mapmode(struct arm *arm,
                break;
        /* r8..r12 aren't shadowed for anything except FIQ */
        case 8 ... 12:
-               if (mode == ARMV4_5_MODE_FIQ)
+               if (mode == ARM_MODE_FIQ)
                        return mode;
                break;
        /* r13/sp, and r14/lr are always shadowed */
@@ -462,7 +463,7 @@ static enum armv4_5_mode dpm_mapmode(struct arm *arm,
                LOG_WARNING("invalid register #%u", num);
                break;
        }
-       return ARMV4_5_MODE_ANY;
+       return ARM_MODE_ANY;
 }
 
 
@@ -473,7 +474,7 @@ static enum armv4_5_mode dpm_mapmode(struct arm *arm,
  */
 
 static int arm_dpm_read_core_reg(struct target *target, struct reg *r,
-               int regnum, enum armv4_5_mode mode)
+               int regnum, enum arm_mode mode)
 {
        struct arm_dpm *dpm = target_to_arm(target)->dpm;
        int retval;
@@ -482,7 +483,7 @@ static int arm_dpm_read_core_reg(struct target *target, struct reg *r,
                return ERROR_INVALID_ARGUMENTS;
 
        if (regnum == 16) {
-               if (mode != ARMV4_5_MODE_ANY)
+               if (mode != ARM_MODE_ANY)
                        regnum = 17;
        } else
                mode = dpm_mapmode(dpm->arm, regnum, mode);
@@ -495,7 +496,7 @@ static int arm_dpm_read_core_reg(struct target *target, struct reg *r,
        if (retval != ERROR_OK)
                return retval;
 
-       if (mode != ARMV4_5_MODE_ANY) {
+       if (mode != ARM_MODE_ANY) {
                retval = dpm_modeswitch(dpm, mode);
                if (retval != ERROR_OK)
                        goto fail;
@@ -504,8 +505,8 @@ static int arm_dpm_read_core_reg(struct target *target, struct reg *r,
        retval = dpm_read_reg(dpm, r, regnum);
        /* always clean up, regardless of error */
 
-       if (mode != ARMV4_5_MODE_ANY)
-               /* (void) */ dpm_modeswitch(dpm, ARMV4_5_MODE_ANY);
+       if (mode != ARM_MODE_ANY)
+               /* (void) */ dpm_modeswitch(dpm, ARM_MODE_ANY);
 
 fail:
        /* (void) */ dpm->finish(dpm);
@@ -513,7 +514,7 @@ fail:
 }
 
 static int arm_dpm_write_core_reg(struct target *target, struct reg *r,
-               int regnum, enum armv4_5_mode mode, uint32_t value)
+               int regnum, enum arm_mode mode, uint32_t value)
 {
        struct arm_dpm *dpm = target_to_arm(target)->dpm;
        int retval;
@@ -523,7 +524,7 @@ static int arm_dpm_write_core_reg(struct target *target, struct reg *r,
                return ERROR_INVALID_ARGUMENTS;
 
        if (regnum == 16) {
-               if (mode != ARMV4_5_MODE_ANY)
+               if (mode != ARM_MODE_ANY)
                        regnum = 17;
        } else
                mode = dpm_mapmode(dpm->arm, regnum, mode);
@@ -536,7 +537,7 @@ static int arm_dpm_write_core_reg(struct target *target, struct reg *r,
        if (retval != ERROR_OK)
                return retval;
 
-       if (mode != ARMV4_5_MODE_ANY) {
+       if (mode != ARM_MODE_ANY) {
                retval = dpm_modeswitch(dpm, mode);
                if (retval != ERROR_OK)
                        goto fail;
@@ -545,8 +546,8 @@ static int arm_dpm_write_core_reg(struct target *target, struct reg *r,
        retval = dpm_write_reg(dpm, r, regnum);
        /* always clean up, regardless of error */
 
-       if (mode != ARMV4_5_MODE_ANY)
-               /* (void) */ dpm_modeswitch(dpm, ARMV4_5_MODE_ANY);
+       if (mode != ARM_MODE_ANY)
+               /* (void) */ dpm_modeswitch(dpm, ARM_MODE_ANY);
 
 fail:
        /* (void) */ dpm->finish(dpm);
@@ -566,7 +567,7 @@ static int arm_dpm_full_context(struct target *target)
                goto done;
 
        do {
-               enum armv4_5_mode mode = ARMV4_5_MODE_ANY;
+               enum arm_mode mode = ARM_MODE_ANY;
 
                did_read = false;
 
@@ -593,8 +594,8 @@ static int arm_dpm_full_context(struct target *target)
                                /* For R8..R12 when we've entered debug
                                 * state in FIQ mode... patch mode.
                                 */
-                               if (mode == ARMV4_5_MODE_ANY)
-                                       mode = ARMV4_5_MODE_USR;
+                               if (mode == ARM_MODE_ANY)
+                                       mode = ARM_MODE_USR;
 
                                /* REVISIT error checks */
                                retval = dpm_modeswitch(dpm, mode);
@@ -611,7 +612,7 @@ static int arm_dpm_full_context(struct target *target)
 
        } while (did_read);
 
-       retval = dpm_modeswitch(dpm, ARMV4_5_MODE_ANY);
+       retval = dpm_modeswitch(dpm, ARM_MODE_ANY);
        /* (void) */ dpm->finish(dpm);
 done:
        return retval;
@@ -819,7 +820,7 @@ int arm_dpm_setup(struct arm_dpm *dpm)
        arm->read_core_reg = arm_dpm_read_core_reg;
        arm->write_core_reg = arm_dpm_write_core_reg;
 
-       cache = armv4_5_build_reg_cache(target, arm);
+       cache = arm_build_reg_cache(target, arm);
        if (!cache)
                return ERROR_FAIL;
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)