[Pdbg] [PATCH 3/7] libpdbg: Add sbefifo pba hwunit
Amitay Isaacs
amitay at ozlabs.org
Thu Oct 24 12:48:43 AEDT 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/sbefifo.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
index a448107..7bc6676 100644
--- a/libpdbg/sbefifo.c
+++ b/libpdbg/sbefifo.c
@@ -134,6 +134,102 @@ static int sbefifo_op_putmem(struct mem *sbefifo_mem,
return 0;
}
+static int sbefifo_op_getmem_pba(struct pba *sbefifo_pba,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint8_t block_size, bool ci)
+{
+ struct sbefifo *sbefifo = target_to_sbefifo(sbefifo_pba->target.parent);
+ uint8_t *out;
+ uint64_t start_addr, end_addr;
+ uint32_t align, offset, len;
+ uint16_t flags;
+ int rc;
+
+ align = 128;
+
+ if (block_size && block_size != 128) {
+ PR_ERROR("sbefifo: Only 128 byte block sizes are supported\n");
+ return -1;
+ };
+
+ start_addr = addr & (~(uint64_t)(align-1));
+ end_addr = (addr + size + (align-1)) & (~(uint64_t)(align-1));
+
+ if (end_addr - start_addr > UINT32_MAX) {
+ PR_ERROR("sbefifo: size too large\n");
+ return -EINVAL;
+ }
+
+ offset = addr - start_addr;
+ len = end_addr - start_addr;
+
+ PR_NOTICE("sbefifo: getmempba addr=0x%016" PRIx64 ", len=%u\n",
+ start_addr, len);
+
+ flags = SBEFIFO_MEMORY_FLAG_PBA;
+ if (ci)
+ flags |= SBEFIFO_MEMORY_FLAG_CI;
+
+ rc = sbefifo_mem_get(sbefifo->sf_ctx, start_addr, len, flags, &out);
+ if (rc)
+ return rc;
+
+ pdbg_progress_tick(len, len);
+
+ memcpy(data, out+offset, size);
+ free(out);
+
+ return 0;
+}
+
+static int sbefifo_op_putmem_pba(struct pba *sbefifo_pba,
+ uint64_t addr, uint8_t *data, uint64_t size,
+ uint8_t block_size, bool ci)
+{
+ struct sbefifo *sbefifo = target_to_sbefifo(sbefifo_pba->target.parent);
+ uint32_t align, len;
+ uint16_t flags;
+ int rc;
+
+ align = 128;
+
+ if (block_size && block_size != 128) {
+ PR_ERROR("sbefifo: Only 128 byte block sizes are supported\n");
+ return -1;
+ };
+
+ if (addr & (align-1)) {
+ PR_ERROR("sbefifo: Address must be aligned to %d bytes\n", align);
+ return -1;
+ }
+
+ if (size & (align-1)) {
+ PR_ERROR("sbefifo: Data must be multiple of %d bytes\n", align);
+ return -1;
+ }
+
+ if (size > UINT32_MAX) {
+ PR_ERROR("sbefifo: size too large\n");
+ return -1;
+ }
+
+ len = size & 0xffffffff;
+
+ PR_NOTICE("sbefifo: putmempba addr=0x%016"PRIx64", len=%u\n", addr, len);
+
+ flags = SBEFIFO_MEMORY_FLAG_PBA;
+ if (ci)
+ flags |= SBEFIFO_MEMORY_FLAG_CI;
+
+ rc = sbefifo_mem_put(sbefifo->sf_ctx, addr, data, len, flags);
+ if (rc)
+ return rc;
+
+ pdbg_progress_tick(len, len);
+
+ return 0;
+}
+
static int sbefifo_op_control(struct sbefifo *sbefifo,
uint32_t core_id, uint32_t thread_id,
uint32_t oper)
@@ -203,6 +299,17 @@ struct mem sbefifo_mem = {
};
DECLARE_HW_UNIT(sbefifo_mem);
+struct pba sbefifo_pba = {
+ .target = {
+ .name = "SBE FIFO Chip-op based PBA memory access",
+ .compatible = "ibm,sbefifo-pba",
+ .class = "pba",
+ },
+ .read = sbefifo_op_getmem_pba,
+ .write = sbefifo_op_putmem_pba,
+};
+DECLARE_HW_UNIT(sbefifo_pba);
+
struct sbefifo kernel_sbefifo = {
.target = {
.name = "Kernel based FSI SBE FIFO",
@@ -224,4 +331,5 @@ static void register_sbefifo(void)
{
pdbg_hwunit_register(&kernel_sbefifo_hw_unit);
pdbg_hwunit_register(&sbefifo_mem_hw_unit);
+ pdbg_hwunit_register(&sbefifo_pba_hw_unit);
}
--
2.21.0
More information about the Pdbg
mailing list