Browse Source

target: Remove target_check_error from external interface.

pull/143/head
Gareth McMullin 8 years ago
parent
commit
9a45d89b4a
  1. 9
      src/gdb_main.c
  2. 5
      src/include/target.h
  3. 18
      src/target/target.c
  4. 1
      src/target/target_internal.h

9
src/gdb_main.c

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

5
src/include/target.h

@ -41,14 +41,13 @@ void target_list_free(void);
target *target_attach(target *t, struct target_controller *);
target *target_attach_n(int n, struct target_controller *);
void target_detach(target *t);
bool target_check_error(target *t);
bool target_attached(target *t);
const char *target_driver_name(target *t);
/* Memory access functions */
const char *target_mem_map(target *t);
void 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_read(target *t, void *dest, target_addr src, size_t len);
int target_mem_write(target *t, target_addr dest, const void *src, size_t len);
/* Flash memory access functions */
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);

18
src/target/target.c

@ -293,14 +293,16 @@ bool target_check_error(target *t) { return t->check_error(t); }
bool target_attached(target *t) { return t->attached; }
/* 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);
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);
return target_check_error(t);
}
/* 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 ret;
target_mem_read(t, &ret, addr, sizeof(ret));
t->mem_read(t, &ret, addr, sizeof(ret));
return ret;
}
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 ret;
target_mem_read(t, &ret, addr, sizeof(ret));
t->mem_read(t, &ret, addr, sizeof(ret));
return ret;
}
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 ret;
target_mem_read(t, &ret, addr, sizeof(ret));
t->mem_read(t, &ret, addr, sizeof(ret));
return ret;
}
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)

1
src/target/target_internal.h

@ -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_write16(target *t, uint32_t addr, uint16_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 */
void tc_printf(target *t, const char *fmt, ...);

Loading…
Cancel
Save