1
0
Fork 0
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:
wangmingrong1 2024-12-04 15:16:12 +08:00 committed by Xiang Xiao
parent 6e8375f97b
commit eed302b8bb

View file

@ -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)
{