[Pdbg] [PATCH 7/7] main: Use sbefifo first before adu for memory read/write
Amitay Isaacs
amitay at ozlabs.org
Wed Apr 10 18:08:54 AEST 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
src/mem.c | 48 +++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/src/mem.c b/src/mem.c
index 421eea3..8663ee1 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -78,7 +78,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci)
{
struct pdbg_target *target;
uint8_t *buf;
- int count = 0;
+ int rc, count = 0;
if (size == 0) {
PR_ERROR("Size must be > 0\n");
@@ -88,9 +88,24 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci)
buf = malloc(size);
assert(buf);
- pdbg_for_each_class_target("adu", target) {
- int rc;
+ pdbg_for_each_class_target("sbefifo", target) {
+ if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ pdbg_set_progress_tick(progress_tick);
+ progress_init();
+ rc = mem_read(target, addr, buf, size, block_size, ci);
+ progress_end();
+ if (rc) {
+ PR_ERROR("Unable to read memory using sbefifo\n");
+ continue;
+ }
+
+ count++;
+ goto done;
+ }
+ pdbg_for_each_class_target("adu", target) {
if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
continue;
@@ -99,14 +114,15 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci)
rc = mem_read(target, addr, buf, size, block_size, ci);
progress_end();
if (rc) {
- PR_ERROR("Unable to read memory.\n");
+ PR_ERROR("Unable to read memory using adu\n");
continue;
}
count++;
- break;
+ goto done;
}
+done:
if (count > 0) {
uint64_t i;
bool printable = true;
@@ -159,6 +175,23 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci)
buf = read_stdin(&buflen);
assert(buf);
+ pdbg_for_each_class_target("sbefifo", target) {
+ if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
+ continue;
+
+ pdbg_set_progress_tick(progress_tick);
+ progress_init();
+ rc = mem_write(target, addr, buf, buflen, block_size, ci);
+ progress_end();
+ if (rc) {
+ printf("Unable to write memory using sbefifo\n");
+ continue;
+ }
+
+ count++;
+ goto done;
+ }
+
pdbg_for_each_class_target("adu", target) {
if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED)
continue;
@@ -168,14 +201,15 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci)
rc = mem_write(target, addr, buf, buflen, block_size, ci);
progress_end();
if (rc) {
- printf("Unable to write memory\n");
+ printf("Unable to write memory using adu\n");
continue;
}
count++;
- break;
+ goto done;
}
+done:
if (count > 0)
printf("Wrote %zu bytes starting at 0x%016" PRIx64 "\n", buflen, addr);
--
2.20.1
More information about the Pdbg
mailing list