}
}
+static int cfi_target_write_memory(struct target *target, target_addr_t addr,
+ uint32_t size, uint32_t count,
+ const uint8_t *buffer)
+{
+ return target_write_memory(target, addr, size, count, buffer);
+}
+
+static int cfi_target_read_memory(struct target *target, target_addr_t addr,
+ uint32_t size, uint32_t count,
+ uint8_t *buffer)
+{
+ return target_read_memory(target, addr, size, count, buffer);
+}
+
static void cfi_command(struct flash_bank *bank, uint8_t cmd, uint8_t *cmd_buf)
{
int i;
uint8_t command[CFI_MAX_BUS_WIDTH];
cfi_command(bank, cmd, command);
- return target_write_memory(bank->target, address, bank->bus_width, 1, command);
+ return cfi_target_write_memory(bank->target, address, bank->bus_width, 1, command);
}
/* read unsigned 8-bit value from the bank
uint8_t data[CFI_MAX_BUS_WIDTH];
int retval;
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
int i;
int retval;
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 1, data);
if (retval != ERROR_OK)
return retval;
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 2; i++) {
- retval = target_read_memory(target, flash_address(bank, sector, offset + i),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset + i),
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 2, data);
if (retval != ERROR_OK)
return retval;
if (cfi_info->x16_as_x8) {
uint8_t i;
for (i = 0; i < 4; i++) {
- retval = target_read_memory(target, flash_address(bank, sector, offset + i),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset + i),
bank->bus_width, 1, &data[i * bank->bus_width]);
if (retval != ERROR_OK)
return retval;
}
} else {
- retval = target_read_memory(target, flash_address(bank, sector, offset),
+ retval = cfi_target_read_memory(target, flash_address(bank, sector, offset),
bank->bus_width, 4, data);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, 1, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, 1, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, bufferwsize, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, 1, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, 1, word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word);
+ retval = cfi_target_write_memory(target, address, bank->bus_width, bufferwsize, word);
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %d unaligned read head bytes", align);
/* read a complete word from flash */
- retval = target_read_memory(target, read_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
align = count / bank->bus_width;
if (align) {
- retval = target_read_memory(target, read_p, bank->bus_width, align, buffer);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, align, buffer);
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %" PRIu32 " unaligned read tail bytes", count);
/* read a complete word from flash */
- retval = target_read_memory(target, read_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, read_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %d unaligned head bytes", align);
/* read a complete word from flash */
- retval = target_read_memory(target, write_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, write_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
LOG_INFO("Fixup %" PRId32 " unaligned tail bytes", count);
/* read a complete word from flash */
- retval = target_read_memory(target, write_p, bank->bus_width, 1, current_word);
+ retval = cfi_target_read_memory(target, write_p, bank->bus_width, 1, current_word);
if (retval != ERROR_OK)
return retval;
if (retval != ERROR_OK)
return retval;
- retval = target_read_memory(target, flash_address(bank, 0, 0x00),
+ retval = cfi_target_read_memory(target, flash_address(bank, 0, 0x00),
bank->bus_width, 1, value_buf0);
if (retval != ERROR_OK)
return retval;
- retval = target_read_memory(target, flash_address(bank, 0, 0x01),
+ retval = cfi_target_read_memory(target, flash_address(bank, 0, 0x01),
bank->bus_width, 1, value_buf1);
if (retval != ERROR_OK)
return retval;