]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PlatformDxe: connect RouteConfig() to platform data
authorLaszlo Ersek <lersek@redhat.com>
Sat, 22 Mar 2014 07:14:09 +0000 (07:14 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 22 Mar 2014 07:14:09 +0000 (07:14 +0000)
Establish the full stack of conversions when modifying the platform
configuration:

       ConfigResp            -- form engine / HII communication
            |
     [ConfigToBlock]
            |
            v
     MAIN_FORM_STATE         -- binary representation of form/widget state
            |
[FormStateToPlatformConfig]
            |
            v
     PLATFORM_CONFIG         -- accessible to DXE and UEFI drivers
            |
   [PlatformConfigSave]
            |
            v
  UEFI non-volatile variable -- accessible to external utilities

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15375 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/PlatformDxe/Platform.c

index 49189141bbbbe04351f56e97111c1d6b0aeada41..4ec327e763f65ec18346f9dace2e9745c9f01155 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