breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
- retval = target->type->write_memory(target,
+ retval = target_write_memory(target,
breakpoint->address & 0xFFFFFFFE,
breakpoint->length, 1, code);
if (retval != ERROR_OK)
} else {
/* restore original instruction (kept in target endianness) */
if (breakpoint->length == 4) {
- retval = target->type->write_memory(target,
+ retval = target_write_memory(target,
breakpoint->address & 0xFFFFFFFE,
4, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return retval;
} else {
- retval = target->type->write_memory(target,
+ retval = target_write_memory(target,
breakpoint->address & 0xFFFFFFFE,
2, 1, breakpoint->orig_instr);
if (retval != ERROR_OK)
return target->type->name;
}
-static int target_write_memory_imp(struct target *target, uint32_t address,
- uint32_t size, uint32_t count, const uint8_t *buffer)
-{
- if (!target_was_examined(target)) {
- LOG_ERROR("Target not examined yet");
- return ERROR_FAIL;
- }
- return target->type->write_memory_imp(target, address, size, count, buffer);
-}
-
static int target_read_memory_imp(struct target *target, uint32_t address,
uint32_t size, uint32_t count, uint8_t *buffer)
{
int target_write_memory(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
+ if (!target_was_examined(target)) {
+ LOG_ERROR("Target not examined yet");
+ return ERROR_FAIL;
+ }
return target->type->write_memory(target, address, size, count, buffer);
}
static int target_write_phys_memory(struct target *target,
uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
{
+ if (!target_was_examined(target)) {
+ LOG_ERROR("Target not examined yet");
+ return ERROR_FAIL;
+ }
return target->type->write_phys_memory(target, address, size, count, buffer);
}
/* a non-invasive way(in terms of patches) to add some code that
* runs before the type->write/read_memory implementation
*/
- type->write_memory_imp = target->type->write_memory;
- type->write_memory = target_write_memory_imp;
-
type->read_memory_imp = target->type->read_memory;
type->read_memory = target_read_memory_imp;
*/
int (*read_memory)(struct target *target, uint32_t address,
uint32_t size, uint32_t count, uint8_t *buffer);
- int (*write_memory_imp)(struct target *target, uint32_t address,
- uint32_t size, uint32_t count, const uint8_t *buffer);
/**
* Target memory write callback. Do @b not call this function
* directly, use target_write_memory() instead.