[Pdbg] [PATCH v2 2/3] libpdbg: adu: Add progress bar variant adu_getmem
Joel Stanley
joel at jms.id.au
Mon May 14 16:34:28 AEST 2018
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
libpdbg/adu.c | 26 +++++++++++++++++++++++++-
libpdbg/libpdbg.h | 1 +
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/libpdbg/adu.c b/libpdbg/adu.c
index 2a0b8d5f0020..5cfd1c29100d 100644
--- a/libpdbg/adu.c
+++ b/libpdbg/adu.c
@@ -20,6 +20,7 @@
#include "operations.h"
#include "bitutils.h"
+#include "progress.h"
/* P8 ADU SCOM Register Definitions */
#define P8_ALTD_CONTROL_REG 0x0
@@ -79,7 +80,8 @@
#define FBC_ALTD_DATA_DONE PPC_BIT(3)
#define FBC_ALTD_PBINIT_MISSING PPC_BIT(18)
-int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *output, uint64_t size)
+static int __adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr,
+ uint8_t *output, uint64_t size, bool progress_bar)
{
struct adu *adu;
int rc = 0;
@@ -88,6 +90,9 @@ int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *out
assert(!strcmp(adu_target->class, "adu"));
adu = target_to_adu(adu_target);
+ if (progress_bar)
+ progress_init(size);
+
/* We read data in 8-byte aligned chunks */
for (addr = 8*(start_addr / 8); addr < start_addr + size; addr += 8) {
uint64_t data;
@@ -107,11 +112,30 @@ int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *out
memcpy(output, &data, 8);
output += 8;
}
+ if (progress_bar)
+ progress_tick(addr - start_addr);
+ }
+ if (progress_bar) {
+ progress_tick(size);
+ progress_end();
}
return rc;
}
+
+int adu_getmem_progress(struct pdbg_target *adu_target, uint64_t start_addr,
+ uint8_t *output, uint64_t size)
+{
+ return __adu_getmem(adu_target, start_addr, output, size, true);
+}
+
+int adu_getmem(struct pdbg_target *adu_target, uint64_t start_addr,
+ uint8_t *output, uint64_t size)
+{
+ return __adu_getmem(adu_target, start_addr, output, size, false);
+}
+
int adu_putmem(struct pdbg_target *adu_target, uint64_t start_addr, uint8_t *input, uint64_t size)
{
struct adu *adu;
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index f2b5de707a97..dcfa2c99d8bf 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -121,6 +121,7 @@ int htm_reset(struct pdbg_target *target, uint64_t *base, uint64_t *size);
int htm_dump(struct pdbg_target *target, uint64_t size, const char *filename);
int adu_getmem(struct pdbg_target *target, uint64_t addr, uint8_t *ouput, uint64_t size);
+int adu_getmem_progress(struct pdbg_target *target, uint64_t addr, uint8_t *ouput, uint64_t size);
int adu_putmem(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size);
int opb_read(struct pdbg_target *target, uint32_t addr, uint32_t *data);
--
2.17.0
More information about the Pdbg
mailing list