1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
28 #include "configuration.h"
29 #include "interpreter.h"
36 #include "telnet_server.h"
37 #include "gdb_server.h"
40 #include <sys/types.h>
41 #include <sys/socket.h>
44 #include <netinet/in.h>
52 int main(int argc, char *argv[])
54 /* initialize commandline interface */
55 command_context_t *cmd_ctx, *cfg_cmd_ctx;
56 cmd_ctx = command_init();
58 /* register subsystem commands */
59 server_register_commands(cmd_ctx);
60 telnet_register_commands(cmd_ctx);
61 gdb_register_commands(cmd_ctx);
62 log_register_commands(cmd_ctx);
63 jtag_register_commands(cmd_ctx);
64 interpreter_register_commands(cmd_ctx);
65 xsvf_register_commands(cmd_ctx);
66 target_register_commands(cmd_ctx);
67 flash_register_commands(cmd_ctx);
69 if (log_init(cmd_ctx) != ERROR_OK)
71 DEBUG("log init complete");
73 INFO("Open On-Chip Debugger (Revision 65)");
75 cfg_cmd_ctx = copy_command_context(cmd_ctx);
76 cfg_cmd_ctx->mode = COMMAND_CONFIG;
77 command_set_output_handler(cfg_cmd_ctx, configuration_output_handler, NULL);
79 if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
82 if (parse_config_file(cfg_cmd_ctx) != ERROR_OK)
85 command_done(cfg_cmd_ctx);
87 if (jtag_init(cmd_ctx) != ERROR_OK)
89 DEBUG("jtag init complete");
91 if (target_init(cmd_ctx) != ERROR_OK)
93 DEBUG("target init complete");
95 if (flash_init(cmd_ctx) != ERROR_OK)
97 DEBUG("flash init complete");
99 /* initialize tcp server */
102 /* initialize telnet subsystem */
103 telnet_init("Open On-Chip Debugger");
106 /* handle network connections */
107 server_loop(cmd_ctx);
109 /* free commandline interface */
110 command_done(cmd_ctx);