]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformDxe/Platform.c
OvmfPkg: PlatformDxe: set preferred video resolution from platform config
[mirror_edk2.git] / OvmfPkg / PlatformDxe / Platform.c
index 7e2353035cfee6e8db0dca9eb225bc07daf83748..a6172a8018761f9a8c97e73eadff9b110a50782a 100644 (file)
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 \r
+#include "PlatformConfig.h"\r
+\r
+/**\r
+  Load and execute the platform configuration.\r
+\r
+  @retval EFI_SUCCESS            Configuration loaded and executed.\r
+  @return                        Status codes from PlatformConfigLoad().\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+ExecutePlatformConfig (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS      Status;\r
+  PLATFORM_CONFIG PlatformConfig;\r
+  UINT64          OptionalElements;\r
+\r
+  Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG (((Status == EFI_NOT_FOUND) ? EFI_D_VERBOSE : EFI_D_ERROR,\r
+      "%a: failed to load platform config: %r\n", __FUNCTION__, Status));\r
+    return Status;\r
+  }\r
+\r
+  if (OptionalElements & PLATFORM_CONFIG_F_GRAPHICS_RESOLUTION) {\r
+    //\r
+    // Pass the preferred resolution to GraphicsConsoleDxe via dynamic PCDs.\r
+    //\r
+    PcdSet32 (PcdVideoHorizontalResolution,\r
+      PlatformConfig.HorizontalResolution);\r
+    PcdSet32 (PcdVideoVerticalResolution,\r
+      PlatformConfig.VerticalResolution);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
 /**\r
   Entry point for this driver.\r
 \r
 /**\r
   Entry point for this driver.\r
 \r
@@ -33,6 +73,7 @@ PlatformInit (
   IN  EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
   IN  EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
+  ExecutePlatformConfig ();\r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r