TianoCore EDK2 master
|
#include <PiDxe.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/FirmwareVolumeBlock.h>
#include <Protocol/BlockIo.h>
#include <Protocol/LoadFile.h>
#include <Protocol/SimpleFileSystem.h>
#include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h>
Go to the source code of this file.
Data Structures | |
struct | EFI_OPEN_FILE |
Public information about the open file. More... | |
Macros | |
#define | MAX_PATHNAME 0x200 |
Enumerations | |
enum | EFI_OPEN_FILE_TYPE { EfiOpenLoadFile , EfiOpenMemoryBuffer , EfiOpenFirmwareVolume , EfiOpenFileSystem , EfiOpenBlockIo , EfiOpenTftp , EfiOpenMaxValue } |
Type of the file that has been opened. More... | |
enum | EFI_SEEK_TYPE { EfiSeekStart , EfiSeekCurrent , EfiSeekEnd , EfiSeekMax } |
Type of Seek to perform. More... | |
Functions | |
EFI_OPEN_FILE * | EfiOpen (IN CHAR8 *PathName, IN CONST UINT64 OpenMode, IN CONST EFI_SECTION_TYPE SectionType) |
EFI_STATUS | EfiCopyFile (IN CHAR8 *DestinationFile, IN CHAR8 *SourceFile) |
EFI_OPEN_FILE * | EfiDeviceOpenByType (IN EFI_OPEN_FILE_TYPE DeviceType, IN UINTN Index) |
EFI_STATUS | EfiClose (IN EFI_OPEN_FILE *Stream) |
UINTN | EfiTell (IN EFI_OPEN_FILE *Stream, OUT UINT64 *CurrentPosition OPTIONAL) |
EFI_STATUS | EfiSeek (IN EFI_OPEN_FILE *Stream, IN EFI_LBA Offset, IN EFI_SEEK_TYPE SeekType) |
EFI_STATUS | EfiRead (IN EFI_OPEN_FILE *Stream, OUT VOID *Buffer, OUT UINTN *BufferSize) |
EFI_STATUS | EfiReadAllocatePool (IN EFI_OPEN_FILE *Stream, OUT VOID **Buffer, OUT UINTN *BufferSize) |
EFI_STATUS | EfiWrite (IN EFI_OPEN_FILE *Stream, OUT VOID *Buffer, OUT UINTN *BufferSize) |
UINTN | EfiGetDeviceCounts (IN EFI_OPEN_FILE_TYPE Type) |
EFI_STATUS | EfiSetCwd (IN CHAR8 *Cwd) |
CHAR8 * | EfiGetCwd (VOID) |
Library functions that perform file IO. Memory buffer, file system, and firmware volume operations are supported.
Copyright (c) 2007, Intel Corporation. All rights reserved.
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Basic support for opening files on different device types. The device string is in the form of DevType:Path. Current DevType is required as there is no current mounted device concept of current working directory concept implement by this library.
Device names are case insensitive and only check the leading characters for unique matches. Thus the following are all the same: LoadFile0: l0: L0: Lo0:
Supported Device Names: A0x1234:0x12 - A memory buffer starting at address 0x1234 for 0x12 bytes l1: - EFI LoadFile device one. B0: - EFI BlockIo zero. fs3: - EFI Simple File System device 3 Fv2: - EFI Firmware Volume device 2 1.2.3.4:name - TFTP IP and file name
Definition in file EfiFileLib.h.
#define MAX_PATHNAME 0x200 |
Definition at line 45 of file EfiFileLib.h.
enum EFI_OPEN_FILE_TYPE |
Type of the file that has been opened.
Definition at line 48 of file EfiFileLib.h.
enum EFI_SEEK_TYPE |
Type of Seek to perform.
Definition at line 102 of file EfiFileLib.h.
EFI_STATUS EfiClose | ( | IN EFI_OPEN_FILE * | Stream | ) |
EFI_OPEN_FILE * EfiDeviceOpenByType | ( | IN EFI_OPEN_FILE_TYPE | DeviceType, |
IN UINTN | Index | ||
) |
Use DeviceType and Index to form a valid PathName and try and open it.
DeviceType | Device type to open |
Index | Device Index to use. Zero relative. |
CHAR8 * EfiGetCwd | ( | VOID | ) |
Set the Current Working Directory (CWD). If a call is made to EfiOpen () and the path does not contain a device name, The CWD is prepended to the path.
Cwd | Current Working Directory |
UINTN EfiGetDeviceCounts | ( | IN EFI_OPEN_FILE_TYPE | Type | ) |
Return the number of devices of the current type active in the system
Type | Device type to check |
EFI_OPEN_FILE * EfiOpen | ( | IN CHAR8 * | PathName, |
IN CONST UINT64 | OpenMode, | ||
IN CONST EFI_SECTION_TYPE | SectionType | ||
) |
Open a device named by PathName. The PathName includes a device name and path separated by a :. See file header for more details on the PathName syntax. There is no checking to prevent a file from being opened more than one type.
SectionType is only used to open an FV. Each file in an FV contains multiple sections and only the SectionType section is opened.
For any file that is opened with EfiOpen() must be closed with EfiClose().
PathName | Path to parse to open |
OpenMode | Same as EFI_FILE.Open() |
SectionType | Section in FV to open. |
EFI_STATUS EfiRead | ( | IN EFI_OPEN_FILE * | Stream, |
OUT VOID * | Buffer, | ||
OUT UINTN * | BufferSize | ||
) |
Read BufferSize bytes from the current location in the file. For load file and FV case you must read the entire file.
Stream | Open File Handle |
Buffer | Caller allocated buffer. |
BufferSize | Size of buffer in bytes. |
EFI_STATUS EfiReadAllocatePool | ( | IN EFI_OPEN_FILE * | Stream, |
OUT VOID ** | Buffer, | ||
OUT UINTN * | BufferSize | ||
) |
Read the entire file into a buffer. This routine allocates the buffer and returns it to the user full of the read data.
This is very useful for load file where it's hard to know how big the buffer must be.
Stream | Open File Handle |
Buffer | Pointer to buffer to return. |
BufferSize | Pointer to Size of buffer return.. |
EFI_STATUS EfiSeek | ( | IN EFI_OPEN_FILE * | Stream, |
IN EFI_LBA | Offset, | ||
IN EFI_SEEK_TYPE | SeekType | ||
) |
Seek to the Offset location in the file. LoadFile and FV device types do not support EfiSeek(). It is not possible to grow the file size using EfiSeek().
SeekType defines how use Offset to calculate the new file position: EfiSeekStart : Position = Offset EfiSeekCurrent: Position is Offset bytes from the current position EfiSeekEnd : Only supported if Offset is zero to seek to end of file.
Stream | Open File Handle |
Offset | Offset to seek too. |
SeekType | Type of seek to perform |
EFI_STATUS EfiSetCwd | ( | IN CHAR8 * | Cwd | ) |
Set the Current Working Directory (CWD). If a call is made to EfiOpen () and the path does not contain a device name, The CWD is prepended to the path.
Cwd | Current Working Directory to set |
UINTN EfiTell | ( | IN EFI_OPEN_FILE * | Stream, |
OUT UINT64 *CurrentPosition | OPTIONAL | ||
) |
Return the size of the file represented by Stream. Also return the current Seek position. Opening a file will enable a valid file size to be returned. LoadFile is an exception as a load file size is set to zero.
Stream | Open File Handle |
EFI_STATUS EfiWrite | ( | IN EFI_OPEN_FILE * | Stream, |
OUT VOID * | Buffer, | ||
OUT UINTN * | BufferSize | ||
) |
Write data back to the file.
Stream | Open File Handle |
Buffer | Pointer to buffer to return. |
BufferSize | Pointer to Size of buffer return.. |