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

-- gerrit

commit bb3c9340fd7e54d95ed61bb2de03ed1350d0fafe
Author: Antonio Borneo <[email protected]>
Date:   Wed Aug 4 12:25:18 2021 +0200

    arm_adi_v5: fix signed offset in Class 0x1 ROM tables
    
    In both arm ADIv5 and ADIv6 documentation, for both Class 0x1 and
    Class 0x9 ROM tables, the offset field from ROM tables is supposed
    to be a signed value: "Negative values of OFFSET are permitted,
    using two’s complement."
    
    The commit c819444e9665 ("target: add 64-bit address array command
    support") extends to 64 bits the addresses while managing the ROM
    tables. The offset is read as unsigned and in the former 32 bits
    implementation the wrap-around was hiding the need for converting
    the offset to signed. The new implementation requires the proper
    cast to the offset.
    
    On a STM32F411, without this fix the ROM table dump is incorrectly
    reporting addresses out of the 32 bit bus range:
    MEM-AP BASE 0xe00ff003
        Valid ROM table present
                Component base address 0xe00ff000
                Peripheral ID 0x00000a0411
                Designer is 0x0a0, STMicroelectronics
                Part is 0x411, Unrecognized
                Component class is 0x1, ROM table
                MEMTYPE system memory present on bus
        ROMTABLE[0x0] = 0xfff0f003
                Component base address 0x1e000e000
                                       ^^^^^^^^^^^
    
    Cast the offset before adding it to the base address of the ROM
    table.
    
    Change-Id: I8d31fd2b3d657286cb96f8e22fb00842baa728f7
    Signed-off-by: Antonio Borneo <[email protected]>
    Fixes: c819444e9665 ("target: add 64-bit address array command support")

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index c421fe6..21788af 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -1310,8 +1310,8 @@ static int dap_rom_display(struct command_invocation *cmd,
                        command_print(cmd, "\t%sROMTABLE[0x%x] = 0x%" PRIx32 "",
                                        tabs, entry_offset, romentry);
                        if (romentry & 0x01) {
-                               /* Recurse */
-                               retval = dap_rom_display(cmd, ap, base_addr + 
(romentry & 0xFFFFF000), depth + 1);
+                               /* Recurse. "romentry" is signed */
+                               retval = dap_rom_display(cmd, ap, base_addr + 
(int32_t)(romentry & 0xFFFFF000), depth + 1);
                                if (retval != ERROR_OK)
                                        return retval;
                        } else if (romentry != 0) {

-- 

Reply via email to