X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Farm_dap.c;h=0f2957804c97bd0ace0b94b328b33e79bcfa0218;hb=1fbe8450a9dd99a66f6a4035652beb400deb9277;hp=8c081800fcb37111a909955f261ff9c9560eca81;hpb=414213a5ead0e34dec7f72748dbd5c721cb92c09;p=openocd.git diff --git a/src/target/arm_dap.c b/src/target/arm_dap.c index 8c081800fc..0f2957804c 100644 --- a/src/target/arm_dap.c +++ b/src/target/arm_dap.c @@ -48,7 +48,7 @@ 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 */ @@ -56,9 +56,10 @@ static void dap_instance_init(struct adiv5_dap *dap) /* 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; + dap->ap[i].csw_default = CSW_AHB_DEFAULT; } INIT_LIST_HEAD(&dap->cmd_journal); + INIT_LIST_HEAD(&dap->cmd_pool); } const char *adiv5_dap_name(struct adiv5_dap *self) @@ -132,8 +133,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); } @@ -308,20 +314,25 @@ COMMAND_HANDLER(handle_dap_info_command) struct adiv5_dap *dap = arm->dap; uint32_t apsel; + if (dap == NULL) { + LOG_ERROR("DAP instance not available. Probably a HLA target..."); + return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; + } + switch (CMD_ARGC) { case 0: apsel = dap->apsel; 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: return ERROR_COMMAND_SYNTAX_ERROR; } - return dap_info_command(CMD_CTX, &dap->ap[apsel]); + return dap_info_command(CMD, &dap->ap[apsel]); } static const struct command_registration dap_subcommand_handlers[] = { @@ -363,6 +374,7 @@ static const struct command_registration dap_commands[] = { .mode = COMMAND_CONFIG, .help = "DAP commands", .chain = dap_subcommand_handlers, + .usage = "", }, COMMAND_REGISTRATION_DONE };