X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Ftarget.c;h=de71b140fd4b4da9d1f5522f2878a211edc30e6a;hp=b7f842e7b8f85e8641a00bc79a9e063774e64395;hb=29000b204d039bc1123027eba755329ab36a3dde;hpb=f94d66d7c5f3c018ba72593b720746e4c5be1a16 diff --git a/src/target/target.c b/src/target/target.c index b7f842e7b8..de71b140fd 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -23,6 +23,7 @@ #include "replacements.h" #include "target.h" +#include "target_request.h" #include "log.h" #include "configuration.h" @@ -31,6 +32,7 @@ #include #include +#include #include #include @@ -81,6 +83,7 @@ extern target_type_t arm920t_target; extern target_type_t arm966e_target; extern target_type_t arm926ejs_target; extern target_type_t xscale_target; +extern target_type_t cortexm3_target; target_type_t *target_types[] = { @@ -91,6 +94,7 @@ target_type_t *target_types[] = &arm966e_target, &arm926ejs_target, &xscale_target, + &cortexm3_target, NULL, }; @@ -650,6 +654,7 @@ int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buff { if ((retval = target->type->write_memory(target, address, 1, size, buffer)) != ERROR_OK) return retval; + return ERROR_OK; } /* handle unaligned head bytes */ @@ -708,6 +713,7 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe { if ((retval = target->type->read_memory(target, address, 1, size, buffer)) != ERROR_OK) return retval; + return ERROR_OK; } /* handle unaligned head bytes */ @@ -873,11 +879,14 @@ int target_register_user_commands(struct command_context_s *cmd_ctx) register_command(cmd_ctx, NULL, "wp", handle_wp_command, COMMAND_EXEC, "set watchpoint
[value] [mask]"); register_command(cmd_ctx, NULL, "rwp", handle_rwp_command, COMMAND_EXEC, "remove watchpoint "); - register_command(cmd_ctx, NULL, "load_image", handle_load_image_command, COMMAND_EXEC, "load_image
['bin'|'ihex']"); + register_command(cmd_ctx, NULL, "load_image", handle_load_image_command, COMMAND_EXEC, "load_image
['bin'|'ihex'|'elf'|'s19']"); register_command(cmd_ctx, NULL, "dump_image", handle_dump_image_command, COMMAND_EXEC, "dump_image
"); register_command(cmd_ctx, NULL, "load_binary", handle_load_image_command, COMMAND_EXEC, "[DEPRECATED] load_binary
"); register_command(cmd_ctx, NULL, "dump_binary", handle_dump_image_command, COMMAND_EXEC, "[DEPRECATED] dump_binary
"); + target_request_register_commands(cmd_ctx); + trace_register_commands(cmd_ctx); + return ERROR_OK; } @@ -995,6 +1004,16 @@ int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **a (*last_target_p)->next = NULL; (*last_target_p)->arch_info = NULL; + /* initialize trace information */ + (*last_target_p)->trace_info = malloc(sizeof(trace_t)); + (*last_target_p)->trace_info->num_trace_points = 0; + (*last_target_p)->trace_info->trace_points_size = 0; + (*last_target_p)->trace_info->trace_points = NULL; + (*last_target_p)->trace_info->trace_history_size = 0; + (*last_target_p)->trace_info->trace_history = NULL; + (*last_target_p)->trace_info->trace_history_pos = 0; + (*last_target_p)->trace_info->trace_history_overflowed = 0; + (*last_target_p)->type->target_command(cmd_ctx, cmd, args, argc, *last_target_p); found = 1; @@ -1654,7 +1673,6 @@ int handle_mw_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - u32 address; u8 *buffer; u32 buf_cnt; u32 image_size; @@ -1668,22 +1686,28 @@ int handle_load_image_command(struct command_context_s *cmd_ctx, char *cmd, char target_t *target = get_current_target(cmd_ctx); - if (argc < 2) + if (argc < 1) { - command_print(cmd_ctx, "usage: load_image
[type]"); + command_print(cmd_ctx, "usage: load_image [address] [type]"); return ERROR_OK; } - identify_image_type(&image.type, (argc == 3) ? args[2] : NULL); - - image.base_address_set = 1; - image.base_address = strtoul(args[1], NULL, 0); + /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */ + if (argc >= 2) + { + image.base_address_set = 1; + image.base_address = strtoul(args[1], NULL, 0); + } + else + { + image.base_address_set = 0; + } image.start_address_set = 0; duration_start_measure(&duration); - if (image_open(&image, args[0], FILEIO_READ) != ERROR_OK) + if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK) { command_print(cmd_ctx, "load_image error: %s", image.error_str); return ERROR_OK; @@ -1769,7 +1793,7 @@ int handle_dump_image_command(struct command_context_s *cmd_ctx, char *cmd, char fileio_close(&fileio); duration_stop_measure(&duration, &duration_text); - command_print(cmd_ctx, "dumped %lli byte in %s", fileio.size, duration_text); + command_print(cmd_ctx, "dumped %"PRIi64" byte in %s", fileio.size, duration_text); free(duration_text); return ERROR_OK; @@ -1852,6 +1876,7 @@ int handle_rbp_command(struct command_context_s *cmd_ctx, char *cmd, char **args int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { target_t *target = get_current_target(cmd_ctx); + int retval; if (argc == 0) { @@ -1895,7 +1920,23 @@ int handle_wp_command(struct command_context_s *cmd_ctx, char *cmd, char **args, { data_mask = strtoul(args[4], NULL, 0); } - watchpoint_add(target, strtoul(args[0], NULL, 0), strtoul(args[1], NULL, 0), type, data_value, data_mask); + + if ((retval = watchpoint_add(target, strtoul(args[0], NULL, 0), + strtoul(args[1], NULL, 0), type, data_value, data_mask)) != ERROR_OK) + { + switch (retval) + { + case ERROR_TARGET_NOT_HALTED: + command_print(cmd_ctx, "target must be halted to set watchpoints"); + break; + case ERROR_TARGET_RESOURCE_NOT_AVAILABLE: + command_print(cmd_ctx, "no more watchpoints available"); + break; + default: + command_print(cmd_ctx, "unknown error, watchpoint not set"); + break; + } + } } else {