arm_adi_v5: separate ROM table parsing from command output [3/3]
[openocd.git] / src / target / arm_adi_v5.c
index b6053b0987b31aaba9711e53282f4ecee6a58712..60bd5466694f0e1a045a6eba77eba3594faee863 100644 (file)
@@ -1491,6 +1491,9 @@ static int dap_info_mem_ap_header(struct command_invocation *cmd,
                target_addr_t dbgbase, uint32_t apid);
 static int dap_info_cs_component(struct command_invocation *cmd,
                int retval, struct cs_component_vals *v, int depth);
+static int dap_info_rom_table_entry(struct command_invocation *cmd,
+               int retval, int depth,
+               unsigned int offset, uint32_t romentry);
 
 static int rtp_cs_component(struct command_invocation *cmd,
                struct adiv5_ap *ap, target_addr_t dbgbase, int depth);
@@ -1501,11 +1504,6 @@ static int rtp_rom_loop(struct command_invocation *cmd,
 {
        assert(IS_ALIGNED(base_address, ARM_CS_ALIGN));
 
-       char tabs[16] = "";
-
-       if (depth)
-               snprintf(tabs, sizeof(tabs), "[L%02d] ", depth);
-
        unsigned int offset = 0;
        while (max_entries--) {
                uint32_t romentry;
@@ -1513,26 +1511,20 @@ static int rtp_rom_loop(struct command_invocation *cmd,
 
                int retval = mem_ap_read_atomic_u32(ap, base_address + offset, &romentry);
                offset += 4;
-               if (retval != ERROR_OK) {
+               if (retval != ERROR_OK)
                        LOG_DEBUG("Failed read ROM table entry");
-                       command_print(cmd, "\t%sROMTABLE[0x%x] Read error", tabs, saved_offset);
-                       command_print(cmd, "\t\tUnable to continue");
-                       command_print(cmd, "\t%s\tStop parsing of ROM table", tabs);
-                       return retval;
-               }
 
-               command_print(cmd, "\t%sROMTABLE[0x%x] = 0x%08" PRIx32,
-                               tabs, saved_offset, romentry);
+               retval = dap_info_rom_table_entry(cmd, retval, depth, saved_offset, romentry);
+               if (retval != ERROR_OK)
+                       return retval;
 
                if (romentry == 0) {
-                       command_print(cmd, "\t%s\tEnd of ROM table", tabs);
+                       /* End of ROM table */
                        break;
                }
 
-               if (!(romentry & ARM_CS_ROMENTRY_PRESENT)) {
-                       command_print(cmd, "\t\tComponent not present");
+               if (!(romentry & ARM_CS_ROMENTRY_PRESENT))
                        continue;
-               }
 
                /* Recurse. "romentry" is signed */
                target_addr_t component_base = base_address + (int32_t)(romentry & ARM_CS_ROMENTRY_OFFSET_MASK);
@@ -1753,6 +1745,38 @@ static int dap_info_cs_component(struct command_invocation *cmd,
        return ERROR_OK;
 }
 
+static int dap_info_rom_table_entry(struct command_invocation *cmd,
+               int retval, int depth,
+               unsigned int offset, uint32_t romentry)
+{
+       char tabs[16] = "";
+
+       if (depth)
+               snprintf(tabs, sizeof(tabs), "[L%02d] ", depth);
+
+       if (retval != ERROR_OK) {
+               command_print(cmd, "\t%sROMTABLE[0x%x] Read error", tabs, offset);
+               command_print(cmd, "\t\tUnable to continue");
+               command_print(cmd, "\t%s\tStop parsing of ROM table", tabs);
+               return retval;
+       }
+
+       command_print(cmd, "\t%sROMTABLE[0x%x] = 0x%08" PRIx32,
+                       tabs, offset, romentry);
+
+       if (romentry == 0) {
+               command_print(cmd, "\t%s\tEnd of ROM table", tabs);
+               return ERROR_OK;
+       }
+
+       if (!(romentry & ARM_CS_ROMENTRY_PRESENT)) {
+               command_print(cmd, "\t\tComponent not present");
+               return ERROR_OK;
+       }
+
+       return ERROR_OK;
+}
+
 enum adiv5_cfg_param {
        CFG_DAP,
        CFG_AP_NUM,

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)