From: Zach W. <zw...@us...> - 2009-11-25 19:56:45
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e2f23c54373097098ef0b59377299d7382f4c58a (commit) via 76b89755c994faa8ff0f646c722373ccb876f744 (commit) via 75e37b5348161c97285b808e792976870c383f4c (commit) via b4c4b5f71ef069a641adad541b42ef79ca43ac60 (commit) via 29772ec37293e7fbc6f11cc8a73b5d4d820707c7 (commit) via 8de1e7bd9eb7f5e1db7ea2f4cb03e73f442a1a12 (commit) via 1595fd7c4b6ea2e2fcd5f82e89a1f46dc8e525e8 (commit) via 16e0404777581e55bb42b95f5c9208b2c411debe (commit) via e7fd1d3d5031a98e56503c46baa0c2f23ac7d88c (commit) from 62e56496009796497665c1d06819c163589a3877 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e2f23c54373097098ef0b59377299d7382f4c58a Author: Zachary T Welch <zw...@su...> Date: Mon Nov 23 09:30:02 2009 -0800 pld: use static registration instead of callback Remove register_callbacks from pld_device structure, using an array of command_registration records instead. diff --git a/src/pld/pld.c b/src/pld/pld.c index 421fc61..24afd07 100644 --- a/src/pld/pld.c +++ b/src/pld/pld.c @@ -74,17 +74,22 @@ COMMAND_HANDLER(handle_pld_device_command) struct pld_device *p, *c; /* register pld specific commands */ - if (pld_drivers[i]->register_commands(CMD_CTX) != ERROR_OK) - { - LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); - exit(-1); + int retval; + if (pld_drivers[i]->commands) { + retval = register_commands(CMD_CTX, NULL, + pld_drivers[i]->commands); + if (ERROR_OK != retval) + { + LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); + return ERROR_FAIL; + } } c = malloc(sizeof(struct pld_device)); c->driver = pld_drivers[i]; c->next = NULL; - int retval = CALL_COMMAND_HANDLER(pld_drivers[i]->pld_device_command, c); + retval = CALL_COMMAND_HANDLER(pld_drivers[i]->pld_device_command, c); if (ERROR_OK != retval) { LOG_ERROR("'%s' driver rejected pld device", CMD_ARGV[0]); diff --git a/src/pld/pld.h b/src/pld/pld.h index b183e3e..1ae775c 100644 --- a/src/pld/pld.h +++ b/src/pld/pld.h @@ -31,7 +31,7 @@ struct pld_driver { char *name; __PLD_DEVICE_COMMAND((*pld_device_command)); - int (*register_commands)(struct command_context *cmd_ctx); + const struct command_registration *commands; int (*load)(struct pld_device *pld_device, const char *filename); }; diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 1025e61..77eb866 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -253,14 +253,9 @@ static const struct command_registration virtex2_command_handler[] = { COMMAND_REGISTRATION_DONE }; -static int virtex2_register_commands(struct command_context *cmd_ctx) -{ - return register_commands(cmd_ctx, NULL, virtex2_command_handler); -} - struct pld_driver virtex2_pld = { .name = "virtex2", - .register_commands = &virtex2_register_commands, + .commands = virtex2_command_handler, .pld_device_command = &virtex2_pld_device_command, .load = &virtex2_load, }; commit 76b89755c994faa8ff0f646c722373ccb876f744 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 01:50:22 2009 -0800 pld: use register_commands() Updates core PLD and virtex2 commands to use register_commands(). diff --git a/src/pld/pld.c b/src/pld/pld.c index 021a8e6..421fc61 100644 --- a/src/pld/pld.c +++ b/src/pld/pld.c @@ -37,7 +37,6 @@ static struct pld_driver *pld_drivers[] = }; static struct pld_device *pld_devices; -static struct command *pld_cmd; struct pld_device *get_pld_device_by_num(int num) { @@ -184,26 +183,52 @@ COMMAND_HANDLER(handle_pld_load_command) return ERROR_OK; } +static const struct command_registration pld_exec_command_handlers[] = { + { + .name = "devices", + .handler = &handle_pld_devices_command, + .mode = COMMAND_EXEC, + .help = "list configured pld devices", + }, + { + .name = "load", + .handler = &handle_pld_load_command, + .mode = COMMAND_EXEC, + .help = "load configuration file into PLD", + .usage = "<device#> <file>", + }, + COMMAND_REGISTRATION_DONE +}; int pld_init(struct command_context *cmd_ctx) { if (!pld_devices) return ERROR_OK; - COMMAND_REGISTER(cmd_ctx, pld_cmd, "devices", - handle_pld_devices_command, COMMAND_EXEC, - "list configured pld devices"); - COMMAND_REGISTER(cmd_ctx, pld_cmd, "load", - handle_pld_load_command, COMMAND_EXEC, - "load configuration <file> into programmable logic device"); - - return ERROR_OK; + struct command *parent = command_find_in_context(cmd_ctx, "pld"); + return register_commands(cmd_ctx, parent, pld_exec_command_handlers); } +static const struct command_registration pld_config_command_handlers[] = { + { + .name = "device", + .mode = COMMAND_CONFIG, + .handler = &handle_pld_device_command, + .help = "configure a PLD device", + .usage = "<driver> ...", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration pld_command_handler[] = { + { + .name = "pld", + .mode = COMMAND_ANY, + .help = "programmable logic device commands", + + .chain = pld_config_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; int pld_register_commands(struct command_context *cmd_ctx) { - pld_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "pld", NULL, COMMAND_ANY, "programmable logic device commands"); - - COMMAND_REGISTER(cmd_ctx, pld_cmd, "device", handle_pld_device_command, COMMAND_CONFIG, NULL); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, pld_command_handler); } diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index 527434a..1025e61 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -233,16 +233,29 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command) return ERROR_OK; } +static const struct command_registration virtex2_exec_command_handlers[] = { + { + .name = "read_stat", + .mode = COMMAND_EXEC, + .handler = &virtex2_handle_read_stat_command, + .help = "read status register", + .usage = "<device_id>", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration virtex2_command_handler[] = { + { + .name = "virtex2", + .mode = COMMAND_ANY, + .help = "Virtex-II specific commands", + .chain = virtex2_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + static int virtex2_register_commands(struct command_context *cmd_ctx) { - struct command *virtex2_cmd = COMMAND_REGISTER(cmd_ctx, NULL, "virtex2", - NULL, COMMAND_ANY, "virtex2 specific commands"); - - COMMAND_REGISTER(cmd_ctx, virtex2_cmd, "read_stat", - &virtex2_handle_read_stat_command, COMMAND_EXEC, - "read Virtex-II status register"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, virtex2_command_handler); } struct pld_driver virtex2_pld = { commit 75e37b5348161c97285b808e792976870c383f4c Author: Zachary T Welch <zw...@su...> Date: Sun Nov 22 01:11:18 2009 -0800 {,x}svf: use register_commands() Use register_commands() for registering {,x}svf commands. diff --git a/src/svf/svf.c b/src/svf/svf.c index 1fc3835..e01b933 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -1460,11 +1460,18 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str) return ERROR_OK; } +static const struct command_registration svf_command_handlers[] = { + { + .name = "svf", + .handler = &handle_svf_command, + .mode = COMMAND_EXEC, + .help = "Runs a SVF file.", + .usage = "<file>", + }, + COMMAND_REGISTRATION_DONE +}; + int svf_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, NULL, "svf", - &handle_svf_command, COMMAND_EXEC, - "run svf <file>"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, svf_command_handlers); } diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 82ddb84..f5c89d4 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -1050,13 +1050,23 @@ COMMAND_HANDLER(handle_xsvf_command) return ERROR_OK; } +static const struct command_registration xsvf_command_handlers[] = { + { + .name = "xsvf", + .handler = &handle_xsvf_command, + .mode = COMMAND_EXEC, + .help = "Runs a XSVF file. If 'virt2' is given, xruntest " + "counts are interpreted as TCK cycles rather than " + "as microseconds. Without the 'quiet' option, all " + "comments, retries, and mismatches will be reported.", + .usage = "<file> [virt2] [quiet]", + }, + COMMAND_REGISTRATION_DONE +}; + int xsvf_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, NULL, "xsvf", - &handle_xsvf_command, COMMAND_EXEC, - "run xsvf <file> [virt2] [quiet]"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, xsvf_command_handlers); } #if 0 /* this comment style used to try and keep uncrustify from adding * at begin of line */ commit b4c4b5f71ef069a641adad541b42ef79ca43ac60 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 21 14:42:05 2009 -0800 server: use register_commands Converts server directory to use new command registration paradigm. diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index be1f8db..cb14cc3 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2326,27 +2326,55 @@ COMMAND_HANDLER(handle_gdb_breakpoint_override_command) return ERROR_OK; } -int gdb_register_commands(struct command_context *command_context) +static const struct command_registration gdb_command_handlers[] = { + { + .name = "gdb_sync", + .handler = &handle_gdb_sync_command, + .mode = COMMAND_ANY, + .help = "next stepi will return immediately allowing " + "GDB to fetch register state without affecting " + "target state", + }, + { + .name = "gdb_port", + .handler = &handle_gdb_port_command, + .mode = COMMAND_ANY, + .help = "daemon configuration command gdb_port", + .usage = "<port>", + }, + { + .name = "gdb_memory_map", + .handler = &handle_gdb_memory_map_command, + .mode = COMMAND_CONFIG, + .help = "enable or disable memory map", + .usage = "enable|disable" + }, + { + .name = "gdb_flash_program", + .handler = &handle_gdb_flash_program_command, + .mode = COMMAND_CONFIG, + .help = "enable or disable flash program", + .usage = "enable|disable" + }, + { + .name = "gdb_report_data_abort", + .handler = &handle_gdb_report_data_abort_command, + .mode = COMMAND_CONFIG, + .help = "enable or disable reporting data aborts", + .usage = "enable|disable" + }, + { + .name = "gdb_breakpoint_override", + .handler = &handle_gdb_breakpoint_override_command, + .mode = COMMAND_EXEC, + .help = "force type of breakpoint " + "used by gdb 'break' commands.", + .usage = "hard|soft|disable", + }, + COMMAND_REGISTRATION_DONE +}; + +int gdb_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(command_context, NULL, "gdb_sync", - handle_gdb_sync_command, COMMAND_ANY, - "next stepi will return immediately allowing GDB to " - "fetch register state without affecting target state"); - COMMAND_REGISTER(command_context, NULL, "gdb_port", - handle_gdb_port_command, COMMAND_ANY, - "daemon configuration command gdb_port"); - COMMAND_REGISTER(command_context, NULL, "gdb_memory_map", - handle_gdb_memory_map_command, COMMAND_CONFIG, - "enable or disable memory map"); - COMMAND_REGISTER(command_context, NULL, "gdb_flash_program", - handle_gdb_flash_program_command, COMMAND_CONFIG, - "enable or disable flash program"); - COMMAND_REGISTER(command_context, NULL, "gdb_report_data_abort", - handle_gdb_report_data_abort_command, COMMAND_CONFIG, - "enable or disable reporting data aborts"); - COMMAND_REGISTER(command_context, NULL, "gdb_breakpoint_override", - handle_gdb_breakpoint_override_command, COMMAND_EXEC, - "hard/soft/disable - force type of breakpoint " - "used by gdb 'break' commands."); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, gdb_command_handlers); } diff --git a/src/server/server.c b/src/server/server.c index 5be1316..50bc00e 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -539,16 +539,21 @@ COMMAND_HANDLER(handle_shutdown_command) return ERROR_COMMAND_CLOSE_CONNECTION; } -int server_register_commands(struct command_context *context) +static const struct command_registration server_command_handlers[] = { + { + .name = "shutdown", + .handler = &handle_shutdown_command, + .mode = COMMAND_ANY, + .help = "shut the server down", + }, + COMMAND_REGISTRATION_DONE +}; + +int server_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(context, NULL, "shutdown", - handle_shutdown_command, COMMAND_ANY, - "shut the server down"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, server_command_handlers); } - SERVER_PORT_COMMAND() { switch (CMD_ARGC) { diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index a12176e..22469a4 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -175,10 +175,19 @@ COMMAND_HANDLER(handle_tcl_port_command) return CALL_COMMAND_HANDLER(server_port_command, &tcl_port); } +static const struct command_registration tcl_command_handlers[] = { + { + .name = "tcl_port", + .handler = &handle_tcl_port_command, + .mode = COMMAND_CONFIG, + .help = "port on which to listen " + "for incoming TCL syntax", + .usage = "<port>", + }, + COMMAND_REGISTRATION_DONE +}; + int tcl_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, NULL, "tcl_port", - handle_tcl_port_command, COMMAND_CONFIG, - "port on which to listen for incoming TCL syntax"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, tcl_command_handlers); } diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index c52119d..8a86efa 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -616,17 +616,25 @@ COMMAND_HANDLER(handle_exit_command) return ERROR_COMMAND_CLOSE_CONNECTION; } -int telnet_register_commands(struct command_context *command_context) +static const struct command_registration telnet_command_handlers[] = { + { + .name = "exit", + .handler = &handle_exit_command, + .mode = COMMAND_EXEC, + .help = "exit telnet session", + }, + { + .name = "telnet_port", + .handler = &handle_telnet_port_command, + .mode = COMMAND_ANY, + .help = "port on which to listen " + "for incoming telnet connections", + .usage = "<port>", + }, + COMMAND_REGISTRATION_DONE +}; + +int telnet_register_commands(struct command_context *cmd_ctx) { - COMMAND_REGISTER(command_context, NULL, "exit", - &handle_exit_command, COMMAND_EXEC, - "exit telnet session"); - - COMMAND_REGISTER(command_context, NULL, "telnet_port", - &handle_telnet_port_command, COMMAND_ANY, - "port on which to listen for incoming telnet connections"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, telnet_command_handlers); } - - commit 29772ec37293e7fbc6f11cc8a73b5d4d820707c7 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 20 15:52:18 2009 -0800 log: use register_commands() Use register_commands() for logging callbacks. Improve help and add proper usage. diff --git a/src/helper/log.c b/src/helper/log.c index b1352a3..3799fb3 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -316,15 +316,29 @@ COMMAND_HANDLER(handle_log_output_command) return ERROR_OK; } +static struct command_registration log_command_handlers[] = { + { + .name = "log_output", + .handler = &handle_log_output_command, + .mode = COMMAND_ANY, + .help = "redirect logging to a file (default: stderr)", + .usage = "<file_name>", + }, + { + .name = "debug_level", + .handler = &handle_debug_level_command, + .mode = COMMAND_ANY, + .help = "sets the verbosity level of debugging output", + .usage = "<level:0-3>", + }, + COMMAND_REGISTRATION_DONE +}; + int log_register_commands(struct command_context *cmd_ctx) { start = timeval_ms(); - COMMAND_REGISTER(cmd_ctx, NULL, "log_output", handle_log_output_command, - COMMAND_ANY, "redirect logging to <file> (default: stderr)"); - COMMAND_REGISTER(cmd_ctx, NULL, "debug_level", handle_debug_level_command, - COMMAND_ANY, "adjust debug level <0-3>"); - return ERROR_OK; + return register_commands(cmd_ctx, NULL, log_command_handlers); } int log_init(struct command_context *cmd_ctx) commit 8de1e7bd9eb7f5e1db7ea2f4cb03e73f442a1a12 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 20 15:47:08 2009 -0800 ioutil: use register_commands() Use table instead of individual calls. Add proper usage information. diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c index 52ecb9f..58521ee 100644 --- a/src/helper/ioutil.c +++ b/src/helper/ioutil.c @@ -643,27 +643,55 @@ static int zylinjtag_Jim_Command_mac(Jim_Interp *interp, int argc, } +static const struct command_registration ioutil_command_handlers[] = { + { + .name = "rm", + .handler = &handle_rm_command, + .mode = COMMAND_ANY, + .help = "remove file", + .usage= "<file_name>", + }, + { + .name = "cat", + .handler = &handle_cat_command, + .mode = COMMAND_ANY, + .help = "display file content", + .usage= "<file_name>", + }, + { + .name = "trunc", + .handler = &handle_trunc_command, + .mode = COMMAND_ANY, + .help = "truncate a file 0 size", + .usage= "<file_name>", + }, + { + .name = "cp", + .handler = &handle_cp_command, + .mode = COMMAND_ANY, + .help = "copy a file", + .usage = "<src> <dst>", + }, + { + .name = "append_file", + .handler = &handle_append_command, + .mode = COMMAND_ANY, + .help = "append a variable number of strings to a file", + .usage= "<file_name> [<string> ...]", + }, + { + .name = "meminfo", + .handler = &handle_meminfo_command, + .mode = COMMAND_ANY, + .help = "display available ram memory", + }, + COMMAND_REGISTRATION_DONE +}; int ioutil_init(struct command_context *cmd_ctx) { - COMMAND_REGISTER(cmd_ctx, NULL, "rm", handle_rm_command, COMMAND_ANY, - "remove file"); - - COMMAND_REGISTER(cmd_ctx, NULL, "cat", handle_cat_command, COMMAND_ANY, - "display file content"); - - COMMAND_REGISTER(cmd_ctx, NULL, "trunc", handle_trunc_command, COMMAND_ANY, - "truncate a file to 0 size"); - - COMMAND_REGISTER(cmd_ctx, NULL, "cp", handle_cp_command, - COMMAND_ANY, "copy a file <from> <to>"); - - COMMAND_REGISTER(cmd_ctx, NULL, "append_file", handle_append_command, - COMMAND_ANY, "append a variable number of strings to a file"); - - COMMAND_REGISTER(cmd_ctx, NULL, "meminfo", handle_meminfo_command, - COMMAND_ANY, "display available ram memory"); + register_commands(cmd_ctx, NULL, ioutil_command_handlers); Jim_CreateCommand(interp, "rm", zylinjtag_Jim_Command_rm, NULL, NULL); commit 1595fd7c4b6ea2e2fcd5f82e89a1f46dc8e525e8 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 20 16:58:45 2009 -0800 openocd: use register_commands() Use register_commands() for top-level version and init command. diff --git a/src/openocd.c b/src/openocd.c index 379373c..63289e4 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -159,6 +159,23 @@ COMMAND_HANDLER(handle_init_command) return ERROR_OK; } +static const struct command_registration openocd_command_handlers[] = { + { + .name = "version", + .handler = &handle_version_command, + .mode = COMMAND_EXEC, + .help = "show program version", + }, + { + .name = "init", + .handler = &handle_init_command, + .mode = COMMAND_ANY, + .help = "Initializes configured targets and servers. " + "If called more than once, does nothing.", + }, + COMMAND_REGISTRATION_DONE +}; + struct command_context *global_cmd_ctx; /// src/hello.c gives a simple example for writing new command modules @@ -171,9 +188,7 @@ struct command_context *setup_command_handler(void) global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl); - COMMAND_REGISTER(cmd_ctx, NULL, "version", handle_version_command, - COMMAND_EXEC, "show OpenOCD version"); - + register_commands(cmd_ctx, NULL, openocd_command_handlers); /* register subsystem commands */ hello_register_commands(cmd_ctx); server_register_commands(cmd_ctx); @@ -198,9 +213,6 @@ struct command_context *setup_command_handler(void) LOG_OUTPUT(OPENOCD_VERSION "\n"); - COMMAND_REGISTER(cmd_ctx, NULL, "init", handle_init_command, - COMMAND_ANY, "initializes target and servers - nop on subsequent invocations"); - return cmd_ctx; } commit 16e0404777581e55bb42b95f5c9208b2c411debe Author: Zachary T Welch <zw...@su...> Date: Sat Nov 21 15:52:12 2009 -0800 demonstrate chaining with foo commands Use the new command registration chaining capabilities to eliminate the foo_register_commands helper, folding its remaining command handler setup into the hello_command_handlers registration array. diff --git a/src/hello.c b/src/hello.c index 6f02494..9a1bf92 100644 --- a/src/hello.c +++ b/src/hello.c @@ -75,16 +75,6 @@ static const struct command_registration foo_command_handlers[] = { COMMAND_REGISTRATION_DONE }; -int foo_register_commands(struct command_context *cmd_ctx) -{ - // register several commands under the foo command - struct command *cmd = COMMAND_REGISTER(cmd_ctx, NULL, "foo", - NULL, COMMAND_ANY, "example command handler skeleton"); - - - return register_commands(cmd_ctx, cmd, foo_command_handlers); -} - static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name) { if (CMD_ARGC > 1) @@ -119,12 +109,17 @@ static const struct command_registration hello_command_handlers[] = { .help = "prints a warm welcome", .usage = "[<name>]", }, + { + .name = "foo", + .mode = COMMAND_ANY, + .help = "example command handler skeleton", + + .chain = foo_command_handlers, + }, COMMAND_REGISTRATION_DONE }; int hello_register_commands(struct command_context *cmd_ctx) { - foo_register_commands(cmd_ctx); - return register_commands(cmd_ctx, NULL, hello_command_handlers); } commit e7fd1d3d5031a98e56503c46baa0c2f23ac7d88c Author: Zachary T Welch <zw...@su...> Date: Sat Nov 21 13:49:00 2009 -0800 hello: use register_commands() Use new register_commands() with command registration table. diff --git a/src/hello.c b/src/hello.c index 8c97a40..6f02494 100644 --- a/src/hello.c +++ b/src/hello.c @@ -53,24 +53,36 @@ COMMAND_HANDLER(handle_flag_command) &foo_flag, "foo flag"); } +static const struct command_registration foo_command_handlers[] = { + { + .name = "bar", + .handler = &handle_foo_command, + .mode = COMMAND_ANY, + .help = "<address> [enable|disable] - an example command", + }, + { + .name = "baz", + .handler = &handle_foo_command, + .mode = COMMAND_ANY, + .help = "<address> [enable|disable] - a sample command", + }, + { + .name = "flag", + .handler = &handle_flag_command, + .mode = COMMAND_ANY, + .help = "[on|off] - set a flag", + }, + COMMAND_REGISTRATION_DONE +}; + int foo_register_commands(struct command_context *cmd_ctx) { // register several commands under the foo command struct command *cmd = COMMAND_REGISTER(cmd_ctx, NULL, "foo", - NULL, COMMAND_ANY, "foo: command handler skeleton"); + NULL, COMMAND_ANY, "example command handler skeleton"); - COMMAND_REGISTER(cmd_ctx, cmd, "bar", - &handle_foo_command, COMMAND_ANY, - "<address> [enable|disable] - an example command"); - COMMAND_REGISTER(cmd_ctx, cmd, "baz", - &handle_foo_command, COMMAND_ANY, - "<address> [enable|disable] - a sample command"); - COMMAND_REGISTER(cmd_ctx, cmd, "flag", - &handle_flag_command, COMMAND_ANY, - "[on|off] - set a flag"); - - return ERROR_OK; + return register_commands(cmd_ctx, cmd, foo_command_handlers); } static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name) @@ -99,12 +111,20 @@ COMMAND_HANDLER(handle_hello_command) return retval; } +static const struct command_registration hello_command_handlers[] = { + { + .name = "hello", + .handler = &handle_hello_command, + .mode = COMMAND_ANY, + .help = "prints a warm welcome", + .usage = "[<name>]", + }, + COMMAND_REGISTRATION_DONE +}; + int hello_register_commands(struct command_context *cmd_ctx) { foo_register_commands(cmd_ctx); - struct command *cmd = COMMAND_REGISTER(cmd_ctx, NULL, "hello", - &handle_hello_command, COMMAND_ANY, - "[<name>] - prints a warm welcome"); - return cmd ? ERROR_OK : -ENOMEM; + return register_commands(cmd_ctx, NULL, hello_command_handlers); } ----------------------------------------------------------------------- Summary of changes: src/hello.c | 65 ++++++++++++++++++++++++--------------- src/helper/ioutil.c | 62 +++++++++++++++++++++++++++---------- src/helper/log.c | 24 +++++++++++--- src/openocd.c | 24 +++++++++++---- src/pld/pld.c | 68 ++++++++++++++++++++++++++++++----------- src/pld/pld.h | 2 +- src/pld/virtex2.c | 32 ++++++++++++------- src/server/gdb_server.c | 72 ++++++++++++++++++++++++++++++------------- src/server/server.c | 19 +++++++---- src/server/tcl_server.c | 17 ++++++++-- src/server/telnet_server.c | 32 ++++++++++++------- src/svf/svf.c | 17 +++++++--- src/xsvf/xsvf.c | 20 +++++++++--- 13 files changed, 314 insertions(+), 140 deletions(-) hooks/post-receive -- Main OpenOCD repository |