OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum

Use QueueNumMax as QueueNum default for drivers which do not
explicitly call VIRTIO_DEVICE_PROTOCOL->SetQueueSize().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Gerd Hoffmann 2021-08-27 21:44:57 +08:00 committed by mergify[bot]
parent 537a724421
commit 6a3e9576b8
2 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,7 @@
typedef struct {
UINT32 Signature;
UINT32 Version;
UINT16 QueueNum;
VIRTIO_DEVICE_PROTOCOL VirtioDevice;
PHYSICAL_ADDRESS BaseAddress;
} VIRTIO_MMIO_DEVICE;

View File

@ -83,7 +83,11 @@ VirtioMmioSetQueueSize (
Device = VIRTIO_MMIO_DEVICE_FROM_VIRTIO_DEVICE (This);
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, QueueSize);
} else {
Device->QueueNum = QueueSize;
}
return EFI_SUCCESS;
}
@ -171,6 +175,10 @@ VirtioMmioSetQueueSel (
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_SEL, Sel);
if (Device->Version == VIRTIO_MMIO_DEVICE_VERSION_0_95) {
Device->QueueNum = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM_MAX) & 0xFFFF;
}
return EFI_SUCCESS;
}
@ -193,6 +201,8 @@ VirtioMmioSetQueueAddress (
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_PFN,
(UINT32)((UINTN)Ring->Base >> EFI_PAGE_SHIFT));
} else {
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_NUM, Device->QueueNum);
Address = (UINTN)Ring->Base;
VIRTIO_CFG_WRITE (Device, VIRTIO_MMIO_OFFSET_QUEUE_DESC_LO,
(UINT32)Address);