forked from nuttx/nuttx-update
virtio: Add virtio version check
In the source code of qemu or linux, there is a check for the virtio version /* Check device version */ priv->version = readl(priv->base + VIRTIO_MMIO_VERSION); if (priv->version < 1 || priv->version > 2) { debug("(%s): version %d not supported!\n", udev->name, priv->version); return 0; } /* Check device ID */ uc_priv->device = readl(priv->base + VIRTIO_MMIO_DEVICE_ID); if (uc_priv->device == 0) { /* * virtio-mmio device with an ID 0 is a (dummy) placeholder * with no function. End probing now with no error reported. */ return 0; } Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
6e8375f97b
commit
eed302b8bb
1 changed files with 6 additions and 0 deletions
|
@ -821,6 +821,12 @@ static int virtio_mmio_init_device(FAR struct virtio_mmio_device_s *vmdev,
|
|||
}
|
||||
|
||||
vdev->id.version = metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_VERSION);
|
||||
if (vdev->id.version < 1 || vdev->id.version > 2)
|
||||
{
|
||||
vrterr("Version %d not supported!\n", vdev->id.version);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
vdev->id.device = metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_DEVICE_ID);
|
||||
if (vdev->id.device == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue