]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/GenericBdsLib/BdsBoot.c
Remove SafeFreePool from MemoryAllocationLib as this API's name is misleading. Its...
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / BdsBoot.c
index 30d3a50d906076feba4a713f8d773e76ac6508c6..c8b2c59f5244e08ebbeeb5bc07119447c1225c6a 100644 (file)
@@ -120,8 +120,8 @@ BdsLibBootViaBootOption (
 \r
   //\r
   // Notes: this code can be remove after the s3 script table\r
-  // hook on the event EFI_EVENT_SIGNAL_READY_TO_BOOT or\r
-  // EFI_EVENT_SIGNAL_LEGACY_BOOT\r
+  // hook on the event EVT_SIGNAL_READY_TO_BOOT or\r
+  // EVT_SIGNAL_LEGACY_BOOT\r
   //\r
   Status = gBS->LocateProtocol (&gEfiAcpiS3SaveProtocolGuid, NULL, (VOID **) &AcpiS3Save);\r
   if (!EFI_ERROR (Status)) {\r
@@ -142,7 +142,7 @@ BdsLibBootViaBootOption (
     }\r
   }\r
   //\r
-  // Signal the EFI_EVENT_SIGNAL_READY_TO_BOOT event\r
+  // Signal the EVT_SIGNAL_READY_TO_BOOT event\r
   //\r
   EfiSignalEventReadyToBoot();\r
   \r
@@ -173,7 +173,7 @@ BdsLibBootViaBootOption (
   Status = BdsLibUpdateFvFileDevicePath (&DevicePath, &gEfiShellFileGuid);\r
   if (!EFI_ERROR(Status)) {\r
     if (Option->DevicePath != NULL) {\r
-      SafeFreePool(Option->DevicePath);\r
+      FreePool(Option->DevicePath);\r
     }\r
     Option->DevicePath  = AllocateZeroPool (GetDevicePathSize (DevicePath));\r
     CopyMem (Option->DevicePath, DevicePath, GetDevicePathSize (DevicePath));\r
@@ -186,15 +186,10 @@ BdsLibBootViaBootOption (
     //\r
     // free the temporary device path created by BdsLibUpdateFvFileDevicePath()\r
     //\r
-    SafeFreePool (DevicePath); \r
+    FreePool (DevicePath); \r
     DevicePath = Option->DevicePath;\r
   }\r
 \r
-  //\r
-  // Drop the TPL level from TPL_APPLICATION to TPL_APPLICATION\r
-  //\r
-  gBS->RestoreTPL (TPL_APPLICATION);\r
-\r
   DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Booting %S\n", Option->Description));\r
 \r
   Status = gBS->LoadImage (\r
@@ -285,11 +280,6 @@ Done:
         &Option->BootCurrent\r
         );\r
 \r
-  //\r
-  // Raise the TPL level back to TPL_APPLICATION\r
-  //\r
-  gBS->RaiseTPL (TPL_APPLICATION);\r
-\r
   return Status;\r
 }\r
 \r
@@ -368,7 +358,7 @@ BdsExpandPartitionPartialDevicePathToFull (
       // Come here means the first instance is not matched\r
       //\r
       NeedAdjust = TRUE;\r
-      SafeFreePool(Instance);\r
+      FreePool(Instance);\r
     } while (TempNewDevicePath != NULL);\r
 \r
     if (DeviceExist) {\r
@@ -388,14 +378,14 @@ BdsExpandPartitionPartialDevicePathToFull (
         //\r
         TempNewDevicePath = CachedDevicePath;\r
         CachedDevicePath  = BdsLibDelPartMatchInstance (CachedDevicePath, Instance );\r
-        SafeFreePool (TempNewDevicePath);\r
+        FreePool (TempNewDevicePath);\r
         \r
         //\r
         // Second, append the remaining parth after the matched instance\r
         //\r
         TempNewDevicePath = CachedDevicePath;\r
         CachedDevicePath = AppendDevicePathInstance (Instance, CachedDevicePath );\r
-        SafeFreePool (TempNewDevicePath);\r
+        FreePool (TempNewDevicePath);\r
         //\r
         // Save the matching Device Path so we don't need to do a connect all next time\r
         //\r
@@ -408,8 +398,8 @@ BdsExpandPartitionPartialDevicePathToFull (
                         );\r
       }\r
       \r
-      SafeFreePool (Instance);\r
-      SafeFreePool (CachedDevicePath);\r
+      FreePool (Instance);\r
+      FreePool (CachedDevicePath);\r
       return FullDevicePath;\r
     }\r
   }\r
@@ -454,15 +444,15 @@ BdsExpandPartitionPartialDevicePathToFull (
         if (BdsLibMatchDevicePaths (CachedDevicePath, BlockIoDevicePath)) {\r
           TempNewDevicePath = CachedDevicePath;\r
           CachedDevicePath = BdsLibDelPartMatchInstance (CachedDevicePath, BlockIoDevicePath);\r
-          SafeFreePool(TempNewDevicePath);\r
+          FreePool(TempNewDevicePath);\r
 \r
           TempNewDevicePath = CachedDevicePath;\r
           CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);\r
-          SafeFreePool(TempNewDevicePath);\r
+          FreePool(TempNewDevicePath);\r
         } else {\r
           TempNewDevicePath = CachedDevicePath;\r
           CachedDevicePath = AppendDevicePathInstance (BlockIoDevicePath, CachedDevicePath);\r
-          SafeFreePool(TempNewDevicePath);\r
+          FreePool(TempNewDevicePath);\r
         }\r
         //\r
         // Here limit the device path instance number to 12, which is max number for a system support 3 IDE controller\r
@@ -506,8 +496,10 @@ BdsExpandPartitionPartialDevicePathToFull (
     }\r
   }\r
   \r
-  SafeFreePool (CachedDevicePath);\r
-  SafeFreePool (BlockIoBuffer);\r
+  FreePool (CachedDevicePath);\r
+  if (BlockIoBuffer != NULL) {\r
+    FreePool (BlockIoBuffer);\r
+  }\r
   return FullDevicePath;\r
 }\r
 \r
@@ -659,7 +651,7 @@ BdsLibDeleteOptionFromHandle (
                       );\r
                       \r
     if (BootOptionVar == NULL) {\r
-      SafeFreePool (BootOrder);\r
+      FreePool (BootOrder);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -675,11 +667,11 @@ BdsLibDeleteOptionFromHandle (
     if ((OptionDevicePathSize == DevicePathSize) &&\r
         (CompareMem (DevicePath, OptionDevicePath, DevicePathSize) == 0)) {\r
       BdsDeleteBootOption (BootOrder[Index], BootOrder, &BootOrderSize);\r
-      SafeFreePool (BootOptionVar);\r
+      FreePool (BootOptionVar);\r
       break;\r
     }\r
 \r
-    SafeFreePool (BootOptionVar);\r
+    FreePool (BootOptionVar);\r
     Index++;\r
   }\r
 \r
@@ -694,7 +686,7 @@ BdsLibDeleteOptionFromHandle (
                   BootOrder\r
                   );\r
 \r
-  SafeFreePool (BootOrder);\r
+  FreePool (BootOrder);\r
 \r
   return Status;\r
 }\r
@@ -751,7 +743,7 @@ BdsDeleteAllInvalidEfiBootOption (
                       &BootOptionSize\r
                       );\r
     if (NULL == BootOptionVar) {\r
-      SafeFreePool (BootOrder);\r
+      FreePool (BootOrder);\r
       return EFI_OUT_OF_RESOURCES;\r
     }\r
 \r
@@ -765,7 +757,7 @@ BdsDeleteAllInvalidEfiBootOption (
     //\r
     if ((DevicePathType (OptionDevicePath) == BBS_DEVICE_PATH) &&\r
         (DevicePathSubType (OptionDevicePath) == BBS_BBS_DP)) {\r
-      SafeFreePool (BootOptionVar);\r
+      FreePool (BootOptionVar);\r
       Index++;\r
       continue;\r
     }\r
@@ -787,7 +779,7 @@ BdsDeleteAllInvalidEfiBootOption (
       BootOrder[Index] = 0xffff;\r
     }\r
 \r
-    SafeFreePool (BootOptionVar);\r
+    FreePool (BootOptionVar);\r
     Index++;\r
   }\r
 \r
@@ -809,7 +801,7 @@ BdsDeleteAllInvalidEfiBootOption (
                   BootOrder\r
                   );\r
 \r
-  SafeFreePool (BootOrder);\r
+  FreePool (BootOrder);\r
 \r
   return Status;\r
 }\r
@@ -973,7 +965,7 @@ BdsLibEnumerateAllBootOption (
   }\r
 \r
   if (NumberBlockIoHandles != 0) {\r
-    SafeFreePool (BlockIoHandles);\r
+    FreePool (BlockIoHandles);\r
   }\r
 \r
   //\r
@@ -1035,7 +1027,7 @@ BdsLibEnumerateAllBootOption (
   }\r
 \r
   if (NumberFileSystemHandles != 0) {\r
-    SafeFreePool (FileSystemHandles);\r
+    FreePool (FileSystemHandles);\r
   }\r
 \r
   //\r
@@ -1058,7 +1050,7 @@ BdsLibEnumerateAllBootOption (
   }\r
 \r
   if (NumberSimpleNetworkHandles != 0) {\r
-    SafeFreePool (SimpleNetworkHandles);\r
+    FreePool (SimpleNetworkHandles);\r
   }\r
 \r
   //\r
@@ -1112,7 +1104,7 @@ BdsLibEnumerateAllBootOption (
   }\r
 \r
   if (FvHandleCount != 0) {\r
-    SafeFreePool (FvHandleBuffer);\r
+    FreePool (FvHandleBuffer);\r
   }\r
   //\r
   // Make sure every boot only have one time\r
@@ -1317,7 +1309,7 @@ BdsLibGetBootableHandle (
                BlockIo->Media->BlockSize,\r
                Buffer\r
                );\r
-      SafeFreePool(Buffer);\r
+      FreePool(Buffer);\r
     }\r
   }\r
 \r
@@ -1330,6 +1322,8 @@ BdsLibGetBootableHandle (
   // Try to locate the USB node device path first, if fail then use its previour PCI node to search\r
   //\r
   DupDevicePath = DuplicateDevicePath (DevicePath);\r
+  ASSERT (DupDevicePath != NULL);\r
+  \r
   UpdatedDevicePath = DupDevicePath;\r
   Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &UpdatedDevicePath, &Handle);\r
   //\r
@@ -1389,9 +1383,11 @@ BdsLibGetBootableHandle (
     }\r
   }\r
 \r
-  SafeFreePool(DupDevicePath);\r
+  FreePool(DupDevicePath);\r
 \r
-  SafeFreePool(SimpleFileSystemHandles);\r
+  if (SimpleFileSystemHandles != NULL) {\r
+    FreePool(SimpleFileSystemHandles);\r
+  }\r
 \r
   return ReturnHandle;\r
 }\r
@@ -1650,7 +1646,7 @@ BdsLibIsValidEFIBootOptDevicePath (
       return TRUE;\r
     } else {\r
       if (Status == EFI_SUCCESS) {\r
-        SafeFreePool (TempDevicePath); \r
+        FreePool (TempDevicePath); \r
       }\r
       return FALSE;\r
     }\r
@@ -1895,8 +1891,10 @@ BdsLibUpdateFvFileDevicePath (
       FoundFvHandle = FvHandleBuffer[Index];\r
       break;\r
     }\r
-    \r
-    SafeFreePool (FvHandleBuffer);  \r
+\r
+    if (FvHandleBuffer != NULL) {\r
+      FreePool (FvHandleBuffer);  \r
+    }\r
   }\r
 \r
   if (FindFvFile) {\r