#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 }};
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");
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);
}
*
*/
+#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_
**/
+#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
**/
BDS_COMMON_OPTION *
-EFIAPI
BdsLibVariableToOption (
IN OUT LIST_ENTRY *BdsCommonOptionList,
IN CHAR16 *VariableName
**/
VOID *
-EFIAPI
BdsLibGetVariableAndSize (
IN CHAR16 *Name,
IN EFI_GUID *VendorGuid,
// 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
//
// 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;
}
\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
{\r
EFI_STATUS Status;\r
\r
- Status = gBS->LocateProtocol (\r
+ Status = refit_call3_wrapper(gBS->LocateProtocol,\r
ProtocolGuid,\r
NULL,\r
(VOID **) Interface\r
//\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
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
\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
return *FirstString - *SecondString;\r
}\r
\r
-\r
/**\r
\r
Function gets the file information from an open file descriptor, and stores it\r
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
\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
#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
//\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
\r
**/\r
VOID *\r
-EFIAPI\r
BdsLibGetVariableAndSize (\r
IN CHAR16 *Name,\r
IN EFI_GUID *VendorGuid,\r
@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
\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
\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
IN EFI_DEVICE_PATH_PROTOCOL *DevPath\r
);\r
\r
+#ifdef __MAKEWITH_TIANO\r
//\r
// Internal definitions\r
//\r
UINTN Len;\r
UINTN Maxlen;\r
} POOL_PRINT;\r
+#endif\r
\r
typedef\r
VOID\r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
BdsDeleteAllInvalidLegacyBootOptions (\r
VOID\r
);\r
@return Other value LegacyBoot options are not added.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
BdsAddNonExistingLegacyBootOptions (\r
VOID\r
);\r
@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
@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
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
# 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
*
*/
-#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;
)
{
UINTN Index;
- CHAR16 BootOption[9];
+ CHAR16 BootOption[10];
UINTN BootOptionSize;
UINT8 *BootOptionVar;
BBS_TABLE *BbsEntry;
&BootOptionSize
);
if (NULL == BootOptionVar) {
- continue;
+ continue;
}
//
Ptr += sizeof (BBS_TABLE);
*((UINT16 *) Ptr) = (UINT16) Index;
- Status = gRT->SetVariable (
+ Status = refit_call5_wrapper(gRT->SetVariable,
BootString,
&gEfiGlobalVariableGuid,
VAR_FLAG,
@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
//
// 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);
}
@return Other value LegacyBoot options are not added.
**/
EFI_STATUS
-EFIAPI
BdsAddNonExistingLegacyBootOptions (
VOID
)
mBootOptionBbsMappingCount = 0;
}
- LegacyBios->GetBbsInfo (
+ refit_call5_wrapper(LegacyBios->GetBbsInfo,
LegacyBios,
&HddCount,
&LocalHddInfo,
//
// 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;
);
if (BootOrderSize > 0) {
- Status = gRT->SetVariable (
+ Status = refit_call5_wrapper(gRT->SetVariable,
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
@retval EFI_NOT_FOUND The Boot Option Variable was not found
**/
EFI_STATUS
-EFIAPI
BdsDeleteBootOption (
IN UINTN OptionNumber,
IN OUT UINT16 *BootOrder,
@retval EFI_NOT_FOUND Fail to retrive variable of boot order.
**/
EFI_STATUS
-EFIAPI
BdsDeleteAllInvalidLegacyBootOptions (
VOID
)
return Status;
}
- LegacyBios->GetBbsInfo (
+ refit_call5_wrapper(LegacyBios->GetBbsInfo,
LegacyBios,
&HddCount,
&LocalHddInfo,
);
if (NULL == BootOptionVar) {
BootOptionSize = 0;
- Status = gRT->GetVariable (
+ Status = refit_call5_wrapper(gRT->GetVariable,
BootOption,
&gEfiGlobalVariableGuid,
NULL,
// Adjust the number of boot options.
//
if (BootOrderSize != 0) {
- Status = gRT->SetVariable (
+ Status = refit_call5_wrapper(gRT->SetVariable,
L"BootOrder",
&gEfiGlobalVariableGuid,
VAR_FLAG,
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;
-}
*
*/
+#include "LegacyBios.h"
+
#ifndef __LEGACY_H_
#define __LEGACY_H_
#pragma pack()
EFI_STATUS
-EFIAPI
BdsAddNonExistingLegacyBootOptions (
VOID
);
@retval EFI_NOT_FOUND Fail to retrive variable of boot order.
**/
EFI_STATUS
-EFIAPI
BdsDeleteAllInvalidLegacyBootOptions (
VOID
);
-I .. \
-I ../refind \
-I ../libeg \
+ -I ../include \
-I ../mok
OPTIMFLAGS = -fno-strict-aliasing -mno-red-zone -Wno-address -Os
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
+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):
-----------------
#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
gBS = SystemTable->BootServices;
// gRS = SystemTable->RuntimeServices;
gRT = SystemTable->RuntimeServices; // Some BDS functions need gRT to be set
-// EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
// InitializeConsoleSim();
}
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,
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 (
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
#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;
#include "../refind/lib.h"
#include "../include/refit_call_wrapper.h"
#include "libeg.h"
+#include "Handle.h"
#include <efiUgaDraw.h>
#include <efiConsoleControl.h>
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
#include <efilib.h>
#else
#include "../include/tiano_includes.h"
-#include "../EfiLib/GenericBdsLib.h"
#endif
+#include "../EfiLib/GenericBdsLib.h"
#include "libeg.h"
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;
#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
//
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");
// 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
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';
} /* 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)");
PauseForKey();
FinishExternalScreen();
} // static VOID StartLegacyUEFI()
-#endif // __MAKEWITH_TIANO
static LEGACY_ENTRY * AddLegacyEntry(IN CHAR16 *LoaderTitle, IN REFIT_VOLUME *Volume)
{
} /* 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;
// 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
Index++;
} // while
} /* static VOID ScanLegacyUEFI() */
-#endif // __MAKEWITH_GNUEFI
+//#endif // __MAKEWITH_GNUEFI
static VOID ScanLegacyVolume(REFIT_VOLUME *Volume, UINTN VolumeIndex) {
UINTN VolumeIndex2;
return (NumFound);
}
-#ifdef __MAKEWITH_GNUEFI
static EFI_STATUS ConnectAllDriversToAllControllers(VOID)
{
EFI_STATUS Status;
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
// 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
} 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
// 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;
BdsDeleteAllInvalidLegacyBootOptions();
BdsAddNonExistingLegacyBootOptions();
} // if
-#endif
// scan for loaders and tools, add them to the menu
for (i = 0; i < NUM_SCAN_OPTIONS; i++) {
gRT = SystemTable->RuntimeServices; // Some BDS functions need gRT to be set
EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
- InitializeConsoleSim();
+// InitializeConsoleSim();
}
#endif
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);