target/arm_tpiu_swo: rewrite commands 'configure' and 'cget' as COMMAND_HANDLER
Rewrite only the command, but still use the old jimtcl specific code in arm_tpiu_swo_configure(), shared with command 'create'. Change-Id: If2258f048403f54faf229e602d9b395b71894f97 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8900 Tested-by: jenkins
This commit is contained in:
@@ -554,20 +554,28 @@ err_no_params:
|
|||||||
return JIM_ERR;
|
return JIM_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
COMMAND_HANDLER(handle_arm_tpiu_swo_configure)
|
||||||
{
|
{
|
||||||
struct command *c = jim_to_command(interp);
|
struct arm_tpiu_swo_object *obj = CMD_DATA;
|
||||||
struct jim_getopt_info goi;
|
|
||||||
|
|
||||||
jim_getopt_setup(&goi, interp, argc - 1, argv + 1);
|
if (!CMD_ARGC)
|
||||||
goi.is_configure = !strcmp(c->name, "configure");
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||||
if (goi.argc < 1) {
|
|
||||||
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv,
|
struct jim_getopt_info goi;
|
||||||
"missing: -option ...");
|
jim_getopt_setup(&goi, CMD_CTX->interp, CMD_ARGC, CMD_JIMTCL_ARGV);
|
||||||
return JIM_ERR;
|
goi.is_configure = !strcmp(CMD_NAME, "configure");
|
||||||
}
|
|
||||||
struct arm_tpiu_swo_object *obj = c->jim_handler_data;
|
int e = arm_tpiu_swo_configure(&goi, obj);
|
||||||
return arm_tpiu_swo_configure(&goi, obj);
|
|
||||||
|
int reslen;
|
||||||
|
const char *result = Jim_GetString(Jim_GetResult(CMD_CTX->interp), &reslen);
|
||||||
|
if (reslen > 0)
|
||||||
|
command_print(CMD, "%s", result);
|
||||||
|
|
||||||
|
if (e != JIM_OK)
|
||||||
|
return ERROR_FAIL;
|
||||||
|
|
||||||
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wrap_write_u32(struct target *target, struct adiv5_ap *tpiu_ap,
|
static int wrap_write_u32(struct target *target, struct adiv5_ap *tpiu_ap,
|
||||||
@@ -872,14 +880,14 @@ static const struct command_registration arm_tpiu_swo_instance_command_handlers[
|
|||||||
{
|
{
|
||||||
.name = "configure",
|
.name = "configure",
|
||||||
.mode = COMMAND_ANY,
|
.mode = COMMAND_ANY,
|
||||||
.jim_handler = jim_arm_tpiu_swo_configure,
|
.handler = handle_arm_tpiu_swo_configure,
|
||||||
.help = "configure a new TPIU/SWO for use",
|
.help = "configure a new TPIU/SWO for use",
|
||||||
.usage = "[attribute value ...]",
|
.usage = "[attribute value ...]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "cget",
|
.name = "cget",
|
||||||
.mode = COMMAND_ANY,
|
.mode = COMMAND_ANY,
|
||||||
.jim_handler = jim_arm_tpiu_swo_configure,
|
.handler = handle_arm_tpiu_swo_configure,
|
||||||
.help = "returns the specified TPIU/SWO attribute",
|
.help = "returns the specified TPIU/SWO attribute",
|
||||||
.usage = "attribute",
|
.usage = "attribute",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user