return ERROR_OK;
}
-static void exit_handler(void)
-{
- jtag_interface_quit();
-}
static int log_target_callback_event_handler(struct target *target, enum target_event event, void *priv)
{
initialized = 1;
- atexit(exit_handler);
-
command_context_mode(CMD_CTX, COMMAND_EXEC);
if (target_init(CMD_CTX) != ERROR_OK)
return ERROR_FAIL;
LOG_DEBUG("flash init complete");
- if (mflash_init_drivers(CMD_CTX) != ERROR_OK)
+ command_context_mode(CMD_CTX, COMMAND_CONFIG);
+ if (command_run_line(CMD_CTX, "mflash init") != ERROR_OK)
return ERROR_FAIL;
- LOG_DEBUG("mflash init complete");
- if (nand_init(CMD_CTX) != ERROR_OK)
+ if (command_run_line(CMD_CTX, "nand init") != ERROR_OK)
return ERROR_FAIL;
- LOG_DEBUG("NAND init complete");
- if (pld_init(CMD_CTX) != ERROR_OK)
+ if (command_run_line(CMD_CTX, "pld init") != ERROR_OK)
return ERROR_FAIL;
- LOG_DEBUG("pld init complete");
+ command_context_mode(CMD_CTX, COMMAND_EXEC);
/* initialize telnet subsystem */
gdb_target_add_all(all_targets);
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)
+struct command_context *setup_command_handler(Jim_Interp *interp)
{
log_init();
LOG_DEBUG("log_init: complete");
struct command_context *cmd_ctx;
- global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl);
+ global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl, interp);
register_commands(cmd_ctx, NULL, openocd_command_handlers);
/* register subsystem commands */
/* initialize commandline interface */
struct command_context *cmd_ctx;
- cmd_ctx = setup_command_handler();
+ cmd_ctx = setup_command_handler(NULL);
#if BUILD_IOUTIL
if (ioutil_init(cmd_ctx) != ERROR_OK)
return EXIT_FAILURE;
#endif
- ret = server_init();
+ ret = server_init(cmd_ctx);
if (ERROR_OK != ret)
return EXIT_FAILURE;
/* free commandline interface */
command_done(cmd_ctx);
+ jtag_interface_quit();
+
return ret;
}