aarch64: fix cache identification 53/3753/5
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Fri, 16 Sep 2016 09:49:57 +0000 (11:49 +0200)
committerMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Fri, 10 Feb 2017 13:01:38 +0000 (14:01 +0100)
Use correct instructions to access CLIDR, CSSELR and CCSIDR.

Change-Id: I319b96c03a44fdb59fcb18a00f816f6af0261f0a
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
src/target/aarch64.c
src/target/armv8.c

index ef73afd7e84f4c249f28fe7f1c0ae7a333500e31..c2cd4410fdebf91c60ef0f777a6b310e67f8f3e1 100644 (file)
@@ -1235,10 +1235,8 @@ static int aarch64_post_debug_entry(struct target *target)
        LOG_DEBUG("System_register: %8.8" PRIx32, aarch64->system_control_reg);
        aarch64->system_control_reg_curr = aarch64->system_control_reg;
 
-#if 0
        if (armv8->armv8_mmu.armv8_cache.ctype == -1)
                armv8_identify_cache(target);
-#endif
 
        armv8->armv8_mmu.mmu_enabled =
                        (aarch64->system_control_reg & 0x1U) ? 1 : 0;
index 5a96d9650dc95fee3ff397f4ec35988822ba653d..fda51ef446cb64ea707c01f7910cb3d33a7b0b69 100644 (file)
@@ -634,23 +634,22 @@ done:
 
 int armv8_identify_cache(struct target *target)
 {
-       /*  read cache descriptor */
+       /*      read cache descriptor */
        int retval = ERROR_FAIL;
        struct armv8_common *armv8 = target_to_armv8(target);
        struct arm_dpm *dpm = armv8->arm.dpm;
        uint32_t cache_selected, clidr;
        uint32_t cache_i_reg, cache_d_reg;
        struct armv8_cache_common *cache = &(armv8->armv8_mmu.armv8_cache);
-       if (!armv8->is_armv7r)
-               armv8_read_ttbcr(target);
+       armv8_read_ttbcr(target);
        retval = dpm->prepare(dpm);
 
        if (retval != ERROR_OK)
                goto done;
-       /*  retrieve CLIDR
-        *  mrc p15, 1, r0, c0, c0, 1           @ read clidr */
+       /*      retrieve CLIDR
+        *      mrc p15, 1, r0, c0, c0, 1               @ read clidr */
        retval = dpm->instr_read_data_r0(dpm,
-                       ARMV4_5_MRC(15, 1, 0, 0, 0, 1),
+                       ARMV8_MRS(SYSTEM_CLIDR, 0),
                        &clidr);
        if (retval != ERROR_OK)
                goto done;
@@ -658,58 +657,51 @@ int armv8_identify_cache(struct target *target)
        LOG_INFO("number of cache level %" PRIx32, (uint32_t)(clidr / 2));
        if ((clidr / 2) > 1) {
                /* FIXME not supported present in cortex A8 and later */
-               /*  in cortex A7, A15 */
+               /*      in cortex A7, A15 */
                LOG_ERROR("cache l2 present :not supported");
        }
-       /*  retrieve selected cache
-        *  MRC p15, 2,<Rd>, c0, c0, 0; Read CSSELR */
+       /*      retrieve selected cache*/
        retval = dpm->instr_read_data_r0(dpm,
-                       ARMV4_5_MRC(15, 2, 0, 0, 0, 0),
+                       ARMV8_MRS(SYSTEM_CSSELR, 0),
                        &cache_selected);
        if (retval != ERROR_OK)
                goto done;
 
-       retval = armv8->arm.mrc(target, 15,
-                       2, 0,   /* op1, op2 */
-                       0, 0,   /* CRn, CRm */
-                       &cache_selected);
-       if (retval != ERROR_OK)
-               goto done;
+
        /* select instruction cache
-        *  MCR p15, 2,<Rd>, c0, c0, 0; Write CSSELR
-        *  [0]  : 1 instruction cache selection , 0 data cache selection */
+        *      [0]  : 1 instruction cache selection , 0 data cache selection */
        retval = dpm->instr_write_data_r0(dpm,
-                       ARMV4_5_MRC(15, 2, 0, 0, 0, 0),
+                       ARMV8_MRS(SYSTEM_CSSELR, 0),
                        1);
        if (retval != ERROR_OK)
                goto done;
 
        /* read CCSIDR
         * MRC P15,1,<RT>,C0, C0,0 ;on cortex A9 read CCSIDR
-        * [2:0] line size  001 eight word per line
+        * [2:0] line size      001 eight word per line
         * [27:13] NumSet 0x7f 16KB, 0xff 32Kbytes, 0x1ff 64Kbytes */
        retval = dpm->instr_read_data_r0(dpm,
-                       ARMV4_5_MRC(15, 1, 0, 0, 0, 0),
+                       ARMV8_MRS(SYSTEM_CCSIDR, 0),
                        &cache_i_reg);
        if (retval != ERROR_OK)
                goto done;
 
-       /*  select data cache*/
+       /*      select data cache*/
        retval = dpm->instr_write_data_r0(dpm,
-                       ARMV4_5_MRC(15, 2, 0, 0, 0, 0),
+                       ARMV8_MRS(SYSTEM_CSSELR, 0),
                        0);
        if (retval != ERROR_OK)
                goto done;
 
        retval = dpm->instr_read_data_r0(dpm,
-                       ARMV4_5_MRC(15, 1, 0, 0, 0, 0),
+                       ARMV8_MRS(SYSTEM_CCSIDR, 0),
                        &cache_d_reg);
        if (retval != ERROR_OK)
                goto done;
 
-       /*  restore selected cache  */
+       /*      restore selected cache  */
        dpm->instr_write_data_r0(dpm,
-               ARMV4_5_MRC(15, 2, 0, 0, 0, 0),
+               ARMV8_MRS(SYSTEM_CSSELR, 0),
                cache_selected);
 
        if (retval != ERROR_OK)

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)