@@ -126,20 +126,43 @@ static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
126126static void rproc_virtio_read_config (struct virtio_device * vdev ,
127127 uint32_t offset , void * dst , int length )
128128{
129- (void )vdev ;
130- (void )offset ;
131- (void )dst ;
132- (void )length ;
129+ struct remoteproc_virtio * rpvdev ;
130+ struct fw_rsc_vdev * vdev_rsc ;
131+ struct metal_io_region * io ;
132+ char * config ;
133+
134+ if (offset + length > vdev -> config_len || offset + length < length )
135+ return ;
136+
137+ rpvdev = metal_container_of (vdev , struct remoteproc_virtio , vdev );
138+ vdev_rsc = rpvdev -> vdev_rsc ;
139+ config = (char * )(& vdev_rsc -> vring [vdev -> vrings_num ]);
140+ io = rpvdev -> vdev_rsc_io ;
141+ metal_io_block_read (io ,
142+ metal_io_virt_to_offset (io , config + offset ),
143+ dst , length );
133144}
134145
135146#ifndef VIRTIO_SLAVE_ONLY
136147static void rproc_virtio_write_config (struct virtio_device * vdev ,
137148 uint32_t offset , void * src , int length )
138149{
139- (void )vdev ;
140- (void )offset ;
141- (void )src ;
142- (void )length ;
150+ struct remoteproc_virtio * rpvdev ;
151+ struct fw_rsc_vdev * vdev_rsc ;
152+ struct metal_io_region * io ;
153+ char * config ;
154+
155+ if (offset + length > vdev -> config_len || offset + length < length )
156+ return ;
157+
158+ rpvdev = metal_container_of (vdev , struct remoteproc_virtio , vdev );
159+ vdev_rsc = rpvdev -> vdev_rsc ;
160+ config = (char * )(& vdev_rsc -> vring [vdev -> vrings_num ]);
161+ io = rpvdev -> vdev_rsc_io ;
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 );
143166}
144167
145168static void rproc_virtio_reset_device (struct virtio_device * vdev )
@@ -220,6 +243,7 @@ rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
220243 vdev -> notifyid = notifyid ;
221244 vdev -> role = role ;
222245 vdev -> reset_cb = rst_cb ;
246+ vdev -> config_len = vdev_rsc -> config_len ;
223247 vdev -> vrings_num = num_vrings ;
224248 vdev -> func = & remoteproc_virtio_dispatch_funcs ;
225249
0 commit comments