]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
Clean up BootMaint module in BdsDxe.
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / Variable.c
index a5e575f0bf13ecb3aabb99c929c6a11783edb122..7837224e7ea0e98899a594383f06e858a57e047b 100644 (file)
@@ -22,8 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
   @param VOID            EDES_TODO: Add parameter description\r
 \r
-           EDES_TODO: Incomplete Descriptions  EFI_SUCCESS\r
-           EDES_TODO: Incomplete Descriptions  Others\r
+  @retval EFI_SUCCESS   If all boot load option EFI Variables corresponding to  \r
+                        BM_LOAD_CONTEXT marked for deletion is deleted\r
+  @return Others        If failed to update the "BootOrder" variable after deletion. \r
 \r
 **/\r
 EFI_STATUS\r
@@ -87,10 +88,11 @@ Var_DelBootOption (
   scratch by content from BootOptionMenu is needed.\r
 \r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
+  @param VOID\r
 \r
-           EDES_TODO: Incomplete Descriptions  EFI_SUCCESS\r
-           EDES_TODO: Incomplete Descriptions  Others\r
+  @retval  EFI_SUCCESS  The boot order is updated successfully.\r
+  @return               EFI_STATUS other than EFI_SUCCESS if failed to\r
+                        Set the "BootOrder" EFI Variable.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -138,7 +140,7 @@ Var_ChangeBootOrder (
   BootOrderListSize = BootOptionMenu.MenuNumber;\r
 \r
   if (BootOrderListSize > 0) {\r
-    BootOrderList = EfiAllocateZeroPool (BootOrderListSize * sizeof (UINT16));\r
+    BootOrderList = AllocateZeroPool (BootOrderListSize * sizeof (UINT16));\r
     ASSERT (BootOrderList != NULL);\r
     BootOrderListPtr = BootOrderList;\r
 \r
@@ -178,10 +180,11 @@ Var_ChangeBootOrder (
   make sure DriverOrder is in valid state.\r
 \r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
+  @param VOID\r
 \r
-           EDES_TODO: Incomplete Descriptions  EFI_SUCCESS\r
-           EDES_TODO: Incomplete Descriptions  Others\r
+  @retval EFI_SUCCESS Load Option is successfully updated.\r
+  @return Other value than EFI_SUCCESS if failed to update "Driver Order" EFI\r
+          Variable.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -238,10 +241,11 @@ Var_DelDriverOption (
   needed.\r
 \r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
+  @param VOID\r
 \r
-           EDES_TODO: Incomplete Descriptions  EFI_SUCCESS\r
-           EDES_TODO: Incomplete Descriptions  Others\r
+  @retval  EFI_SUCCESS  The driver order is updated successfully.\r
+  @return               EFI_STATUS other than EFI_SUCCESS if failed to\r
+                                 Set the "DriverOrder" EFI Variable.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -280,7 +284,7 @@ Var_ChangeDriverOrder (
   DriverOrderListSize = DriverOptionMenu.MenuNumber;\r
 \r
   if (DriverOrderListSize > 0) {\r
-    DriverOrderList = EfiAllocateZeroPool (DriverOrderListSize * sizeof (UINT16));\r
+    DriverOrderList = AllocateZeroPool (DriverOrderListSize * sizeof (UINT16));\r
     ASSERT (DriverOrderList != NULL);\r
     DriverOrderListPtr = DriverOrderList;\r
 \r
@@ -315,11 +319,13 @@ Var_ChangeDriverOrder (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  Update the device path of "ConOut", "ConIn" and "ErrOut" \r
+  based on the new BaudRate, Data Bits, parity and Stop Bits\r
+  set.\r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
+  @param VOID\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @return VOID\r
 \r
 **/\r
 VOID\r
@@ -373,13 +379,26 @@ Var_UpdateAllConsoleOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
-\r
-  @param ConsoleName     EDES_TODO: Add parameter description\r
-  @param ConsoleMenu     EDES_TODO: Add parameter description\r
-  @param UpdatePageId    EDES_TODO: Add parameter description\r
-\r
-  @return EDES_TODO: Add description for return value\r
+  This function delete and build multi-instance device path for\r
+  specified type of console device.\r
+\r
+  This function clear the EFI variable defined by ConsoleName and\r
+  gEfiGlobalVariableGuid. It then build the multi-instance device\r
+  path by appending the device path of the Console (In/Out/Err) instance \r
+  in ConsoleMenu. Then it scan all corresponding console device by\r
+  scanning Terminal (built from device supporting Serial I/O instances)\r
+  devices in TerminalMenu. At last, it save a EFI variable specifed\r
+  by ConsoleName and gEfiGlobalVariableGuid.\r
+\r
+  @param ConsoleName     The name for the console device type. They are\r
+                         usually "ConIn", "ConOut" and "ErrOut".\r
+  @param ConsoleMenu     The console memu which is a list of console devices.\r
+  @param UpdatePageId    The flag specifying which type of console device\r
+                         to be processed.\r
+\r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -406,13 +425,10 @@ Var_UpdateConsoleOption (
   };\r
 \r
   //\r
-  // First add all console input device to it from console input menu\r
+  // First add all console input device from console input menu\r
   //\r
   for (Index = 0; Index < ConsoleMenu->MenuNumber; Index++) {\r
     NewMenuEntry = BOpt_GetMenuEntry (ConsoleMenu, Index);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
 \r
     NewConsoleContext = (BM_CONSOLE_CONTEXT *) NewMenuEntry->VariableContext;\r
     if (NewConsoleContext->IsActive) {\r
@@ -425,9 +441,6 @@ Var_UpdateConsoleOption (
 \r
   for (Index = 0; Index < TerminalMenu.MenuNumber; Index++) {\r
     NewMenuEntry = BOpt_GetMenuEntry (&TerminalMenu, Index);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
 \r
     NewTerminalContext = (BM_TERMINAL_CONTEXT *) NewMenuEntry->VariableContext;\r
     if (((NewTerminalContext->IsConIn != 0) && (UpdatePageId == FORM_CON_IN_ID)) ||\r
@@ -438,7 +451,7 @@ Var_UpdateConsoleOption (
       Vendor.Header.SubType = MSG_VENDOR_DP;\r
       CopyMem (\r
         &Vendor.Guid,\r
-        &Guid[NewTerminalContext->TerminalType],\r
+        &TerminalTypeGuid[NewTerminalContext->TerminalType],\r
         sizeof (EFI_GUID)\r
         );\r
       SetDevicePathNodeLength (&Vendor.Header, sizeof (VENDOR_DEVICE_PATH));\r
@@ -473,12 +486,15 @@ Var_UpdateConsoleOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function delete and build multi-instance device path ConIn\r
+  console device.\r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @param VOID\r
 \r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 **/\r
 EFI_STATUS\r
 Var_UpdateConsoleInpOption (\r
@@ -489,12 +505,15 @@ Var_UpdateConsoleInpOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function delete and build multi-instance device path ConOut\r
+  console device.\r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @param VOID\r
 \r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 **/\r
 EFI_STATUS\r
 Var_UpdateConsoleOutOption (\r
@@ -505,12 +524,15 @@ Var_UpdateConsoleOutOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function delete and build multi-instance device path ErrOut\r
+  console device.\r
 \r
-  @param VOID            EDES_TODO: Add parameter description\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @param VOID\r
 \r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 **/\r
 EFI_STATUS\r
 Var_UpdateErrorOutOption (\r
@@ -521,15 +543,19 @@ Var_UpdateErrorOutOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
-\r
-  @param CallbackData    EDES_TODO: Add parameter description\r
-  @param HiiHandle       EDES_TODO: Add parameter description\r
-  @param DescriptionData EDES_TODO: Add parameter description\r
-  @param OptionalData    EDES_TODO: Add parameter description\r
+  This function create a currently loaded Drive Option from \r
+  the BMM. It then appends this Driver Option to the end of \r
+  the "DriverOrder" list. It append this Driver Opotion to the end\r
+  of DriverOptionMenu.\r
+\r
+  @param CallbackData    The BMM context data.\r
+  @param HiiHandle       The HII handle associated with the BMM formset.\r
+  @param DescriptionData The description of this driver option.\r
+  @param OptionalData    The optional load option.\r
   @param ForceReconnect  EDES_TODO: Add parameter description\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
+  @retval EFI_SUCCESS          If function completes successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -576,7 +602,7 @@ Var_UpdateDriverOption (
     BufferSize += StrSize (OptionalData);\r
   }\r
 \r
-  Buffer = EfiAllocateZeroPool (BufferSize);\r
+  Buffer = AllocateZeroPool (BufferSize);\r
   if (NULL == Buffer) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -607,7 +633,7 @@ Var_UpdateDriverOption (
     StrSize (DescriptionData)\r
     );\r
 \r
-  NewLoadContext->Description = EfiAllocateZeroPool (StrSize (DescriptionData));\r
+  NewLoadContext->Description = AllocateZeroPool (StrSize (DescriptionData));\r
   ASSERT (NewLoadContext->Description != NULL);\r
   NewMenuEntry->DisplayString = NewLoadContext->Description;\r
   CopyMem (\r
@@ -623,7 +649,7 @@ Var_UpdateDriverOption (
     GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
     );\r
 \r
-  NewLoadContext->FilePathList = EfiAllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
+  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
   ASSERT (NewLoadContext->FilePathList != NULL);\r
 \r
   CopyMem (\r
@@ -669,7 +695,7 @@ Var_UpdateDriverOption (
                       &gEfiGlobalVariableGuid,\r
                       &DriverOrderListSize\r
                       );\r
-  NewDriverOrderList = EfiAllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
+  NewDriverOrderList = AllocateZeroPool (DriverOrderListSize + sizeof (UINT16));\r
   ASSERT (NewDriverOrderList != NULL);\r
   CopyMem (NewDriverOrderList, DriverOrderList, DriverOrderListSize);\r
   NewDriverOrderList[DriverOrderListSize / sizeof (UINT16)] = Index;\r
@@ -698,14 +724,19 @@ Var_UpdateDriverOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function create a currently loaded Boot Option from \r
+  the BMM. It then appends this Boot Option to the end of \r
+  the "BootOrder" list. It also append this Boot Opotion to the end\r
+  of BootOptionMenu.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
-  @param NvRamMap        EDES_TODO: Add parameter description\r
+  @param CallbackData    The BMM context data.\r
+  @param NvRamMap        The file explorer formset internal state.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
+  @retval EFI_SUCCESS          If function completes successfully.\r
 \r
 **/\r
+\r
 EFI_STATUS\r
 Var_UpdateBootOption (\r
   IN  BMM_CALLBACK_DATA                   *CallbackData,\r
@@ -742,7 +773,7 @@ Var_UpdateBootOption (
     BufferSize += StrSize (NvRamMap->OptionalData);\r
   }\r
 \r
-  Buffer = EfiAllocateZeroPool (BufferSize);\r
+  Buffer = AllocateZeroPool (BufferSize);\r
   if (NULL == Buffer) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
@@ -773,7 +804,7 @@ Var_UpdateBootOption (
     StrSize (NvRamMap->DescriptionData)\r
     );\r
 \r
-  NewLoadContext->Description = EfiAllocateZeroPool (StrSize (NvRamMap->DescriptionData));\r
+  NewLoadContext->Description = AllocateZeroPool (StrSize (NvRamMap->DescriptionData));\r
   ASSERT (NewLoadContext->Description != NULL);\r
 \r
   NewMenuEntry->DisplayString = NewLoadContext->Description;\r
@@ -790,7 +821,7 @@ Var_UpdateBootOption (
     GetDevicePathSize (CallbackData->LoadContext->FilePathList)\r
     );\r
 \r
-  NewLoadContext->FilePathList = EfiAllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
+  NewLoadContext->FilePathList = AllocateZeroPool (GetDevicePathSize (CallbackData->LoadContext->FilePathList));\r
   ASSERT (NewLoadContext->FilePathList != NULL);\r
 \r
   CopyMem (\r
@@ -834,7 +865,7 @@ Var_UpdateBootOption (
                     &BootOrderListSize\r
                     );\r
 \r
-  NewBootOrderList = EfiAllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
+  NewBootOrderList = AllocateZeroPool (BootOrderListSize + sizeof (UINT16));\r
   ASSERT (NewBootOrderList != NULL);\r
   CopyMem (NewBootOrderList, BootOrderList, BootOrderListSize);\r
   NewBootOrderList[BootOrderListSize / sizeof (UINT16)] = Index;\r
@@ -865,11 +896,16 @@ Var_UpdateBootOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function update the "BootNext" EFI Variable. If there is \r
+  no "BootNex" specified in BMM, this EFI Variable is deleted.\r
+  It also update the BMM context data specified the "BootNext"\r
+  vaule.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
+  @param CallbackData    The BMM context data.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -887,9 +923,7 @@ Var_UpdateBootNext (
   CurrentFakeNVMap  = &CallbackData->BmmFakeNvData;\r
   for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
     NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);\r
-    if (NULL == NewMenuEntry) {\r
-      return EFI_NOT_FOUND;\r
-    }\r
+    ASSERT (NULL != NewMenuEntry);\r
 \r
     NewLoadContext              = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
     NewLoadContext->IsBootNext  = FALSE;\r
@@ -904,9 +938,7 @@ Var_UpdateBootNext (
                   &BootOptionMenu,\r
                   CurrentFakeNVMap->BootNext\r
                   );\r
-  if (NULL == NewMenuEntry) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
+  ASSERT (NewMenuEntry != NULL);\r
 \r
   NewLoadContext = (BM_LOAD_CONTEXT *) NewMenuEntry->VariableContext;\r
   Status = gRT->SetVariable (\r
@@ -922,11 +954,16 @@ Var_UpdateBootNext (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function update the "BootOrder" EFI Variable based on\r
+  BMM Formset's NV map. It then refresh BootOptionMenu\r
+  with the new "BootOrder" list.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
+  @param CallbackData    The BMM context data.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @retval EFI_SUCCESS    Not enough memory to complete the function.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -939,7 +976,6 @@ Var_UpdateBootOrder (
   UINT16      *BootOrderList;\r
   UINT16      *NewBootOrderList;\r
   UINTN       BootOrderListSize;\r
-  UINT8       *Map;\r
 \r
   BootOrderList     = NULL;\r
   BootOrderListSize = 0;\r
@@ -953,15 +989,11 @@ Var_UpdateBootOrder (
                     &BootOrderListSize\r
                     );\r
 \r
-  NewBootOrderList = EfiAllocateZeroPool (BootOrderListSize);\r
+  NewBootOrderList = AllocateZeroPool (BootOrderListSize);\r
   if (NewBootOrderList == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
-  Map = EfiAllocateZeroPool (BootOrderListSize / sizeof (UINT16));\r
-  if (Map == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
   //\r
   // If exists, delete it to hold new BootOrder\r
   //\r
@@ -982,7 +1014,6 @@ Var_UpdateBootOrder (
                   );\r
   SafeFreePool (BootOrderList);\r
   SafeFreePool (NewBootOrderList);\r
-  SafeFreePool (Map);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -995,11 +1026,16 @@ Var_UpdateBootOrder (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  This function update the "DriverOrder" EFI Variable based on\r
+  BMM Formset's NV map. It then refresh DriverOptionMenu\r
+  with the new "DriverOrder" list.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
+  @param CallbackData    The BMM context data.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_SUCCESS    The function complete successfully.\r
+  @retval EFI_SUCCESS    Not enough memory to complete the function.\r
+  @return                The EFI variable can be saved. See gRT->SetVariable \r
+                         for detail return information.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1025,7 +1061,7 @@ Var_UpdateDriverOrder (
                       &DriverOrderListSize\r
                       );\r
 \r
-  NewDriverOrderList = EfiAllocateZeroPool (DriverOrderListSize);\r
+  NewDriverOrderList = AllocateZeroPool (DriverOrderListSize);\r
 \r
   if (NewDriverOrderList == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -1060,11 +1096,14 @@ Var_UpdateDriverOrder (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  Update the legacy BBS boot option. L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable\r
+  is udpated with the new Legacy Boot order. The EFI Variable of "Boot####" and gEfiGlobalVariableGuid\r
+  is also updated.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
+  @param CallbackData    The context data for BMM.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @return EFI_SUCCESS    The function completed successfully.\r
+  @retval EFI_NOT_FOUND  If L"LegacyDevOrder" and EfiLegacyDevOrderGuid EFI Variable can be found.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -1178,7 +1217,7 @@ Var_UpdateBBSOption (
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  NewOrder = (UINT16 *) EfiAllocateZeroPool (DevOrder->Length - sizeof (UINT16));\r
+  NewOrder = (UINT16 *) AllocateZeroPool (DevOrder->Length - sizeof (UINT16));\r
   if (NULL == NewOrder) {\r
     SafeFreePool (VarData);\r
     return EFI_OUT_OF_RESOURCES;\r
@@ -1262,7 +1301,7 @@ Var_UpdateBBSOption (
     Ptr += sizeof (UINT16);\r
     Ptr += StrSize ((CHAR16 *) Ptr);\r
 \r
-    NewOptionPtr = EfiAllocateZeroPool (NewOptionSize);\r
+    NewOptionPtr = AllocateZeroPool (NewOptionSize);\r
     if (NULL == NewOptionPtr) {\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
@@ -1364,11 +1403,12 @@ Var_UpdateBBSOption (
 }\r
 \r
 /**\r
-  EDES_TODO: Add function description.\r
+  Update the Text Mode of Console.\r
 \r
-  @param CallbackData    EDES_TODO: Add parameter description\r
+  @param CallbackData  The context data for BMM.\r
 \r
-  @return EDES_TODO: Add description for return value\r
+  @retval EFI_SUCCSS If the Text Mode of Console is updated.\r
+  @return Other value if the Text Mode of Console is not updated.\r
 \r
 **/\r
 EFI_STATUS\r