int target_poll(struct target_s *target)
{
+ int retval;
+
/* We can't poll until after examine */
if (!target_was_examined(target))
{
/* Fail silently lest we pollute the log */
return ERROR_FAIL;
}
- return target->type->poll(target);
+
+ retval = target->type->poll(target);
+ if (retval != ERROR_OK)
+ return retval;
+
+ if (target->halt_issued)
+ {
+ if (target->state == TARGET_HALTED)
+ {
+ target->halt_issued = false;
+ } else
+ {
+ long long t = timeval_ms() - target->halt_issued_time;
+ if (t>1000)
+ {
+ target->halt_issued = false;
+ LOG_INFO("Halt timed out, wake up GDB.");
+ target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT);
+ }
+ }
+ }
+
+ return ERROR_OK;
}
int target_halt(struct target_s *target)
{
+ int retval;
/* We can't poll until after examine */
if (!target_was_examined(target))
{
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
- return target->type->halt(target);
+
+ retval = target->type->halt(target);
+ if (retval != ERROR_OK)
+ return retval;
+
+ target->halt_issued = true;
+ target->halt_issued_time = timeval_ms();
+
+ return ERROR_OK;
}
int target_resume(struct target_s *target, int current, uint32_t address, int handle_breakpoints, int debug_execution)
{
target->type->virt2phys = default_virt2phys;
}
- target->type->virt2phys = default_virt2phys;
/* a non-invasive way(in terms of patches) to add some code that
* runs before the type->write/read_memory implementation
*/
}
}
+
+/* FIX? should we propagate errors here rather than printing them
+ * and continuing?
+ */
void target_handle_event(target_t *target, enum target_event e)
{
target_event_action_t *teap;
/* do the assert */
if (n->value == NVP_ASSERT) {
- target->type->assert_reset(target);
+ e = target->type->assert_reset(target);
} else {
- target->type->deassert_reset(target);
+ e = target->type->deassert_reset(target);
}
- return JIM_OK;
+ return (e == ERROR_OK) ? JIM_OK : JIM_ERR;
case TS_CMD_HALT:
if (goi.argc) {
Jim_WrongNumArgs(goi.interp, 0, argv, "halt [no parameters]");
}
if (!target->tap->enabled)
goto err_tap_disabled;
- target->type->halt(target);
- return JIM_OK;
+ e = target->type->halt(target);
+ return (e == ERROR_OK) ? JIM_OK : JIM_ERR;
case TS_CMD_WAITSTATE:
/* params: <name> statename timeoutmsecs */
if (goi.argc != 2) {
target->display = 1;
+ target->halt_issued = false;
+
/* initialize trace information */
target->trace_info = malloc(sizeof(trace_t));
target->trace_info->num_trace_points = 0;