@@ -179,3 +179,60 @@ int sbefifo_mpipl_stopclocks(struct sbefifo_context *sctx, uint16_t target_type,
return rc;
}
+
+static int sbefifo_mpipl_get_ti_info_push(uint8_t **buf, uint32_t *buflen)
+{
+ uint32_t *msg;
+ uint32_t nwords, cmd;
+
+ nwords = 2;
+ *buflen = nwords * sizeof(uint32_t);
+ msg = malloc(*buflen);
+ if (!msg)
+ return ENOMEM;
+
+ cmd = SBEFIFO_CMD_CLASS_MPIPL | SBEFIFO_CMD_GET_TI_INFO;
+
+ msg[0] = htobe32(nwords);
+ msg[1] = htobe32(cmd);
+
+ *buf = (uint8_t *)msg;
+ return 0;
+}
+
+static int sbefifo_mpipl_get_ti_info_pull(uint8_t *buf, uint32_t buflen, uint8_t **data, uint32_t *data_len)
+{
+ if (buflen < 4)
+ return EPROTO;
+
+ *data_len = be32toh(*(uint32_t *) &buf[buflen-4]);
+ *data = malloc(*data_len);
+ if (! *data)
+ return ENOMEM;
+
+ memcpy(*data, buf, *data_len);
+ return 0;
+}
+
+int sbefifo_mpipl_get_ti_info(struct sbefifo_context *sctx, uint8_t **data, uint32_t *data_len)
+{
+ uint8_t *msg, *out;
+ uint32_t msg_len, out_len;
+ int rc;
+
+ rc = sbefifo_mpipl_get_ti_info_push(&msg, &msg_len);
+ if (rc)
+ return rc;
+
+ out_len = 0;
+ rc = sbefifo_operation(sctx, msg, msg_len, &out, &out_len);
+ free(msg);
+ if (rc)
+ return rc;
+
+ rc = sbefifo_mpipl_get_ti_info_pull(out, out_len, data, data_len);
+ if (out)
+ free(out);
+
+ return rc;
+}
@@ -124,6 +124,6 @@ int sbefifo_quiesce(struct sbefifo_context *sctx);
int sbefifo_mpipl_enter(struct sbefifo_context *sctx);
int sbefifo_mpipl_continue(struct sbefifo_context *sctx);
int sbefifo_mpipl_stopclocks(struct sbefifo_context *sctx, uint16_t target_type, uint8_t chiplet_id);
-
+int sbefifo_mpipl_get_ti_info(struct sbefifo_context *sctx, uint8_t **data, uint32_t *data_len);
#endif /* __LIBSBEFIFO_H__ */
@@ -61,6 +61,7 @@
#define SBEFIFO_CMD_ENTER_MPIPL 0x01
#define SBEFIFO_CMD_CONTINUE_MPIPL 0x02
#define SBEFIFO_CMD_STOP_CLOCKS 0x03
+#define SBEFIFO_CMD_GET_TI_INFO 0x04
struct sbefifo_context {
int fd;
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> --- libsbefifo/cmd_mpipl.c | 57 ++++++++++++++++++++++++++++++++++++ libsbefifo/libsbefifo.h | 2 +- libsbefifo/sbefifo_private.h | 1 + 3 files changed, 59 insertions(+), 1 deletion(-)