]> code.delx.au - refind/commitdiff
BIOS-mode boot support now works when compiled with GNU-EFI
authorsrs5694 <srs5694@users.sourceforge.net>
Fri, 9 May 2014 00:33:35 +0000 (20:33 -0400)
committersrs5694 <srs5694@users.sourceforge.net>
Fri, 9 May 2014 00:33:35 +0000 (20:33 -0400)
20 files changed:
EfiLib/BdsHelper.c
EfiLib/BdsHelper.h
EfiLib/BdsTianoCore.c
EfiLib/BmLib.c
EfiLib/GenericBdsLib.h
EfiLib/Make.tiano
EfiLib/Makefile
EfiLib/legacy.c
EfiLib/legacy.h
Make.tiano
Makefile
NEWS.txt
gptsync/os_efi.c
include/Handle.h
include/tiano_includes.h
libeg/libeg.h
libeg/screen.c
refind/Makefile
refind/global.h
refind/main.c

index 40f44831549173f6cd2624aaf9283f64a87347fa..b5958580e4fe52b36c52e670bfe797249263ca14 100644 (file)
@@ -8,6 +8,7 @@
 #include "BdsHelper.h"
 #include "legacy.h"
 #include "../refind/screen.h"
+#include "refit_call_wrapper.h"
 
 EFI_GUID gEfiLegacyBootProtocolGuid     = { 0xdb9a1e3d, 0x45cb, 0x4abb, { 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d }};
 
@@ -38,13 +39,13 @@ VOID UpdateBbsTable (BDS_COMMON_OPTION *Option) {
    BBS_BBS_DEVICE_PATH       *OptionBBS;
    CHAR16                    Desc[100];
 
-   Status = gBS->LocateProtocol (&gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+   Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
    if (EFI_ERROR (Status) || (Option == NULL)) {
       return;
    }
 
    OptionBBS = (BBS_BBS_DEVICE_PATH *) Option->DevicePath;
-   Status = LegacyBios->GetBbsInfo (LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable);
+   Status = refit_call5_wrapper(LegacyBios->GetBbsInfo, LegacyBios, &HddCount, &HddInfo, &BbsCount, &LocalBbsTable);
 
 //    Print (L"\n");
 //    Print (L" NO  Prio bb/dd/ff cl/sc Type Stat segm:offs\n");
@@ -108,13 +109,13 @@ BdsLibDoLegacyBoot (
     EFI_STATUS                Status;
     EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
 
-    Status = gBS->LocateProtocol (&gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+    Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
     if (EFI_ERROR (Status)) {
       return EFI_UNSUPPORTED;
     }
 
     UpdateBbsTable(Option);
 
-    return LegacyBios->LegacyBoot(LegacyBios, (BBS_BBS_DEVICE_PATH *) Option->DevicePath,
+    return refit_call4_wrapper(LegacyBios->LegacyBoot, LegacyBios, (BBS_BBS_DEVICE_PATH *) Option->DevicePath,
                                   Option->LoadOptionsSize, Option->LoadOptions);
 }
index 23240328934d16c80b42f95ff08b22bd4abd559a..b8395afabaa340ed1c677f1fc53c54373ae851f5 100644 (file)
@@ -4,7 +4,12 @@
  *
  */
 
+#ifdef __MAKEWITH_TIANO
 #include "../include/tiano_includes.h"
+#else
+#include "gnuefi-helper.h"
+#include "GenericBdsLib.h"
+#endif
 
 #ifndef _BDS_HELPER_H_
 #define _BDS_HELPER_H_
index 2163b99218061c8d5c46794ab1ef6143072268bd..7c7d214432847f7e34c50ca3cc52d92bd4736cac 100644 (file)
@@ -12,7 +12,139 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
+#ifdef __MAKEWITH_TIANO
 #include "../include/tiano_includes.h"
+#else
+#include "BdsHelper.h"
+#include "gnuefi-helper.h"
+#endif
+#include "refit_call_wrapper.h"
+
+EFI_GUID EfiDevicePathProtocolGuid = { 0x09576E91, 0x6D3F, 0x11D2, { 0x8E, 0x39, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B }};
+
+/**
+  This function will create all handles associate with every device
+  path node. If the handle associate with one device path node can not
+  be created success, then still give one chance to do the dispatch,
+  which load the missing drivers if possible.
+
+  @param  DevicePathToConnect   The device path which will be connected, it can be
+                                a multi-instance device path
+
+  @retval EFI_SUCCESS           All handles associate with every device path  node
+                                have been created
+  @retval EFI_OUT_OF_RESOURCES  There is no resource to create new handles
+  @retval EFI_NOT_FOUND         Create the handle associate with one device  path
+                                node failed
+
+**/
+EFI_STATUS
+BdsLibConnectDevicePath (
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect
+  )
+{
+  EFI_STATUS                Status;
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  *CopyOfDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  *Instance;
+  EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  *Next;
+  EFI_HANDLE                Handle;
+  EFI_HANDLE                PreviousHandle;
+  UINTN                     Size;
+
+  if (DevicePathToConnect == NULL) {
+    return EFI_SUCCESS;
+  }
+
+  DevicePath        = DuplicateDevicePath (DevicePathToConnect);
+  if (DevicePath == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  CopyOfDevicePath  = DevicePath;
+
+  do {
+    //
+    // The outer loop handles multi instance device paths.
+    // Only console variables contain multiple instance device paths.
+    //
+    // After this call DevicePath points to the next Instance
+    //
+    Instance  = GetNextDevicePathInstance (&DevicePath, &Size);
+    if (Instance == NULL) {
+      FreePool (CopyOfDevicePath);
+      return EFI_OUT_OF_RESOURCES;
+    }
+
+    Next      = Instance;
+    while (!IsDevicePathEndType (Next)) {
+      Next = NextDevicePathNode (Next);
+    }
+
+    SetDevicePathEndNode (Next);
+
+    //
+    // Start the real work of connect with RemainingDevicePath
+    //
+    PreviousHandle = NULL;
+    do {
+      //
+      // Find the handle that best matches the Device Path. If it is only a
+      // partial match the remaining part of the device path is returned in
+      // RemainingDevicePath.
+      //
+      RemainingDevicePath = Instance;
+      Status              = refit_call3_wrapper(gBS->LocateDevicePath, &EfiDevicePathProtocolGuid, &RemainingDevicePath, &Handle);
+
+      if (!EFI_ERROR (Status)) {
+#ifdef __MAKEWITH_TIANO
+         if (Handle == PreviousHandle) {
+          //
+          // If no forward progress is made try invoking the Dispatcher.
+          // A new FV may have been added to the system an new drivers
+          // may now be found.
+          // Status == EFI_SUCCESS means a driver was dispatched
+          // Status == EFI_NOT_FOUND means no new drivers were dispatched
+          //
+          Status = gDS->Dispatch ();
+        }
+#endif
+
+        if (!EFI_ERROR (Status)) {
+          PreviousHandle = Handle;
+          //
+          // Connect all drivers that apply to Handle and RemainingDevicePath,
+          // the Recursive flag is FALSE so only one level will be expanded.
+          //
+          // Do not check the connect status here, if the connect controller fail,
+          // then still give the chance to do dispatch, because partial
+          // RemainingDevicepath may be in the new FV
+          //
+          // 1. If the connect fail, RemainingDevicepath and handle will not
+          //    change, so next time will do the dispatch, then dispatch's status
+          //    will take effect
+          // 2. If the connect success, the RemainingDevicepath and handle will
+          //    change, then avoid the dispatch, we have chance to continue the
+          //    next connection
+          //
+          refit_call4_wrapper(gBS->ConnectController, Handle, NULL, RemainingDevicePath, FALSE);
+        }
+      }
+      //
+      // Loop until RemainingDevicePath is an empty device path
+      //
+    } while (!EFI_ERROR (Status) && !IsDevicePathEnd (RemainingDevicePath));
+
+  } while (DevicePath != NULL);
+
+  if (CopyOfDevicePath != NULL) {
+    FreePool (CopyOfDevicePath);
+  }
+  //
+  // All handle with DevicePath exists in the handle database
+  //
+  return Status;
+}
 
 /**
   Build the boot#### or driver#### option from the VariableName, the
@@ -28,7 +160,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 BDS_COMMON_OPTION *
-EFIAPI
 BdsLibVariableToOption (
   IN OUT LIST_ENTRY                   *BdsCommonOptionList,
   IN  CHAR16                          *VariableName
@@ -160,7 +291,6 @@ BdsLibVariableToOption (
 
 **/
 VOID *
-EFIAPI
 BdsLibGetVariableAndSize (
   IN  CHAR16              *Name,
   IN  EFI_GUID            *VendorGuid,
@@ -177,7 +307,7 @@ BdsLibGetVariableAndSize (
   // Pass in a zero size buffer to find the required buffer size.
   //
   BufferSize  = 0;
-  Status      = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
+  Status      = refit_call5_wrapper(gRT->GetVariable, Name, VendorGuid, NULL, &BufferSize, Buffer);
   if (Status == EFI_BUFFER_TOO_SMALL) {
     //
     // Allocate the buffer to return
@@ -189,7 +319,7 @@ BdsLibGetVariableAndSize (
     //
     // Read variable into the allocated buffer.
     //
-    Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize, Buffer);
+    Status = refit_call5_wrapper(gRT->GetVariable, Name, VendorGuid, NULL, &BufferSize, Buffer);
     if (EFI_ERROR (Status)) {
       BufferSize = 0;
     }
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
index b4c9225daaf8d94c6964fddc3cf8283a565c1535..d4958c4ec00f48bb5ba3969f30e2f71e1c919848 100644 (file)
@@ -18,7 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #ifndef _GENERIC_BDS_LIB_H_\r
 #define _GENERIC_BDS_LIB_H_\r
 \r
-#include <Protocol/UserManager.h>\r
+#ifdef __MAKEWITH_GNUEFI\r
+#include "gnuefi-helper.h"\r
+#endif\r
+\r
+//#include <Protocol/UserManager.h>\r
 \r
 ///\r
 /// Constants which are variable names used to access variables.\r
@@ -70,7 +74,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 // This data structure is the part of BDS_CONNECT_ENTRY\r
 //\r
+#ifdef __MAKEWITH_TIANO\r
 #define BDS_LOAD_OPTION_SIGNATURE SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+#else\r
+#define BDS_LOAD_OPTION_SIGNATURE EFI_SIGNATURE_32 ('B', 'd', 'C', 'O')\r
+#endif\r
 \r
 typedef struct {\r
 \r
@@ -290,7 +298,6 @@ BdsLibBuildOptionFromVar (
 \r
 **/\r
 VOID *\r
-EFIAPI\r
 BdsLibGetVariableAndSize (\r
   IN  CHAR16              *Name,\r
   IN  EFI_GUID            *VendorGuid,\r
@@ -309,12 +316,12 @@ BdsLibGetVariableAndSize (
   @retval EFI_STATUS            Return the status of the ConOut->OutputString ().\r
 \r
 **/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibOutputStrings (\r
-  IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,\r
-  ...\r
-  );\r
+// EFI_STATUS\r
+// EFIAPI\r
+// BdsLibOutputStrings (\r
+//   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL   *ConOut,\r
+//   ...\r
+//   );\r
 \r
 /**\r
   Build the boot#### or driver#### option from the VariableName. The\r
@@ -330,60 +337,11 @@ BdsLibOutputStrings (
 \r
 **/\r
 BDS_COMMON_OPTION *\r
-EFIAPI\r
 BdsLibVariableToOption (\r
   IN OUT LIST_ENTRY                   *BdsCommonOptionList,\r
   IN  CHAR16                          *VariableName\r
   );\r
 \r
-/**\r
-  This function registers the new boot#### or driver#### option based on\r
-  the VariableName. The new registered boot#### or driver#### will be linked\r
-  to BdsOptionList and also update to the VariableName. After the boot#### or\r
-  driver#### updated, the BootOrder or DriverOrder will also be updated.\r
-\r
-  @param  BdsOptionList         The header of the boot#### or driver#### link list.\r
-  @param  DevicePath            The device path that the boot#### or driver####\r
-                                option present.\r
-  @param  String                The description of the boot#### or driver####.\r
-  @param  VariableName          Indicate if the boot#### or driver#### option.\r
-\r
-  @retval EFI_SUCCESS           The boot#### or driver#### have been successfully\r
-                                registered.\r
-  @retval EFI_STATUS            Return the status of gRS->SetVariable ().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibRegisterNewOption (\r
-  IN  LIST_ENTRY                     *BdsOptionList,\r
-  IN  EFI_DEVICE_PATH_PROTOCOL       *DevicePath,\r
-  IN  CHAR16                         *String,\r
-  IN  CHAR16                         *VariableName\r
-  );\r
-\r
-//\r
-// Bds connect and disconnect driver lib funcions\r
-//\r
-/**\r
-  This function connects all system drivers with the corresponding controllers. \r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllDriversToAllControllers (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function connects all system drivers to controllers.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAll (\r
-  VOID\r
-  );\r
 \r
 /**\r
   This function creates all handles associated with the given device\r
@@ -400,55 +358,10 @@ BdsLibConnectAll (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 BdsLibConnectDevicePath (\r
   IN EFI_DEVICE_PATH_PROTOCOL  *DevicePathToConnect\r
   );\r
 \r
-/**\r
-  This function will connect all current system handles recursively.     \r
-  gBS->ConnectController() service is invoked for each handle exist in system handler buffer.  \r
-  If the handle is bus type handler, all childrens also will be connected recursively  by gBS->ConnectController().\r
-  \r
-  @retval EFI_SUCCESS           All handles and child handles have been\r
-                                connected.  \r
-  @retval EFI_STATUS            Return the status of gBS->LocateHandleBuffer().\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibConnectAllEfi (\r
-  VOID\r
-  );\r
-\r
-/**\r
-  This function will disconnect all current system handles.     \r
-  gBS->DisconnectController() is invoked for each handle exists in system handle buffer.  \r
-  If handle is a bus type handle, all childrens also are disconnected recursively by  gBS->DisconnectController().\r
-  \r
-  @retval EFI_SUCCESS           All handles have been disconnected.\r
-  @retval EFI_STATUS            Error status returned by of gBS->LocateHandleBuffer().\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibDisconnectAllEfi (\r
-  VOID\r
-  );\r
-\r
-//\r
-// Bds console related lib functions\r
-//\r
-/**\r
-  This function will search every simpletxt device in the current system,\r
-  and make every simpletxt device a potential console device.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-BdsLibConnectAllConsoles (\r
-  VOID\r
-  );\r
-\r
 \r
 /**\r
   This function will connect console device based on the console\r
@@ -568,6 +481,7 @@ DevicePathToStr (
   IN EFI_DEVICE_PATH_PROTOCOL     *DevPath\r
   );\r
 \r
+#ifdef __MAKEWITH_TIANO\r
 //\r
 // Internal definitions\r
 //\r
@@ -576,6 +490,7 @@ typedef struct {
   UINTN   Len;\r
   UINTN   Maxlen;\r
 } POOL_PRINT;\r
+#endif\r
 \r
 typedef\r
 VOID\r
@@ -627,7 +542,6 @@ typedef struct {
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 BdsDeleteAllInvalidLegacyBootOptions (\r
   VOID\r
   );\r
@@ -642,7 +556,6 @@ BdsDeleteAllInvalidLegacyBootOptions (
   @return Other value          LegacyBoot options are not added.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 BdsAddNonExistingLegacyBootOptions (\r
   VOID\r
   );\r
@@ -691,7 +604,6 @@ BdsRefreshBbsTableForBoot (
   @retval  EFI_NOT_FOUND         The Boot Option Variable was not found.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 BdsDeleteBootOption (\r
   IN UINTN                       OptionNumber,\r
   IN OUT UINT16                  *BootOrder,\r
@@ -964,11 +876,11 @@ BdsLibSaveMemoryTypeInformation (
   @retval EFI_ACCESS_DENIED   The user was not successfully identified.\r
 \r
 **/\r
-EFI_STATUS\r
-EFIAPI\r
-BdsLibUserIdentify (\r
-  OUT EFI_USER_PROFILE_HANDLE         *User\r
-  );  \r
+// EFI_STATUS\r
+// EFIAPI\r
+// BdsLibUserIdentify (\r
+//   OUT EFI_USER_PROFILE_HANDLE         *User\r
+//   );  \r
 \r
 /**\r
   This function checks if a Fv file device path is valid, according to a file GUID. If it is invalid,\r
index 5c44d75bf9167adfb1b192f1fc7d91e37a25c8e5..03b2e0d3a6746ec297e2e4eab5a8eb197de6d73e 100644 (file)
@@ -5,7 +5,7 @@
 
 include ../Make.tiano
 
-SOURCE_NAMES     = legacy BdsConnect BmLib Console DevicePath BdsHelper BdsTianoCore
+SOURCE_NAMES     = legacy BmLib DevicePath BdsHelper BdsTianoCore
 OBJS             = $(SOURCE_NAMES:=.obj)
 #DRIVERNAME      = ext2
 #BUILDME          = $(DRIVERNAME)_$(FILENAME_CODE).efi
index 8487805d5a9aeb9e5ebca9fac0f66cd57ecb08b3..ad63f0ec61ed38ee6de80ae9d4983ac4cfb6809c 100644 (file)
@@ -2,5 +2,18 @@
 # EfiLib/Makefile
 #
 
+SRCDIR = .
+
+VPATH = $(SRCDIR)
+
+LOCAL_CPPFLAGS  = -I$(SRCDIR) -I$(SRCDIR)/../include
+
+OBJS            = gnuefi-helper.o legacy.o BdsHelper.o BdsTianoCore.o
+TARGET          = libEfiLib.a
+
+all: $(TARGET)
+
+include $(SRCDIR)/../Make.common
+
 clean:
-       rm -f *.o *.obj *~ *.lib
+       rm -f *.o *.obj *~ *.lib *.a
index 4578da0b3105f053efa13c88e37e0b1f29c5757a..58242970913a56967cd32bbe79ce58f2310fd1db 100644 (file)
  *
  */
 
-#include "../include/tiano_includes.h"
+#ifdef __MAKEWITH_GNUEFI
+#include "efi.h"
+#include "efilib.h"
+#include "gnuefi-helper.h"
+#define EFI_DEVICE_PATH_PROTOCOL EFI_DEVICE_PATH
+#define EfiReallocatePool ReallocatePool
+#define EfiLibLocateProtocol LibLocateProtocol
+#else
+#include "tiano_includes.h"
+#endif
 #include "legacy.h"
+#include "GenericBdsLib.h"
+#include "../refind/global.h"
+#include "../include/refit_call_wrapper.h"
 
 BOOT_OPTION_BBS_MAPPING  *mBootOptionBbsMapping     = NULL;
 UINTN                    mBootOptionBbsMappingCount = 0;
@@ -244,7 +256,7 @@ BdsFindLegacyBootOptionByDevTypeAndName (
   )
 {
   UINTN     Index;
-  CHAR16    BootOption[9];
+  CHAR16    BootOption[10];
   UINTN     BootOptionSize;
   UINT8     *BootOptionVar;
   BBS_TABLE *BbsEntry;
@@ -268,7 +280,7 @@ BdsFindLegacyBootOptionByDevTypeAndName (
                       &BootOptionSize
                       );
     if (NULL == BootOptionVar) {
-      continue;
+       continue;
     }
 
     //
@@ -448,7 +460,7 @@ BdsCreateLegacyBootOption (
   Ptr += sizeof (BBS_TABLE);
   *((UINT16 *) Ptr) = (UINT16) Index;
 
-  Status = gRT->SetVariable (
+  Status = refit_call5_wrapper(gRT->SetVariable,
                   BootString,
                   &gEfiGlobalVariableGuid,
                   VAR_FLAG,
@@ -646,7 +658,7 @@ EfiLibGetVariable (
 
   @param VarName           A Null-terminated Unicode string that is
                            the name of the vendor's variable.
-                         
+
   @param VarGuid           A unique identifier for the vendor.
 
   @retval  EFI_SUCCESS           The variable was found and removed
@@ -671,7 +683,7 @@ EfiLibDeleteVariable (
     //
     // Delete variable from Storage
     //
-    Status = gRT->SetVariable (VarName, VarGuid, VAR_FLAG, 0, NULL);
+    Status = refit_call5_wrapper(gRT->SetVariable, VarName, VarGuid, VAR_FLAG, 0, NULL);
     ASSERT (!EFI_ERROR (Status));
     FreePool (VarBuf);
   }
@@ -689,7 +701,6 @@ EfiLibDeleteVariable (
   @return Other value          LegacyBoot options are not added.
 **/
 EFI_STATUS
-EFIAPI
 BdsAddNonExistingLegacyBootOptions (
   VOID
   )
@@ -726,7 +737,7 @@ BdsAddNonExistingLegacyBootOptions (
     mBootOptionBbsMappingCount = 0;
   }
 
-  LegacyBios->GetBbsInfo (
+  refit_call5_wrapper(LegacyBios->GetBbsInfo,
                 LegacyBios,
                 &HddCount,
                 &LocalHddInfo,
@@ -783,10 +794,10 @@ BdsAddNonExistingLegacyBootOptions (
     //
     // Save the BbsIndex
     //
-    mBootOptionBbsMapping = ReallocatePool (
+    mBootOptionBbsMapping = EfiReallocatePool (
+                              mBootOptionBbsMapping,
                               mBootOptionBbsMappingCount * sizeof (BOOT_OPTION_BBS_MAPPING),
-                              (mBootOptionBbsMappingCount + 1) * sizeof (BOOT_OPTION_BBS_MAPPING),
-                              mBootOptionBbsMapping
+                              (mBootOptionBbsMappingCount + 1) * sizeof (BOOT_OPTION_BBS_MAPPING)
                               );
     ASSERT (mBootOptionBbsMapping != NULL);
     mBootOptionBbsMapping[mBootOptionBbsMappingCount].BootOptionNumber = OptionNumber;
@@ -804,7 +815,7 @@ BdsAddNonExistingLegacyBootOptions (
     );
 
   if (BootOrderSize > 0) {
-    Status = gRT->SetVariable (
+    Status = refit_call5_wrapper(gRT->SetVariable,
                     L"BootOrder",
                     &gEfiGlobalVariableGuid,
                     VAR_FLAG,
@@ -835,7 +846,6 @@ BdsAddNonExistingLegacyBootOptions (
   @retval  EFI_NOT_FOUND         The Boot Option Variable was not found
 **/
 EFI_STATUS
-EFIAPI
 BdsDeleteBootOption (
   IN UINTN                       OptionNumber,
   IN OUT UINT16                  *BootOrder,
@@ -885,7 +895,6 @@ BdsDeleteBootOption (
   @retval EFI_NOT_FOUND           Fail to retrive variable of boot order.
 **/
 EFI_STATUS
-EFIAPI
 BdsDeleteAllInvalidLegacyBootOptions (
   VOID
   )
@@ -921,7 +930,7 @@ BdsDeleteAllInvalidLegacyBootOptions (
     return Status;
   }
 
-  LegacyBios->GetBbsInfo (
+  refit_call5_wrapper(LegacyBios->GetBbsInfo,
                 LegacyBios,
                 &HddCount,
                 &LocalHddInfo,
@@ -948,7 +957,7 @@ BdsDeleteAllInvalidLegacyBootOptions (
                       );
     if (NULL == BootOptionVar) {
       BootOptionSize = 0;
-      Status = gRT->GetVariable (
+      Status = refit_call5_wrapper(gRT->GetVariable,
                       BootOption,
                       &gEfiGlobalVariableGuid,
                       NULL,
@@ -1024,7 +1033,7 @@ BdsDeleteAllInvalidLegacyBootOptions (
   // Adjust the number of boot options.
   //
   if (BootOrderSize != 0) {
-    Status = gRT->SetVariable (
+    Status = refit_call5_wrapper(gRT->SetVariable,
                     L"BootOrder",
                     &gEfiGlobalVariableGuid,
                     VAR_FLAG,
@@ -1078,130 +1087,3 @@ BdsFillDevOrderBuf (
 
   return Buf;
 }
-
-/**
-  Create the device order buffer.
-
-  @param BbsTable        The BBS table.
-  @param BbsCount        The BBS Count.
-
-  @retval EFI_SUCCES             The buffer is created and the EFI variable named 
-                                 VAR_LEGACY_DEV_ORDER and gEfiLegacyDevOrderVariableGuid is
-                                 set correctly.
-  @retval EFI_OUT_OF_RESOURCES   Memmory or storage is not enough.
-  @retval EFI_DEVICE_ERROR       Fail to add the device order into EFI variable fail
-                                 because of hardware error.
-**/
-EFI_STATUS
-BdsCreateDevOrder (
-  IN BBS_TABLE                  *BbsTable,
-  IN UINT16                     BbsCount
-  )
-{
-  UINTN                       Index;
-  UINTN                       FDCount;
-  UINTN                       HDCount;
-  UINTN                       CDCount;
-  UINTN                       NETCount;
-  UINTN                       BEVCount;
-  UINTN                       TotalSize;
-  UINTN                       HeaderSize;
-  LEGACY_DEV_ORDER_ENTRY      *DevOrder;
-  LEGACY_DEV_ORDER_ENTRY      *DevOrderPtr;
-  EFI_STATUS                  Status;
-
-  FDCount     = 0;
-  HDCount     = 0;
-  CDCount     = 0;
-  NETCount    = 0;
-  BEVCount    = 0;
-  TotalSize   = 0;
-  HeaderSize  = sizeof (BBS_TYPE) + sizeof (UINT16);
-  DevOrder    = NULL;
-  Status      = EFI_SUCCESS;
-
-  //
-  // Count all boot devices
-  //
-  for (Index = 0; Index < BbsCount; Index++) {
-    if (BbsTable[Index].BootPriority == BBS_IGNORE_ENTRY) {
-      continue;
-    }
-
-    switch (BbsTable[Index].DeviceType) {
-    case BBS_FLOPPY:
-      FDCount++;
-      break;
-
-    case BBS_HARDDISK:
-      HDCount++;
-      break;
-
-    case BBS_CDROM:
-      CDCount++;
-      break;
-
-    case BBS_EMBED_NETWORK:
-      NETCount++;
-      break;
-
-    case BBS_BEV_DEVICE:
-      BEVCount++;
-      break;
-
-    default:
-      break;
-    }
-  }
-
-  TotalSize += (HeaderSize + sizeof (UINT16) * FDCount);
-  TotalSize += (HeaderSize + sizeof (UINT16) * HDCount);
-  TotalSize += (HeaderSize + sizeof (UINT16) * CDCount);
-  TotalSize += (HeaderSize + sizeof (UINT16) * NETCount);
-  TotalSize += (HeaderSize + sizeof (UINT16) * BEVCount);
-
-  //
-  // Create buffer to hold all boot device order
-  //
-  DevOrder = AllocateZeroPool (TotalSize);
-  if (NULL == DevOrder) {
-    return EFI_OUT_OF_RESOURCES;
-  }
-  DevOrderPtr          = DevOrder;
-
-  DevOrderPtr->BbsType = BBS_FLOPPY;
-  DevOrderPtr->Length  = (UINT16) (sizeof (DevOrderPtr->Length) + FDCount * sizeof (UINT16));
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_FLOPPY, BbsCount, DevOrderPtr->Data);
-
-  DevOrderPtr->BbsType = BBS_HARDDISK;
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + HDCount * sizeof (UINT16));
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_HARDDISK, BbsCount, DevOrderPtr->Data);
-  
-  DevOrderPtr->BbsType = BBS_CDROM;
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + CDCount * sizeof (UINT16));
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_CDROM, BbsCount, DevOrderPtr->Data);
-  
-  DevOrderPtr->BbsType = BBS_EMBED_NETWORK;
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + NETCount * sizeof (UINT16));
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_EMBED_NETWORK, BbsCount, DevOrderPtr->Data);
-
-  DevOrderPtr->BbsType = BBS_BEV_DEVICE;
-  DevOrderPtr->Length  = (UINT16) (sizeof (UINT16) + BEVCount * sizeof (UINT16));
-  DevOrderPtr          = (LEGACY_DEV_ORDER_ENTRY *) BdsFillDevOrderBuf (BbsTable, BBS_BEV_DEVICE, BbsCount, DevOrderPtr->Data);
-
-  ASSERT (TotalSize == (UINTN) ((UINT8 *) DevOrderPtr - (UINT8 *) DevOrder));
-
-  //
-  // Save device order for legacy boot device to variable.
-  //
-  Status = gRT->SetVariable (
-                  VAR_LEGACY_DEV_ORDER,
-                  &gEfiLegacyDevOrderVariableGuid,
-                  VAR_FLAG,
-                  TotalSize,
-                  DevOrder
-                  );
-  FreePool (DevOrder);
-
-  return Status;
-}
index 0c6ca06d8ba5e1c00bdea98f12c390da41c3c53d..3384f48832171bec5b54fcd0c0b6f513c6f9dca5 100644 (file)
@@ -15,6 +15,8 @@
  *
  */
 
+#include "LegacyBios.h"
+
 #ifndef __LEGACY_H_
 #define __LEGACY_H_
 
@@ -49,7 +51,6 @@ typedef struct {
 #pragma pack()
 
 EFI_STATUS
-EFIAPI
 BdsAddNonExistingLegacyBootOptions (
    VOID
 );
@@ -62,7 +63,6 @@ BdsAddNonExistingLegacyBootOptions (
   @retval EFI_NOT_FOUND           Fail to retrive variable of boot order.
 **/
 EFI_STATUS
-EFIAPI
 BdsDeleteAllInvalidLegacyBootOptions (
   VOID
   );
index 5ed907b301784eb047b7a5ba9862f1dce9d187eb..5bfb158a04a6a7073d64d362923e6429a0e0844b 100644 (file)
@@ -44,6 +44,7 @@ INCLUDE_DIRS    = -I $(EDK2BASE)/MdePkg \
                  -I .. \
                  -I ../refind \
                  -I ../libeg \
+                 -I ../include \
                  -I ../mok
 
 OPTIMFLAGS      = -fno-strict-aliasing -mno-red-zone -Wno-address -Os
index a84ca25bbcd4060c8a12a8eb6954ca4061e2eabf..c2616e8d2317749966710a7475f67d1bb3de7eb0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,7 @@ all:  tiano
 gnuefi:
        +make -C $(LIBEG_DIR)
        +make -C $(MOK_DIR)
+       +make -C $(EFILIB_DIR)
        +make -C $(LOADER_DIR)
        +make -C $(GPTSYNC_DIR) gnuefi
 #      +make -C $(FS_DIR) all_gnuefi
index cb27b89b6e818fdbe654e7ea20ba1338634f8366..53c8398ae93b07de83cf6928d4e715a1aee98c56 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,3 +1,18 @@
+0.8.1 (5/??/2014):
+------------------
+
+- Reversed order of search for icons by extension: rEFInd now searches
+  for PNG files before ICNS files, rather than the other way around. This
+  makes it possible to override a volume icon for rEFInd by giving it the
+  name .VolumeIcon.png, even when a .VolumeIcon.icns file exists on the
+  volume and is used by OS X.
+
+- Fixed bug that caused .VolumeIcon.icns to take higher-than-intended
+  precedence in icon setting for OS X.
+
+- Chainloading to BIOS-mode boot loaders now works on UEFI-based PCs when
+  rEFInd is built with GNU-EFI, not just when built with Tianocore.
+
 0.8.0 (5/4/2014):
 -----------------
 
index e40037fc431dd265eda3a22565bb9c90a41651b4..fa48733e8cfb7cfac5b9d3479585ce3afe2c8f61 100644 (file)
@@ -149,8 +149,6 @@ UINTN input_boolean(CHARN *prompt, BOOLEAN *bool_out)
 
 #ifdef __MAKEWITH_TIANO
 
-extern EFI_DXE_SERVICES  *gDS;
-
 // EFI_GUID gEfiDxeServicesTableGuid = { 0x05AD34BA, 0x6F02, 0x4214, { 0x95, 0x2E, 0x4D, 0xA0, 0x39, 0x8E, 0x2B, 0xB9 }};
 
 // Minimal initialization function
@@ -160,7 +158,6 @@ static VOID InitializeLib(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *System
    gBS            = SystemTable->BootServices;
    //    gRS            = SystemTable->RuntimeServices;
    gRT = SystemTable->RuntimeServices; // Some BDS functions need gRT to be set
-//   EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
 
 //   InitializeConsoleSim();
 }
index 50dff48aa30d68332f58462c1f97616f39892e9a..9d3a08259fcf244ccd5eb78393d6d294f35f8bc5 100644 (file)
@@ -43,36 +43,6 @@ EfiLibFileSystemInfo (
   IN EFI_FILE_HANDLE                FHand
   );
 
-/*EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *
-LibFileSystemVolumeLabelInfo (
-  IN EFI_FILE_HANDLE                FHand
-  );
-
-EFI_STATUS
-LibScanHandleDatabase (
-  EFI_HANDLE  DriverBindingHandle, OPTIONAL
-  UINT32      *DriverBindingHandleIndex, OPTIONAL
-  EFI_HANDLE  ControllerHandle, OPTIONAL
-  UINT32      *ControllerHandleIndex, OPTIONAL
-  UINTN       *HandleCount,
-  EFI_HANDLE  **HandleBuffer,
-  UINT32      **HandleType
-  );
-
-EFI_STATUS
-LibGetManagingDriverBindingHandles (
-  EFI_HANDLE  ControllerHandle,
-  UINTN       *DriverBindingHandleCount,
-  EFI_HANDLE  **DriverBindingHandleBuffer
-  );
-
-EFI_STATUS
-LibGetParentControllerHandles (
-  EFI_HANDLE  ControllerHandle,
-  UINTN       *ParentControllerHandleCount,
-  EFI_HANDLE  **ParentControllerHandleBuffer
-  );
-*/
 EFI_STATUS
 LibGetManagedChildControllerHandles (
   EFI_HANDLE  DriverBindingHandle,
index 86b7b6d94905371e88276f51ac3e23433689e3fd..67851382f282a01960fde99954259a7b23330e7d 100644 (file)
@@ -143,10 +143,6 @@ INTN EFIAPI StriCmp (
 extern EFI_FILE_INFO * EfiLibFileInfo (IN EFI_FILE_HANDLE      FHand);
 extern EFI_FILE_SYSTEM_INFO * EfiLibFileSystemInfo (IN EFI_FILE_HANDLE   Root);
 
-extern UINTN
-EfiDevicePathInstanceCount (
-   IN EFI_DEVICE_PATH_PROTOCOL      *DevicePath
-);
 
 extern VOID *
 EfiReallocatePool (
@@ -155,12 +151,6 @@ EfiReallocatePool (
    IN UINTN                NewSize
 );
 
-extern BOOLEAN
-TimeCompare (
-   IN EFI_TIME               *FirstTime,
-   IN EFI_TIME               *SecondTime
-);
-
 #define PoolPrint(...) CatSPrint(NULL, __VA_ARGS__)
 
 #endif
\ No newline at end of file
index e94f1eb9b62ac0e07ca32657f68ea6f0a76a0eaf..5f554220e4ee997894aea0ce38792ee9fd7a5665 100644 (file)
@@ -71,7 +71,7 @@ typedef struct {
 #define EG_EICOMPMODE_RLE           (1)
 #define EG_EICOMPMODE_EFICOMPRESS   (2)
 
-#define ICON_EXTENSIONS L"icns,png"
+#define ICON_EXTENSIONS L"png,icns"
 
 typedef struct {
     UINTN       Width;
index c6f23037fa13313948a84d06fb083dfb3f2bf8ae..9fa999bd15a671a8b921cdaacfe0541fd65ffaf2 100644 (file)
@@ -47,6 +47,7 @@
 #include "../refind/lib.h"
 #include "../include/refit_call_wrapper.h"
 #include "libeg.h"
+#include "Handle.h"
 
 #include <efiUgaDraw.h>
 #include <efiConsoleControl.h>
index ba39980a04e6a5e88690e759e17947423d6d9659..b03dfefcd5b4dc6b7341377bde446c7ea5d965cf 100644 (file)
@@ -22,8 +22,8 @@ ifeq ($(ARCH),x86_64)
 endif
 
 LOCAL_CPPFLAGS  = -I$(SRCDIR) -I$(SRCDIR)/../include -I$(SRCDIR)/../libeg -I$(SRCDIR)/../mok
-LOCAL_LDFLAGS   = -L$(SRCDIR)/../libeg/ -L$(SRCDIR)/../mok/
-LOCAL_LIBS      = -leg -lmok
+LOCAL_LDFLAGS   = -L$(SRCDIR)/../libeg/ -L$(SRCDIR)/../mok/ -L$(SRCDIR)/../EfiLib/
+LOCAL_LIBS      = -leg -lmok -lEfiLib
 
 OBJS            = main.o config.o menu.o screen.o icns.o gpt.o crc32.o lib.o driver_support.o
 #OBJS            = main.o config.o menu.o screen.o icns.o lib.o mok.o driver_support.o variables.o sha256.o pecoff.o simple_file.o security_policy.o guid.o
index 739519201dd251237ae597304ffda17eec4d748c..f8575530f075ac62cf1ebf4a80cc0edd252373da 100644 (file)
@@ -50,8 +50,8 @@
 #include <efilib.h>
 #else
 #include "../include/tiano_includes.h"
-#include "../EfiLib/GenericBdsLib.h"
 #endif
+#include "../EfiLib/GenericBdsLib.h"
 
 #include "libeg.h"
 
@@ -236,9 +236,9 @@ typedef struct {
 typedef struct {
    REFIT_MENU_ENTRY  me;
    REFIT_VOLUME      *Volume;
-#ifndef __MAKEWITH_GNUEFI
+//#ifndef __MAKEWITH_GNUEFI
    BDS_COMMON_OPTION *BdsOption;
-#endif
+//#endif
    CHAR16            *LoadOptions;
    BOOLEAN           Enabled;
 } LEGACY_ENTRY;
index 5df0aebbfad9fc3851ab1128f67dfb5faf5a4987..7ea5571102ca0afc63095a72dc373f445a1a3597 100644 (file)
 #ifndef EFI_SECURITY_VIOLATION
 #define EFI_SECURITY_VIOLATION    EFIERR (26)
 #endif
-#else
+#endif
+//#else
 #include "../EfiLib/BdsHelper.h"
 #include "../EfiLib/legacy.h"
-#endif // __MAKEWITH_GNUEFI
 
 #ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI
 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001ULL
+#else
+#define LibLocateHandle gBS->LocateHandleBuffer
 #endif
 
 //
@@ -164,7 +166,7 @@ static VOID AboutrEFInd(VOID)
 
     if (AboutMenu.EntryCount == 0) {
         AboutMenu.TitleImage = BuiltinIcon(BUILTIN_ICON_FUNC_ABOUT);
-        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.0");
+        AddMenuInfoLine(&AboutMenu, L"rEFInd Version 0.8.0.3");
         AddMenuInfoLine(&AboutMenu, L"");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2006-2010 Christoph Pfisterer");
         AddMenuInfoLine(&AboutMenu, L"Copyright (c) 2012-2014 Roderick W. Smith");
@@ -907,10 +909,12 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, REFIT_VOLUME *Vo
 
    // locate a custom icon for the loader
    // Anything found here takes precedence over the "hints" in the OSIconName variable
-   if (!Entry->me.Image)
+   if (!Entry->me.Image) {
       Entry->me.Image = egLoadIconAnyType(Volume->RootDir, PathOnly, NoExtension, GlobalConfig.IconSizes[ICON_SIZE_BIG]);
-   if (!Entry->me.Image)
+   }
+   if (!Entry->me.Image) {
       Entry->me.Image = egCopyImage(Volume->VolIconImage);
+   }
 
    // Begin creating icon "hints" by using last part of directory path leading
    // to the loader
@@ -960,9 +964,6 @@ VOID SetLoaderDefaults(LOADER_ENTRY *Entry, CHAR16 *LoaderPath, REFIT_VOLUME *Vo
       Entry->OSType = 'R';
       ShortcutLetter = 'R';
    } else if (StriCmp(LoaderPath, MACOSX_LOADER_PATH) == 0) {
-      if (Volume->VolIconImage != NULL) { // custom icon file found
-         Entry->me.Image = Volume->VolIconImage;
-      }
       MergeStrings(&OSIconName, L"mac", L',');
       Entry->OSType = 'M';
       ShortcutLetter = 'M';
@@ -1650,7 +1651,6 @@ static VOID StartLegacy(IN LEGACY_ENTRY *Entry)
 } /* static VOID StartLegacy() */
 
 // Start a device on a non-Mac using the EFI_LEGACY_BIOS_PROTOCOL
-#ifdef __MAKEWITH_TIANO
 static VOID StartLegacyUEFI(LEGACY_ENTRY *Entry)
 {
     BeginExternalScreen(TRUE, L"Booting Legacy OS (UEFI mode)");
@@ -1663,7 +1663,6 @@ static VOID StartLegacyUEFI(LEGACY_ENTRY *Entry)
     PauseForKey();
     FinishExternalScreen();
 } // static VOID StartLegacyUEFI()
-#endif // __MAKEWITH_TIANO
 
 static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume)
 {
@@ -1734,9 +1733,9 @@ static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Vo
 } /* static LEGACY_ENTRY * AddLegacyEntry() */
 
 
-#ifdef __MAKEWITH_GNUEFI
-static VOID ScanLegacyUEFI(IN UINTN DiskType){}
-#else
+// #ifdef __MAKEWITH_GNUEFI
+// static VOID ScanLegacyUEFI(IN UINTN DiskType){}
+// #else
 // default volume badge icon based on disk kind
 static EG_IMAGE * GetDiskBadge(IN UINTN DiskType) {
    EG_IMAGE * Badge = NULL;
@@ -1833,9 +1832,9 @@ static VOID ScanLegacyUEFI(IN UINTN DiskType)
 
     // If LegacyBios protocol is not implemented on this platform, then
     //we do not support this type of legacy boot on this machine.
-    Status = gBS->LocateProtocol(&gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+    Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
     if (EFI_ERROR (Status))
-        return;
+       return;
 
     // EFI calls USB drives BBS_HARDDRIVE, but we want to distinguish them,
     // so we set DiskType inappropriately elsewhere in the program and
@@ -1883,7 +1882,7 @@ static VOID ScanLegacyUEFI(IN UINTN DiskType)
         Index++;
     } // while
 } /* static VOID ScanLegacyUEFI() */
-#endif // __MAKEWITH_GNUEFI
+//#endif // __MAKEWITH_GNUEFI
 
 static VOID ScanLegacyVolume(REFIT_VOLUME *Volume, UINTN VolumeIndex) {
    UINTN VolumeIndex2;
@@ -2039,7 +2038,6 @@ static UINTN ScanDriverDir(IN CHAR16 *Path)
     return (NumFound);
 }
 
-#ifdef __MAKEWITH_GNUEFI
 static EFI_STATUS ConnectAllDriversToAllControllers(VOID)
 {
     EFI_STATUS           Status;
@@ -2107,12 +2105,6 @@ Done:
     MyFreePool (AllHandleBuffer);
     return Status;
 } /* EFI_STATUS ConnectAllDriversToAllControllers() */
-#else
-static EFI_STATUS ConnectAllDriversToAllControllers(VOID) {
-   BdsLibConnectAllDriversToAllControllers();
-   return 0;
-}
-#endif
 
 // Load all EFI drivers from rEFInd's "drivers" subdirectory and from the
 // directories specified by the user in the "scan_driver_dirs" configuration
@@ -2151,20 +2143,16 @@ static VOID LoadDrivers(VOID)
 
 // Determine what (if any) type of legacy (BIOS) boot support is available
 static VOID FindLegacyBootType(VOID) {
-#ifdef __MAKEWITH_TIANO
    EFI_STATUS                Status;
    EFI_LEGACY_BIOS_PROTOCOL  *LegacyBios;
-#endif
 
    GlobalConfig.LegacyType = LEGACY_TYPE_NONE;
 
    // UEFI-style legacy BIOS support is available only with the TianoCore EDK2
    // build environment, and then only with some EFI implementations....
-#ifdef __MAKEWITH_TIANO
-   Status = gBS->LocateProtocol (&gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
+   Status = refit_call3_wrapper(gBS->LocateProtocol, &gEfiLegacyBootProtocolGuid, NULL, (VOID **) &LegacyBios);
    if (!EFI_ERROR (Status))
       GlobalConfig.LegacyType = LEGACY_TYPE_UEFI;
-#endif
 
    // Macs have their own system. If the firmware vendor code contains the
    // string "Apple", assume it's available. Note that this overrides the
@@ -2189,16 +2177,8 @@ static VOID WarnIfLegacyProblems() {
       } while ((i < NUM_SCAN_OPTIONS) && (!found));
       if (found) {
          Print(L"NOTE: refind.conf's 'scanfor' line specifies scanning for one or more legacy\n");
-         Print(L"(BIOS) boot options; however, this is not possible because ");
-#ifdef __MAKEWITH_TIANO
-         Print(L"your computer lacks\n");
+         Print(L"(BIOS) boot options; however, this is not possible because your computer lacks\n");
          Print(L"the necessary Compatibility Support Module (CSM) support.\n");
-#else
-         Print(L"this program was\n");
-         Print(L"compiled without the necessary support. Please visit\n");
-         Print(L"http://www.rodsbooks.com/refind/getting.html and download and install a rEFInd\n");
-         Print(L"binary built with the TianoCore EDK2 to enable legacy boot support.\n");
-#endif
          PauseForKey();
       } // if (found)
    } // if no legacy support
@@ -2207,7 +2187,6 @@ static VOID WarnIfLegacyProblems() {
 // Locates boot loaders. NOTE: This assumes that GlobalConfig.LegacyType is set correctly.
 static VOID ScanForBootloaders(VOID) {
    UINTN    i;
-#ifdef __MAKEWITH_TIANO
    CHAR8    s;
    BOOLEAN  ScanForLegacy = FALSE;
 
@@ -2223,7 +2202,6 @@ static VOID ScanForBootloaders(VOID) {
       BdsDeleteAllInvalidLegacyBootOptions();
       BdsAddNonExistingLegacyBootOptions();
    } // if
-#endif
 
    // scan for loaders and tools, add them to the menu
    for (i = 0; i < NUM_SCAN_OPTIONS; i++) {
@@ -2445,7 +2423,7 @@ static VOID InitializeLib(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *System
    gRT = SystemTable->RuntimeServices; // Some BDS functions need gRT to be set
    EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
 
-   InitializeConsoleSim();
+//   InitializeConsoleSim();
 }
 
 #endif
@@ -2611,11 +2589,9 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
                 StartLegacy((LEGACY_ENTRY *)ChosenEntry);
                 break;
 
-#ifdef __MAKEWITH_TIANO
             case TAG_LEGACY_UEFI: // Boot a legacy OS on a non-Mac
                 StartLegacyUEFI((LEGACY_ENTRY *)ChosenEntry);
                 break;
-#endif
 
             case TAG_TOOL:     // Start a EFI tool
                 StartTool((LOADER_ENTRY *)ChosenEntry);