X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fsvf%2Fsvf.c;h=4dea968fd471f25b29e4f54e81a1eddd4093ff51;hp=276a374ebfef129b2417001c429456e5aa336d6e;hb=42ef503d37b18d907da16d26e99167566d5aabd1;hpb=592e021543353e6ef2814713f0a1412e4119710a;ds=sidebyside diff --git a/src/svf/svf.c b/src/svf/svf.c index 276a374ebf..4dea968fd4 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -210,14 +210,13 @@ static int svf_read_command_from_file(int fd); static int svf_check_tdo(void); static int svf_add_check_para(uint8_t enabled, int buffer_offset, int bit_len); static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str); -static int handle_svf_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); static int svf_fd = 0; static char *svf_command_buffer = NULL; static int svf_command_buffer_size = 0; static int svf_line_number = 1; -static jtag_tap_t *tap = NULL; +static struct jtag_tap *tap = NULL; #define SVF_MAX_BUFFER_SIZE_TO_COMMIT (4 * 1024) static uint8_t *svf_tdi_buffer = NULL, *svf_tdo_buffer = NULL, *svf_mask_buffer = NULL; @@ -225,14 +224,6 @@ static int svf_buffer_index = 0, svf_buffer_size = 0; static int svf_quiet = 0; -int svf_register_commands(struct command_context_s *cmd_ctx) -{ - register_command(cmd_ctx, NULL, "svf", handle_svf_command, - COMMAND_EXEC, "run svf "); - - return ERROR_OK; -} - static void svf_free_xxd_para(svf_xxr_para_t *para) { if (NULL != para) @@ -310,10 +301,10 @@ int svf_add_statemove(tap_state_t state_to) return ERROR_FAIL; } -static int handle_svf_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +COMMAND_HANDLER(handle_svf_command) { #define SVF_NUM_OF_OPTIONS 1 - int command_num = 0, i; + int command_num = 0; int ret = ERROR_OK; long long time_ago; @@ -325,7 +316,7 @@ static int handle_svf_command(struct command_context_s *cmd_ctx, char *cmd, char // parse variant svf_quiet = 0; - for (i = 1; i < argc; i++) + for (unsigned i = 1; i < argc; i++) { if (!strcmp(args[i], "quiet")) { @@ -685,9 +676,9 @@ static int svf_copy_hexstring_to_binary(char *str, uint8_t **bin, int orig_bit_l str_len--; // check valid - if (str_len > 0 || (ch & ~((1 << (4 - (bit_len % 4))) - 1)) != 0) + if (str_len > 0 || (ch & ~((2 << ((bit_len - 1) % 4)) - 1)) != 0) { - LOG_ERROR("value execede length"); + LOG_ERROR("value execeeds length"); return ERROR_FAIL; } @@ -1468,3 +1459,12 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str) return ERROR_OK; } + +int svf_register_commands(struct command_context_s *cmd_ctx) +{ + register_command(cmd_ctx, NULL, "svf", + &handle_svf_command, COMMAND_EXEC, + "run svf "); + + return ERROR_OK; +}