X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fhelper%2Fcommand.h;h=1a26c069956af15e6d3302b444ccc5ff8d8e4aca;hb=bb9d9c60264a905926e0d15f84842858d0de80b7;hp=bd24156e31af1d27d9ff7af8329d7be11b7bc89d;hpb=47b8cf84202bf792cf66fbfa01169e9592236b8a;p=openocd diff --git a/src/helper/command.h b/src/helper/command.h index bd24156e..1a26c069 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -49,7 +49,15 @@ struct command_context { Jim_Interp *interp; enum command_mode mode; struct command *commands; - int current_target; + struct target *current_target; + /* The target set by 'targets xx' command or the latest created */ + struct target *current_target_override; + /* If set overrides current_target + * It happens during processing of + * 1) a target prefixed command + * 2) an event handler + * Pay attention to reentrancy when setting override. + */ command_output_handler_t output_handler; void *output_handler_priv; }; @@ -168,6 +176,11 @@ struct command { command_handler_t handler; Jim_CmdProc *jim_handler; void *jim_handler_data; + /* Currently used only for target of target-prefixed cmd. + * Native OpenOCD commands use jim_handler_data exclusively + * as a target override. + * Jim handlers outside of target cmd tree can use + * jim_handler_data for any handler specific data */ enum command_mode mode; struct command *next; }; @@ -307,6 +320,14 @@ struct command_context *current_command_context(Jim_Interp *interp); * creates a command interpreter. */ struct command_context *command_init(const char *startup_tcl, Jim_Interp *interp); +/** + * Shutdown a command context. + * + * Free the command context and the associated Jim interpreter. + * + * @param context The command_context that will be destroyed. + */ +void command_exit(struct command_context *context); /** * Creates a copy of an existing command context. This does not create * a deep copy of the command list, so modifications in one context will