This is an automated email from Gerrit. David Ung ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2499
-- gerrit commit ba28a4e5cd86a22c0398cc9cf3317f915512719c Author: David Ung <[email protected]> Date: Fri Jan 16 17:39:13 2015 -0800 target: Allow target 64bit addressing reads Modify various function to allow 64bit addressing reads to memory. Change-Id: I944786ec7eabac4605fad682739bbb25c30d9ba2 Signed-off-by: David Ung <[email protected]> diff --git a/src/target/target.c b/src/target/target.c index af5c5b9..2c49e29 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -62,6 +62,8 @@ static int target_read_buffer_default(struct target *target, uint32_t address, uint32_t count, uint8_t *buffer); +static int target_read_buffer_default_64(struct target *target, uint64_t address, + uint32_t count, uint8_t *buffer); static int target_write_buffer_default(struct target *target, uint32_t address, uint32_t count, const uint8_t *buffer); static int target_array2mem(Jim_Interp *interp, struct target *target, @@ -991,17 +993,22 @@ int target_run_flash_async_algorithm(struct target *target, } int target_read_memory(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer) + uint64_t address, uint32_t size, uint32_t count, uint8_t *buffer) { + int i; if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; } - return target->type->read_memory(target, address, size, count, buffer); + if (target->reg_cache->reg_list[0].size == 64) + i = target->type->read_memory_64(target, address, size, count, buffer); + else + i = target->type->read_memory(target, address, size, count, buffer); + return i; } int target_read_phys_memory(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer) + uint64_t address, uint32_t size, uint32_t count, uint8_t *buffer) { if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); @@ -1219,6 +1226,9 @@ static int target_init_one(struct command_context *cmd_ctx, if (target->type->read_buffer == NULL) target->type->read_buffer = target_read_buffer_default; + if (target->type->read_buffer_64 == NULL) + target->type->read_buffer_64 = target_read_buffer_default_64; + if (target->type->write_buffer == NULL) target->type->write_buffer = target_write_buffer_default; @@ -1914,7 +1924,7 @@ static int target_write_buffer_default(struct target *target, uint32_t address, * mode respectively, otherwise data is handled as quickly as * possible */ -int target_read_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer) +int target_read_buffer(struct target *target, uint64_t address, uint32_t size, uint8_t *buffer) { LOG_DEBUG("reading buffer of %i byte at 0x%8.8x", (int)size, (unsigned)address); @@ -1930,12 +1940,15 @@ int target_read_buffer(struct target *target, uint32_t address, uint32_t size, u if ((address + size - 1) < address) { /* GDB can request this when e.g. PC is 0xfffffffc*/ LOG_ERROR("address + size wrapped(0x%08" PRIx32 ", 0x%08" PRIx32 ")", - address, + (unsigned)address, size); return ERROR_FAIL; } - return target->type->read_buffer(target, address, size, buffer); + if (target->reg_cache->reg_list[0].size == 64) + return target->type->read_buffer_64(target, address, size, buffer); + else + return target->type->read_buffer(target, address, size, buffer); } static int target_read_buffer_default(struct target *target, uint32_t address, uint32_t count, uint8_t *buffer) @@ -1971,6 +1984,39 @@ static int target_read_buffer_default(struct target *target, uint32_t address, u return ERROR_OK; } +static int target_read_buffer_default_64(struct target *target, uint64_t address, uint32_t count, uint8_t *buffer) +{ + uint32_t size; + + /* Align up to maximum 4 bytes. The loop condition makes sure the next pass + * will have something to do with the size we leave to it. */ + for (size = 1; size < 8 && count >= size * 2 + (address & size); size *= 2) { + if (address & size) { + int retval = target_read_memory(target, address, size, 1, buffer); + if (retval != ERROR_OK) + return retval; + address += size; + count -= size; + buffer += size; + } + } + + /* Read the data with as large access size as possible. */ + for (; size > 0; size /= 2) { + uint32_t aligned = count - count % size; + if (aligned > 0) { + int retval = target_read_memory(target, address, size, aligned / size, buffer); + if (retval != ERROR_OK) + return retval; + address += aligned; + count -= aligned; + buffer += aligned; + } + } + + return ERROR_OK; +} + int target_checksum_memory(struct target *target, uint32_t address, uint32_t size, uint32_t* crc) { uint8_t *buffer; @@ -2818,7 +2864,7 @@ COMMAND_HANDLER(handle_md_command) bool physical = strcmp(CMD_ARGV[0], "phys") == 0; int (*fn)(struct target *target, - uint32_t address, uint32_t size_value, uint32_t count, uint8_t *buffer); + uint64_t address, uint32_t size_value, uint32_t count, uint8_t *buffer); if (physical) { CMD_ARGC--; CMD_ARGV++; @@ -4554,7 +4600,7 @@ static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } int (*fn)(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); + uint64_t address, uint32_t size, uint32_t count, uint8_t *buffer); fn = target_read_memory; int e; diff --git a/src/target/target.h b/src/target/target.h index 0552b8f..f17c3d7 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -487,9 +487,9 @@ int target_run_flash_async_algorithm(struct target *target, * This routine is a wrapper for target->type->read_memory. */ int target_read_memory(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); + uint64_t address, uint32_t size, uint32_t count, uint8_t *buffer); int target_read_phys_memory(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); + uint64_t address, uint32_t size, uint32_t count, uint8_t *buffer); /** * Write @a count items of @a size bytes to the memory of @a target at * the @a address given. @a address must be aligned to @a size @@ -539,7 +539,7 @@ int target_write_phys_memory(struct target *target, int target_write_buffer(struct target *target, uint32_t address, uint32_t size, const uint8_t *buffer); int target_read_buffer(struct target *target, - uint32_t address, uint32_t size, uint8_t *buffer); + uint64_t address, uint32_t size, uint8_t *buffer); int target_checksum_memory(struct target *target, uint32_t address, uint32_t size, uint32_t *crc); int target_blank_check_memory(struct target *target, diff --git a/src/target/target_type.h b/src/target/target_type.h index cf3c864..8963cc4 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -115,6 +115,9 @@ struct target_type { */ int (*read_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); + + int (*read_memory_64)(struct target *target, uint64_t address, + uint32_t size, uint32_t count, uint8_t *buffer); /** * Target memory write callback. Do @b not call this function * directly, use target_write_memory() instead. @@ -126,6 +129,9 @@ struct target_type { int (*read_buffer)(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer); + int (*read_buffer_64)(struct target *target, uint64_t address, + uint32_t size, uint8_t *buffer); + /* Default implementation will do some fancy alignment to improve performance, target can override */ int (*write_buffer)(struct target *target, uint32_t address, uint32_t size, const uint8_t *buffer); @@ -241,6 +247,8 @@ struct target_type { int (*read_phys_memory)(struct target *target, uint32_t phys_address, uint32_t size, uint32_t count, uint8_t *buffer); + int (*read_phys_memory_64)(struct target *target, uint64_t phys_address, + uint32_t size, uint32_t count, uint8_t *buffer); /* * same as read_phys_memory, except that it writes... */ -- ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
