diff options
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/arm7_9_common.c | 4 | ||||
-rw-r--r-- | src/target/armv7m.c | 4 | ||||
-rw-r--r-- | src/target/target.c | 11 | ||||
-rw-r--r-- | src/target/target.h | 15 |
4 files changed, 30 insertions, 4 deletions
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 4db26e92..0d202d1a 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2747,7 +2747,7 @@ int arm7_9_checksum_memory(struct target_s *target, u32 address, u32 count, u32* buf_set_u32(reg_params[0].value, 0, 32, address); buf_set_u32(reg_params[1].value, 0, 32, count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params, crc_algorithm->address, crc_algorithm->address + (sizeof(arm7_9_crc_code) - 8), 20000, &armv4_5_info)) != ERROR_OK) { LOG_ERROR("error executing arm7_9 crc algorithm"); @@ -2812,7 +2812,7 @@ int arm7_9_blank_check_memory(struct target_s *target, u32 address, u32 count, u init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); buf_set_u32(reg_params[2].value, 0, 32, 0xff); - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code) - 4), 10000, &armv4_5_info)) != ERROR_OK) { destroy_reg_param(®_params[0]); diff --git a/src/target/armv7m.c b/src/target/armv7m.c index a73e60ea..629ac463 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -613,7 +613,7 @@ int armv7m_checksum_memory(struct target_s *target, u32 address, u32 count, u32* buf_set_u32(reg_params[0].value, 0, 32, address); buf_set_u32(reg_params[1].value, 0, 32, count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params, crc_algorithm->address, crc_algorithm->address + (sizeof(cortex_m3_crc_code)-6), 20000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing cortex_m3 crc algorithm"); @@ -674,7 +674,7 @@ int armv7m_blank_check_memory(struct target_s *target, u32 address, u32 count, u init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); buf_set_u32(reg_params[2].value, 0, 32, 0xff); - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code)-2), 10000, &armv7m_info)) != ERROR_OK) { destroy_reg_param(®_params[0]); diff --git a/src/target/target.c b/src/target/target.c index d5a40195..71eb9d2b 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -537,6 +537,17 @@ int target_write_memory(struct target_s *target, return target->type->write_memory(target, address, size, count, buffer); } +int target_run_algorithm(struct target_s *target, + int num_mem_params, mem_param_t *mem_params, + int num_reg_params, reg_param_t *reg_param, + u32 entry_point, u32 exit_point, + int timeout_ms, void *arch_info) +{ + return target->type->run_algorithm(target, + num_mem_params, mem_params, num_reg_params, reg_param, + entry_point, exit_point, timeout_ms, arch_info); +} + int target_init(struct command_context_s *cmd_ctx) { diff --git a/src/target/target.h b/src/target/target.h index 2214c06e..c319a25b 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -204,6 +204,10 @@ typedef struct target_type_s /* target algorithm support */ int (*run_algorithm_imp)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info); + /** + * Target algorithm support. Do @b not call this method directly, + * use target_run_algorithm() instead. + */ int (*run_algorithm)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info); int (*register_commands)(struct command_context_s *cmd_ctx); @@ -380,6 +384,17 @@ extern int get_num_by_target(target_t *query_target); extern target_t *get_target(const char *id); /** + * Run an algorithm on the @a target given. + * + * This routine is a wrapper for target->type->run_algorithm. + */ +extern int target_run_algorithm(struct target_s *target, + int num_mem_params, mem_param_t *mem_params, + int num_reg_params, reg_param_t *reg_param, + u32 entry_point, u32 exit_point, + int timeout_ms, void *arch_info); + +/** * Read @count items of @a size bytes from the memory of @a target at * the @a address given. * |