move server_init() to openocd_main()
Moves the telnet and TCL server startup to server_init(), moving their respective command registration in to server_register_commands(). Adds proper error checking for these particular startup processes. Moves the core server startup to openocd_main(), improving related error checking and preparing to defer 'init'.__archive__
parent
ec6c1962c2
commit
64653b0bbb
|
@ -38,9 +38,7 @@
|
||||||
#include "mflash.h"
|
#include "mflash.h"
|
||||||
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "telnet_server.h"
|
|
||||||
#include "gdb_server.h"
|
#include "gdb_server.h"
|
||||||
#include "tcl_server.h"
|
|
||||||
#include "httpd.h"
|
#include "httpd.h"
|
||||||
|
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
|
@ -149,13 +147,8 @@ COMMAND_HANDLER(handle_init_command)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
LOG_DEBUG("pld init complete");
|
LOG_DEBUG("pld init complete");
|
||||||
|
|
||||||
/* initialize tcp server */
|
|
||||||
server_init();
|
|
||||||
|
|
||||||
/* initialize telnet subsystem */
|
/* initialize telnet subsystem */
|
||||||
telnet_init("Open On-Chip Debugger");
|
|
||||||
gdb_target_add_all(all_targets);
|
gdb_target_add_all(all_targets);
|
||||||
tcl_init(); /* allows tcl to just connect without going thru telnet */
|
|
||||||
|
|
||||||
target_register_event_callback(log_target_callback_event_handler, CMD_CTX);
|
target_register_event_callback(log_target_callback_event_handler, CMD_CTX);
|
||||||
|
|
||||||
|
@ -194,9 +187,7 @@ struct command_context *setup_command_handler(void)
|
||||||
register_commands(cmd_ctx, NULL, openocd_command_handlers);
|
register_commands(cmd_ctx, NULL, openocd_command_handlers);
|
||||||
/* register subsystem commands */
|
/* register subsystem commands */
|
||||||
server_register_commands(cmd_ctx);
|
server_register_commands(cmd_ctx);
|
||||||
telnet_register_commands(cmd_ctx);
|
|
||||||
gdb_register_commands(cmd_ctx);
|
gdb_register_commands(cmd_ctx);
|
||||||
tcl_register_commands(cmd_ctx); /* tcl server commands */
|
|
||||||
log_register_commands(cmd_ctx);
|
log_register_commands(cmd_ctx);
|
||||||
jtag_register_commands(cmd_ctx);
|
jtag_register_commands(cmd_ctx);
|
||||||
xsvf_register_commands(cmd_ctx);
|
xsvf_register_commands(cmd_ctx);
|
||||||
|
@ -259,7 +250,7 @@ int openocd_main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
ret = parse_config_file(cmd_ctx);
|
ret = parse_config_file(cmd_ctx);
|
||||||
if ((ret != ERROR_OK) && (ret != ERROR_COMMAND_CLOSE_CONNECTION))
|
if (ret != ERROR_OK)
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
#if BUILD_HTTPD
|
#if BUILD_HTTPD
|
||||||
|
@ -267,16 +258,21 @@ int openocd_main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret != ERROR_COMMAND_CLOSE_CONNECTION)
|
ret = server_init();
|
||||||
{
|
if (ERROR_OK != ret)
|
||||||
if (command_run_line(cmd_ctx, "init") != ERROR_OK)
|
return EXIT_FAILURE;
|
||||||
return EXIT_FAILURE;
|
|
||||||
|
|
||||||
/* handle network connections */
|
if (1)
|
||||||
server_loop(cmd_ctx);
|
{
|
||||||
|
ret = command_run_line(cmd_ctx, "init");
|
||||||
|
if (ERROR_OK != ret)
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* shut server down */
|
/* handle network connections */
|
||||||
|
if (ERROR_OK == ret)
|
||||||
|
server_loop(cmd_ctx);
|
||||||
|
|
||||||
server_quit();
|
server_quit();
|
||||||
|
|
||||||
#if BUILD_HTTPD
|
#if BUILD_HTTPD
|
||||||
|
@ -288,6 +284,5 @@ int openocd_main(int argc, char *argv[])
|
||||||
/* free commandline interface */
|
/* free commandline interface */
|
||||||
command_done(cmd_ctx);
|
command_done(cmd_ctx);
|
||||||
|
|
||||||
|
return ret;
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "openocd.h"
|
#include "openocd.h"
|
||||||
|
#include "tcl_server.h"
|
||||||
|
#include "telnet_server.h"
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
@ -516,7 +518,11 @@ int server_init(void)
|
||||||
signal(SIGABRT, sig_handler);
|
signal(SIGABRT, sig_handler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ERROR_OK;
|
int ret = tcl_init();
|
||||||
|
if (ERROR_OK != ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return telnet_init("Open On-Chip Debugger");
|
||||||
}
|
}
|
||||||
|
|
||||||
int server_quit(void)
|
int server_quit(void)
|
||||||
|
@ -551,6 +557,14 @@ static const struct command_registration server_command_handlers[] = {
|
||||||
|
|
||||||
int server_register_commands(struct command_context *cmd_ctx)
|
int server_register_commands(struct command_context *cmd_ctx)
|
||||||
{
|
{
|
||||||
|
int retval = telnet_register_commands(cmd_ctx);
|
||||||
|
if (ERROR_OK != retval)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
retval = tcl_register_commands(cmd_ctx);
|
||||||
|
if (ERROR_OK != retval)
|
||||||
|
return retval;
|
||||||
|
|
||||||
return register_commands(cmd_ctx, NULL, server_command_handlers);
|
return register_commands(cmd_ctx, NULL, server_command_handlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue