[4/5] adu: Add new api for memory read/write
diff mbox series

Message ID 20190107043020.145107-5-amitay@ozlabs.org
State Accepted
Headers show
Series
  • Introduce new api mem_read/mem_write
Related show

Checks

Context Check Description
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Amitay Isaacs Jan. 7, 2019, 4:30 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/libpdbg.h |  3 +++
 libpdbg/target.c  | 20 ++++++++++++++++++++
 2 files changed, 23 insertions(+)

Patch
diff mbox series

diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index ee8437f..b332a7e 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -221,6 +221,9 @@  int __adu_getmem(struct pdbg_target *target, uint64_t addr, uint8_t *ouput,
 int __adu_putmem(struct pdbg_target *target, uint64_t addr, uint8_t *input,
 		 uint64_t size, bool ci);
 
+int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_t size, uint8_t block_size, bool ci);
+int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size, uint8_t block_size, bool ci);
+
 int opb_read(struct pdbg_target *target, uint32_t addr, uint32_t *data);
 int opb_write(struct pdbg_target *target, uint32_t addr, uint32_t data);
 
diff --git a/libpdbg/target.c b/libpdbg/target.c
index af9199d..e678470 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -216,6 +216,26 @@  int fsi_write(struct pdbg_target *fsi_dt, uint32_t addr, uint32_t data)
 	return fsi->write(fsi, addr64, data);
 }
 
+int mem_read(struct pdbg_target *target, uint64_t addr, uint8_t *output, uint64_t size, uint8_t block_size, bool ci)
+{
+	struct adu *adu;
+
+	assert(pdbg_target_is_class(target, "adu"));
+	adu = target_to_adu(target);
+
+	return adu->read(adu, addr, output, size, block_size, ci);
+}
+
+int mem_write(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size, uint8_t block_size, bool ci)
+{
+	struct adu *adu;
+
+	assert(pdbg_target_is_class(target, "adu"));
+	adu = target_to_adu(target);
+
+	return adu->write(adu, addr, input, size, block_size, ci);
+}
+
 struct pdbg_target *require_target_parent(struct pdbg_target *target)
 {
 	assert(target->parent);