[edk2-devel] [PATCH v2 4/4] OvmfPkg/PlatformBootManagerLib: setup virtio serial console
Gerd Hoffmann
kraxel at redhat.com
Thu May 4 13:12:01 UTC 2023
In case a virtio-serial device is present in the system register the
first serial port as console.
Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
.../PlatformBootManagerLib/BdsPlatform.c | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index a90076c9e672..3b7dc53e9f86 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -976,6 +976,45 @@ PreparePciSerialDevicePath (
return EFI_SUCCESS;
}
+EFI_STATUS
+PrepareVirtioSerialDevicePath (
+ IN EFI_HANDLE DeviceHandle
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ DevicePath = NULL;
+ Status = gBS->HandleProtocol (
+ DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *)&DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ gPnp16550ComPortDeviceNode.UID = 0;
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode
+ );
+ DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode
+ );
+
+ EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
VisitAllInstancesOfProtocol (
IN EFI_GUID *Id,
@@ -1144,6 +1183,14 @@ DetectAndPreparePlatformPciDevicePath (
return EFI_SUCCESS;
}
+ if (((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1003)) ||
+ ((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1043)))
+ {
+ DEBUG ((DEBUG_INFO, "Found virtio serial device\n"));
+ PrepareVirtioSerialDevicePath (Handle);
+ return EFI_SUCCESS;
+ }
+
return Status;
}
--
2.40.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#103995): https://edk2.groups.io/g/devel/message/103995
Mute This Topic: https://groups.io/mt/98683338/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list