In my UEFI Application, I am using the EFI Simple Filesystem protocol to read and create files in the ESP partition.
My question is, is this protocol always available? Meaning can I assume this protocol always exists no matter the motherboard model? Meaning can I be sure that the following function never fails in my UEFI Application (during BOOT obviously, so gBS is available) :
Status = gBS->LocateProtocol(
&gEfiSimpleFileSystemProtocolGuid,
NULL,
(VOID**)&simpleFileSystem);
If not, then how can read and create files in my UEFI Application in a way that I can be sure it works in all motherboard models?
I have seen some codes that check for gEfiLoadFile2ProtocolGuid
and gEfiLoadFileProtocolGuid
, in case gEfiSimpleFileSystemProtocolGuid
is not available, is this necessary?
Following is a edk2 sample code that does what I describe:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Image/Image.c
It will be available on most, if not all, FAT12/16/32 formated partitions, because this a requirement in the specification:
The firmware automatically creates handles for any block device that supports the following file system formats:
• FAT12
• FAT16
• FAT32
But, like most protocols, you can never be sure that it is available on all systems. Even if the driver is loaded there may be no instance of the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL available. An example would be a client without local storage that is booted via PXE.