{ .value = TARGET_EVENT_GDB_FLASH_ERASE_START, .name = "gdb-flash-erase-start" },
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_END , .name = "gdb-flash-erase-end" },
+ { .value = TARGET_EVENT_TRACE_CONFIG, .name = "trace-config" },
+
{ .name = NULL, .value = -1 }
};
}
/* returns a pointer to the n-th configured target */
-static struct target *get_target_by_num(int num)
+struct target *get_target_by_num(int num)
{
struct target *target = all_targets;
break;
}
- if ((rp & (block_size - 1)) || rp < fifo_start_addr || rp >= fifo_end_addr) {
+ if (((rp - fifo_start_addr) & (block_size - 1)) || rp < fifo_start_addr || rp >= fifo_end_addr) {
LOG_ERROR("corrupted fifo read pointer 0x%" PRIx32, rp);
break;
}
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
+ if (!target->type->read_memory) {
+ LOG_ERROR("Target %s doesn't support read_memory", target_name(target));
+ return ERROR_FAIL;
+ }
return target->type->read_memory(target, address, size, count, buffer);
}
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
+ if (!target->type->read_phys_memory) {
+ LOG_ERROR("Target %s doesn't support read_phys_memory", target_name(target));
+ return ERROR_FAIL;
+ }
return target->type->read_phys_memory(target, address, size, count, buffer);
}
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
+ if (!target->type->write_memory) {
+ LOG_ERROR("Target %s doesn't support write_memory", target_name(target));
+ return ERROR_FAIL;
+ }
return target->type->write_memory(target, address, size, count, buffer);
}
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
+ if (!target->type->write_phys_memory) {
+ LOG_ERROR("Target %s doesn't support write_phys_memory", target_name(target));
+ return ERROR_FAIL;
+ }
return target->type->write_phys_memory(target, address, size, count, buffer);
}
target->examined = false;
}
-static int err_read_phys_memory(struct target *target, uint32_t address,
- uint32_t size, uint32_t count, uint8_t *buffer)
-{
- LOG_ERROR("Not implemented: %s", __func__);
- return ERROR_FAIL;
-}
-
-static int err_write_phys_memory(struct target *target, uint32_t address,
- uint32_t size, uint32_t count, const uint8_t *buffer)
-{
- LOG_ERROR("Not implemented: %s", __func__);
- return ERROR_FAIL;
-}
-
static int handle_target(void *priv);
static int target_init_one(struct command_context *cmd_ctx,
* implement it in stages, but warn if we need to do so.
*/
if (type->mmu) {
- if (type->write_phys_memory == NULL) {
- LOG_ERROR("type '%s' is missing write_phys_memory",
- type->name);
- type->write_phys_memory = err_write_phys_memory;
- }
- if (type->read_phys_memory == NULL) {
- LOG_ERROR("type '%s' is missing read_phys_memory",
- type->name);
- type->read_phys_memory = err_read_phys_memory;
- }
if (type->virt2phys == NULL) {
LOG_ERROR("type '%s' is missing virt2phys", type->name);
type->virt2phys = identity_virt2phys;
return target_free_working_area_restore(target, area, 1);
}
+void target_quit(void)
+{
+ struct target_event_callback *pe = target_event_callbacks;
+ while (pe) {
+ struct target_event_callback *t = pe->next;
+ free(pe);
+ pe = t;
+ }
+ target_event_callbacks = NULL;
+
+ struct target_timer_callback *pt = target_timer_callbacks;
+ while (pt) {
+ struct target_timer_callback *t = pt->next;
+ free(pt);
+ pt = t;
+ }
+ target_timer_callbacks = NULL;
+
+ for (struct target *target = all_targets;
+ target; target = target->next) {
+ if (target->type->deinit_target)
+ target->type->deinit_target(target);
+ }
+}
+
/* free resources and restore memory, if restoring memory fails,
* free up resources anyway
*/
target->backoff.times *= 2;
target->backoff.times++;
}
- LOG_USER("Polling target %s failed, GDB will be halted. Polling again in %dms",
- target_name(target),
- target->backoff.times * polling_interval);
/* Tell GDB to halt the debugger. This allows the user to
* run monitor commands to handle the situation.
*/
target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT);
- return retval;
}
- /* Since we succeeded, we reset backoff count */
if (target->backoff.times > 0) {
- LOG_USER("Polling target %s succeeded again, trying to reexamine", target_name(target));
+ LOG_USER("Polling target %s failed, trying to reexamine", target_name(target));
target_reset_examined(target);
retval = target_examine_one(target);
/* Target examination could have failed due to unstable connection,
* but we set the examined flag anyway to repoll it later */
if (retval != ERROR_OK) {
target->examined = true;
+ LOG_USER("Examination failed, GDB will be halted. Polling again in %dms",
+ target->backoff.times * polling_interval);
return retval;
}
}
+ /* Since we succeeded, we reset backoff count */
target->backoff.times = 0;
}
}