This is an automated email from Gerrit. Andreas Färber ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/3713
-- gerrit commit b44eea763c628887423d783ba03710da24492df2 Author: Andreas Färber <[email protected]> Date: Sun Aug 21 16:05:11 2016 +0200 target: Introduce target_write_phys_u32() for ARMv7-A cache Add a wrapper target_write_phys_u32() for handling 32-bit writes with target_write_phys_memory() in an endian-safe way. Use this wrapper to fix incorrect usages of target_write_phys_memory() in armv7a_l2c_flash_all_data(), armv7a_l2x_cache_flush_virt(), armv7a_l2x_cache_inval_virt() and armv7a_l2x_cache_clean_virt(). Change-Id: Id259b58f6342af2c456e8a291ff12f427174b4cd Fixes: cd440bd ("add armv7a_cache handlers") Signed-off-by: Andreas Färber <[email protected]> diff --git a/src/target/armv7a_cache_l2x.c b/src/target/armv7a_cache_l2x.c index 7988438..3d19ce6 100644 --- a/src/target/armv7a_cache_l2x.c +++ b/src/target/armv7a_cache_l2x.c @@ -63,9 +63,9 @@ int arm7a_l2x_flush_all_data(struct target *target) l2_way_val = (1 << l2x_cache->way) - 1; - return target_write_phys_memory(target, + return target_write_phys_u32(target, l2x_cache->base + L2X0_CLEAN_INV_WAY, - 4, 1, (uint8_t *)&l2_way_val); + l2_way_val); } int armv7a_l2x_cache_flush_virt(struct target *target, uint32_t virt, @@ -90,9 +90,8 @@ int armv7a_l2x_cache_flush_virt(struct target *target, uint32_t virt, if (retval != ERROR_OK) goto done; - retval = target_write_phys_memory(target, - l2x_cache->base + L2X0_CLEAN_INV_LINE_PA, - 4, 1, (uint8_t *)&pa); + retval = target_write_phys_u32(target, + l2x_cache->base + L2X0_CLEAN_INV_LINE_PA, pa); if (retval != ERROR_OK) goto done; } @@ -126,9 +125,8 @@ static int armv7a_l2x_cache_inval_virt(struct target *target, uint32_t virt, if (retval != ERROR_OK) goto done; - retval = target_write_phys_memory(target, - l2x_cache->base + L2X0_INV_LINE_PA, - 4, 1, (uint8_t *)&pa); + retval = target_write_phys_u32(target, + l2x_cache->base + L2X0_INV_LINE_PA, pa); if (retval != ERROR_OK) goto done; } @@ -162,9 +160,8 @@ static int armv7a_l2x_cache_clean_virt(struct target *target, uint32_t virt, if (retval != ERROR_OK) goto done; - retval = target_write_phys_memory(target, - l2x_cache->base + L2X0_CLEAN_LINE_PA, - 4, 1, (uint8_t *)&pa); + retval = target_write_phys_u32(target, + l2x_cache->base + L2X0_CLEAN_LINE_PA, pa); if (retval != ERROR_OK) goto done; } diff --git a/src/target/target.c b/src/target/target.c index 56d9eee..e5961f8 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2369,6 +2369,27 @@ int target_write_u8(struct target *target, uint32_t address, uint8_t value) return retval; } +int target_write_phys_u32(struct target *target, uint32_t address, uint32_t value) +{ + int retval; + uint8_t value_buf[4]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8" PRIx32 "", + address, + value); + + target_buffer_set_u32(target, value_buf, value); + retval = target_write_phys_memory(target, address, 4, 1, value_buf); + if (retval != ERROR_OK) + LOG_DEBUG("failed: %i", retval); + + return retval; +} + static int find_target(struct command_context *cmd_ctx, const char *name) { struct target *target = get_target(name); diff --git a/src/target/target.h b/src/target/target.h index 0cee117..e21eb97 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -664,6 +664,8 @@ int target_write_u32(struct target *target, uint32_t address, uint32_t value); int target_write_u16(struct target *target, uint32_t address, uint16_t value); int target_write_u8(struct target *target, uint32_t address, uint8_t value); +int target_write_phys_u32(struct target *target, uint32_t address, uint32_t value); + /* Issues USER() statements with target state information */ int target_arch_state(struct target *target); -- ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
