target: use proper format with uint32_t
[openocd.git] / src / target / arm_adi_v5.c
index 8ff5efd7afd7e4426127bcfbc4543d7c4688e66b..a09e2698a78eb8fc0de3e51990c4e2f431562193 100644 (file)
@@ -51,7 +51,7 @@
  * is set in the DP_CTRL_STAT register, the SSTICKYORUN status is set and
  * further AP operations will fail.  There are two basic methods to avoid
  * such overrun errors.  One involves polling for status instead of using
- * transaction piplining.  The other involves adding delays to ensure the
+ * transaction pipelining.  The other involves adding delays to ensure the
  * AP has enough time to complete one operation before starting the next
  * one.  (For JTAG these delays are controlled by memaccess_tck.)
  */
@@ -804,26 +804,9 @@ int mem_ap_init(struct adiv5_ap *ap)
  */
 int dap_to_swd(struct adiv5_dap *dap)
 {
-       int retval;
-
        LOG_DEBUG("Enter SWD mode");
 
-       if (transport_is_jtag()) {
-               retval =  jtag_add_tms_seq(swd_seq_jtag_to_swd_len,
-                               swd_seq_jtag_to_swd, TAP_INVALID);
-               if (retval == ERROR_OK)
-                       retval = jtag_execute_queue();
-               return retval;
-       }
-
-       if (transport_is_swd()) {
-               const struct swd_driver *swd = adiv5_dap_swd_driver(dap);
-
-               return swd->switch_seq(JTAG_TO_SWD);
-       }
-
-       LOG_ERROR("Nor JTAG nor SWD transport");
-       return ERROR_FAIL;
+       return dap_send_sequence(dap, JTAG_TO_SWD);
 }
 
 /**
@@ -839,26 +822,9 @@ int dap_to_swd(struct adiv5_dap *dap)
  */
 int dap_to_jtag(struct adiv5_dap *dap)
 {
-       int retval;
-
        LOG_DEBUG("Enter JTAG mode");
 
-       if (transport_is_jtag()) {
-               retval = jtag_add_tms_seq(swd_seq_swd_to_jtag_len,
-                               swd_seq_swd_to_jtag, TAP_RESET);
-               if (retval == ERROR_OK)
-                       retval = jtag_execute_queue();
-               return retval;
-       }
-
-       if (transport_is_swd()) {
-               const struct swd_driver *swd = adiv5_dap_swd_driver(dap);
-
-               return swd->switch_seq(SWD_TO_JTAG);
-       }
-
-       LOG_ERROR("Nor JTAG nor SWD transport");
-       return ERROR_FAIL;
+       return dap_send_sequence(dap, SWD_TO_JTAG);
 }
 
 /* CID interpretation -- see ARM IHI 0029B section 3
@@ -906,7 +872,7 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
                 *  3-0  : AP Type (0=JTAG-AP 1=AHB-AP 2=APB-AP 4=AXI-AP)
                 */
 
-               /* Reading register for a non-existant AP should not cause an error,
+               /* Reading register for a non-existent AP should not cause an error,
                 * but just to be sure, try to continue searching if an error does happen.
                 */
                if ((retval == ERROR_OK) &&                  /* Register read success */
@@ -914,7 +880,8 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
                        ((id_val & IDR_TYPE) == type_to_find)) {      /* type matches*/
 
                        LOG_DEBUG("Found %s at AP index: %d (IDR=0x%08" PRIX32 ")",
-                                               (type_to_find == AP_TYPE_AHB_AP)  ? "AHB-AP"  :
+                                               (type_to_find == AP_TYPE_AHB3_AP)  ? "AHB3-AP"  :
+                                               (type_to_find == AP_TYPE_AHB5_AP)  ? "AHB5-AP"  :
                                                (type_to_find == AP_TYPE_APB_AP)  ? "APB-AP"  :
                                                (type_to_find == AP_TYPE_AXI_AP)  ? "AXI-AP"  :
                                                (type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown",
@@ -926,7 +893,8 @@ int dap_find_ap(struct adiv5_dap *dap, enum ap_type type_to_find, struct adiv5_a
        }
 
        LOG_DEBUG("No %s found",
-                               (type_to_find == AP_TYPE_AHB_AP)  ? "AHB-AP"  :
+                               (type_to_find == AP_TYPE_AHB3_AP)  ? "AHB3-AP"  :
+                               (type_to_find == AP_TYPE_AHB5_AP)  ? "AHB5-AP"  :
                                (type_to_find == AP_TYPE_APB_AP)  ? "APB-AP"  :
                                (type_to_find == AP_TYPE_AXI_AP)  ? "AXI-AP"  :
                                (type_to_find == AP_TYPE_JTAG_AP) ? "JTAG-AP" : "Unknown");
@@ -1104,21 +1072,23 @@ static const struct {
        { ARM_ID, 0x00c, "Cortex-M4 SCS",              "(System Control Space)", },
        { ARM_ID, 0x00d, "CoreSight ETM11",            "(Embedded Trace)", },
        { ARM_ID, 0x00e, "Cortex-M7 FPB",              "(Flash Patch and Breakpoint)", },
+       { ARM_ID, 0x470, "Cortex-M1 ROM",              "(ROM Table)", },
+       { ARM_ID, 0x471, "Cortex-M0 ROM",              "(ROM Table)", },
        { ARM_ID, 0x490, "Cortex-A15 GIC",             "(Generic Interrupt Controller)", },
        { ARM_ID, 0x4a1, "Cortex-A53 ROM",             "(v8 Memory Map ROM Table)", },
        { ARM_ID, 0x4a2, "Cortex-A57 ROM",             "(ROM Table)", },
        { ARM_ID, 0x4a3, "Cortex-A53 ROM",             "(v7 Memory Map ROM Table)", },
        { ARM_ID, 0x4a4, "Cortex-A72 ROM",             "(ROM Table)", },
        { ARM_ID, 0x4a9, "Cortex-A9 ROM",              "(ROM Table)", },
+       { ARM_ID, 0x4aa, "Cortex-A35 ROM",             "(v8 Memory Map ROM Table)", },
        { ARM_ID, 0x4af, "Cortex-A15 ROM",             "(ROM Table)", },
+       { ARM_ID, 0x4b5, "Cortex-R5 ROM",              "(ROM Table)", },
        { ARM_ID, 0x4c0, "Cortex-M0+ ROM",             "(ROM Table)", },
        { ARM_ID, 0x4c3, "Cortex-M3 ROM",              "(ROM Table)", },
        { ARM_ID, 0x4c4, "Cortex-M4 ROM",              "(ROM Table)", },
        { ARM_ID, 0x4c7, "Cortex-M7 PPB ROM",          "(Private Peripheral Bus ROM Table)", },
        { ARM_ID, 0x4c8, "Cortex-M7 ROM",              "(ROM Table)", },
-       { ARM_ID, 0x4b5, "Cortex-R5 ROM",              "(ROM Table)", },
-       { ARM_ID, 0x470, "Cortex-M1 ROM",              "(ROM Table)", },
-       { ARM_ID, 0x471, "Cortex-M0 ROM",              "(ROM Table)", },
+       { ARM_ID, 0x4e0, "Cortex-A35 ROM",             "(v7 Memory Map ROM Table)", },
        { ARM_ID, 0x906, "CoreSight CTI",              "(Cross Trigger)", },
        { ARM_ID, 0x907, "CoreSight ETB",              "(Trace Buffer)", },
        { ARM_ID, 0x908, "CoreSight CSTF",             "(Trace Funnel)", },
@@ -1161,6 +1131,7 @@ static const struct {
        { ARM_ID, 0x9d3, "Cortex-A53 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9d7, "Cortex-A57 PMU",             "(Performance Monitor Unit)", },
        { ARM_ID, 0x9d8, "Cortex-A72 PMU",             "(Performance Monitor Unit)", },
+       { ARM_ID, 0x9da, "Cortex-A35 PMU/CTI/ETM",     "(Performance Monitor Unit/Cross Trigger/ETM)", },
        { ARM_ID, 0xc05, "Cortex-A5 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xc07, "Cortex-A7 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xc08, "Cortex-A8 Debug",            "(Debug Unit)", },
@@ -1171,6 +1142,7 @@ static const struct {
        { ARM_ID, 0xc15, "Cortex-R5 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xc17, "Cortex-R7 Debug",            "(Debug Unit)", },
        { ARM_ID, 0xd03, "Cortex-A53 Debug",           "(Debug Unit)", },
+       { ARM_ID, 0xd04, "Cortex-A35 Debug",           "(Debug Unit)", },
        { ARM_ID, 0xd07, "Cortex-A57 Debug",           "(Debug Unit)", },
        { ARM_ID, 0xd08, "Cortex-A72 Debug",           "(Debug Unit)", },
        { 0x097,  0x9af, "MSP432 ROM",                 "(ROM Table)" },
@@ -1181,8 +1153,8 @@ static const struct {
        { 0x0E5,  0x000, "SHARC+/Blackfin+",           "", },
        { 0x0F0,  0x440, "Qualcomm QDSS Component v1", "(Qualcomm Designed CoreSight Component v1)", },
        { 0x3eb,  0x181, "Tegra 186 ROM",              "(ROM Table)", },
-       { 0x3eb,  0x211, "Tegra 210 ROM",              "(ROM Table)", },
        { 0x3eb,  0x202, "Denver ETM",                 "(Denver Embedded Trace)", },
+       { 0x3eb,  0x211, "Tegra 210 ROM",              "(ROM Table)", },
        { 0x3eb,  0x302, "Denver Debug",               "(Debug Unit)", },
        { 0x3eb,  0x402, "Denver PMU",                 "(Performance Monitor Unit)", },
        /* legacy comment: 0x113: what? */
@@ -1466,8 +1438,11 @@ int dap_info_command(struct command_invocation *cmd,
        case IDR_JEP106_ARM | AP_TYPE_JTAG_AP:
                command_print(cmd, "\tType is JTAG-AP");
                break;
-       case IDR_JEP106_ARM | AP_TYPE_AHB_AP:
-               command_print(cmd, "\tType is MEM-AP AHB");
+       case IDR_JEP106_ARM | AP_TYPE_AHB3_AP:
+               command_print(cmd, "\tType is MEM-AP AHB3");
+               break;
+       case IDR_JEP106_ARM | AP_TYPE_AHB5_AP:
+               command_print(cmd, "\tType is MEM-AP AHB5");
                break;
        case IDR_JEP106_ARM | AP_TYPE_APB_AP:
                command_print(cmd, "\tType is MEM-AP APB");
@@ -1639,8 +1614,10 @@ COMMAND_HANDLER(handle_dap_info_command)
                break;
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
-               if (apsel > DP_APSEL_MAX)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+               if (apsel > DP_APSEL_MAX) {
+                       command_print(CMD, "Invalid AP number");
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
+               }
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1662,8 +1639,10 @@ COMMAND_HANDLER(dap_baseaddr_command)
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
                /* AP address is in bits 31:24 of DP_SELECT */
-               if (apsel > DP_APSEL_MAX)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+               if (apsel > DP_APSEL_MAX) {
+                       command_print(CMD, "Invalid AP number");
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
+               }
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1703,7 +1682,7 @@ COMMAND_HANDLER(dap_memaccess_command)
        }
        dap->ap[dap->apsel].memaccess_tck = memaccess_tck;
 
-       command_print(CMD, "memory bus access delay set to %" PRIi32 " tck",
+       command_print(CMD, "memory bus access delay set to %" PRIu32 " tck",
                        dap->ap[dap->apsel].memaccess_tck);
 
        return ERROR_OK;
@@ -1716,13 +1695,15 @@ COMMAND_HANDLER(dap_apsel_command)
 
        switch (CMD_ARGC) {
        case 0:
-               command_print(CMD, "%" PRIi32, dap->apsel);
+               command_print(CMD, "%" PRIu32, dap->apsel);
                return ERROR_OK;
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
                /* AP address is in bits 31:24 of DP_SELECT */
-               if (apsel > DP_APSEL_MAX)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+               if (apsel > DP_APSEL_MAX) {
+                       command_print(CMD, "Invalid AP number");
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
+               }
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1740,18 +1721,18 @@ COMMAND_HANDLER(dap_apcsw_command)
 
        switch (CMD_ARGC) {
        case 0:
-               command_print(CMD, "ap %" PRIi32 " selected, csw 0x%8.8" PRIx32,
+               command_print(CMD, "ap %" PRIu32 " selected, csw 0x%8.8" PRIx32,
                        dap->apsel, apcsw);
                return ERROR_OK;
        case 1:
                if (strcmp(CMD_ARGV[0], "default") == 0)
-                       csw_val = CSW_DEFAULT;
+                       csw_val = CSW_AHB_DEFAULT;
                else
                        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], csw_val);
 
                if (csw_val & (CSW_SIZE_MASK | CSW_ADDRINC_MASK)) {
                        LOG_ERROR("CSW value cannot include 'Size' and 'AddrInc' bit-fields");
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
                }
                apcsw = csw_val;
                break;
@@ -1760,7 +1741,7 @@ COMMAND_HANDLER(dap_apcsw_command)
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], csw_mask);
                if (csw_mask & (CSW_SIZE_MASK | CSW_ADDRINC_MASK)) {
                        LOG_ERROR("CSW mask cannot include 'Size' and 'AddrInc' bit-fields");
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
                }
                apcsw = (apcsw & ~csw_mask) | (csw_val & csw_mask);
                break;
@@ -1787,8 +1768,10 @@ COMMAND_HANDLER(dap_apid_command)
        case 1:
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
                /* AP address is in bits 31:24 of DP_SELECT */
-               if (apsel > DP_APSEL_MAX)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
+               if (apsel > DP_APSEL_MAX) {
+                       command_print(CMD, "Invalid AP number");
+                       return ERROR_COMMAND_ARGUMENT_INVALID;
+               }
                break;
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1818,13 +1801,18 @@ COMMAND_HANDLER(dap_apreg_command)
 
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
        /* AP address is in bits 31:24 of DP_SELECT */
-       if (apsel > DP_APSEL_MAX)
-               return ERROR_COMMAND_SYNTAX_ERROR;
+       if (apsel > DP_APSEL_MAX) {
+               command_print(CMD, "Invalid AP number");
+               return ERROR_COMMAND_ARGUMENT_INVALID;
+       }
+
        ap = dap_ap(dap, apsel);
 
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg);
-       if (reg >= 256 || (reg & 3))
-               return ERROR_COMMAND_SYNTAX_ERROR;
+       if (reg >= 256 || (reg & 3)) {
+               command_print(CMD, "Invalid reg value (should be less than 256 and 4 bytes aligned)");
+               return ERROR_COMMAND_ARGUMENT_INVALID;
+       }
 
        if (CMD_ARGC == 3) {
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
@@ -1868,8 +1856,10 @@ COMMAND_HANDLER(dap_dpreg_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], reg);
-       if (reg >= 256 || (reg & 3))
-               return ERROR_COMMAND_SYNTAX_ERROR;
+       if (reg >= 256 || (reg & 3)) {
+               command_print(CMD, "Invalid reg value (should be less than 256 and 4 bytes aligned)");
+               return ERROR_COMMAND_ARGUMENT_INVALID;
+       }
 
        if (CMD_ARGC == 2) {
                COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
@@ -1892,24 +1882,8 @@ COMMAND_HANDLER(dap_dpreg_command)
 COMMAND_HANDLER(dap_ti_be_32_quirks_command)
 {
        struct adiv5_dap *dap = adiv5_get_dap(CMD_DATA);
-       uint32_t enable = dap->ti_be_32_quirks;
-
-       switch (CMD_ARGC) {
-       case 0:
-               break;
-       case 1:
-               COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], enable);
-               if (enable > 1)
-                       return ERROR_COMMAND_SYNTAX_ERROR;
-               break;
-       default:
-               return ERROR_COMMAND_SYNTAX_ERROR;
-       }
-       dap->ti_be_32_quirks = enable;
-       command_print(CMD, "TI BE-32 quirks mode %s",
-               enable ? "enabled" : "disabled");
-
-       return 0;
+       return CALL_COMMAND_HANDLER(handle_command_parse_bool, &dap->ti_be_32_quirks,
+               "TI BE-32 quirks mode");
 }
 
 const struct command_registration dap_instance_commands[] = {

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)