X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftarget.c;h=d672649281add2bf6a737b3fa553cda9ffb17833;hb=733dfb288fadefee93e61bb61a39171d210a93aa;hp=993b8c61353c542b050ee89ac701cf2ea814f6b8;hpb=17fa4de8541ac12fad2ce836aa61d22dbf1642c8;p=openocd.git diff --git a/src/target/target.c b/src/target/target.c index 993b8c6135..d672649281 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -34,6 +34,7 @@ #endif #include "target.h" +#include "target_type.h" #include "target_request.h" #include "time_support.h" #include "register.h" @@ -41,8 +42,6 @@ #include "image.h" #include "jtag.h" -#include - static int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); @@ -467,6 +466,11 @@ static int default_examine(struct target_s *target) return ERROR_OK; } +int target_examine_one(struct target_s *target) +{ + return target->type->examine(target); +} + /* Targets that correctly implement init+examine, i.e. * no communication with target during init: * @@ -478,12 +482,16 @@ int target_examine(void) target_t *target = all_targets; while (target) { - if ((retval = target->type->examine(target))!=ERROR_OK) + if ((retval = target_examine_one(target)) != ERROR_OK) return retval; target = target->next; } return retval; } +const char *target_get_name(struct target_s *target) +{ + return target->type->name; +} static int target_write_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { @@ -542,6 +550,27 @@ int target_bulk_write_memory(struct target_s *target, return target->type->bulk_write_memory(target, address, count, buffer); } +int target_add_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint) +{ + return target->type->add_breakpoint(target, breakpoint); +} +int target_remove_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint) +{ + return target->type->remove_breakpoint(target, breakpoint); +} + +int target_add_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint) +{ + return target->type->add_watchpoint(target, watchpoint); +} +int target_remove_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint) +{ + return target->type->remove_watchpoint(target, watchpoint); +} int target_get_gdb_reg_list(struct target_s *target, struct reg_s **reg_list[], int *reg_list_size) @@ -598,7 +627,7 @@ int target_init(struct command_context_s *cmd_ctx) if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK) { - LOG_ERROR("target '%s' init failed", target->type->name); + LOG_ERROR("target '%s' init failed", target_get_name(target)); return retval; } @@ -1451,7 +1480,7 @@ DumpTargets: command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %10d %14s %s", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name, target->tap->abs_chain_position, target->tap->dotted_name, @@ -1914,9 +1943,9 @@ static void handle_md_output(struct command_context_s *cmd_ctx, const char *value_fmt; switch (size) { - case 4: value_fmt = "%8.8x"; break; - case 2: value_fmt = "%4.2x"; break; - case 1: value_fmt = "%2.2x"; break; + case 4: value_fmt = "%8.8x "; break; + case 2: value_fmt = "%4.2x "; break; + case 1: value_fmt = "%2.2x "; break; default: LOG_ERROR("invalid memory read size: %u", size); exit(-1); @@ -1931,7 +1960,7 @@ static void handle_md_output(struct command_context_s *cmd_ctx, "0x%8.8x: ", address + (i*size)); } - u32 value; + u32 value=0; const u8 *value_ptr = buffer + i * size; switch (size) { case 4: value = target_buffer_get_u32(target, value_ptr); break; @@ -3131,7 +3160,7 @@ void target_handle_event( target_t *target, enum target_event e ) LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), e, Jim_Nvp_value2name_simple( nvp_target_event, e )->name, Jim_GetString( teap->body, NULL ) ); @@ -3220,7 +3249,7 @@ static int target_configure( Jim_GetOptInfo *goi, target_t *target ) return JIM_ERR; } } - Jim_SetResultString( goi->interp, target->type->name, -1 ); + Jim_SetResultString( goi->interp, target_get_name(target), -1 ); /* loop for more */ break; case TCFG_EVENT: @@ -3419,7 +3448,7 @@ static int target_configure( Jim_GetOptInfo *goi, target_t *target ) if( e != JIM_OK ){ return e; } - tap = jtag_TapByJimObj( goi->interp, o ); + tap = jtag_tap_by_jim_obj( goi->interp, o ); if( tap == NULL ){ return JIM_ERR; }