]> code.delx.au - refind/blobdiff - EfiLib/BmLib.c
BIOS-mode boot support now works when compiled with GNU-EFI
[refind] / EfiLib / BmLib.c
index a8b4dc539d428ef3990a857a0854b6c29edde887..4feddd50337fbc33e4275797b93461a6f137b27f 100644 (file)
@@ -12,7 +12,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
+#ifdef __MAKEWITH_TIANO\r
 #include "Platform.h"\r
+#else\r
+#include "gnuefi-helper.h"\r
+#endif\r
+#include "refit_call_wrapper.h"\r
+\r
 /**\r
 \r
   Find the first instance of this Protocol\r
@@ -35,7 +41,7 @@ EfiLibLocateProtocol (
 {\r
   EFI_STATUS  Status;\r
 \r
-  Status = gBS->LocateProtocol (\r
+  Status = refit_call3_wrapper(gBS->LocateProtocol,\r
                   ProtocolGuid,\r
                   NULL,\r
                   (VOID **) Interface\r
@@ -66,7 +72,7 @@ EfiLibOpenRoot (
   //\r
   // File the file system interface to the device\r
   //\r
-  Status = gBS->HandleProtocol (\r
+  Status = refit_call3_wrapper(gBS->HandleProtocol,\r
                   DeviceHandle,\r
                   &gEfiSimpleFileSystemProtocolGuid,\r
                   (VOID **) &Volume\r
@@ -87,36 +93,6 @@ EfiLibOpenRoot (
   return EFI_ERROR (Status) ? NULL : File;\r
 }\r
 \r
-/**\r
-\r
-  Function gets the file system information from an open file descriptor,\r
-  and stores it in a buffer allocated from pool.\r
-\r
-\r
-  @param FHand           The file handle.\r
-\r
-  @return                A pointer to a buffer with file information.\r
-  @retval                NULL is returned if failed to get Volume Label Info.\r
-\r
-**/\r
-EFI_FILE_SYSTEM_VOLUME_LABEL *\r
-EfiLibFileSystemVolumeLabelInfo (\r
-  IN EFI_FILE_HANDLE      FHand\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL *VolumeInfo = NULL;\r
-  UINTN         Size = 0;\r
-  \r
-  Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo);\r
-  if (Status == EFI_BUFFER_TOO_SMALL) {\r
-    VolumeInfo = AllocateZeroPool (Size);\r
-    Status = FHand->GetInfo (FHand, &gEfiFileSystemVolumeLabelInfoIdGuid, &Size, VolumeInfo);\r
-  }\r
-  \r
-  return EFI_ERROR(Status)?NULL:VolumeInfo;  \r
-}\r
-\r
 /**\r
   Duplicate a string.\r
 \r
@@ -136,13 +112,13 @@ EfiStrDuplicate (
 \r
   Size  = StrSize (Src); //at least 2bytes\r
   Dest  = AllocateZeroPool (Size);\r
-//  ASSERT (Dest != NULL);\r
   if (Dest != NULL) {\r
     CopyMem (Dest, Src, Size);\r
   }\r
 \r
   return Dest;\r
 }\r
+\r
 //Compare strings case insensitive\r
 INTN\r
 EFIAPI\r
@@ -159,7 +135,6 @@ StriCmp (
        return *FirstString - *SecondString;\r
 }\r
 \r
-\r
 /**\r
 \r
   Function gets the file information from an open file descriptor, and stores it\r
@@ -196,41 +171,14 @@ EfiLibFileSystemInfo (
   EFI_STATUS    Status;\r
   EFI_FILE_SYSTEM_INFO *FileSystemInfo = NULL;\r
   UINTN         Size = 0;\r
-  \r
+\r
   Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
     FileSystemInfo = AllocateZeroPool (Size);\r
     Status = FHand->GetInfo (FHand, &gEfiFileSystemInfoGuid, &Size, FileSystemInfo);\r
   }\r
-  \r
-  return EFI_ERROR(Status)?NULL:FileSystemInfo;\r
-}\r
-\r
-/**\r
-  Function is used to determine the number of device path instances\r
-  that exist in a device path.\r
-\r
-\r
-  @param DevicePath      A pointer to a device path data structure.\r
-\r
-  @return This function counts and returns the number of device path instances\r
-          in DevicePath.\r
-\r
-**/\r
-UINTN\r
-EfiDevicePathInstanceCount (\r
-  IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath\r
-  )\r
-{\r
-  UINTN Count;\r
-  UINTN Size;\r
-\r
-  Count = 0;\r
-  while (GetNextDevicePathInstance (&DevicePath, &Size) != NULL) {\r
-    Count += 1;\r
-  }\r
 \r
-  return Count;\r
+  return EFI_ERROR(Status)?NULL:FileSystemInfo;\r
 }\r
 \r
 /**\r
@@ -269,57 +217,3 @@ EfiReallocatePool (
 \r
   return NewPool;\r
 }\r
-\r
-/**\r
-  Compare two EFI_TIME data.\r
-\r
-\r
-  @param FirstTime       - A pointer to the first EFI_TIME data.\r
-  @param SecondTime      - A pointer to the second EFI_TIME data.\r
-\r
-  @retval  TRUE              The FirstTime is not later than the SecondTime.\r
-  @retval  FALSE             The FirstTime is later than the SecondTime.\r
-\r
-**/\r
-BOOLEAN\r
-TimeCompare (\r
-  IN EFI_TIME               *FirstTime,\r
-  IN EFI_TIME               *SecondTime\r
-  )\r
-{\r
-  if (FirstTime->Year != SecondTime->Year) {\r
-    return (BOOLEAN) (FirstTime->Year < SecondTime->Year);\r
-  } else if (FirstTime->Month != SecondTime->Month) {\r
-    return (BOOLEAN) (FirstTime->Month < SecondTime->Month);\r
-  } else if (FirstTime->Day != SecondTime->Day) {\r
-    return (BOOLEAN) (FirstTime->Day < SecondTime->Day);\r
-  } else if (FirstTime->Hour != SecondTime->Hour) {\r
-    return (BOOLEAN) (FirstTime->Hour < SecondTime->Hour);\r
-  } else if (FirstTime->Minute != SecondTime->Minute) {\r
-    return (BOOLEAN) (FirstTime->Minute < FirstTime->Minute);\r
-  } else if (FirstTime->Second != SecondTime->Second) {\r
-    return (BOOLEAN) (FirstTime->Second < SecondTime->Second);\r
-  }\r
-\r
-  return (BOOLEAN) (FirstTime->Nanosecond <= SecondTime->Nanosecond);\r
-}\r
-\r
-/**\r
-  Get a string from the Data Hub record based on \r
-  a device path.\r
-\r
-  @param DevPath         The device Path.\r
-\r
-  @return A string located from the Data Hub records based on\r
-          the device path.\r
-  @retval NULL  If failed to get the String from Data Hub.\r
-\r
-**/\r
-/*\r
-UINT16 *\r
-EfiLibStrFromDatahub (\r
-  IN EFI_DEVICE_PATH_PROTOCOL                 *DevPath\r
-  )\r
-{\r
-  return NULL;\r
-}*/\r