12 #ifndef _RPMSG_VIRTIO_H_
13 #define _RPMSG_VIRTIO_H_
16 #include <metal/mutex.h>
17 #include <metal/cache.h>
21 #if defined __cplusplus
26 #ifndef RPMSG_BUFFER_SIZE
27 #define RPMSG_BUFFER_SIZE (512)
31 #define VIRTIO_RPMSG_F_NS 0
33 #if defined(VIRTIO_USE_DCACHE)
34 #define BUFFER_FLUSH(x, s) metal_cache_flush(x, s)
35 #define BUFFER_INVALIDATE(x, s) metal_cache_invalidate(x, s)
37 #define BUFFER_FLUSH(x, s) do { } while (0)
38 #define BUFFER_INVALIDATE(x, s) do { } while (0)
109 #define RPMSG_REMOTE VIRTIO_DEV_DEVICE
110 #define RPMSG_HOST VIRTIO_DEV_DRIVER
131 static inline unsigned int
196 struct metal_io_region *shm_io,
234 struct metal_io_region *shm_io,
258 void *shbuf,
size_t size);
293 #if defined __cplusplus
void(* rpmsg_ns_bind_cb)(struct rpmsg_device *rdev, const char *name, uint32_t dest)
Definition: rpmsg.h:56
int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev, struct virtio_device *vdev, rpmsg_ns_bind_cb ns_bind_cb, struct metal_io_region *shm_io, struct rpmsg_virtio_shm_pool *shpool, const struct rpmsg_virtio_config *config)
Initialize rpmsg virtio device with config.
Definition: rpmsg_virtio.c:788
metal_weak void * rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool, size_t size)
Get buffer in the shared memory pool.
static struct rpmsg_device * rpmsg_virtio_get_rpmsg_device(struct rpmsg_virtio_device *rvdev)
Get RPMsg device from RPMsg virtio device.
Definition: rpmsg_virtio.h:268
static void rpmsg_virtio_set_wait_cb(struct rpmsg_virtio_device *rvdev, rpmsg_virtio_notify_wait_cb notify_wait_cb)
Set the virtio callback to manage the wait for TX buffer availability.
Definition: rpmsg_virtio.h:118
static unsigned int rpmsg_virtio_get_role(struct rpmsg_virtio_device *rvdev)
Get rpmsg virtio device role.
Definition: rpmsg_virtio.h:132
int rpmsg_virtio_get_tx_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio buffer size.
Definition: rpmsg_virtio.c:706
int rpmsg_virtio_get_rx_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio Rx buffer size.
Definition: rpmsg_virtio.c:742
void rpmsg_virtio_init_shm_pool(struct rpmsg_virtio_shm_pool *shpool, void *shbuf, size_t size)
Initialize default shared buffers pool.
Definition: rpmsg_virtio.c:89
void rpmsg_deinit_vdev(struct rpmsg_virtio_device *rvdev)
Deinitialize rpmsg virtio device.
Definition: rpmsg_virtio.c:960
static int rpmsg_virtio_get_buffer_size(struct rpmsg_device *rdev)
Get rpmsg virtio Tx buffer size.
Definition: rpmsg_virtio.h:165
int rpmsg_init_vdev(struct rpmsg_virtio_device *rvdev, struct virtio_device *vdev, rpmsg_ns_bind_cb ns_bind_cb, struct metal_io_region *shm_io, struct rpmsg_virtio_shm_pool *shpool)
Initialize rpmsg virtio device.
Definition: rpmsg_virtio.c:778
int(* rpmsg_virtio_notify_wait_cb)(struct rpmsg_device *rdev, uint32_t id)
Definition: rpmsg_virtio.h:42
Representation of a RPMsg device.
Definition: rpmsg.h:133
Configuration of RPMsg device based on virtio.
Definition: rpmsg_virtio.h:62
bool split_shpool
The flag for splitting shared memory pool to TX and RX.
Definition: rpmsg_virtio.h:70
uint32_t h2r_buf_size
The size of the buffer used to send data from host to remote.
Definition: rpmsg_virtio.h:64
uint32_t r2h_buf_size
The size of the buffer used to send data from remote to host.
Definition: rpmsg_virtio.h:67
Representation of a RPMsg device based on virtio.
Definition: rpmsg_virtio.h:74
struct virtio_device * vdev
Pointer to the virtio device.
Definition: rpmsg_virtio.h:82
rpmsg_virtio_notify_wait_cb notify_wait_cb
Callback handler for rpmsg virtio service, called when service can't get tx buffer.
Definition: rpmsg_virtio.h:106
struct metal_io_region * shbuf_io
Pointer to the shared buffer I/O region.
Definition: rpmsg_virtio.h:91
struct rpmsg_virtio_shm_pool * shpool
Pointer to the shared buffers pool.
Definition: rpmsg_virtio.h:94
struct virtqueue * rvq
Pointer to receive virtqueue.
Definition: rpmsg_virtio.h:85
struct virtqueue * svq
Pointer to send virtqueue.
Definition: rpmsg_virtio.h:88
struct rpmsg_device rdev
RPMsg device.
Definition: rpmsg_virtio.h:76
struct rpmsg_virtio_config config
Structure containing virtio configuration.
Definition: rpmsg_virtio.h:79
struct metal_list reclaimer
RPMsg buffer reclaimer that contains buffers released by the rpmsg_virtio_release_tx_buffer function.
Definition: rpmsg_virtio.h:100
Shared memory pool used for RPMsg buffers.
Definition: rpmsg_virtio.h:45
size_t size
Total pool size.
Definition: rpmsg_virtio.h:53
size_t avail
Available memory size.
Definition: rpmsg_virtio.h:50
void * base
Base address of the memory pool.
Definition: rpmsg_virtio.h:47
Structure definition for virtio devices for use by the applications/drivers.
Definition: virtio.h:176
unsigned int role
If it is virtio backend or front end.
Definition: virtio.h:187
Local virtio queue to manage a virtio ring for sending or receiving.
Definition: virtqueue.h:78