X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fxsvf%2Fxsvf.c;h=d9b63163037c55a39675e40e82b27bf6c0501425;hp=013803f6a3e33cce9aa418052358873c7c0be476;hb=d47e1b8f362379d8a2307f49e2b42115a3f40524;hpb=8b4e882a1630d63bbc9840fa3f968e36b6ac3702 diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 013803f6a3..d9b6316303 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -17,6 +17,10 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "xsvf.h" #include "jtag.h" @@ -28,7 +32,6 @@ #include #include #include -#include #include #include @@ -93,7 +96,7 @@ int xsvf_read_xstates(int fd, enum tap_state *path, int max_path, int *path_len) { if (*path_len > max_path) { - WARNING("XSTATE path longer than max_path"); + LOG_WARNING("XSTATE path longer than max_path"); break; } if (read(fd, &uc, 1) < 0) @@ -111,6 +114,7 @@ int xsvf_read_xstates(int fd, enum tap_state *path, int max_path, int *path_len) int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { char c; + u8 buf4[4], buf2[2]; unsigned char uc, uc2; unsigned int ui; unsigned short us; @@ -150,7 +154,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg switch (c) { case 0x00: /* XCOMPLETE */ - DEBUG("XCOMPLETE"); + LOG_DEBUG("XCOMPLETE"); if (jtag_execute_queue() != ERROR_OK) { tdo_mismatch = 1; @@ -158,12 +162,12 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x01: /* XTDOMASK */ - DEBUG("XTDOMASK"); + LOG_DEBUG("XTDOMASK"); if (dr_in_mask && (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_mask) != ERROR_OK)) do_abort = 1; break; case 0x02: /* XSIR */ - DEBUG("XSIR"); + LOG_DEBUG("XSIR"); if (read(xsvf_fd, &c, 1) < 0) do_abort = 1; else @@ -211,7 +215,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x03: /* XSDR */ - DEBUG("XSDR"); + LOG_DEBUG("XSDR"); if (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_out_buf) != ERROR_OK) do_abort = 1; else @@ -222,10 +226,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg field.out_value = dr_out_buf; field.out_mask = NULL; field.in_value = NULL; - field.in_check_value = dr_in_buf; - field.in_check_mask = dr_in_mask; - field.in_handler = NULL; - field.in_handler_priv = NULL; + jtag_set_check_value(&field, dr_in_buf, dr_in_mask, NULL); if (device == -1) jtag_add_plain_dr_scan(1, &field, TAP_PD); else @@ -251,16 +252,16 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x04: /* XRUNTEST */ - DEBUG("XRUNTEST"); - if (read(xsvf_fd, &ui, 4) < 0) + LOG_DEBUG("XRUNTEST"); + if (read(xsvf_fd, buf4, 4) < 0) do_abort = 1; else { - xruntest = ntohl(ui); + xruntest = be_to_h_u32(buf4); } break; case 0x07: /* XREPEAT */ - DEBUG("XREPEAT"); + LOG_DEBUG("XREPEAT"); if (read(xsvf_fd, &c, 1) < 0) do_abort = 1; else @@ -269,12 +270,12 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x08: /* XSDRSIZE */ - DEBUG("XSDRSIZE"); - if (read(xsvf_fd, &ui, 4) < 0) + LOG_DEBUG("XSDRSIZE"); + if (read(xsvf_fd, buf4, 4) < 0) do_abort = 1; else { - xsdrsize = ntohl(ui); + xsdrsize = be_to_h_u32(buf4); free(dr_out_buf); free(dr_in_buf); free(dr_in_mask); @@ -284,7 +285,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x09: /* XSDRTDO */ - DEBUG("XSDRTDO"); + LOG_DEBUG("XSDRTDO"); if (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_out_buf) != ERROR_OK) do_abort = 1; else @@ -299,10 +300,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg field.out_value = dr_out_buf; field.out_mask = NULL; field.in_value = NULL; - field.in_check_value = dr_in_buf; - field.in_check_mask = dr_in_mask; - field.in_handler = NULL; - field.in_handler_priv = NULL; + jtag_set_check_value(&field, dr_in_buf, dr_in_mask, NULL); if (device == -1) jtag_add_plain_dr_scan(1, &field, TAP_PD); else @@ -329,11 +327,11 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x0a: /* XSETDRMASKS */ - printf("unsupported XSETSDRMASKS\n"); + LOG_ERROR("unsupported XSETSDRMASKS\n"); unsupported = 1; break; case 0x0b: /* XSDRINC */ - printf("unsupported XSDRINC\n"); + LOG_ERROR("unsupported XSDRINC\n"); unsupported = 1; break; case 0x0c: /* XSDRB */ @@ -355,7 +353,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg unsupported = 1; break; case 0x12: /* XSTATE */ - DEBUG("XSTATE"); + LOG_DEBUG("XSTATE"); if (read(xsvf_fd, &uc, 1) < 0) do_abort = 1; else @@ -373,7 +371,7 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } break; case 0x13: /* XENDIR */ - DEBUG("XENDIR"); + LOG_DEBUG("XENDIR"); if (read(xsvf_fd, &c, 1) < 0) do_abort = 1; else @@ -384,13 +382,13 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg xendir = 0xd; else { - ERROR("unknown XENDIR endstate"); + LOG_ERROR("unknown XENDIR endstate"); unsupported = 1; } } break; case 0x14: /* XENDDR */ - DEBUG("XENDDR"); + LOG_DEBUG("XENDDR"); if (read(xsvf_fd, &c, 1) < 0) do_abort = 1; else @@ -401,19 +399,19 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg xenddr = 0x6; else { - ERROR("unknown XENDDR endstate"); + LOG_ERROR("unknown XENDDR endstate"); unsupported = 1; } } break; case 0x15: /* XSIR2 */ - DEBUG("XSIR2"); - if (read(xsvf_fd, &us, 2) < 0) + LOG_DEBUG("XSIR2"); + if (read(xsvf_fd, buf2, 2) < 0) do_abort = 1; else { u8 *ir_buf; - us = ntohs(us); + us = be_to_h_u16(buf2); ir_buf = malloc((us + 7) / 8); if (xsvf_read_buffer(us, xsvf_fd, ir_buf) != ERROR_OK) do_abort = 1; @@ -448,19 +446,19 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg } while (c != 0); break; case 0x17: /* XWAIT */ - DEBUG("XWAIT"); - if ((read(xsvf_fd, &uc, 1) < 0) || (read(xsvf_fd, &uc2, 1) < 0) || (read(xsvf_fd, &ui, 4) < 0)) + LOG_DEBUG("XWAIT"); + if ((read(xsvf_fd, &uc, 1) < 0) || (read(xsvf_fd, &uc2, 1) < 0) || (read(xsvf_fd, buf4, 4) < 0)) do_abort = 1; else { jtag_add_statemove(xsvf_to_tap[uc]); - ui = ntohl(ui); + ui = be_to_h_u32(buf4); jtag_add_sleep(ui); jtag_add_statemove(xsvf_to_tap[uc2]); } break; default: - printf("unknown xsvf command (0x%2.2x)\n", c); + LOG_ERROR("unknown xsvf command (0x%2.2x)\n", c); unsupported = 1; } @@ -471,21 +469,18 @@ int handle_xsvf_command(struct command_context_s *cmd_ctx, char *cmd, char **arg if (tdo_mismatch) { command_print(cmd_ctx, "TDO mismatch, aborting"); - jtag_cancel_queue(); return ERROR_OK; } if (unsupported) { command_print(cmd_ctx, "unsupported xsvf command encountered, aborting"); - jtag_cancel_queue(); return ERROR_OK; } if (do_abort) { command_print(cmd_ctx, "premature end detected, aborting"); - jtag_cancel_queue(); return ERROR_OK; }