Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/include/openamp/remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,23 @@ struct fw_rsc_vdev {
struct fw_rsc_vdev_vring vring[0];
} METAL_PACKED_END;

/**
* struct fw_rsc_config - configuration space declaration
* @h2r_buf_size: the size of the buffer used to send data from host to remote
* @r2h_buf_size: the size of the buffer used to send data from remote to host
* @reserved: reserved (must be zero)
*
* This structure immediately follow fw_rsc_vdev to provide the config info.
*/
METAL_PACKED_BEGIN
struct fw_rsc_config {
/* The individual buffer size(if VIRTIO_RPMSG_F_BUFSZ) */
uint32_t h2r_buf_size;
uint32_t r2h_buf_size;
uint32_t reserved[14]; /* Reserve for the future use */
/* Put the customize config here */
} METAL_PACKED_END;

/**
* @brief Resource table remote processor vendor specific entry
*
Expand Down
1 change: 1 addition & 0 deletions lib/include/openamp/rpmsg_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C" {

/* The feature bitmap for virtio rpmsg */
#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */
#define VIRTIO_RPMSG_F_BUFSZ 2 /* RP supports buffer size negotiation */

#ifdef VIRTIO_CACHED_BUFFERS
#warning "VIRTIO_CACHED_BUFFERS is deprecated, please use VIRTIO_USE_DCACHE"
Expand Down
9 changes: 9 additions & 0 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <metal/sleep.h>
#include <metal/utilities.h>
#include <openamp/rpmsg_virtio.h>
#include <openamp/remoteproc.h>
#include <openamp/virtqueue.h>

#include "rpmsg_internal.h"
Expand Down Expand Up @@ -783,6 +784,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
struct rpmsg_device *rdev;
const char *vq_names[RPMSG_NUM_VRINGS];
vq_callback callback[RPMSG_NUM_VRINGS];
struct fw_rsc_config fw_config;
uint32_t features;
int status;
unsigned int i;
Expand Down Expand Up @@ -829,6 +831,13 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
return status;
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));

if (features & (1 << VIRTIO_RPMSG_F_BUFSZ)) {
virtio_read_config(vdev,
0, &fw_config, sizeof(fw_config));
rvdev->config.h2r_buf_size = fw_config.h2r_buf_size;
rvdev->config.r2h_buf_size = fw_config.r2h_buf_size;
}

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
/*
* Since device is RPMSG Remote so we need to manage the
Expand Down