X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fjtag%2Ftcl.c;h=3e6074b8a549b2cbd842d66d2d5a6cb9e24890d5;hb=8eb92c7e99c018c1cb48be76b0c9736b6c64cba9;hp=579ca9e598f55d99086cdfda0e9ac2ad4a70d9ae;hpb=d37a10da52bc8e6df4e3df2edd02ddbc29fe3bc4;p=openocd diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 579ca9e5..3e6074b8 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -63,7 +63,7 @@ struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o) if (NULL == cp) cp = "(unknown)"; if (NULL == t) - Jim_SetResult_sprintf(interp, "Tap '%s' could not be found", cp); + Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp); return t; } @@ -145,7 +145,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args endstate = tap_state_by_name(cp); if (endstate < 0) { /* update the error message */ - Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp); + Jim_SetResultFormatted(interp,"endstate: %s invalid", cp); } else { if (!scan_is_safe(endstate)) LOG_WARNING("drscan with unsafe " @@ -242,7 +242,7 @@ static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *ar if (states[i] < 0) { /* update the error message */ - Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp); + Jim_SetResultFormatted(interp,"endstate: %s invalid", cp); return JIM_ERR; } } @@ -419,7 +419,7 @@ static int jtag_tap_configure_cmd(Jim_GetOptInfo *goi, struct jtag_tap * tap) return e; break; default: - Jim_SetResult_sprintf(goi->interp, "unknown event: %s", n->name); + Jim_SetResultFormatted(goi->interp, "unknown event: %s", n->name); return JIM_ERR; } } @@ -443,7 +443,7 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi, jim_wide w; int e = Jim_GetOpt_Wide(goi, &w); if (e != JIM_OK) { - Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name); + Jim_SetResultFormatted(goi->interp, "option: %s bad parameter", n->name); return e; } @@ -451,7 +451,7 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi, uint32_t *new_expected_ids = malloc(expected_len + sizeof(uint32_t)); if (new_expected_ids == NULL) { - Jim_SetResult_sprintf(goi->interp, "no memory"); + Jim_SetResultFormatted(goi->interp, "no memory"); return JIM_ERR; } @@ -481,7 +481,7 @@ static int jim_newtap_ir_param(Jim_Nvp *n, Jim_GetOptInfo *goi, int e = Jim_GetOpt_Wide(goi, &w); if (e != JIM_OK) { - Jim_SetResult_sprintf(goi->interp, + Jim_SetResultFormatted(goi->interp, "option: %s bad parameter", n->name); free((void *)pTap->dotted_name); return e; @@ -545,7 +545,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) pTap = calloc(1, sizeof(struct jtag_tap)); if (!pTap) { - Jim_SetResult_sprintf(goi->interp, "no memory"); + Jim_SetResultFormatted(goi->interp, "no memory"); return JIM_ERR; } @@ -553,7 +553,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) * we expect CHIP + TAP + OPTIONS * */ if (goi->argc < 3) { - Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ...."); + Jim_SetResultFormatted(goi->interp, "Missing CHIP TAP OPTIONS ...."); free(pTap); return JIM_ERR; } @@ -631,7 +631,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) return JIM_OK; } - Jim_SetResult_sprintf(goi->interp, + Jim_SetResultFormatted(goi->interp, "newtap: %s missing IR length", pTap->dotted_name); jtag_tap_free(pTap); @@ -654,7 +654,8 @@ static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e) if (Jim_EvalObj(jteap->interp, jteap->body) != JIM_OK) { - Jim_PrintErrorMessage(jteap->interp); + Jim_MakeErrorMessage(jteap->interp); + LOG_USER("%s", Jim_GetString(Jim_GetResult(jteap->interp), NULL)); continue; } @@ -684,10 +685,12 @@ static int jim_jtag_arp_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)"); return JIM_ERR; } - struct command_context *context = Jim_GetAssocData(interp, "context"); + struct command_context *context = current_command_context(interp); int e = jtag_init_inner(context); if (e != ERROR_OK) { - Jim_SetResult_sprintf(goi.interp, "error: %d", e); + Jim_Obj *eObj = Jim_NewIntObj(goi.interp, e); + Jim_SetResultFormatted(goi.interp, "error: %#s", eObj); + Jim_FreeNewObj(goi.interp, eObj); return JIM_ERR; } return JIM_OK; @@ -701,16 +704,18 @@ static int jim_jtag_arp_init_reset(Jim_Interp *interp, int argc, Jim_Obj *const Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)"); return JIM_ERR; } - struct command_context *context = Jim_GetAssocData(interp, "context"); + struct command_context *context = current_command_context(interp); int e = jtag_init_reset(context); if (e != ERROR_OK) { - Jim_SetResult_sprintf(goi.interp, "error: %d", e); + Jim_Obj *eObj = Jim_NewIntObj(goi.interp, e); + Jim_SetResultFormatted(goi.interp, "error: %#s", eObj); + Jim_FreeNewObj(goi.interp, eObj); return JIM_ERR; } return JIM_OK; } -static int jim_jtag_newtap(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +int jim_jtag_newtap(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1); @@ -754,7 +759,7 @@ static int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *ar Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1); if (goi.argc != 1) { - Jim_SetResult_sprintf(goi.interp, "usage: %s ", cmd_name); + Jim_SetResultFormatted(goi.interp, "usage: %s ", cmd_name); return JIM_ERR; } @@ -768,10 +773,10 @@ static int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *ar // do nothing, just return the value } else if (strcasecmp(cmd_name, "tapenable") == 0) { if (!jtag_tap_enable(t)) - LOG_WARNING("failed to disable tap"); + LOG_WARNING("failed to enable tap %s", t->dotted_name); } else if (strcasecmp(cmd_name, "tapdisable") == 0) { if (!jtag_tap_disable(t)) - LOG_WARNING("failed to disable tap"); + LOG_WARNING("failed to disable tap %s", t->dotted_name); } else { LOG_ERROR("command '%s' unknown", cmd_name); return JIM_ERR; @@ -1248,7 +1253,31 @@ COMMAND_HANDLER(handle_tms_sequence_command) return ERROR_OK; } +COMMAND_HANDLER(handle_jtag_flush_queue_sleep) +{ + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + int sleep_ms; + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], sleep_ms); + + jtag_set_flush_queue_sleep(sleep_ms); + + return ERROR_OK; +} + + + static const struct command_registration jtag_command_handlers[] = { + + { + .name = "jtag_flush_queue_sleep", + .handler = handle_jtag_flush_queue_sleep, + .mode = COMMAND_ANY, + .help = "For debug purposes(simulate long delays of interface) " + "to test performance or change in behavior. Default 0ms.", + .usage = "[sleep in ms]", + }, { .name = "jtag_rclk", .handler = handle_jtag_rclk_command,