aarch64: Add ARMv8 AARCH64 support files
[openocd.git] / src / target / arm_dpm.c
index 0c84be5440cef355ceeff28207cd3697afa56e90..55f253e464ff95e730541939b8d44de1d03d2021 100644 (file)
@@ -299,10 +299,15 @@ static int dpm_write_reg64(struct arm_dpm *dpm, struct reg *r, unsigned regnum)
        switch (regnum) {
                case 0 ... 30:
                        i = 0xd5330400 + regnum;
-                       retval = dpm->instr_write_data_dcc(dpm, i, value);
+                       retval = dpm->instr_write_data_dcc_64(dpm, i, value);
+                       break;
+               case 32: /* PC */
+                       i = 0xd51b4520;
+                       retval = dpm->instr_write_data_r0_64(dpm, i, value);
                        break;
-
                default:
+                       LOG_DEBUG("register %s (%16.16llx) not defined", r->name,
+                                 (unsigned long long)value);
                        break;
        }
 
@@ -354,6 +359,9 @@ static int arm_dpm_read_current_registers_i(struct arm_dpm *dpm)
 
        /* update core mode and state, plus shadow mapping for R8..R14 */
        arm_set_cpsr(arm, cpsr);
+       if (core_state == ARM_STATE_AARCH64)
+               /* arm_set_cpsr changes core_state, restore it for now */
+               arm->core_state = ARM_STATE_AARCH64;
 
        core_regs = arm->core_cache->num_regs;
 
@@ -573,7 +581,7 @@ static int arm_dpm_write_dirty_registers_64(struct arm_dpm *dpm)
         */
 
        /* check everything except our scratch register R0 */
-       for (unsigned i = 1; i < 32; i++) {
+       for (unsigned i = 1; i <= 32; i++) {
                struct arm_reg *r;
                unsigned regnum;
 
@@ -1119,7 +1127,7 @@ int arm_dpm_setup(struct arm_dpm *dpm)
 {
        struct arm *arm = dpm->arm;
        struct target *target = arm->target;
-       struct reg_cache *cache;
+       struct reg_cache *cache = 0;
 
        arm->dpm = dpm;
 
@@ -1128,13 +1136,17 @@ int arm_dpm_setup(struct arm_dpm *dpm)
        arm->read_core_reg = arm->read_core_reg ? : arm_dpm_read_core_reg;
        arm->write_core_reg = arm->write_core_reg ? : arm_dpm_write_core_reg;
 
-       /* avoid duplicating the register cache */
-       if (arm->core_cache == NULL) {
-               cache = arm_build_reg_cache(target, arm);
+       if (arm->core_cache != NULL) {
+               if (arm->core_state == ARM_STATE_AARCH64) {
+                       cache = armv8_build_reg_cache(target);
+                       target->reg_cache = cache;
+               } else {
+                       cache = arm_build_reg_cache(target, arm);
+                       *register_get_last_cache_p(&target->reg_cache) = cache;
+               }
+
                if (!cache)
                        return ERROR_FAIL;
-
-               *register_get_last_cache_p(&target->reg_cache) = cache;
        }
 
        /* coprocessor access setup */

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)