+ if ((retval = jtag_interface_init(CMD_CTX)) != ERROR_OK)
+ {
+ /* we must be able to set up the jtag interface */
+ return retval;
+ }
+ LOG_DEBUG("jtag interface init complete");
+
+ /* Try to initialize & examine the JTAG chain at this point, but
+ * continue startup regardless */
+ if (jtag_init(CMD_CTX) == ERROR_OK)
+ {
+ LOG_DEBUG("jtag init complete");
+ if (target_examine() == ERROR_OK)
+ {
+ LOG_DEBUG("jtag examine complete");
+ }
+ }
+
+ if (flash_init_drivers(CMD_CTX) != ERROR_OK)
+ return ERROR_FAIL;
+ LOG_DEBUG("flash init complete");
+
+ if (mflash_init_drivers(CMD_CTX) != ERROR_OK)
+ return ERROR_FAIL;
+ LOG_DEBUG("mflash init complete");
+
+ if (nand_init(CMD_CTX) != ERROR_OK)
+ return ERROR_FAIL;
+ LOG_DEBUG("NAND init complete");
+
+ if (pld_init(CMD_CTX) != ERROR_OK)
+ return ERROR_FAIL;
+ LOG_DEBUG("pld init complete");
+
+ /* initialize tcp server */
+ server_init();
+
+ /* initialize telnet subsystem */
+ telnet_init("Open On-Chip Debugger");
+ gdb_init();
+ tcl_init(); /* allows tcl to just connect without going thru telnet */
+
+ target_register_event_callback(log_target_callback_event_handler, CMD_CTX);
+
+ 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;
+
+/* NB! this fn can be invoked outside this file for non PC hosted builds */
+struct command_context *setup_command_handler(void)
+{
+ log_init();
+ LOG_DEBUG("log_init: complete");