Add target_read_memory wrapper:

- replaces all calls to target->type->read_memory.
- add documentation in target_s to warn not to invoke callback directly.


git-svn-id: svn://svn.berlios.de/openocd/trunk@1959 b42882b7-edfa-0310-969c-e2dbd0fdcd60
__archive__
zwelch 2009-05-31 09:37:35 +00:00
parent 6785193118
commit b6db182c00
11 changed files with 58 additions and 39 deletions

View File

@ -665,7 +665,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank)
for (nSector=0; nSector<bank->num_sectors; nSector++) for (nSector=0; nSector<bank->num_sectors; nSector++)
{ {
bank->sectors[nSector].is_erased = 1; bank->sectors[nSector].is_erased = 1;
retval = target->type->read_memory(target, bank->base+bank->sectors[nSector].offset, 4, retval = target_read_memory(target, bank->base+bank->sectors[nSector].offset, 4,
bank->sectors[nSector].size/4, buffer); bank->sectors[nSector].size/4, buffer);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;

View File

@ -166,7 +166,7 @@ static u8 cfi_query_u8(flash_bank_t *bank, int sector, u32 offset)
target_t *target = bank->target; target_t *target = bank->target;
u8 data[CFI_MAX_BUS_WIDTH]; u8 data[CFI_MAX_BUS_WIDTH];
target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN) if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
return data[0]; return data[0];
@ -184,7 +184,7 @@ static u8 cfi_get_u8(flash_bank_t *bank, int sector, u32 offset)
u8 data[CFI_MAX_BUS_WIDTH]; u8 data[CFI_MAX_BUS_WIDTH];
int i; int i;
target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN) if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
{ {
@ -213,11 +213,11 @@ static u16 cfi_query_u16(flash_bank_t *bank, int sector, u32 offset)
{ {
u8 i; u8 i;
for(i=0;i<2;i++) for(i=0;i<2;i++)
target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
&data[i*bank->bus_width] ); &data[i*bank->bus_width] );
} }
else else
target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data); target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN) if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
return data[0] | data[bank->bus_width] << 8; return data[0] | data[bank->bus_width] << 8;
@ -235,11 +235,11 @@ static u32 cfi_query_u32(flash_bank_t *bank, int sector, u32 offset)
{ {
u8 i; u8 i;
for(i=0;i<4;i++) for(i=0;i<4;i++)
target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1,
&data[i*bank->bus_width] ); &data[i*bank->bus_width] );
} }
else else
target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data); target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data);
if (bank->target->endianness == TARGET_LITTLE_ENDIAN) if (bank->target->endianness == TARGET_LITTLE_ENDIAN)
return data[0] | data[bank->bus_width] << 8 | data[bank->bus_width * 2] << 16 | data[bank->bus_width * 3] << 24; return data[0] | data[bank->bus_width] << 8 | data[bank->bus_width * 2] << 16 | data[bank->bus_width * 3] << 24;
@ -1889,7 +1889,7 @@ int cfi_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
for (i = 0; i < align; ++i, ++copy_p) for (i = 0; i < align; ++i, ++copy_p)
{ {
u8 byte; u8 byte;
if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -1908,7 +1908,7 @@ int cfi_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
for (; (count == 0) && (i < bank->bus_width); ++i, ++copy_p) for (; (count == 0) && (i < bank->bus_width); ++i, ++copy_p)
{ {
u8 byte; u8 byte;
if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -2039,7 +2039,7 @@ int cfi_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
for (; i < bank->bus_width; ++i, ++copy_p) for (; i < bank->bus_width; ++i, ++copy_p)
{ {
u8 byte; u8 byte;
if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{ {
return retval; return retval;
} }

View File

@ -1157,7 +1157,7 @@ int default_flash_mem_blank_check(struct flash_bank_s *bank)
chunk = (j - bank->sectors[i].size); chunk = (j - bank->sectors[i].size);
} }
retval = target->type->read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer); retval = target_read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;

View File

@ -759,12 +759,12 @@ static int lpc3180_read_page(struct nand_device_s *device, u32 page, u8 *data, u
if (data) if (data)
{ {
target->type->read_memory(target, 0x200a8000, 4, 128, page_buffer + page_bytes_done); target_read_memory(target, 0x200a8000, 4, 128, page_buffer + page_bytes_done);
} }
if (oob) if (oob)
{ {
target->type->read_memory(target, 0x200a8000, 4, 4, oob_buffer + oob_bytes_done); target_read_memory(target, 0x200a8000, 4, 4, oob_buffer + oob_bytes_done);
} }
page_bytes_done += 512; page_bytes_done += 512;

View File

@ -345,7 +345,7 @@ static int mg_dsk_drv_info(void)
if (! mflash_bank->drv_info) if (! mflash_bank->drv_info)
mflash_bank->drv_info = malloc(sizeof(mg_drv_info_t)); mflash_bank->drv_info = malloc(sizeof(mg_drv_info_t));
target->type->read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1, target_read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1,
(u8 *)&mflash_bank->drv_info->drv_id); (u8 *)&mflash_bank->drv_info->drv_id);
mflash_bank->drv_info->tot_sects = (u32)(mflash_bank->drv_info->drv_id.total_user_addressable_sectors_hi << 16) mflash_bank->drv_info->tot_sects = (u32)(mflash_bank->drv_info->drv_id.total_user_addressable_sectors_hi << 16)
@ -428,7 +428,7 @@ static int mg_mflash_do_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
for (i = 0; i < sect_cnt; i++) { for (i = 0; i < sect_cnt; i++) {
mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL); mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL);
target->type->read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr);
buff_ptr += MG_MFLASH_SECTOR_SIZE; buff_ptr += MG_MFLASH_SECTOR_SIZE;
target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read);
@ -932,7 +932,7 @@ static int mg_verify_interface(void)
memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE); memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE);
target->type->read_memory(target, address, 2, target_read_memory(target, address, 2,
MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff); MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff);
for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) { for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) {

View File

@ -274,7 +274,7 @@ int arm7_9_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u32 verify = 0xffffffff; u32 verify = 0xffffffff;
/* keep the original instruction in target endianness */ /* keep the original instruction in target endianness */
if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -298,7 +298,7 @@ int arm7_9_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u16 verify = 0xffff; u16 verify = 0xffff;
/* keep the original instruction in target endianness */ /* keep the original instruction in target endianness */
if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -373,7 +373,7 @@ int arm7_9_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u32 current_instr; u32 current_instr;
/* check that user program as not modified breakpoint instruction */ /* check that user program as not modified breakpoint instruction */
if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, (u8*)&current_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 4, 1, (u8*)&current_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -387,7 +387,7 @@ int arm7_9_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u16 current_instr; u16 current_instr;
/* check that user program as not modified breakpoint instruction */ /* check that user program as not modified breakpoint instruction */
if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, (u8*)&current_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 2, 1, (u8*)&current_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }

View File

@ -930,7 +930,7 @@ int cortex_m3_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u8 code[4]; u8 code[4];
buf_set_u32(code, 0, 32, ARMV7M_T_BKPT(0x11)); buf_set_u32(code, 0, 32, ARMV7M_T_BKPT(0x11));
if((retval = target->type->read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) if((retval = target_read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }

View File

@ -529,7 +529,7 @@ int mips_m4k_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u32 verify = 0xffffffff; u32 verify = 0xffffffff;
if((retval = target->type->read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -552,7 +552,7 @@ int mips_m4k_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
{ {
u16 verify = 0xffff; u16 verify = 0xffff;
if((retval = target->type->read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -611,7 +611,7 @@ int mips_m4k_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
u32 current_instr; u32 current_instr;
/* check that user program has not modified breakpoint instruction */ /* check that user program has not modified breakpoint instruction */
if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, (u8*)&current_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 4, 1, (u8*)&current_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -628,7 +628,7 @@ int mips_m4k_unset_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
u16 current_instr; u16 current_instr;
/* check that user program has not modified breakpoint instruction */ /* check that user program has not modified breakpoint instruction */
if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, (u8*)&current_instr)) != ERROR_OK) if ((retval = target_read_memory(target, breakpoint->address, 2, 1, (u8*)&current_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }

View File

@ -525,6 +525,12 @@ static int target_run_algorithm_imp(struct target_s *target, int num_mem_params,
return target->type->run_algorithm_imp(target, num_mem_params, mem_params, num_reg_params, reg_param, entry_point, exit_point, timeout_ms, arch_info); return target->type->run_algorithm_imp(target, num_mem_params, mem_params, num_reg_params, reg_param, entry_point, exit_point, timeout_ms, arch_info);
} }
int target_read_memory(struct target_s *target,
u32 address, u32 size, u32 count, u8 *buffer)
{
return target->type->read_memory(target, address, size, count, buffer);
}
int target_init(struct command_context_s *cmd_ctx) int target_init(struct command_context_s *cmd_ctx)
{ {
target_t *target = all_targets; target_t *target = all_targets;
@ -858,7 +864,7 @@ int target_alloc_working_area(struct target_s *target, u32 size, working_area_t
{ {
int retval; int retval;
new_wa->backup = malloc(new_wa->size); new_wa->backup = malloc(new_wa->size);
if((retval = target->type->read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK) if((retval = target_read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK)
{ {
free(new_wa->backup); free(new_wa->backup);
free(new_wa); free(new_wa);
@ -1077,7 +1083,7 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe
if (((address % 2) == 0) && (size == 2)) if (((address % 2) == 0) && (size == 2))
{ {
return target->type->read_memory(target, address, 2, 1, buffer); return target_read_memory(target, address, 2, 1, buffer);
} }
/* handle unaligned head bytes */ /* handle unaligned head bytes */
@ -1088,7 +1094,7 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe
if (unaligned > size) if (unaligned > size)
unaligned = size; unaligned = size;
if ((retval = target->type->read_memory(target, address, 1, unaligned, buffer)) != ERROR_OK) if ((retval = target_read_memory(target, address, 1, unaligned, buffer)) != ERROR_OK)
return retval; return retval;
buffer += unaligned; buffer += unaligned;
@ -1101,7 +1107,7 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe
{ {
int aligned = size - (size % 4); int aligned = size - (size % 4);
if ((retval = target->type->read_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK) if ((retval = target_read_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK)
return retval; return retval;
buffer += aligned; buffer += aligned;
@ -1112,7 +1118,7 @@ int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffe
/* handle tail writes of less than 4 bytes */ /* handle tail writes of less than 4 bytes */
if (size > 0) if (size > 0)
{ {
if ((retval = target->type->read_memory(target, address, 1, size, buffer)) != ERROR_OK) if ((retval = target_read_memory(target, address, 1, size, buffer)) != ERROR_OK)
return retval; return retval;
} }
@ -1190,7 +1196,7 @@ int target_read_u32(struct target_s *target, u32 address, u32 *value)
return ERROR_FAIL; return ERROR_FAIL;
} }
int retval = target->type->read_memory(target, address, 4, 1, value_buf); int retval = target_read_memory(target, address, 4, 1, value_buf);
if (retval == ERROR_OK) if (retval == ERROR_OK)
{ {
@ -1215,7 +1221,7 @@ int target_read_u16(struct target_s *target, u32 address, u16 *value)
return ERROR_FAIL; return ERROR_FAIL;
} }
int retval = target->type->read_memory(target, address, 2, 1, value_buf); int retval = target_read_memory(target, address, 2, 1, value_buf);
if (retval == ERROR_OK) if (retval == ERROR_OK)
{ {
@ -1233,7 +1239,7 @@ int target_read_u16(struct target_s *target, u32 address, u16 *value)
int target_read_u8(struct target_s *target, u32 address, u8 *value) int target_read_u8(struct target_s *target, u32 address, u8 *value)
{ {
int retval = target->type->read_memory(target, address, 1, 1, value); int retval = target_read_memory(target, address, 1, 1, value);
if (!target->type->examined) if (!target->type->examined)
{ {
LOG_ERROR("Target not examined yet"); LOG_ERROR("Target not examined yet");
@ -1914,7 +1920,7 @@ static int handle_md_command(struct command_context_s *cmd_ctx, char *cmd, char
u8 *buffer = calloc(count, size); u8 *buffer = calloc(count, size);
target_t *target = get_current_target(cmd_ctx); target_t *target = get_current_target(cmd_ctx);
int retval = target->type->read_memory(target, int retval = target_read_memory(target,
address, size, count, buffer); address, size, count, buffer);
if (ERROR_OK == retval) if (ERROR_OK == retval)
handle_md_output(cmd_ctx, target, address, size, count, buffer); handle_md_output(cmd_ctx, target, address, size, count, buffer);
@ -2256,7 +2262,7 @@ static int handle_verify_image_command_internal(struct command_context_s *cmd_ct
size *= 4; size *= 4;
count /= 4; count /= 4;
} }
retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data); retval = target_read_memory(target, image.sections[i].base_address, size, count, data);
if (retval == ERROR_OK) if (retval == ERROR_OK)
{ {
u32 t; u32 t;
@ -2829,7 +2835,7 @@ static int target_mem2array(Jim_Interp *interp, target_t *target, int argc, Jim_
count = (sizeof(buffer)/width); count = (sizeof(buffer)/width);
} }
retval = target->type->read_memory( target, addr, width, count, buffer ); retval = target_read_memory( target, addr, width, count, buffer );
if (retval != ERROR_OK) { if (retval != ERROR_OK) {
/* BOO !*/ /* BOO !*/
LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count); LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count);
@ -3575,7 +3581,7 @@ static int tcl_target_func( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
if( y > 16 ){ if( y > 16 ){
y = 16; y = 16;
} }
e = target->type->read_memory( target, a, b, y / b, target_buf ); e = target_read_memory( target, a, b, y / b, target_buf );
if( e != ERROR_OK ){ if( e != ERROR_OK ){
Jim_SetResult_sprintf( interp, "error reading target @ 0x%08lx", (int)(a) ); Jim_SetResult_sprintf( interp, "error reading target @ 0x%08lx", (int)(a) );
return JIM_ERR; return JIM_ERR;

View File

@ -161,6 +161,10 @@ typedef struct target_type_s
* count: number of items of <size> * count: number of items of <size>
*/ */
int (*read_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*read_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
/**
* Target memory read callback. Do @b not call this function
* directly, use target_read_memory() instead.
*/
int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer);
@ -371,6 +375,15 @@ extern target_t* get_current_target(struct command_context_s *cmd_ctx);
extern int get_num_by_target(target_t *query_target); extern int get_num_by_target(target_t *query_target);
extern target_t *get_target(const char *id); extern target_t *get_target(const char *id);
/**
* Read @count items of @a size bytes from the memory of @a target at
* the @a address given.
*
* This routine is a wrapper for target->type->read_memory.
*/
extern int target_read_memory(struct target_s *target,
u32 address, u32 size, u32 count, u8 *buffer);
extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer);
extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer);
extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc); extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc);

View File

@ -2187,7 +2187,7 @@ int xscale_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
if (breakpoint->length == 4) if (breakpoint->length == 4)
{ {
/* keep the original instruction in target endianness */ /* keep the original instruction in target endianness */
if((retval = target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) if((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }
@ -2200,7 +2200,7 @@ int xscale_set_breakpoint(struct target_s *target, breakpoint_t *breakpoint)
else else
{ {
/* keep the original instruction in target endianness */ /* keep the original instruction in target endianness */
if((retval = target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) if((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{ {
return retval; return retval;
} }