diff options
-rw-r--r-- | doc/openocd.texi | 9 | ||||
-rw-r--r-- | src/target/target.c | 33 |
2 files changed, 31 insertions, 11 deletions
diff --git a/doc/openocd.texi b/doc/openocd.texi index 65075d77..cb340b4b 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2117,14 +2117,15 @@ You can display the list with the @command{targets} This display often has only one CPU; here's what it might look like with more than one: @verbatim - CmdName Type Endian AbsChainPos Name State --- ---------- ---------- ---------- ----------- ------------- ---------- - 0: rm9200.cpu arm920t little 2 rm9200.cpu running - 1: MyTarget cortex_m3 little 0 mychip.cpu halted + TargetName Type Endian TapName State +-- ------------------ ---------- ------ ------------------ ------------ + 0* at91rm9200.cpu arm920t little at91rm9200.cpu running + 1 MyTarget cortex_m3 little mychip.foo tap-disabled @end verbatim One member of that list is the @dfn{current target}, which is implicitly referenced by many commands. +It's the one marked with a @code{*} near the target name. In particular, memory addresses often refer to the address space seen by that current target. Commands like @command{mdw} (memory display words) diff --git a/src/target/target.c b/src/target/target.c index 1c32fdbb..eac87633 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1467,6 +1467,12 @@ static int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, command_print(cmd_ctx,"Target: %s is unknown, try one of:\n", args[0] ); goto DumpTargets; } + if (!target->tap->enabled) { + command_print(cmd_ctx,"Target: TAP %s is disabled, " + "can't be the current target\n", + target->tap->dotted_name); + return ERROR_FAIL; + } cmd_ctx->current_target = target->target_number; return ERROR_OK; @@ -1474,19 +1480,32 @@ static int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, DumpTargets: target = all_targets; - command_print(cmd_ctx, " CmdName Type Endian AbsChainPos Name State "); - command_print(cmd_ctx, "-- ---------- ---------- ---------- ----------- ------------- ----------"); + command_print(cmd_ctx, " TargetName Type Endian TapName State "); + command_print(cmd_ctx, "-- ------------------ ---------- ------ ------------------ ------------"); while (target) { - /* XX: abcdefghij abcdefghij abcdefghij abcdefghij */ - command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %10d %14s %s", + const char *state; + char marker = ' '; + + if (target->tap->enabled) + state = Jim_Nvp_value2name_simple(nvp_target_state, + target->state)->name; + else + state = "tap-disabled"; + + if (cmd_ctx->current_target == target->target_number) + marker = '*'; + + /* keep columns lined up to match the headers above */ + command_print(cmd_ctx, "%2d%c %-18s %-10s %-6s %-18s %s", target->target_number, + marker, target->cmd_name, target_get_name(target), - Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name, - target->tap->abs_chain_position, + Jim_Nvp_value2name_simple(nvp_target_endian, + target->endianness)->name, target->tap->dotted_name, - Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name ); + state); target = target->next; } |