]> 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 d5674e3b42d555987a82c3a1d3318b39f3ce8088..2cddb519df46e1ebd0d1154920da4e1ae7dcdd06 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   The functions for Boot Maintainence Main menu.\r
 \r
-Copyright (c) 2004 - 2009, 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
@@ -626,11 +678,11 @@ ApplyChangeHandler (
 \r
   case FORM_BOOT_DEL_ID:\r
     for (Index = 0; \r
-         ((Index < BootOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->BootOptionDel) / sizeof (UINT8)))); \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
@@ -638,11 +690,11 @@ ApplyChangeHandler (
 \r
   case FORM_DRV_DEL_ID:\r
     for (Index = 0; \r
-         ((Index < DriverOptionMenu.MenuNumber) && (Index < (sizeof (CurrentFakeNVMap->DriverOptionDel) / sizeof (UINT8)))); \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
@@ -690,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
@@ -705,14 +758,14 @@ ApplyChangeHandler (
     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
+      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
+      ASSERT (Index + ConsoleInpMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsConIn = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleInpMenu.MenuNumber];\r
     }\r
 \r
@@ -723,14 +776,14 @@ ApplyChangeHandler (
     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
+      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
+      ASSERT (Index + ConsoleOutMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsConOut  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleOutMenu.MenuNumber];\r
     }\r
 \r
@@ -741,14 +794,14 @@ ApplyChangeHandler (
     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
+      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
+      ASSERT (Index + ConsoleErrMenu.MenuNumber < MAX_MENU_NUMBER);\r
       NewTerminalContext->IsStdErr  = CurrentFakeNVMap->ConsoleCheck[Index + ConsoleErrMenu.MenuNumber];\r
     }\r
 \r
@@ -798,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
@@ -929,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
@@ -1161,7 +1214,7 @@ FreeAllMenu (
 }\r
 \r
 /**\r
-  Intialize all the string depositories.\r
+  Initialize all the string depositories.\r
 \r
 **/\r
 VOID\r
@@ -1397,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