Commit 8d73c2a9 authored by oharboe's avatar oharboe
Browse files

duan ellis target tcl work in progress

  converts a number of 'simple string lookup tables' into NVP tables.
  These NVP tables will be used by various commands coming in the next patch.


git-svn-id: svn://svn.berlios.de/openocd/trunk@962 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 6abf942b
......@@ -649,7 +649,7 @@ int gdb_target_callback_event_handler(struct target_s *target, enum target_event
case TARGET_EVENT_HALTED:
gdb_frontend_halted(target, connection);
break;
case TARGET_EVENT_GDB_PROGRAM:
case TARGET_EVENT_GDB_FLASH_ERASE_START:
gdb_program_handler(target, event, connection->cmd_ctx);
break;
default:
......@@ -1769,7 +1769,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
flash_set_dirty();
/* perform any target specific operations before the erase */
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_PROGRAM);
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_FLASH_ERASE_START);
/* perform erase */
if ((result = flash_erase_address_range(gdb_service->target, addr, length)) != ERROR_OK)
......@@ -2063,8 +2063,7 @@ int gdb_input(connection_t *connection)
int gdb_init(void)
{
gdb_service_t *gdb_service;
target_t *target = targets;
int i = 0;
target_t *target = all_targets;
if (!target)
{
......@@ -2082,16 +2081,21 @@ int gdb_init(void)
{
char service_name[8];
snprintf(service_name, 8, "gdb-%2.2i", i);
snprintf(service_name, 8, "gdb-%2.2i", target->target_number);
gdb_service = malloc(sizeof(gdb_service_t));
gdb_service->target = target;
add_service("gdb", CONNECTION_GDB, gdb_port + i, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service);
add_service("gdb", CONNECTION_GDB,
gdb_port + target->target_number,
1, gdb_new_connection, gdb_input,
gdb_connection_closed,
gdb_service);
LOG_DEBUG("gdb service for target %s at port %i", target->type->name, gdb_port + i);
LOG_DEBUG("gdb service for target %s at port %i",
target->type->name,
gdb_port + target->target_number);
i++;
target = target->next;
}
......
......@@ -726,7 +726,8 @@ int arm11_halt(struct target_s *target)
arm11_common_t * arm11 = target->arch_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
if (target->state == TARGET_UNKNOWN)
{
......@@ -782,7 +783,9 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b
arm11_common_t * arm11 = target->arch_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
if (target->state != TARGET_HALTED)
{
......@@ -877,7 +880,8 @@ int arm11_step(struct target_s *target, int current, u32 address, int handle_bre
{
FNC_INFO;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
if (target->state != TARGET_HALTED)
{
......@@ -1012,7 +1016,9 @@ int arm11_deassert_reset(struct target_s *target)
FNC_INFO;
#if 0
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
/* deassert reset lines */
jtag_add_reset(0, 0);
......@@ -1667,7 +1673,7 @@ arm11_common_t * arm11_find_target(const char * arg)
size_t jtag_target = strtoul(arg, NULL, 0);
{target_t * t;
for (t = targets; t; t = t->next)
for (t = all_targets; t; t = t->next)
{
if (t->type != &arm11_target)
continue;
......
......@@ -321,7 +321,7 @@ int arm720t_arch_state(struct target_s *target)
"cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, Cache: %s",
armv4_5_state_strings[armv4_5->core_state],
target_debug_reason_strings[target->debug_reason],
Jim_Nvp_value2name_simple( nvp_target_debug_reason, target->debug_reason )->name ,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32),
......
......@@ -734,7 +734,8 @@ int arm7_9_assert_reset(target_t *target)
{
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state,target->state)->name);
if (!(jtag_reset_config & RESET_HAS_SRST))
{
......@@ -795,7 +796,9 @@ int arm7_9_assert_reset(target_t *target)
int arm7_9_deassert_reset(target_t *target)
{
int retval=ERROR_OK;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state,target->state)->name);
/* deassert reset lines */
jtag_add_reset(0, 0);
......@@ -969,7 +972,8 @@ int arm7_9_halt(target_t *target)
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL];
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state,target->state)->name);
if (target->state == TARGET_HALTED)
{
......
......@@ -45,6 +45,7 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */
int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct target_s *target);
int arm7tdmi_target_create(Jim_Interp *interp, struct target_s *target);
int arm7tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm7tdmi_quit(void);
......@@ -86,6 +87,7 @@ target_type_t arm7tdmi_target =
.register_commands = arm7tdmi_register_commands,
.target_command = arm7tdmi_target_command,
// .target_create = arm7tdmi_target_create,
.init_target = arm7tdmi_init_target,
.examine = arm7tdmi_examine,
.quit = arm7tdmi_quit
......@@ -759,7 +761,7 @@ int arm7tdmi_quit(void)
return ERROR_OK;
}
int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, int chain_pos, char *variant)
int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, int chain_pos, const char *variant)
{
armv4_5_common_t *armv4_5;
arm7_9_common_t *arm7_9;
......@@ -851,6 +853,20 @@ int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_OK;
}
int arm7tdmi_target_create(Jim_Interp *interp,
struct target_s *target)
{
arm7tdmi_common_t *arm7tdmi;
arm7tdmi = calloc(1,sizeof(arm7tdmi_common_t));
arm7tdmi_init_arch_info(target, arm7tdmi, target->chain_position, target->variant);
return ERROR_OK;
}
int arm7tdmi_register_commands(struct command_context_s *cmd_ctx)
{
int retval;
......@@ -861,3 +877,10 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx)
}
/*
* Local Variables: ***
* c-basic-offset: 4 ***
* tab-width: 4 ***
* End: ***
*/
......@@ -38,7 +38,7 @@ typedef struct arm7tdmi_common_s
} arm7tdmi_common_t;
int arm7tdmi_register_commands(struct command_context_s *cmd_ctx);
int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, int chain_pos, char *variant);
int arm7tdmi_init_arch_info(target_t *target, arm7tdmi_common_t *arm7tdmi, int chain_pos, const char *variant);
int arm7tdmi_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm7tdmi_examine(struct target_s *target);
......
......@@ -566,7 +566,7 @@ int arm920t_arch_state(struct target_s *target)
"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],
target_debug_reason_strings[target->debug_reason],
Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32),
......
......@@ -562,7 +562,7 @@ int arm926ejs_arch_state(struct target_s *target)
"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],
target_debug_reason_strings[target->debug_reason],
Jim_Nvp_value2name_simple( nvp_target_debug_reason,target->debug_reason)->name,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32),
......
......@@ -302,7 +302,7 @@ int armv4_5_arch_state(struct target_s *target)
LOG_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],
Jim_Nvp_value2name_simple( nvp_target_debug_reason, target->debug_reason )->name,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32));
......
......@@ -439,7 +439,7 @@ int armv7m_arch_state(struct target_s *target)
armv7m_common_t *armv7m = target->arch_info;
LOG_USER("target halted due to %s, current mode: %s %s\nxPSR: 0x%8.8x pc: 0x%8.8x",
target_debug_reason_strings[target->debug_reason],
Jim_Nvp_value2name_simple( nvp_target_debug_reason,target->debug_reason)->name,
armv7m_mode_strings[armv7m->core_mode],
armv7m_exception_string(armv7m->exception_number),
buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32),
......
......@@ -359,8 +359,10 @@ int cortex_m3_debug_entry(target_t *target)
cortex_m3_examine_exception_reason(target);
}
LOG_DEBUG("entered debug state in core mode: %s at PC 0x%x, target->state: %s", armv7m_mode_strings[armv7m->core_mode], \
*(u32*)(armv7m->core_cache->reg_list[15].value), target_state_strings[target->state]);
LOG_DEBUG("entered debug state in core mode: %s at PC 0x%x, target->state: %s",
armv7m_mode_strings[armv7m->core_mode],
*(u32*)(armv7m->core_cache->reg_list[15].value),
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
if (armv7m->post_debug_entry)
armv7m->post_debug_entry(target);
......@@ -436,7 +438,7 @@ int cortex_m3_poll(target_t *target)
#if 0
/* 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);
LOG_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]);
LOG_DEBUG("dcb_dhcsr 0x%x, nvic_dfsr 0x%x, target->state: %s", cortex_m3->dcb_dhcsr, cortex_m3->nvic_dfsr, Jim_Nvp_value2name( nvp_target_state, target->state )->name );
#endif
return ERROR_OK;
......@@ -449,7 +451,8 @@ int cortex_m3_halt(target_t *target)
cortex_m3_common_t *cortex_m3 = armv7m->arch_info;
swjdp_common_t *swjdp = &cortex_m3->swjdp_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
if (target->state == TARGET_HALTED)
{
......@@ -676,7 +679,8 @@ int cortex_m3_assert_reset(target_t *target)
swjdp_common_t *swjdp = &cortex_m3->swjdp_info;
int assert_srst = 1;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name );
if (!(jtag_reset_config & RESET_HAS_SRST))
{
......@@ -774,7 +778,8 @@ int cortex_m3_assert_reset(target_t *target)
int cortex_m3_deassert_reset(target_t *target)
{
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
/* deassert reset lines */
jtag_add_reset(0, 0);
......
......@@ -266,7 +266,7 @@ int mips32_arch_state(struct target_s *target)
}
LOG_USER("target halted due to %s, pc: 0x%8.8x",
target_debug_reason_strings[target->debug_reason],
Jim_Nvp_value2name_simple( nvp_target_debug_reason, target->debug_reason )->name ,
buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
return ERROR_OK;
......
......@@ -119,8 +119,9 @@ int mips_m4k_debug_entry(target_t *target)
mips32_save_context(target);
LOG_DEBUG("entered debug state at PC 0x%x, target->state: %s", \
*(u32*)(mips32->core_cache->reg_list[MIPS32_PC].value), target_state_strings[target->state]);
LOG_DEBUG("entered debug state at PC 0x%x, target->state: %s",
*(u32*)(mips32->core_cache->reg_list[MIPS32_PC].value),
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
return ERROR_OK;
}
......@@ -187,7 +188,8 @@ int mips_m4k_halt(struct target_s *target)
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
if (target->state == TARGET_HALTED)
{
......@@ -231,7 +233,8 @@ int mips_m4k_assert_reset(target_t *target)
mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
if (!(jtag_reset_config & RESET_HAS_SRST))
{
......@@ -279,7 +282,8 @@ int mips_m4k_assert_reset(target_t *target)
int mips_m4k_deassert_reset(target_t *target)
{
LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
LOG_DEBUG("target->state: %s",
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
/* deassert reset lines */
jtag_add_reset(0, 0);
......
......@@ -80,6 +80,11 @@ static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
static int jim_mem2array(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv);
static int target_mem2array(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv);
/* targets */
extern target_type_t arm7tdmi_target;
extern target_type_t arm720t_target;
......@@ -109,32 +114,105 @@ target_type_t *target_types[] =
NULL,
};
target_t *targets = NULL;
target_t *all_targets = NULL;
target_event_callback_t *target_event_callbacks = NULL;
target_timer_callback_t *target_timer_callbacks = NULL;
char *target_state_strings[] =
{
"unknown",
"running",
"halted",
"reset",
"debug_running",
const Jim_Nvp nvp_assert[] = {
{ .name = "assert", NVP_ASSERT },
{ .name = "deassert", NVP_DEASSERT },
{ .name = "T", NVP_ASSERT },
{ .name = "F", NVP_DEASSERT },
{ .name = "t", NVP_ASSERT },
{ .name = "f", NVP_DEASSERT },
{ .name = NULL, .value = -1 }
};
char *target_debug_reason_strings[] =
{
"debug request", "breakpoint", "watchpoint",
"watchpoint and breakpoint", "single step",
"target not halted", "undefined"
const Jim_Nvp nvp_target_event[] = {
{ .value = TARGET_EVENT_HALTED, .name = "halted" },
{ .value = TARGET_EVENT_RESUMED, .name = "resumed" },
{ .value = TARGET_EVENT_RESUME_START, .name = "resume-start" },
{ .value = TARGET_EVENT_RESUME_END, .name = "resume-end" },
/* historical name */
{ .value = TARGET_EVENT_RESET_START , .name = "pre_reset" },
{ .value = TARGET_EVENT_RESET_START, .name = "reset-start" },
/* historical name */
{ .value = TARGET_EVENT_RESET , .name = "reset" },
{ .value = TARGET_EVENT_RESET_INIT , .name = "reset-init" },
{ .value = TARGET_EVENT_RESET_END, .name = "reset-end" },
{ .value = TARGET_EVENT_DEBUG_HALTED, .name = "debug-halted" },
{ .value = TARGET_EVENT_DEBUG_RESUMED, .name = "debug-resumed" },
{ .value = TARGET_EVENT_GDB_ATTACH, .name = "gdb-attach" },
{ .value = TARGET_EVENT_GDB_DETACH, .name = "gdb-detach" },
{ .value = TARGET_EVENT_GDB_FLASH_WRITE_START, .name = "gdb-flash-write-start" },
{ .value = TARGET_EVENT_GDB_FLASH_WRITE_END , .name = "gdb-flash-write-end" },
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_START , .name = "gdb_program_config" },
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_START, .name = "gdb-flash-erase-start" },
{ .value = TARGET_EVENT_GDB_FLASH_ERASE_END , .name = "gdb-flash-erase-end" },
{ .value = TARGET_EVENT_RESUME_START, .name = "resume-start" },
{ .value = TARGET_EVENT_RESUMED , .name = "resume-ok" },
{ .value = TARGET_EVENT_RESUME_END , .name = "resume-end" },
{ .name = NULL, .value = -1 }
};
char *target_endianess_strings[] =
{
"big endian",
"little endian",
const Jim_Nvp nvp_target_state[] = {
{ .name = "unknown", .value = TARGET_UNKNOWN },
{ .name = "running", .value = TARGET_RUNNING },
{ .name = "halted", .value = TARGET_HALTED },
{ .name = "reset", .value = TARGET_RESET },
{ .name = "debug-running", .value = TARGET_DEBUG_RUNNING },
{ .name = NULL, .value = -1 },
};
const Jim_Nvp nvp_target_debug_reason [] = {
{ .name = "debug-request" , .value = DBG_REASON_DBGRQ },
{ .name = "breakpoint" , .value = DBG_REASON_BREAKPOINT },
{ .name = "watchpoint" , .value = DBG_REASON_WATCHPOINT },
{ .name = "watchpoint-and-breakpoint", .value = DBG_REASON_WPTANDBKPT },
{ .name = "single-step" , .value = DBG_REASON_SINGLESTEP },
{ .name = "target-not-halted" , .value = DBG_REASON_NOTHALTED },
{ .name = "undefined" , .value = DBG_REASON_UNDEFINED },
{ .name = NULL, .value = -1 },
};
const Jim_Nvp nvp_target_endian[] = {
{ .name = "big", .value = TARGET_BIG_ENDIAN },
{ .name = "little", .value = TARGET_LITTLE_ENDIAN },
{ .name = "be", .value = TARGET_BIG_ENDIAN },
{ .name = "le", .value = TARGET_LITTLE_ENDIAN },
{ .name = NULL, .value = -1 },
};
/* determine the number of the new target */
static int
new_target_number( void )
{
target_t *t;
int x;
/* number is 0 based */
x = -1;
t = all_targets;
while(t){
if( x < t->target_number ){
x = t->target_number;
}
t = t->next;
}
return x+1;
}
static int target_continous_poll = 1;
/* read a u32 from a buffer in target memory endianness */
......@@ -155,6 +233,12 @@ u16 target_buffer_get_u16(target_t *target, u8 *buffer)
return be_to_h_u16(buffer);
}
/* read a u8 from a buffer in target memory endianness */
u8 target_buffer_get_u8(target_t *target, u8 *buffer)
{
return *buffer & 0x0ff;
}
/* write a u32 to a buffer in target memory endianness */
void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value)
{
......@@ -173,18 +257,22 @@ void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value)
h_u16_to_be(buffer, value);
}
/* write a u8 to a buffer in target memory endianness */
void target_buffer_set_u8(target_t *target, u8 *buffer, u8 value)
{
*buffer = value;
}
/* returns a pointer to the n-th configured target */
target_t* get_target_by_num(int num)
{
target_t *target = targets;
int i = 0;
target_t *target = all_targets;
while (target)
{
if (num == i)
while (target){
if( target->target_number == num ){
return target;
}
target = target->next;
i++;
}
return NULL;
......@@ -192,18 +280,7 @@ target_t* get_target_by_num(int num)
int get_num_by_target(target_t *query_target)
{
target_t *target = targets;
int i = 0;
while (target)
{
if (target == query_target)
return i;
target = target->next;
i++;
}
return -1;
return query_target->target_number;
}
target_t* get_current_target(command_context_t *cmd_ctx)
......@@ -268,7 +345,7 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
int retval = ERROR_OK;
target_t *target;
target = targets;
target = all_targets;
while (target)
{
target_invoke_script(cmd_ctx, target, "pre_reset");
......@@ -295,7 +372,7 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
keep_alive(); /* we might be running on a very slow JTAG clk */
target = targets;
target = all_targets;
while (target)
{
/* we have no idea what state the target is in, so we
......@@ -308,7 +385,7 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
target = target->next;
}
target = targets;
target = all_targets;
while (target)
{
if ((retval = target->type->deassert_reset(target))!=ERROR_OK)
......@@ -316,7 +393,7 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
target = target->next;
}
target = targets;
target = all_targets;
while (target)
{
/* We can fail to bring the target into the halted state, try after reset has been deasserted */
......@@ -340,14 +417,15 @@ int target_process_reset(struct command_context_s *cmd_ctx, enum target_reset_mo
if ((reset_mode == RESET_HALT) || (reset_mode == RESET_INIT))
{
target = targets;
target = all_targets;
while (target)
{
/* Wait for reset to complete, maximum 5 seconds. */
if (((retval=target_wait_state(target, TARGET_HALTED, 5000)))==ERROR_OK)
{
if (reset_mode == RESET_INIT)
if (reset_mode == RESET_INIT)
target_invoke_script(cmd_ctx, target, "post_reset");
}
target = target->next;
}
......@@ -386,7 +464,7 @@ static int default_examine(struct target_s *target)
int target_examine(void)
{
int retval = ERROR_OK;
target_t *target = targets;
target_t *target = all_targets;
while (target)
{
if ((retval = target->type->examine(target))!=ERROR_OK)
......@@ -438,7 +516,7 @@ static int target_run_algorithm_imp(struct target_s *target, int num_mem_params,
int target_init(struct command_context_s *cmd_ctx)
{
target_t *target = targets;
target_t *target = all_targets;
while (target)
{
......@@ -480,7 +558,7 @@ int target_init(struct command_context_s *cmd_ctx)
target = target->next;