X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftarget.c;h=ebddbba823d2fca74574169ff33a6640f0caaa23;hb=28f8e9dfb7bfaf87957c95790c3ffe5d9fbd8834;hp=4013442612dd8489074a89911ef7ee27a59671ca;hpb=62fbb0f545213f8a813819f319e20fee8a859319;p=openocd.git diff --git a/src/target/target.c b/src/target/target.c index 4013442612..ebddbba823 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -33,15 +33,16 @@ #include "config.h" #endif +#include +#include + #include "target.h" #include "target_type.h" #include "target_request.h" #include "breakpoints.h" -#include "time_support.h" #include "register.h" #include "trace.h" #include "image.h" -#include "jtag.h" static int target_array2mem(Jim_Interp *interp, struct target *target, int argc, Jim_Obj *const *argv); @@ -63,6 +64,7 @@ extern struct target_type cortexa8_target; extern struct target_type arm11_target; extern struct target_type mips_m4k_target; extern struct target_type avr_target; +extern struct target_type dsp563xx_target; extern struct target_type testee_target; struct target_type *target_types[] = @@ -82,6 +84,7 @@ struct target_type *target_types[] = &arm11_target, &mips_m4k_target, &avr_target, + &dsp563xx_target, &testee_target, NULL, }; @@ -90,7 +93,7 @@ struct target *all_targets = NULL; struct target_event_callback *target_event_callbacks = NULL; struct target_timer_callback *target_timer_callbacks = NULL; -const Jim_Nvp nvp_assert[] = { +static const Jim_Nvp nvp_assert[] = { { .name = "assert", NVP_ASSERT }, { .name = "deassert", NVP_DEASSERT }, { .name = "T", NVP_ASSERT }, @@ -100,7 +103,7 @@ const Jim_Nvp nvp_assert[] = { { .name = NULL, .value = -1 } }; -const Jim_Nvp nvp_error_target[] = { +static const Jim_Nvp nvp_error_target[] = { { .value = ERROR_TARGET_INVALID, .name = "err-invalid" }, { .value = ERROR_TARGET_INIT_FAILED, .name = "err-init-failed" }, { .value = ERROR_TARGET_TIMEOUT, .name = "err-timeout" }, @@ -178,7 +181,7 @@ static const Jim_Nvp nvp_target_event[] = { { .name = NULL, .value = -1 } }; -const Jim_Nvp nvp_target_state[] = { +static const Jim_Nvp nvp_target_state[] = { { .name = "unknown", .value = TARGET_UNKNOWN }, { .name = "running", .value = TARGET_RUNNING }, { .name = "halted", .value = TARGET_HALTED }, @@ -187,7 +190,7 @@ const Jim_Nvp nvp_target_state[] = { { .name = NULL, .value = -1 }, }; -const Jim_Nvp nvp_target_debug_reason [] = { +static const Jim_Nvp nvp_target_debug_reason [] = { { .name = "debug-request" , .value = DBG_REASON_DBGRQ }, { .name = "breakpoint" , .value = DBG_REASON_BREAKPOINT }, { .name = "watchpoint" , .value = DBG_REASON_WATCHPOINT }, @@ -198,7 +201,7 @@ const Jim_Nvp nvp_target_debug_reason [] = { { .name = NULL, .value = -1 }, }; -const Jim_Nvp nvp_target_endian[] = { +static const Jim_Nvp nvp_target_endian[] = { { .name = "big", .value = TARGET_BIG_ENDIAN }, { .name = "little", .value = TARGET_LITTLE_ENDIAN }, { .name = "be", .value = TARGET_BIG_ENDIAN }, @@ -206,7 +209,7 @@ const Jim_Nvp nvp_target_endian[] = { { .name = NULL, .value = -1 }, }; -const Jim_Nvp nvp_reset_modes[] = { +static const Jim_Nvp nvp_reset_modes[] = { { .name = "unknown", .value = RESET_UNKNOWN }, { .name = "run" , .value = RESET_RUN }, { .name = "halt" , .value = RESET_HALT }, @@ -214,6 +217,19 @@ const Jim_Nvp nvp_reset_modes[] = { { .name = NULL , .value = -1 }, }; +const char *debug_reason_name(struct target *t) +{ + const char *cp; + + cp = Jim_Nvp_value2name_simple(nvp_target_debug_reason, + t->debug_reason)->name; + if (!cp) { + LOG_ERROR("Invalid debug reason: %d", (int)(t->debug_reason)); + cp = "(*BUG*unknown*BUG*)"; + } + return cp; +} + const char * target_state_name( struct target *t ) { @@ -2141,8 +2157,9 @@ static void handle_md_output(struct command_context *cmd_ctx, case 2: value_fmt = "%4.2x "; break; case 1: value_fmt = "%2.2x "; break; default: + /* "can't happen", caller checked */ LOG_ERROR("invalid memory read size: %u", size); - exit(-1); + return; } for (unsigned i = 0; i < count; i++) @@ -4590,6 +4607,12 @@ static int jim_target_count(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } static const struct command_registration target_subcommand_handlers[] = { + { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_target_init_command, + .help = "initialize targets", + }, { .name = "create", .mode = COMMAND_ANY, @@ -4803,12 +4826,6 @@ COMMAND_HANDLER(handle_fast_load_command) } static const struct command_registration target_command_handlers[] = { - { - .name = "init", - .mode = COMMAND_CONFIG, - .handler = &handle_target_init_command, - .help = "initialize targets", - }, { .name = "targets", .handler = &handle_targets_command,