/*++\r
\r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\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
\r
EFI_STATUS\r
EFIAPI\r
-FatFlush (\r
- IN EFI_FILE_PROTOCOL *FHand\r
+FatFlushEx (\r
+ IN EFI_FILE_PROTOCOL *FHand,\r
+ IN EFI_FILE_IO_TOKEN *Token\r
)\r
/*++\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
FAT_OFILE *OFile;\r
FAT_VOLUME *Volume;\r
EFI_STATUS Status;\r
+ FAT_TASK *Task;\r
\r
IFile = IFILE_FROM_FHAND (FHand);\r
OFile = IFile->OFile;\r
Volume = OFile->Volume;\r
+ Task = NULL;\r
\r
//\r
// If the file has a permanent error, return it\r
if (IFile->ReadOnly) {\r
return EFI_ACCESS_DENIED;\r
}\r
+\r
+ if (Token == NULL) {\r
+ FatWaitNonblockingTask (IFile);\r
+ } else {\r
+ //\r
+ // Caller shouldn't call the non-blocking interfaces if the low layer doesn't support DiskIo2.\r
+ // But if it calls, the below check can avoid crash.\r
+ //\r
+ if (FHand->Revision < EFI_FILE_PROTOCOL_REVISION2) {\r
+ return EFI_UNSUPPORTED;\r
+ }\r
+ Task = FatCreateTask (IFile, Token);\r
+ if (Task == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ }\r
+\r
//\r
// Flush the OFile\r
//\r
FatAcquireLock ();\r
Status = FatOFileFlush (OFile);\r
- Status = FatCleanupVolume (OFile->Volume, OFile, Status);\r
+ Status = FatCleanupVolume (OFile->Volume, OFile, Status, Task);\r
FatReleaseLock ();\r
+\r
+ if (Token != NULL) {\r
+ if (!EFI_ERROR (Status)) {\r
+ Status = FatQueueTask (IFile, Task);\r
+ } else {\r
+ FatDestroyTask (Task);\r
+ }\r
+ }\r
+\r
return Status;\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
+Arguments:\r
+\r
+ FHand - Handle to file to flush.\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
+ return FatFlushEx (FHand, NULL);\r
+}\r
+\r
EFI_STATUS\r
EFIAPI\r
FatClose (\r
//\r
// Done. Unlock the volume\r
//\r
- FatCleanupVolume (Volume, OFile, EFI_SUCCESS);\r
+ FatCleanupVolume (Volume, OFile, EFI_SUCCESS, NULL);\r
FatReleaseLock ();\r
\r
//\r
\r
ASSERT_VOLUME_LOCKED (Volume);\r
\r
+ FatWaitNonblockingTask (IFile);\r
+\r
//\r
// Remove the IFile struct\r
//\r
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
// indicates this a FAT32 volume\r
//\r
if (Volume->FreeInfoValid && Volume->FatDirty && Volume->FreeInfoPos) {\r
- Status = FatDiskIo (Volume, WRITE_DISK, Volume->FreeInfoPos, sizeof (FAT_INFO_SECTOR), &Volume->FatInfoSector);\r
+ Status = FatDiskIo (Volume, WRITE_DISK, Volume->FreeInfoPos, sizeof (FAT_INFO_SECTOR), &Volume->FatInfoSector, Task);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
//\r
// Flush all dirty cache entries to disk\r
//\r
- Status = FatVolumeFlushCache (Volume);\r
+ Status = FatVolumeFlushCache (Volume, Task);\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r