*/
#include "fsw_efi.h"
+#include "fsw_core.h"
+#ifdef __MAKEWITH_GNUEFI
+#include "edk2/DriverBinding.h"
+#include "edk2/ComponentName.h"
+#endif
+#include "../include/refit_call_wrapper.h"
#define DEBUG_LEVEL 0
#ifndef FSTYPE
-#ifdef VBOX
#error FSTYPE must be defined!
-#else
-#define FSTYPE ext2
-#endif
#endif
#define DEBUG_VBFS 1
-// CHAR8 *msgCursor;
-// MESSAGE_LOG_PROTOCOL *Msg = NULL;
#if DEBUG_VBFS==2
#define DBG(x...) AsciiPrint(x)
#define DBG(x...)
#endif
+#ifdef __MAKEWITH_GNUEFI
+
+#define EFI_DISK_IO_PROTOCOL_GUID \
+ { \
+ 0xce345171, 0xba0b, 0x11d2, {0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+#define EFI_BLOCK_IO_PROTOCOL_GUID \
+ { \
+ 0x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
+ }
+
+EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID;
+EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID;
+EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
+EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID;
+EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID;
+EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID;
+#define SimpleFileSystemProtocol FileSystemProtocol
+#endif
/** Helper macro for stringification. */
#define FSW_EFI_STRINGIFY(x) #x
/** Expands to the EFI driver name given the file system type name. */
-#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.4.0 " FSW_EFI_STRINGIFY(t) L" File System Driver"
+#define FSW_EFI_DRIVER_NAME(t) L"rEFInd 0.6.5 " FSW_EFI_STRINGIFY(t) L" File System Driver"
// function prototypes
EFI_COMPONENT_NAME_PROTOCOL fsw_efi_ComponentName_table = {
fsw_efi_ComponentName_GetDriverName,
fsw_efi_ComponentName_GetControllerName,
- "eng"
+ (CHAR8*) "eng"
};
/**
{
EFI_STATUS Status;
-#ifndef VBOX
+#ifndef HOST_EFI_EDK2
+ // Not available in EDK2 toolkit
InitializeLib(ImageHandle, SystemTable);
#endif
fsw_efi_DriverBinding_table.ImageHandle = ImageHandle;
fsw_efi_DriverBinding_table.DriverBindingHandle = ImageHandle;
// install Driver Binding protocol
- Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
- &PROTO_NAME(DriverBindingProtocol),
+ Status = refit_call4_wrapper(BS->InstallProtocolInterface, &fsw_efi_DriverBinding_table.DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
EFI_NATIVE_INTERFACE,
&fsw_efi_DriverBinding_table);
if (EFI_ERROR (Status)) {
}
// install Component Name protocol
- Status = BS->InstallProtocolInterface(&fsw_efi_DriverBinding_table.DriverBindingHandle,
- &PROTO_NAME(ComponentNameProtocol),
+ Status = refit_call4_wrapper(BS->InstallProtocolInterface, &fsw_efi_DriverBinding_table.DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
EFI_NATIVE_INTERFACE,
&fsw_efi_ComponentName_table);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
+#ifdef __MAKEWITH_GNUEFI
+EFI_DRIVER_ENTRY_POINT(fsw_efi_main)
+#endif
+
/**
* Driver Binding EFI protocol, Supported function. This function is called by EFI
* to test if this driver can handle a certain device. Our implementation only checks
// we check for both DiskIO and BlockIO protocols
// first, open DiskIO
- Status = BS->OpenProtocol(ControllerHandle,
+ Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
&PROTO_NAME(DiskIoProtocol),
(VOID **) &DiskIo,
This->DriverBindingHandle,
return Status;
// we were just checking, close it again
- BS->CloseProtocol(ControllerHandle,
+ refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
&PROTO_NAME(DiskIoProtocol),
This->DriverBindingHandle,
ControllerHandle);
// next, check BlockIO without actually opening it
- Status = BS->OpenProtocol(ControllerHandle,
+ Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
&PROTO_NAME(BlockIoProtocol),
NULL,
This->DriverBindingHandle,
#endif
// open consumed protocols
- Status = BS->OpenProtocol(ControllerHandle,
+ Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
&PROTO_NAME(BlockIoProtocol),
(VOID **) &BlockIo,
This->DriverBindingHandle,
return Status;
}
- Status = BS->OpenProtocol(ControllerHandle,
+ Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
&PROTO_NAME(DiskIoProtocol),
(VOID **) &DiskIo,
This->DriverBindingHandle,
// register the SimpleFileSystem protocol
Volume->FileSystem.Revision = EFI_FILE_IO_INTERFACE_REVISION;
Volume->FileSystem.OpenVolume = fsw_efi_FileSystem_OpenVolume;
- Status = BS->InstallMultipleProtocolInterfaces(&ControllerHandle,
+ Status = refit_call4_wrapper(BS->InstallMultipleProtocolInterfaces, &ControllerHandle,
&PROTO_NAME(SimpleFileSystemProtocol),
&Volume->FileSystem,
NULL);
fsw_unmount(Volume->vol);
FreePool(Volume);
- BS->CloseProtocol(ControllerHandle,
+ refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
&PROTO_NAME(DiskIoProtocol),
This->DriverBindingHandle,
ControllerHandle);
#endif
// get the installed SimpleFileSystem interface
- Status = BS->OpenProtocol(ControllerHandle,
+ Status = refit_call6_wrapper(BS->OpenProtocol, ControllerHandle,
&PROTO_NAME(SimpleFileSystemProtocol),
(VOID **) &FileSystem,
This->DriverBindingHandle,
Volume = FSW_VOLUME_FROM_FILE_SYSTEM(FileSystem);
// uninstall Simple File System protocol
- Status = BS->UninstallMultipleProtocolInterfaces(ControllerHandle,
+ Status = refit_call4_wrapper(BS->UninstallMultipleProtocolInterfaces, ControllerHandle,
&PROTO_NAME(SimpleFileSystemProtocol), &Volume->FileSystem,
NULL);
if (EFI_ERROR(Status)) {
FreePool(Volume);
// close the consumed protocols
- Status = BS->CloseProtocol(ControllerHandle,
+ Status = refit_call4_wrapper(BS->CloseProtocol, ControllerHandle,
&PROTO_NAME(DiskIoProtocol),
This->DriverBindingHandle,
ControllerHandle);
// FSW_MSG_DEBUGV((FSW_MSGSTR("fsw_efi_read_block: %d (%d)\n"), phys_bno, vol->phys_blocksize));
// read from disk
- Status = Volume->DiskIo->ReadDisk(Volume->DiskIo, Volume->MediaId,
+ Status = refit_call5_wrapper(Volume->DiskIo->ReadDisk, Volume->DiskIo, Volume->MediaId,
(UINT64)phys_bno * vol->phys_blocksize,
vol->phys_blocksize,
buffer);
{
EFI_STATUS Status;
- Status = This->Close(This);
+ Status = refit_call1_wrapper(This->Close, This);
if (Status == EFI_SUCCESS) {
// this driver is read-only
Status = EFI_WARN_DELETE_FAILURE;
* to be a special value for the end of the file.
*/
-EFI_STATUS fsw_efi_file_setpos(IN FSW_FILE_DATA *File,
- IN UINT64 Position)
+EFI_STATUS fsw_efi_file_setpos(IN FSW_FILE_DATA *File, IN UINT64 Position)
{
if (Position == 0xFFFFFFFFFFFFFFFFULL)
File->shand.pos = File->shand.dnode->size;
lookup_path.data = FileName;
// resolve the path (symlinks along the way are automatically resolved)
- Status = fsw_efi_map_status(fsw_dnode_lookup_path(File->shand.dnode, &lookup_path, '\\', &dno),
- Volume);
+ Status = fsw_efi_map_status(fsw_dnode_lookup_path(File->shand.dnode, &lookup_path, '\\', &dno), Volume);
if (EFI_ERROR(Status))
return Status;
// if the final node is a symlink, also resolve it
- Status = fsw_efi_map_status(fsw_dnode_resolve(dno, &target_dno),
- Volume);
+ Status = fsw_efi_map_status(fsw_dnode_resolve(dno, &target_dno), Volume);
fsw_dnode_release(dno);
if (EFI_ERROR(Status))
return Status;
#endif
// read the next entry
- Status = fsw_efi_map_status(fsw_dnode_dir_read(&File->shand, &dno),
- Volume);
+ Status = fsw_efi_map_status(fsw_dnode_dir_read(&File->shand, &dno), Volume);
if (Status == EFI_NOT_FOUND) {
// end of directory
*BufferSize = 0;
* position to zero.
*/
-EFI_STATUS fsw_efi_dir_setpos(IN FSW_FILE_DATA *File,
- IN UINT64 Position)
+EFI_STATUS fsw_efi_dir_setpos(IN FSW_FILE_DATA *File, IN UINT64 Position)
{
if (Position == 0) {
File->shand.pos = 0;