Skip to content

Commit

Permalink
implement rproc_virtio_read_config/rproc_virtio_write_config
Browse files Browse the repository at this point in the history
so the rpmsg could access the configuration space as needed

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 authored and arnopo committed May 13, 2020
1 parent 7a8527e commit 20292c5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
14 changes: 14 additions & 0 deletions lib/include/openamp/rpmsg_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
return rvdev->vdev->func->get_features(rvdev->vdev);
}

static inline void
rpmsg_virtio_read_config(struct rpmsg_virtio_device *rvdev,
uint32_t offset, void *dst, int length)
{
rvdev->vdev->func->read_config(rvdev->vdev, offset, dst, length);
}

static inline void
rpmsg_virtio_write_config(struct rpmsg_virtio_device *rvdev,
uint32_t offset, void *dst, int length)
{
rvdev->vdev->func->write_config(rvdev->vdev, offset, dst, length);
}

static inline int
rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
int flags, unsigned int nvqs,
Expand Down
38 changes: 30 additions & 8 deletions lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,42 @@ static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
static void rproc_virtio_read_config(struct virtio_device *vdev,
uint32_t offset, void *dst, int length)
{
(void)vdev;
(void)offset;
(void)dst;
(void)length;
struct remoteproc_virtio *rpvdev;
struct fw_rsc_vdev *vdev_rsc;
struct metal_io_region *io;
char *config;

rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
vdev_rsc = rpvdev->vdev_rsc;
config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
io = rpvdev->vdev_rsc_io;

if (offset + length <= vdev_rsc->config_len)
metal_io_block_read(io,
metal_io_virt_to_offset(io, config + offset),
dst, length);
}

#ifndef VIRTIO_SLAVE_ONLY
static void rproc_virtio_write_config(struct virtio_device *vdev,
uint32_t offset, void *src, int length)
{
(void)vdev;
(void)offset;
(void)src;
(void)length;
struct remoteproc_virtio *rpvdev;
struct fw_rsc_vdev *vdev_rsc;
struct metal_io_region *io;
char *config;

rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
vdev_rsc = rpvdev->vdev_rsc;
config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
io = rpvdev->vdev_rsc_io;

if (offset + length <= vdev_rsc->config_len) {
metal_io_block_write(io,
metal_io_virt_to_offset(io, config + offset),
src, length);
rpvdev->notify(rpvdev->priv, vdev->notifyid);
}
}

static void rproc_virtio_reset_device(struct virtio_device *vdev)
Expand Down

0 comments on commit 20292c5

Please sign in to comment.