]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformDxe/Platform.c
OvmfPkg/PlatformDxe: list "Platform.h" in the INF file
[mirror_edk2.git] / OvmfPkg / PlatformDxe / Platform.c
index 49189141bbbbe04351f56e97111c1d6b0aeada41..126d8e73823b408e1980581b3ce5f3b9f4ad6c08 100644 (file)
@@ -258,6 +258,62 @@ ExtractConfig (
 }\r
 \r
 \r
+/**\r
+  Interpret the binary form state and save it as persistent platform\r
+  configuration.\r
+\r
+  @param[in] MainFormState  Binary form/widget state to verify and save.\r
+\r
+  @retval EFI_SUCCESS  Platform configuration saved.\r
+  @return              Error codes from underlying functions.\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+FormStateToPlatformConfig (\r
+  IN CONST MAIN_FORM_STATE *MainFormState\r
+  )\r
+{\r
+  EFI_STATUS      Status;\r
+  PLATFORM_CONFIG PlatformConfig;\r
+  CONST GOP_MODE  *GopMode;\r
+\r
+  //\r
+  // There's nothing to do with the textual CurrentPreferredResolution field.\r
+  // We verify and translate the selection in the drop-down list.\r
+  //\r
+  if (MainFormState->NextPreferredResolution >= mNumGopModes) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  GopMode = mGopModes + MainFormState->NextPreferredResolution;\r
+\r
+  ZeroMem (&PlatformConfig, sizeof PlatformConfig);\r
+  PlatformConfig.HorizontalResolution = GopMode->X;\r
+  PlatformConfig.VerticalResolution   = GopMode->Y;\r
+\r
+  Status = PlatformConfigSave (&PlatformConfig);\r
+  return Status;\r
+}\r
+\r
+\r
+/**\r
+  This function is called by the HII machinery when it wants the driver to\r
+  interpret and persist the form state.\r
+\r
+  See the precise documentation in the UEFI spec.\r
+\r
+  @param[in]  This           The Config Access Protocol instance.\r
+\r
+  @param[in]  Configuration  A <ConfigResp> format UCS-2 string describing the\r
+                             form state.\r
+\r
+  @param[out] Progress       A pointer into Configuration on output,\r
+                             identifying the element where processing failed.\r
+\r
+  @retval EFI_SUCCESS  Configuration verified, state permanent.\r
+\r
+  @return              Status codes from underlying functions.\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -267,9 +323,46 @@ RouteConfig (
   OUT       EFI_STRING                      *Progress\r
 )\r
 {\r
+  MAIN_FORM_STATE MainFormState;\r
+  UINTN           BlockSize;\r
+  EFI_STATUS      Status;\r
+\r
   DEBUG ((EFI_D_VERBOSE, "%a: Configuration=\"%s\"\n", __FUNCTION__,\r
     Configuration));\r
-  return EFI_SUCCESS;\r
+\r
+  //\r
+  // the "read" step in RMW\r
+  //\r
+  Status = PlatformConfigToFormState (&MainFormState);\r
+  if (EFI_ERROR (Status)) {\r
+    *Progress = Configuration;\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // the "modify" step in RMW\r
+  //\r
+  // (Update the binary form state. This update may be partial, which is why in\r
+  // general we must pre-load the form state from the platform config.)\r
+  //\r
+  BlockSize = sizeof MainFormState;\r
+  Status = gHiiConfigRouting->ConfigToBlock (gHiiConfigRouting, Configuration,\r
+                                (VOID *) &MainFormState, &BlockSize, Progress);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "%a: ConfigToBlock(): %r, Progress=\"%s\"\n",\r
+      __FUNCTION__, Status,\r
+      (Status == EFI_BUFFER_TOO_SMALL) ? NULL : *Progress));\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // the "write" step in RMW\r
+  //\r
+  Status = FormStateToPlatformConfig (&MainFormState);\r
+  if (EFI_ERROR (Status)) {\r
+    *Progress = Configuration;\r
+  }\r
+  return Status;\r
 }\r
 \r
 \r
@@ -570,6 +663,7 @@ ExecutePlatformConfig (
   EFI_STATUS      Status;\r
   PLATFORM_CONFIG PlatformConfig;\r
   UINT64          OptionalElements;\r
+  RETURN_STATUS   PcdStatus;\r
 \r
   Status = PlatformConfigLoad (&PlatformConfig, &OptionalElements);\r
   if (EFI_ERROR (Status)) {\r
@@ -582,10 +676,13 @@ ExecutePlatformConfig (
     //\r
     // Pass the preferred resolution to GraphicsConsoleDxe via dynamic PCDs.\r
     //\r
-    PcdSet32 (PcdVideoHorizontalResolution,\r
+    PcdStatus = PcdSet32S (PcdVideoHorizontalResolution,\r
       PlatformConfig.HorizontalResolution);\r
-    PcdSet32 (PcdVideoVerticalResolution,\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
+\r
+    PcdStatus = PcdSet32S (PcdVideoVerticalResolution,\r
       PlatformConfig.VerticalResolution);\r
+    ASSERT_RETURN_ERROR (PcdStatus);\r
   }\r
 \r
   return EFI_SUCCESS;\r