summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-24 18:52:45 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-02-24 18:52:45 +0000
commit1aa854684de1827edd3b605fc64a78a498f2358a (patch)
tree570d9229ec0b96cb12b564974ca6009064bdf5bb /src/target
parent379f0b0b9b10d4bc2a018d3683bd6de45e186b2b (diff)
downloadopenocd+libswd-1aa854684de1827edd3b605fc64a78a498f2358a.tar.gz
openocd+libswd-1aa854684de1827edd3b605fc64a78a498f2358a.tar.bz2
openocd+libswd-1aa854684de1827edd3b605fc64a78a498f2358a.tar.xz
openocd+libswd-1aa854684de1827edd3b605fc64a78a498f2358a.zip
- fixed target->type->poll() return value
- added arch_state to show status of currently selected target - simplified target->type->arch_state() api. - clean up telnet output a bit - fixed GDB output for arch_state - removed a couple of unecessary exit()'s - cleaned up error propagation a bit in a few places git-svn-id: svn://svn.berlios.de/openocd/trunk@332 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r--src/target/arm720t.c7
-rw-r--r--src/target/arm7_9_common.c26
-rw-r--r--src/target/arm7_9_common.h2
-rw-r--r--src/target/arm7tdmi.c2
-rw-r--r--src/target/arm920t.c7
-rw-r--r--src/target/arm926ejs.c6
-rw-r--r--src/target/arm926ejs.h2
-rw-r--r--src/target/armv4_5.c5
-rw-r--r--src/target/armv4_5.h2
-rw-r--r--src/target/cortex_m3.c12
-rw-r--r--src/target/cortex_m3.h2
-rw-r--r--src/target/target.c49
-rw-r--r--src/target/target.h7
-rw-r--r--src/target/xscale.c50
14 files changed, 100 insertions, 79 deletions
diff --git a/src/target/arm720t.c b/src/target/arm720t.c
index 05cc30f4..62b70e3b 100644
--- a/src/target/arm720t.c
+++ b/src/target/arm720t.c
@@ -44,7 +44,7 @@ int arm720t_handle_mw_phys_command(struct command_context_s *cmd_ctx, char *cmd,
int arm720t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
int arm720t_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm720t_quit();
-int arm720t_arch_state(struct target_s *target, char *buf, int buf_size);
+int arm720t_arch_state(struct target_s *target);
int arm720t_read_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm720t_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm720t_soft_reset_halt(struct target_s *target);
@@ -297,7 +297,7 @@ int arm720t_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p, ar
return ERROR_OK;
}
-int arm720t_arch_state(struct target_s *target, char *buf, int buf_size)
+int arm720t_arch_state(struct target_s *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
@@ -315,8 +315,7 @@ int arm720t_arch_state(struct target_s *target, char *buf, int buf_size)
exit(-1);
}
- snprintf(buf, buf_size,
- "target halted in %s state due to %s, current mode: %s\n"
+ USER("target halted in %s state due to %s, current mode: %s\n"
"cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, Cache: %s",
armv4_5_state_strings[armv4_5->core_state],
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 3a0eb7b0..2a149425 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -676,7 +676,7 @@ int arm7_9_handle_target_request(void *priv)
return ERROR_OK;
}
-enum target_state arm7_9_poll(target_t *target)
+int arm7_9_poll(target_t *target)
{
int retval;
armv4_5_common_t *armv4_5 = target->arch_info;
@@ -692,24 +692,15 @@ enum target_state arm7_9_poll(target_t *target)
embeddedice_read_reg(dbg_stat);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
- switch (retval)
- {
- case ERROR_JTAG_QUEUE_FAILED:
- ERROR("JTAG queue failed while reading EmbeddedICE status register");
- exit(-1);
- break;
- default:
- break;
- }
+ return retval;
}
if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1))
{
DEBUG("DBGACK set, dbg_state->value: 0x%x", buf_get_u32(dbg_stat->value, 0, 32));
- if ((target->state == TARGET_UNKNOWN))
+ if (target->state == TARGET_UNKNOWN)
{
- WARNING("DBGACK set while target was in unknown state. Reset or initialize target before resuming");
- target->state = TARGET_RUNNING;
+ WARNING("DBGACK set while target was in unknown state. Reset or initialize target.");
}
if ((target->state == TARGET_RUNNING) || (target->state == TARGET_RESET))
{
@@ -727,14 +718,18 @@ enum target_state arm7_9_poll(target_t *target)
target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
}
- }
+ if (target->state != TARGET_HALTED)
+ {
+ WARNING("DBGACK set, but the target did not end up in the halted stated %d", target->state);
+ }
+ }
else
{
if (target->state != TARGET_DEBUG_RUNNING)
target->state = TARGET_RUNNING;
}
- return target->state;
+ return ERROR_OK;
}
int arm7_9_assert_reset(target_t *target)
@@ -1307,7 +1302,6 @@ int arm7_9_restore_context(target_t *target)
else
{
ERROR("BUG: dirty register '%s', but no valid data", reg->name);
- exit(-1);
}
}
}
diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h
index 01b9242a..b95516e6 100644
--- a/src/target/arm7_9_common.h
+++ b/src/target/arm7_9_common.h
@@ -101,7 +101,7 @@ typedef struct arm7_9_common_s
int arm7_9_register_commands(struct command_context_s *cmd_ctx);
-enum target_state arm7_9_poll(target_t *target);
+int arm7_9_poll(target_t *target);
int arm7_9_target_request_data(target_t *target, u32 size, u8 *buffer);
diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c
index 9a9a2450..c308380a 100644
--- a/src/target/arm7tdmi.c
+++ b/src/target/arm7tdmi.c
@@ -49,7 +49,7 @@ int arm7tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *tar
int arm7tdmi_quit();
/* target function declarations */
-enum target_state arm7tdmi_poll(struct target_s *target);
+int arm7tdmi_poll(struct target_s *target);
int arm7tdmi_halt(target_t *target);
target_type_t arm7tdmi_target =
diff --git a/src/target/arm920t.c b/src/target/arm920t.c
index ef955810..bf159dbe 100644
--- a/src/target/arm920t.c
+++ b/src/target/arm920t.c
@@ -49,7 +49,7 @@ int arm920t_handle_read_mmu_command(struct command_context_s *cmd_ctx, char *cmd
int arm920t_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
int arm920t_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm920t_quit();
-int arm920t_arch_state(struct target_s *target, char *buf, int buf_size);
+int arm920t_arch_state(struct target_s *target);
int arm920t_read_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm920t_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm920t_soft_reset_halt(struct target_s *target);
@@ -536,7 +536,7 @@ int arm920t_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p, ar
return ERROR_OK;
}
-int arm920t_arch_state(struct target_s *target, char *buf, int buf_size)
+int arm920t_arch_state(struct target_s *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
@@ -554,8 +554,7 @@ int arm920t_arch_state(struct target_s *target, char *buf, int buf_size)
exit(-1);
}
- snprintf(buf, buf_size,
- "target halted in %s state due to %s, current mode: %s\n"
+ USER( "target halted in %s state due to %s, current mode: %s\n"
"cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, D-Cache: %s, I-Cache: %s",
armv4_5_state_strings[armv4_5->core_state],
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index ba974eb9..10061530 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -49,7 +49,7 @@ int arm926ejs_handle_read_mmu_command(struct command_context_s *cmd_ctx, char *c
int arm926ejs_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
int arm926ejs_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm926ejs_quit();
-int arm926ejs_arch_state(struct target_s *target, char *buf, int buf_size);
+int arm926ejs_arch_state(struct target_s *target);
int arm926ejs_read_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm926ejs_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int arm926ejs_soft_reset_halt(struct target_s *target);
@@ -530,7 +530,7 @@ int arm926ejs_get_arch_pointers(target_t *target, armv4_5_common_t **armv4_5_p,
return ERROR_OK;
}
-int arm926ejs_arch_state(struct target_s *target, char *buf, int buf_size)
+int arm926ejs_arch_state(struct target_s *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
@@ -548,7 +548,7 @@ int arm926ejs_arch_state(struct target_s *target, char *buf, int buf_size)
exit(-1);
}
- snprintf(buf, buf_size,
+ USER(
"target halted in %s state due to %s, current mode: %s\n"
"cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, D-Cache: %s, I-Cache: %s",
diff --git a/src/target/arm926ejs.h b/src/target/arm926ejs.h
index 65e67c5d..178fc229 100644
--- a/src/target/arm926ejs.h
+++ b/src/target/arm926ejs.h
@@ -45,7 +45,7 @@ typedef struct arm926ejs_common_s
extern int arm926ejs_init_arch_info(target_t *target, arm926ejs_common_t *arm926ejs, int chain_pos, char *variant);
extern int arm926ejs_register_commands(struct command_context_s *cmd_ctx);
-extern int arm926ejs_arch_state(struct target_s *target, char *buf, int buf_size);
+extern int arm926ejs_arch_state(struct target_s *target);
extern int arm926ejs_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
extern int arm926ejs_soft_reset_halt(struct target_s *target);
diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c
index 02a731ca..2528f107 100644
--- a/src/target/armv4_5.c
+++ b/src/target/armv4_5.c
@@ -322,7 +322,7 @@ reg_cache_t* armv4_5_build_reg_cache(target_t *target, armv4_5_common_t *armv4_5
return cache;
}
-int armv4_5_arch_state(struct target_s *target, char *buf, int buf_size)
+int armv4_5_arch_state(struct target_s *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
@@ -332,8 +332,7 @@ int armv4_5_arch_state(struct target_s *target, char *buf, int buf_size)
exit(-1);
}
- snprintf(buf, buf_size,
- "target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8x pc: 0x%8.8x",
+ USER("target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8x pc: 0x%8.8x",
armv4_5_state_strings[armv4_5->core_state],
target_debug_reason_strings[target->debug_reason],
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h
index 36264f35..f04a4113 100644
--- a/src/target/armv4_5.h
+++ b/src/target/armv4_5.h
@@ -98,7 +98,7 @@ extern reg_cache_t* armv4_5_build_reg_cache(target_t *target, armv4_5_common_t *
extern enum armv4_5_mode armv4_5_number_to_mode(int number);
extern int armv4_5_mode_to_number(enum armv4_5_mode mode);
-extern int armv4_5_arch_state(struct target_s *target, char *buf, int buf_size);
+extern int armv4_5_arch_state(struct target_s *target);
extern int armv4_5_get_gdb_reg_list(target_t *target, reg_t **reg_list[], int *reg_list_size);
extern int armv4_5_invalidate_core_regs(target_t *target);
diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c
index db9dd054..bdb40503 100644
--- a/src/target/cortex_m3.c
+++ b/src/target/cortex_m3.c
@@ -348,7 +348,7 @@ int cortex_m3_debug_entry(target_t *target)
return ERROR_OK;
}
-enum target_state cortex_m3_poll(target_t *target)
+int cortex_m3_poll(target_t *target)
{
int retval;
u32 prev_target_state = target->state;
@@ -363,7 +363,7 @@ enum target_state cortex_m3_poll(target_t *target)
if (retval != ERROR_OK)
{
target->state = TARGET_UNKNOWN;
- return TARGET_UNKNOWN;
+ return retval;
}
if (cortex_m3->dcb_dhcsr & S_RESET_ST)
@@ -374,7 +374,7 @@ enum target_state cortex_m3_poll(target_t *target)
if (cortex_m3->dcb_dhcsr & S_RESET_ST)
{
target->state = TARGET_RESET;
- return target->state;
+ return ERROR_OK;
}
}
@@ -394,7 +394,7 @@ enum target_state cortex_m3_poll(target_t *target)
if ((prev_target_state == TARGET_RUNNING) || (prev_target_state == TARGET_RESET))
{
if ((retval = cortex_m3_debug_entry(target)) != ERROR_OK)
- return TARGET_UNKNOWN;
+ return retval;
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
}
@@ -402,7 +402,7 @@ enum target_state cortex_m3_poll(target_t *target)
{
DEBUG(" ");
if ((retval = cortex_m3_debug_entry(target)) != ERROR_OK)
- return TARGET_UNKNOWN;
+ return retval;
target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
}
@@ -416,7 +416,7 @@ enum target_state cortex_m3_poll(target_t *target)
/* Read Debug Fault Status Register, added to figure out the lockup when running flashtest.script */
ahbap_read_system_atomic_u32(swjdp, NVIC_DFSR, &cortex_m3->nvic_dfsr);
DEBUG("dcb_dhcsr 0x%x, nvic_dfsr 0x%x, target->state: %s", cortex_m3->dcb_dhcsr, cortex_m3->nvic_dfsr, target_state_strings[target->state]);
- return target->state;
+ return ERROR_OK;
}
int cortex_m3_halt(target_t *target)
diff --git a/src/target/cortex_m3.h b/src/target/cortex_m3.h
index 7932dff8..0ed3b0ad 100644
--- a/src/target/cortex_m3.h
+++ b/src/target/cortex_m3.h
@@ -189,7 +189,7 @@ typedef struct cortex_m3_common_s
extern void cortex_m3_build_reg_cache(target_t *target);
-enum target_state cortex_m3_poll(target_t *target);
+int cortex_m3_poll(target_t *target);
int cortex_m3_halt(target_t *target);
int cortex_m3_resume(struct target_s *target, int current, u32 address, int handle_breakpoints, int debug_execution);
int cortex_m3_step(struct target_s *target, int current, u32 address, int handle_breakpoints);
diff --git a/src/target/target.c b/src/target/target.c
index ce2d0856..fc1adb09 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -49,6 +49,8 @@
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);
@@ -387,7 +389,6 @@ static int default_virt2phys(struct target_s *target, u32 virtual, u32 *physical
static int default_mmu(struct target_s *target, int *enabled)
{
- USER("No MMU present");
*enabled = 0;
return ERROR_OK;
}
@@ -748,10 +749,29 @@ 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;
}
+int target_arch_state(struct target_s *target)
+{
+ int retval;
+ if (target==NULL)
+ {
+ USER("No target has been configured");
+ return ERROR_OK;
+ }
+
+ USER("target state: %s", target_state_strings[target->state]);
+
+ if (target->state!=TARGET_HALTED)
+ return ERROR_OK;
+
+ retval=target->type->arch_state(target);
+ return retval;
+}
+
/* Single aligned words are guaranteed to use 16 or 32 bit access
* mode respectively, otherwise data is handled as quickly as
* possible
@@ -1325,9 +1345,9 @@ int handle_target(void *priv)
if (target->state != TARGET_HALTED)
{
if (target_continous_poll)
- if ((retval = target->type->poll(target)) < 0)
+ if ((retval = target->type->poll(target)) != ERROR_OK)
{
- ERROR("couldn't poll target. It's due for a reset.");
+ ERROR("couldn't poll target(%d). It's due for a reset.", retval);
}
}
@@ -1464,16 +1484,14 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
target_t *target = get_current_target(cmd_ctx);
- char buffer[512];
if (argc == 0)
{
- command_print(cmd_ctx, "target state: %s", target_state_strings[target->type->poll(target)]);
+ target->type->poll(target);
+ command_print(cmd_ctx, "target state: %s", target_state_strings[target->state]);
if (target->state == TARGET_HALTED)
{
- target->type->arch_state(target, buffer, 512);
- buffer[511] = 0;
- command_print(cmd_ctx, "%s", buffer);
+ target_arch_state(target);
}
}
else
@@ -1524,6 +1542,7 @@ static void target_process_events(struct command_context_s *cmd_ctx)
static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_state state, int ms)
{
+ int retval;
struct timeval timeout, now;
gettimeofday(&timeout, NULL);
@@ -1531,8 +1550,10 @@ static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_
command_print(cmd_ctx, "waiting for target %s...", target_state_strings[state]);
target_t *target = get_current_target(cmd_ctx);
- while (target->type->poll(target))
+ for (;;)
{
+ if ((retval=target->type->poll(target))!=ERROR_OK)
+ return retval;
target_call_timer_callbacks();
if (target->state == state)
{
@@ -2330,3 +2351,13 @@ 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;
+}
diff --git a/src/target/target.h b/src/target/target.h
index 29de1e98..7c07288b 100644
--- a/src/target/target.h
+++ b/src/target/target.h
@@ -98,9 +98,10 @@ typedef struct target_type_s
char *name;
/* poll current target status */
- enum target_state (*poll)(struct target_s *target);
- /* architecture specific status reply */
- int (*arch_state)(struct target_s *target, char *buf, int buf_size);
+ int (*poll)(struct target_s *target);
+ /* Invoked only from target_arch_state().
+ * Issue USER() w/architecture specific status. */
+ int (*arch_state)(struct target_s *target);
/* target request support */
int (*target_request_data)(struct target_s *target, u32 size, u8 *buffer);
diff --git a/src/target/xscale.c b/src/target/xscale.c
index 6a5aabb8..4e111521 100644
--- a/src/target/xscale.c
+++ b/src/target/xscale.c
@@ -53,8 +53,8 @@ int xscale_target_command(struct command_context_s *cmd_ctx, char *cmd, char **a
int xscale_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int xscale_quit();
-int xscale_arch_state(struct target_s *target, char *buf, int buf_size);
-enum target_state xscale_poll(target_t *target);
+int xscale_arch_state(struct target_s *target);
+int xscale_poll(target_t *target);
int xscale_halt(target_t *target);
int xscale_resume(struct target_s *target, int current, u32 address, int handle_breakpoints, int debug_execution);
int xscale_step(struct target_s *target, int current, u32 address, int handle_breakpoints);
@@ -955,7 +955,7 @@ int xscale_update_vectors(target_t *target)
return ERROR_OK;
}
-int xscale_arch_state(struct target_s *target, char *buf, int buf_size)
+int xscale_arch_state(struct target_s *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
xscale_common_t *xscale = armv4_5->arch_info;
@@ -976,8 +976,7 @@ int xscale_arch_state(struct target_s *target, char *buf, int buf_size)
exit(-1);
}
- snprintf(buf, buf_size,
- "target halted in %s state due to %s, current mode: %s\n"
+ USER("target halted in %s state due to %s, current mode: %s\n"
"cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, D-Cache: %s, I-Cache: %s"
"%s",
@@ -994,17 +993,17 @@ int xscale_arch_state(struct target_s *target, char *buf, int buf_size)
return ERROR_OK;
}
-enum target_state xscale_poll(target_t *target)
+int xscale_poll(target_t *target)
{
- int retval;
+ int retval=ERROR_OK;
armv4_5_common_t *armv4_5 = target->arch_info;
xscale_common_t *xscale = armv4_5->arch_info;
if ((target->state == TARGET_RUNNING) || (target->state == TARGET_DEBUG_RUNNING))
{
+ enum target_state previous_state = target->state;
if ((retval = xscale_read_tx(target, 0)) == ERROR_OK)
{
- enum target_state previous_state = target->state;
/* there's data to read from the tx register, we entered debug state */
xscale->handler_running = 1;
@@ -1012,30 +1011,29 @@ enum target_state xscale_poll(target_t *target)
target->state = TARGET_HALTED;
/* process debug entry, fetching current mode regs */
- if ((retval = xscale_debug_entry(target)) != ERROR_OK)
- return retval;
+ retval = xscale_debug_entry(target);
+ }
+ else if (retval != ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
+ {
+ USER("error while polling TX register, reset CPU");
+ /* here we "lie" so GDB won't get stuck and a reset can be perfomed */
+ target->state = TARGET_HALTED;
+ }
/* debug_entry could have overwritten target state (i.e. immediate resume)
* don't signal event handlers in that case
*/
- if (target->state != TARGET_HALTED)
- return target->state;
+ if (target->state != TARGET_HALTED)
+ return ERROR_OK;
- /* if target was running, signal that we halted
- * otherwise we reentered from debug execution */
- if (previous_state == TARGET_RUNNING)
- target_call_event_callbacks(target, TARGET_EVENT_HALTED);
- else
- target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
- }
- else if (retval != ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
- {
- ERROR("error while polling TX register");
- return retval;
- }
+ /* if target was running, signal that we halted
+ * otherwise we reentered from debug execution */
+ if (previous_state == TARGET_RUNNING)
+ target_call_event_callbacks(target, TARGET_EVENT_HALTED);
+ else
+ target_call_event_callbacks(target, TARGET_EVENT_DEBUG_HALTED);
}
-
- return target->state;
+ return retval;
}
int xscale_debug_entry(target_t *target)
n1326'>1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539