This is an automated email from Gerrit.

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

-- gerrit

commit 4454922cef2254744c71c36a1f1e9e9a2150beae
Author: Antonio Borneo <[email protected]>
Date:   Fri Jun 15 16:30:41 2018 +0200

    target/arm_adi_v5: sync CSW and TAR cache on apreg write
    
    When using apreg to change AP registers CSW or TAR we get internal
    cached value not valid anymore.
    
    Reuse the setup functions for CSW and TAR to write them.
    Invalidate the cached value before the call to force the write, thus
    keeping original apreg behaviour.
    
    Change-Id: Ib14fafd5e584345de94f2e983de55406c588ac1c
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index 9c0b51b..43fd5a6 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -1726,6 +1726,7 @@ COMMAND_HANDLER(dap_apreg_command)
 {
        struct adiv5_dap *dap = adiv5_get_dap(CMD_DATA);
        uint32_t apsel, reg, value;
+       struct adiv5_ap *ap;
        int retval;
 
        if (CMD_ARGC < 2 || CMD_ARGC > 3)
@@ -1735,6 +1736,7 @@ COMMAND_HANDLER(dap_apreg_command)
        /* AP address is in bits 31:24 of DP_SELECT */
        if (apsel >= 256)
                return ERROR_COMMAND_SYNTAX_ERROR;
+       ap = dap_ap(dap, apsel);
 
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg);
        if (reg >= 256 || (reg & 3))
@@ -1742,9 +1744,21 @@ COMMAND_HANDLER(dap_apreg_command)
 
        if (CMD_ARGC == 3) {
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
-               retval = dap_queue_ap_write(dap_ap(dap, apsel), reg, value);
+               switch(reg) {
+               case MEM_AP_REG_CSW:
+                       ap->csw_default = 0;  /* invalid, force write */
+                       retval = mem_ap_setup_csw(ap, value);
+                       break;
+               case MEM_AP_REG_TAR:
+                       ap->tar_valid = false;  /* invalid, force write */
+                       retval = mem_ap_setup_tar(ap, value);
+                       break;
+               default:
+                       retval = dap_queue_ap_write(ap, reg, value);
+                       break;
+               }
        } else {
-               retval = dap_queue_ap_read(dap_ap(dap, apsel), reg, &value);
+               retval = dap_queue_ap_read(ap, reg, &value);
        }
        if (retval == ERROR_OK)
                retval = dap_run(dap);

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to