[Pdbg] [PATCH 5/7] mem: Pass target class as argument to _getmem/_putmem
Amitay Isaacs
amitay at ozlabs.org
Thu Oct 24 12:48:45 AEDT 2019
This will allow different mem class (e.g. pba) to be supported.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
src/mem.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/mem.c b/src/mem.c
index 2fe5918..b225047 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -81,7 +81,7 @@ static uint8_t *read_stdin(size_t *size)
return buf;
}
-static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bool raw)
+static int _getmem(const char *classname, uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bool raw)
{
struct pdbg_target *target;
uint8_t *buf;
@@ -95,7 +95,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo
buf = malloc(size);
assert(buf);
- pdbg_for_each_class_target("mem", target) {
+ pdbg_for_each_class_target(classname, target) {
if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
continue;
@@ -129,21 +129,21 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci, bo
static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags)
{
if (flags.ci)
- return _getmem(addr, size, 8, true, flags.raw);
+ return _getmem("mem", addr, size, 8, true, flags.raw);
else
- return _getmem(addr, size, 0, false, flags.raw);
+ return _getmem("mem", addr, size, 0, false, flags.raw);
}
OPTCMD_DEFINE_CMD_WITH_FLAGS(getmem, getmem, (ADDRESS, DATA),
mem_flags, (MEM_CI_FLAG, MEM_RAW_FLAG));
static int getmemio(uint64_t addr, uint64_t size, uint8_t block_size, struct mem_io_flags flags)
{
- return _getmem(addr, size, block_size, true, flags.raw);
+ return _getmem("mem", addr, size, block_size, true, flags.raw);
}
OPTCMD_DEFINE_CMD_WITH_FLAGS(getmemio, getmemio, (ADDRESS, DATA, BLOCK_SIZE),
mem_io_flags, (MEM_RAW_FLAG));
-static int _putmem(uint64_t addr, uint8_t block_size, bool ci)
+static int _putmem(const char *classname, uint64_t addr, uint8_t block_size, bool ci)
{
uint8_t *buf;
size_t buflen;
@@ -153,7 +153,7 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci)
buf = read_stdin(&buflen);
assert(buf);
- pdbg_for_each_class_target("mem", target) {
+ pdbg_for_each_class_target(classname, target) {
if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
continue;
@@ -181,14 +181,14 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci)
static int putmem(uint64_t addr, struct mem_flags flags)
{
if (flags.ci)
- return _putmem(addr, 8, true);
+ return _putmem("mem", addr, 8, true);
else
- return _putmem(addr, 0, false);
+ return _putmem("mem", 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, true);
+ return _putmem("mem", addr, block_size, true);
}
OPTCMD_DEFINE_CMD_WITH_ARGS(putmemio, putmemio, (ADDRESS, BLOCK_SIZE));
--
2.21.0
More information about the Pdbg
mailing list