diff mbox series

[v2,10/20] libsbefifo: Add implementation of suspend_io chipop

Message ID 20201001070814.102735-11-amitay@ozlabs.org
State New
Headers show
Series Add p10 support to libpdbg | expand

Commit Message

Amitay Isaacs Oct. 1, 2020, 7:08 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libsbefifo/cmd_control.c     | 51 ++++++++++++++++++++++++++++++++++++
 libsbefifo/libsbefifo.h      |  1 +
 libsbefifo/sbefifo_private.h |  1 +
 3 files changed, 53 insertions(+)

Comments

Joel Stanley Oct. 7, 2020, 11:47 a.m. UTC | #1
On Thu, 1 Oct 2020 at 07:11, Amitay Isaacs <amitay@ozlabs.org> wrote:
>
> Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  libsbefifo/cmd_control.c     | 51 ++++++++++++++++++++++++++++++++++++
>  libsbefifo/libsbefifo.h      |  1 +
>  libsbefifo/sbefifo_private.h |  1 +
>  3 files changed, 53 insertions(+)
>
> diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
> index 9293ef9..4826b5d 100644
> --- a/libsbefifo/cmd_control.c
> +++ b/libsbefifo/cmd_control.c
> @@ -76,3 +76,54 @@ int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
>
>         return rc;
>  }
> +
> +static int sbefifo_suspend_io_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_CONTROL | SBEFIFO_CMD_SUSPEND_IO;
> +
> +       msg[0] = htobe32(nwords);
> +       msg[1] = htobe32(cmd);
> +
> +       *buf = (uint8_t *)msg;
> +       return 0;
> +}
> +
> +static int sbefifo_suspend_io_pull(uint8_t *buf, uint32_t buflen)
> +{
> +       if (buflen != 0)
> +               return EPROTO;
> +
> +       return 0;
> +}
> +
> +int sbefifo_suspend_io(struct sbefifo_context *sctx)
> +{
> +       uint8_t *msg, *out;
> +       uint32_t msg_len, out_len;
> +       int rc;
> +
> +       rc = sbefifo_suspend_io_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_suspend_io_pull(out, out_len);
> +       if (out)
> +               free(out);
> +
> +       return rc;
> +}
> diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
> index 3af54b4..1c26ea3 100644
> --- a/libsbefifo/libsbefifo.h
> +++ b/libsbefifo/libsbefifo.h
> @@ -73,6 +73,7 @@ uint32_t sbefifo_ffdc_get(struct sbefifo_context *sctx, const uint8_t **ffdc, ui
>  void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
>
>  int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor);
> +int sbefifo_suspend_io(struct sbefifo_context *sctx);
>
>  #define SBEFIFO_SCOM_OPERAND_NONE        0
>  #define SBEFIFO_SCOM_OPERAND_OR          1
> diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
> index 6262c3e..5c9b10a 100644
> --- a/libsbefifo/sbefifo_private.h
> +++ b/libsbefifo/sbefifo_private.h
> @@ -22,6 +22,7 @@
>
>  #define SBEFIFO_CMD_CLASS_CONTROL        0xA100
>  #define   SBEFIFO_CMD_EXECUTE_ISTEP        0x01
> +#define   SBEFIFO_CMD_SUSPEND_IO           0x02
>
>  #define SBEFIFO_CMD_CLASS_SCOM           0xA200
>  #define   SBEFIFO_CMD_GET_SCOM             0x01
> --
> 2.26.2
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
diff mbox series

Patch

diff --git a/libsbefifo/cmd_control.c b/libsbefifo/cmd_control.c
index 9293ef9..4826b5d 100644
--- a/libsbefifo/cmd_control.c
+++ b/libsbefifo/cmd_control.c
@@ -76,3 +76,54 @@  int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t m
 
 	return rc;
 }
+
+static int sbefifo_suspend_io_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_CONTROL | SBEFIFO_CMD_SUSPEND_IO;
+
+	msg[0] = htobe32(nwords);
+	msg[1] = htobe32(cmd);
+
+	*buf = (uint8_t *)msg;
+	return 0;
+}
+
+static int sbefifo_suspend_io_pull(uint8_t *buf, uint32_t buflen)
+{
+	if (buflen != 0)
+		return EPROTO;
+
+	return 0;
+}
+
+int sbefifo_suspend_io(struct sbefifo_context *sctx)
+{
+	uint8_t *msg, *out;
+	uint32_t msg_len, out_len;
+	int rc;
+
+	rc = sbefifo_suspend_io_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_suspend_io_pull(out, out_len);
+	if (out)
+		free(out);
+
+	return rc;
+}
diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
index 3af54b4..1c26ea3 100644
--- a/libsbefifo/libsbefifo.h
+++ b/libsbefifo/libsbefifo.h
@@ -73,6 +73,7 @@  uint32_t sbefifo_ffdc_get(struct sbefifo_context *sctx, const uint8_t **ffdc, ui
 void sbefifo_ffdc_dump(struct sbefifo_context *sctx);
 
 int sbefifo_istep_execute(struct sbefifo_context *sctx, uint8_t major, uint8_t minor);
+int sbefifo_suspend_io(struct sbefifo_context *sctx);
 
 #define SBEFIFO_SCOM_OPERAND_NONE        0
 #define SBEFIFO_SCOM_OPERAND_OR          1
diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
index 6262c3e..5c9b10a 100644
--- a/libsbefifo/sbefifo_private.h
+++ b/libsbefifo/sbefifo_private.h
@@ -22,6 +22,7 @@ 
 
 #define SBEFIFO_CMD_CLASS_CONTROL        0xA100
 #define   SBEFIFO_CMD_EXECUTE_ISTEP        0x01
+#define   SBEFIFO_CMD_SUSPEND_IO           0x02
 
 #define SBEFIFO_CMD_CLASS_SCOM           0xA200
 #define   SBEFIFO_CMD_GET_SCOM             0x01