target: Remove target_check_error from external interface.

This commit is contained in:
Gareth McMullin 2016-07-11 10:53:54 +12:00
parent 97f3fc6155
commit 9a45d89b4a
4 changed files with 16 additions and 17 deletions

View File

@ -117,8 +117,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
sscanf(pbuf, "m%" SCNx32 ",%" SCNx32, &addr, &len); sscanf(pbuf, "m%" SCNx32 ",%" SCNx32, &addr, &len);
DEBUG("m packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len); DEBUG("m packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
uint8_t mem[len]; uint8_t mem[len];
target_mem_read(cur_target, mem, addr, len); if (target_mem_read(cur_target, mem, addr, len))
if(target_check_error(cur_target))
gdb_putpacketz("E01"); gdb_putpacketz("E01");
else else
gdb_putpacket(hexify(pbuf, mem, len), len*2); gdb_putpacket(hexify(pbuf, mem, len), len*2);
@ -140,8 +139,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
DEBUG("M packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len); DEBUG("M packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
uint8_t mem[len]; uint8_t mem[len];
unhexify(mem, pbuf + hex, len); unhexify(mem, pbuf + hex, len);
target_mem_write(cur_target, addr, mem, len); if (target_mem_write(cur_target, addr, mem, len))
if(target_check_error(cur_target))
gdb_putpacketz("E01"); gdb_putpacketz("E01");
else else
gdb_putpacketz("OK"); gdb_putpacketz("OK");
@ -253,8 +251,7 @@ int gdb_main_loop(struct target_controller *tc, bool in_syscall)
ERROR_IF_NO_TARGET(); ERROR_IF_NO_TARGET();
sscanf(pbuf, "X%" SCNx32 ",%" SCNx32 ":%n", &addr, &len, &bin); sscanf(pbuf, "X%" SCNx32 ",%" SCNx32 ":%n", &addr, &len, &bin);
DEBUG("X packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len); DEBUG("X packet: addr = %" PRIx32 ", len = %" PRIx32 "\n", addr, len);
target_mem_write(cur_target, addr, pbuf+bin, len); if (target_mem_write(cur_target, addr, pbuf+bin, len))
if(target_check_error(cur_target))
gdb_putpacketz("E01"); gdb_putpacketz("E01");
else else
gdb_putpacketz("OK"); gdb_putpacketz("OK");

View File

@ -41,14 +41,13 @@ void target_list_free(void);
target *target_attach(target *t, struct target_controller *); target *target_attach(target *t, struct target_controller *);
target *target_attach_n(int n, struct target_controller *); target *target_attach_n(int n, struct target_controller *);
void target_detach(target *t); void target_detach(target *t);
bool target_check_error(target *t);
bool target_attached(target *t); bool target_attached(target *t);
const char *target_driver_name(target *t); const char *target_driver_name(target *t);
/* Memory access functions */ /* Memory access functions */
const char *target_mem_map(target *t); const char *target_mem_map(target *t);
void target_mem_read(target *t, void *dest, target_addr src, size_t len); int target_mem_read(target *t, void *dest, target_addr src, size_t len);
void target_mem_write(target *t, target_addr dest, const void *src, size_t len); int target_mem_write(target *t, target_addr dest, const void *src, size_t len);
/* Flash memory access functions */ /* Flash memory access functions */
int target_flash_erase(target *t, target_addr addr, size_t len); int target_flash_erase(target *t, target_addr addr, size_t len);
int target_flash_write(target *t, target_addr dest, const void *src, size_t len); int target_flash_write(target *t, target_addr dest, const void *src, size_t len);

View File

@ -293,14 +293,16 @@ bool target_check_error(target *t) { return t->check_error(t); }
bool target_attached(target *t) { return t->attached; } bool target_attached(target *t) { return t->attached; }
/* Memory access functions */ /* Memory access functions */
void target_mem_read(target *t, void *dest, target_addr src, size_t len) int target_mem_read(target *t, void *dest, target_addr src, size_t len)
{ {
t->mem_read(t, dest, src, len); t->mem_read(t, dest, src, len);
return target_check_error(t);
} }
void target_mem_write(target *t, target_addr dest, const void *src, size_t len) int target_mem_write(target *t, target_addr dest, const void *src, size_t len)
{ {
t->mem_write(t, dest, src, len); t->mem_write(t, dest, src, len);
return target_check_error(t);
} }
/* Register access functions */ /* Register access functions */
@ -389,37 +391,37 @@ const char *target_driver_name(target *t)
uint32_t target_mem_read32(target *t, uint32_t addr) uint32_t target_mem_read32(target *t, uint32_t addr)
{ {
uint32_t ret; uint32_t ret;
target_mem_read(t, &ret, addr, sizeof(ret)); t->mem_read(t, &ret, addr, sizeof(ret));
return ret; return ret;
} }
void target_mem_write32(target *t, uint32_t addr, uint32_t value) void target_mem_write32(target *t, uint32_t addr, uint32_t value)
{ {
target_mem_write(t, addr, &value, sizeof(value)); t->mem_write(t, addr, &value, sizeof(value));
} }
uint16_t target_mem_read16(target *t, uint32_t addr) uint16_t target_mem_read16(target *t, uint32_t addr)
{ {
uint16_t ret; uint16_t ret;
target_mem_read(t, &ret, addr, sizeof(ret)); t->mem_read(t, &ret, addr, sizeof(ret));
return ret; return ret;
} }
void target_mem_write16(target *t, uint32_t addr, uint16_t value) void target_mem_write16(target *t, uint32_t addr, uint16_t value)
{ {
target_mem_write(t, addr, &value, sizeof(value)); t->mem_write(t, addr, &value, sizeof(value));
} }
uint8_t target_mem_read8(target *t, uint32_t addr) uint8_t target_mem_read8(target *t, uint32_t addr)
{ {
uint8_t ret; uint8_t ret;
target_mem_read(t, &ret, addr, sizeof(ret)); t->mem_read(t, &ret, addr, sizeof(ret));
return ret; return ret;
} }
void target_mem_write8(target *t, uint32_t addr, uint8_t value) void target_mem_write8(target *t, uint32_t addr, uint8_t value)
{ {
target_mem_write(t, addr, &value, sizeof(value)); t->mem_write(t, addr, &value, sizeof(value));
} }
void target_command_help(target *t) void target_command_help(target *t)

View File

@ -141,6 +141,7 @@ uint8_t target_mem_read8(target *t, uint32_t addr);
void target_mem_write32(target *t, uint32_t addr, uint32_t value); void target_mem_write32(target *t, uint32_t addr, uint32_t value);
void target_mem_write16(target *t, uint32_t addr, uint16_t value); void target_mem_write16(target *t, uint32_t addr, uint16_t value);
void target_mem_write8(target *t, uint32_t addr, uint8_t value); void target_mem_write8(target *t, uint32_t addr, uint8_t value);
bool target_check_error(target *t);
/* Access to host controller interface */ /* Access to host controller interface */
void tc_printf(target *t, const char *fmt, ...); void tc_printf(target *t, const char *fmt, ...);