summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
4289389)
Replace the "struct command *parent" parameter with a string that
contains the command prefix.
This abstracts the openocd code from the knowledge of the tree of
struct command.
This also makes unused the function command_find_in_context(), so
remove it.
Change-Id: I598d60719cfdc1811ee6f6edfff8a116f82c7ed6
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5668
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
{
if (!nand_devices)
return ERROR_OK;
{
if (!nand_devices)
return ERROR_OK;
- struct command *parent = command_find_in_context(cmd_ctx, "nand");
- return register_commands(cmd_ctx, parent, nand_exec_command_handlers);
+
+ return register_commands(cmd_ctx, "nand", nand_exec_command_handlers);
}
COMMAND_HANDLER(handle_nand_init_command)
}
COMMAND_HANDLER(handle_nand_init_command)
FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command)
{
struct esirisc_flash_bank *esirisc_info;
FLASH_BANK_COMMAND_HANDLER(esirisc_flash_bank_command)
{
struct esirisc_flash_bank *esirisc_info;
- struct command *esirisc_cmd;
if (CMD_ARGC < 9)
return ERROR_COMMAND_SYNTAX_ERROR;
if (CMD_ARGC < 9)
return ERROR_COMMAND_SYNTAX_ERROR;
bank->driver_priv = esirisc_info;
/* register commands using existing esirisc context */
bank->driver_priv = esirisc_info;
/* register commands using existing esirisc context */
- esirisc_cmd = command_find_in_context(CMD_CTX, "esirisc");
- register_commands(CMD_CTX, esirisc_cmd, esirisc_flash_command_handlers);
+ register_commands(CMD_CTX, "esirisc", esirisc_flash_command_handlers);
if (!flash_bank_list())
return ERROR_OK;
if (!flash_bank_list())
return ERROR_OK;
- struct command *parent = command_find_in_context(cmd_ctx, "flash");
- return register_commands(cmd_ctx, parent, flash_exec_command_handlers);
+ return register_commands(cmd_ctx, "flash", flash_exec_command_handlers);
}
COMMAND_HANDLER(handle_flash_bank_command)
}
COMMAND_HANDLER(handle_flash_bank_command)
-struct command *command_find_in_context(struct command_context *cmd_ctx,
- const char *name)
-{
- return command_find(cmd_ctx->commands, name);
-}
-
/**
* Add the command into the linked list, sorted by name.
* @param head Address to head of command list pointer, which may be
/**
* Add the command into the linked list, sorted by name.
* @param head Address to head of command list pointer, which may be
-int __register_commands(struct command_context *cmd_ctx, struct command *parent,
+static int ___register_commands(struct command_context *cmd_ctx, struct command *parent,
const struct command_registration *cmds, void *data,
struct target *override_target)
{
const struct command_registration *cmds, void *data,
struct target *override_target)
{
}
if (NULL != cr->chain) {
struct command *p = c ? : parent;
}
if (NULL != cr->chain) {
struct command *p = c ? : parent;
- retval = __register_commands(cmd_ctx, p, cr->chain, data, override_target);
+ retval = ___register_commands(cmd_ctx, p, cr->chain, data, override_target);
if (ERROR_OK != retval)
break;
}
if (ERROR_OK != retval)
break;
}
+int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix,
+ const struct command_registration *cmds, void *data,
+ struct target *override_target)
+{
+ struct command *parent = NULL;
+
+ if (cmd_prefix)
+ parent = command_find(cmd_ctx->commands, cmd_prefix);
+
+ return ___register_commands(cmd_ctx, parent, cmds, data, override_target);
+}
+
int unregister_all_commands(struct command_context *context,
struct command *parent)
{
int unregister_all_commands(struct command_context *context,
struct command *parent)
{
/** Use this as the last entry in an array of command_registration records. */
#define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL }
/** Use this as the last entry in an array of command_registration records. */
#define COMMAND_REGISTRATION_DONE { .name = NULL, .chain = NULL }
-int __register_commands(struct command_context *cmd_ctx, struct command *parent,
+int __register_commands(struct command_context *cmd_ctx, const char *cmd_prefix,
const struct command_registration *cmds, void *data,
struct target *override_target);
const struct command_registration *cmds, void *data,
struct target *override_target);
* Otherwise, the chained commands are added as children of the command.
*
* @param cmd_ctx The command_context in which to register the command.
* Otherwise, the chained commands are added as children of the command.
*
* @param cmd_ctx The command_context in which to register the command.
- * @param parent Register this command as a child of this, or NULL to
+ * @param cmd_prefix Register this command as a child of this, or NULL to
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* NULL for all fields.
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* NULL for all fields.
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
-static inline int register_commands(struct command_context *cmd_ctx, struct command *parent,
+static inline int register_commands(struct command_context *cmd_ctx, const char *cmd_prefix,
const struct command_registration *cmds)
{
const struct command_registration *cmds)
{
- return __register_commands(cmd_ctx, parent, cmds, NULL, NULL);
+ return __register_commands(cmd_ctx, cmd_prefix, cmds, NULL, NULL);
* that command should override the current target
*
* @param cmd_ctx The command_context in which to register the command.
* that command should override the current target
*
* @param cmd_ctx The command_context in which to register the command.
- * @param parent Register this command as a child of this, or NULL to
+ * @param cmd_prefix Register this command as a child of this, or NULL to
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
static inline int register_commands_override_target(struct command_context *cmd_ctx,
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
static inline int register_commands_override_target(struct command_context *cmd_ctx,
- struct command *parent, const struct command_registration *cmds,
+ const char *cmd_prefix, const struct command_registration *cmds,
- return __register_commands(cmd_ctx, parent, cmds, NULL, target);
+ return __register_commands(cmd_ctx, cmd_prefix, cmds, NULL, target);
* is unregistered.
*
* @param cmd_ctx The command_context in which to register the command.
* is unregistered.
*
* @param cmd_ctx The command_context in which to register the command.
- * @param parent Register this command as a child of this, or NULL to
+ * @param cmd_prefix Register this command as a child of this, or NULL to
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* register a top-level command.
* @param cmds Pointer to an array of command_registration records that
* contains the desired command parameters. The last record must have
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
static inline int register_commands_with_data(struct command_context *cmd_ctx,
* @returns ERROR_OK on success; ERROR_FAIL if any registration fails.
*/
static inline int register_commands_with_data(struct command_context *cmd_ctx,
- struct command *parent, const struct command_registration *cmds,
+ const char *cmd_prefix, const struct command_registration *cmds,
- return __register_commands(cmd_ctx, parent, cmds, data, NULL);
+ return __register_commands(cmd_ctx, cmd_prefix, cmds, data, NULL);
int unregister_all_commands(struct command_context *cmd_ctx,
struct command *parent);
int unregister_all_commands(struct command_context *cmd_ctx,
struct command *parent);
-struct command *command_find_in_context(struct command_context *cmd_ctx,
- const char *name);
-
void command_set_output_handler(struct command_context *context,
command_output_handler_t output_handler, void *priv);
void command_set_output_handler(struct command_context *context,
command_output_handler_t output_handler, void *priv);
if (!pld_devices)
return ERROR_OK;
if (!pld_devices)
return ERROR_OK;
- struct command *parent = command_find_in_context(cmd_ctx, "pld");
- return register_commands(cmd_ctx, parent, pld_exec_command_handlers);
+ return register_commands(cmd_ctx, "pld", pld_exec_command_handlers);
}
COMMAND_HANDLER(handle_pld_init_command)
}
COMMAND_HANDLER(handle_pld_init_command)
static int etm_register_user_commands(struct command_context *cmd_ctx)
{
static int etm_register_user_commands(struct command_context *cmd_ctx)
{
- struct command *etm_cmd = command_find_in_context(cmd_ctx, "etm");
- return register_commands(cmd_ctx, etm_cmd, etm_exec_command_handlers);
+ return register_commands(cmd_ctx, "etm", etm_exec_command_handlers);
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)