]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Fat.h
FatPkg/EnhancedFatDxe: Make the comments align with EDKIIcoding style
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Fat.h
index 3a782cb0266993e68638effd25257724e98e2536..9490868ea756a8e8c9a549d561b8d48e345a438f 100644 (file)
@@ -1,7 +1,8 @@
-/*++\r
+/** @file\r
+  Main header file for EFI FAT file system driver.\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\r
+Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available\r
 under the terms and conditions of the BSD License which accompanies this\r
 distribution. The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -9,18 +10,7 @@ http://opensource.org/licenses/bsd-license.php
 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
@@ -32,6 +22,7 @@ Revision History
 #include <Guid/FileSystemVolumeLabelInfo.h>\r
 #include <Protocol/BlockIo.h>\r
 #include <Protocol/DiskIo.h>\r
+#include <Protocol/DiskIo2.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
 #include <Protocol/UnicodeCollation.h>\r
 \r
@@ -55,6 +46,8 @@ Revision History
 #define FAT_ODIR_SIGNATURE           SIGNATURE_32 ('f', 'a', 't', 'd')\r
 #define FAT_DIRENT_SIGNATURE         SIGNATURE_32 ('f', 'a', 't', 'e')\r
 #define FAT_OFILE_SIGNATURE          SIGNATURE_32 ('f', 'a', 't', 'o')\r
+#define FAT_TASK_SIGNATURE           SIGNATURE_32 ('f', 'a', 't', 'T')\r
+#define FAT_SUBTASK_SIGNATURE        SIGNATURE_32 ('f', 'a', 't', 'S')\r
 \r
 #define ASSERT_VOLUME_LOCKED(a)      ASSERT_LOCKED (&FatFsLock)\r
 \r
@@ -125,28 +118,28 @@ typedef CHAR8                   LC_ISO_639_2;
 // 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
@@ -181,20 +174,26 @@ typedef struct {
 //\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
@@ -205,23 +204,43 @@ typedef struct _FAT_ODIR {
   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            Handle;\r
+  EFI_FILE_PROTOCOL   Handle;\r
   UINT64              Position;\r
   BOOLEAN             ReadOnly;\r
-  struct _FAT_OFILE   *OFile;\r
-  LIST_ENTRY          Link;\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
+typedef struct {\r
+  UINTN               Signature;\r
+  EFI_FILE_IO_TOKEN   *FileIoToken;\r
+  FAT_IFILE           *IFile;\r
+  LIST_ENTRY          Subtasks;               // List of all FAT_SUBTASKs\r
+  LIST_ENTRY          Link;                   // Link to other FAT_TASKs\r
+} FAT_TASK;\r
+\r
+typedef struct {\r
+  UINTN               Signature;\r
+  EFI_DISK_IO2_TOKEN  DiskIo2Token;\r
+  FAT_TASK            *Task;\r
+  BOOLEAN             Write;\r
+  UINT64              Offset;\r
+  VOID                *Buffer;\r
+  UINTN               BufferSize;\r
+  LIST_ENTRY          Link;\r
+} FAT_SUBTASK;\r
+\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
@@ -261,7 +280,7 @@ typedef struct _FAT_OFILE {
   //\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
@@ -280,9 +299,9 @@ typedef struct _FAT_OFILE {
   // 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
@@ -296,6 +315,7 @@ typedef struct _FAT_VOLUME {
   //\r
   EFI_BLOCK_IO_PROTOCOL           *BlockIo;\r
   EFI_DISK_IO_PROTOCOL            *DiskIo;\r
+  EFI_DISK_IO2_PROTOCOL           *DiskIo2;\r
   UINT32                          MediaId;\r
   BOOLEAN                         ReadOnly;\r
 \r
@@ -342,7 +362,7 @@ typedef struct _FAT_VOLUME {
   // 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
@@ -360,286 +380,323 @@ typedef struct _FAT_VOLUME {
   // 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  EFI_FILE          *FHand,\r
-  OUT EFI_FILE          **NewHandle,\r
+  IN  EFI_FILE_PROTOCOL *FHand,\r
+  OUT EFI_FILE_PROTOCOL **NewHandle,\r
   IN  CHAR16            *FileName,\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
-FatGetPosition (\r
-  IN  EFI_FILE          *FHand,\r
-  OUT UINT64            *Position\r
+FatOpenEx (\r
+  IN  EFI_FILE_PROTOCOL       *FHand,\r
+  OUT EFI_FILE_PROTOCOL       **NewHandle,\r
+  IN  CHAR16                  *FileName,\r
+  IN  UINT64                  OpenMode,\r
+  IN  UINT64                  Attributes,\r
+  IN OUT EFI_FILE_IO_TOKEN    *Token\r
   )\r
-/*++\r
+;\r
 \r
-Routine Description:\r
+/**\r
 \r
   Get the file's position of the file\r
 \r
-Arguments:\r
-\r
-  FHand                 - The handle of file.\r
-  Position              - The file's position of the file.\r
+  @param  FHand                 - The handle of file.\r
+  @param  Position              - The file's position of the file.\r
 \r
-Returns:\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
-\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
-FatGetInfo (\r
-  IN     EFI_FILE      *FHand,\r
-  IN     EFI_GUID      *Type,\r
-  IN OUT UINTN         *BufferSize,\r
-     OUT VOID          *Buffer\r
+FatGetPosition (\r
+  IN  EFI_FILE_PROTOCOL *FHand,\r
+  OUT UINT64            *Position\r
   )\r
-/*++\r
+;\r
 \r
-Routine Description:\r
+/**\r
 \r
   Get the some types info of the file into Buffer\r
 \r
-Arguments:\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
+  @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     EFI_FILE_PROTOCOL      *FHand,\r
+  IN     EFI_GUID               *Type,\r
+  IN OUT UINTN                  *BufferSize,\r
+     OUT VOID                   *Buffer\r
+  )\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
+  Set 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
+  @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           - 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 EFI_FILE           *FHand,\r
+  IN EFI_FILE_PROTOCOL  *FHand,\r
   IN EFI_GUID           *Type,\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           *FHand\r
+  IN EFI_FILE_PROTOCOL  *FHand\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
+/**\r
 \r
-Returns:\r
+  Flushes all data associated with 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 volume is not read only\r
-                          but the file is read only\r
-  Others                - Flushing of the file is failed\r
+  @param  FHand                 - Handle to file to flush.\r
+  @param  Token                 - A pointer to the token associated with the transaction.\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
-FatClose (\r
-  IN EFI_FILE  *FHand\r
+FatFlushEx (\r
+  IN EFI_FILE_PROTOCOL  *FHand,\r
+  IN EFI_FILE_IO_TOKEN  *Token\r
   )\r
-/*++\r
+;\r
 \r
-Routine Description:\r
+/**\r
 \r
   Flushes & Closes the file handle.\r
 \r
-Arguments:\r
-\r
-  FHand                 - Handle to the file to delete.\r
+  @param  FHand                 - Handle to the file to delete.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS           - Closed the file successfully.\r
-\r
---*/\r
-;\r
+  @retval EFI_SUCCESS           - Closed the file successfully.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
-FatDelete (\r
-  IN EFI_FILE           *FHand\r
+FatClose (\r
+  IN EFI_FILE_PROTOCOL  *FHand\r
   )\r
-/*++\r
+;\r
 \r
-Routine Description:\r
+/**\r
 \r
   Deletes the file & Closes the file handle.\r
 \r
-Arguments:\r
+  @param  FHand                    - Handle to the file to delete.\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
-  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           *FHand,\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     EFI_FILE   *FHand,\r
-  IN OUT UINTN      *BufferSize,\r
-     OUT VOID       *Buffer\r
+  IN     EFI_FILE_PROTOCOL    *FHand,\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
+  @param FHand                 - The handle of the file.\r
+  @param Token                 - A pointer to the token associated with the transaction.\r
 \r
-  FHand                 - The handle of the file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing read data.\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
-Returns:\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
-  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
+  Set the file info.\r
+\r
+  @param  FHand                 - The handle of the file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param Buffer                - Buffer containing write data.\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     EFI_FILE      *FHand,\r
-  IN OUT UINTN         *BufferSize,\r
-  IN     VOID          *Buffer\r
+  IN     EFI_FILE_PROTOCOL      *FHand,\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
+  @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
+**/\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
 //\r
@@ -657,12 +714,14 @@ FatAccessCache (
   IN     IO_MODE             IoMode,\r
   IN     UINT64              Offset,\r
   IN     UINTN               BufferSize,\r
-  IN OUT UINT8               *Buffer\r
+  IN OUT UINT8               *Buffer,\r
+  IN     FAT_TASK            *Task\r
   );\r
 \r
 EFI_STATUS\r
 FatVolumeFlushCache (\r
-  IN FAT_VOLUME              *Volume\r
+  IN FAT_VOLUME              *Volume,\r
+  IN FAT_TASK                *Task\r
   );\r
 \r
 //\r
@@ -693,7 +752,8 @@ EFI_STATUS
 FatCleanupVolume (\r
   IN FAT_VOLUME         *Volume,\r
   IN FAT_OFILE          *OFile,\r
-  IN EFI_STATUS         EfiStatus\r
+  IN EFI_STATUS         EfiStatus,\r
+  IN FAT_TASK           *Task\r
   );\r
 \r
 //\r
@@ -741,6 +801,7 @@ EFI_STATUS
 FatAllocateVolume (\r
   IN  EFI_HANDLE                     Handle,\r
   IN  EFI_DISK_IO_PROTOCOL           *DiskIo,\r
+  IN  EFI_DISK_IO2_PROTOCOL          *DiskIo2,\r
   IN  EFI_BLOCK_IO_PROTOCOL          *BlockIo\r
   );\r
 \r
@@ -757,6 +818,33 @@ FatAbandonVolume (
 //\r
 // Misc.c\r
 //\r
+FAT_TASK *\r
+FatCreateTask (\r
+  FAT_IFILE           *IFile,\r
+  EFI_FILE_IO_TOKEN   *Token\r
+  );\r
+\r
+VOID\r
+FatDestroyTask (\r
+  FAT_TASK            *Task\r
+  );\r
+\r
+VOID\r
+FatWaitNonblockingTask (\r
+  FAT_IFILE           *IFile\r
+  );\r
+\r
+LIST_ENTRY *\r
+FatDestroySubtask (\r
+  FAT_SUBTASK         *Subtask\r
+  );\r
+\r
+EFI_STATUS\r
+FatQueueTask (\r
+  IN FAT_IFILE        *IFile,\r
+  IN FAT_TASK         *Task\r
+  );\r
+\r
 EFI_STATUS\r
 FatAccessVolumeDirty (\r
   IN FAT_VOLUME         *Volume,\r
@@ -770,7 +858,8 @@ FatDiskIo (
   IN IO_MODE            IoMode,\r
   IN UINT64             Offset,\r
   IN UINTN              BufferSize,\r
-  IN OUT VOID           *Buffer\r
+  IN OUT VOID           *Buffer,\r
+  IN FAT_TASK           *Task\r
   );\r
 \r
 VOID\r
@@ -783,8 +872,8 @@ FatReleaseLock (
   VOID\r
   );\r
 \r
-BOOLEAN\r
-FatIsLocked (\r
+EFI_STATUS\r
+FatAcquireLockOrFail (\r
   VOID\r
   );\r
 \r
@@ -883,7 +972,7 @@ EFI_STATUS
 EFIAPI\r
 FatOpenVolume (\r
   IN  EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r
-  OUT EFI_FILE                        **File\r
+  OUT EFI_FILE_PROTOCOL               **File\r
   );\r
 \r
 //\r
@@ -895,7 +984,8 @@ FatAccessOFile (
   IN IO_MODE            IoMode,\r
   IN UINTN              Position,\r
   IN UINTN              *DataBufferSize,\r
-  IN UINT8              *UserBuffer\r
+  IN UINT8              *UserBuffer,\r
+  IN FAT_TASK           *Task\r
   );\r
 \r
 EFI_STATUS\r
@@ -926,7 +1016,7 @@ FatResetODirCursor (
 \r
 EFI_STATUS\r
 FatGetNextDirEnt (\r
-  IN  FAT_OFILE         *OFILE,\r
+  IN  FAT_OFILE         *OFile,\r
   OUT FAT_DIRENT        **PtrDirEnt\r
   );\r
 \r
@@ -1067,8 +1157,9 @@ FatSetCaseFlag (
 \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
@@ -1113,6 +1204,7 @@ extern EFI_DRIVER_BINDING_PROTOCOL     gFatDriverBinding;
 extern EFI_COMPONENT_NAME_PROTOCOL     gFatComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL    gFatComponentName2;\r
 extern EFI_LOCK                        FatFsLock;\r
-extern EFI_FILE                        FatFileInterface;\r
+extern EFI_LOCK                        FatTaskLock;\r
+extern EFI_FILE_PROTOCOL               FatFileInterface;\r
 \r
 #endif\r