summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flash/at91sam7.c3
-rw-r--r--src/flash/lpc2000.c8
-rw-r--r--src/helper/configuration.c6
-rw-r--r--src/helper/options.c9
-rw-r--r--src/jtag/jtag.c53
-rw-r--r--src/server/server.c9
-rw-r--r--src/server/telnet_server.c2
-rw-r--r--src/target/target.c41
8 files changed, 50 insertions, 81 deletions
diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c
index 3e920e3d..a9776d48 100644
--- a/src/flash/at91sam7.c
+++ b/src/flash/at91sam7.c
@@ -955,8 +955,7 @@ int at91sam7_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd,
}
else
{
- command_print(cmd_ctx, "usage: at91sam7 gpnvm <num> <bit> <set|clear>");
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
/* Configure the flash controller timing */
diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c
index da79ea73..009c0c05 100644
--- a/src/flash/lpc2000.c
+++ b/src/flash/lpc2000.c
@@ -476,11 +476,6 @@ int lpc2000_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
int i;
working_area_t *download_area;
- if (bank->target->state != TARGET_HALTED)
- {
- return ERROR_TARGET_NOT_HALTED;
- }
-
/* allocate a working area */
if (target_alloc_working_area(target, lpc2000_info->cmd51_max_buffer, &download_area) != ERROR_OK)
{
@@ -654,8 +649,7 @@ int lpc2000_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd,
if (argc < 1)
{
- command_print(cmd_ctx, "usage: lpc2000 part_id <num>");
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
diff --git a/src/helper/configuration.c b/src/helper/configuration.c
index 0a7bf180..1bed1e06 100644
--- a/src/helper/configuration.c
+++ b/src/helper/configuration.c
@@ -36,12 +36,6 @@ static char** config_file_names;
static size_t num_script_dirs;
static char** script_search_dirs;
-int configuration_output_handler(struct command_context_s *context, char* line)
-{
- INFO(line);
-
- return ERROR_OK;
-}
void add_script_search_dir (const char *dir)
{
diff --git a/src/helper/options.c b/src/helper/options.c
index 908748dd..b6b2c6dc 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -48,6 +48,15 @@ static struct option long_options[] =
};
+
+int configuration_output_handler(struct command_context_s *context, char* line)
+{
+ INFO(line);
+
+ return ERROR_OK;
+}
+
+
int parse_cmdline_args(struct command_context_s *cmd_ctx, int argc, char *argv[])
{
int c;
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 974328c5..c4015118 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -1610,7 +1610,7 @@ int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char *
if (argc < 1)
{
- command_print(cmd_ctx, "usage: endstate <tap_state>");
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
else
{
@@ -1632,13 +1632,12 @@ int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char
{
int trst = -1;
int srst = -1;
- char *usage = "usage: jtag_reset <trst> <srst>";
int retval;
if (argc < 1)
{
- command_print(cmd_ctx, usage);
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
}
if (args[0][0] == '1')
@@ -1647,8 +1646,7 @@ int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char
trst = 0;
else
{
- command_print(cmd_ctx, usage);
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
if (args[1][0] == '1')
@@ -1657,8 +1655,7 @@ int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char
srst = 0;
else
{
- command_print(cmd_ctx, usage);
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
if ((retval = jtag_add_reset(trst, srst)) != ERROR_OK)
@@ -1684,8 +1681,7 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **
{
if (argc < 1)
{
- command_print(cmd_ctx, "usage: runtest <num_cycles>");
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
jtag_add_runtest(strtol(args[0], NULL, 0), -1);
@@ -1725,8 +1721,7 @@ int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **a
if ((argc < 2) || (argc % 2))
{
- command_print(cmd_ctx, "usage: irscan <device> <instr> [dev2] [instr2] ...");
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
fields = malloc(sizeof(scan_field_t) * argc / 2);
@@ -1766,8 +1761,7 @@ int handle_drscan_command(struct command_context_s *cmd_ctx, char *cmd, char **a
if ((argc < 2) || (argc % 2))
{
- command_print(cmd_ctx, "usage: drscan <device> <var> [dev2] [var2]");
- return ERROR_OK;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
for (i = 0; i < argc; i+=2)
@@ -1818,20 +1812,25 @@ int handle_drscan_command(struct command_context_s *cmd_ctx, char *cmd, char **a
int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc == 0)
- {
- command_print(cmd_ctx, "verify Capture-IR is %s", (jtag_verify_capture_ir) ? "enabled": "disabled");
- return ERROR_OK;
- }
-
- if (strcmp(args[0], "enable") == 0)
+ if (argc == 1)
{
- jtag_verify_capture_ir = 1;
- }
- else if (strcmp(args[0], "disable") == 0)
- {
- jtag_verify_capture_ir = 0;
- }
+ if (strcmp(args[0], "enable") == 0)
+ {
+ jtag_verify_capture_ir = 1;
+ }
+ else if (strcmp(args[0], "disable") == 0)
+ {
+ jtag_verify_capture_ir = 0;
+ } else
+ {
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+ } else if (argc != 0)
+ {
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
+
+ command_print(cmd_ctx, "verify Capture-IR is %s", (jtag_verify_capture_ir) ? "enabled": "disabled");
return ERROR_OK;
}
diff --git a/src/server/server.c b/src/server/server.c
index b0ad834a..6e43cf7c 100644
--- a/src/server/server.c
+++ b/src/server/server.c
@@ -277,7 +277,9 @@ int server_loop(command_context_t *command_context)
FD_SET(fileno(stdin), &read_fds);
#endif
- if ((retval = select(fd_max + 1, &read_fds, NULL, NULL, &tv)) == -1)
+ retval = select(fd_max + 1, &read_fds, NULL, NULL, &tv);
+
+ if (retval == -1)
{
#ifdef _WIN32
@@ -293,7 +295,9 @@ int server_loop(command_context_t *command_context)
#else
if (errno == EINTR)
+ {
FD_ZERO(&read_fds);
+ }
else
{
ERROR("error during select: %s", strerror(errno));
@@ -309,6 +313,7 @@ int server_loop(command_context_t *command_context)
/* do regular tasks after at most 100ms */
tv.tv_sec = 0;
tv.tv_usec = 10000;
+ FD_ZERO(&read_fds); /* eCos leaves read_fds unchanged in this case! */
}
for (service = services; service; service = service->next)
@@ -318,7 +323,9 @@ int server_loop(command_context_t *command_context)
&& (FD_ISSET(service->fd, &read_fds)))
{
if (service->max_connections > 0)
+ {
add_connection(service, command_context);
+ }
else
{
struct sockaddr_in sin;
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index b40daca8..899902a7 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -121,13 +121,11 @@ int telnet_target_callback_event_handler(struct target_s *target, enum target_ev
switch (event)
{
case TARGET_EVENT_HALTED:
- command_print(cmd_ctx, "Target %i halted", get_num_by_target(target));
target_arch_state(target);
if (!t_con->suppress_prompt)
telnet_prompt(connection);
break;
case TARGET_EVENT_RESUMED:
- command_print(cmd_ctx, "Target %i resumed", get_num_by_target(target));
if (!t_con->suppress_prompt)
telnet_prompt(connection);
break;
diff --git a/src/target/target.c b/src/target/target.c
index fc1adb09..27df12fc 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -50,7 +50,6 @@
int cli_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv);
-int handle_arch_state_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_daemon_startup_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_targets_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
@@ -749,7 +748,6 @@ int target_register_commands(struct command_context_s *cmd_ctx)
register_command(cmd_ctx, NULL, "run_and_halt_time", handle_run_and_halt_time_command, COMMAND_CONFIG, NULL);
register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "working_area <target#> <address> <size> <'backup'|'nobackup'> [virtual address]");
register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "virt2phys <virtual address>");
- register_command(cmd_ctx, NULL, "arch_state", handle_arch_state_command, COMMAND_ANY, "prints CPU state information");
return ERROR_OK;
}
@@ -1488,11 +1486,7 @@ int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
if (argc == 0)
{
target->type->poll(target);
- command_print(cmd_ctx, "target state: %s", target_state_strings[target->state]);
- if (target->state == TARGET_HALTED)
- {
target_arch_state(target);
- }
}
else
{
@@ -1547,7 +1541,6 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
gettimeofday(&timeout, NULL);
timeval_add_time(&timeout, 0, ms * 1000);
- command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
target_t *target = get_current_target(cmd_ctx);
for (;;)
@@ -1557,9 +1550,9 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
target_call_timer_callbacks();
if (target->state == state)
{
- command_print(cmd_ctx, "target %s", target_state_strings[state]);
break;
}
+ command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
gettimeofday(&now, NULL);
if ((now.tv_sec > timeout.tv_sec) || ((now.tv_sec == timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec)))
@@ -1702,34 +1695,20 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
int retval;
target_t *target = get_current_target(cmd_ctx);
- DEBUG("-");
-
if (argc == 0)
retval = target->type->resume(target, 1, 0, 1, 0); /* current pc, addr = 0, handle breakpoints, not debugging */
else if (argc == 1)
retval = target->type->resume(target, 0, strtoul(args[0], NULL, 0), 1, 0); /* addr = args[0], handle breakpoints, not debugging */
else
{
- command_print(cmd_ctx, "usage: resume [address]");
- return ERROR_OK;
- }
-
- if (retval != ERROR_OK)
- {
- switch (retval)
- {
- case ERROR_TARGET_NOT_HALTED:
- command_print(cmd_ctx, "target not halted");
- break;
- default:
- command_print(cmd_ctx, "unknown error... shutting down");
- exit(-1);
- }
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
target_process_events(cmd_ctx);
- return ERROR_OK;
+ target_arch_state(target);
+
+ return retval;
}
int handle_step_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -2351,13 +2330,3 @@ int handle_virt2phys_command(command_context_t *cmd_ctx, char *cmd, char **args,
}
return retval;
}
-int handle_arch_state_command(command_context_t *cmd_ctx, char *cmd, char **args, int argc)
-{
- int retval;
- if (argc!=0)
- return ERROR_COMMAND_SYNTAX_ERROR;
-
- target_t *target = get_target_by_num(cmd_ctx->current_target);
- retval=target_arch_state(target);
- return retval;
-}