Skip to content

Commit 20292c5

Browse files
xiaoxiang781216arnopo
authored andcommitted
implement rproc_virtio_read_config/rproc_virtio_write_config
so the rpmsg could access the configuration space as needed Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
1 parent 7a8527e commit 20292c5

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

lib/include/openamp/rpmsg_virtio.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
8585
return rvdev->vdev->func->get_features(rvdev->vdev);
8686
}
8787

88+
static inline void
89+
rpmsg_virtio_read_config(struct rpmsg_virtio_device *rvdev,
90+
uint32_t offset, void *dst, int length)
91+
{
92+
rvdev->vdev->func->read_config(rvdev->vdev, offset, dst, length);
93+
}
94+
95+
static inline void
96+
rpmsg_virtio_write_config(struct rpmsg_virtio_device *rvdev,
97+
uint32_t offset, void *dst, int length)
98+
{
99+
rvdev->vdev->func->write_config(rvdev->vdev, offset, dst, length);
100+
}
101+
88102
static inline int
89103
rpmsg_virtio_create_virtqueues(struct rpmsg_virtio_device *rvdev,
90104
int flags, unsigned int nvqs,

lib/remoteproc/remoteproc_virtio.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,42 @@ static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
128128
static void rproc_virtio_read_config(struct virtio_device *vdev,
129129
uint32_t offset, void *dst, int length)
130130
{
131-
(void)vdev;
132-
(void)offset;
133-
(void)dst;
134-
(void)length;
131+
struct remoteproc_virtio *rpvdev;
132+
struct fw_rsc_vdev *vdev_rsc;
133+
struct metal_io_region *io;
134+
char *config;
135+
136+
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
137+
vdev_rsc = rpvdev->vdev_rsc;
138+
config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
139+
io = rpvdev->vdev_rsc_io;
140+
141+
if (offset + length <= vdev_rsc->config_len)
142+
metal_io_block_read(io,
143+
metal_io_virt_to_offset(io, config + offset),
144+
dst, length);
135145
}
136146

137147
#ifndef VIRTIO_SLAVE_ONLY
138148
static void rproc_virtio_write_config(struct virtio_device *vdev,
139149
uint32_t offset, void *src, int length)
140150
{
141-
(void)vdev;
142-
(void)offset;
143-
(void)src;
144-
(void)length;
151+
struct remoteproc_virtio *rpvdev;
152+
struct fw_rsc_vdev *vdev_rsc;
153+
struct metal_io_region *io;
154+
char *config;
155+
156+
rpvdev = metal_container_of(vdev, struct remoteproc_virtio, vdev);
157+
vdev_rsc = rpvdev->vdev_rsc;
158+
config = (char *)(&vdev_rsc->vring[vdev->vrings_num]);
159+
io = rpvdev->vdev_rsc_io;
160+
161+
if (offset + length <= vdev_rsc->config_len) {
162+
metal_io_block_write(io,
163+
metal_io_virt_to_offset(io, config + offset),
164+
src, length);
165+
rpvdev->notify(rpvdev->priv, vdev->notifyid);
166+
}
145167
}
146168

147169
static void rproc_virtio_reset_device(struct virtio_device *vdev)

0 commit comments

Comments
 (0)