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 ***************************************************************************/
21 #define OPENOCD_VERSION "Open On-Chip Debugger (2007-03-15 14:30 CET)"
30 #include "configuration.h"
31 #include "interpreter.h"
39 #include "telnet_server.h"
40 #include "gdb_server.h"
43 #include <sys/types.h>
51 /* Give TELNET a way to find out what version this is */
52 int handle_version_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
54 command_print(cmd_ctx, OPENOCD_VERSION);
59 int main(int argc, char *argv[])
61 /* initialize commandline interface */
62 command_context_t *cmd_ctx, *cfg_cmd_ctx;
63 cmd_ctx = command_init();
65 register_command(cmd_ctx, NULL, "version", handle_version_command,
66 COMMAND_EXEC, "show OpenOCD version");
68 /* register subsystem commands */
69 server_register_commands(cmd_ctx);
70 telnet_register_commands(cmd_ctx);
71 gdb_register_commands(cmd_ctx);
72 log_register_commands(cmd_ctx);
73 jtag_register_commands(cmd_ctx);
74 interpreter_register_commands(cmd_ctx);
75 xsvf_register_commands(cmd_ctx);
76 target_register_commands(cmd_ctx);
77 flash_register_commands(cmd_ctx);
78 nand_register_commands(cmd_ctx);
79 pld_register_commands(cmd_ctx);
81 if (log_init(cmd_ctx) != ERROR_OK)
83 DEBUG("log init complete");
85 INFO( OPENOCD_VERSION );
87 cfg_cmd_ctx = copy_command_context(cmd_ctx);
88 cfg_cmd_ctx->mode = COMMAND_CONFIG;
89 command_set_output_handler(cfg_cmd_ctx, configuration_output_handler, NULL);
91 if (parse_cmdline_args(cfg_cmd_ctx, argc, argv) != ERROR_OK)
94 if (parse_config_file(cfg_cmd_ctx) != ERROR_OK)
97 command_done(cfg_cmd_ctx);
99 command_set_output_handler(cmd_ctx, configuration_output_handler, NULL);
101 if (jtag_init(cmd_ctx) != ERROR_OK)
103 DEBUG("jtag init complete");
105 if (target_init(cmd_ctx) != ERROR_OK)
107 DEBUG("target init complete");
109 if (flash_init(cmd_ctx) != ERROR_OK)
111 DEBUG("flash init complete");
113 if (nand_init(cmd_ctx) != ERROR_OK)
115 DEBUG("NAND init complete");
117 if (pld_init(cmd_ctx) != ERROR_OK)
119 DEBUG("pld init complete");
121 /* initialize tcp server */
124 /* initialize telnet subsystem */
125 telnet_init("Open On-Chip Debugger");
128 /* handle network connections */
129 server_loop(cmd_ctx);
131 /* shut server down */
134 /* free commandline interface */
135 command_done(cmd_ctx);