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 ...@@ -649,7 +649,7 @@ int gdb_target_callback_event_handler(struct target_s *target, enum target_event
case TARGET_EVENT_HALTED: case TARGET_EVENT_HALTED:
gdb_frontend_halted(target, connection); gdb_frontend_halted(target, connection);
break; break;
case TARGET_EVENT_GDB_PROGRAM: case TARGET_EVENT_GDB_FLASH_ERASE_START:
gdb_program_handler(target, event, connection->cmd_ctx); gdb_program_handler(target, event, connection->cmd_ctx);
break; break;
default: default:
...@@ -1769,7 +1769,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p ...@@ -1769,7 +1769,7 @@ int gdb_v_packet(connection_t *connection, target_t *target, char *packet, int p
flash_set_dirty(); flash_set_dirty();
/* perform any target specific operations before the erase */ /* 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 */ /* perform erase */
if ((result = flash_erase_address_range(gdb_service->target, addr, length)) != ERROR_OK) if ((result = flash_erase_address_range(gdb_service->target, addr, length)) != ERROR_OK)
...@@ -2063,8 +2063,7 @@ int gdb_input(connection_t *connection) ...@@ -2063,8 +2063,7 @@ int gdb_input(connection_t *connection)
int gdb_init(void) int gdb_init(void)
{ {
gdb_service_t *gdb_service; gdb_service_t *gdb_service;
target_t *target = targets; target_t *target = all_targets;
int i = 0;
if (!target) if (!target)
{ {
...@@ -2082,16 +2081,21 @@ int gdb_init(void) ...@@ -2082,16 +2081,21 @@ int gdb_init(void)
{ {
char service_name[8]; 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 = malloc(sizeof(gdb_service_t));
gdb_service->target = target; 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; target = target->next;
} }
......
...@@ -726,7 +726,8 @@ int arm11_halt(struct target_s *target) ...@@ -726,7 +726,8 @@ int arm11_halt(struct target_s *target)
arm11_common_t * arm11 = target->arch_info; 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) if (target->state == TARGET_UNKNOWN)
{ {
...@@ -782,7 +783,9 @@ int arm11_resume(struct target_s *target, int current, u32 address, int handle_b ...@@ -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; 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) if (target->state != TARGET_HALTED)
{ {
...@@ -877,7 +880,8 @@ int arm11_step(struct target_s *target, int current, u32 address, int handle_bre ...@@ -877,7 +880,8 @@ int arm11_step(struct target_s *target, int current, u32 address, int handle_bre
{ {
FNC_INFO; 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) if (target->state != TARGET_HALTED)
{ {
...@@ -1012,7 +1016,9 @@ int arm11_deassert_reset(struct target_s *target) ...@@ -1012,7 +1016,9 @@ int arm11_deassert_reset(struct target_s *target)
FNC_INFO; FNC_INFO;
#if 0 #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 */ /* deassert reset lines */
jtag_add_reset(0, 0); jtag_add_reset(0, 0);
...@@ -1667,7 +1673,7 @@ arm11_common_t * arm11_find_target(const char * arg) ...@@ -1667,7 +1673,7 @@ arm11_common_t * arm11_find_target(const char * arg)
size_t jtag_target = strtoul(arg, NULL, 0); size_t jtag_target = strtoul(arg, NULL, 0);
{target_t * t; {target_t * t;
for (t = targets; t; t = t->next) for (t = all_targets; t; t = t->next)
{ {
if (t->type != &arm11_target) if (t->type != &arm11_target)
continue; continue;
......
...@@ -321,7 +321,7 @@ int arm720t_arch_state(struct target_s *target) ...@@ -321,7 +321,7 @@ int arm720t_arch_state(struct target_s *target)
"cpsr: 0x%8.8x pc: 0x%8.8x\n" "cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, Cache: %s", "MMU: %s, Cache: %s",
armv4_5_state_strings[armv4_5->core_state], 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)], 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[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].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) ...@@ -734,7 +734,8 @@ int arm7_9_assert_reset(target_t *target)
{ {
armv4_5_common_t *armv4_5 = target->arch_info; armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->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)) if (!(jtag_reset_config & RESET_HAS_SRST))
{ {
...@@ -795,7 +796,9 @@ int arm7_9_assert_reset(target_t *target) ...@@ -795,7 +796,9 @@ int arm7_9_assert_reset(target_t *target)
int arm7_9_deassert_reset(target_t *target) int arm7_9_deassert_reset(target_t *target)
{ {
int retval=ERROR_OK; 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 */ /* deassert reset lines */
jtag_add_reset(0, 0); jtag_add_reset(0, 0);
...@@ -969,7 +972,8 @@ int arm7_9_halt(target_t *target) ...@@ -969,7 +972,8 @@ int arm7_9_halt(target_t *target)
arm7_9_common_t *arm7_9 = armv4_5->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info;
reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]; 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) if (target->state == TARGET_HALTED)
{ {
......
...@@ -45,6 +45,7 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx); ...@@ -45,6 +45,7 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx);
/* forward declarations */ /* 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_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_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm7tdmi_quit(void); int arm7tdmi_quit(void);
...@@ -86,6 +87,7 @@ target_type_t arm7tdmi_target = ...@@ -86,6 +87,7 @@ target_type_t arm7tdmi_target =
.register_commands = arm7tdmi_register_commands, .register_commands = arm7tdmi_register_commands,
.target_command = arm7tdmi_target_command, .target_command = arm7tdmi_target_command,
// .target_create = arm7tdmi_target_create,
.init_target = arm7tdmi_init_target, .init_target = arm7tdmi_init_target,
.examine = arm7tdmi_examine, .examine = arm7tdmi_examine,
.quit = arm7tdmi_quit .quit = arm7tdmi_quit
...@@ -759,7 +761,7 @@ int arm7tdmi_quit(void) ...@@ -759,7 +761,7 @@ int arm7tdmi_quit(void)
return ERROR_OK; 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; armv4_5_common_t *armv4_5;
arm7_9_common_t *arm7_9; arm7_9_common_t *arm7_9;
...@@ -851,6 +853,20 @@ int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char * ...@@ -851,6 +853,20 @@ int arm7tdmi_target_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_OK; 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 arm7tdmi_register_commands(struct command_context_s *cmd_ctx)
{ {
int retval; int retval;
...@@ -861,3 +877,10 @@ int arm7tdmi_register_commands(struct command_context_s *cmd_ctx) ...@@ -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 ...@@ -38,7 +38,7 @@ typedef struct arm7tdmi_common_s
} arm7tdmi_common_t; } arm7tdmi_common_t;
int arm7tdmi_register_commands(struct command_context_s *cmd_ctx); 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_init_target(struct command_context_s *cmd_ctx, struct target_s *target);
int arm7tdmi_examine(struct target_s *target); int arm7tdmi_examine(struct target_s *target);
......
...@@ -566,7 +566,7 @@ int arm920t_arch_state(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" "cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, D-Cache: %s, I-Cache: %s", "MMU: %s, D-Cache: %s, I-Cache: %s",
armv4_5_state_strings[armv4_5->core_state], 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)], 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[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].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) ...@@ -562,7 +562,7 @@ int arm926ejs_arch_state(struct target_s *target)
"cpsr: 0x%8.8x pc: 0x%8.8x\n" "cpsr: 0x%8.8x pc: 0x%8.8x\n"
"MMU: %s, D-Cache: %s, I-Cache: %s", "MMU: %s, D-Cache: %s, I-Cache: %s",
armv4_5_state_strings[armv4_5->core_state], 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)], 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[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].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) ...@@ -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", 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], 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)], 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[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].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) ...@@ -439,7 +439,7 @@ int armv7m_arch_state(struct target_s *target)
armv7m_common_t *armv7m = target->arch_info; 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", 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_mode_strings[armv7m->core_mode],
armv7m_exception_string(armv7m->exception_number), armv7m_exception_string(armv7m->exception_number),
buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32), 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) ...@@ -359,8 +359,10 @@ int cortex_m3_debug_entry(target_t *target)
cortex_m3_examine_exception_reason(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], \ LOG_DEBUG("entered debug state in core mode: %s at PC 0x%x, target->state: %s",
*(u32*)(armv7m->core_cache->reg_list[15].value), target_state_strings[target->state]); 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) if (armv7m->post_debug_entry)
armv7m->post_debug_entry(target); armv7m->post_debug_entry(target);
...@@ -436,7 +438,7 @@ int cortex_m3_poll(target_t *target) ...@@ -436,7 +438,7 @@ int cortex_m3_poll(target_t *target)
#if 0 #if 0
/* Read Debug Fault Status Register, added to figure out the lockup when running flashtest.script */ /* 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); 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 #endif
return ERROR_OK; return ERROR_OK;
...@@ -449,7 +451,8 @@ int cortex_m3_halt(target_t *target) ...@@ -449,7 +451,8 @@ int cortex_m3_halt(target_t *target)
cortex_m3_common_t *cortex_m3 = armv7m->arch_info; cortex_m3_common_t *cortex_m3 = armv7m->arch_info;
swjdp_common_t *swjdp = &cortex_m3->swjdp_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) if (target->state == TARGET_HALTED)
{ {
...@@ -676,7 +679,8 @@ int cortex_m3_assert_reset(target_t *target) ...@@ -676,7 +679,8 @@ int cortex_m3_assert_reset(target_t *target)
swjdp_common_t *swjdp = &cortex_m3->swjdp_info; swjdp_common_t *swjdp = &cortex_m3->swjdp_info;
int assert_srst = 1; 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)) if (!(jtag_reset_config & RESET_HAS_SRST))
{ {
...@@ -774,7 +778,8 @@ int cortex_m3_assert_reset(target_t *target) ...@@ -774,7 +778,8 @@ int cortex_m3_assert_reset(target_t *target)
int cortex_m3_deassert_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 */ /* deassert reset lines */
jtag_add_reset(0, 0); jtag_add_reset(0, 0);
......
...@@ -266,7 +266,7 @@ int mips32_arch_state(struct target_s *target) ...@@ -266,7 +266,7 @@ int mips32_arch_state(struct target_s *target)
} }
LOG_USER("target halted due to %s, pc: 0x%8.8x", 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)); buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
return ERROR_OK; return ERROR_OK;
......
...@@ -119,8 +119,9 @@ int mips_m4k_debug_entry(target_t *target) ...@@ -119,8 +119,9 @@ int mips_m4k_debug_entry(target_t *target)
mips32_save_context(target); mips32_save_context(target);
LOG_DEBUG("entered debug state at PC 0x%x, target->state: %s", \ 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]); *(u32*)(mips32->core_cache->reg_list[MIPS32_PC].value),
Jim_Nvp_value2name_simple( nvp_target_state, target->state )->name);
return ERROR_OK; return ERROR_OK;
} }
...@@ -187,7 +188,8 @@ int mips_m4k_halt(struct target_s *target) ...@@ -187,7 +188,8 @@ int mips_m4k_halt(struct target_s *target)
mips32_common_t *mips32 = target->arch_info; mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_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) if (target->state == TARGET_HALTED)
{ {
...@@ -231,7 +233,8 @@ int mips_m4k_assert_reset(target_t *target) ...@@ -231,7 +233,8 @@ int mips_m4k_assert_reset(target_t *target)
mips32_common_t *mips32 = target->arch_info; mips32_common_t *mips32 = target->arch_info;
mips_ejtag_t *ejtag_info = &mips32->ejtag_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)) if (!(jtag_reset_config & RESET_HAS_SRST))
{ {
...@@ -279,7 +282,8 @@ int mips_m4k_assert_reset(target_t *target) ...@@ -279,7 +282,8 @@ int mips_m4k_assert_reset(target_t *target)
int mips_m4k_deassert_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 */ /* deassert reset lines */
jtag_add_reset(0, 0); jtag_add_reset(0, 0);
......
...@@ -80,6 +80,11 @@ static int jim_array2mem(Jim_Interp *interp, int argc, Jim_Obj *const *argv); ...@@ -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 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 */ /* targets */
extern target_type_t arm7tdmi_target; extern target_type_t arm7tdmi_target;
extern target_type_t arm720t_target; extern target_type_t arm720t_target;
...@@ -109,32 +114,105 @@ target_type_t *target_types[] = ...@@ -109,32 +114,105 @@ target_type_t *target_types[] =
NULL, NULL,
}; };
target_t *targets = NULL; target_t *all_targets = NULL;
target_event_callback_t *target_event_callbacks = NULL; target_event_callback_t *target_event_callbacks = NULL;
target_timer_callback_t *target_timer_callbacks = NULL; target_timer_callback_t *target_timer_callbacks = NULL;
char *target_state_strings[] = const Jim_Nvp nvp_assert[] = {
{ { .name = "assert", NVP_ASSERT },
"unknown", { .name = "deassert", NVP_DEASSERT },
"running", { .name = "T", NVP_ASSERT },
"halted", { .name = "F", NVP_DEASSERT },
"reset", { .name = "t", NVP_ASSERT },
"debug_running", { .name = "f", NVP_DEASSERT },
{ .name = NULL, .value = -1 }
}; };
char *target_debug_reason_strings[] = const Jim_Nvp nvp_target_event[] = {
{ { .value = TARGET_EVENT_HALTED, .name = "halted" },
"debug request", "breakpoint", "watchpoint", { .value = TARGET_EVENT_RESUMED, .name = "resumed" },
"watchpoint and breakpoint", "single step", { .value = TARGET_EVENT_RESUME_START, .name = "resume-start" },
"target not halted", "undefined" { .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[] = const Jim_Nvp nvp_target_state[] = {
{ { .name = "unknown", .value = TARGET_UNKNOWN },
"big endian", { .name = "running", .value = TARGET_RUNNING },
"little endian", { .name = "halted", .value = TARGET_HALTED },
{ .name = "reset", .value = TARGET_RESET },
{ .name = "debug-running", .value = TARGET_DEBUG_RUNNING },
{ .