ARM11: fix dbgtap JTAG_DEBUG
[openocd.git] / src / target / target.c
index 97a93c06121f409a6f10c14b96a7e4c821f06d7a..28387f447e3bdb4a7493cff5634ba4738299c42d 100644 (file)
@@ -147,6 +147,7 @@ static const Jim_Nvp nvp_target_event[] = {
        { .value = TARGET_EVENT_RESET_START, .name = "reset-start" },
 
        { .value = TARGET_EVENT_RESET_ASSERT_PRE,    .name = "reset-assert-pre" },
+       { .value = TARGET_EVENT_RESET_ASSERT,        .name = "reset-assert" },
        { .value = TARGET_EVENT_RESET_ASSERT_POST,   .name = "reset-assert-post" },
        { .value = TARGET_EVENT_RESET_DEASSERT_PRE,  .name = "reset-deassert-pre" },
        { .value = TARGET_EVENT_RESET_DEASSERT_POST, .name = "reset-deassert-post" },
@@ -154,8 +155,8 @@ static const Jim_Nvp nvp_target_event[] = {
        { .value = TARGET_EVENT_RESET_HALT_POST,     .name = "reset-halt-post" },
        { .value = TARGET_EVENT_RESET_WAIT_PRE,      .name = "reset-wait-pre" },
        { .value = TARGET_EVENT_RESET_WAIT_POST,     .name = "reset-wait-post" },
-       { .value = TARGET_EVENT_RESET_INIT , .name = "reset-init" },
-       { .value = TARGET_EVENT_RESET_END, .name = "reset-end" },
+       { .value = TARGET_EVENT_RESET_INIT,          .name = "reset-init" },
+       { .value = TARGET_EVENT_RESET_END,           .name = "reset-end" },
 
        { .value = TARGET_EVENT_EXAMINE_START, .name = "examine-start" },
        { .value = TARGET_EVENT_EXAMINE_END, .name = "examine-end" },
@@ -522,7 +523,7 @@ int target_examine(void)
        }
        return retval;
 }
-const char *target_get_name(struct target *target)
+const char *target_type_name(struct target *target)
 {
        return target->type->name;
 }
@@ -556,7 +557,7 @@ static int target_soft_reset_halt_imp(struct target *target)
        }
        if (!target->type->soft_reset_halt_imp) {
                LOG_ERROR("Target %s does not support soft_reset_halt",
-                               target->cmd_name);
+                               target_name(target));
                return ERROR_FAIL;
        }
        return target->type->soft_reset_halt_imp(target);
@@ -605,6 +606,10 @@ int target_bulk_write_memory(struct target *target,
 int target_add_breakpoint(struct target *target,
                struct breakpoint *breakpoint)
 {
+       if (target->state != TARGET_HALTED) {
+               LOG_WARNING("target %s is not halted", target->cmd_name);
+               return ERROR_TARGET_NOT_HALTED;
+       }
        return target->type->add_breakpoint(target, breakpoint);
 }
 int target_remove_breakpoint(struct target *target,
@@ -616,6 +621,10 @@ int target_remove_breakpoint(struct target *target,
 int target_add_watchpoint(struct target *target,
                struct watchpoint *watchpoint)
 {
+       if (target->state != TARGET_HALTED) {
+               LOG_WARNING("target %s is not halted", target->cmd_name);
+               return ERROR_TARGET_NOT_HALTED;
+       }
        return target->type->add_watchpoint(target, watchpoint);
 }
 int target_remove_watchpoint(struct target *target,
@@ -766,7 +775,7 @@ int target_init(struct command_context *cmd_ctx)
 
                if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK)
                {
-                       LOG_ERROR("target '%s' init failed", target_get_name(target));
+                       LOG_ERROR("target '%s' init failed", target_name(target));
                        return retval;
                }
 
@@ -1697,8 +1706,8 @@ DumpTargets:
                command_print(CMD_CTX, "%2d%c %-18s %-10s %-6s %-18s %s",
                                          target->target_number,
                                          marker,
-                                         target->cmd_name,
-                                         target_get_name(target),
+                                         target_name(target),
+                                         target_type_name(target),
                                          Jim_Nvp_value2name_simple(nvp_target_endian,
                                                                target->endianness)->name,
                                          target->tap->dotted_name,
@@ -3510,8 +3519,8 @@ void target_handle_event(struct target *target, enum target_event e)
                if (teap->event == e) {
                        LOG_DEBUG("target: (%d) %s (%s) event: %d (%s) action: %s",
                                           target->target_number,
-                                          target->cmd_name,
-                                          target_get_name(target),
+                                          target_name(target),
+                                          target_type_name(target),
                                           e,
                                           Jim_Nvp_value2name_simple(nvp_target_event, e)->name,
                                           Jim_GetString(teap->body, NULL));
@@ -3523,6 +3532,20 @@ void target_handle_event(struct target *target, enum target_event e)
        }
 }
 
+/**
+ * Returns true only if the target has a handler for the specified event.
+ */
+bool target_has_event_action(struct target *target, enum target_event event)
+{
+       struct target_event_action *teap;
+
+       for (teap = target->event_action; teap != NULL; teap = teap->next) {
+               if (teap->event == event)
+                       return true;
+       }
+       return false;
+}
+
 enum target_cfg_param {
        TCFG_TYPE,
        TCFG_EVENT,
@@ -3585,16 +3608,20 @@ static int target_configure(Jim_GetOptInfo *goi, struct target *target)
                case TCFG_TYPE:
                        /* not setable */
                        if (goi->isconfigure) {
-                               Jim_SetResult_sprintf(goi->interp, "not setable: %s", n->name);
+                               Jim_SetResult_sprintf(goi->interp,
+                                               "not settable: %s", n->name);
                                return JIM_ERR;
                        } else {
                        no_params:
                                if (goi->argc != 0) {
-                                       Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
+                                       Jim_WrongNumArgs(goi->interp,
+                                                       goi->argc, goi->argv,
+                                                       "NO PARAMS");
                                        return JIM_ERR;
                                }
                        }
-                       Jim_SetResultString(goi->interp, target_get_name(target), -1);
+                       Jim_SetResultString(goi->interp,
+                                       target_type_name(target), -1);
                        /* loop for more */
                        break;
                case TCFG_EVENT:
@@ -4135,7 +4162,7 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                                || !target->type->deassert_reset) {
                        Jim_SetResult_sprintf(interp,
                                        "No target-specific reset for %s",
-                                       target->cmd_name);
+                                       target_name(target));
                        return JIM_ERR;
                }
                /* determine if we should halt or not. */
@@ -4179,10 +4206,9 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                e = target_wait_state(target, n->value, a);
                if (e != ERROR_OK) {
                        Jim_SetResult_sprintf(goi.interp,
-                                                                  "target: %s wait %s fails (%d) %s",
-                                                                  target->cmd_name,
-                                                                  n->name,
-                                                                  e, target_strerror_safe(e));
+                                       "target: %s wait %s fails (%d) %s",
+                                       target_name(target), n->name,
+                                       e, target_strerror_safe(e));
                        return JIM_ERR;
                } else {
                        return JIM_OK;
@@ -4194,9 +4220,10 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                {
                        struct target_event_action *teap;
                        teap = target->event_action;
-                       command_print(cmd_ctx, "Event actions for target (%d) %s\n",
-                                                  target->target_number,
-                                                  target->cmd_name);
+                       command_print(cmd_ctx,
+                                       "Event actions for target (%d) %s\n",
+                                       target->target_number,
+                                       target_name(target));
                        command_print(cmd_ctx, "%-25s | Body", "Event");
                        command_print(cmd_ctx, "------------------------- | ----------------------------------------");
                        while (teap) {
@@ -4446,7 +4473,9 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                        Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
                        return JIM_ERR;
                }
-               Jim_SetResultString(goi.interp, get_current_target(cmd_ctx)->cmd_name, -1);
+               Jim_SetResultString(goi.interp,
+                               target_name(get_current_target(cmd_ctx)),
+                               -1);
                return JIM_OK;
        case TG_CMD_TYPES:
                if (goi.argc != 0) {
@@ -4469,8 +4498,9 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                target = all_targets;
                while (target) {
                        Jim_ListAppendElement(goi.interp,
-                                                                  Jim_GetResult(goi.interp),
-                                                                  Jim_NewStringObj(goi.interp, target->cmd_name, -1));
+                                       Jim_GetResult(goi.interp),
+                                       Jim_NewStringObj(goi.interp,
+                                               target_name(target), -1));
                        target = target->next;
                }
                return JIM_OK;
@@ -4501,7 +4531,7 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                                        "Target: number %d does not exist", (int)(w));
                        return JIM_ERR;
                }
-               Jim_SetResultString(goi.interp, target->cmd_name, -1);
+               Jim_SetResultString(goi.interp, target_name(target), -1);
                return JIM_OK;
        case TG_CMD_COUNT:
                if (goi.argc != 0) {

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)