]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/BdsDxe/BootMaint/Variable.c
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its...
[mirror_edk2.git] / MdeModulePkg / Universal / BdsDxe / BootMaint / Variable.c
index 7837224e7ea0e98899a594383f06e858a57e047b..622093c8bb4912c807bd10987b11fb3de54ba43f 100644 (file)
@@ -19,9 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   After deleting this boot option, call Var_ChangeBootOrder to\r
   make sure BootOrder is in valid state.\r
 \r
-\r
-  @param VOID            EDES_TODO: Add parameter description\r
-\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
@@ -88,7 +85,7 @@ Var_DelBootOption (
   scratch by content from BootOptionMenu is needed.\r
 \r
 \r
-  @param VOID\r
+  \r
 \r
   @retval  EFI_SUCCESS  The boot order is updated successfully.\r
   @return               EFI_STATUS other than EFI_SUCCESS if failed to\r
@@ -125,7 +122,7 @@ Var_ChangeBootOrder (
   //\r
   if (BootOrderList != NULL) {\r
     EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
-    SafeFreePool (BootOrderList);\r
+    FreePool (BootOrderList);\r
     BootOrderList = NULL;\r
   }\r
   //\r
@@ -179,9 +176,6 @@ Var_ChangeBootOrder (
   After deleting this Driver option, call Var_ChangeDriverOrder to\r
   make sure DriverOrder is in valid state.\r
 \r
-\r
-  @param VOID\r
-\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
@@ -240,9 +234,6 @@ Var_DelDriverOption (
   rebuild DriverOrder from scratch by content from DriverOptionMenu is\r
   needed.\r
 \r
-\r
-  @param VOID\r
-\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
@@ -277,7 +268,7 @@ Var_ChangeDriverOrder (
   //\r
   if (DriverOrderList != NULL) {\r
     EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
-    SafeFreePool (DriverOrderList);\r
+    FreePool (DriverOrderList);\r
     DriverOrderList = NULL;\r
   }\r
 \r
@@ -323,10 +314,6 @@ Var_ChangeDriverOrder (
   based on the new BaudRate, Data Bits, parity and Stop Bits\r
   set.\r
 \r
-  @param VOID\r
-\r
-  @return VOID\r
-\r
 **/\r
 VOID\r
 Var_UpdateAllConsoleOption (\r
@@ -420,7 +407,7 @@ Var_UpdateConsoleOption (
   ConDevicePath = EfiLibGetVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
   if (ConDevicePath != NULL) {\r
     EfiLibDeleteVariable (ConsoleName, &gEfiGlobalVariableGuid);\r
-    SafeFreePool (ConDevicePath);\r
+    FreePool (ConDevicePath);\r
     ConDevicePath = NULL;\r
   };\r
 \r
@@ -489,9 +476,6 @@ Var_UpdateConsoleOption (
   This function delete and build multi-instance device path ConIn\r
   console device.\r
 \r
-\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
@@ -508,9 +492,6 @@ Var_UpdateConsoleInpOption (
   This function delete and build multi-instance device path ConOut\r
   console device.\r
 \r
-\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
@@ -527,9 +508,6 @@ Var_UpdateConsoleOutOption (
   This function delete and build multi-instance device path ErrOut\r
   console device.\r
 \r
-\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
@@ -552,7 +530,7 @@ Var_UpdateErrorOutOption (
   @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
+  @param ForceReconnect  If to force reconnect.\r
 \r
   @retval EFI_OUT_OF_RESOURCES If not enought memory to complete the operation.\r
   @retval EFI_SUCCESS          If function completes successfully.\r
@@ -711,10 +689,11 @@ Var_UpdateDriverOption (
                   NewDriverOrderList\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
-  SafeFreePool (DriverOrderList);\r
+  if (DriverOrderList != NULL) {\r
+    FreePool (DriverOrderList);\r
+  }\r
   DriverOrderList = NULL;\r
-  SafeFreePool (NewDriverOrderList);\r
-  NewDriverOrderList = NULL;\r
+  FreePool (NewDriverOrderList);\r
   InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);\r
   DriverOptionMenu.MenuNumber++;\r
 \r
@@ -736,7 +715,6 @@ Var_UpdateDriverOption (
   @retval EFI_SUCCESS          If function completes successfully.\r
 \r
 **/\r
-\r
 EFI_STATUS\r
 Var_UpdateBootOption (\r
   IN  BMM_CALLBACK_DATA                   *CallbackData,\r
@@ -872,6 +850,7 @@ Var_UpdateBootOption (
 \r
   if (BootOrderList != NULL) {\r
     EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+    FreePool (BootOrderList);\r
   }\r
 \r
   Status = gRT->SetVariable (\r
@@ -883,9 +862,7 @@ Var_UpdateBootOption (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  SafeFreePool (BootOrderList);\r
-  BootOrderList = NULL;\r
-  SafeFreePool (NewBootOrderList);\r
+  FreePool (NewBootOrderList);\r
   NewBootOrderList = NULL;\r
   InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);\r
   BootOptionMenu.MenuNumber++;\r
@@ -999,6 +976,7 @@ Var_UpdateBootOrder (
   //\r
   if (BootOrderList != NULL) {\r
     EfiLibDeleteVariable (L"BootOrder", &gEfiGlobalVariableGuid);\r
+    FreePool (BootOrderList);\r
   }\r
 \r
   for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {\r
@@ -1012,8 +990,7 @@ Var_UpdateBootOrder (
                   BootOrderListSize,\r
                   NewBootOrderList\r
                   );\r
-  SafeFreePool (BootOrderList);\r
-  SafeFreePool (NewBootOrderList);\r
+  FreePool (NewBootOrderList);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -1071,6 +1048,7 @@ Var_UpdateDriverOrder (
   //\r
   if (DriverOrderList != NULL) {\r
     EfiLibDeleteVariable (L"DriverOrder", &gEfiGlobalVariableGuid);\r
+    FreePool (DriverOrderList);\r
   }\r
 \r
   for (Index = 0; Index < DriverOrderListSize; Index++) {\r
@@ -1088,8 +1066,6 @@ Var_UpdateDriverOrder (
     return Status;\r
   }\r
 \r
-  SafeFreePool (DriverOrderList);\r
-\r
   BOpt_FreeMenu (&DriverOptionMenu);\r
   BOpt_GetDriverOptions (CallbackData);\r
   return EFI_SUCCESS;\r
@@ -1213,13 +1189,13 @@ Var_UpdateBBSOption (
   }\r
 \r
   if (VarData >= VarData + VarSize) {\r
-    SafeFreePool (OriginalPtr);\r
+    FreePool (OriginalPtr);\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
   NewOrder = (UINT16 *) AllocateZeroPool (DevOrder->Length - sizeof (UINT16));\r
   if (NULL == NewOrder) {\r
-    SafeFreePool (VarData);\r
+    FreePool (VarData);\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
@@ -1252,7 +1228,7 @@ Var_UpdateBBSOption (
     NewOrder,\r
     DevOrder->Length - sizeof (UINT16)\r
     );\r
-  SafeFreePool (NewOrder);\r
+  FreePool (NewOrder);\r
 \r
   Status = gRT->SetVariable (\r
                   VAR_LEGACY_DEV_ORDER,\r
@@ -1262,7 +1238,7 @@ Var_UpdateBBSOption (
                   OriginalPtr\r
                   );\r
 \r
-  SafeFreePool (OriginalPtr);\r
+  FreePool (OriginalPtr);\r
 \r
   //\r
   // Update Optional Data of Boot####\r
@@ -1276,7 +1252,7 @@ Var_UpdateBBSOption (
       StrSize (LegacyDeviceContext->Description)\r
       );\r
 \r
-    UnicodeToAscii (DescString, StrSize (DescString), DescAsciiString);\r
+       UnicodeStrToAsciiStr((CONST CHAR16*)&DescString, (CHAR8 *)&DescAsciiString);\r
 \r
     NewOptionSize = sizeof (UINT32) + sizeof (UINT16) + StrSize (DescString) +\r
                     sizeof (BBS_BBS_DEVICE_PATH);\r
@@ -1394,8 +1370,8 @@ Var_UpdateBBSOption (
                     NewOptionPtr\r
                     );\r
 \r
-    SafeFreePool (NewOptionPtr);\r
-    SafeFreePool (BootOptionVar);\r
+    FreePool (NewOptionPtr);\r
+    FreePool (BootOptionVar);\r
   }\r
 \r
   BOpt_GetBootOptions (CallbackData);\r
@@ -1429,7 +1405,7 @@ Var_UpdateConMode (
   }\r
 \r
   Status = gRT->SetVariable (\r
-                  VarConOutMode,\r
+                  VAR_CON_OUT_MODE,\r
                   &gEfiGenericPlatformVariableGuid,\r
                   EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
                   sizeof (CONSOLE_OUT_MODE),\r