]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Support inconsistent if opcode used in string/password opcode.
authorydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Dec 2010 06:47:50 +0000 (06:47 +0000)
committerydong10 <ydong10@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 23 Dec 2010 06:47:50 +0000 (06:47 +0000)
2. Add sample code of using inconsistent if opcode in string opcode.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11196 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c
MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
MdeModulePkg/Universal/SetupBrowserDxe/ProcessOptions.c
MdeModulePkg/Universal/SetupBrowserDxe/Setup.c
MdeModulePkg/Universal/SetupBrowserDxe/Ui.c

index efd260512ac62405452aed2dd36d82b5a63b61e4..9b664b4958c50912d98dfe3e2cd2d4f29caa0964 100644 (file)
@@ -910,9 +910,6 @@ DriverCallback (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
 \r
   Status = EFI_SUCCESS;\r
   PrivateData = DRIVER_SAMPLE_PRIVATE_FROM_THIS (This);\r
@@ -1166,6 +1163,15 @@ DriverCallback (
     break;\r
 \r
   case 0x2000:\r
+    //\r
+    // Only used to update the state.\r
+    //\r
+    if ((Type == EFI_IFR_TYPE_STRING) && (Value->string == 0) && \r
+      (PrivateData->PasswordState == BROWSER_STATE_SET_PASSWORD)) {\r
+      PrivateData->PasswordState = BROWSER_STATE_VALIDATE_PASSWORD;\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+\r
     //\r
     // When try to set a new password, user will be chanlleged with old password.\r
     // The Callback is responsible for validating old password input by user,\r
index e82cccc9db5a9d2be08251ad83583c8ecf410394..00982700b7b03f2585852eada595587cf90aa26b 100644 (file)
@@ -285,6 +285,9 @@ formset
               key      = 0x1236,\r
               minsize  = 6,\r
               maxsize  = 40,\r
+              inconsistentif prompt = STRING_TOKEN(STR_STRING_CHECK_ERROR_POPUP),\r
+                pushthis != stringref(STRING_TOKEN(STR_STRING_CHECK))\r
+              endif\r
     endstring;\r
 \r
     //\r
index 4abcfa2cd7344297dd559f3ed9bb25cf9fcbf62f..5b65a1bc1b4af22facac7f96f3efe583e7e815a7 100644 (file)
Binary files a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni and b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni differ
index 4923478954ea7ef19d60d2d9b244150586406d58..314f91b529bb1225677d8e94c5946fa0b8dfbe32 100644 (file)
@@ -542,11 +542,13 @@ DestroyStorage (
 /**\r
   Free resources of a Statement.\r
 \r
+  @param  FormSet                Pointer of the FormSet\r
   @param  Statement              Pointer of the Statement\r
 \r
 **/\r
 VOID\r
 DestroyStatement (\r
+  IN     FORM_BROWSER_FORMSET    *FormSet,\r
   IN OUT FORM_BROWSER_STATEMENT  *Statement\r
   )\r
 {\r
@@ -608,18 +610,23 @@ DestroyStatement (
   if (Statement->BufferValue != NULL) {\r
     FreePool (Statement->BufferValue);\r
   }\r
+  if (Statement->Operand == EFI_IFR_STRING_OP || Statement->Operand == EFI_IFR_PASSWORD_OP) {\r
+    DeleteString(Statement->HiiValue.Value.string, FormSet->HiiHandle);\r
+  }\r
 }\r
 \r
 \r
 /**\r
   Free resources of a Form.\r
 \r
+  @param  FormSet                Pointer of the FormSet\r
   @param  Form                   Pointer of the Form.\r
 \r
 **/\r
 VOID\r
 DestroyForm (\r
-  IN OUT FORM_BROWSER_FORM  *Form\r
+  IN     FORM_BROWSER_FORMSET  *FormSet,\r
+  IN OUT FORM_BROWSER_FORM     *Form\r
   )\r
 {\r
   LIST_ENTRY              *Link;\r
@@ -645,7 +652,7 @@ DestroyForm (
     Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);\r
     RemoveEntryList (&Statement->Link);\r
 \r
-    DestroyStatement (Statement);\r
+    DestroyStatement (FormSet, Statement);\r
   }\r
 \r
   //\r
@@ -731,7 +738,7 @@ DestroyFormSet (
       Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
       RemoveEntryList (&Form->Link);\r
 \r
-      DestroyForm (Form);\r
+      DestroyForm (FormSet, Form);\r
     }\r
   }\r
 \r
@@ -1580,6 +1587,7 @@ ParseOpCodes (
 \r
       CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;\r
       CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth + sizeof (CHAR16));\r
+      CurrentStatement->HiiValue.Value.string = NewString ((CHAR16*) CurrentStatement->BufferValue, FormSet->HiiHandle);\r
 \r
       InitializeRequestElement (FormSet, CurrentStatement);\r
       break;\r
@@ -1598,6 +1606,7 @@ ParseOpCodes (
 \r
       CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;\r
       CurrentStatement->BufferValue = AllocateZeroPool ((CurrentStatement->StorageWidth + sizeof (CHAR16)));\r
+      CurrentStatement->HiiValue.Value.string = NewString ((CHAR16*) CurrentStatement->BufferValue, FormSet->HiiHandle);\r
 \r
       InitializeRequestElement (FormSet, CurrentStatement);\r
       break;\r
index a2704511c29ecf8b0a4380556c304ef86fdb962b..6d9a555b4920c1e33b88f6102a0215d47f835485 100644 (file)
@@ -1103,12 +1103,7 @@ SetupBrowser (
 \r
         HiiValue = &Statement->HiiValue;\r
         TypeValue = &HiiValue->Value;\r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Create String in HII database for Configuration Driver to retrieve\r
-          //\r
-          HiiValue->Value.string = NewString ((CHAR16 *) Statement->BufferValue, Selection->FormSet->HiiHandle);\r
-        } else if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+        if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
           //\r
           // For OrderedList, passing in the value buffer to Callback()\r
           //\r
@@ -1124,13 +1119,6 @@ SetupBrowser (
                                  &ActionRequest\r
                                  );\r
 \r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Clean the String in HII Database\r
-          //\r
-          DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);\r
-        }\r
-\r
         if (!EFI_ERROR (Status)) {\r
           switch (ActionRequest) {\r
           case EFI_BROWSER_ACTION_REQUEST_RESET:\r
index a4d19e0afe042fe6a011b27ee82d0e76cf728126..e654545bf73e84d28c26eb000d495447122c866d 100644 (file)
@@ -302,9 +302,8 @@ PasswordCallback (
   EFI_STATUS                      Status;\r
   EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;\r
   EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
-  EFI_HII_VALUE                   *QuestionValue;\r
+  EFI_IFR_TYPE_VALUE              IfrTypeValue;\r
 \r
-  QuestionValue = &MenuOption->ThisTag->HiiValue;\r
   ConfigAccess = Selection->FormSet->ConfigAccess;\r
   if (ConfigAccess == NULL) {\r
     return EFI_UNSUPPORTED;\r
@@ -314,9 +313,9 @@ PasswordCallback (
   // Prepare password string in HII database\r
   //\r
   if (String != NULL) {\r
-    QuestionValue->Value.string = NewString (String, Selection->FormSet->HiiHandle);\r
+    IfrTypeValue.string = NewString (String, Selection->FormSet->HiiHandle);\r
   } else {\r
-    QuestionValue->Value.string = 0;\r
+    IfrTypeValue.string = 0;\r
   }\r
 \r
   //\r
@@ -326,8 +325,8 @@ PasswordCallback (
                            ConfigAccess,\r
                            EFI_BROWSER_ACTION_CHANGING,\r
                            MenuOption->ThisTag->QuestionId,\r
-                           QuestionValue->Type,\r
-                           &QuestionValue->Value,\r
+                           MenuOption->ThisTag->HiiValue.Type,\r
+                           &IfrTypeValue,\r
                            &ActionRequest\r
                            );\r
 \r
@@ -335,7 +334,7 @@ PasswordCallback (
   // Remove password string from HII database\r
   //\r
   if (String != NULL) {\r
-    DeleteString (QuestionValue->Value.string, Selection->FormSet->HiiHandle);\r
+    DeleteString (IfrTypeValue.string, Selection->FormSet->HiiHandle);\r
   }\r
 \r
   return Status;\r
@@ -402,12 +401,14 @@ ProcessOptions (
   UINTN                           Index2;\r
   UINT8                           *ValueArray;\r
   UINT8                           ValueType;\r
+  EFI_STRING_ID                   StringId;\r
 \r
   Status        = EFI_SUCCESS;\r
 \r
   StringPtr     = NULL;\r
   Character[1]  = L'\0';\r
   *OptionString = NULL;\r
+  StringId      = 0;\r
 \r
   ZeroMem (FormattedNumber, 21 * sizeof (CHAR16));\r
   BufferSize = (gOptionBlockWidth + 1) * 2 * gScreenDimensions.BottomRow;\r
@@ -742,10 +743,16 @@ ProcessOptions (
 \r
       Status = ReadString (MenuOption, gPromptForData, StringPtr);\r
       if (!EFI_ERROR (Status)) {\r
-        CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
-        SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
+        HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, StringPtr, NULL);\r
+        Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);\r
+        if (EFI_ERROR (Status)) {\r
+          HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);\r
+        } else {\r
+          CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
+          SetQuestionValue (Selection->FormSet, Selection->Form, Question, TRUE);\r
 \r
-        UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
+          UpdateStatusBar (NV_UPDATE_REQUIRED, Question->QuestionFlags, TRUE);\r
+        }\r
       }\r
 \r
       FreePool (StringPtr);\r
@@ -890,13 +897,47 @@ ProcessOptions (
       //\r
       if (StrCmp (StringPtr, TempString) == 0) {\r
         //\r
-        // Two password match, send it to Configuration Driver\r
+        // Prepare the  Question->HiiValue.Value.string for ValidateQuestion use.\r
         //\r
-        if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {\r
-          PasswordCallback (Selection, MenuOption, StringPtr);\r
+        if((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {\r
+          StringId = Question->HiiValue.Value.string;\r
+          Question->HiiValue.Value.string = NewString (StringPtr, Selection->FormSet->HiiHandle);\r
         } else {\r
-          CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
-          SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
+          HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, StringPtr, NULL);\r
+        }\r
+        \r
+        Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);\r
+\r
+        //\r
+        //  Researve the Question->HiiValue.Value.string.\r
+        //\r
+        if((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {\r
+          DeleteString(Question->HiiValue.Value.string, Selection->FormSet->HiiHandle);\r
+          Question->HiiValue.Value.string = StringId;\r
+        }   \r
+        \r
+        if (EFI_ERROR (Status)) {\r
+          //\r
+          // Reset state machine for interactive password\r
+          //\r
+          if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {\r
+            PasswordCallback (Selection, MenuOption, NULL);\r
+          } else {\r
+            //\r
+            // Researve the Question->HiiValue.Value.string.\r
+            //\r
+            HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);            \r
+          }\r
+        } else {\r
+          //\r
+          // Two password match, send it to Configuration Driver\r
+          //\r
+          if ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) {\r
+            PasswordCallback (Selection, MenuOption, StringPtr);\r
+          } else {\r
+            CopyMem (Question->BufferValue, StringPtr, Maximum * sizeof (CHAR16));\r
+            SetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
+          }\r
         }\r
       } else {\r
         //\r
index 740ee50d0b82a3a29c8db96d77ae1242b71f6bac..4896a076a57f5ae159242dd5e1d75f8296abe8fc 100644 (file)
@@ -2077,7 +2077,11 @@ LoadFormConfig (
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
-    \r
+\r
+    if ((Question->Operand == EFI_IFR_STRING_OP) || (Question->Operand == EFI_IFR_PASSWORD_OP)) {\r
+      HiiSetString (FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);\r
+    }\r
+\r
     //\r
     // Check whether EfiVarstore with CallBack can be got.\r
     //\r
@@ -2109,12 +2113,7 @@ LoadFormConfig (
         ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
         HiiValue = &Question->HiiValue;\r
         BufferValue = (UINT8 *) &Question->HiiValue.Value;\r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Create String in HII database for Configuration Driver to retrieve\r
-          //\r
-          HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, FormSet->HiiHandle);\r
-        } else if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+        if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
           BufferValue = Question->BufferValue;\r
         }\r
 \r
@@ -2126,14 +2125,6 @@ LoadFormConfig (
                                  (EFI_IFR_TYPE_VALUE *) BufferValue,\r
                                  &ActionRequest\r
                                  );\r
-\r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Clean the String in HII Database\r
-          //\r
-          DeleteString (HiiValue->Value.string, FormSet->HiiHandle);\r
-        }\r
-\r
         if (!EFI_ERROR (Status)) {\r
           switch (ActionRequest) {\r
           case EFI_BROWSER_ACTION_REQUEST_RESET:\r
index 6e851ed7bdeeade944cf02e02297fb72fc1c0e16..36ae3db0da2491cf432184eef88ef04650ee33f5 100644 (file)
@@ -341,7 +341,6 @@ RefreshForm (
   UI_MENU_SELECTION               *Selection;\r
   FORM_BROWSER_STATEMENT          *Question;\r
   EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess;\r
-  EFI_HII_VALUE                   *HiiValue;\r
   EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
 \r
   if (gMenuRefreshHead != NULL) {\r
@@ -384,31 +383,14 @@ RefreshForm (
       ConfigAccess = Selection->FormSet->ConfigAccess;\r
       if (((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) && (ConfigAccess != NULL)) {\r
         ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-\r
-        HiiValue = &Question->HiiValue;\r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Create String in HII database for Configuration Driver to retrieve\r
-          //\r
-          HiiValue->Value.string = NewString ((CHAR16 *) Question->BufferValue, Selection->FormSet->HiiHandle);\r
-        }\r
-\r
         Status = ConfigAccess->Callback (\r
                                  ConfigAccess,\r
                                  EFI_BROWSER_ACTION_CHANGING,\r
                                  Question->QuestionId,\r
-                                 HiiValue->Type,\r
-                                 &HiiValue->Value,\r
+                                 Question->HiiValue.Type,\r
+                                 &Question->HiiValue.Value,\r
                                  &ActionRequest\r
                                  );\r
-\r
-        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
-          //\r
-          // Clean the String in HII Database\r
-          //\r
-          DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);\r
-        }\r
-\r
         if (!EFI_ERROR (Status)) {\r
           switch (ActionRequest) {\r
           case EFI_BROWSER_ACTION_REQUEST_RESET:\r