]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
Sync value for string opcode after call the Callback function.
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Presentation.c
index b3a3d237614c661d2439fd5b8e566ecbd6f2bb79..8f67f86446a3b3bdf7454bbaaa31e209feb6f7cf 100644 (file)
@@ -2092,6 +2092,7 @@ ProcessCallBackFunction (
   BROWSER_SETTING_SCOPE           SettingLevel;\r
   EFI_IFR_TYPE_VALUE              BackUpValue;\r
   UINT8                           *BackUpBuffer;\r
+  CHAR16                          *NewString;\r
 \r
   ConfigAccess = FormSet->ConfigAccess;\r
   SubmitFormIsRequired  = FALSE;\r
@@ -2209,6 +2210,22 @@ ProcessCallBackFunction (
         }\r
       }\r
 \r
+      //\r
+      // Need to sync the value between Statement->HiiValue->Value and Statement->BufferValue\r
+      //\r
+      if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
+        NewString = GetToken (Statement->HiiValue.Value.string, FormSet->HiiHandle);\r
+        ASSERT (NewString != NULL);\r
+\r
+        ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);\r
+        if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {\r
+          CopyMem (Statement->BufferValue, NewString, StrSize (NewString));\r
+        } else {\r
+          CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);\r
+        }\r
+        FreePool (NewString);\r
+      }\r
+\r
       //\r
       // According the spec, return value from call back of "changing" and \r
       // "retrieve" should update to the question's temp buffer.\r
@@ -2277,6 +2294,7 @@ ProcessCallBackFunction (
 \r
   @param ConfigAccess          The config access protocol produced by the hii driver.\r
   @param Statement             The Question which need to call.\r
+  @param FormSet               The formset this question belong to.\r
 \r
   @retval EFI_SUCCESS          The call back function excutes successfully.\r
   @return Other value if the call back function failed to excute.  \r
@@ -2284,13 +2302,15 @@ ProcessCallBackFunction (
 EFI_STATUS \r
 ProcessRetrieveForQuestion (\r
   IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
-  IN     FORM_BROWSER_STATEMENT          *Statement\r
+  IN     FORM_BROWSER_STATEMENT          *Statement,\r
+  IN     FORM_BROWSER_FORMSET            *FormSet\r
   )\r
 {\r
   EFI_STATUS                      Status;\r
   EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
   EFI_HII_VALUE                   *HiiValue;\r
   EFI_IFR_TYPE_VALUE              *TypeValue;\r
+  CHAR16                          *NewString;\r
 \r
   Status                = EFI_SUCCESS;\r
   ActionRequest         = EFI_BROWSER_ACTION_REQUEST_NONE;\r
@@ -2317,6 +2337,19 @@ ProcessRetrieveForQuestion (
                            TypeValue,\r
                            &ActionRequest\r
                            );\r
+  if (!EFI_ERROR (Status) && HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
+    NewString = GetToken (Statement->HiiValue.Value.string, FormSet->HiiHandle);\r
+    ASSERT (NewString != NULL);\r
+\r
+    ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth);\r
+    if (StrLen (NewString) * sizeof (CHAR16) <= Statement->StorageWidth) {\r
+      CopyMem (Statement->BufferValue, NewString, StrSize (NewString));\r
+    } else {\r
+      CopyMem (Statement->BufferValue, NewString, Statement->StorageWidth);\r
+    }\r
+    FreePool (NewString);\r
+  }\r
+\r
   return Status;\r
 }\r
 \r