/** @file\r
- Library functions that perform file IO. Memory buffer, file system, and \r
- fimrware volume operations are supproted. \r
+ Library functions that perform file IO. Memory buffer, file system, and\r
+ firmware volume operations are supported.\r
\r
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
Basic support for opening files on different device types. The device string\r
is in the form of DevType:Path. Current DevType is required as there is no\r
current mounted device concept of current working directory concept implement\r
by this library.\r
\r
- Device names are case insensative and only check the leading characters for \r
+ Device names are case insensitive and only check the leading characters for\r
unique matches. Thus the following are all the same:\r
LoadFile0:\r
l0:\r
l1: - EFI LoadFile device one.\r
B0: - EFI BlockIo zero.\r
fs3: - EFI Simple File System device 3\r
- Fv2: - EFI Firmware VOlume device 2\r
+ Fv2: - EFI Firmware Volume device 2\r
1.2.3.4:name - TFTP IP and file name\r
- \r
+\r
**/\r
\r
#ifndef __EFI_FILE_LIB_H__\r
#include <Guid/FileInfo.h>\r
#include <Guid/FileSystemInfo.h>\r
\r
-#define MAX_PATHNAME 0x200\r
+#define MAX_PATHNAME 0x200\r
\r
-/// Type of the file that has been opened \r
+/// Type of the file that has been opened\r
typedef enum {\r
EfiOpenLoadFile,\r
EfiOpenMemoryBuffer,\r
EfiOpenMaxValue\r
} EFI_OPEN_FILE_TYPE;\r
\r
-\r
/// Public information about the open file\r
typedef struct {\r
- UINTN Version; // Common information \r
- EFI_OPEN_FILE_TYPE Type;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_STATUS LastError;\r
- EFI_HANDLE EfiHandle; \r
- CHAR8 *DeviceName;\r
- CHAR8 *FileName;\r
-\r
- UINT64 CurrentPosition; // Information for Seek\r
- UINT64 MaxPosition;\r
-\r
- UINTN BaseOffset; // Base offset for hexdump command\r
- \r
- UINTN Size; // Valid for all types other than l#:\r
- UINT8 *Buffer; // Information valid for A#:\r
-\r
- EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; // Information valid for Fv#: \r
- EFI_GUID FvNameGuid; \r
- EFI_SECTION_TYPE FvSectionType; \r
- EFI_FV_FILETYPE FvType; \r
- EFI_FV_FILE_ATTRIBUTES FvAttributes; \r
-\r
- EFI_PHYSICAL_ADDRESS FvStart; \r
- UINTN FvSize; \r
- UINTN FvHeaderSize;\r
-\r
- EFI_FILE *FsFileHandle; // Information valid for Fs#:\r
- EFI_FILE_SYSTEM_INFO *FsInfo;\r
- EFI_FILE_INFO *FsFileInfo;\r
- EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:\r
-\r
- UINTN DiskOffset; // Information valid for B#:\r
-\r
- EFI_LOAD_FILE_PROTOCOL *LoadFile; // Information valid for l#:\r
- \r
- EFI_IP_ADDRESS ServerIp; // Information valid for t:\r
- BOOLEAN IsDirty;\r
- BOOLEAN IsBufferValid;\r
- \r
-} EFI_OPEN_FILE;\r
+ UINTN Version; // Common information\r
+ EFI_OPEN_FILE_TYPE Type;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_STATUS LastError;\r
+ EFI_HANDLE EfiHandle;\r
+ CHAR8 *DeviceName;\r
+ CHAR8 *FileName;\r
+\r
+ UINT64 CurrentPosition; // Information for Seek\r
+ UINT64 MaxPosition;\r
+\r
+ UINTN BaseOffset; // Base offset for hexdump command\r
+\r
+ UINTN Size; // Valid for all types other than l#:\r
+ UINT8 *Buffer; // Information valid for A#:\r
\r
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv; // Information valid for Fv#:\r
+ EFI_GUID FvNameGuid;\r
+ EFI_SECTION_TYPE FvSectionType;\r
+ EFI_FV_FILETYPE FvType;\r
+ EFI_FV_FILE_ATTRIBUTES FvAttributes;\r
+\r
+ EFI_PHYSICAL_ADDRESS FvStart;\r
+ UINTN FvSize;\r
+ UINTN FvHeaderSize;\r
+\r
+ EFI_FILE *FsFileHandle; // Information valid for Fs#:\r
+ EFI_FILE_SYSTEM_INFO *FsInfo;\r
+ EFI_FILE_INFO *FsFileInfo;\r
+ EFI_BLOCK_IO_MEDIA *FsBlockIoMedia; // Information valid for Fs#: or B#:\r
+ EFI_BLOCK_IO_PROTOCOL *FsBlockIo; // Information valid for Fs#: or B#:\r
+\r
+ UINTN DiskOffset; // Information valid for B#:\r
+\r
+ EFI_LOAD_FILE_PROTOCOL *LoadFile; // Information valid for l#:\r
+\r
+ EFI_IP_ADDRESS ServerIp; // Information valid for t:\r
+ BOOLEAN IsDirty;\r
+ BOOLEAN IsBufferValid;\r
+} EFI_OPEN_FILE;\r
\r
/// Type of Seek to perform\r
typedef enum {\r
EfiSeekMax\r
} EFI_SEEK_TYPE;\r
\r
-\r
/**\r
- Open a device named by PathName. The PathName includes a device name and \r
- path seperated by a :. See file header for more details on the PathName \r
+ Open a device named by PathName. The PathName includes a device name and\r
+ path separated by a :. See file header for more details on the PathName\r
syntax. There is no checking to prevent a file from being opened more than\r
- one type. \r
+ one type.\r
\r
SectionType is only used to open an FV. Each file in an FV contains multiple\r
- secitons and only the SectionType section is opened. \r
+ sections and only the SectionType section is opened.\r
\r
For any file that is opened with EfiOpen() must be closed with EfiClose().\r
\r
- @param PathName Path to parse to open \r
+ @param PathName Path to parse to open\r
@param OpenMode Same as EFI_FILE.Open()\r
@param SectionType Section in FV to open.\r
\r
**/\r
EFI_OPEN_FILE *\r
EfiOpen (\r
- IN CHAR8 *PathName,\r
- IN CONST UINT64 OpenMode,\r
- IN CONST EFI_SECTION_TYPE SectionType\r
+ IN CHAR8 *PathName,\r
+ IN CONST UINT64 OpenMode,\r
+ IN CONST EFI_SECTION_TYPE SectionType\r
);\r
\r
EFI_STATUS\r
EfiCopyFile (\r
- IN CHAR8 *DestinationFile,\r
- IN CHAR8 *SourceFile\r
+ IN CHAR8 *DestinationFile,\r
+ IN CHAR8 *SourceFile\r
);\r
\r
/**\r
**/\r
EFI_OPEN_FILE *\r
EfiDeviceOpenByType (\r
- IN EFI_OPEN_FILE_TYPE DeviceType,\r
- IN UINTN Index\r
+ IN EFI_OPEN_FILE_TYPE DeviceType,\r
+ IN UINTN Index\r
);\r
\r
-\r
/**\r
Close a file handle opened by EfiOpen() and free all resources allocated by\r
EfiOpen().\r
**/\r
EFI_STATUS\r
EfiClose (\r
- IN EFI_OPEN_FILE *Stream\r
+ IN EFI_OPEN_FILE *Stream\r
);\r
\r
-\r
/**\r
- Return the size of the file represented by Stream. Also return the current \r
+ Return the size of the file represented by Stream. Also return the current\r
Seek position. Opening a file will enable a valid file size to be returned.\r
- LoadFile is an exception as a load file size is set to zero. \r
+ LoadFile is an exception as a load file size is set to zero.\r
\r
@param Stream Open File Handle\r
\r
**/\r
UINTN\r
EfiTell (\r
- IN EFI_OPEN_FILE *Stream,\r
- OUT UINT64 *CurrentPosition OPTIONAL\r
+ IN EFI_OPEN_FILE *Stream,\r
+ OUT UINT64 *CurrentPosition OPTIONAL\r
);\r
\r
-\r
/**\r
- Seek to the Offset locaiton in the file. LoadFile and FV device types do\r
- not support EfiSeek(). It is not possible to grow the file size using \r
+ Seek to the Offset location in the file. LoadFile and FV device types do\r
+ not support EfiSeek(). It is not possible to grow the file size using\r
EfiSeek().\r
- \r
+\r
SeekType defines how use Offset to calculate the new file position:\r
EfiSeekStart : Position = Offset\r
EfiSeekCurrent: Position is Offset bytes from the current position\r
EfiSeekEnd : Only supported if Offset is zero to seek to end of file.\r
\r
@param Stream Open File Handle\r
- @param Offset Offset to seek too. \r
+ @param Offset Offset to seek too.\r
@param SeekType Type of seek to perform\r
\r
\r
@return EFI_INVALID_PARAMETER Stream is not an Open File\r
- @return EFI_UNSUPPORTED LoadFile and FV doe not support Seek\r
+ @return EFI_UNSUPPORTED LoadFile and FV does not support Seek\r
@return EFI_NOT_FOUND Seek past the end of the file.\r
@return EFI_SUCCESS Steam closed\r
\r
**/\r
EFI_STATUS\r
EfiSeek (\r
- IN EFI_OPEN_FILE *Stream,\r
- IN EFI_LBA Offset,\r
- IN EFI_SEEK_TYPE SeekType\r
+ IN EFI_OPEN_FILE *Stream,\r
+ IN EFI_LBA Offset,\r
+ IN EFI_SEEK_TYPE SeekType\r
);\r
\r
-\r
/**\r
- Read BufferSize bytes from the current locaiton in the file. For load file\r
- and FV case you must read the entire file. \r
+ Read BufferSize bytes from the current location in the file. For load file\r
+ and FV case you must read the entire file.\r
\r
@param Stream Open File Handle\r
- @param Buffer Caller allocated buffer. \r
+ @param Buffer Caller allocated buffer.\r
@param BufferSize Size of buffer in bytes.\r
\r
\r
**/\r
EFI_STATUS\r
EfiRead (\r
- IN EFI_OPEN_FILE *Stream,\r
- OUT VOID *Buffer,\r
- OUT UINTN *BufferSize\r
+ IN EFI_OPEN_FILE *Stream,\r
+ OUT VOID *Buffer,\r
+ OUT UINTN *BufferSize\r
);\r
\r
-\r
/**\r
Read the entire file into a buffer. This routine allocates the buffer and\r
- returns it to the user full of the read data. \r
+ returns it to the user full of the read data.\r
\r
- This is very useful for load flie where it's hard to know how big the buffer\r
+ This is very useful for load file where it's hard to know how big the buffer\r
must be.\r
\r
@param Stream Open File Handle\r
- @param Buffer Pointer to buffer to return. \r
+ @param Buffer Pointer to buffer to return.\r
@param BufferSize Pointer to Size of buffer return..\r
\r
\r
**/\r
EFI_STATUS\r
EfiReadAllocatePool (\r
- IN EFI_OPEN_FILE *Stream,\r
- OUT VOID **Buffer,\r
- OUT UINTN *BufferSize\r
+ IN EFI_OPEN_FILE *Stream,\r
+ OUT VOID **Buffer,\r
+ OUT UINTN *BufferSize\r
);\r
\r
-\r
/**\r
- Write data back to the file. \r
+ Write data back to the file.\r
\r
@param Stream Open File Handle\r
- @param Buffer Pointer to buffer to return. \r
+ @param Buffer Pointer to buffer to return.\r
@param BufferSize Pointer to Size of buffer return..\r
\r
\r
**/\r
EFI_STATUS\r
EfiWrite (\r
- IN EFI_OPEN_FILE *Stream,\r
- OUT VOID *Buffer,\r
- OUT UINTN *BufferSize\r
+ IN EFI_OPEN_FILE *Stream,\r
+ OUT VOID *Buffer,\r
+ OUT UINTN *BufferSize\r
);\r
\r
-\r
/**\r
Return the number of devices of the current type active in the system\r
\r
**/\r
UINTN\r
EfiGetDeviceCounts (\r
- IN EFI_OPEN_FILE_TYPE Type\r
+ IN EFI_OPEN_FILE_TYPE Type\r
);\r
- \r
\r
/**\r
- Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and \r
+ Set the Current Working Directory (CWD). If a call is made to EfiOpen () and\r
the path does not contain a device name, The CWD is prepended to the path.\r
- \r
+\r
@param Cwd Current Working Directory to set\r
\r
\r
**/\r
EFI_STATUS\r
EfiSetCwd (\r
- IN CHAR8 *Cwd\r
- ); \r
+ IN CHAR8 *Cwd\r
+ );\r
\r
/**\r
- Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and \r
+ Set the Current Working Directory (CWD). If a call is made to EfiOpen () and\r
the path does not contain a device name, The CWD is prepended to the path.\r
- \r
- @param Cwd Current Working Directory \r
+\r
+ @param Cwd Current Working Directory\r
\r
\r
@return NULL No CWD set\r
@return 'other' malloc'ed buffer contains CWD.\r
- \r
+\r
**/\r
CHAR8 *\r
EfiGetCwd (\r
VOID\r
- ); \r
+ );\r
\r
#endif\r