Commit 3acb107b authored by drath's avatar drath
Browse files

- endianess fixes everywhere but in the flash code. flashing might still be...

- endianess fixes everywhere but in the flash code. flashing might still be broken on big-endian targets and/or hosts
- added access to ARM920T vector catch register (via generic register mechanism)
- don't disable linefills on ARM920T cores - this lead to lockups when accessing lines already contained in cache
- read content of ARM920T cache and tlb into file (arm920t read_flash/read_mmu commands)
- memory reading improved on ARM7/9, can be further accelerated with new "arm7_9 fast_memory_access enable" command (renamed from fast_writes)
- made in_handler independent from in field (makes the handler more flexible)
- added timeout to ft2232 when using D2XX library
- fixed STR7x protection bit handling on second bank (thanks to Bernard)
- added support for using the OpenOCD on AT91RM9200 systems (thanks to Anders Larsen)
- fixed AT91SAM7 flash handling when not running from 32kHz clock (thanks to Anders Larsen)


git-svn-id: svn://svn.berlios.de/openocd/trunk@90 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent da9eedc0
...@@ -40,6 +40,10 @@ AC_ARG_ENABLE(ep93xx, ...@@ -40,6 +40,10 @@ AC_ARG_ENABLE(ep93xx,
AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]), AS_HELP_STRING([--enable-ep93xx], [Enable building support for EP93xx based SBCs]),
[build_ep93xx=$enableval], [build_ep93xx=no]) [build_ep93xx=$enableval], [build_ep93xx=no])
AC_ARG_ENABLE(at91rm9200,
AS_HELP_STRING([--enable-at91rm9200], [Enable building support for AT91RM9200 based SBCs]),
[build_at91rm9200=$enableval], [build_at91rm9200=no])
AC_ARG_WITH(ftd2xx, AC_ARG_WITH(ftd2xx,
[AS_HELP_STRING(--with-ftd2xx, [AS_HELP_STRING(--with-ftd2xx,
[Where libftd2xx can be found <default=search>])], [Where libftd2xx can be found <default=search>])],
...@@ -96,6 +100,13 @@ else ...@@ -96,6 +100,13 @@ else
AC_DEFINE(BUILD_EP93XX, 0, [0 if you don't want ep93xx.]) AC_DEFINE(BUILD_EP93XX, 0, [0 if you don't want ep93xx.])
fi fi
if test $build_at91rm9200 = yes; then
build_bitbang=yes
AC_DEFINE(BUILD_AT91RM9200, 1, [1 if you want at91rm9200.])
else
AC_DEFINE(BUILD_AT91RM9200, 0, [0 if you don't want at91rm9200.])
fi
if test $parport_use_ppdev = yes; then if test $parport_use_ppdev = yes; then
AC_DEFINE(PARPORT_USE_PPDEV, 1, [1 if you want parport to use ppdev.]) AC_DEFINE(PARPORT_USE_PPDEV, 1, [1 if you want parport to use ppdev.])
else else
...@@ -138,6 +149,7 @@ AM_INIT_AUTOMAKE(openocd, 0.1) ...@@ -138,6 +149,7 @@ AM_INIT_AUTOMAKE(openocd, 0.1)
AM_CONDITIONAL(PARPORT, test $build_parport = yes) AM_CONDITIONAL(PARPORT, test $build_parport = yes)
AM_CONDITIONAL(GIVEIO, test $parport_use_giveio = yes) AM_CONDITIONAL(GIVEIO, test $parport_use_giveio = yes)
AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes) AM_CONDITIONAL(EP93XX, test $build_ep93xx = yes)
AM_CONDITIONAL(AT91RM9200, test $build_at91rm9200 = yes)
AM_CONDITIONAL(BITBANG, test $build_bitbang = yes) AM_CONDITIONAL(BITBANG, test $build_bitbang = yes)
AM_CONDITIONAL(FT2232_LIBFTDI, test $build_ft2232_libftdi = yes) AM_CONDITIONAL(FT2232_LIBFTDI, test $build_ft2232_libftdi = yes)
AM_CONDITIONAL(FT2232_FTD2XX, test $build_ft2232_ftd2xx = yes) AM_CONDITIONAL(FT2232_FTD2XX, test $build_ft2232_ftd2xx = yes)
......
...@@ -7,7 +7,7 @@ interface ft2232 ...@@ -7,7 +7,7 @@ interface ft2232
ft2232_device_desc "Amontec JTAGkey A" ft2232_device_desc "Amontec JTAGkey A"
ft2232_layout jtagkey ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8 ft2232_vid_pid 0x0403 0xcff8
jtag_speed 0 jtag_speed 2
#use combined on interfaces or targets that can't set TRST/SRST separately #use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst reset_config trst_and_srst srst_pulls_trst
......
...@@ -133,9 +133,10 @@ u32 at91sam7_get_flash_status(flash_bank_t *bank) ...@@ -133,9 +133,10 @@ u32 at91sam7_get_flash_status(flash_bank_t *bank)
{ {
at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv; at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv;
target_t *target = at91sam7_info->target; target_t *target = at91sam7_info->target;
long fsr; u32 fsr;
target->type->read_memory(target, MC_FSR, 4, 1, (u8 *)&fsr); target->type->read_memory(target, MC_FSR, 4, 1, (u8 *)&fsr);
fsr = target_buffer_get_u32(target, (u8 *)&fsr);
return fsr; return fsr;
} }
...@@ -206,7 +207,7 @@ void at91sam7_read_clock_info(flash_bank_t *bank) ...@@ -206,7 +207,7 @@ void at91sam7_read_clock_info(flash_bank_t *bank)
/* Setup the timimg registers for nvbits or normal flash */ /* Setup the timimg registers for nvbits or normal flash */
void at91sam7_set_flash_mode(flash_bank_t *bank,int mode) void at91sam7_set_flash_mode(flash_bank_t *bank,int mode)
{ {
u32 fmcn, fmr; u32 fmr, fmcn = 0, fws = 0;
at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv; at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv;
target_t *target = at91sam7_info->target; target_t *target = at91sam7_info->target;
...@@ -220,12 +221,14 @@ void at91sam7_set_flash_mode(flash_bank_t *bank,int mode) ...@@ -220,12 +221,14 @@ void at91sam7_set_flash_mode(flash_bank_t *bank,int mode)
fmcn = (at91sam7_info->mck_freq/666666ul)+1; fmcn = (at91sam7_info->mck_freq/666666ul)+1;
/* Only allow fmcn=0 if clock period is > 30 us. */ /* Only allow fmcn=0 if clock period is > 30 us. */
if (at91sam7_info->mck_freq <= 33333) if (at91sam7_info->mck_freq <= 33333333ul)
fmcn = 0; fmcn = 0;
else
fws = 1;
DEBUG("fmcn: %i", fmcn); DEBUG("fmcn: %i", fmcn);
fmr = fmcn<<16; fmr = fmcn << 16 | fws << 8;
target->type->write_memory(target, MC_FSR, 4, 1, (u8 *)&fmr); target->type->write_memory(target, MC_FMR, 4, 1, (u8 *)&fmr);
} }
at91sam7_info->flashmode = mode; at91sam7_info->flashmode = mode;
} }
......
...@@ -48,7 +48,7 @@ typedef struct at91sam7_flash_bank_s ...@@ -48,7 +48,7 @@ typedef struct at91sam7_flash_bank_s
u8 num_erase_regions; u8 num_erase_regions;
u32 *erase_region_info; u32 *erase_region_info;
/* nv memory bits */ /* nv memory bits */
u16 num_lockbits; u16 num_lockbits;
u16 lockbits; u16 lockbits;
u16 num_nvmbits; u16 num_nvmbits;
......
...@@ -44,8 +44,8 @@ str7x_mem_layout_t mem_layout[] = { ...@@ -44,8 +44,8 @@ str7x_mem_layout_t mem_layout[] = {
{0x00010000, 0x10000, 0x01}, {0x00010000, 0x10000, 0x01},
{0x00020000, 0x10000, 0x01}, {0x00020000, 0x10000, 0x01},
{0x00030000, 0x10000, 0x01}, {0x00030000, 0x10000, 0x01},
{0x000C0000, 0x02000, 0x10}, {0x000C0000, 0x02000, 0x100},
{0x000C2000, 0x02000, 0x10}, {0x000C2000, 0x02000, 0x100},
{0,0}, {0,0},
}; };
......
...@@ -49,6 +49,12 @@ else ...@@ -49,6 +49,12 @@ else
EP93XXFILES = EP93XXFILES =
endif endif
libjtag_a_SOURCES = jtag.c $(BITBANGFILES) $(PARPORTFILES) $(FT2232FILES) $(AMTJTAGACCELFILES) $(EP93XXFILES) if AT91RM9200
AT91RM9200FILES = at91rm9200.c
else
AT91RM9200FILES =
endif
libjtag_a_SOURCES = jtag.c $(BITBANGFILES) $(PARPORTFILES) $(FT2232FILES) $(AMTJTAGACCELFILES) $(EP93XXFILES) $(AT91RM9200FILES)
noinst_HEADERS = bitbang.h jtag.h noinst_HEADERS = bitbang.h jtag.h
...@@ -1009,6 +1009,12 @@ int ft2232_init(void) ...@@ -1009,6 +1009,12 @@ int ft2232_init(void)
{ {
DEBUG("current latency timer: %i", latency_timer); DEBUG("current latency timer: %i", latency_timer);
} }
if ((status = FT_SetTimeouts(ftdih, 5000, 5000)) != FT_OK)
{
ERROR("unable to set timeouts: %i", status);
return ERROR_JTAG_INIT_FAILED;
}
if ((status = FT_SetBitMode(ftdih, 0x0b, 2)) != FT_OK) if ((status = FT_SetBitMode(ftdih, 0x0b, 2)) != FT_OK)
{ {
......
...@@ -140,6 +140,10 @@ jtag_event_callback_t *jtag_event_callbacks; ...@@ -140,6 +140,10 @@ jtag_event_callback_t *jtag_event_callbacks;
extern jtag_interface_t ep93xx_interface; extern jtag_interface_t ep93xx_interface;
#endif #endif
#if BUILD_AT91RM9200 == 1
extern jtag_interface_t at91rm9200_interface;
#endif
jtag_interface_t *jtag_interfaces[] = { jtag_interface_t *jtag_interfaces[] = {
#if BUILD_PARPORT == 1 #if BUILD_PARPORT == 1
&parport_interface, &parport_interface,
...@@ -155,6 +159,9 @@ jtag_interface_t *jtag_interfaces[] = { ...@@ -155,6 +159,9 @@ jtag_interface_t *jtag_interfaces[] = {
#endif #endif
#if BUILD_EP93XX == 1 #if BUILD_EP93XX == 1
&ep93xx_interface, &ep93xx_interface,
#endif
#if BUILD_AT91RM9200 == 1
&at91rm9200_interface,
#endif #endif
NULL, NULL,
}; };
...@@ -974,20 +981,26 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) ...@@ -974,20 +981,26 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
for (i=0; i < cmd->num_fields; i++) for (i=0; i < cmd->num_fields; i++)
{ {
/* if neither in_value nor in_check_value are specified we don't have to examine this field */ /* if neither in_value, in_check_value nor in_handler
if (cmd->fields[i].in_value || cmd->fields[i].in_check_value) * are specified we don't have to examine this field
*/
if (cmd->fields[i].in_value || cmd->fields[i].in_check_value || cmd->fields[i].in_handler)
{ {
int num_bits = cmd->fields[i].num_bits; int num_bits = cmd->fields[i].num_bits;
u8 *captured = buf_set_buf(buffer, bit_count, malloc(CEIL(num_bits, 8)), 0, num_bits);
if (cmd->fields[i].in_value) #ifdef _DEBUG_JTAG_IO_
{
char *char_buf; char *char_buf;
buf_set_buf(buffer, bit_count, cmd->fields[i].in_value, 0, num_bits);
char_buf = buf_to_char(cmd->fields[i].in_value, num_bits); char_buf = buf_to_char(captured, num_bits);
#ifdef _DEBUG_JTAG_IO_
DEBUG("fields[%i].in_value: %s", i, char_buf); DEBUG("fields[%i].in_value: %s", i, char_buf);
#endif
free(char_buf); free(char_buf);
#endif
if (cmd->fields[i].in_value)
{
buf_cpy(captured, cmd->fields[i].in_value, num_bits);
if (cmd->fields[i].in_handler) if (cmd->fields[i].in_handler)
{ {
if (cmd->fields[i].in_handler(cmd->fields[i].in_value, cmd->fields[i].in_handler_priv) != ERROR_OK) if (cmd->fields[i].in_handler(cmd->fields[i].in_value, cmd->fields[i].in_handler_priv) != ERROR_OK)
...@@ -998,6 +1011,18 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) ...@@ -998,6 +1011,18 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
} }
} }
} }
/* no in_value specified, but a handler takes care of the scanned data */
if (cmd->fields[i].in_handler && (!cmd->fields[i].in_value))
{
if (cmd->fields[i].in_handler(captured, cmd->fields[i].in_handler_priv) != ERROR_OK)
{
/* TODO: error reporting */
WARNING("in_handler reported a failed check");
retval = ERROR_JTAG_QUEUE_FAILED;
}
}
if (cmd->fields[i].in_check_value) if (cmd->fields[i].in_check_value)
{ {
...@@ -1015,8 +1040,8 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd) ...@@ -1015,8 +1040,8 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
free(in_check_value_char); free(in_check_value_char);
free(in_check_mask_char); free(in_check_mask_char);
} }
free(captured);
} }
free(captured);
} }
bit_count += cmd->fields[i].num_bits; bit_count += cmd->fields[i].num_bits;
} }
...@@ -1031,7 +1056,7 @@ enum scan_type jtag_scan_type(scan_command_t *cmd) ...@@ -1031,7 +1056,7 @@ enum scan_type jtag_scan_type(scan_command_t *cmd)
for (i=0; i < cmd->num_fields; i++) for (i=0; i < cmd->num_fields; i++)
{ {
if (cmd->fields[i].in_check_value || cmd->fields[i].in_value) if (cmd->fields[i].in_check_value || cmd->fields[i].in_value || cmd->fields[i].in_handler)
type |= SCAN_IN; type |= SCAN_IN;
if (cmd->fields[i].out_value) if (cmd->fields[i].out_value)
type |= SCAN_OUT; type |= SCAN_OUT;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "command.h" #include "command.h"
#if 1 #if 0
#define _DEBUG_JTAG_IO_ #define _DEBUG_JTAG_IO_
#endif #endif
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if 1 #if 0
#define _DEBUG_INSTRUCTION_EXECUTION_ #define _DEBUG_INSTRUCTION_EXECUTION_
#endif #endif
...@@ -92,8 +92,7 @@ int arm720t_scan_cp15(target_t *target, u32 out, u32 *in, int instruction, int c ...@@ -92,8 +92,7 @@ int arm720t_scan_cp15(target_t *target, u32 out, u32 *in, int instruction, int c
u8 out_buf[4]; u8 out_buf[4];
u8 instruction_buf = instruction; u8 instruction_buf = instruction;
out = flip_u32(out, 32); buf_set_u32(out_buf, 0, 32, flip_u32(out, 32));
buf_set_u32(out_buf, 0, 32, out);
jtag_add_end_state(TAP_PD); jtag_add_end_state(TAP_PD);
arm_jtag_scann(jtag_info, 0xf); arm_jtag_scann(jtag_info, 0xf);
...@@ -113,14 +112,13 @@ int arm720t_scan_cp15(target_t *target, u32 out, u32 *in, int instruction, int c ...@@ -113,14 +112,13 @@ int arm720t_scan_cp15(target_t *target, u32 out, u32 *in, int instruction, int c
fields[1].num_bits = 32; fields[1].num_bits = 32;
fields[1].out_value = out_buf; fields[1].out_value = out_buf;
fields[1].out_mask = NULL; fields[1].out_mask = NULL;
fields[1].in_value = NULL;
if (in) if (in)
{ {
fields[1].in_value = (u8*)in;
fields[1].in_handler = arm_jtag_buf_to_u32_flip; fields[1].in_handler = arm_jtag_buf_to_u32_flip;
fields[1].in_handler_priv = in; fields[1].in_handler_priv = in;
} else } else
{ {
fields[1].in_value = NULL;
fields[1].in_handler = NULL; fields[1].in_handler = NULL;
fields[1].in_handler_priv = NULL; fields[1].in_handler_priv = NULL;
} }
......
...@@ -52,7 +52,7 @@ int handle_arm7_9_write_core_reg_command(struct command_context_s *cmd_ctx, char ...@@ -52,7 +52,7 @@ int handle_arm7_9_write_core_reg_command(struct command_context_s *cmd_ctx, char
int handle_arm7_9_sw_bkpts_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_arm7_9_sw_bkpts_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_arm7_9_force_hw_bkpts_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_arm7_9_force_hw_bkpts_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_arm7_9_dbgrq_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_arm7_9_dbgrq_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_arm7_9_fast_writes_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_arm7_9_fast_memory_access_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_arm7_9_dcc_downloads_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); int handle_arm7_9_dcc_downloads_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int arm7_9_reinit_embeddedice(target_t *target) int arm7_9_reinit_embeddedice(target_t *target)
...@@ -184,13 +184,17 @@ int arm7_9_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint) ...@@ -184,13 +184,17 @@ int arm7_9_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
if (breakpoint->length == 4) if (breakpoint->length == 4)
{ {
/* keep the original instruction in target endianness */
target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr); target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr);
target->type->write_memory(target, breakpoint->address, 4, 1, (u8*)(&arm7_9->arm_bkpt)); /* write the original instruction in target endianness (arm7_9->arm_bkpt is host endian) */
target_write_u32(target, breakpoint->address, arm7_9->arm_bkpt);
} }
else else
{ {
/* keep the original instruction in target endianness */
target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr); target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr);
target->type->write_memory(target, breakpoint->address, 2, 1, (u8*)(&arm7_9->thumb_bkpt)); /* write the original instruction in target endianness (arm7_9->arm_bkpt is host endian) */
target_write_u32(target, breakpoint->address, arm7_9->thumb_bkpt);
} }
breakpoint->set = 1; breakpoint->set = 1;
} }
...@@ -234,6 +238,7 @@ int arm7_9_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint) ...@@ -234,6 +238,7 @@ int arm7_9_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
} }
else else
{ {
/* restore original instruction (kept in target endianness) */
if (breakpoint->length == 4) if (breakpoint->length == 4)
{ {
target->type->write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr); target->type->write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr);
...@@ -534,7 +539,7 @@ int arm7_9_execute_sys_speed(struct target_s *target) ...@@ -534,7 +539,7 @@ int arm7_9_execute_sys_speed(struct target_s *target)
arm7_9_common_t *arm7_9 = armv4_5->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT]; reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
/* set RESTART instruction */ /* set RESTART instruction */
jtag_add_end_state(TAP_RTI); jtag_add_end_state(TAP_RTI);
arm_jtag_set_instr(jtag_info, 0x4); arm_jtag_set_instr(jtag_info, 0x4);
...@@ -567,7 +572,7 @@ int arm7_9_execute_fast_sys_speed(struct target_s *target) ...@@ -567,7 +572,7 @@ int arm7_9_execute_fast_sys_speed(struct target_s *target)
arm7_9_common_t *arm7_9 = armv4_5->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info;
arm_jtag_t *jtag_info = &arm7_9->jtag_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info;
reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT]; reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
/* set RESTART instruction */ /* set RESTART instruction */
jtag_add_end_state(TAP_RTI); jtag_add_end_state(TAP_RTI);
arm_jtag_set_instr(jtag_info, 0x4); arm_jtag_set_instr(jtag_info, 0x4);
...@@ -588,7 +593,6 @@ enum target_state arm7_9_poll(target_t *target) ...@@ -588,7 +593,6 @@ enum target_state arm7_9_poll(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;
reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT]; reg_t *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL];
if (arm7_9->reinit_embeddedice) if (arm7_9->reinit_embeddedice)
{ {
...@@ -967,6 +971,7 @@ int arm7_9_debug_entry(target_t *target) ...@@ -967,6 +971,7 @@ int arm7_9_debug_entry(target_t *target)
for (i=0; i<=15; i++) for (i=0; i<=15; i++)
{ {
DEBUG("r%i: 0x%8.8x", i, context[i]);
buf_set_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).value, 0, 32, context[i]); buf_set_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).value, 0, 32, context[i]);
ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).dirty = 0; ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).dirty = 0;
ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).valid = 1; ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i).valid = 1;
...@@ -1619,14 +1624,13 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count ...@@ -1619,14 +1624,13 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
arm7_9_common_t *arm7_9 = armv4_5->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info;
u32 reg[16]; u32 reg[16];
u32 *reg_p[16];
int num_accesses = 0; int num_accesses = 0;
int thisrun_accesses; int thisrun_accesses;
int i; int i;
u32 cpsr; u32 cpsr;
int retval; int retval;
int last_reg = 0; int last_reg = 0;
DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count);
if (target->state != TARGET_HALTED) if (target->state != TARGET_HALTED)
...@@ -1642,11 +1646,6 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count ...@@ -1642,11 +1646,6 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u))) if (((size == 4) && (address & 0x3u)) || ((size == 2) && (address & 0x1u)))
return ERROR_TARGET_UNALIGNED_ACCESS; return ERROR_TARGET_UNALIGNED_ACCESS;
for (i = 0; i < 16; i++)
{
reg_p[i] = &reg[i];
}
/* load the base register with the address of the first word */ /* load the base register with the address of the first word */
reg[0] = address; reg[0] = address;
arm7_9->write_core_regs(target, 0x1, reg); arm7_9->write_core_regs(target, 0x1, reg);
...@@ -1660,19 +1659,23 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count ...@@ -1660,19 +1659,23 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
thisrun_accesses = ((count - num_accesses) >= 14) ? 14 : (count - num_accesses); thisrun_accesses = ((count - num_accesses) >= 14) ? 14 : (count - num_accesses);
reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe; reg_list = (0xffff >> (15 - thisrun_accesses)) & 0xfffe;
if (last_reg <= thisrun_accesses)
last_reg = thisrun_accesses;
arm7_9->load_word_regs(target, reg_list); arm7_9->load_word_regs(target, reg_list);
arm7_9_execute_sys_speed(target);
arm7_9->read_core_regs(target, reg_list, reg_p); /* fast memory reads are only safe when the target is running
jtag_execute_queue(); * from a sufficiently high clock (32 kHz is usually too slow)
*/
if (arm7_9->fast_memory_access)
arm7_9_execute_fast_sys_speed(target);
else
arm7_9_execute_sys_speed(target);
arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 4);
for (i = 1; i <= thisrun_accesses; i++) /* advance buffer, count number of accesses */
{ buffer += thisrun_accesses * 4;
if (i > last_reg)
last_reg = i;
target_buffer_set_u32(target, buffer, reg[i]);
buffer += 4;
}
num_accesses += thisrun_accesses; num_accesses += thisrun_accesses;
} }
break; break;
...@@ -1688,17 +1691,19 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count ...@@ -1688,17 +1691,19 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
if (i > last_reg) if (i > last_reg)
last_reg = i; last_reg = i;
arm7_9->load_hword_reg(target, i); arm7_9->load_hword_reg(target, i);
arm7_9_execute_sys_speed(target); /* fast memory reads are only safe when the target is running
* from a sufficiently high clock (32 kHz is usually too slow)
*/
if (arm7_9->fast_memory_access)
arm7_9_execute_fast_sys_speed(target);
else
arm7_9_execute_sys_speed(target);
} }
arm7_9->read_core_regs(target, reg_list, reg_p); arm7_9->read_core_regs_target_buffer(target, reg_list, buffer, 2);
jtag_execute_queue();
for (i = 1; i <= thisrun_accesses; i++) /* advance buffer, count number of accesses */
{ buffer += thisrun_accesses * 2;
target_buffer_set_u16(target, buffer, reg[i]);
buffer += 2;
}
num_accesses += thisrun_accesses; num_accesses += thisrun_accesses;
} }
break; break;
...@@ -1714,16 +1719,19 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count ...@@ -1714,16 +1719,19 @@ int arm7_9_read_memory(struct target_s *target, u32 address, u32 size, u32 count
if (i > last_reg) if (i > last_reg)
last_reg = i; last_reg = i;
arm7_9->load_byte_reg(target, i); arm7_9->load_byte_reg(target, i);
arm7_9_execute_sys_speed(target); /* fast memory reads are only safe when the target is running
* from a sufficiently high clock (32 kHz is usually too slow)
*/