]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Ui.c
K8:
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Ui.c
index fc715fea5b65567a543ec1904b08c32a96554b1c..cc9652ee1767cb18c8216822bb11e19e4e5e3c08 100644 (file)
@@ -117,6 +117,7 @@ SCREEN_OPERATION_T0_CONTROL_FLAG  gScreenOperationToControlFlag[] = {
 };\r
 \r
 BOOLEAN  mInputError;\r
+BOOLEAN GetLineByWidthFinished = FALSE;\r
 \r
 \r
 /**\r
@@ -190,7 +191,7 @@ UiRemoveMenuListEntry (
     Selection->FormId = UiMenuList->FormId;\r
     Selection->QuestionId = UiMenuList->QuestionId;\r
     RemoveEntryList (&UiMenuList->MenuLink);\r
-    gBS->FreePool (UiMenuList);\r
+    FreePool (UiMenuList);\r
   }\r
 }\r
 \r
@@ -209,7 +210,7 @@ UiFreeMenuList (
   while (!IsListEmpty (&gMenuList)) {\r
     UiMenuList = CR (gMenuList.ForwardLink, UI_MENU_LIST, MenuLink, UI_MENU_LIST_SIGNATURE);\r
     RemoveEntryList (&UiMenuList->MenuLink);\r
-    gBS->FreePool (UiMenuList);\r
+    FreePool (UiMenuList);\r
   }\r
 }\r
 \r
@@ -262,9 +263,9 @@ UiFreeMenu (
       // Data format :      [01/02/2004]      [11:22:33]\r
       // Line number :        0  0    1         0  0  1\r
       //\r
-      gBS->FreePool (MenuOption->Description);\r
+      FreePool (MenuOption->Description);\r
     }\r
-    gBS->FreePool (MenuOption);\r
+    FreePool (MenuOption);\r
   }\r
 }\r
 \r
@@ -282,7 +283,7 @@ UiFreeRefreshList (
 \r
   while (gMenuRefreshHead != NULL) {\r
     OldMenuRefreshEntry = gMenuRefreshHead->Next;\r
-    gBS->FreePool (gMenuRefreshHead);\r
+    FreePool (gMenuRefreshHead);\r
     gMenuRefreshHead = OldMenuRefreshEntry;\r
   }\r
 \r
@@ -295,66 +296,122 @@ UiFreeRefreshList (
   Refresh screen.\r
 \r
 **/\r
-VOID\r
+EFI_STATUS\r
 RefreshForm (\r
   VOID\r
   )\r
 {\r
-  CHAR16                  *OptionString;\r
-  MENU_REFRESH_ENTRY      *MenuRefreshEntry;\r
-  UINTN                   Index;\r
-  UINTN                   Loop;\r
-  EFI_STATUS              Status;\r
-  UI_MENU_SELECTION       *Selection;\r
-  FORM_BROWSER_STATEMENT  *Question;\r
-\r
-  OptionString = NULL;\r
+  CHAR16                          *OptionString;\r
+  MENU_REFRESH_ENTRY              *MenuRefreshEntry;\r
+  UINTN                           Index;\r
+  EFI_STATUS                      Status;\r
+  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
 \r
     MenuRefreshEntry = gMenuRefreshHead;\r
 \r
+    //\r
+    // Reset FormPackage update flag\r
+    //\r
+    mHiiPackageListUpdated = FALSE;\r
+\r
     do {\r
       gST->ConOut->SetAttribute (gST->ConOut, MenuRefreshEntry->CurrentAttribute);\r
 \r
       Selection = MenuRefreshEntry->Selection;\r
       Question = MenuRefreshEntry->MenuOption->ThisTag;\r
 \r
+      Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
+      if (EFI_ERROR (Status)) {\r
+        return Status;\r
+      }\r
+\r
+      OptionString = NULL;\r
+      ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);\r
+\r
+      if (OptionString != NULL) {\r
+        //\r
+        // If leading spaces on OptionString - remove the spaces\r
+        //\r
+        for (Index = 0; OptionString[Index] == L' '; Index++)\r
+          ;\r
+\r
+        PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, &OptionString[Index]);\r
+        FreePool (OptionString);\r
+      }\r
+\r
       //\r
-      // Don't update Question being edited\r
+      // Question value may be changed, need invoke its Callback()\r
       //\r
-      if (Question != MenuRefreshEntry->Selection->Statement) {\r
+      ConfigAccess = Selection->FormSet->ConfigAccess;\r
+      if (((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != 0) && (ConfigAccess != NULL)) {\r
+        ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
 \r
-        Status = GetQuestionValue (Selection->FormSet, Selection->Form, Question, FALSE);\r
-        if (EFI_ERROR (Status)) {\r
-          return;\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
-        ProcessOptions (Selection, MenuRefreshEntry->MenuOption, FALSE, &OptionString);\r
+        Status = ConfigAccess->Callback (\r
+                                 ConfigAccess,\r
+                                 EFI_BROWSER_ACTION_CHANGING,\r
+                                 Question->QuestionId,\r
+                                 HiiValue->Type,\r
+                                 &HiiValue->Value,\r
+                                 &ActionRequest\r
+                                 );\r
 \r
-        if (OptionString != NULL) {\r
+        if (HiiValue->Type == EFI_IFR_TYPE_STRING) {\r
           //\r
-          // If leading spaces on OptionString - remove the spaces\r
+          // Clean the String in HII Database\r
           //\r
-          for (Index = 0; OptionString[Index] == L' '; Index++)\r
-            ;\r
+          DeleteString (HiiValue->Value.string, Selection->FormSet->HiiHandle);\r
+        }\r
 \r
-          for (Loop = 0; OptionString[Index] != CHAR_NULL; Index++) {\r
-            OptionString[Loop] = OptionString[Index];\r
-            Loop++;\r
-          }\r
+        if (!EFI_ERROR (Status)) {\r
+          switch (ActionRequest) {\r
+          case EFI_BROWSER_ACTION_REQUEST_RESET:\r
+            gResetRequired = TRUE;\r
+            break;\r
 \r
-          OptionString[Loop] = CHAR_NULL;\r
+          case EFI_BROWSER_ACTION_REQUEST_SUBMIT:\r
+            SubmitForm (Selection->FormSet, Selection->Form);\r
+            break;\r
 \r
-          PrintStringAt (MenuRefreshEntry->CurrentColumn, MenuRefreshEntry->CurrentRow, OptionString);\r
-          gBS->FreePool (OptionString);\r
+          case EFI_BROWSER_ACTION_REQUEST_EXIT:\r
+            Selection->Action = UI_ACTION_EXIT;\r
+            gNvUpdateRequired = FALSE;\r
+            break;\r
+\r
+          default:\r
+            break;\r
+          }\r
         }\r
       }\r
 \r
       MenuRefreshEntry = MenuRefreshEntry->Next;\r
 \r
     } while (MenuRefreshEntry != NULL);\r
+\r
+    if (mHiiPackageListUpdated) {\r
+      //\r
+      // Package list is updated, force to reparse IFR binary of target Formset\r
+      //\r
+      mHiiPackageListUpdated = FALSE;\r
+      Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
+      return EFI_SUCCESS;\r
+    }\r
   }\r
+\r
+  return EFI_TIMEOUT;\r
 }\r
 \r
 \r
@@ -446,7 +503,7 @@ UiWaitForSingleEvent (
       if (!EFI_ERROR (Status) && Index == 1) {\r
         Status = EFI_TIMEOUT;\r
         if (RefreshInterval != 0) {\r
-          RefreshForm ();\r
+          Status = RefreshForm ();\r
         }\r
       }\r
 \r
@@ -672,8 +729,8 @@ CreateDialog (
       case CHAR_NULL:\r
         switch (Key.ScanCode) {\r
         case SCAN_ESC:\r
-          gBS->FreePool (TempString);\r
-          gBS->FreePool (BufferedString);\r
+          FreePool (TempString);\r
+          FreePool (BufferedString);\r
           gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r
           gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
           return EFI_DEVICE_ERROR;\r
@@ -686,8 +743,8 @@ CreateDialog (
 \r
       case CHAR_CARRIAGE_RETURN:\r
         SelectionComplete = TRUE;\r
-        gBS->FreePool (TempString);\r
-        gBS->FreePool (BufferedString);\r
+        FreePool (TempString);\r
+        FreePool (BufferedString);\r
         gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);\r
         gST->ConOut->EnableCursor (gST->ConOut, TRUE);\r
         return EFI_SUCCESS;\r
@@ -961,8 +1018,8 @@ UpdateStatusBar (
     break;\r
   }\r
 \r
-  gBS->FreePool (InputErrorMessage);\r
-  gBS->FreePool (NvUpdateMessage);\r
+  FreePool (InputErrorMessage);\r
+  FreePool (NvUpdateMessage);\r
   return ;\r
 }\r
 \r
@@ -994,7 +1051,7 @@ GetWidth (
   if ((Statement->Operand == EFI_IFR_TEXT_OP) && (Statement->TextTwo != 0)) {\r
     String = GetToken (Statement->TextTwo, Handle);\r
     Size   = StrLen (String);\r
-    gBS->FreePool (String);\r
+    FreePool (String);\r
   }\r
 \r
   if ((Statement->Operand == EFI_IFR_SUBTITLE_OP) ||\r
@@ -1019,9 +1076,6 @@ GetWidth (
   return Width;\r
 }\r
 \r
-\r
-BOOLEAN GetLineByWidthFinished = FALSE;\r
-\r
 /**\r
   Will copy LineWidth amount of a string in the OutputString buffer and return the\r
   number of CHAR16 characters that were copied into the OutputString buffer.\r
@@ -1178,7 +1232,7 @@ UpdateOptionSkipLines (
         }\r
       }\r
 \r
-      gBS->FreePool (OutputString);\r
+      FreePool (OutputString);\r
       if (SkipValue != 0) {\r
         SkipValue--;\r
       }\r
@@ -1585,7 +1639,7 @@ UiDisplayMenu (
               }\r
             }\r
 \r
-            gBS->FreePool (OutputString);\r
+            FreePool (OutputString);\r
             if (Temp != 0) {\r
               Temp--;\r
             }\r
@@ -1595,7 +1649,16 @@ UiDisplayMenu (
           Row   = OriginalRow;\r
 \r
           gST->ConOut->SetAttribute (gST->ConOut, FIELD_TEXT | FIELD_BACKGROUND);\r
-          ProcessOptions (Selection, MenuOption, FALSE, &OptionString);\r
+          Status = ProcessOptions (Selection, MenuOption, FALSE, &OptionString);\r
+          if (EFI_ERROR (Status)) {\r
+            //\r
+            // Repaint to clear possible error prompt pop-up\r
+            //\r
+            Repaint = TRUE;\r
+            NewLine = TRUE;\r
+            ControlFlag = CfRepaint;\r
+            break;\r
+          }\r
 \r
           if (OptionString != NULL) {\r
             if (Statement->Operand == EFI_IFR_DATE_OP || Statement->Operand == EFI_IFR_TIME_OP) {\r
@@ -1681,7 +1744,7 @@ UiDisplayMenu (
                 }\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
               if (Temp2 != 0) {\r
                 Temp2--;\r
               }\r
@@ -1690,7 +1753,7 @@ UiDisplayMenu (
             Temp2 = 0;\r
             Row   = OriginalRow;\r
 \r
-            gBS->FreePool (OptionString);\r
+            FreePool (OptionString);\r
           }\r
           //\r
           // If this is a text op with secondary text information\r
@@ -1724,14 +1787,14 @@ UiDisplayMenu (
                 }\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
               if (Temp2 != 0) {\r
                 Temp2--;\r
               }\r
             }\r
 \r
             Row = OriginalRow;\r
-            gBS->FreePool (StringPtr);\r
+            FreePool (StringPtr);\r
           }\r
 \r
           //\r
@@ -1886,12 +1949,12 @@ UiDisplayMenu (
                 MenuOption->Row++;\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
             }\r
 \r
             MenuOption->Row = OriginalRow;\r
 \r
-            gBS->FreePool (OptionString);\r
+            FreePool (OptionString);\r
           } else {\r
             if (NewLine) {\r
               if (MenuOption->GrayOut) {\r
@@ -1914,7 +1977,7 @@ UiDisplayMenu (
                   MenuOption->Row++;\r
                 }\r
 \r
-                gBS->FreePool (OutputString);\r
+                FreePool (OutputString);\r
               }\r
 \r
               MenuOption->Row = OriginalRow;\r
@@ -1992,12 +2055,12 @@ UiDisplayMenu (
               MenuOption->Row++;\r
             }\r
 \r
-            gBS->FreePool (OutputString);\r
+            FreePool (OutputString);\r
           }\r
 \r
           MenuOption->Row = OriginalRow;\r
 \r
-          gBS->FreePool (OptionString);\r
+          FreePool (OptionString);\r
         } else {\r
           if (NewLine) {\r
             OriginalRow = MenuOption->Row;\r
@@ -2015,7 +2078,7 @@ UiDisplayMenu (
                 MenuOption->Row++;\r
               }\r
 \r
-              gBS->FreePool (OutputString);\r
+              FreePool (OutputString);\r
             }\r
 \r
             MenuOption->Row = OriginalRow;\r
@@ -2023,12 +2086,8 @@ UiDisplayMenu (
           }\r
         }\r
 \r
-        if (((NewPos->ForwardLink != &Menu) && (ScreenOperation == UiDown)) ||\r
-            ((NewPos->BackLink != &Menu) && (ScreenOperation == UiUp)) ||\r
-            (ScreenOperation == UiNoOperation)\r
-            ) {\r
-          UpdateKeyHelp (MenuOption, FALSE);\r
-        }\r
+        UpdateKeyHelp (MenuOption, FALSE);\r
+\r
         //\r
         // Clear reverse attribute\r
         //\r
@@ -2095,17 +2154,22 @@ UiDisplayMenu (
         Status = UiWaitForSingleEvent (gST->ConIn->WaitForKey, 0, MinRefreshInterval);\r
       } while (Status == EFI_TIMEOUT);\r
 \r
-      if (Status == EFI_TIMEOUT) {\r
-        Key.UnicodeChar = CHAR_CARRIAGE_RETURN;\r
-      } else {\r
-        Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+      if (Selection->Action == UI_ACTION_REFRESH_FORMSET) {\r
         //\r
-        // if we encounter error, continue to read another key in.\r
+        // IFR is updated in Callback of refresh opcode, re-parse it\r
         //\r
-        if (EFI_ERROR (Status)) {\r
-          ControlFlag = CfReadKey;\r
-          continue;\r
-        }\r
+        ControlFlag = CfUiReset;\r
+        Selection->Statement = NULL;\r
+        break;\r
+      }\r
+\r
+      Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+      //\r
+      // if we encounter error, continue to read another key in.\r
+      //\r
+      if (EFI_ERROR (Status)) {\r
+        ControlFlag = CfReadKey;\r
+        break;\r
       }\r
 \r
       if (IsListEmpty (&Menu) && Key.UnicodeChar != CHAR_NULL) {\r
@@ -2138,6 +2202,13 @@ UiDisplayMenu (
             gDirection = SCAN_LEFT;\r
           }\r
           Status = ProcessOptions (Selection, MenuOption, TRUE, &OptionString);\r
+          if (EFI_ERROR (Status)) {\r
+            //\r
+            // Repaint to clear possible error prompt pop-up\r
+            //\r
+            Repaint = TRUE;\r
+            NewLine = TRUE;\r
+          }\r
           if (OptionString != NULL) {\r
             FreePool (OptionString);\r
           }\r
@@ -2299,8 +2370,8 @@ UiDisplayMenu (
             break;\r
           }\r
 \r
-          gBS->FreePool (StringPtr);\r
-          gBS->FreePool (DevicePath);\r
+          FreePool (StringPtr);\r
+          FreePool (DevicePath);\r
 \r
           CopyMem (&Selection->FormSetGuid, &Statement->RefFormSetId, sizeof (EFI_GUID));\r
           Selection->FormId = Statement->RefFormId;\r
@@ -2378,15 +2449,14 @@ UiDisplayMenu (
         if (EFI_ERROR (Status)) {\r
           Repaint = TRUE;\r
           NewLine = TRUE;\r
-          break;\r
-        }\r
-\r
-        if (OptionString != NULL) {\r
-          PrintStringAt (LocalScreen.LeftColumn + gPromptBlockWidth + 1, MenuOption->Row, OptionString);\r
-          gBS->FreePool (OptionString);\r
-        }\r
+            UpdateKeyHelp (MenuOption, FALSE);\r
+          } else {\r
+            Selection->Action = UI_ACTION_REFRESH_FORM;\r
+          }\r
 \r
-        Selection->Action = UI_ACTION_REFRESH_FORM;\r
+          if (OptionString != NULL) {\r
+            FreePool (OptionString);\r
+          }\r
         break;\r
       }\r
       break;\r