static int mem_ap_target_create(struct target *target, Jim_Interp *interp)
{
- struct mem_ap *mem_ap = calloc(1, sizeof(struct mem_ap));
+ struct mem_ap *mem_ap;
struct adiv5_private_config *pc;
pc = (struct adiv5_private_config *)target->private_config;
return ERROR_FAIL;
}
+ mem_ap = calloc(1, sizeof(struct mem_ap));
+ if (mem_ap == NULL) {
+ LOG_ERROR("Out of memory");
+ return ERROR_FAIL;
+ }
+
mem_ap->ap_num = pc->ap_num;
mem_ap->arm.common_magic = ARM_COMMON_MAGIC;
mem_ap->arm.dap = pc->dap;
return ERROR_OK;
}
+static void mem_ap_deinit_target(struct target *target)
+{
+ LOG_DEBUG("%s", __func__);
+
+ free(target->private_config);
+ free(target->arch_info);
+ return;
+}
+
static int mem_ap_arch_state(struct target *target)
{
LOG_DEBUG("%s", __func__);
{
struct mem_ap *mem_ap = target->arch_info;
- LOG_DEBUG("Reading memory at physical address 0x" TARGET_ADDR_FMT
- "; size %" PRId32 "; count %" PRId32, address, size, count);
+ LOG_DEBUG("Reading memory at physical address " TARGET_ADDR_FMT
+ "; size %" PRIu32 "; count %" PRIu32, address, size, count);
if (count == 0 || buffer == NULL)
return ERROR_COMMAND_SYNTAX_ERROR;
{
struct mem_ap *mem_ap = target->arch_info;
- LOG_DEBUG("Writing memory at physical address 0x" TARGET_ADDR_FMT
- "; size %" PRId32 "; count %" PRId32, address, size, count);
+ LOG_DEBUG("Writing memory at physical address " TARGET_ADDR_FMT
+ "; size %" PRIu32 "; count %" PRIu32, address, size, count);
if (count == 0 || buffer == NULL)
return ERROR_COMMAND_SYNTAX_ERROR;
.target_create = mem_ap_target_create,
.init_target = mem_ap_init_target,
+ .deinit_target = mem_ap_deinit_target,
.examine = mem_ap_examine,
.target_jim_configure = adiv5_jim_configure,