OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
fsw_efi.c File Reference
#include "fsw_efi.h"

Go to the source code of this file.

Macros

#define DEBUG_LEVEL   0
 
#define FSTYPE   ext2
 
#define FSW_EFI_STRINGIFY(x)
 
#define FSW_EFI_DRIVER_NAME(t)
 

Functions

EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
void fsw_efi_change_blocksize (struct fsw_volume *vol, fsw_u32 old_phys_blocksize, fsw_u32 old_log_blocksize, fsw_u32 new_phys_blocksize, fsw_u32 new_log_blocksize)
 
fsw_status_t fsw_efi_read_block (struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
 
EFI_STATUS fsw_efi_map_status (fsw_status_t fsw_status, FSW_VOLUME_DATA *Volume)
 
EFI_STATUS EFIAPI fsw_efi_FileSystem_OpenVolume (IN EFI_FILE_IO_INTERFACE *This, OUT EFI_FILE **Root)
 
EFI_STATUS fsw_efi_dnode_to_FileHandle (IN struct fsw_dnode *dno, OUT EFI_FILE **NewFileHandle)
 
EFI_STATUS fsw_efi_file_read (IN FSW_FILE_DATA *File, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS fsw_efi_file_getpos (IN FSW_FILE_DATA *File, OUT UINT64 *Position)
 
EFI_STATUS fsw_efi_file_setpos (IN FSW_FILE_DATA *File, IN UINT64 Position)
 
EFI_STATUS fsw_efi_dir_open (IN FSW_FILE_DATA *File, OUT EFI_FILE **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_STATUS fsw_efi_dir_read (IN FSW_FILE_DATA *File, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS fsw_efi_dir_setpos (IN FSW_FILE_DATA *File, IN UINT64 Position)
 
EFI_STATUS fsw_efi_dnode_getinfo (IN FSW_FILE_DATA *File, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS fsw_efi_dnode_fill_FileInfo (IN FSW_VOLUME_DATA *Volume, IN struct fsw_dnode *dno, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS fsw_efi_bless_info (IN FSW_VOLUME_DATA *Volume, IN UINT32 type, OUT VOID *Buffer, IN OUT UINTN *BufferSize)
 
struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME (FSTYPE)
 
EFI_STATUS EFIAPI fsw_efi_main (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Open (IN EFI_FILE *This, OUT EFI_FILE **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Close (IN EFI_FILE *This)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Delete (IN EFI_FILE *This)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Read (IN EFI_FILE *This, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Write (IN EFI_FILE *This, IN OUT UINTN *BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetPosition (IN EFI_FILE *This, OUT UINT64 *Position)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetPosition (IN EFI_FILE *This, IN UINT64 Position)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_GetInfo (IN EFI_FILE *This, IN EFI_GUID *InformationType, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_SetInfo (IN EFI_FILE *This, IN EFI_GUID *InformationType, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI fsw_efi_FileHandle_Flush (IN EFI_FILE *This)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL fsw_efi_DriverBinding_table
 
EFI_COMPONENT_NAME_PROTOCOL fsw_efi_ComponentName_table
 
struct fsw_host_table fsw_efi_host_table
 

Detailed Description

EFI host environment code.

Definition in file fsw_efi.c.

Macro Definition Documentation

◆ DEBUG_LEVEL

#define DEBUG_LEVEL   0

Definition at line 40 of file fsw_efi.c.

◆ FSTYPE

#define FSTYPE   ext2

The file system type name to use.

Definition at line 45 of file fsw_efi.c.

◆ FSW_EFI_DRIVER_NAME

#define FSW_EFI_DRIVER_NAME ( t)
Value:
L"Fsw " FSW_EFI_STRINGIFY(t) L" File System Driver"
#define FSW_EFI_STRINGIFY(x)
Definition fsw_efi.c:49

Expands to the EFI driver name given the file system type name.

Definition at line 51 of file fsw_efi.c.

◆ FSW_EFI_STRINGIFY

#define FSW_EFI_STRINGIFY ( x)
Value:
#x

Helper macro for stringification.

Definition at line 49 of file fsw_efi.c.

Function Documentation

◆ fsw_efi_bless_info()

EFI_STATUS fsw_efi_bless_info ( IN FSW_VOLUME_DATA * Volume,
IN UINT32 type,
OUT VOID * Buffer,
IN OUT UINTN * BufferSize )

Definition at line 870 of file fsw_efi.c.

◆ fsw_efi_change_blocksize()

void fsw_efi_change_blocksize ( struct fsw_volume * vol,
fsw_u32 old_phys_blocksize,
fsw_u32 old_log_blocksize,
fsw_u32 new_phys_blocksize,
fsw_u32 new_log_blocksize )

FSW interface function for block size changes. This function is called by the FSW core when the file system driver changes the block sizes for the volume.

Definition at line 422 of file fsw_efi.c.

◆ fsw_efi_ComponentName_GetControllerName()

EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName ( IN EFI_COMPONENT_NAME_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 * Language,
OUT CHAR16 ** ControllerName )

Component Name EFI protocol, GetControllerName function. Not implemented because this is not a "bus" driver in the sense of the EFI Driver Model.

Definition at line 408 of file fsw_efi.c.

◆ fsw_efi_ComponentName_GetDriverName()

EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL * This,
IN CHAR8 * Language,
OUT CHAR16 ** DriverName )

Component Name EFI protocol, GetDriverName function. Used by the EFI environment to inquire the name of this driver. The name returned is based on the file system type actually used in compilation.

Definition at line 389 of file fsw_efi.c.

◆ fsw_efi_dir_open()

EFI_STATUS fsw_efi_dir_open ( IN FSW_FILE_DATA * File,
OUT EFI_FILE ** NewHandle,
IN CHAR16 * FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes )

Open function used to open new file handles relative to a directory. In EFI, the "open file" function is implemented by directory file handles and is passed a relative or volume-absolute path to the file or directory to open. We use fsw_dnode_lookup_path to find the node plus an additional call to fsw_dnode_resolve because EFI has no concept of symbolic links.

Definition at line 771 of file fsw_efi.c.

◆ fsw_efi_dir_read()

EFI_STATUS fsw_efi_dir_read ( IN FSW_FILE_DATA * File,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

Read function for directories. A file handle read on a directory retrieves the next directory entry.

Definition at line 820 of file fsw_efi.c.

◆ fsw_efi_dir_setpos()

EFI_STATUS fsw_efi_dir_setpos ( IN FSW_FILE_DATA * File,
IN UINT64 Position )

Set file position for directories. The only allowed set position operation for directories is to rewind the directory completely by setting the position to zero.

Definition at line 858 of file fsw_efi.c.

◆ fsw_efi_dnode_fill_FileInfo()

EFI_STATUS fsw_efi_dnode_fill_FileInfo ( IN FSW_VOLUME_DATA * Volume,
IN struct fsw_dnode * dno,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

Common function to fill an EFI_FILE_INFO with information about a dnode.

Definition at line 1043 of file fsw_efi.c.

◆ fsw_efi_dnode_getinfo()

EFI_STATUS fsw_efi_dnode_getinfo ( IN FSW_FILE_DATA * File,
IN EFI_GUID * InformationType,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

Get file or volume information. This function implements the GetInfo call for all file handles. Control is dispatched according to the type of information requested by the caller.

Definition at line 927 of file fsw_efi.c.

◆ fsw_efi_dnode_to_FileHandle()

EFI_STATUS fsw_efi_dnode_to_FileHandle ( IN struct fsw_dnode * dno,
OUT EFI_FILE ** NewFileHandle )

Set up a file handle for a dnode. This function allocates a data structure for a file handle, opens a FSW shandle and populates the EFI_FILE structure with the interface functions.

Definition at line 666 of file fsw_efi.c.

◆ fsw_efi_DriverBinding_Start()

EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start ( IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath )

Driver Binding EFI protocol, Start function. This function is called by EFI to start driving the given device. It is still possible at this point to return EFI_UNSUPPORTED, and in fact we will do so if the file system driver cannot find the superblock signature (or equivalent) that it expects.

This function allocates memory for a per-volume structure, opens the required protocols (just Disk I/O in our case, Block I/O is only looked at to get the MediaId field), and lets the FSW core mount the file system. If successful, an EFI Simple File System protocol is exported on the device handle.

Definition at line 246 of file fsw_efi.c.

◆ fsw_efi_DriverBinding_Stop()

EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop ( IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE * ChildHandleBuffer )

Driver Binding EFI protocol, Stop function. This function is called by EFI to stop the driver on the given device. This translates to an unmount call for the FSW core.

We assume that all file handles on the volume have been closed before the driver is stopped. At least with the EFI shell, that is actually the case; it closes all file handles between commands.

Definition at line 331 of file fsw_efi.c.

◆ fsw_efi_DriverBinding_Supported()

EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported ( IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath )

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 if the device is a disk (i.e. that it supports the Block I/O and Disk I/O protocols) and implicitly checks if the disk is already in use by another driver.

Definition at line 198 of file fsw_efi.c.

◆ fsw_efi_file_getpos()

EFI_STATUS fsw_efi_file_getpos ( IN FSW_FILE_DATA * File,
OUT UINT64 * Position )

Get file position for regular files.

Definition at line 741 of file fsw_efi.c.

◆ fsw_efi_file_read()

EFI_STATUS fsw_efi_file_read ( IN FSW_FILE_DATA * File,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

Data read function for regular files. Calls through to fsw_shandle_read.

Definition at line 718 of file fsw_efi.c.

◆ fsw_efi_file_setpos()

EFI_STATUS fsw_efi_file_setpos ( IN FSW_FILE_DATA * File,
IN UINT64 Position )

Set file position for regular files. EFI specifies the all-ones value to be a special value for the end of the file.

Definition at line 753 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Close()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Close ( IN EFI_FILE * This)

File Handle EFI protocol, Close function. Closes the FSW shandle and frees the memory used for the structure.

Definition at line 524 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Delete()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Delete ( IN EFI_FILE * This)

File Handle EFI protocol, Delete function. Calls through to Close and returns a warning because this driver is read-only.

Definition at line 543 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Flush()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Flush ( IN EFI_FILE * This)

File Handle EFI protocol, Flush function. Returns unsupported status because this driver is read-only.

Definition at line 654 of file fsw_efi.c.

◆ fsw_efi_FileHandle_GetInfo()

EFI_STATUS EFIAPI fsw_efi_FileHandle_GetInfo ( IN EFI_FILE * This,
IN EFI_GUID * InformationType,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

File Handle EFI protocol, GetInfo function. Dispatches to the common function implementing this.

Definition at line 625 of file fsw_efi.c.

◆ fsw_efi_FileHandle_GetPosition()

EFI_STATUS EFIAPI fsw_efi_FileHandle_GetPosition ( IN EFI_FILE * This,
OUT UINT64 * Position )

File Handle EFI protocol, GetPosition function. Dispatches the call based on the kind of file handle.

Definition at line 592 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Open()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Open ( IN EFI_FILE * This,
OUT EFI_FILE ** NewHandle,
IN CHAR16 * FileName,
IN UINT64 OpenMode,
IN UINT64 Attributes )

File Handle EFI protocol, Open function. Dispatches the call based on the kind of file handle.

Definition at line 505 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Read()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Read ( IN EFI_FILE * This,
IN OUT UINTN * BufferSize,
OUT VOID * Buffer )

File Handle EFI protocol, Read function. Dispatches the call based on the kind of file handle.

Definition at line 561 of file fsw_efi.c.

◆ fsw_efi_FileHandle_SetInfo()

EFI_STATUS EFIAPI fsw_efi_FileHandle_SetInfo ( IN EFI_FILE * This,
IN EFI_GUID * InformationType,
IN UINTN BufferSize,
IN VOID * Buffer )

File Handle EFI protocol, SetInfo function. Returns unsupported status because this driver is read-only.

Definition at line 640 of file fsw_efi.c.

◆ fsw_efi_FileHandle_SetPosition()

EFI_STATUS EFIAPI fsw_efi_FileHandle_SetPosition ( IN EFI_FILE * This,
IN UINT64 Position )

File Handle EFI protocol, SetPosition function. Dispatches the call based on the kind of file handle.

Definition at line 608 of file fsw_efi.c.

◆ fsw_efi_FileHandle_Write()

EFI_STATUS EFIAPI fsw_efi_FileHandle_Write ( IN EFI_FILE * This,
IN OUT UINTN * BufferSize,
IN VOID * Buffer )

File Handle EFI protocol, Write function. Returns unsupported status because this driver is read-only.

Definition at line 579 of file fsw_efi.c.

◆ fsw_efi_FileSystem_OpenVolume()

EFI_STATUS EFIAPI fsw_efi_FileSystem_OpenVolume ( IN EFI_FILE_IO_INTERFACE * This,
OUT EFI_FILE ** Root )

File System EFI protocol, OpenVolume function. Creates a file handle for the root directory and returns it. Note that this function may be called multiple times and returns a new file handle each time. Each returned handle is closed by the client using it.

Definition at line 485 of file fsw_efi.c.

◆ fsw_efi_main()

EFI_STATUS EFIAPI fsw_efi_main ( IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE * SystemTable )

Image entry point. Installs the Driver Binding and Component Name protocols on the image's handle. Actually mounting a file system is initiated through the Driver Binding protocol at the firmware's request.

Definition at line 162 of file fsw_efi.c.

◆ fsw_efi_map_status()

EFI_STATUS fsw_efi_map_status ( fsw_status_t fsw_status,
FSW_VOLUME_DATA * Volume )

Map FSW status codes to EFI status codes. The FSW_IO_ERROR code is only produced by fsw_efi_read_block, so we map it back to the EFI status code remembered from the last I/O operation.

Definition at line 458 of file fsw_efi.c.

◆ fsw_efi_read_block()

fsw_status_t fsw_efi_read_block ( struct fsw_volume * vol,
fsw_u32 phys_bno,
void * buffer )

FSW interface function to read data blocks. This function is called by the FSW core to read a block of data from the device. The buffer is allocated by the core code.

Definition at line 434 of file fsw_efi.c.

◆ FSW_FSTYPE_TABLE_NAME()

struct fsw_fstype_table FSW_FSTYPE_TABLE_NAME ( FSTYPE )
extern

Variable Documentation

◆ fsw_efi_ComponentName_table

EFI_COMPONENT_NAME_PROTOCOL fsw_efi_ComponentName_table
Initial value:
= {
"eng"
}
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
Definition fsw_efi.c:408
EFI_STATUS EFIAPI fsw_efi_ComponentName_GetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition fsw_efi.c:389

Interface structure for the EFI Component Name protocol.

Definition at line 136 of file fsw_efi.c.

◆ fsw_efi_DriverBinding_table

EFI_DRIVER_BINDING_PROTOCOL fsw_efi_DriverBinding_table
Initial value:
= {
0x10,
NULL,
NULL
}
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Start(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition fsw_efi.c:246
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Supported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition fsw_efi.c:198
EFI_STATUS EFIAPI fsw_efi_DriverBinding_Stop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition fsw_efi.c:331

Interface structure for the EFI Driver Binding protocol.

Definition at line 123 of file fsw_efi.c.

◆ fsw_efi_host_table

struct fsw_host_table fsw_efi_host_table
Initial value:
= {
}
@ FSW_STRING_TYPE_UTF16
Definition fsw_core.h:188
fsw_status_t fsw_efi_read_block(struct fsw_volume *vol, fsw_u32 phys_bno, void *buffer)
Definition fsw_efi.c:434
void fsw_efi_change_blocksize(struct fsw_volume *vol, fsw_u32 old_phys_blocksize, fsw_u32 old_log_blocksize, fsw_u32 new_phys_blocksize, fsw_u32 new_log_blocksize)
Definition fsw_efi.c:422

Dispatch table for our FSW host driver.

Definition at line 146 of file fsw_efi.c.