OvmfPkg/PlatformBootManagerLib: setup virtio serial console

In case a virtio-serial device is present in the system register the
first serial port as console.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2023-05-04 15:12:01 +02:00 committed by mergify[bot]
parent c6c4362051
commit 4b02045f86
1 changed files with 47 additions and 0 deletions

View File

@ -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;
}