X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftarget.c;h=73a762d4990a82df9a3cd619385ab48f461989da;hb=adf2a9a267422a2914a50b4a4a35a0e19b25d1c3;hp=9a605f3dca81401c9f445425a47d3867d19bdb04;hpb=4c43afce852b1ed6bff544bed6d28cce3d366886;p=openocd.git diff --git a/src/target/target.c b/src/target/target.c index 9a605f3dca..73a762d499 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++) @@ -2471,7 +2488,7 @@ COMMAND_HANDLER(handle_dump_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD_CTX, - "dumped %zu bytes in %fs (%0.3f kb/s)", fileio.size, + "dumped %ld bytes in %fs (%0.3f kb/s)", (long)fileio.size, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } @@ -4062,6 +4079,11 @@ static int jim_target_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv) struct target *target = Jim_CmdPrivData(goi.interp); if (!target->tap->enabled) return jim_target_tap_disabled(interp); + if (!(target_was_examined(target))) + { + LOG_ERROR("Target not examined yet"); + return ERROR_TARGET_NOT_EXAMINED; + } if (!target->type->assert_reset || !target->type->deassert_reset) { Jim_SetResult_sprintf(interp, @@ -4844,7 +4866,7 @@ static const struct command_registration target_exec_command_handlers[] = { { .name = "fast_load", .handler = &handle_fast_load_command, - .mode = COMMAND_ANY, + .mode = COMMAND_EXEC, .help = "loads active fast load image to current target " "- mainly for profiling purposes", },