}
}
-/* Convert code image to target endian
- * FIXME create general block conversion fcts in target.c?) */
-static void cfi_fix_code_endian(struct target *target, uint8_t *dest,
- const uint32_t *src, uint32_t count)
-{
- uint32_t i;
- for (i = 0; i < count; i++) {
- target_buffer_set_u32(target, dest, *src);
- dest += 4;
- src++;
- }
-}
-
static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
{
struct target *target = bank->target;
}
}
-static int cfi_intel_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_intel_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct target *target = bank->target;
arm_algo.core_state = ARM_STATE_ARM;
} else {
LOG_ERROR("Unknown architecture");
- return ERROR_FAIL;
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
cfi_intel_clear_status_register(bank);
"Increase CFI_MAX_INTEL_CODESIZE and recompile.");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
- cfi_fix_code_endian(target, target_code, target_code_src, target_code_size / 4);
+
+ target_buffer_set_u32_array(target, target_code, target_code_size / 4, target_code_src);
/* Get memory for block write handler */
retval = target_alloc_working_area(target,
return retval;
}
-static int cfi_spansion_write_block_mips(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
- cfi_fix_code_endian(target, target_code, target_code_src, target_code_size / 4);
+
+ target_buffer_set_u32_array(target, target_code, target_code_size / 4, target_code_src);
/* allocate working area */
retval = target_alloc_working_area(target, target_code_size,
}
;
- init_reg_param(®_params[0], "a0", 32, PARAM_OUT);
- init_reg_param(®_params[1], "a1", 32, PARAM_OUT);
- init_reg_param(®_params[2], "a2", 32, PARAM_OUT);
- init_reg_param(®_params[3], "a3", 32, PARAM_OUT);
- init_reg_param(®_params[4], "t0", 32, PARAM_OUT);
- init_reg_param(®_params[5], "t1", 32, PARAM_IN);
- init_reg_param(®_params[6], "t4", 32, PARAM_OUT);
- init_reg_param(®_params[7], "t5", 32, PARAM_OUT);
- init_reg_param(®_params[8], "t6", 32, PARAM_OUT);
- init_reg_param(®_params[9], "t7", 32, PARAM_OUT);
+ init_reg_param(®_params[0], "r4", 32, PARAM_OUT);
+ init_reg_param(®_params[1], "r5", 32, PARAM_OUT);
+ init_reg_param(®_params[2], "r6", 32, PARAM_OUT);
+ init_reg_param(®_params[3], "r7", 32, PARAM_OUT);
+ init_reg_param(®_params[4], "r8", 32, PARAM_OUT);
+ init_reg_param(®_params[5], "r9", 32, PARAM_IN);
+ init_reg_param(®_params[6], "r12", 32, PARAM_OUT);
+ init_reg_param(®_params[7], "r13", 32, PARAM_OUT);
+ init_reg_param(®_params[8], "r14", 32, PARAM_OUT);
+ init_reg_param(®_params[9], "r15", 32, PARAM_OUT);
while (count > 0) {
uint32_t thisrun_count = (count > buffer_size) ? buffer_size : count;
return retval;
}
-static int cfi_spansion_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buffer,
uint32_t address, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
arm_algo = &armv4_5_algo;
} else {
LOG_ERROR("Unknown architecture");
- return ERROR_FAIL;
+ return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
}
int target_code_size = 0;
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
- cfi_fix_code_endian(target, target_code, target_code_src, target_code_size / 4);
+
+ target_buffer_set_u32_array(target, target_code, target_code_size / 4, target_code_src);
/* allocate working area */
retval = target_alloc_working_area(target, target_code_size,
return ERROR_OK;
}
-static int cfi_intel_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
int retval;
return ERROR_OK;
}
-static int cfi_spansion_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
int retval;
return ERROR_FLASH_OPERATION_FAILED;
}
-static int cfi_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_write_words(struct flash_bank *bank, const uint8_t *word,
uint32_t wordcount, uint32_t address)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
}
if (count) {
- LOG_INFO("Fixup %d unaligned read tail bytes", count);
+ 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);
return ERROR_OK;
}
-static int cfi_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
struct target *target = bank->target;
static void cfi_fixup_0002_polling_bits(struct flash_bank *bank, const void *param)
{
struct cfi_flash_bank *cfi_info = bank->driver_priv;
- const int status_poll_mask = *(const int *)param;
+ const int *status_poll_mask = param;
- cfi_info->status_poll_mask = status_poll_mask;
+ cfi_info->status_poll_mask = *status_poll_mask;
}