]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c
MdeModulePkg BootMaintenanceManagerUiLib: Move refresh boot option later
[mirror_edk2.git] / MdeModulePkg / Library / BootMaintenanceManagerUiLib / BootMaintenance.c
index f40c61a0fb909877ef8a070fdba9808685375bca..fdcb56a9df2b5d7012767eef22c980f12d6d31dc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 The functions for Boot Maintainence Main menu.\r
 \r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -571,6 +571,7 @@ UpdateTerminalContent (
 /**\r
   Update the console content in ConsoleMenu.\r
 \r
+  @param ConsoleName       The name for the console device type.\r
   @param BmmData           The BMM fake NV data.\r
 \r
 **/\r
@@ -1110,6 +1111,7 @@ BootMaintCallback (
         // 2. Re-scan the BootOption menus (including the legacy boot option).\r
         //\r
         CustomizeMenus ();\r
+        EfiBootManagerRefreshAllBootOption ();\r
         BOpt_GetBootOptions (Private);\r
         mFirstEnterBMMForm = TRUE;\r
       }\r
@@ -1213,9 +1215,11 @@ BootMaintCallback (
     }\r
    \r
     if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_BOOT) {\r
+      CleanUselessBeforeSubmit (Private);\r
       CurrentFakeNVMap->BootOptionChanged = FALSE;\r
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
     } else if (QuestionId == KEY_VALUE_SAVE_AND_EXIT_DRIVER) {\r
+      CleanUselessBeforeSubmit (Private);\r
       CurrentFakeNVMap->DriverOptionChanged = FALSE;\r
       *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
     } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT_DRIVER) {\r
@@ -1268,6 +1272,7 @@ BootMaintCallback (
       case KEY_VALUE_SAVE_AND_EXIT:\r
       case KEY_VALUE_NO_SAVE_AND_EXIT:\r
         if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {\r
+          CleanUselessBeforeSubmit (Private);\r
           *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
         } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {\r
           DiscardChangeHandler (Private, CurrentFakeNVMap);\r
@@ -1298,7 +1303,7 @@ BootMaintCallback (
     } else if ((QuestionId >= CON_OUT_DEVICE_QUESTION_ID) && (QuestionId < CON_OUT_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {\r
       UpdateConsoleContent (L"ConOut", CurrentFakeNVMap);\r
     } else if ((QuestionId >= CON_ERR_DEVICE_QUESTION_ID) && (QuestionId < CON_ERR_DEVICE_QUESTION_ID + MAX_MENU_NUMBER)) {\r
-      UpdateConsoleContent (L"ConErr", CurrentFakeNVMap);\r
+      UpdateConsoleContent (L"ErrOut", CurrentFakeNVMap);\r
     }\r
   }\r
 \r
@@ -1369,6 +1374,36 @@ DiscardChangeHandler (
   }\r
 }\r
 \r
+/**\r
+  This function is to clean some useless data before submit changes.\r
+\r
+  @param Private            The BMM context data.\r
+\r
+**/\r
+VOID\r
+CleanUselessBeforeSubmit (\r
+  IN  BMM_CALLBACK_DATA               *Private\r
+  )\r
+{\r
+  UINT16  Index;\r
+  if (Private->BmmPreviousPageId != FORM_BOOT_DEL_ID) {\r
+    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+      if (Private->BmmFakeNvData.BootOptionDel[Index] && !Private->BmmFakeNvData.BootOptionDelMark[Index]) {\r
+        Private->BmmFakeNvData.BootOptionDel[Index] = FALSE;\r
+        Private->BmmOldFakeNVData.BootOptionDel[Index] = FALSE;\r
+      }\r
+    }\r
+  }\r
+  if (Private->BmmPreviousPageId != FORM_DRV_DEL_ID) {\r
+    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+      if (Private->BmmFakeNvData.DriverOptionDel[Index] && !Private->BmmFakeNvData.DriverOptionDelMark[Index]) {\r
+        Private->BmmFakeNvData.DriverOptionDel[Index] = FALSE;\r
+        Private->BmmOldFakeNVData.DriverOptionDel[Index] = FALSE;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
 /**\r
 \r
   Update the menus in the BMM page.\r
@@ -1656,8 +1691,6 @@ BootMaintenanceManagerUiLibConstructor (
   Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &mBmmCallbackInfo->FormBrowser2);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  EfiBootManagerRefreshAllBootOption ();\r
-\r
   //\r
   // Create LoadOption in BmmCallbackInfo for Driver Callback\r
   //\r