flash/nor: use target_addr_t for flash bank base
This should allow users to configure flash at >32-bit addresses. Change-Id: I7c9d3c5762579011a2d9708e5317e5765349845c Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: http://openocd.zylin.com/4919 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
committed by
Matthias Welwarsky
parent
57e30102ea
commit
c3b90c052a
@@ -99,7 +99,8 @@ int flash_driver_write(struct flash_bank *bank,
|
||||
retval = bank->driver->write(bank, buffer, offset, count);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR(
|
||||
"error writing to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32,
|
||||
"error writing to flash at address " TARGET_ADDR_FMT
|
||||
" at offset 0x%8.8" PRIx32,
|
||||
bank->base,
|
||||
offset);
|
||||
}
|
||||
@@ -117,7 +118,8 @@ int flash_driver_read(struct flash_bank *bank,
|
||||
retval = bank->driver->read(bank, buffer, offset, count);
|
||||
if (retval != ERROR_OK) {
|
||||
LOG_ERROR(
|
||||
"error reading to flash at address 0x%08" PRIx32 " at offset 0x%8.8" PRIx32,
|
||||
"error reading to flash at address " TARGET_ADDR_FMT
|
||||
" at offset 0x%8.8" PRIx32,
|
||||
bank->base,
|
||||
offset);
|
||||
}
|
||||
@@ -268,7 +270,7 @@ int get_flash_bank_by_num(int num, struct flash_bank **bank)
|
||||
/* lookup flash bank by address, bank not found is success, but
|
||||
* result_bank is set to NULL. */
|
||||
int get_flash_bank_by_addr(struct target *target,
|
||||
uint32_t addr,
|
||||
target_addr_t addr,
|
||||
bool check,
|
||||
struct flash_bank **result_bank)
|
||||
{
|
||||
@@ -294,7 +296,7 @@ int get_flash_bank_by_addr(struct target *target,
|
||||
}
|
||||
*result_bank = NULL;
|
||||
if (check) {
|
||||
LOG_ERROR("No flash at address 0x%08" PRIx32, addr);
|
||||
LOG_ERROR("No flash at address " TARGET_ADDR_FMT, addr);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
return ERROR_OK;
|
||||
@@ -414,13 +416,13 @@ int default_flash_blank_check(struct flash_bank *bank)
|
||||
* warning about those additions.
|
||||
*/
|
||||
static int flash_iterate_address_range_inner(struct target *target,
|
||||
char *pad_reason, uint32_t addr, uint32_t length,
|
||||
char *pad_reason, target_addr_t addr, uint32_t length,
|
||||
bool iterate_protect_blocks,
|
||||
int (*callback)(struct flash_bank *bank, int first, int last))
|
||||
{
|
||||
struct flash_bank *c;
|
||||
struct flash_sector *block_array;
|
||||
uint32_t last_addr = addr + length; /* first address AFTER end */
|
||||
target_addr_t last_addr = addr + length; /* first address AFTER end */
|
||||
int first = -1;
|
||||
int last = -1;
|
||||
int i;
|
||||
@@ -491,10 +493,10 @@ static int flash_iterate_address_range_inner(struct target *target,
|
||||
else if (addr < end && pad_reason) {
|
||||
/* FIXME say how many bytes (e.g. 80 KB) */
|
||||
LOG_WARNING("Adding extra %s range, "
|
||||
"%#8.8x to %#8.8x",
|
||||
"%#8.8x to " TARGET_ADDR_FMT,
|
||||
pad_reason,
|
||||
(unsigned) f->offset,
|
||||
(unsigned) addr - 1);
|
||||
addr - 1);
|
||||
first = i;
|
||||
} else
|
||||
continue;
|
||||
@@ -527,10 +529,10 @@ static int flash_iterate_address_range_inner(struct target *target,
|
||||
|
||||
/* invalid start or end address? */
|
||||
if (first == -1 || last == -1) {
|
||||
LOG_ERROR("address range 0x%8.8x .. 0x%8.8x "
|
||||
"is not sector-aligned",
|
||||
(unsigned) (c->base + addr),
|
||||
(unsigned) (c->base + last_addr - 1));
|
||||
LOG_ERROR("address range " TARGET_ADDR_FMT " .. " TARGET_ADDR_FMT
|
||||
" is not sector-aligned",
|
||||
c->base + addr,
|
||||
c->base + last_addr - 1);
|
||||
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
|
||||
}
|
||||
|
||||
@@ -545,7 +547,7 @@ static int flash_iterate_address_range_inner(struct target *target,
|
||||
* multiple chips.
|
||||
*/
|
||||
static int flash_iterate_address_range(struct target *target,
|
||||
char *pad_reason, uint32_t addr, uint32_t length,
|
||||
char *pad_reason, target_addr_t addr, uint32_t length,
|
||||
bool iterate_protect_blocks,
|
||||
int (*callback)(struct flash_bank *bank, int first, int last))
|
||||
{
|
||||
@@ -579,7 +581,7 @@ static int flash_iterate_address_range(struct target *target,
|
||||
}
|
||||
|
||||
int flash_erase_address_range(struct target *target,
|
||||
bool pad, uint32_t addr, uint32_t length)
|
||||
bool pad, target_addr_t addr, uint32_t length)
|
||||
{
|
||||
return flash_iterate_address_range(target, pad ? "erase" : NULL,
|
||||
addr, length, false, &flash_driver_erase);
|
||||
@@ -590,7 +592,8 @@ static int flash_driver_unprotect(struct flash_bank *bank, int first, int last)
|
||||
return flash_driver_protect(bank, 0, first, last);
|
||||
}
|
||||
|
||||
int flash_unlock_address_range(struct target *target, uint32_t addr, uint32_t length)
|
||||
int flash_unlock_address_range(struct target *target, target_addr_t addr,
|
||||
uint32_t length)
|
||||
{
|
||||
/* By default, pad to sector boundaries ... the real issue here
|
||||
* is that our (only) caller *permanently* removes protection,
|
||||
|
||||
Reference in New Issue
Block a user