#include <metal/io.h>#include <metal/mutex.h>#include <metal/cache.h>#include <openamp/rpmsg.h>#include <openamp/virtio.h>Go to the source code of this file.
Data Structures | |
| struct | rpmsg_virtio_shm_pool |
| Shared memory pool used for RPMsg buffers. More... | |
| struct | rpmsg_virtio_config |
| Configuration of RPMsg device based on virtio. More... | |
| struct | rpmsg_virtio_device |
| Representation of a RPMsg device based on virtio. More... | |
Macros | |
| #define | RPMSG_BUFFER_SIZE (512) |
| #define | VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ |
| #define | BUFFER_FLUSH(x, s) do { } while (0) |
| #define | BUFFER_INVALIDATE(x, s) do { } while (0) |
| #define | RPMSG_REMOTE VIRTIO_DEV_DEVICE |
| #define | RPMSG_HOST VIRTIO_DEV_DRIVER |
Typedefs | |
| typedef int(* | rpmsg_virtio_notify_wait_cb) (struct rpmsg_device *rdev, uint32_t id) |
Functions | |
| 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. More... | |
| static unsigned int | rpmsg_virtio_get_role (struct rpmsg_virtio_device *rvdev) |
| Get rpmsg virtio device role. More... | |
| static __deprecated void | rpmsg_virtio_set_status (struct rpmsg_virtio_device *rvdev, uint8_t status) |
| Set rpmsg virtio device status. More... | |
| static __deprecated uint8_t | rpmsg_virtio_get_status (struct rpmsg_virtio_device *rvdev) |
| Retrieve rpmsg virtio device status. More... | |
| static __deprecated uint32_t | rpmsg_virtio_get_features (struct rpmsg_virtio_device *rvdev) |
| Get the rpmsg virtio device features. More... | |
| static __deprecated void | rpmsg_virtio_read_config (struct rpmsg_virtio_device *rvdev, uint32_t offset, void *dst, int length) |
| Retrieve configuration data from the rpmsg virtio device. More... | |
| static __deprecated void | rpmsg_virtio_write_config (struct rpmsg_virtio_device *rvdev, uint32_t offset, void *src, int length) |
| Write configuration data to the rpmsg virtio device. More... | |
| static __deprecated int | rpmsg_virtio_create_virtqueues (struct rpmsg_virtio_device *rvdev, int flags, unsigned int nvqs, const char *names[], vq_callback *callbacks) |
| Create the rpmsg virtio device virtqueue. More... | |
| static __deprecated void | rpmsg_virtio_delete_virtqueues (struct rpmsg_virtio_device *rvdev) |
| Delete the virtqueues created in rpmsg_virtio_create_virtqueues() More... | |
| int | rpmsg_virtio_get_tx_buffer_size (struct rpmsg_device *rdev) |
| Get rpmsg virtio buffer size. More... | |
| int | rpmsg_virtio_get_rx_buffer_size (struct rpmsg_device *rdev) |
| Get rpmsg virtio Rx buffer size. More... | |
| static int | rpmsg_virtio_get_buffer_size (struct rpmsg_device *rdev) |
| Get rpmsg virtio Tx buffer size. More... | |
| 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. More... | |
| 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. More... | |
| void | rpmsg_deinit_vdev (struct rpmsg_virtio_device *rvdev) |
| Deinitialize rpmsg virtio device. More... | |
| void | rpmsg_virtio_init_shm_pool (struct rpmsg_virtio_shm_pool *shpool, void *shbuf, size_t size) |
| Initialize default shared buffers pool. More... | |
| static struct rpmsg_device * | rpmsg_virtio_get_rpmsg_device (struct rpmsg_virtio_device *rvdev) |
| Get RPMsg device from RPMsg virtio device. More... | |
| 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. More... | |
| #define BUFFER_FLUSH | ( | x, | |
| s | |||
| ) | do { } while (0) |
| #define BUFFER_INVALIDATE | ( | x, | |
| s | |||
| ) | do { } while (0) |
| #define RPMSG_BUFFER_SIZE (512) |
| #define RPMSG_HOST VIRTIO_DEV_DRIVER |
| #define RPMSG_REMOTE VIRTIO_DEV_DEVICE |
| #define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ |
| typedef int(* rpmsg_virtio_notify_wait_cb) (struct rpmsg_device *rdev, uint32_t id) |
| void rpmsg_deinit_vdev | ( | struct rpmsg_virtio_device * | rvdev | ) |
Deinitialize rpmsg virtio device.
| rvdev | Pointer to the rpmsg virtio device |
| 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.
Host side: Initialize RPMsg virtio queues and shared buffers, the address of shm can be ANY. In this case, function will get shared memory from system shared memory pools. If the vdev has the RPMsg name service feature, this API will create a name service endpoint.
Remote side: This API will not return until the driver ready is set by the host side.
| rvdev | Pointer to the rpmsg virtio device |
| vdev | Pointer to the virtio device |
| ns_bind_cb | Callback handler for name service announcement without local endpoints waiting to bind. |
| shm_io | Pointer to the share memory I/O region. |
| shpool | Pointer to shared memory pool. rpmsg_virtio_init_shm_pool has to be called first to fill this structure. |
| 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.
Host side: Initialize RPMsg virtio queues and shared buffers, the address of shm can be ANY. In this case, function will get shared memory from system shared memory pools. If the vdev has the RPMsg name service feature, this API will create a name service endpoint. Sizes of virtio data buffers used by the initialized RPMsg instance are set to values read from the passed configuration structure.
Remote side: This API will not return until the driver ready is set by the host side. Sizes of virtio data buffers are set by the host side. Values passed in the configuration structure have no effect.
| rvdev | Pointer to the rpmsg virtio device |
| vdev | Pointer to the virtio device |
| ns_bind_cb | Callback handler for name service announcement without local endpoints waiting to bind. |
| shm_io | Pointer to the share memory I/O region. |
| shpool | Pointer to shared memory pool array. If the config->split_shpool is turn on, the array will contain two elements, the shpool of txshpool and rxshpool, Otherwise, the array has only one element, and txshpool rxshpool shares a shpool. And rpmsg_virtio_init_shm_pool has to be called first to fill each shpool in this array. |
| config | Pointer to configuration structure |
|
inlinestatic |
Create the rpmsg virtio device virtqueue.
Deprecated: Use virtio_create_virtqueues() instead
| rvdev | Pointer to the rpmsg virtio device. |
| flags | Create flag. |
| nvqs | The virtqueue number. |
| names | Virtqueue names. |
| callbacks | Virtqueue callback functions. |
|
inlinestatic |
Delete the virtqueues created in rpmsg_virtio_create_virtqueues()
Deprecated: Use virtio_delete_virtqueues() instead
| rvdev | Pointer to the rpmsg virtio device |
|
inlinestatic |
Get rpmsg virtio Tx buffer size.
This function is same as rpmsg_virtio_get_tx_buffer_size(), keep it here to maintain the forward compatibility.
| rdev | Pointer to the rpmsg device. |
|
inlinestatic |
Get the rpmsg virtio device features.
Deprecated: Use virtio_get_features() instead
| rvdev | Pointer to the rpmsg virtio device. |
|
inlinestatic |
Get rpmsg virtio device role.
| rvdev | Pointer to rpmsg virtio device. |
|
inlinestatic |
Get RPMsg device from RPMsg virtio device.
| rvdev | Pointer to RPMsg virtio device |
| int rpmsg_virtio_get_rx_buffer_size | ( | struct rpmsg_device * | rdev | ) |
Get rpmsg virtio Rx buffer size.
| rdev | Pointer to the rpmsg device |
|
inlinestatic |
Retrieve rpmsg virtio device status.
Deprecated: Use virtio_get_status() instead
| rvdev | Pointer to rpmsg virtio device. |
| int rpmsg_virtio_get_tx_buffer_size | ( | struct rpmsg_device * | rdev | ) |
Get rpmsg virtio buffer size.
| rdev | Pointer to the rpmsg device |
| void rpmsg_virtio_init_shm_pool | ( | struct rpmsg_virtio_shm_pool * | shpool, |
| void * | shbuf, | ||
| size_t | size | ||
| ) |
Initialize default shared buffers pool.
RPMsg virtio has default shared buffers pool implementation. The memory assigned to this pool will be dedicated to the RPMsg virtio. This function has to be called before calling rpmsg_init_vdev, to initialize the rpmsg_virtio_shm_pool structure.
| shpool | Pointer to the shared buffers pool structure |
| shbuf | Pointer to the beginning of shared buffers |
| size | Shared buffers total size |
|
inlinestatic |
Retrieve configuration data from the rpmsg virtio device.
Deprecated: Use virtio_read_config() instead
| rvdev | Pointer to the rpmsg virtio device. |
| offset | Offset of the data within the configuration area. |
| dst | Address of the buffer that will hold the data. |
| length | Length of the data to be retrieved. |
|
inlinestatic |
Set rpmsg virtio device status.
Deprecated: Use virtio_set_status() instead
| rvdev | Pointer to rpmsg virtio device. |
| status | Value to be set as rpmsg virtio device status. |
|
inlinestatic |
Set the virtio callback to manage the wait for TX buffer availability.
| rvdev | Pointer to rpmsg virtio device. |
| notify_wait_cb | Callback handler to wait buffer notification. |
| 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.
RPMsg virtio has default shared buffers pool implementation. The memory assigned to this pool will be dedicated to the RPMsg virtio. If you prefer to have other shared buffers allocation, you can implement your rpmsg_virtio_shm_pool_get_buffer function.
| shpool | Pointer to the shared buffers pool |
| size | Shared buffers total size |
|
inlinestatic |
Write configuration data to the rpmsg virtio device.
Deprecated: Use virtio_write_config() instead
| rvdev | Pointer to the rpmsg virtio device. |
| offset | Offset of the data within the configuration area. |
| src | Address of the buffer that holds the data to write. |
| length | Length of the data to be written. |