diff options
| author | Amitay Isaacs <amitay@ozlabs.org> | 2019-01-07 15:30:20 +1100 |
|---|---|---|
| committer | Alistair Popple <alistair@popple.id.au> | 2019-03-26 11:52:44 +1100 |
| commit | 39f85aac1ae5998407f6428b71d469a4520823f8 (patch) | |
| tree | 04f97a73ea9a0a476aa32e2df7b1f279e61623ce /src | |
| parent | 433a51007f4edc39f0f26daf56d4a88426efe957 (diff) | |
| download | pdbg-39f85aac1ae5998407f6428b71d469a4520823f8.tar.gz pdbg-39f85aac1ae5998407f6428b71d469a4520823f8.zip | |
main: Use new api to read/write memory
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/mem.c | 28 | ||||
| -rw-r--r-- | src/pdbgproxy.c | 6 | ||||
| -rw-r--r-- | src/thread.c | 2 |
3 files changed, 14 insertions, 22 deletions
@@ -41,7 +41,7 @@ struct mem_flags { #define MEM_CI_FLAG ("--ci", ci, parse_flag_noarg, false) #define BLOCK_SIZE (parse_number8_pow2, NULL) -static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) +static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci) { struct pdbg_target *target; uint8_t *buf; @@ -60,11 +60,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) pdbg_set_progress_tick(progress_tick); progress_init(); - if (block_size) - rc = adu_getmem_io(target, addr, buf, size, block_size); - else - rc = adu_getmem(target, addr, buf, size); - + rc = mem_read(target, addr, buf, size, block_size, ci); if (rc) PR_ERROR("Unable to read memory.\n"); @@ -84,20 +80,20 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags) { if (flags.ci) - return _getmem(addr, size, 8); + return _getmem(addr, size, 8, true); else - return _getmem(addr, size, 0); + return _getmem(addr, size, 0, false); } OPTCMD_DEFINE_CMD_WITH_FLAGS(getmem, getmem, (ADDRESS, DATA), mem_flags, (MEM_CI_FLAG)); static int getmemio(uint64_t addr, uint64_t size, uint8_t block_size) { - return _getmem(addr, size, block_size); + return _getmem(addr, size, block_size, true); } OPTCMD_DEFINE_CMD_WITH_ARGS(getmemio, getmemio, (ADDRESS, DATA, BLOCK_SIZE)); -static int _putmem(uint64_t addr, uint8_t block_size) +static int _putmem(uint64_t addr, uint8_t block_size, bool ci) { uint8_t *buf; int read_size, rc = 0; @@ -118,11 +114,7 @@ static int _putmem(uint64_t addr, uint8_t block_size) if (read_size <= 0) break; - if (block_size) - rc = adu_putmem_io(adu_target, addr, buf, read_size, block_size); - else - rc = adu_putmem(adu_target, addr, buf, read_size); - + rc = mem_write(adu_target, addr, buf, read_size, block_size, ci); if (rc) { rc = 0; printf("Unable to write memory.\n"); @@ -141,14 +133,14 @@ static int _putmem(uint64_t addr, uint8_t block_size) static int putmem(uint64_t addr, struct mem_flags flags) { if (flags.ci) - return _putmem(addr, 8); + return _putmem(addr, 8, true); else - return _putmem(addr, 0); + return _putmem(addr, 0, false); } OPTCMD_DEFINE_CMD_WITH_FLAGS(putmem, putmem, (ADDRESS), mem_flags, (MEM_CI_FLAG)); static int putmemio(uint64_t addr, uint8_t block_size) { - return _putmem(addr, block_size); + return _putmem(addr, block_size, true); } OPTCMD_DEFINE_CMD_WITH_ARGS(putmemio, putmemio, (ADDRESS, BLOCK_SIZE)); diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index dedea7a..572af01 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -183,7 +183,7 @@ static void get_spr(uint64_t *stack, void *priv) #define MAX_DATA 0x1000 -/* Returns a real address to use with adu_getmem or -1UL if we +/* Returns a real address to use with mem_read or -1UL if we * couldn't determine a real address. At the moment we only deal with * kernel linear mapping but in future we could walk that page * tables. */ @@ -223,7 +223,7 @@ static void get_mem(uint64_t *stack, void *priv) linear_map = get_real_addr(addr); if (linear_map != -1UL) { - if (adu_getmem(adu_target, linear_map, (uint8_t *) data, len)) { + if (mem_read(adu_target, linear_map, (uint8_t *) data, len, 0, false)) { PR_ERROR("Unable to read memory\n"); err = 1; } @@ -293,7 +293,7 @@ static void put_mem(uint64_t *stack, void *priv) PR_INFO("put_mem 0x%016" PRIx64 " = 0x%016" PRIx64 "\n", addr, stack[2]); - if (adu_putmem(adu_target, addr, data, len)) { + if (mem_write(adu_target, addr, data, len, 0, false)) { PR_ERROR("Unable to write memory\n"); err = 3; } diff --git a/src/thread.c b/src/thread.c index 1fd448d..8f34233 100644 --- a/src/thread.c +++ b/src/thread.c @@ -35,7 +35,7 @@ static bool is_real_address(struct thread_regs *regs, uint64_t addr) static int load8(struct pdbg_target *target, uint64_t addr, uint64_t *value) { - if (adu_getmem(target, addr, (uint8_t *)value, 8)) { + if (mem_read(target, addr, (uint8_t *)value, 8, 0, false)) { pdbg_log(PDBG_ERROR, "Unable to read memory address=%016" PRIx64 ".\n", addr); return 0; } |

