summaryrefslogtreecommitdiffstats
path: root/OvmfPkg
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2023-07-06 17:31:43 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-09-07 15:47:58 +0000
commit163083fd80d5e4e24fe110a2be1b11c80445206d (patch)
treeb8d0a22c082299ef60df771edc215f2828a8c02b /OvmfPkg
parentb81557a00c61cc80ab118828f16ed9ce79455880 (diff)
downloadedk2-163083fd80d5e4e24fe110a2be1b11c80445206d.tar.gz
edk2-163083fd80d5e4e24fe110a2be1b11c80445206d.tar.bz2
edk2-163083fd80d5e4e24fe110a2be1b11c80445206d.zip
OvmfPkg/PlatformBootManagerLib: setup virtio-mmio devices.
Add DetectAndPreparePlatformVirtioDevicePath() helper function to setup virtio-mmio devices. Start with virtio-serial support. This makes virtio console usable with microvm. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c31
-rw-r--r--OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf1
2 files changed, 32 insertions, 0 deletions
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 8dc2bbf973..88c39df4ae 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -10,6 +10,7 @@
#include <Guid/RootBridgesConnectedEventGroup.h>
#include <Guid/SerialPortLibVendor.h>
#include <Protocol/FirmwareVolume2.h>
+#include <Protocol/VirtioDevice.h>
#include <Library/PlatformBmPrintScLib.h>
#include <Library/Tcg2PhysicalPresenceLib.h>
#include <Library/XenPlatformLib.h>
@@ -1236,6 +1237,30 @@ DetectAndPreparePlatformPciDevicePath (
return Status;
}
+EFI_STATUS
+EFIAPI
+DetectAndPreparePlatformVirtioDevicePath (
+ IN EFI_HANDLE Handle,
+ IN VOID *Instance,
+ IN VOID *Context
+ )
+{
+ VIRTIO_DEVICE_PROTOCOL *VirtIo = (VIRTIO_DEVICE_PROTOCOL *)Instance;
+
+ DEBUG ((DEBUG_INFO, "%a:%d: id %d\n", __func__, __LINE__, VirtIo->SubSystemDeviceId));
+
+ switch (VirtIo->SubSystemDeviceId) {
+ case 3:
+ PrepareVirtioSerialDevicePath (Handle);
+ break;
+ default:
+ /* nothing */
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
/**
Connect the predefined platform default console device.
@@ -1256,6 +1281,12 @@ PlatformInitializeConsole (
//
VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
+ VisitAllInstancesOfProtocol (
+ &gVirtioDeviceProtocolGuid,
+ DetectAndPreparePlatformVirtioDevicePath,
+ NULL
+ );
+
PrepareMicrovmDevicePath ();
//
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 6b396eac7d..c6ffc1ed9e 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -75,6 +75,7 @@
[Protocols]
gEfiDecompressProtocolGuid
gEfiPciRootBridgeIoProtocolGuid
+ gVirtioDeviceProtocolGuid
gEfiS3SaveStateProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED