[Pdbg] [PATCH v2 1/6] libpdbg: Refactor getmem/putmem chip-ops
Amitay Isaacs
amitay at ozlabs.org
Thu Oct 31 17:39:25 AEDT 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/sbefifo.c | 52 +++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
index b313b67..75a3645 100644
--- a/libpdbg/sbefifo.c
+++ b/libpdbg/sbefifo.c
@@ -92,14 +92,13 @@ static int sbefifo_op_istep(struct sbefifo *sbefifo, uint32_t major, uint32_t mi
return rc;
}
-static int sbefifo_op_getmem(struct mem *sbefifo_mem,
- uint64_t addr, uint8_t *data, uint64_t size,
- uint8_t block_size, bool ci)
+static int _sbefifo_op_getmem(struct mem *sbefifo_mem,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint16_t flags, const char *op)
{
struct sbefifo *sbefifo = target_to_sbefifo(sbefifo_mem->target.parent);
uint8_t *msg, *out;
uint32_t msg_len, out_len, len;
- uint16_t flags;
int rc;
if (size > UINT32_MAX) {
@@ -109,11 +108,7 @@ static int sbefifo_op_getmem(struct mem *sbefifo_mem,
len = size & 0xffffffff;
- PR_NOTICE("sbefifo: getmem addr=0x%016" PRIx64 ", len=%u\n", addr, len);
-
- flags = SBEFIFO_MEMORY_FLAG_PROC;
- if (ci)
- flags |= SBEFIFO_MEMORY_FLAG_CI;
+ PR_NOTICE("sbefifo: %s addr=0x%016" PRIx64 ", len=%u\n", op, addr, len);
rc = sbefifo_mem_get_push(addr, len, flags, &msg, &msg_len);
if (rc)
@@ -138,14 +133,13 @@ static int sbefifo_op_getmem(struct mem *sbefifo_mem,
return rc;
}
-static int sbefifo_op_putmem(struct mem *sbefifo_mem,
- uint64_t addr, uint8_t *data, uint64_t size,
- uint8_t block_size, bool ci)
+static int _sbefifo_op_putmem(struct mem *sbefifo_mem,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint16_t flags, const char *op)
{
struct sbefifo *sbefifo = target_to_sbefifo(sbefifo_mem->target.parent);
uint8_t *msg, *out;
uint32_t msg_len, out_len, len;
- uint16_t flags;
int rc;
if (size > UINT32_MAX) {
@@ -155,11 +149,7 @@ static int sbefifo_op_putmem(struct mem *sbefifo_mem,
len = size & 0xffffffff;
- PR_NOTICE("sbefifo: putmem addr=0x%016"PRIx64", len=%u\n", addr, len);
-
- flags = SBEFIFO_MEMORY_FLAG_PROC;
- if (ci)
- flags |= SBEFIFO_MEMORY_FLAG_CI;
+ PR_NOTICE("sbefifo: %s addr=0x%016"PRIx64", len=%u\n", op, addr, len);
rc = sbefifo_mem_put_push(addr, data, len, flags, &msg, &msg_len);
if (rc)
@@ -181,6 +171,32 @@ static int sbefifo_op_putmem(struct mem *sbefifo_mem,
return rc;
}
+static int sbefifo_op_getmem(struct mem *sbefifo_mem,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint8_t block_size, bool ci)
+{
+ uint16_t flags;
+
+ flags = SBEFIFO_MEMORY_FLAG_PROC;
+ if (ci)
+ flags |= SBEFIFO_MEMORY_FLAG_CI;
+
+ return _sbefifo_op_getmem(sbefifo_mem, addr, data, size, flags, "getmem");
+}
+
+static int sbefifo_op_putmem(struct mem *sbefifo_mem,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint8_t block_size, bool ci)
+{
+ uint16_t flags;
+
+ flags = SBEFIFO_MEMORY_FLAG_PROC;
+ if (ci)
+ flags |= SBEFIFO_MEMORY_FLAG_CI;
+
+ return _sbefifo_op_putmem(sbefifo_mem, addr, data, size, flags, "putmem");
+}
+
static int sbefifo_op_control(struct sbefifo *sbefifo,
uint32_t core_id, uint32_t thread_id,
uint32_t oper)
--
2.21.0
More information about the Pdbg
mailing list