#include "image.h"
+static int target_read_buffer_default(struct target *target, uint32_t address,
+ uint32_t size, uint8_t *buffer);
+static int target_write_buffer_default(struct target *target, uint32_t address,
+ uint32_t size, uint8_t *buffer);
static int target_array2mem(Jim_Interp *interp, struct target *target,
int argc, Jim_Obj *const *argv);
static int target_mem2array(Jim_Interp *interp, struct target *target,
type->read_phys_memory = type->read_memory;
type->virt2phys = identity_virt2phys;
}
+
+ if (target->type->read_buffer == NULL)
+ target->type->read_buffer = target_read_buffer_default;
+
+ if (target->type->write_buffer == NULL)
+ target->type->write_buffer = target_write_buffer_default;
+
return ERROR_OK;
}
*/
int target_write_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
{
- int retval;
LOG_DEBUG("writing buffer of %i byte at 0x%8.8x",
(int)size, (unsigned)address);
return ERROR_FAIL;
}
+ return target->type->write_buffer(target, address, size, buffer);
+}
+
+static int target_write_buffer_default(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
+{
+ int retval = ERROR_OK;
+
if (((address % 2) == 0) && (size == 2))
{
return target_write_memory(target, address, 2, 1, buffer);
return retval;
}
- return ERROR_OK;
+ return retval;
}
/* Single aligned words are guaranteed to use 16 or 32 bit access
*/
int target_read_buffer(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
{
- int retval;
LOG_DEBUG("reading buffer of %i byte at 0x%8.8x",
(int)size, (unsigned)address);
return ERROR_FAIL;
}
+ return target->type->read_buffer(target, address, size, buffer);
+}
+
+static int target_read_buffer_default(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
+{
+ int retval = ERROR_OK;
+
if (((address % 2) == 0) && (size == 2))
{
return target_read_memory(target, address, 2, 1, buffer);
{ .name = "-variant", .value = TCFG_VARIANT },
{ .name = "-coreid", .value = TCFG_COREID },
{ .name = "-chain-position", .value = TCFG_CHAIN_POSITION },
-
{ .name = NULL, .value = -1 }
};
*/
int (*write_memory)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
+ /* Default implementation will do some fancy alignment to improve performance, target can override */
+ int (*read_buffer)(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer);
+
+ /* Default implementation will do some fancy alignment to improve performance, target can override */
+ int (*write_buffer)(struct target *target, uint32_t address, uint32_t size, uint8_t *buffer);
+
/**
* Write target memory in multiples of 4 bytes, optimized for
* writing large quantities of data. Do @b not call this