From 1e54139f4a45d379c1cda7ad02a3f4a7d321b78e Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Sat, 28 Mar 2015 20:15:33 -0700 Subject: target: Remove pc_read/pc_write methods. --- src/cortexm.c | 5 +---- src/include/cortexm.h | 1 + src/include/target.h | 9 --------- src/lmi.c | 3 ++- src/nrf51.c | 3 ++- src/stm32l0.c | 5 +++-- 6 files changed, 9 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/cortexm.c b/src/cortexm.c index 4a4b5bf..0a9785f 100644 --- a/src/cortexm.c +++ b/src/cortexm.c @@ -62,7 +62,6 @@ const struct command_s cortexm_cmd_list[] = { static int cortexm_regs_read(target *t, void *data); static int cortexm_regs_write(target *t, const void *data); -static int cortexm_pc_write(target *t, const uint32_t val); static uint32_t cortexm_pc_read(target *t); static void cortexm_reset(target *t); @@ -218,8 +217,6 @@ bool cortexm_probe(target *t) t->tdesc = tdesc_cortex_m; t->regs_read = cortexm_regs_read; t->regs_write = cortexm_regs_write; - t->pc_write = cortexm_pc_write; - t->pc_read = cortexm_pc_read; t->reset = cortexm_reset; t->halt_request = cortexm_halt_request; @@ -428,7 +425,7 @@ static uint32_t cortexm_pc_read(target *t) return 0; } -static int cortexm_pc_write(target *t, const uint32_t val) +int cortexm_pc_write(target *t, const uint32_t val) { target_mem_write32(t, CORTEXM_DCRDR, val); target_mem_write32(t, CORTEXM_DCRSR, CORTEXM_DCRSR_REGWnR | 0x0F); diff --git a/src/include/cortexm.h b/src/include/cortexm.h index 8f4d45d..9c906a1 100644 --- a/src/include/cortexm.h +++ b/src/include/cortexm.h @@ -149,6 +149,7 @@ void cortexm_halt_resume(struct target_s *target, bool step); int cortexm_run_stub(struct target_s *target, uint32_t loadaddr, const uint16_t *stub, uint32_t stublen, uint32_t r0, uint32_t r1, uint32_t r2, uint32_t r3); +int cortexm_pc_write(target *t, const uint32_t val); #endif diff --git a/src/include/target.h b/src/include/target.h index 92703b7..48e81f2 100644 --- a/src/include/target.h +++ b/src/include/target.h @@ -61,12 +61,6 @@ target *target_attach(target *t, target_destroy_callback destroy_cb); #define target_regs_write(target, data) \ (target)->regs_write((target), (data)) -#define target_pc_read(target) \ - (target)->pc_read((target)) - -#define target_pc_write(target, val) \ - (target)->pc_write((target), (val)) - /* Halt/resume functions */ #define target_reset(target) \ @@ -135,9 +129,6 @@ struct target_s { int (*regs_read)(target *t, void *data); int (*regs_write)(target *t, const void *data); - uint32_t (*pc_read)(target *t); - int (*pc_write)(target *t, const uint32_t val); - /* Halt/resume functions */ void (*reset)(target *t); void (*halt_request)(target *t); diff --git a/src/lmi.c b/src/lmi.c index d9aa613..f9fd225 100644 --- a/src/lmi.c +++ b/src/lmi.c @@ -30,6 +30,7 @@ #include "general.h" #include "adiv5.h" #include "target.h" +#include "cortexm.h" static int lmi_flash_erase(struct target_s *target, uint32_t addr, size_t len); static int lmi_flash_write(struct target_s *target, uint32_t dest, @@ -163,7 +164,7 @@ int lmi_flash_write(struct target_s *target, uint32_t dest, DEBUG("Sending data\n"); target_mem_write(target, 0x20000030, data, len + 8); DEBUG("Running stub\n"); - target_pc_write(target, 0x20000000); + cortexm_pc_write(target, 0x20000000); target_halt_resume(target, 0); DEBUG("Waiting for halt\n"); while(!target_halt_wait(target)); diff --git a/src/nrf51.c b/src/nrf51.c index ed0137c..a75b356 100644 --- a/src/nrf51.c +++ b/src/nrf51.c @@ -26,6 +26,7 @@ #include "target.h" #include "command.h" #include "gdb_packet.h" +#include "cortexm.h" static int nrf51_flash_erase(struct target_s *target, uint32_t addr, size_t len); static int nrf51_flash_write(struct target_s *target, uint32_t dest, @@ -229,7 +230,7 @@ static int nrf51_flash_write(struct target_s *target, uint32_t dest, /* Write stub and data to target ram and set PC */ target_mem_write(target, 0x20000000, nrf51_flash_write_stub, 0x28); target_mem_write(target, 0x20000028, data, len + 8); - target_pc_write(target, 0x20000000); + cortexm_pc_write(target, 0x20000000); if(target_check_error(target)) return -1; diff --git a/src/stm32l0.c b/src/stm32l0.c index 93c5d94..6d02ad2 100644 --- a/src/stm32l0.c +++ b/src/stm32l0.c @@ -117,6 +117,7 @@ #include "target.h" #include "command.h" #include "gdb_packet.h" +#include "cortexm.h" #include "stm32lx-nvm.h" @@ -386,7 +387,7 @@ static int stm32lx_nvm_prog_erase_stubbed(struct target_s* target, &info, sizeof(info)); /* Execute stub */ - target_pc_write(target, STM32Lx_STUB_PHYS); + cortexm_pc_write(target, STM32Lx_STUB_PHYS); if (target_check_error(target)) return -1; target_halt_resume(target, 0); @@ -462,7 +463,7 @@ static int stm32lx_nvm_prog_write_stubbed(struct target_s* target, &info, sizeof(info)); /* Execute stub */ - target_pc_write(target, STM32Lx_STUB_PHYS); + cortexm_pc_write(target, STM32Lx_STUB_PHYS); if (target_check_error(target)) return -1; target_halt_resume(target, 0); -- cgit v1.2.3