]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Fat.h
MdeModulePkg/PciSioSerial: Fix bad EOL
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Fat.h
index 56822f723a56b023183458f7a6122cd1a7e9e913..b73135cdbc26354886fa233d9318698e797be94c 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2005 - 2009, 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
@@ -32,6 +32,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 +56,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
@@ -213,9 +216,29 @@ typedef struct {
   UINT64              Position;\r
   BOOLEAN             ReadOnly;\r
   struct _FAT_OFILE   *OFile;\r
-  LIST_ENTRY          Link;\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
@@ -296,6 +319,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
@@ -400,6 +424,42 @@ Returns:
 --*/\r
 ;\r
 \r
+EFI_STATUS\r
+EFIAPI\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
+Routine Description:\r
+\r
+  Implements OpenEx() of Simple File System Protocol.\r
+\r
+Arguments:\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
+Returns:\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
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 FatGetPosition (\r
@@ -510,6 +570,33 @@ Returns:
 --*/\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
+  FHand                 - Handle to file to flush.\r
+  Token                 - A pointer to the token associated with the transaction.\r
+\r
+Returns:\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
+\r
+--*/\r
+;\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 FatClose (\r
@@ -610,6 +697,33 @@ Returns:
 --*/\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
+  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
 EFI_STATUS\r
 EFIAPI\r
 FatWrite (\r
@@ -642,6 +756,33 @@ Returns:
 --*/\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
 // DiskCache.c\r
 //\r
@@ -657,12 +798,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 +836,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 +885,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 +902,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 +942,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 +956,8 @@ FatReleaseLock (
   VOID\r
   );\r
 \r
-BOOLEAN\r
-FatIsLocked (\r
+EFI_STATUS\r
+FatAcquireLockOrFail (\r
   VOID\r
   );\r
 \r
@@ -895,7 +1068,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
@@ -1067,8 +1241,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 +1288,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_LOCK                        FatTaskLock;\r
 extern EFI_FILE_PROTOCOL               FatFileInterface;\r
 \r
 #endif\r