This is an automated email from Gerrit. daniele12457 (daniele12...@hotmail.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2750
-- gerrit commit 9dd92dedaa3c7fd6fdc32d4c0ebb6736239211fa Author: daniele12457 <daniele12...@hotmail.com> Date: Tue Apr 28 17:46:19 2015 +0200 topic: new feature I think it's usefull to have target read and write from a physical address. Change-Id: Ia0ac4d928b2a0faf2b7e71bce2be879a62bcdea3 Signed-off-by: daniele12457 <daniele12...@hotmail.com> diff --git a/src/target/target.c b/src/target/target.c index 27f8839..8669460 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2138,6 +2138,181 @@ int target_blank_check_memory(struct target *target, uint32_t address, uint32_t return retval; } +int target_read_phys_u64(struct target *target, uint64_t address, uint64_t *value) +{ + uint8_t value_buf[8]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + int retval = target_read_phys_memory(target, address, 8, 1, value_buf); + + if (retval == ERROR_OK) { + *value = target_buffer_get_u64(target, value_buf); + LOG_DEBUG("address: 0x%" PRIx64 ", value: 0x%16.16" PRIx64 "", + address, + *value); + } else { + *value = 0x0; + LOG_DEBUG("address: 0x%" PRIx64 " failed", + address); + } + + return retval; +} + +int target_read_phys_u32(struct target *target, uint32_t address, uint32_t *value) +{ + uint8_t value_buf[4]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + int retval = target_read_phys_memory(target, address, 4, 1, value_buf); + + if (retval == ERROR_OK) { + *value = target_buffer_get_u32(target, value_buf); + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8" PRIx32 "", + address, + *value); + } else { + *value = 0x0; + LOG_DEBUG("address: 0x%8.8" PRIx32 " failed", + address); + } + + return retval; +} + +int target_read_phys_u16(struct target *target, uint32_t address, uint16_t *value) +{ + uint8_t value_buf[2]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + int retval = target_read_phys_memory(target, address, 2, 1, value_buf); + + if (retval == ERROR_OK) { + *value = target_buffer_get_u16(target, value_buf); + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%4.4x", + address, + *value); + } else { + *value = 0x0; + LOG_DEBUG("address: 0x%8.8" PRIx32 " failed", + address); + } + + return retval; +} + +int target_read_phys_u8(struct target *target, uint32_t address, uint8_t *value) +{ + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + int retval = target_read_phys_memory(target, address, 1, 1, value); + + if (retval == ERROR_OK) { + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%2.2x", + address, + *value); + } else { + *value = 0x0; + LOG_DEBUG("address: 0x%8.8" PRIx32 " failed", + address); + } + + return retval; +} + +int target_write_phys_u64(struct target *target, uint64_t address, uint64_t value) +{ + int retval; + uint8_t value_buf[8]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + LOG_DEBUG("address: 0x%" PRIx64 ", value: 0x%16.16" PRIx64 "", + address, + value); + + target_buffer_set_u64(target, value_buf, value); + retval = target_write_phys_memory(target, address, 8, 1, value_buf); + if (retval != ERROR_OK) + LOG_DEBUG("failed: %i", retval); + + 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; +} + +int target_write_phys_u16(struct target *target, uint32_t address, uint16_t value) +{ + int retval; + uint8_t value_buf[2]; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%8.8x", + address, + value); + + target_buffer_set_u16(target, value_buf, value); + retval = target_write_phys_memory(target, address, 2, 1, value_buf); + if (retval != ERROR_OK) + LOG_DEBUG("failed: %i", retval); + + return retval; +} + +int target_write_phys_u8(struct target *target, uint32_t address, uint8_t value) +{ + int retval; + if (!target_was_examined(target)) { + LOG_ERROR("Target not examined yet"); + return ERROR_FAIL; + } + + LOG_DEBUG("address: 0x%8.8" PRIx32 ", value: 0x%2.2x", + address, value); + + retval = target_write_phys_memory(target, address, 1, 1, &value); + if (retval != ERROR_OK) + LOG_DEBUG("failed: %i", retval); + + return retval; +} + int target_read_u64(struct target *target, uint64_t address, uint64_t *value) { uint8_t value_buf[8]; -- ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel