- /* copy data to target's memory */
- target_buf = hw->copy_area->address + code_size;
- retval = target_bulk_write_memory(target, target_buf, size/4, data);
- if (retval == ERROR_OK && size & 3) {
- retval = target_write_memory(target,
- target_buf + (size & ~3),
- 1, size & 3, data + (size & ~3));
- }
- if (retval != ERROR_OK)
- return retval;
-
- algo.common_magic = ARMV4_5_COMMON_MAGIC;
- algo.core_mode = ARMV4_5_MODE_SVC;
- algo.core_state = ARMV4_5_STATE_ARM;
-
- init_reg_param(®_params[0], "r0", 32, PARAM_IN);
- init_reg_param(®_params[1], "r1", 32, PARAM_IN);
- init_reg_param(®_params[2], "r2", 32, PARAM_IN);
-
- buf_set_u32(reg_params[0].value, 0, 32, hw->data);
- buf_set_u32(reg_params[1].value, 0, 32, target_buf);
- buf_set_u32(reg_params[2].value, 0, 32, size);
-
- retval = target_run_algorithm(target, 0, NULL, 3, reg_params,
- hw->copy_area->address,
- hw->copy_area->address + code_size - 4,
- 1000, &algo);
- if (retval != ERROR_OK)
- LOG_ERROR("error executing hosted NAND write");
-
- destroy_reg_param(®_params[0]);
- destroy_reg_param(®_params[1]);
- destroy_reg_param(®_params[2]);