-/*++\r
+/** @file\r
+ Main header file for EFI FAT file system driver.\r
\r
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available\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
\r
-\r
-Module Name:\r
-\r
- Fat.h\r
-\r
-Abstract:\r
-\r
- Main header file for EFI FAT file system driver\r
-\r
-Revision History\r
-\r
---*/\r
+**/\r
\r
#ifndef _FAT_H_\r
#define _FAT_H_\r
// The fat types we support\r
//\r
typedef enum {\r
- FAT12,\r
- FAT16,\r
- FAT32,\r
+ Fat12,\r
+ Fat16,\r
+ Fat32,\r
FatUndefined\r
} FAT_VOLUME_TYPE;\r
\r
typedef enum {\r
- CACHE_FAT,\r
- CACHE_DATA,\r
- CACHE_MAX_TYPE\r
+ CacheFat,\r
+ CacheData,\r
+ CacheMaxType\r
} CACHE_DATA_TYPE;\r
\r
//\r
// Used in FatDiskIo\r
//\r
typedef enum {\r
- READ_DISK = 0, // raw disk read\r
- WRITE_DISK = 1, // raw disk write\r
- READ_FAT = 2, // read fat cache\r
- WRITE_FAT = 3, // write fat cache\r
- READ_DATA = 6, // read data cache\r
- WRITE_DATA = 7 // write data cache\r
+ ReadDisk = 0, // raw disk read\r
+ WriteDisk = 1, // raw disk write\r
+ ReadFat = 2, // read fat cache\r
+ WriteFat = 3, // write fat cache\r
+ ReadData = 6, // read data cache\r
+ WriteData = 7 // write data cache\r
} IO_MODE;\r
\r
#define CACHE_ENABLED(a) ((a) >= 2)\r
//\r
// The directory entry for opened directory\r
//\r
-typedef struct _FAT_DIRENT {\r
+\r
+typedef struct _FAT_DIRENT FAT_DIRENT;\r
+typedef struct _FAT_ODIR FAT_ODIR;\r
+typedef struct _FAT_OFILE FAT_OFILE;\r
+typedef struct _FAT_VOLUME FAT_VOLUME;\r
+\r
+struct _FAT_DIRENT {\r
UINTN Signature;\r
UINT16 EntryPos; // The position of this directory entry in the parent directory file\r
UINT8 EntryCount; // The count of the directory entry in the parent directory file\r
BOOLEAN Invalid; // Indicate whether this directory entry is valid\r
CHAR16 *FileString; // The unicode long file name for this directory entry\r
- struct _FAT_OFILE *OFile; // The OFile of the corresponding directory entry\r
- struct _FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename\r
- struct _FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename\r
+ FAT_OFILE *OFile; // The OFile of the corresponding directory entry\r
+ FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename\r
+ FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename\r
LIST_ENTRY Link; // Connection of every directory entry\r
FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk\r
-} FAT_DIRENT;\r
+};\r
\r
-typedef struct _FAT_ODIR {\r
+struct _FAT_ODIR {\r
UINTN Signature;\r
UINT32 CurrentEndPos; // Current end position of the directory\r
UINT32 CurrentPos; // Current position of the directory\r
UINTN DirCacheTag; // The identification of the directory when in directory cache\r
FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];\r
FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];\r
-} FAT_ODIR;\r
+};\r
\r
typedef struct {\r
UINTN Signature;\r
EFI_FILE_PROTOCOL Handle;\r
UINT64 Position;\r
BOOLEAN ReadOnly;\r
- struct _FAT_OFILE *OFile;\r
+ FAT_OFILE *OFile;\r
LIST_ENTRY Tasks; // List of all FAT_TASKs\r
LIST_ENTRY Link; // Link to other IFiles\r
} FAT_IFILE;\r
//\r
// FAT_OFILE - Each opened file\r
//\r
-typedef struct _FAT_OFILE {\r
+struct _FAT_OFILE {\r
UINTN Signature;\r
- struct _FAT_VOLUME *Volume;\r
+ FAT_VOLUME *Volume;\r
//\r
// A permanant error code to return to all accesses to\r
// this opened file\r
//\r
// The opened parent, full path length and currently opened child files\r
//\r
- struct _FAT_OFILE *Parent;\r
+ FAT_OFILE *Parent;\r
UINTN FullPathLen;\r
LIST_ENTRY ChildHead;\r
LIST_ENTRY ChildLink;\r
// Link in Volume's reference list\r
//\r
LIST_ENTRY CheckLink;\r
-} FAT_OFILE;\r
+};\r
\r
-typedef struct _FAT_VOLUME {\r
+struct _FAT_VOLUME {\r
UINTN Signature;\r
\r
EFI_HANDLE Handle;\r
// File Name of root OFile, it is empty string\r
//\r
CHAR16 RootFileString[1];\r
- struct _FAT_OFILE *Root;\r
+ FAT_OFILE *Root;\r
\r
//\r
// New OFiles are added to this list so they\r
// Disk Cache for this volume\r
//\r
VOID *CacheBuffer;\r
- DISK_CACHE DiskCache[CACHE_MAX_TYPE];\r
-} FAT_VOLUME;\r
+ DISK_CACHE DiskCache[CacheMaxType];\r
+};\r
\r
//\r
// Function Prototypes\r
//\r
+\r
+/**\r
+\r
+ Implements Open() of Simple File System Protocol.\r
+\r
+ @param FHand - File handle of the file serves as a starting reference point.\r
+ @param NewHandle - Handle of the file that is newly opened.\r
+ @param FileName - File name relative to FHand.\r
+ @param OpenMode - Open mode.\r
+ @param Attributes - Attributes to set if the file is created.\r
+\r
+\r
+ @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r
+ The OpenMode is not supported.\r
+ The Attributes is not the valid attributes.\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r
+ @retval EFI_SUCCESS - Open the file successfully.\r
+ @return Others - The status of open file.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatOpen (\r
IN UINT64 OpenMode,\r
IN UINT64 Attributes\r
)\r
-/*++\r
-Routine Description:\r
-\r
- Implements Open() of Simple File System Protocol.\r
+;\r
\r
-Arguments:\r
+/**\r
\r
- FHand - File handle of the file serves as a starting reference point.\r
- NewHandle - Handle of the file that is newly opened.\r
- FileName - File name relative to FHand.\r
- OpenMode - Open mode.\r
- Attributes - Attributes to set if the file is created.\r
+ Implements OpenEx() of Simple File System Protocol.\r
\r
-Returns:\r
+ @param FHand - File handle of the file serves as a starting reference point.\r
+ @param NewHandle - Handle of the file that is newly opened.\r
+ @param FileName - File name relative to FHand.\r
+ @param OpenMode - Open mode.\r
+ @param Attributes - Attributes to set if the file is created.\r
+ @param Token - A pointer to the token associated with the transaction.\r
\r
- EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r
+ @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r
The OpenMode is not supported.\r
The Attributes is not the valid attributes.\r
- EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r
- EFI_SUCCESS - Open the file successfully.\r
- Others - The status of open file.\r
-\r
---*/\r
-;\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r
+ @retval EFI_SUCCESS - Open the file successfully.\r
+ @return Others - The status of open file.\r
\r
+**/\r
EFI_STATUS\r
+EFIAPI\r
FatOpenEx (\r
IN EFI_FILE_PROTOCOL *FHand,\r
OUT EFI_FILE_PROTOCOL **NewHandle,\r
IN UINT64 Attributes,\r
IN OUT EFI_FILE_IO_TOKEN *Token\r
)\r
-/*++\r
-Routine Description:\r
-\r
- Implements OpenEx() of Simple File System Protocol.\r
-\r
-Arguments:\r
+;\r
\r
- FHand - File handle of the file serves as a starting reference point.\r
- NewHandle - Handle of the file that is newly opened.\r
- FileName - File name relative to FHand.\r
- OpenMode - Open mode.\r
- Attributes - Attributes to set if the file is created.\r
- Token - A pointer to the token associated with the transaction.\r
+/**\r
\r
-Returns:\r
+ Get the file's position of the file\r
\r
- EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r
- The OpenMode is not supported.\r
- The Attributes is not the valid attributes.\r
- EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r
- EFI_SUCCESS - Open the file successfully.\r
- Others - The status of open file.\r
+ @param FHand - The handle of file.\r
+ @param Position - The file's position of the file.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Get the info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
+ @retval EFI_UNSUPPORTED - The open file is not a file.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatGetPosition (\r
IN EFI_FILE_PROTOCOL *FHand,\r
OUT UINT64 *Position\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the file's position of the file\r
-\r
-Arguments:\r
+;\r
\r
- FHand - The handle of file.\r
- Position - The file's position of the file.\r
+/**\r
\r
-Returns:\r
+ Get the some types info of the file into Buffer\r
\r
- EFI_SUCCESS - Get the info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
- EFI_UNSUPPORTED - The open file is not a file.\r
+ @param FHand - The handle of file.\r
+ @param Type - The type of the info.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing volume info.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Get the info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatGetInfo (\r
IN OUT UINTN *BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the some types info of the file into Buffer\r
+;\r
\r
-Arguments:\r
+/**\r
\r
- FHand - The handle of file.\r
- Type - The type of the info.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing volume info.\r
+ Set the some types info of the file into Buffer.\r
\r
-Returns:\r
+ @param FHand - The handle of file.\r
+ @param Type - The type of the info.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing volume info.\r
\r
- EFI_SUCCESS - Get the info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
-\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Set the info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatSetInfo (\r
IN UINTN BufferSize,\r
IN VOID *Buffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Set the some types info of the file into Buffer\r
-\r
-Arguments:\r
+;\r
\r
- FHand - The handle of file.\r
- Type - The type of the info.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing volume info.\r
+/**\r
\r
-Returns:\r
+ Flushes all data associated with the file handle.\r
\r
- EFI_SUCCESS - Set the info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
+ @param FHand - Handle to file to flush\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Flushed the file successfully\r
+ @retval EFI_WRITE_PROTECTED - The volume is read only\r
+ @retval EFI_ACCESS_DENIED - The volume is not read only\r
+ but the file is read only\r
+ @return Others - Flushing of the file is failed\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatFlush (\r
IN EFI_FILE_PROTOCOL *FHand\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Flushes all data associated with the file handle\r
+;\r
\r
-Arguments:\r
+/**\r
\r
- FHand - Handle to file to flush\r
+ Flushes all data associated with the file handle.\r
\r
-Returns:\r
+ @param FHand - Handle to file to flush.\r
+ @param Token - A pointer to the token associated with the transaction.\r
\r
- EFI_SUCCESS - Flushed the file successfully\r
- EFI_WRITE_PROTECTED - The volume is read only\r
- EFI_ACCESS_DENIED - The volume is not read only\r
- but the file is read only\r
- Others - Flushing of the file is failed\r
-\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Flushed the file successfully.\r
+ @retval EFI_WRITE_PROTECTED - The volume is read only.\r
+ @retval EFI_ACCESS_DENIED - The file is read only.\r
+ @return Others - Flushing of the file failed.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatFlushEx (\r
IN EFI_FILE_PROTOCOL *FHand,\r
IN EFI_FILE_IO_TOKEN *Token\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Flushes all data associated with the file handle.\r
-\r
-Arguments:\r
+;\r
\r
- FHand - Handle to file to flush.\r
- Token - A pointer to the token associated with the transaction.\r
+/**\r
\r
-Returns:\r
+ Flushes & Closes the file handle.\r
\r
- EFI_SUCCESS - Flushed the file successfully.\r
- EFI_WRITE_PROTECTED - The volume is read only.\r
- EFI_ACCESS_DENIED - The file is read only.\r
- Others - Flushing of the file failed.\r
+ @param FHand - Handle to the file to delete.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Closed the file successfully.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatClose (\r
IN EFI_FILE_PROTOCOL *FHand\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Flushes & Closes the file handle.\r
-\r
-Arguments:\r
+;\r
\r
- FHand - Handle to the file to delete.\r
+/**\r
\r
-Returns:\r
+ Deletes the file & Closes the file handle.\r
\r
- EFI_SUCCESS - Closed the file successfully.\r
+ @param FHand - Handle to the file to delete.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Delete the file successfully.\r
+ @retval EFI_WARN_DELETE_FAILURE - Fail to delete the file.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatDelete (\r
IN EFI_FILE_PROTOCOL *FHand\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Deletes the file & Closes the file handle.\r
-\r
-Arguments:\r
+;\r
\r
- FHand - Handle to the file to delete.\r
+/**\r
\r
-Returns:\r
+ Set the file's position of the file.\r
\r
- EFI_SUCCESS - Delete the file successfully.\r
- EFI_WARN_DELETE_FAILURE - Fail to delete the file.\r
+ @param FHand - The handle of file\r
+ @param Position - The file's position of the file\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Set the info successfully\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file\r
+ @retval EFI_UNSUPPORTED - Set a directory with a not-zero position\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatSetPosition (\r
IN EFI_FILE_PROTOCOL *FHand,\r
IN UINT64 Position\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Set the file's position of the file\r
+;\r
\r
-Arguments:\r
+/**\r
\r
- FHand - The handle of file\r
- Position - The file's position of the file\r
+ Get the file info.\r
\r
-Returns:\r
+ @param FHand - The handle of the file.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing read data.\r
\r
- EFI_SUCCESS - Set the info successfully\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file\r
- EFI_UNSUPPORTED - Set a directory with a not-zero position\r
-\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Get the file info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
+ @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
+ @return other - An error occurred when operation the disk.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatRead (\r
IN OUT UINTN *BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
+;\r
\r
-Routine Description:\r
+/**\r
\r
Get the file info.\r
\r
-Arguments:\r
-\r
- FHand - The handle of the file.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing read data.\r
+ @param FHand - The handle of the file.\r
+ @param Token - A pointer to the token associated with the transaction.\r
\r
-Returns:\r
-\r
- EFI_SUCCESS - Get the file info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
- EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
- other - An error occurred when operation the disk.\r
-\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Get the file info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
+ @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
+ @return other - An error occurred when operation the disk.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatReadEx (\r
IN EFI_FILE_PROTOCOL *FHand,\r
IN OUT EFI_FILE_IO_TOKEN *Token\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the file info.\r
-\r
-Arguments:\r
+;\r
\r
- FHand - The handle of the file.\r
- Token - A pointer to the token associated with the transaction.\r
+/**\r
\r
-Returns:\r
+ Set the file info.\r
\r
- EFI_SUCCESS - Get the file info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
- EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
- other - An error occurred when operation the disk.\r
+ @param FHand - The handle of the file.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing write data.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Set the file info successfully.\r
+ @retval EFI_WRITE_PROTECTED - The disk is write protected.\r
+ @retval EFI_ACCESS_DENIED - The file is read-only.\r
+ @retval EFI_DEVICE_ERROR - The OFile is not valid.\r
+ @retval EFI_UNSUPPORTED - The open file is not a file.\r
+ - The writing file size is larger than 4GB.\r
+ @return other - An error occurred when operation the disk.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatWrite (\r
IN OUT UINTN *BufferSize,\r
IN VOID *Buffer\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Set the file info.\r
+;\r
\r
-Arguments:\r
+/**\r
\r
- FHand - The handle of the file.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing write data.\r
+ Get the file info.\r
\r
-Returns:\r
+ @param FHand - The handle of the file.\r
+ @param Token - A pointer to the token associated with the transaction.\r
\r
- EFI_SUCCESS - Set the file info successfully.\r
- EFI_WRITE_PROTECTED - The disk is write protected.\r
- EFI_ACCESS_DENIED - The file is read-only.\r
- EFI_DEVICE_ERROR - The OFile is not valid.\r
- EFI_UNSUPPORTED - The open file is not a file.\r
- - The writing file size is larger than 4GB.\r
- other - An error occurred when operation the disk.\r
-\r
---*/\r
-;\r
+ @retval EFI_SUCCESS - Get the file info successfully.\r
+ @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
+ @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
+ @return other - An error occurred when operation the disk.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatWriteEx (\r
IN EFI_FILE_PROTOCOL *FHand,\r
IN OUT EFI_FILE_IO_TOKEN *Token\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the file info.\r
-\r
-Arguments:\r
-\r
- FHand - The handle of the file.\r
- Token - A pointer to the token associated with the transaction.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Get the file info successfully.\r
- EFI_DEVICE_ERROR - Can not find the OFile for the file.\r
- EFI_VOLUME_CORRUPTED - The file type of open file is error.\r
- other - An error occurred when operation the disk.\r
-\r
---*/\r
;\r
\r
//\r
\r
EFI_STATUS\r
FatGetNextDirEnt (\r
- IN FAT_OFILE *OFILE,\r
+ IN FAT_OFILE *OFile,\r
OUT FAT_DIRENT **PtrDirEnt\r
);\r
\r
\r
VOID\r
FatGetFileNameViaCaseFlag (\r
- IN FAT_DIRENT *DirEnt,\r
- OUT CHAR16 *FileString\r
+ IN FAT_DIRENT *DirEnt,\r
+ IN OUT CHAR16 *FileString,\r
+ IN UINTN FileStringMax\r
);\r
\r
UINT8\r