- server_register_commands(cmd_ctx);
- telnet_register_commands(cmd_ctx);
- gdb_register_commands(cmd_ctx);
- log_register_commands(cmd_ctx);
- jtag_register_commands(cmd_ctx);
- interpreter_register_commands(cmd_ctx);
- xsvf_register_commands(cmd_ctx);
- target_register_commands(cmd_ctx);
- flash_register_commands(cmd_ctx);
- nand_register_commands(cmd_ctx);
- pld_register_commands(cmd_ctx);
-
- if (log_init(cmd_ctx) != ERROR_OK)
+ typedef int (*command_registrant_t)(struct command_context *cmd_ctx_value);
+ static const command_registrant_t command_registrants[] = {
+ &openocd_register_commands,
+ &server_register_commands,
+ &gdb_register_commands,
+ &log_register_commands,
+ &transport_register_commands,
+ &interface_register_commands,
+ &target_register_commands,
+ &flash_register_commands,
+ &nand_register_commands,
+ &pld_register_commands,
+ &mflash_register_commands,
+ NULL
+ };
+ for (unsigned i = 0; NULL != command_registrants[i]; i++) {
+ int retval = (*command_registrants[i])(cmd_ctx);
+ if (ERROR_OK != retval) {
+ command_done(cmd_ctx);
+ return NULL;
+ }
+ }
+ LOG_DEBUG("command registration: complete");
+
+ LOG_OUTPUT(OPENOCD_VERSION "\n"
+ "Licensed under GNU GPL v2\n");
+
+ global_cmd_ctx = cmd_ctx;
+
+ return cmd_ctx;
+}
+
+/** OpenOCD runtime meat that can become single-thread in future. It parse
+ * commandline, reads configuration, sets up the target and starts server loop.
+ * Commandline arguments are passed into this function from openocd_main().
+ */
+static int openocd_thread(int argc, char *argv[], struct command_context *cmd_ctx)
+{
+ int ret;
+
+ if (parse_cmdline_args(cmd_ctx, argc, argv) != ERROR_OK)