Hello, this patch add a target memory alignment option.
Regards, Mathias
>From 7cafbb5b454fb79f36368e9b8c3a62b486f6c024 Mon Sep 17 00:00:00 2001 From: Mathias K. <[email protected]> Date: Thu, 3 Mar 2011 11:01:46 +0100 Subject: [PATCH] target: memory alignment option Add a target option to enable/disable memory alignment. --- src/target/target.c | 19 ++++++++++++++++++- src/target/target.h | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletions(-) diff --git a/src/target/target.c b/src/target/target.c index 3a6c6bb..971531b 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1356,6 +1356,14 @@ int target_write_buffer(struct target *target, uint32_t address, uint32_t size, return ERROR_FAIL; } + /* if memory alignment disabled handle all parameters + * on target implementation + */ + if ( target->alignment == MEMORY_ALIGNMENT_DISABLED ) + { + return target_write_memory(target, address, 0, size, buffer); + } + if (((address % 2) == 0) && (size == 2)) { return target_write_memory(target, address, 2, 1, buffer); @@ -1438,6 +1446,14 @@ int target_read_buffer(struct target *target, uint32_t address, uint32_t size, u return ERROR_FAIL; } + /* if memory alignment disabled handle all parameters + * on target implementation + */ + if ( target->alignment == MEMORY_ALIGNMENT_DISABLED ) + { + return target_read_memory(target, address, 0, size, buffer); + } + if (((address % 2) == 0) && (size == 2)) { return target_read_memory(target, address, 2, 1, buffer); @@ -3695,7 +3711,6 @@ static Jim_Nvp nvp_config_opts[] = { { .name = "-variant", .value = TCFG_VARIANT }, { .name = "-coreid", .value = TCFG_COREID }, { .name = "-chain-position", .value = TCFG_CHAIN_POSITION }, - { .name = NULL, .value = -1 } }; @@ -4673,6 +4688,8 @@ static int target_create(Jim_GetOptInfo *goi) /* will be set by "-endian" */ target->endianness = TARGET_ENDIAN_UNKNOWN; + target->alignment = MEMORY_ALIGNMENT_ENABLED; + /* default to first core, override with -coreid */ target->coreid = 0; diff --git a/src/target/target.h b/src/target/target.h index 2bf9668..07b6e6f 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -90,6 +90,13 @@ enum target_endianess TARGET_BIG_ENDIAN = 1, TARGET_LITTLE_ENDIAN = 2 }; +enum memory_alignment +{ + MEMORY_ALIGNMENT_UNKNOWN = 0, + MEMORY_ALIGNMENT_ENABLED = 1, + MEMORY_ALIGNMENT_DISABLED = 2 +}; + struct working_area { uint32_t address; @@ -140,6 +147,7 @@ struct target struct working_area *working_areas;/* list of allocated working areas */ enum target_debug_reason debug_reason;/* reason why the target entered debug state */ enum target_endianess endianness; /* target endianess */ + enum memory_alignment alignment; /* memory alignment */ // also see: target_state_name() enum target_state state; /* the current backend-state (running, halted, ...) */ struct reg_cache *reg_cache; /* the first register cache of the target (core regs) */ -- 1.7.3.4
_______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
