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/5883

-- gerrit

commit d1622e0300ae56bee67b35a4fcaa82830ab9b65a
Author: Antonio Borneo <[email protected]>
Date:   Sun Oct 25 17:35:45 2020 +0100

    stlink: handle read/write FPU registers in HLA API
    
    Old stlink firmware in stlink V1 and stlink V2 pre-J15 do not
    handle FPU registers in the read_reg() and write_reg() API.
    
    Add code to be compatible with the new API of OpenOCD.
    
    Change-Id: Ib0439c5294b6911ea75efe8c7fa085b014317a4b
    Signed-off-by: Antonio Borneo <[email protected]>

diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 25f4175..6863b02 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -323,6 +323,9 @@ struct stlink_usb_handle_s {
 
 /* aliases */
 #define STLINK_F_HAS_TARGET_VOLT        STLINK_F_HAS_TRACE
+#define STLINK_F_HAS_FPU_REG            STLINK_F_HAS_GETLASTRWSTATUS2
+
+#define STLINK_REGSEL_IS_FPU(x)         ((x) > 0x1F)
 
 struct speed_map {
        int speed;
@@ -2022,6 +2025,15 @@ static int stlink_usb_read_reg(void *handle, unsigned 
int regsel, uint32_t *val)
 
        assert(handle != NULL);
 
+       if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & 
STLINK_F_HAS_FPU_REG)) {
+               res = stlink_usb_write_debug_reg(h, DCB_DCRSR, regsel & 0x7f);
+               if (res != ERROR_OK)
+                       return res;
+
+               /* FIXME: poll DHCSR.S_REGRDY before read DCRDR */
+               return stlink_usb_v2_read_debug_reg(h, DCB_DCRDR, val);
+       }
+
        stlink_usb_init_buffer(handle, h->rx_ep, h->version.jtag_api == 
STLINK_JTAG_API_V1 ? 4 : 8);
 
        h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;
@@ -2053,6 +2065,15 @@ static int stlink_usb_write_reg(void *handle, unsigned 
int regsel, uint32_t val)
 
        assert(handle != NULL);
 
+       if (STLINK_REGSEL_IS_FPU(regsel) && !(h->version.flags & 
STLINK_F_HAS_FPU_REG)) {
+               int res = stlink_usb_write_debug_reg(h, DCB_DCRDR, val);
+               if (res != ERROR_OK)
+                       return res;
+
+               return stlink_usb_write_debug_reg(h, DCB_DCRSR, DCRSR_WnR | 
(regsel & 0x7f));
+               /* FIXME: poll DHCSR.S_REGRDY after write DCRSR */
+       }
+
        stlink_usb_init_buffer(handle, h->rx_ep, 2);
 
        h->cmdbuf[h->cmdidx++] = STLINK_DEBUG_COMMAND;

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to