diff mbox series

[5/5] libpdbg: Add sbe_dump() api to collect sbe dump data

Message ID 20201211021356.414095-6-amitay@ozlabs.org
State Accepted
Headers show
Series Implement get dump chip-op | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch master (41586bce6f00623d2d25a8483ee9187c2c0218af)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Amitay Isaacs Dec. 11, 2020, 2:13 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/libpdbg.h | 16 ++++++++++++++++
 libpdbg/target.c  | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index 7b3b760..93c9e8b 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -1347,6 +1347,22 @@  int sbe_mpipl_continue(struct pdbg_target *target);
  */
 int sbe_mpipl_get_ti_info(struct pdbg_target *target, uint8_t **data, uint32_t *data_len);
 
+/**
+ * @brief Get sbe dump
+ *
+ * The dump data must be freed by caller.  It is allocated using malloc() and
+ * must be freed using free().
+ *
+ * @param[in] target pib target to operate on
+ * @param[in] type Type of dump
+ * @param[in] clock Clock on or off
+ * @param[out] data Dump information
+ * @param[out] data_len length of the data
+ *
+ * @return 0 on success, -1 on failure
+ */
+int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, uint8_t **data, uint32_t *data_len);
+
 /**
  * @brief Read a OCMB SCOM register
  *
diff --git a/libpdbg/target.c b/libpdbg/target.c
index 89006d0..f0cf3dc 100644
--- a/libpdbg/target.c
+++ b/libpdbg/target.c
@@ -455,6 +455,22 @@  int sbe_mpipl_get_ti_info(struct pdbg_target *target, uint8_t **data, uint32_t *
 	return chipop->mpipl_get_ti_info(chipop, data, data_len);
 }
 
+int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, uint8_t **data, uint32_t *data_len)
+{
+	struct chipop *chipop;
+
+	chipop = pib_to_chipop(target);
+	if (!chipop)
+		return -1;
+
+	if (!chipop->dump) {
+		PR_ERROR("dump() not implemented for the target\n");
+		return -1;
+	}
+
+	return chipop->dump(chipop, type, clock, data, data_len);
+}
+
 int ocmb_getscom(struct pdbg_target *target, uint64_t addr, uint64_t *val)
 {
 	struct ocmb *ocmb;