[Pdbg] [PATCH v2 22/24] libpdbg: Add accessor to get sbefifo_context

Amitay Isaacs amitay at ozlabs.org
Thu Nov 7 13:28:06 AEDT 2019


This avoids the need to peek inside sbefifo structure from the methods
for different hardware units.

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

diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h
index 40689df..d9b6425 100644
--- a/libpdbg/hwunit.h
+++ b/libpdbg/hwunit.h
@@ -79,6 +79,7 @@ struct chipop {
 struct sbefifo {
 	struct pdbg_target target;
 	struct sbefifo_context *sf_ctx;
+	struct sbefifo_context * (*get_sbefifo_context)(struct sbefifo *);
 };
 #define target_to_sbefifo(x) container_of(x, struct sbefifo, target)
 
diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c
index 98f3442..5ca8412 100644
--- a/libpdbg/sbefifo.c
+++ b/libpdbg/sbefifo.c
@@ -150,6 +150,11 @@ static int sbefifo_op_thread_sreset(struct chipop *chipop,
 	return sbefifo_op_control(chipop, core_id, thread_id, SBEFIFO_INSN_OP_SRESET);
 }
 
+static struct sbefifo_context *sbefifo_op_get_context(struct sbefifo *sbefifo)
+{
+	return sbefifo->sf_ctx;
+}
+
 static int sbefifo_probe(struct pdbg_target *target)
 {
 	struct sbefifo *sf = target_to_sbefifo(target);
@@ -209,6 +214,7 @@ static struct sbefifo kernel_sbefifo = {
 		.probe = sbefifo_probe,
 		.release = sbefifo_release,
 	},
+	.get_sbefifo_context = sbefifo_op_get_context,
 };
 DECLARE_HW_UNIT(kernel_sbefifo);
 
-- 
2.21.0



More information about the Pdbg mailing list