]> xenbits.xensource.com Git - ovmf.git/commitdiff
OvmfPkg/PlatformBootManagerLib: setup virtio serial console
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 4 May 2023 13:12:01 +0000 (15:12 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 4 May 2023 14:26:58 +0000 (14:26 +0000)
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>
OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c

index a90076c9e672cdd098773eaf9797ed4555cebd81..3b7dc53e9f868963c093e3f0f9c204394a3557f9 100644 (file)
@@ -976,6 +976,45 @@ PreparePciSerialDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
+EFI_STATUS\r
+PrepareVirtioSerialDevicePath (\r
+  IN EFI_HANDLE  DeviceHandle\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+\r
+  DevicePath = NULL;\r
+  Status     = gBS->HandleProtocol (\r
+                      DeviceHandle,\r
+                      &gEfiDevicePathProtocolGuid,\r
+                      (VOID *)&DevicePath\r
+                      );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  gPnp16550ComPortDeviceNode.UID = 0;\r
+  DevicePath                     = AppendDevicePathNode (\r
+                                     DevicePath,\r
+                                     (EFI_DEVICE_PATH_PROTOCOL *)&gPnp16550ComPortDeviceNode\r
+                                     );\r
+  DevicePath = AppendDevicePathNode (\r
+                 DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode\r
+                 );\r
+  DevicePath = AppendDevicePathNode (\r
+                 DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode\r
+                 );\r
+\r
+  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 EFI_STATUS\r
 VisitAllInstancesOfProtocol (\r
   IN EFI_GUID                    *Id,\r
@@ -1144,6 +1183,14 @@ DetectAndPreparePlatformPciDevicePath (
     return EFI_SUCCESS;\r
   }\r
 \r
+  if (((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1003)) ||\r
+      ((Pci->Hdr.VendorId == 0x1af4) && (Pci->Hdr.DeviceId == 0x1043)))\r
+  {\r
+    DEBUG ((DEBUG_INFO, "Found virtio serial device\n"));\r
+    PrepareVirtioSerialDevicePath (Handle);\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   return Status;\r
 }\r
 \r