]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe: Add support for PCD PcdPteMemoryEn...
[mirror_edk2.git] / MdeModulePkg / Universal / DisplayEngineDxe / FormDisplay.c
index 938cce41410609f96fbafc7e8fc1a68d3b0b4895..0eb7dddf7baad2cb7e416fa2e25c1c8ee956593f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Entry and initialization module for the browser.\r
 \r
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -49,7 +49,7 @@ SCAN_CODE_TO_SCREEN_OPERATION     gScanCodeToOperation[] = {
   }\r
 };\r
 \r
-UINTN mScanCodeNumber = sizeof (gScanCodeToOperation) / sizeof (gScanCodeToOperation[0]);\r
+UINTN mScanCodeNumber = ARRAY_SIZE (gScanCodeToOperation);\r
 \r
 SCREEN_OPERATION_T0_CONTROL_FLAG  gScreenOperationToControlFlag[] = {\r
   {\r
@@ -153,6 +153,7 @@ CHAR16            *gConfirmOptYes;
 CHAR16            *gConfirmOptNo;\r
 CHAR16            *gConfirmMsgConnect;\r
 CHAR16            *gConfirmMsgEnd;\r
+CHAR16            *gPasswordUnsupported;\r
 CHAR16            gModalSkipColumn;\r
 CHAR16            gPromptBlockWidth;\r
 CHAR16            gOptionBlockWidth;\r
@@ -248,6 +249,7 @@ InitializeDisplayStrings (
   gConfirmOptNo         = GetToken (STRING_TOKEN (CONFIRM_OPTION_NO), gHiiHandle);\r
   gConfirmMsgConnect    = GetToken (STRING_TOKEN (CONFIRM_OPTION_CONNECT), gHiiHandle);\r
   gConfirmMsgEnd        = GetToken (STRING_TOKEN (CONFIRM_OPTION_END), gHiiHandle);\r
+  gPasswordUnsupported  = GetToken (STRING_TOKEN (PASSWORD_NOT_SUPPORTED ), gHiiHandle);\r
 }\r
 \r
 /**\r
@@ -301,6 +303,7 @@ FreeDisplayStrings (
   FreePool (gConfirmOptNo);\r
   FreePool (gConfirmMsgConnect);\r
   FreePool (gConfirmMsgEnd);\r
+  FreePool (gPasswordUnsupported);\r
 }\r
 \r
 /**\r
@@ -604,7 +607,6 @@ UiAddMenuOption (
   UI_MENU_OPTION   *MenuOption;\r
   UINTN            Index;\r
   UINTN            Count;\r
-  CHAR16           *String;\r
   UINT16           NumberOfLines;\r
   UINT16           GlyphWidth;\r
   UINT16           Width;\r
@@ -621,9 +623,6 @@ UiAddMenuOption (
   PromptId = GetPrompt (Statement->OpCode);\r
   ASSERT (PromptId != 0);\r
 \r
-  String = GetToken (PromptId, gFormData->HiiHandle);\r
-  ASSERT (String != NULL);\r
-\r
   if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP || Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {\r
     Count = 3;\r
   }\r
@@ -633,7 +632,7 @@ UiAddMenuOption (
     ASSERT (MenuOption);\r
 \r
     MenuOption->Signature   = UI_MENU_OPTION_SIGNATURE;\r
-    MenuOption->Description = String;\r
+    MenuOption->Description = GetToken (PromptId, gFormData->HiiHandle);\r
     MenuOption->Handle      = gFormData->HiiHandle;\r
     MenuOption->ThisTag     = Statement;\r
     MenuOption->NestInStatement = NestIn;\r
@@ -697,11 +696,11 @@ UiAddMenuOption (
       (Statement->OpCode->OpCode != EFI_IFR_DATE_OP) && \r
       (Statement->OpCode->OpCode != EFI_IFR_TIME_OP)) {\r
       Width  = GetWidth (MenuOption, NULL);\r
-      for (; GetLineByWidth (String, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {\r
+      for (; GetLineByWidth (MenuOption->Description, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) {\r
         //\r
         // If there is more string to process print on the next row and increment the Skip value\r
         //\r
-        if (StrLen (&String[ArrayEntry]) != 0) {\r
+        if (StrLen (&MenuOption->Description[ArrayEntry]) != 0) {\r
           NumberOfLines++;\r
         }\r
         FreePool (OutputString);\r
@@ -1054,12 +1053,8 @@ MoveToNextStatement (
       UpdateOptionSkipLines (NextMenuOption);\r
     }\r
 \r
-    if (IsSelectable (NextMenuOption)) {\r
-      break;\r
-    }\r
-\r
     //\r
-    // In this case, still can't find the selectable menu,\r
+    // Check whether the menu is beyond current showing form,\r
     // return the first one beyond the showing form.\r
     //\r
     if ((UINTN) Distance + NextMenuOption->Skip > GapToTop) {\r
@@ -1069,6 +1064,13 @@ MoveToNextStatement (
       break;\r
     }\r
 \r
+    //\r
+    // return the selectable menu in the showing form.\r
+    //\r
+    if (IsSelectable (NextMenuOption)) {\r
+      break;\r
+    }\r
+\r
     Distance += NextMenuOption->Skip;\r
 \r
     //\r
@@ -1831,7 +1833,7 @@ FindTopMenu (
       }\r
     } else {\r
       //\r
-      // Last time highlight menu has disappear, find the first highlightable menu as the defalut one.\r
+      // Last time highlight menu has disappear, find the first highlightable menu as the default one.\r
       //\r
       *HighlightMenu = gMenuOption.ForwardLink;\r
       if (!IsListEmpty (&gMenuOption)) {\r
@@ -2949,7 +2951,7 @@ UiDisplayMenu (
           //\r
           if (HelpLine > 2 * RowCount - 2) {\r
             HelpPageCount = (HelpLine - RowCount + 1) / (RowCount - 2) + 1;\r
-            if ((HelpLine - RowCount + 1) % (RowCount - 2) > 1) {\r
+            if ((HelpLine - RowCount + 1) % (RowCount - 2) != 0) {\r
               HelpPageCount += 1;\r
             }\r
           } else {\r
@@ -3252,7 +3254,7 @@ UiDisplayMenu (
       }\r
 \r
       for (Index = 0;\r
-           Index < sizeof (gScreenOperationToControlFlag) / sizeof (gScreenOperationToControlFlag[0]);\r
+           Index < ARRAY_SIZE (gScreenOperationToControlFlag);\r
            Index++\r
           ) {\r
         if (ScreenOperation == gScreenOperationToControlFlag[Index].ScreenOperation) {\r
@@ -3729,6 +3731,34 @@ UiDisplayMenu (
   }\r
 }\r
 \r
+/**\r
+  Free the UI Menu Option structure data.\r
+\r
+  @param   MenuOptionList         Point to the menu option list which need to be free.\r
+\r
+**/\r
+VOID\r
+FreeMenuOptionData(\r
+  LIST_ENTRY           *MenuOptionList\r
+  )\r
+{\r
+  LIST_ENTRY           *Link;\r
+  UI_MENU_OPTION       *Option;\r
+\r
+  //\r
+  // Free menu option list\r
+  //\r
+  while (!IsListEmpty (MenuOptionList)) {\r
+    Link = GetFirstNode (MenuOptionList);\r
+    Option = MENU_OPTION_FROM_LINK (Link);\r
+    if (Option->Description != NULL){\r
+      FreePool(Option->Description);\r
+    }\r
+    RemoveEntryList (&Option->Link);\r
+    FreePool (Option);\r
+  }\r
+}\r
+\r
 /**\r
 \r
   Base on the browser status info to show an pop up message.\r
@@ -4001,6 +4031,11 @@ FormDisplay (
   CopyGuid (&gOldFormEntry.FormSetGuid, &FormData->FormSetGuid);\r
   gOldFormEntry.FormId    = FormData->FormId;\r
 \r
+  //\r
+  //Free the Ui menu option list.\r
+  //\r
+  FreeMenuOptionData(&gMenuOption);\r
+\r
   return Status;\r
 }\r
 \r