[Pdbg] [PATCH v2 10/12] sbefifo: Add procedure for custom chipop

Amitay Isaacs amitay at ozlabs.org
Thu Jul 4 18:05:23 AEST 2019


Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 libpdbg/hwunit.h  |  1 +
 libpdbg/sbefifo.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h
index 497e5d7..19b8a5c 100644
--- a/libpdbg/hwunit.h
+++ b/libpdbg/hwunit.h
@@ -71,6 +71,7 @@ struct sbefifo {
 	int (*mem_read)(struct sbefifo *, uint64_t, uint8_t *, uint64_t, bool);
 	int (*mem_write)(struct sbefifo *, uint64_t, uint8_t *, uint64_t, bool);
 	int (*control)(struct sbefifo *, uint32_t core_id, uint32_t thread_id, uint32_t oper);
+	int (*custom)(struct sbefifo *, uint32_t *, uint32_t, uint8_t **, uint32_t *, uint32_t *);
 	uint32_t (*ffdc_get)(struct sbefifo *, const uint8_t **, uint32_t *);
 	void (*ffdc_dump)(struct sbefifo *);
 	int fd;
diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
index 42b33ef..efb1cc9 100644
--- a/libpdbg/sbefifo.c
+++ b/libpdbg/sbefifo.c
@@ -470,6 +470,34 @@ static int sbefifo_op_control(struct sbefifo *sbefifo,
 	return 0;
 }
 
+static int sbefifo_op_custom(struct sbefifo *sbefifo,
+			     uint32_t *msg, uint32_t msg_len,
+			     uint8_t **out, uint32_t *out_len, uint32_t *status)
+{
+	uint32_t len, cmd, op;
+	int rc;
+
+	assert(msg_len > 3);
+
+	len = be32toh(msg[0]);
+	cmd = be32toh(msg[1]);
+	op = be32toh(msg[2]);
+
+	PR_NOTICE("sbefifo: custom command=%u, op=%u\n", cmd, op);
+
+	if (len != msg_len) {
+		PR_ERROR("sbefifo: custom: Invalid msg length, expected %u, got %u\n",
+			 len, msg_len);
+		return -1;
+	}
+
+	rc = sbefifo_op(sbefifo, msg, msg_len, cmd, out, out_len, status);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+
 static int sbefifo_probe(struct pdbg_target *target)
 {
 	struct sbefifo *sf = target_to_sbefifo(target);
@@ -498,6 +526,7 @@ struct sbefifo kernel_sbefifo = {
 	.mem_read = sbefifo_op_getmem,
 	.mem_write = sbefifo_op_putmem,
 	.control = sbefifo_op_control,
+	.custom = sbefifo_op_custom,
 	.ffdc_get = sbefifo_ffdc_get,
 	.ffdc_dump = sbefifo_ffdc_dump,
 	.fd = -1,
-- 
2.21.0



More information about the Pdbg mailing list