[Pdbg] [PATCH 03/17] libsbefifo: Refactor protocol marshalling for istep chip-op
Amitay Isaacs
amitay at ozlabs.org
Thu Oct 31 17:34:14 AEDT 2019
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libsbefifo/cmd_control.c | 50 +++++++++++++++++++++++++++++++---------
libsbefifo/libsbefifo.h | 3 +++
2 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
index 51bf842..a7b48c2 100644
--- a/libsbefifo/cmd_control.c
+++ b/libsbefifo/cmd_control.c
@@ -22,29 +22,57 @@
#include "libsbefifo.h"
#include "sbefifo_private.h"
-int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor)
+int sbefifo_istep_execute_push(uint8_t major, uint8_t minor, uint8_t **buf, uint32_t *buflen)
{
- uint8_t *out;
- uint32_t msg[3];
- uint32_t cmd, step, out_len;
- int rc;
+ uint32_t *msg;
+ uint32_t nwords, cmd;
+ uint32_t step;
+
+ nwords = 3;
+ *buflen = nwords * sizeof(uint32_t);
+ msg = malloc(*buflen);
+ if (!msg)
+ return ENOMEM;
cmd = SBEFIFO_CMD_CLASS_CONTROL | SBEFIFO_CMD_EXECUTE_ISTEP;
+
step = (major << 16) | minor;
- msg[0] = htobe32(3); // number of words
+ msg[0] = htobe32(nwords);
msg[1] = htobe32(cmd);
msg[2] = htobe32(step);
+ *buf = (uint8_t *)msg;
+ return 0;
+}
+
+int sbefifo_istep_execute_pull(uint8_t *buf, uint32_t buflen)
+{
+ if (buflen != 0)
+ return EPROTO;
+
+ return 0;
+}
+
+int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor)
+{
+ uint8_t *msg, *out;
+ uint32_t msg_len, out_len;
+ int rc;
+
+ rc = sbefifo_istep_execute_push(major, minor, &msg, &msg_len);
+ if (rc)
+ return rc;
+
out_len = 0;
- rc = sbefifo_operation(sctx, (uint8_t *)msg, 3 * 4, &out, &out_len);
+ rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ free(msg);
if (rc)
return rc;
- if (out_len != 0) {
+ rc = sbefifo_istep_execute_pull(out, out_len);
+ if (out)
free(out);
- return EPROTO;
- }
- return 0;
+ return rc;
}
diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
index 84b0169..7a2d104 100644
--- a/libsbefifo/libsbefifo.h
+++ b/libsbefifo/libsbefifo.h
@@ -54,6 +54,9 @@ void sbefifo_disconnect(struct sbefifo_context *sctx);
uint32_t sbefifo_ffdc_get(struct sbefifo_context *sctx, const uint8_t **ffdc, uint32_t *ffdc_len);
void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
+int sbefifo_istep_execute_push(uint8_t major, uint8_t minor, uint8_t **buf, uint32_t *buflen);
+int sbefifo_istep_execute_pull(uint8_t *buf, uint32_t buflen);
+
int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor);
#define SBEFIFO_SCOM_OPERAND_NONE 0
--
2.21.0
More information about the Pdbg
mailing list