unsigned additional, struct working_area **area)
{
uint8_t code_buf[code_size];
- unsigned i;
int retval;
unsigned size = code_size + additional;
}
/* buffer code in target endianness */
- for (i = 0; i < code_size / 4; i++)
- target_buffer_set_u32(target, code_buf + i * 4, code[i]);
+ target_buffer_set_u32_array(target, code_buf, code_size / 4, code);
/* copy code to work area */
retval = target_write_memory(target, (*area)->address,
}
}
-/* 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;
"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,
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,
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,
{
int retval;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
- int i;
if (address % 4 != 0)
return ERROR_TARGET_UNALIGNED_ACCESS;
}
/* copy target instructions to target endianness */
- for (i = 0; i < 6; i++)
- target_buffer_set_u32(target, dcc_code_buf + i*4, dcc_code[i]);
+ target_buffer_set_u32_array(target, dcc_code_buf, ARRAY_SIZE(dcc_code), dcc_code);
/* write DCC code to working area, using the non-optimized
* memory write to avoid ending up here again */
}
/* copy target instructions to target endianness */
- for (i = 0; i < dcc_size/4; i++)
- target_buffer_set_u32(target, dcc_code_buf + i*4, dcc_code[i]);
+ target_buffer_set_u32_array(target, dcc_code_buf, ARRAY_SIZE(dcc_code), dcc_code);
/* write DCC code to working area, using the non-optimized
* memory write to avoid ending up here again */