]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Sync value for string opcode after call the Callback function.
authorEric Dong <eric.dong@intel.com>
Fri, 11 Apr 2014 06:15:57 +0000 (06:15 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 11 Apr 2014 06:15:57 +0000 (06:15 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming, Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15448 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.h

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
index 35bd04b16bc51d2d012d8bb0bf54e0f266217507..d7536e7ba539f26ed5a100aa00f971d923b67e0b 100644 (file)
@@ -2993,6 +2993,7 @@ GetQuestionDefault (
   EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;\r
   EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
   INTN                            Action;\r
+  CHAR16                          *NewString;\r
 \r
   Status   = EFI_NOT_FOUND;\r
   StrValue = NULL;\r
@@ -3030,6 +3031,19 @@ GetQuestionDefault (
                              &ActionRequest\r
                              );\r
     if (!EFI_ERROR (Status)) {\r
+      if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
+        NewString = GetToken (Question->HiiValue.Value.string, FormSet->HiiHandle);\r
+        ASSERT (NewString != NULL);\r
+\r
+        ASSERT (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth);\r
+        if (StrLen (NewString) * sizeof (CHAR16) <= Question->StorageWidth) {\r
+          CopyMem (Question->BufferValue, NewString, StrSize (NewString));\r
+        } else {\r
+          CopyMem (Question->BufferValue, NewString, Question->StorageWidth);\r
+        }\r
+\r
+        FreePool (NewString);\r
+      }\r
       return Status;\r
     }\r
   }\r
@@ -3307,7 +3321,7 @@ ExtractDefault (
         //\r
         // Call the Retrieve call back to get the initial question value.\r
         //\r
-        Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question);\r
+        Status = ProcessRetrieveForQuestion(FormSet->ConfigAccess, Question, FormSet);\r
       }\r
 \r
       //\r
index 50ab1fa6fd2a77392431bd902b46bc8148789227..b47c402c9ee102e76e0b32025c36865a5cdbae64 100644 (file)
@@ -1205,6 +1205,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
@@ -1212,7 +1213,8 @@ 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
 /**\r