[Pdbg] [PATCH v2 17/24] libsbefifo: Add support for custom transport for sbefifo
Alistair Popple
alistair at popple.id.au
Wed Nov 20 14:48:26 AEDT 2019
Reviewed-by: Alistair Popple <alistair at popple.id.au>
On Thursday, 7 November 2019 1:28:01 PM AEDT Amitay Isaacs wrote:
> Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
> ---
> libsbefifo/libsbefifo.h | 4 ++++
> libsbefifo/operation.c | 8 ++++++--
> libsbefifo/sbefifo_private.h | 4 ++++
> 3 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/libsbefifo/libsbefifo.h b/libsbefifo/libsbefifo.h
> index 536b24e..7989b21 100644
> --- a/libsbefifo/libsbefifo.h
> +++ b/libsbefifo/libsbefifo.h
> @@ -50,6 +50,10 @@
>
> struct sbefifo_context;
>
> +typedef int (*sbefifo_transport_fn)(uint8_t *msg, uint32_t msg_len,
> + uint8_t *out, uint32_t *out_len,
> + void *private_data);
> +
> int sbefifo_connect(const char *fifo_path, struct sbefifo_context **out);
> void sbefifo_disconnect(struct sbefifo_context *sctx);
>
> diff --git a/libsbefifo/operation.c b/libsbefifo/operation.c
> index 792b2ae..07d9f64 100644
> --- a/libsbefifo/operation.c
> +++ b/libsbefifo/operation.c
> @@ -147,7 +147,7 @@ int sbefifo_operation(struct sbefifo_context *sctx,
> assert(msg);
> assert(msg_len > 0);
>
> - if (sctx->fd == -1)
> + if (!sctx->transport && sctx->fd == -1)
> return ENOTCONN;
>
> /*
> @@ -163,7 +163,11 @@ int sbefifo_operation(struct sbefifo_context *sctx,
>
> LOG("request: cmd=%08x, len=%u\n", cmd, msg_len);
>
> - rc = sbefifo_transport(sctx, msg, msg_len, buf, &buflen);
> + if (sctx->transport)
> + rc = sctx->transport(msg, msg_len, buf, &buflen, sctx->priv);
> + else
> + rc = sbefifo_transport(sctx, msg, msg_len, buf, &buflen);
> +
> if (rc) {
> free(buf);
> return rc;
> diff --git a/libsbefifo/sbefifo_private.h b/libsbefifo/sbefifo_private.h
> index 41966ba..ef432c4 100644
> --- a/libsbefifo/sbefifo_private.h
> +++ b/libsbefifo/sbefifo_private.h
> @@ -18,6 +18,7 @@
> #define __SBEFIFO_PRIVATE_H__
>
> #include <stdint.h>
> +#include "libsbefifo.h"
>
> #define SBEFIFO_CMD_CLASS_CONTROL 0xA100
> #define SBEFIFO_CMD_EXECUTE_ISTEP 0x01
> @@ -64,6 +65,9 @@
> struct sbefifo_context {
> int fd;
>
> + sbefifo_transport_fn transport;
> + void *priv;
> +
> uint32_t status;
> uint8_t *ffdc;
> uint32_t ffdc_len;
>
More information about the Pdbg
mailing list