adi_v5: enforce check on AP number value
[openocd.git] / src / target / arm_dap.c
index 692feb322fca732f1514edee326670a558c13a4e..3adb4ed267babe0ff5b5fc03274cfb1114deb5a3 100644 (file)
@@ -48,13 +48,15 @@ static void dap_instance_init(struct adiv5_dap *dap)
 {
        int i;
        /* Set up with safe defaults */
-       for (i = 0; i <= 255; i++) {
+       for (i = 0; i <= DP_APSEL_MAX; i++) {
                dap->ap[i].dap = dap;
                dap->ap[i].ap_num = i;
                /* memaccess_tck max is 255 */
                dap->ap[i].memaccess_tck = 255;
                /* Number of bits for tar autoincrement, impl. dep. at least 10 */
                dap->ap[i].tar_autoincr_block = (1<<10);
+               /* default CSW value */
+               dap->ap[i].csw_default = CSW_DEFAULT;
        }
        INIT_LIST_HEAD(&dap->cmd_journal);
 }
@@ -130,8 +132,13 @@ static int dap_init_all(void)
 int dap_cleanup_all(void)
 {
        struct arm_dap_object *obj, *tmp;
+       struct adiv5_dap *dap;
 
        list_for_each_entry_safe(obj, tmp, &all_dap, lh) {
+               dap = &obj->dap;
+               if (dap->ops && dap->ops->quit)
+                       dap->ops->quit(dap);
+
                free(obj->name);
                free(obj);
        }
@@ -141,10 +148,12 @@ int dap_cleanup_all(void)
 
 enum dap_cfg_param {
        CFG_CHAIN_POSITION,
+       CFG_IGNORE_SYSPWRUPACK,
 };
 
 static const Jim_Nvp nvp_config_opts[] = {
        { .name = "-chain-position",   .value = CFG_CHAIN_POSITION },
+       { .name = "-ignore-syspwrupack", .value = CFG_IGNORE_SYSPWRUPACK },
        { .name = NULL, .value = -1 }
 };
 
@@ -177,6 +186,9 @@ static int dap_configure(Jim_GetOptInfo *goi, struct arm_dap_object *dap)
                        /* loop for more */
                        break;
                }
+               case CFG_IGNORE_SYSPWRUPACK:
+                       dap->dap.ignore_syspwrupack = true;
+                       break;
                default:
                        break;
                }
@@ -307,7 +319,7 @@ COMMAND_HANDLER(handle_dap_info_command)
                        break;
                case 1:
                        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel);
-                       if (apsel >= 256)
+                       if (apsel > DP_APSEL_MAX)
                                return ERROR_COMMAND_SYNTAX_ERROR;
                        break;
                default:

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)