]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkModulePkg/Universal/BdsDxe/BootMaint/BootMaint.c
Refine all R9 call back function to return EFI_UNSUPPORTED for all unsupported call...
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / BdsDxe / BootMaint / BootMaint.c
index da5611d2de9deb80c8b3e0b69536321d67566709..2cddb519df46e1ebd0d1154920da4e1ae7dcdd06 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The functions for Boot Maintainence Main menu.\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2011, 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
 http://opensource.org/licenses/bsd-license.php\r
@@ -184,25 +184,70 @@ BootMaintExtractConfig (
   EFI_STATUS         Status;\r
   UINTN              BufferSize;\r
   BMM_CALLBACK_DATA  *Private;\r
+  EFI_STRING                       ConfigRequestHdr;\r
+  EFI_STRING                       ConfigRequest;\r
+  BOOLEAN                          AllocatedRequest;\r
+  UINTN                            Size;\r
 \r
-  if (Request == NULL) {\r
+  if (Progress == NULL || Results == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
+  *Progress = Request;\r
+  if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &mBootMaintGuid, mBootMaintStorageName)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
 \r
+  ConfigRequestHdr = NULL;\r
+  ConfigRequest    = NULL;\r
+  AllocatedRequest = FALSE;\r
+  Size             = 0;\r
+\r
+  Private = BMM_CALLBACK_DATA_FROM_THIS (This);\r
   //\r
   // Convert buffer data to <ConfigResp> by helper function BlockToConfig()\r
   //\r
   BufferSize = sizeof (BMM_FAKE_NV_DATA);\r
+  ConfigRequest = Request;\r
+  if ((Request == NULL) || (StrStr (Request, L"OFFSET") == NULL)) {\r
+    //\r
+    // Request has no request element, construct full request string.\r
+    // Allocate and fill a buffer large enough to hold the <ConfigHdr> template\r
+    // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator\r
+    //\r
+    ConfigRequestHdr = HiiConstructConfigHdr (&mBootMaintGuid, mBootMaintStorageName, Private->BmmDriverHandle);\r
+    Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);\r
+    ConfigRequest = AllocateZeroPool (Size);\r
+    ASSERT (ConfigRequest != NULL);\r
+    AllocatedRequest = TRUE;\r
+    UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);\r
+    FreePool (ConfigRequestHdr);\r
+  }\r
+\r
   Status = gHiiConfigRouting->BlockToConfig (\r
                                 gHiiConfigRouting,\r
-                                Request,\r
+                                ConfigRequest,\r
                                 (UINT8 *) &Private->BmmFakeNvData,\r
                                 BufferSize,\r
                                 Results,\r
                                 Progress\r
                                 );\r
+  //\r
+  // Free the allocated config request string.\r
+  //\r
+  if (AllocatedRequest) {\r
+    FreePool (ConfigRequest);\r
+    ConfigRequest = NULL;\r
+  }\r
+  //\r
+  // Set Progress string to the original request string.\r
+  //\r
+  if (Request == NULL) {\r
+    *Progress = NULL;\r
+  } else if (StrStr (Request, L"OFFSET") == NULL) {\r
+    *Progress = Request + StrLen (Request);\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
@@ -252,6 +297,13 @@ BootMaintCallback (
   UINT8             *DisMap;\r
   EFI_FORM_ID       FormId;\r
   \r
+  if ((Action == EFI_BROWSER_ACTION_FORM_OPEN) || (Action == EFI_BROWSER_ACTION_FORM_CLOSE)) {\r
+    //\r
+    // Do nothing for UEFI OPEN/CLOSE Action\r
+    //\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   if ((Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -450,7 +502,7 @@ BootMaintCallback (
     if (QuestionId < CONFIG_OPTION_OFFSET) {\r
       switch (QuestionId) {\r
       case KEY_VALUE_BOOT_FROM_FILE:\r
-        Private->FeCurrentState = BOOT_FROM_FILE_STATE;\r
+        Private->FeCurrentState = FileExplorerStateBootFromFile;\r
 \r
         //\r
         // Exit Bmm main formset to send File Explorer formset.\r
@@ -459,7 +511,7 @@ BootMaintCallback (
         break;\r
 \r
       case FORM_BOOT_ADD_ID:\r
-        Private->FeCurrentState = ADD_BOOT_OPTION_STATE;\r
+        Private->FeCurrentState = FileExplorerStateAddBootOption;\r
 \r
         //\r
         // Exit Bmm main formset to send File Explorer formset.\r
@@ -468,7 +520,7 @@ BootMaintCallback (
         break;\r
 \r
       case FORM_DRV_ADD_FILE_ID:\r
-        Private->FeCurrentState = ADD_DRIVER_OPTION_STATE;\r
+        Private->FeCurrentState = FileExplorerStateAddDriverOptionState;\r
 \r
         //\r
         // Exit Bmm main formset to send File Explorer formset.\r
@@ -625,22 +677,24 @@ ApplyChangeHandler (
     break;\r
 \r
   case FORM_BOOT_DEL_ID:\r
-    ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (UINT8)));\r
-    for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
+    for (Index = 0; \r
+         ((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])))); \r
+         Index ++) {\r
       NewMenuEntry            = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
       NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-      NewLoadContext->Deleted = CurrentFakeNVMap->BootOptionDel[Index];\r
+      NewLoadContext->Deleted = CurrentFakeNVMap->OptionDel[Index];\r
     }\r
 \r
     Var_DelBootOption ();\r
     break;\r
 \r
   case FORM_DRV_DEL_ID:\r
-    ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (UINT8)));\r
-    for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
+    for (Index = 0; \r
+         ((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])))); \r
+         Index++) {\r
       NewMenuEntry            = BOpt_GetMenuEntry (&DriverOptionMenu, Index);\r
       NewLoadContext          = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
-      NewLoadContext->Deleted = CurrentFakeNVMap->DriverOptionDel[Index];\r
+      NewLoadContext->Deleted = CurrentFakeNVMap->OptionDel[Index];\r
     }\r
 \r
     Var_DelDriverOption ();\r
@@ -688,9 +742,10 @@ ApplyChangeHandler (
     ASSERT (CurrentFakeNVMap->COMParity < (sizeof (ParityList) / sizeof (ParityList[0])));\r
     NewTerminalContext->Parity        = (UINT8) ParityList[CurrentFakeNVMap->COMParity].Value;\r
     NewTerminalContext->TerminalType  = CurrentFakeNVMap->COMTerminalType;\r
+    NewTerminalContext->FlowControl   = CurrentFakeNVMap->COMFlowControl;\r
 \r
     ChangeTerminalDevicePath (\r
-      NewTerminalContext->DevicePath,\r
+      &(NewTerminalContext->DevicePath),\r
       FALSE\r
       );\r
 \r
@@ -700,16 +755,17 @@ ApplyChangeHandler (
     break;\r
 \r
   case FORM_CON_IN_ID:\r
-    ASSERT ((ConsoleInpMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8)));\r
     for (Index = 0; Index < ConsoleInpMenu.MenuNumber; Index++) {\r
       NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleInpMenu, Index);\r
       NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index < MAX_MENU_NUMBER);\r
       NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
     }\r
 \r
     for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
       NewMenuEntry                = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
       NewTerminalContext          = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];\r
     }\r
 \r
@@ -717,16 +773,17 @@ ApplyChangeHandler (
     break;\r
 \r
   case FORM_CON_OUT_ID:\r
-    ASSERT ((ConsoleOutMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8)));\r
     for (Index = 0; Index < ConsoleOutMenu.MenuNumber; Index++) {\r
       NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleOutMenu, Index);\r
       NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index < MAX_MENU_NUMBER);\r
       NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
     }\r
 \r
     for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
       NewMenuEntry                  = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
       NewTerminalContext            = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsConOut  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];\r
     }\r
 \r
@@ -734,16 +791,17 @@ ApplyChangeHandler (
     break;\r
 \r
   case FORM_CON_ERR_ID:\r
-    ASSERT ((ConsoleErrMenu.MenuNumber + TerminalMenu.MenuNumber) <= (sizeof (CurrentFakeNVMap->ConsoleCheck) / sizeof (UINT8)));\r
     for (Index = 0; Index < ConsoleErrMenu.MenuNumber; Index++) {\r
       NewMenuEntry                = BOpt_GetMenuEntry (&ConsoleErrMenu, Index);\r
       NewConsoleContext           = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index < MAX_MENU_NUMBER);\r
       NewConsoleContext->IsActive = CurrentFakeNVMap->ConsoleCheck[Index];\r
     }\r
 \r
     for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
       NewMenuEntry                  = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
       NewTerminalContext            = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
+      ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsStdErr  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];\r
     }\r
 \r
@@ -793,20 +851,20 @@ DiscardChangeHandler (
   switch (Private->BmmPreviousPageId) {\r
   case FORM_BOOT_CHG_ID:\r
   case FORM_DRV_CHG_ID:\r
-    CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, 100);\r
+    CopyMem (CurrentFakeNVMap->OptionOrder, Private->BmmOldFakeNVData.OptionOrder, sizeof (CurrentFakeNVMap->OptionOrder));\r
     break;\r
 \r
   case FORM_BOOT_DEL_ID:\r
-    ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (CurrentFakeNVMap->BootOptionDel[0])));\r
+    ASSERT (BootOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])));\r
     for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
-      CurrentFakeNVMap->BootOptionDel[Index] = 0x00;\r
+      CurrentFakeNVMap->OptionDel[Index] = FALSE;\r
     }\r
     break;\r
 \r
   case FORM_DRV_DEL_ID:\r
-    ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (CurrentFakeNVMap->DriverOptionDel[0])));\r
+    ASSERT (DriverOptionMenu.MenuNumber <= (sizeof (CurrentFakeNVMap->OptionDel) / sizeof (CurrentFakeNVMap->OptionDel[0])));\r
     for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {\r
-      CurrentFakeNVMap->DriverOptionDel[Index] = 0x00;\r
+      CurrentFakeNVMap->OptionDel[Index] = FALSE;\r
     }\r
     break;\r
 \r
@@ -890,8 +948,8 @@ InitializeBM (
   BmmCallbackInfo->FeConfigAccess.ExtractConfig  = FakeExtractConfig;\r
   BmmCallbackInfo->FeConfigAccess.RouteConfig    = FakeRouteConfig;\r
   BmmCallbackInfo->FeConfigAccess.Callback       = FileExplorerCallback;\r
-  BmmCallbackInfo->FeCurrentState                = INACTIVE_STATE;\r
-  BmmCallbackInfo->FeDisplayContext              = UNKNOWN_CONTEXT;\r
+  BmmCallbackInfo->FeCurrentState                = FileExplorerStateInActive;\r
+  BmmCallbackInfo->FeDisplayContext              = FileExplorerDisplayUnknown;\r
 \r
   //\r
   // Install Device Path Protocol and Config Access protocol to driver handle\r
@@ -924,7 +982,7 @@ InitializeBM (
   }\r
 \r
   //\r
-  // Post our Boot Maint VFR binnary to the HII database.\r
+  // Post our Boot Maint VFR binary to the HII database.\r
   //\r
   BmmCallbackInfo->BmmHiiHandle = HiiAddPackages (\r
                                     &mBootMaintGuid,\r
@@ -1156,7 +1214,7 @@ FreeAllMenu (
 }\r
 \r
 /**\r
-  Intialize all the string depositories.\r
+  Initialize all the string depositories.\r
 \r
 **/\r
 VOID\r
@@ -1355,7 +1413,7 @@ FormSetDispatcher (
     //\r
     // When this Formset returns, check if we are going to explore files.\r
     //\r
-    if (INACTIVE_STATE != CallbackData->FeCurrentState) {\r
+    if (FileExplorerStateInActive != CallbackData->FeCurrentState) {\r
       UpdateFileExplorer (CallbackData, 0);\r
 \r
       ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
@@ -1372,8 +1430,8 @@ FormSetDispatcher (
         EnableResetRequired ();\r
       }\r
 \r
-      CallbackData->FeCurrentState    = INACTIVE_STATE;\r
-      CallbackData->FeDisplayContext  = UNKNOWN_CONTEXT;\r
+      CallbackData->FeCurrentState    = FileExplorerStateInActive;\r
+      CallbackData->FeDisplayContext  = FileExplorerDisplayUnknown;\r
       ReclaimStringDepository ();\r
     } else {\r
       break;\r
@@ -1392,9 +1450,9 @@ FormSetDispatcher (
   @param BootOrder       The Boot Order array.\r
   @param BootOrderSize   The size of the Boot Order Array.\r
 \r
-  @return Other value if the Boot Option specified by OptionNumber is not deleteed succesfully.\r
-  @retval EFI_SUCCESS    If function return successfully.\r
-\r
+  @retval  EFI_SUCCESS           The Boot Option Variable was found and removed\r
+  @retval  EFI_UNSUPPORTED       The Boot Option Variable store was inaccessible\r
+  @retval  EFI_NOT_FOUND         The Boot Option Variable was not found\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r