Cc: Ruiyu Ni <ruiyu...@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan...@intel.com>
---
 FatPkg/EnhancedFatDxe/DirectoryManage.c | 16 ++++-----
 FatPkg/EnhancedFatDxe/DiskCache.c       | 50 +++++++++++++--------------
 FatPkg/EnhancedFatDxe/Fat.h             | 28 +++++++--------
 FatPkg/EnhancedFatDxe/FileSpace.c       | 60 ++++++++++++++++-----------------
 FatPkg/EnhancedFatDxe/Flush.c           |  6 ++--
 FatPkg/EnhancedFatDxe/Init.c            | 16 ++++-----
 FatPkg/EnhancedFatDxe/Misc.c            |  4 +--
 FatPkg/EnhancedFatDxe/ReadWrite.c       | 20 +++++------
 8 files changed, 100 insertions(+), 100 deletions(-)

diff --git a/FatPkg/EnhancedFatDxe/DirectoryManage.c 
b/FatPkg/EnhancedFatDxe/DirectoryManage.c
index 3328ae3..149119d 100644
--- a/FatPkg/EnhancedFatDxe/DirectoryManage.c
+++ b/FatPkg/EnhancedFatDxe/DirectoryManage.c
@@ -58,11 +58,11 @@ Returns:
   Position = EntryPos * sizeof (FAT_DIRECTORY_ENTRY);
   if (Position >= Parent->FileSize) {
     //
     // End of directory
     //
-    ASSERT (IoMode == READ_DATA);
+    ASSERT (IoMode == ReadData);
     ((FAT_DIRECTORY_ENTRY *) Entry)->FileName[0] = EMPTY_ENTRY_MARK;
     ((FAT_DIRECTORY_ENTRY *) Entry)->Attributes  = 0;
     return EFI_SUCCESS;
   }
 
@@ -104,11 +104,11 @@ Returns:
   EntryPos   = DirEnt->EntryPos;
   EntryCount = DirEnt->EntryCount;
   //
   // Write directory entry
   //
-  Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &DirEnt->Entry);
+  Status = FatAccessEntry (OFile, WriteData, EntryPos, &DirEnt->Entry);
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
   if (--EntryCount > 0) {
@@ -145,11 +145,11 @@ Returns:
       EntryPos--;
       if (DirEnt->Invalid) {
         LfnEntry.Ordinal = DELETE_ENTRY_MARK;
       }
 
-      Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &LfnEntry);
+      Status = FatAccessEntry (OFile, WriteData, EntryPos, &LfnEntry);
       if (EFI_ERROR (Status)) {
         return Status;
       }
     }
   }
@@ -320,11 +320,11 @@ Returns:
       LfnBufferPointer = LfnBuffer;
       break;
     }
 
     EntryPos--;
-    Status = FatAccessEntry (Parent, READ_DATA, EntryPos, &LfnEntry);
+    Status = FatAccessEntry (Parent, ReadData, EntryPos, &LfnEntry);
     if (EFI_ERROR (Status) ||
         LfnEntry.Attributes != FAT_ATTRIBUTE_LFN ||
         LfnEntry.MustBeZero != 0 ||
         LfnEntry.Checksum != LfnChecksum ||
         (LfnEntry.Ordinal & (~FAT_LFN_LAST)) != LfnOrdinal ||
@@ -440,11 +440,11 @@ Returns:
 
   for (;;) {
     //
     // Read the next directory entry until we find a valid directory entry 
(excluding lfn entry)
     //
-    Status = FatAccessEntry (OFile, READ_DATA, ODir->CurrentEndPos, &Entry);
+    Status = FatAccessEntry (OFile, ReadData, ODir->CurrentEndPos, &Entry);
     if (EFI_ERROR (Status)) {
       return Status;
     }
 
     if (((UINT8) Entry.FileName[0] != DELETE_ENTRY_MARK) && (Entry.Attributes 
& FAT_ATTRIBUTE_VOLUME_ID) == 0) {
@@ -460,11 +460,11 @@ Returns:
   if (Entry.FileName[0] != EMPTY_ENTRY_MARK) {
     //
     // Although FAT spec states this field is always 0 for FAT12 & FAT16, some 
applications
     // might use it for some special usage, it is safer to zero it in memory 
for FAT12 & FAT16.
     //
-    if (OFile->Volume->FatType != FAT32) {
+    if (OFile->Volume->FatType != Fat32) {
       Entry.FileClusterHigh = 0;
     }
 
     //
     // This is a valid directory entry
@@ -855,11 +855,11 @@ Returns:
 
   EntryPos        = 0;
   Entry           = &DirEnt->Entry;
   DirEnt->Invalid = TRUE;
   do {
-    Status = FatAccessEntry (Root, READ_DATA, EntryPos, Entry);
+    Status = FatAccessEntry (Root, ReadData, EntryPos, Entry);
     if (EFI_ERROR (Status)) {
       return Status;
     }
 
     if (((UINT8) Entry->FileName[0] != DELETE_ENTRY_MARK) && 
(((Entry->Attributes) & (~FAT_ATTRIBUTE_ARCHIVE)) == FAT_ATTRIBUTE_VOLUME_ID)) {
@@ -1333,11 +1333,11 @@ Returns:
       // The newly created OFile is root
       //
       Volume                = VOLUME_FROM_ROOT_DIRENT (DirEnt);
       Volume->Root          = OFile;
       OFile->FileCluster    = Volume->RootCluster;
-      if (Volume->FatType  != FAT32) {
+      if (Volume->FatType  != Fat32) {
         OFile->IsFixedRootDir  = TRUE;
       }
     }
 
     OFile->FileCurrentCluster  = OFile->FileCluster;
diff --git a/FatPkg/EnhancedFatDxe/DiskCache.c 
b/FatPkg/EnhancedFatDxe/DiskCache.c
index ddf99ed..7f1fcf4 100644
--- a/FatPkg/EnhancedFatDxe/DiskCache.c
+++ b/FatPkg/EnhancedFatDxe/DiskCache.c
@@ -68,11 +68,11 @@ Returns:
   UINT8       PageAlignment;
   DISK_CACHE  *DiskCache;
   CACHE_TAG   *CacheTag;
   UINT8       *BaseAddress;
 
-  DiskCache     = &Volume->DiskCache[CACHE_DATA];
+  DiskCache     = &Volume->DiskCache[CacheData];
   BaseAddress   = DiskCache->CacheBase;
   GroupMask     = DiskCache->GroupMask;
   PageAlignment = DiskCache->PageAlignment;
   PageSize      = (UINTN)1 << PageAlignment;
 
@@ -83,11 +83,11 @@ Returns:
       //
       // When reading data form disk directly, if some dirty data
       // in cache is in this rang, this data in the Buffer need to
       // be updated with the cache's dirty data.
       //
-      if (IoMode == READ_DISK) {
+      if (IoMode == ReadDisk) {
         if (CacheTag->Dirty) {
           CopyMem (
             Buffer + ((PageNo - StartPageNo) << PageAlignment),
             BaseAddress + (GroupNo << PageAlignment),
             PageSize
@@ -148,21 +148,21 @@ Returns:
   GroupNo       = PageNo & DiskCache->GroupMask;
   PageAlignment = DiskCache->PageAlignment;
   PageAddress   = DiskCache->CacheBase + (GroupNo << PageAlignment);
   EntryPos      = DiskCache->BaseAddress + LShiftU64 (PageNo, PageAlignment);
   RealSize      = CacheTag->RealSize;
-  if (IoMode == READ_DISK) {
+  if (IoMode == ReadDisk) {
     RealSize  = (UINTN)1 << PageAlignment;
     MaxSize   = DiskCache->LimitAddress - EntryPos;
     if (MaxSize < RealSize) {
       DEBUG ((EFI_D_INFO, "FatDiskIo: Cache Page OutBound occurred! \n"));
       RealSize = (UINTN) MaxSize;
     }
   }
 
   WriteCount = 1;
-  if (DataType == CACHE_FAT && IoMode == WRITE_DISK) {
+  if (DataType == CacheFat && IoMode == WriteDisk) {
     WriteCount = Volume->NumFats;
   }
 
   do {
     //
@@ -222,20 +222,20 @@ Returns:
 
   //
   // Write dirty cache page back to disk
   //
   if (CacheTag->RealSize > 0 && CacheTag->Dirty) {
-    Status = FatExchangeCachePage (Volume, CacheDataType, WRITE_DISK, 
CacheTag, NULL);
+    Status = FatExchangeCachePage (Volume, CacheDataType, WriteDisk, CacheTag, 
NULL);
     if (EFI_ERROR (Status)) {
       return Status;
     }
   }
   //
   // Load new data from disk;
   //
   CacheTag->PageNo  = PageNo;
-  Status            = FatExchangeCachePage (Volume, CacheDataType, READ_DISK, 
CacheTag, NULL);
+  Status            = FatExchangeCachePage (Volume, CacheDataType, ReadDisk, 
CacheTag, NULL);
 
   return Status;
 }
 
 STATIC
@@ -284,11 +284,11 @@ Returns:
   CacheTag  = &DiskCache->CacheTag[GroupNo];
   Status    = FatGetCachePage (Volume, CacheDataType, PageNo, CacheTag);
   if (!EFI_ERROR (Status)) {
     Source      = DiskCache->CacheBase + (GroupNo << DiskCache->PageAlignment) 
+ Offset;
     Destination = Buffer;
-    if (IoMode != READ_DISK) {
+    if (IoMode != ReadDisk) {
       CacheTag->Dirty   = TRUE;
       DiskCache->Dirty  = TRUE;
       Destination       = Source;
       Source            = Buffer;
     }
@@ -389,11 +389,11 @@ Returns:
   //
   if (AlignedPageCount > 0) {
     //
     // Accessing fat table cannot have alignment data
     //
-    ASSERT (CacheDataType == CACHE_DATA);
+    ASSERT (CacheDataType == CacheData);
 
     EntryPos    = Volume->RootPos + LShiftU64 (PageNo, PageAlignment);
     AlignedSize = AlignedPageCount << PageAlignment;
     Status      = FatDiskIo (Volume, IoMode, EntryPos, AlignedSize, Buffer, 
Task);
     if (EFI_ERROR (Status)) {
@@ -448,11 +448,11 @@ Returns:
   UINTN           GroupIndex;
   UINTN           GroupMask;
   DISK_CACHE      *DiskCache;
   CACHE_TAG       *CacheTag;
 
-  for (CacheDataType = (CACHE_DATA_TYPE) 0; CacheDataType < CACHE_MAX_TYPE; 
CacheDataType++) {
+  for (CacheDataType = (CACHE_DATA_TYPE) 0; CacheDataType < CacheMaxType; 
CacheDataType++) {
     DiskCache = &Volume->DiskCache[CacheDataType];
     if (DiskCache->Dirty) {
       //
       // Data cache or fat cache is dirty, write the dirty data back
       //
@@ -461,11 +461,11 @@ Returns:
         CacheTag = &DiskCache->CacheTag[GroupIndex];
         if (CacheTag->RealSize > 0 && CacheTag->Dirty) {
           //
           // Write back all Dirty Data Cache Page to disk
           //
-          Status = FatExchangeCachePage (Volume, CacheDataType, WRITE_DISK, 
CacheTag, Task);
+          Status = FatExchangeCachePage (Volume, CacheDataType, WriteDisk, 
CacheTag, Task);
           if (EFI_ERROR (Status)) {
             return Status;
           }
         }
       }
@@ -509,36 +509,36 @@ Returns:
 
   DiskCache = Volume->DiskCache;
   //
   // Configure the parameters of disk cache
   //
-  if (Volume->FatType == FAT12) {
+  if (Volume->FatType == Fat12) {
     FatCacheGroupCount                  = FAT_FATCACHE_GROUP_MIN_COUNT;
-    DiskCache[CACHE_FAT].PageAlignment  = FAT_FATCACHE_PAGE_MIN_ALIGNMENT;
-    DiskCache[CACHE_DATA].PageAlignment = FAT_DATACACHE_PAGE_MIN_ALIGNMENT;
+    DiskCache[CacheFat].PageAlignment  = FAT_FATCACHE_PAGE_MIN_ALIGNMENT;
+    DiskCache[CacheData].PageAlignment = FAT_DATACACHE_PAGE_MIN_ALIGNMENT;
   } else {
     FatCacheGroupCount                  = FAT_FATCACHE_GROUP_MAX_COUNT;
-    DiskCache[CACHE_FAT].PageAlignment  = FAT_FATCACHE_PAGE_MAX_ALIGNMENT;
-    DiskCache[CACHE_DATA].PageAlignment = FAT_DATACACHE_PAGE_MAX_ALIGNMENT;
+    DiskCache[CacheFat].PageAlignment  = FAT_FATCACHE_PAGE_MAX_ALIGNMENT;
+    DiskCache[CacheData].PageAlignment = FAT_DATACACHE_PAGE_MAX_ALIGNMENT;
   }
 
-  DiskCache[CACHE_DATA].GroupMask     = FAT_DATACACHE_GROUP_COUNT - 1;
-  DiskCache[CACHE_DATA].BaseAddress   = Volume->RootPos;
-  DiskCache[CACHE_DATA].LimitAddress  = Volume->VolumeSize;
-  DiskCache[CACHE_FAT].GroupMask      = FatCacheGroupCount - 1;
-  DiskCache[CACHE_FAT].BaseAddress    = Volume->FatPos;
-  DiskCache[CACHE_FAT].LimitAddress   = Volume->FatPos + Volume->FatSize;
-  FatCacheSize                        = FatCacheGroupCount << 
DiskCache[CACHE_FAT].PageAlignment;
-  DataCacheSize                       = FAT_DATACACHE_GROUP_COUNT << 
DiskCache[CACHE_DATA].PageAlignment;
+  DiskCache[CacheData].GroupMask     = FAT_DATACACHE_GROUP_COUNT - 1;
+  DiskCache[CacheData].BaseAddress   = Volume->RootPos;
+  DiskCache[CacheData].LimitAddress  = Volume->VolumeSize;
+  DiskCache[CacheFat].GroupMask      = FatCacheGroupCount - 1;
+  DiskCache[CacheFat].BaseAddress    = Volume->FatPos;
+  DiskCache[CacheFat].LimitAddress   = Volume->FatPos + Volume->FatSize;
+  FatCacheSize                        = FatCacheGroupCount << 
DiskCache[CacheFat].PageAlignment;
+  DataCacheSize                       = FAT_DATACACHE_GROUP_COUNT << 
DiskCache[CacheData].PageAlignment;
   //
   // Allocate the Fat Cache buffer
   //
   CacheBuffer = AllocateZeroPool (FatCacheSize + DataCacheSize);
   if (CacheBuffer == NULL) {
     return EFI_OUT_OF_RESOURCES;
   }
 
   Volume->CacheBuffer             = CacheBuffer;
-  DiskCache[CACHE_FAT].CacheBase  = CacheBuffer;
-  DiskCache[CACHE_DATA].CacheBase = CacheBuffer + FatCacheSize;
+  DiskCache[CacheFat].CacheBase  = CacheBuffer;
+  DiskCache[CacheData].CacheBase = CacheBuffer + FatCacheSize;
   return EFI_SUCCESS;
 }
diff --git a/FatPkg/EnhancedFatDxe/Fat.h b/FatPkg/EnhancedFatDxe/Fat.h
index b73135c..42aa647 100644
--- a/FatPkg/EnhancedFatDxe/Fat.h
+++ b/FatPkg/EnhancedFatDxe/Fat.h
@@ -126,32 +126,32 @@ typedef CHAR8                   LC_ISO_639_2;
 
 //
 // The fat types we support
 //
 typedef enum {
-  FAT12,
-  FAT16,
-  FAT32,
+  Fat12,
+  Fat16,
+  Fat32,
   FatUndefined
 } FAT_VOLUME_TYPE;
 
 typedef enum {
-  CACHE_FAT,
-  CACHE_DATA,
-  CACHE_MAX_TYPE
+  CacheFat,
+  CacheData,
+  CacheMaxType
 } CACHE_DATA_TYPE;
 
 //
 // Used in FatDiskIo
 //
 typedef enum {
-  READ_DISK     = 0,  // raw disk read
-  WRITE_DISK    = 1,  // raw disk write
-  READ_FAT      = 2,  // read fat cache
-  WRITE_FAT     = 3,  // write fat cache
-  READ_DATA     = 6,  // read data cache
-  WRITE_DATA    = 7   // write data cache
+  ReadDisk     = 0,  // raw disk read
+  WriteDisk    = 1,  // raw disk write
+  ReadFat      = 2,  // read fat cache
+  WriteFat     = 3,  // write fat cache
+  ReadData     = 6,  // read data cache
+  WriteData    = 7   // write data cache
 } IO_MODE;
 
 #define CACHE_ENABLED(a)  ((a) >= 2)
 #define RAW_ACCESS(a)     ((IO_MODE)((a) & 0x1))
 #define CACHE_TYPE(a)     ((CACHE_DATA_TYPE)((a) >> 2))
@@ -382,11 +382,11 @@ typedef struct _FAT_VOLUME {
 
   //
   // Disk Cache for this volume
   //
   VOID                            *CacheBuffer;
-  DISK_CACHE                      DiskCache[CACHE_MAX_TYPE];
+  DISK_CACHE                      DiskCache[CacheMaxType];
 } FAT_VOLUME;
 
 //
 // Function Prototypes
 //
@@ -1098,11 +1098,11 @@ FatResetODirCursor (
   IN FAT_OFILE          *OFile
   );
 
 EFI_STATUS
 FatGetNextDirEnt (
-  IN  FAT_OFILE         *OFILE,
+  IN  FAT_OFILE         *OFile,
   OUT FAT_DIRENT        **PtrDirEnt
   );
 
 EFI_STATUS
 FatRemoveDirEnt (
diff --git a/FatPkg/EnhancedFatDxe/FileSpace.c 
b/FatPkg/EnhancedFatDxe/FileSpace.c
index ce7c067..db44a33 100644
--- a/FatPkg/EnhancedFatDxe/FileSpace.c
+++ b/FatPkg/EnhancedFatDxe/FileSpace.c
@@ -57,15 +57,15 @@ Returns:
   }
   //
   // Compute buffer position needed
   //
   switch (Volume->FatType) {
-  case FAT12:
+  case Fat12:
     Pos = FAT_POS_FAT12 (Index);
     break;
 
-  case FAT16:
+  case Fat16:
     Pos = FAT_POS_FAT16 (Index);
     break;
 
   default:
     Pos = FAT_POS_FAT32 (Index);
@@ -74,11 +74,11 @@ Returns:
   // Set the position and read the buffer
   //
   Volume->FatEntryPos = Volume->FatPos + Pos;
   Status = FatDiskIo (
              Volume,
-             READ_FAT,
+             ReadFat,
              Volume->FatEntryPos,
              Volume->FatEntrySize,
              &Volume->FatEntryBuffer,
              NULL
              );
@@ -111,38 +111,38 @@ Returns:
   The value of the FAT entry.
 
 --*/
 {
   VOID    *Pos;
-  UINT8   *E12;
-  UINT16  *E16;
-  UINT32  *E32;
+  UINT8   *En12;
+  UINT16  *En16;
+  UINT32  *En32;
   UINTN   Accum;
 
   Pos = FatLoadFatEntry (Volume, Index);
 
   if (Index > (Volume->MaxCluster + 1)) {
     return (UINTN) -1;
   }
 
   switch (Volume->FatType) {
-  case FAT12:
-    E12   = Pos;
-    Accum = E12[0] | (E12[1] << 8);
+  case Fat12:
+    En12   = Pos;
+    Accum = En12[0] | (En12[1] << 8);
     Accum = FAT_ODD_CLUSTER_FAT12 (Index) ? (Accum >> 4) : (Accum & 
FAT_CLUSTER_MASK_FAT12);
     Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT12) ? 
FAT_CLUSTER_SPECIAL_EXT : 0);
     break;
 
-  case FAT16:
-    E16   = Pos;
-    Accum = *E16;
+  case Fat16:
+    En16   = Pos;
+    Accum = *En16;
     Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT16) ? 
FAT_CLUSTER_SPECIAL_EXT : 0);
     break;
 
   default:
-    E32   = Pos;
-    Accum = *E32 & FAT_CLUSTER_MASK_FAT32;
+    En32   = Pos;
+    Accum = *En32 & FAT_CLUSTER_MASK_FAT32;
     Accum = Accum | ((Accum >= FAT_CLUSTER_SPECIAL_FAT32) ? 
FAT_CLUSTER_SPECIAL_EXT : 0);
   }
 
   return Accum;
 }
@@ -173,13 +173,13 @@ Returns:
   other                 - An error occurred when operation the FAT entries.
 
 --*/
 {
   VOID        *Pos;
-  UINT8       *E12;
-  UINT16      *E16;
-  UINT32      *E32;
+  UINT8       *En12;
+  UINT16      *En16;
+  UINT32      *En32;
   UINTN       Accum;
   EFI_STATUS  Status;
   UINTN       OriginalVal;
 
   if (Index < FAT_MIN_CLUSTER) {
@@ -204,49 +204,49 @@ Returns:
 
   //
   // Update the value
   //
   switch (Volume->FatType) {
-  case FAT12:
-    E12   = Pos;
-    Accum = E12[0] | (E12[1] << 8);
+  case Fat12:
+    En12   = Pos;
+    Accum = En12[0] | (En12[1] << 8);
     Value = Value & FAT_CLUSTER_MASK_FAT12;
 
     if (FAT_ODD_CLUSTER_FAT12 (Index)) {
       Accum = (Value << 4) | (Accum & 0xF);
     } else {
       Accum = Value | (Accum & FAT_CLUSTER_UNMASK_FAT12);
     }
 
-    E12[0]  = (UINT8) (Accum & 0xFF);
-    E12[1]  = (UINT8) (Accum >> 8);
+    En12[0]  = (UINT8) (Accum & 0xFF);
+    En12[1]  = (UINT8) (Accum >> 8);
     break;
 
-  case FAT16:
-    E16   = Pos;
-    *E16  = (UINT16) Value;
+  case Fat16:
+    En16   = Pos;
+    *En16  = (UINT16) Value;
     break;
 
   default:
-    E32   = Pos;
-    *E32  = (*E32 & FAT_CLUSTER_UNMASK_FAT32) | (UINT32) (Value & 
FAT_CLUSTER_MASK_FAT32);
+    En32   = Pos;
+    *En32  = (*En32 & FAT_CLUSTER_UNMASK_FAT32) | (UINT32) (Value & 
FAT_CLUSTER_MASK_FAT32);
   }
   //
   // If the volume's dirty bit is not set, set it now
   //
-  if (!Volume->FatDirty && Volume->FatType != FAT12) {
+  if (!Volume->FatDirty && Volume->FatType != Fat12) {
     Volume->FatDirty = TRUE;
-    FatAccessVolumeDirty (Volume, WRITE_FAT, &Volume->DirtyValue);
+    FatAccessVolumeDirty (Volume, WriteFat, &Volume->DirtyValue);
   }
   //
   // Write the updated fat entry value to the volume
   // The fat is the first fat, and other fat will be in sync
   // when the FAT cache flush back.
   //
   Status = FatDiskIo (
              Volume,
-             WRITE_FAT,
+             WriteFat,
              Volume->FatEntryPos,
              Volume->FatEntrySize,
              &Volume->FatEntryBuffer,
              NULL
              );
diff --git a/FatPkg/EnhancedFatDxe/Flush.c b/FatPkg/EnhancedFatDxe/Flush.c
index 2c960f3..172f202 100644
--- a/FatPkg/EnhancedFatDxe/Flush.c
+++ b/FatPkg/EnhancedFatDxe/Flush.c
@@ -460,21 +460,21 @@ Returns:
     //
     // Update the free hint info. Volume->FreeInfoPos != 0
     // indicates this a FAT32 volume
     //
     if (Volume->FreeInfoValid && Volume->FatDirty && Volume->FreeInfoPos) {
-      Status = FatDiskIo (Volume, WRITE_DISK, Volume->FreeInfoPos, sizeof 
(FAT_INFO_SECTOR), &Volume->FatInfoSector, Task);
+      Status = FatDiskIo (Volume, WriteDisk, Volume->FreeInfoPos, sizeof 
(FAT_INFO_SECTOR), &Volume->FatInfoSector, Task);
       if (EFI_ERROR (Status)) {
         return Status;
       }
     }
     //
     // Update that the volume is not dirty
     //
-    if (Volume->FatDirty && Volume->FatType != FAT12) {
+    if (Volume->FatDirty && Volume->FatType != Fat12) {
       Volume->FatDirty  = FALSE;
-      Status            = FatAccessVolumeDirty (Volume, WRITE_FAT, 
&Volume->NotDirtyValue);
+      Status            = FatAccessVolumeDirty (Volume, WriteFat, 
&Volume->NotDirtyValue);
       if (EFI_ERROR (Status)) {
         return Status;
       }
     }
     //
diff --git a/FatPkg/EnhancedFatDxe/Init.c b/FatPkg/EnhancedFatDxe/Init.c
index 34a7250..d7cfa82 100644
--- a/FatPkg/EnhancedFatDxe/Init.c
+++ b/FatPkg/EnhancedFatDxe/Init.c
@@ -263,11 +263,11 @@ Returns:
   }
 
   SectorsPerFat = FatBs.FatBsb.SectorsPerFat;
   if (SectorsPerFat == 0) {
     SectorsPerFat = FatBs.FatBse.Fat32Bse.LargeSectorsPerFat;
-    FatType       = FAT32;
+    FatType       = Fat32;
   }
   //
   // Is boot sector a fat sector?
   // (Note that so far we only know if the sector is FAT32 or not, we don't
   // know if the sector is Fat16 or Fat12 until later when we can compute
@@ -303,11 +303,11 @@ Returns:
     return EFI_UNSUPPORTED;
   }
   //
   // Initialize fields the volume information for this FatType
   //
-  if (FatType != FAT32) {
+  if (FatType != Fat32) {
     if (FatBs.FatBsb.RootEntries == 0) {
       return EFI_UNSUPPORTED;
     }
     //
     // Unpack fat12, fat16 info
@@ -348,16 +348,16 @@ Returns:
   Volume->ClusterSize       = (UINTN)1 << (Volume->ClusterAlignment);
 
   //
   // If this is not a fat32, determine if it's a fat16 or fat12
   //
-  if (FatType != FAT32) {
+  if (FatType != Fat32) {
     if (Volume->MaxCluster >= FAT_MAX_FAT16_CLUSTER) {
       return EFI_VOLUME_CORRUPTED;
     }
 
-    FatType = Volume->MaxCluster < FAT_MAX_FAT12_CLUSTER ? FAT12 : FAT16;
+    FatType = Volume->MaxCluster < FAT_MAX_FAT12_CLUSTER ? Fat12 : Fat16;
     //
     // fat12 & fat16 fat-entries are 2 bytes
     //
     Volume->FatEntrySize = sizeof (UINT16);
     DirtyMask            = FAT16_DIRTY_MASK;
@@ -374,25 +374,25 @@ Returns:
   //
   // Get the DirtyValue and NotDirtyValue
   // We should keep the initial value as the NotDirtyValue
   // in case the volume is dirty already
   //
-  if (FatType != FAT12) {
-    Status = FatAccessVolumeDirty (Volume, READ_DISK, &Volume->NotDirtyValue);
+  if (FatType != Fat12) {
+    Status = FatAccessVolumeDirty (Volume, ReadDisk, &Volume->NotDirtyValue);
     if (EFI_ERROR (Status)) {
       return Status;
     }
 
     Volume->DirtyValue = Volume->NotDirtyValue & DirtyMask;
   }
   //
   // If present, read the fat hint info
   //
-  if (FatType == FAT32) {
+  if (FatType == Fat32) {
     Volume->FreeInfoPos = FatBs.FatBse.Fat32Bse.FsInfoSector * BlockSize;
     if (FatBs.FatBse.Fat32Bse.FsInfoSector != 0) {
-      FatDiskIo (Volume, READ_DISK, Volume->FreeInfoPos, sizeof 
(FAT_INFO_SECTOR), &Volume->FatInfoSector, NULL);
+      FatDiskIo (Volume, ReadDisk, Volume->FreeInfoPos, sizeof 
(FAT_INFO_SECTOR), &Volume->FatInfoSector, NULL);
       if (Volume->FatInfoSector.Signature == FAT_INFO_SIGNATURE &&
           Volume->FatInfoSector.InfoBeginSignature == FAT_INFO_BEGIN_SIGNATURE 
&&
           Volume->FatInfoSector.InfoEndSignature == FAT_INFO_END_SIGNATURE &&
           Volume->FatInfoSector.FreeInfo.ClusterCount <= Volume->MaxCluster
           ) {
diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c
index 6ad688c..48c99f9 100644
--- a/FatPkg/EnhancedFatDxe/Misc.c
+++ b/FatPkg/EnhancedFatDxe/Misc.c
@@ -394,11 +394,11 @@ Returns:
       if (Task == NULL) {
         //
         // Blocking access
         //
         DiskIo      = Volume->DiskIo;
-        IoFunction  = (IoMode == READ_DISK) ? DiskIo->ReadDisk : 
DiskIo->WriteDisk;
+        IoFunction  = (IoMode == ReadDisk) ? DiskIo->ReadDisk : 
DiskIo->WriteDisk;
         Status      = IoFunction (DiskIo, Volume->MediaId, Offset, BufferSize, 
Buffer);
       } else {
         //
         // Non-blocking access
         //
@@ -406,11 +406,11 @@ Returns:
         if (Subtask == NULL) {
           Status        = EFI_OUT_OF_RESOURCES;
         } else {
           Subtask->Signature  = FAT_SUBTASK_SIGNATURE;
           Subtask->Task       = Task;
-          Subtask->Write      = (BOOLEAN) (IoMode == WRITE_DISK);
+          Subtask->Write      = (BOOLEAN) (IoMode == WriteDisk);
           Subtask->Offset     = Offset;
           Subtask->Buffer     = Buffer;
           Subtask->BufferSize = BufferSize;
           Status = gBS->CreateEvent (
                           EVT_NOTIFY_SIGNAL,
diff --git a/FatPkg/EnhancedFatDxe/ReadWrite.c 
b/FatPkg/EnhancedFatDxe/ReadWrite.c
index 9afb6bf..81676cd 100644
--- a/FatPkg/EnhancedFatDxe/ReadWrite.c
+++ b/FatPkg/EnhancedFatDxe/ReadWrite.c
@@ -251,19 +251,19 @@ Returns:
   Task   = NULL;
 
   //
   // Write to a directory is unsupported
   //
-  if ((OFile->ODir != NULL) && (IoMode == WRITE_DATA)) {
+  if ((OFile->ODir != NULL) && (IoMode == WriteData)) {
     return EFI_UNSUPPORTED;
   }
 
   if (OFile->Error == EFI_NOT_FOUND) {
     return EFI_DEVICE_ERROR;
   }
 
-  if (IoMode == READ_DATA) {
+  if (IoMode == ReadData) {
     //
     // If position is at EOF, then return device error
     //
     if (IFile->Position > OFile->FileSize) {
       return EFI_DEVICE_ERROR;
@@ -303,11 +303,11 @@ Returns:
   if (!EFI_ERROR (Status)) {
     if (OFile->ODir != NULL) {
       //
       // Read a directory is supported
       //
-      ASSERT (IoMode == READ_DATA);
+      ASSERT (IoMode == ReadData);
       Status = FatIFileReadDir (IFile, BufferSize, Buffer);
       OFile = NULL;
     } else {
       //
       // Access a file
@@ -315,11 +315,11 @@ Returns:
       EndPosition = IFile->Position + *BufferSize;
       if (EndPosition > OFile->FileSize) {
         //
         // The position goes beyond the end of file
         //
-        if (IoMode == READ_DATA) {
+        if (IoMode == ReadData) {
           //
           // Adjust the actual size read
           //
           *BufferSize -= (UINTN) EndPosition - OFile->FileSize;
         } else {
@@ -399,11 +399,11 @@ Returns:
   EFI_VOLUME_CORRUPTED  - The file type of open file is error.
   other                 - An error occurred when operation the disk.
 
 --*/
 {
-  return FatIFileAccess (FHand, READ_DATA, BufferSize, Buffer, NULL);
+  return FatIFileAccess (FHand, ReadData, BufferSize, Buffer, NULL);
 }
 
 EFI_STATUS
 EFIAPI
 FatReadEx (
@@ -428,11 +428,11 @@ Returns:
   EFI_VOLUME_CORRUPTED  - The file type of open file is error.
   other                 - An error occurred when operation the disk.
 
 --*/
 {
-  return FatIFileAccess (FHand, READ_DATA, &Token->BufferSize, Token->Buffer, 
Token);
+  return FatIFileAccess (FHand, ReadData, &Token->BufferSize, Token->Buffer, 
Token);
 }
 
 EFI_STATUS
 EFIAPI
 FatWrite (
@@ -462,11 +462,11 @@ Returns:
                         - The writing file size is larger than 4GB.
   other                 - An error occurred when operation the disk.
 
 --*/
 {
-  return FatIFileAccess (FHand, WRITE_DATA, BufferSize, Buffer, NULL);
+  return FatIFileAccess (FHand, WriteData, BufferSize, Buffer, NULL);
 }
 
 EFI_STATUS
 EFIAPI
 FatWriteEx (
@@ -491,11 +491,11 @@ Returns:
   EFI_VOLUME_CORRUPTED  - The file type of open file is error.
   other                 - An error occurred when operation the disk.
 
 --*/
 {
-  return FatIFileAccess (FHand, WRITE_DATA, &Token->BufferSize, Token->Buffer, 
Token);
+  return FatIFileAccess (FHand, WriteData, &Token->BufferSize, Token->Buffer, 
Token);
 }
 
 EFI_STATUS
 FatAccessOFile (
   IN     FAT_OFILE      *OFile,
@@ -561,11 +561,11 @@ Returns:
     // Data was successfully accessed
     //
     Position   += Len;
     UserBuffer += Len;
     BufferSize -= Len;
-    if (IoMode == WRITE_DATA) {
+    if (IoMode == WriteData) {
       OFile->Dirty    = TRUE;
       OFile->Archive  = TRUE;
     }
     //
     // Make sure no outbound occurred
@@ -662,11 +662,11 @@ Returns:
   }
 
   do {
     WriteSize     = AppendedSize > BufferSize ? BufferSize : (UINTN) 
AppendedSize;
     AppendedSize -= WriteSize;
-    Status = FatAccessOFile (OFile, WRITE_DATA, WritePos, &WriteSize, 
ZeroBuffer, NULL);
+    Status = FatAccessOFile (OFile, WriteData, WritePos, &WriteSize, 
ZeroBuffer, NULL);
     if (EFI_ERROR (Status)) {
       break;
     }
 
     WritePos += WriteSize;
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to