Update for IntelFrameworkModulePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / BootMaint.c
index 4c8e3c8..d3215a3 100644 (file)
@@ -286,31 +286,36 @@ BootMaintCallback (
   UINT8             *NewLegacyDev;\r
   UINT8             *DisMap;\r
   EFI_FORM_ID       FormId;\r
-  Status = EFI_SUCCESS;\r
 \r
+  if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) {    \r
+    //\r
+    // All other action return unsupported.\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+  \r
+  Status       = EFI_SUCCESS;\r
+  OldValue     = 0;\r
+  NewValue     = 0;\r
+  Number       = 0;\r
+  OldLegacyDev = NULL;\r
+  NewLegacyDev = NULL;\r
+  NewValuePos  = 0;\r
+  DisMap       = NULL;\r
+\r
+  Private      = BMM_CALLBACK_DATA_FROM_THIS (This);\r
+  //\r
+  // Retrive uncommitted data from Form Browser\r
+  //\r
+  CurrentFakeNVMap = &Private->BmmFakeNvData;\r
+  HiiGetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);\r
   if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
-    if ((Value == NULL) || (ActionRequest == NULL)) {\r
+    if (Value == NULL) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
-\r
-    OldValue       = 0;\r
-    NewValue       = 0;\r
-    Number         = 0;\r
-    OldLegacyDev   = NULL;\r
-    NewLegacyDev   = NULL;\r
-    NewValuePos    = 0;\r
-    DisMap         = NULL;\r
-    *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
-\r
-    Private        = BMM_CALLBACK_DATA_FROM_THIS (This);\r
+    \r
     UpdatePageId (Private, QuestionId);\r
 \r
-    //\r
-    // Retrive uncommitted data from Form Browser\r
-    //\r
-    CurrentFakeNVMap = &Private->BmmFakeNvData;\r
-    HiiGetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap);\r
-\r
     //\r
     // need to be subtituded.\r
     //\r
@@ -488,29 +493,14 @@ BootMaintCallback (
         switch (QuestionId) {\r
         case KEY_VALUE_BOOT_FROM_FILE:\r
           Private->FeCurrentState = FileExplorerStateBootFromFile;\r
-\r
-          //\r
-          // Exit Bmm main formset to send File Explorer formset.\r
-          //\r
-          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
           break;\r
 \r
         case FORM_BOOT_ADD_ID:\r
           Private->FeCurrentState = FileExplorerStateAddBootOption;\r
-\r
-          //\r
-          // Exit Bmm main formset to send File Explorer formset.\r
-          //\r
-          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
           break;\r
 \r
         case FORM_DRV_ADD_FILE_ID:\r
           Private->FeCurrentState = FileExplorerStateAddDriverOptionState;\r
-\r
-          //\r
-          // Exit Bmm main formset to send File Explorer formset.\r
-          //\r
-          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
           break;\r
 \r
         case FORM_DRV_ADD_HANDLE_ID:\r
@@ -543,10 +533,6 @@ BootMaintCallback (
           UpdateTimeOutPage (Private);\r
           break;\r
 \r
-        case FORM_RESET:\r
-          gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
-          return EFI_UNSUPPORTED;\r
-\r
         case FORM_CON_IN_ID:\r
         case FORM_CON_OUT_ID:\r
         case FORM_CON_ERR_ID:\r
@@ -572,25 +558,6 @@ BootMaintCallback (
           UpdateSetLegacyDeviceOrderPage (QuestionId, Private);\r
           break;\r
 \r
-        case KEY_VALUE_SAVE_AND_EXIT:\r
-        case KEY_VALUE_NO_SAVE_AND_EXIT:\r
-\r
-          if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {\r
-            Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);\r
-            if (EFI_ERROR (Status)) {\r
-              return Status;\r
-            }\r
-          } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {\r
-            DiscardChangeHandler (Private, CurrentFakeNVMap);\r
-          }\r
-\r
-          //\r
-          // Tell browser not to ask for confirmation of changes,\r
-          // since we have already applied or discarded.\r
-          //\r
-          *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;\r
-          break;\r
-\r
         default:\r
           break;\r
         }\r
@@ -616,18 +583,44 @@ BootMaintCallback (
         UpdateDriverAddHandleDescPage (Private);\r
       }\r
     }\r
+  } else if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
+    if ((Value == NULL) || (ActionRequest == NULL)) {\r
+      return EFI_INVALID_PARAMETER;\r
+    }\r
+    \r
+    switch (QuestionId) {\r
+    case KEY_VALUE_SAVE_AND_EXIT:\r
+    case KEY_VALUE_NO_SAVE_AND_EXIT:\r
+      if (QuestionId == KEY_VALUE_SAVE_AND_EXIT) {\r
+        Status = ApplyChangeHandler (Private, CurrentFakeNVMap, Private->BmmPreviousPageId);\r
+        if (EFI_ERROR (Status)) {\r
+          return Status;\r
+        }\r
+      } else if (QuestionId == KEY_VALUE_NO_SAVE_AND_EXIT) {\r
+        DiscardChangeHandler (Private, CurrentFakeNVMap);\r
+      }\r
 \r
-    //\r
-    // Pass changed uncommitted data back to Form Browser\r
-    //\r
-    Status = HiiSetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);\r
-    return Status;\r
+      //\r
+      // Tell browser not to ask for confirmation of changes,\r
+      // since we have already applied or discarded.\r
+      //\r
+      *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
+      break;  \r
+\r
+    case FORM_RESET:\r
+      gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+      return EFI_UNSUPPORTED;\r
+\r
+    default:\r
+      break;\r
+    }\r
   }\r
 \r
   //\r
-  // All other action return unsupported.\r
+  // Pass changed uncommitted data back to Form Browser\r
   //\r
-  return EFI_UNSUPPORTED;\r
+  HiiSetBrowserData (&gBootMaintFormSetGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *) CurrentFakeNVMap, NULL);\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r