[Pdbg] [PATCH 6/7] libpdbg: Allow mem_read/mem_write for pba class
Amitay Isaacs
amitay at ozlabs.org
Thu Oct 24 12:48:46 AEDT 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/target.c | 28 ++++++++++++++++++++--------
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/libpdbg/target.c b/libpdbg/target.c
index 7ffc6e9..069d526 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -248,12 +248,18 @@ int fsi_write_mask(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data, uin
int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_t size, uint8_t block_size, bool ci)
{
struct mem *mem;
+ struct pba *pba;
int rc = -1;
- assert(pdbg_target_is_class(target, "mem"));
-
- mem = target_to_mem(target);
- rc = mem->read(mem, addr, output, size, block_size, ci);
+ if (pdbg_target_is_class(target, "mem")) {
+ mem = target_to_mem(target);
+ rc = mem->read(mem, addr, output, size, block_size, ci);
+ } else if (pdbg_target_is_class(target, "pba")) {
+ pba = target_to_pba(target);
+ rc = pba->read(pba, addr, output, size, block_size, ci);
+ } else {
+ assert(pdbg_target_is_class(target, "mem") || pdbg_target_is_class(target, "pba"));
+ }
return rc;
}
@@ -261,12 +267,18 @@ int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_
int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size, uint8_t block_size, bool ci)
{
struct mem *mem;
+ struct pba *pba;
int rc = -1;
- assert(pdbg_target_is_class(target, "mem"));
-
- mem = target_to_mem(target);
- rc = mem->write(mem, addr, input, size, block_size, ci);
+ if (pdbg_target_is_class(target, "mem")) {
+ mem = target_to_mem(target);
+ rc = mem->write(mem, addr, input, size, block_size, ci);
+ } else if (pdbg_target_is_class(target, "pba")) {
+ pba = target_to_pba(target);
+ rc = pba->write(pba, addr, input, size, block_size, ci);
+ } else {
+ assert(pdbg_target_is_class(target, "mem") || pdbg_target_is_class(target, "pba"));
+ }
return rc;
}
--
2.21.0
More information about the Pdbg
mailing list