]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
OvmfPkg/Microvm: wire up serial console, drop super-io
[mirror_edk2.git] / OvmfPkg / Library / PlatformBootManagerLib / BdsPlatform.c
index 4ad80db757b40e3d7d105c1d597dc370f5591117..9b21ba2bd699e8bbfd67c2299d2ca8cdb93549fa 100644 (file)
@@ -8,6 +8,7 @@
 \r
 #include "BdsPlatform.h"\r
 #include <Guid/RootBridgesConnectedEventGroup.h>\r
+#include <Guid/SerialPortLibVendor.h>\r
 #include <Protocol/FirmwareVolume2.h>\r
 #include <Library/PlatformBmPrintScLib.h>\r
 #include <Library/Tcg2PhysicalPresenceLib.h>\r
@@ -669,6 +670,43 @@ PrepareLpcBridgeDevicePath (
   return EFI_SUCCESS;\r
 }\r
 \r
+typedef struct {\r
+  VENDOR_DEVICE_PATH        Guid;\r
+  EFI_DEVICE_PATH_PROTOCOL  End;\r
+} SERIAL_DEVICE_PATH;\r
+\r
+SERIAL_DEVICE_PATH serialDevicePath = {\r
+  {\r
+    { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, { sizeof (VENDOR_DEVICE_PATH), 0} },\r
+    EDKII_SERIAL_PORT_LIB_VENDOR_GUID\r
+  },\r
+  { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { sizeof (EFI_DEVICE_PATH_PROTOCOL), 0 } }\r
+};\r
+\r
+VOID\r
+PrepareMicrovmDevicePath (\r
+  VOID\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  UINT16                    HostBridgeDevId;\r
+\r
+  HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);\r
+  if (HostBridgeDevId != MICROVM_PSEUDO_DEVICE_ID) {\r
+    return;\r
+  }\r
+\r
+  DevicePath = (EFI_DEVICE_PATH_PROTOCOL*)&serialDevicePath;\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gUartDeviceNode);\r
+  DevicePath = AppendDevicePathNode (DevicePath,\r
+                 (EFI_DEVICE_PATH_PROTOCOL *)&gTerminalTypeDeviceNode);\r
+\r
+  EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);\r
+  EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);\r
+}\r
+\r
 EFI_STATUS\r
 GetGopDevicePath (\r
    IN  EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,\r
@@ -1029,6 +1067,8 @@ PlatformInitializeConsole (
   //\r
   VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);\r
 \r
+  PrepareMicrovmDevicePath ();\r
+\r
   //\r
   // Have chance to connect the platform default console,\r
   // the platform default console is the minimum device group\r