[RFC] target: Move bulk_write_memory to arm7_9

The only remaining user is arm7_9 so remove it from the target API and add
it to struct arm7_9_common to support all its variants with minimal
changes. Many of the variants are likely not correct in the cache/mmu
handling when the bulk write is triggered. This patch does nothing to
change that, except for arm946e, where it was easier to do what might be
the right thing.

Change-Id: Ie73ac07507ff0936fefdb90760046cc8810ed182
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1220
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
Andreas Fritiofson 2013-03-11 22:21:13 +01:00 committed by Spencer Oliver
parent 52eb82e893
commit 5c2f920cc7
15 changed files with 70 additions and 50 deletions

View File

@ -565,14 +565,12 @@ struct target_type arm720t_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm720t_read_memory,
.write_memory = arm7_9_write_memory,
.write_memory = arm7_9_write_memory_opt,
.read_phys_memory = arm720t_read_phys_memory,
.write_phys_memory = arm720t_write_phys_memory,
.mmu = arm720_mmu,
.virt2phys = arm720_virt2phys,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -2469,6 +2469,20 @@ int arm7_9_write_memory(struct target *target,
return ERROR_OK;
}
int arm7_9_write_memory_opt(struct target *target,
uint32_t address,
uint32_t size,
uint32_t count,
const uint8_t *buffer)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
return arm7_9->bulk_write_memory(target, address, count, buffer);
else
return arm7_9_write_memory(target, address, size, count, buffer);
}
static int dcc_count;
static const uint8_t *dcc_buffer;

View File

@ -118,6 +118,13 @@ struct arm7_9_common {
void (*pre_restore_context)(struct target *target);
/**< Callback function called before restoring the processor context */
/**
* Write target memory in multiples of 4 bytes, optimized for
* writing large quantities of data.
*/
int (*bulk_write_memory)(struct target *target, uint32_t address,
uint32_t count, const uint8_t *buffer);
};
static inline struct arm7_9_common *target_to_arm7_9(struct target *target)
@ -151,6 +158,8 @@ int arm7_9_read_memory(struct target *target, uint32_t address,
uint32_t size, uint32_t count, uint8_t *buffer);
int arm7_9_write_memory(struct target *target, uint32_t address,
uint32_t size, uint32_t count, const uint8_t *buffer);
int arm7_9_write_memory_opt(struct target *target, uint32_t address,
uint32_t size, uint32_t count, const uint8_t *buffer);
int arm7_9_bulk_write_memory(struct target *target, uint32_t address,
uint32_t count, const uint8_t *buffer);

View File

@ -648,6 +648,8 @@ int arm7tdmi_init_arch_info(struct target *target,
arm7_9->enable_single_step = arm7_9_enable_eice_step;
arm7_9->disable_single_step = arm7_9_disable_eice_step;
arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
arm7_9->post_debug_entry = NULL;
arm7_9->pre_restore_context = NULL;
@ -694,8 +696,7 @@ struct target_type arm7tdmi_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.write_memory = arm7_9_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -740,6 +740,17 @@ int arm920t_write_memory(struct target *target, uint32_t address,
return ERROR_OK;
}
int arm920t_write_memory_opt(struct target *target, uint32_t address,
uint32_t size, uint32_t count, const uint8_t *buffer)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
return arm7_9->bulk_write_memory(target, address, count, buffer);
else
return arm920t_write_memory(target, address, size, count, buffer);
}
/* EXPORTED to FA256 */
int arm920t_soft_reset_halt(struct target *target)
{
@ -1697,14 +1708,12 @@ struct target_type arm920t_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm920t_read_memory,
.write_memory = arm920t_write_memory,
.write_memory = arm920t_write_memory_opt,
.read_phys_memory = arm920t_read_phys_memory,
.write_phys_memory = arm920t_write_phys_memory,
.mmu = arm920_mmu,
.virt2phys = arm920_virt2phys,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -60,6 +60,8 @@ int arm920t_read_memory(struct target *target,
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
int arm920t_write_memory(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
int arm920t_write_memory_opt(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
int arm920t_post_debug_entry(struct target *target);
void arm920t_pre_restore_context(struct target *target);
int arm920t_get_ttb(struct target *target, uint32_t *result);

View File

@ -656,6 +656,17 @@ int arm926ejs_write_memory(struct target *target, uint32_t address,
return retval;
}
int arm926ejs_write_memory_opt(struct target *target, uint32_t address,
uint32_t size, uint32_t count, const uint8_t *buffer)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (size == 4 && count > 32 && arm7_9->bulk_write_memory)
return arm7_9->bulk_write_memory(target, address, count, buffer);
else
return arm926ejs_write_memory(target, address, size, count, buffer);
}
static int arm926ejs_write_phys_memory(struct target *target,
uint32_t address, uint32_t size,
uint32_t count, const uint8_t *buffer)
@ -808,8 +819,7 @@ struct target_type arm926ejs_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm926ejs_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.write_memory = arm926ejs_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -50,6 +50,8 @@ int arm926ejs_init_arch_info(struct target *target,
int arm926ejs_arch_state(struct target *target);
int arm926ejs_write_memory(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
int arm926ejs_write_memory_opt(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer);
int arm926ejs_soft_reset_halt(struct target *target);
extern const struct command_registration arm926ejs_command_handlers[];

View File

@ -504,7 +504,7 @@ int arm946e_write_memory(struct target *target, uint32_t address,
/**
* Write memory
*/
retval = arm7_9_write_memory(target, address, size, count, buffer);
retval = arm7_9_write_memory_opt(target, address, size, count, buffer);
if (retval != ERROR_OK)
return retval;
@ -764,8 +764,6 @@ struct target_type arm946e_target = {
.read_memory = arm946e_read_memory,
.write_memory = arm946e_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -264,8 +264,7 @@ struct target_type arm966e_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.write_memory = arm7_9_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -752,6 +752,8 @@ int arm9tdmi_init_arch_info(struct target *target,
arm7_9->enable_single_step = arm9tdmi_enable_single_step;
arm7_9->disable_single_step = arm9tdmi_disable_single_step;
arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
arm7_9->post_debug_entry = NULL;
arm7_9->pre_restore_context = NULL;
@ -902,8 +904,7 @@ struct target_type arm9tdmi_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm7_9_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.write_memory = arm7_9_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -284,6 +284,8 @@ static int fa526_init_arch_info_2(struct target *target,
arm7_9->enable_single_step = arm9tdmi_enable_single_step;
arm7_9->disable_single_step = arm9tdmi_disable_single_step;
arm7_9->bulk_write_memory = arm7_9_bulk_write_memory;
arm7_9->post_debug_entry = NULL;
arm7_9->pre_restore_context = NULL;
@ -366,8 +368,7 @@ struct target_type fa526_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm920t_read_memory,
.write_memory = arm920t_write_memory,
.bulk_write_memory = arm7_9_bulk_write_memory,
.write_memory = arm920t_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -605,6 +605,8 @@ static void feroceon_common_setup(struct target *target)
arm7_9->enable_single_step = feroceon_enable_single_step;
arm7_9->disable_single_step = feroceon_disable_single_step;
arm7_9->bulk_write_memory = feroceon_bulk_write_memory;
/* MOE is not implemented */
arm7_9->examine_debug_reason = feroceon_examine_debug_reason;
@ -695,8 +697,7 @@ struct target_type feroceon_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm926ejs_write_memory,
.bulk_write_memory = feroceon_bulk_write_memory,
.write_memory = arm926ejs_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,
@ -733,8 +734,7 @@ struct target_type dragonite_target = {
.get_gdb_reg_list = arm_get_gdb_reg_list,
.read_memory = arm7_9_read_memory,
.write_memory = arm7_9_write_memory,
.bulk_write_memory = feroceon_bulk_write_memory,
.write_memory = arm7_9_write_memory_opt,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = arm_blank_check_memory,

View File

@ -986,12 +986,6 @@ int target_write_phys_memory(struct target *target,
return target->type->write_phys_memory(target, address, size, count, buffer);
}
static int target_bulk_write_memory_default(struct target *target,
uint32_t address, uint32_t count, const uint8_t *buffer)
{
return target_write_memory(target, address, 4, count, buffer);
}
int target_add_breakpoint(struct target *target,
struct breakpoint *breakpoint)
{
@ -1173,9 +1167,6 @@ static int target_init_one(struct command_context *cmd_ctx,
if (target->type->write_buffer == NULL)
target->type->write_buffer = target_write_buffer_default;
if (target->type->bulk_write_memory == NULL)
target->type->bulk_write_memory = target_bulk_write_memory_default;
if (target->type->get_gdb_fileio_info == NULL)
target->type->get_gdb_fileio_info = target_get_gdb_fileio_info_default;
@ -1802,16 +1793,9 @@ static int target_write_buffer_default(struct target *target, uint32_t address,
if (size >= 4) {
int aligned = size - (size % 4);
/* use bulk writes above a certain limit. This may have to be changed */
if (aligned > 128) {
retval = target->type->bulk_write_memory(target, address, aligned / 4, buffer);
if (retval != ERROR_OK)
return retval;
} else {
retval = target_write_memory(target, address, 4, aligned / 4, buffer);
if (retval != ERROR_OK)
return retval;
}
retval = target_write_memory(target, address, 4, aligned / 4, buffer);
if (retval != ERROR_OK)
return retval;
buffer += aligned;
address += aligned;

View File

@ -130,14 +130,6 @@ struct target_type {
int (*write_buffer)(struct target *target, uint32_t address,
uint32_t size, const uint8_t *buffer);
/**
* Write target memory in multiples of 4 bytes, optimized for
* writing large quantities of data. Do @b not call this
* function directly, use target_bulk_write_memory() instead.
*/
int (*bulk_write_memory)(struct target *target, uint32_t address,
uint32_t count, const uint8_t *buffer);
int (*checksum_memory)(struct target *target, uint32_t address,
uint32_t count, uint32_t *checksum);
int (*blank_check_memory)(struct target *target, uint32_t address,