]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/DirectoryManage.c
FatPkg/EnhancedFatDxe: Make the comments align with EDKIIcoding style
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / DirectoryManage.c
index f9a764d3aa52dd3b4154bb18dcc73e15fda34596..fe6fcc9d8874256805bd015a858dfc9472a9aa54 100644 (file)
@@ -1,7 +1,8 @@
-/*++\r
+/** @file\r
+  Functions for performing directory entry io.\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 - 2015, 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,21 +10,23 @@ 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
 \r
-Module Name:\r
-\r
-  DirectoryManage.c\r
-\r
-Abstract:\r
+#include "Fat.h"\r
 \r
-  Functions for performing directory entry io\r
+/**\r
 \r
-Revision History\r
+  Get a directory entry from disk for the Ofile.\r
 \r
---*/\r
+  @param  Parent                - The parent of the OFile which need to update.\r
+  @param  IoMode                - Indicate whether to read directory entry or write directroy entry.\r
+  @param  EntryPos              - The position of the directory entry to be accessed.\r
+  @param  Entry                 - The directory entry read or written.\r
 \r
-#include "Fat.h"\r
+  @retval EFI_SUCCESS           - Access the directory entry sucessfully.\r
+  @return other                 - An error occurred when reading the directory entry.\r
 \r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatAccessEntry (\r
@@ -32,25 +35,6 @@ FatAccessEntry (
   IN     UINTN                EntryPos,\r
   IN OUT VOID                 *Entry\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get a directory entry from disk for the Ofile.\r
-\r
-Arguments:\r
-\r
-  Parent                - The parent of the OFile which need to update.\r
-  IoMode                - Indicate whether to read directory entry or write directroy entry.\r
-  EntryPos              - The position of the directory entry to be accessed.\r
-  Entry                 - The directory entry read or written.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Access the directory entry sucessfully.\r
-  other                 - An error occurred when reading the directory entry.\r
-\r
---*/\r
 {\r
   UINTN Position;\r
   UINTN BufferSize;\r
@@ -60,38 +44,32 @@ Returns:
     //\r
     // End of directory\r
     //\r
-    ASSERT (IoMode == READ_DATA);\r
+    ASSERT (IoMode == ReadData);\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->FileName[0] = EMPTY_ENTRY_MARK;\r
     ((FAT_DIRECTORY_ENTRY *) Entry)->Attributes  = 0;\r
     return EFI_SUCCESS;\r
   }\r
 \r
   BufferSize = sizeof (FAT_DIRECTORY_ENTRY);\r
-  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry);\r
+  return FatAccessOFile (Parent, IoMode, Position, &BufferSize, Entry, NULL);\r
 }\r
 \r
-EFI_STATUS\r
-FatStoreDirEnt (\r
-  IN FAT_OFILE            *OFile,\r
-  IN FAT_DIRENT           *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Save the directory entry to disk.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The parent OFile which needs to update.\r
-  DirEnt                - The directory entry to be saved.\r
-\r
-Returns:\r
+  @param  OFile                 - The parent OFile which needs to update.\r
+  @param  DirEnt                - The directory entry to be saved.\r
 \r
-  EFI_SUCCESS           - Store the directory entry successfully.\r
-  other                 - An error occurred when writing the directory entry.\r
+  @retval EFI_SUCCESS           - Store the directory entry successfully.\r
+  @return other                 - An error occurred when writing the directory entry.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatStoreDirEnt (\r
+  IN FAT_OFILE            *OFile,\r
+  IN FAT_DIRENT           *DirEnt\r
+  )\r
 {\r
   EFI_STATUS        Status;\r
   FAT_DIRECTORY_LFN LfnEntry;\r
@@ -106,7 +84,7 @@ Returns:
   //\r
   // Write directory entry\r
   //\r
-  Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &DirEnt->Entry);\r
+  Status = FatAccessEntry (OFile, WriteData, EntryPos, &DirEnt->Entry);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
@@ -116,7 +94,15 @@ Returns:
     // Write LFN directory entry\r
     //\r
     SetMem (LfnBuffer, sizeof (CHAR16) * LFN_CHAR_TOTAL * EntryCount, 0xff);\r
-    StrCpy (LfnBuffer, DirEnt->FileString);\r
+    Status = StrCpyS (\r
+               LfnBuffer,\r
+               ARRAY_SIZE (LfnBuffer),\r
+               DirEnt->FileString\r
+               );\r
+    if (EFI_ERROR (Status)) {\r
+      return Status;\r
+    }\r
+\r
     LfnBufferPointer    = LfnBuffer;\r
     LfnEntry.Attributes = FAT_ATTRIBUTE_LFN;\r
     LfnEntry.Type       = 0;\r
@@ -139,7 +125,7 @@ Returns:
         LfnEntry.Ordinal = DELETE_ENTRY_MARK;\r
       }\r
 \r
-      Status = FatAccessEntry (OFile, WRITE_DATA, EntryPos, &LfnEntry);\r
+      Status = FatAccessEntry (OFile, WriteData, EntryPos, &LfnEntry);\r
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
@@ -149,26 +135,20 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-BOOLEAN\r
-FatIsDotDirEnt (\r
-  IN FAT_DIRENT  *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Determine whether the directory entry is "." or ".." entry.\r
 \r
-Arguments:\r
-\r
-  DirEnt               - The corresponding directory entry.\r
-\r
-Returns:\r
+  @param  DirEnt               - The corresponding directory entry.\r
 \r
-  TRUE                 - The directory entry is "." or ".." directory entry\r
-  FALSE                - The directory entry is not "." or ".." directory entry\r
+  @retval TRUE                 - The directory entry is "." or ".." directory entry\r
+  @retval FALSE                - The directory entry is not "." or ".." directory entry\r
 \r
---*/\r
+**/\r
+BOOLEAN\r
+FatIsDotDirEnt (\r
+  IN FAT_DIRENT  *DirEnt\r
+  )\r
 {\r
   CHAR16  *FileString;\r
   FileString = DirEnt->FileString;\r
@@ -179,26 +159,18 @@ Returns:
   return FALSE;\r
 }\r
 \r
+/**\r
+\r
+  Set the OFile's cluster info in its directory entry.\r
+\r
+  @param  OFile                 - The corresponding OFile.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 FatSetDirEntCluster (\r
   IN FAT_OFILE    *OFile\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set the OFile's cluster info in its directory entry.\r
-\r
-Arguments:\r
-\r
-  OFile                 - The corresponding OFile.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   UINTN       Cluster;\r
   FAT_DIRENT  *DirEnt;\r
@@ -209,52 +181,36 @@ Returns:
   DirEnt->Entry.FileCluster     = (UINT16) Cluster;\r
 }\r
 \r
-VOID\r
-FatUpdateDirEntClusterSizeInfo (\r
-  IN FAT_OFILE    *OFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Set the OFile's cluster and size info in its directory entry.\r
 \r
-Arguments:\r
+  @param  OFile                 - The corresponding OFile.\r
 \r
-  OFile                 - The corresponding OFile.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
+**/\r
+VOID\r
+FatUpdateDirEntClusterSizeInfo (\r
+  IN FAT_OFILE    *OFile\r
+  )\r
 {\r
   ASSERT (OFile->ODir == NULL);\r
   OFile->DirEnt->Entry.FileSize = (UINT32) OFile->FileSize;\r
   FatSetDirEntCluster (OFile);\r
 }\r
 \r
+/**\r
+\r
+  Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.\r
+\r
+  @param  DirEnt1               - The destination directory entry.\r
+  @param  DirEnt2               - The source directory entry.\r
+\r
+**/\r
 VOID\r
 FatCloneDirEnt (\r
   IN  FAT_DIRENT          *DirEnt1,\r
   IN  FAT_DIRENT          *DirEnt2\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.\r
-\r
-Arguments:\r
-\r
-  DirEnt1               - The destination directory entry.\r
-  DirEnt2               - The source directory entry.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   UINT8 *Entry1;\r
   UINT8 *Entry2;\r
@@ -267,28 +223,20 @@ Returns:
     );\r
 }\r
 \r
+/**\r
+\r
+  Get the LFN for the directory entry.\r
+\r
+  @param  Parent                - The parent directory.\r
+  @param  DirEnt                - The directory entry to get LFN.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 FatLoadLongNameEntry (\r
   IN FAT_OFILE           *Parent,\r
   IN FAT_DIRENT          *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the LFN for the directory entry.\r
-\r
-Arguments:\r
-\r
-  Parent                - The parent directory.\r
-  DirEnt                - The directory entry to get LFN.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   CHAR16            LfnBuffer[MAX_LFN_ENTRIES * LFN_CHAR_TOTAL + 1];\r
   CHAR16            *LfnBufferPointer;\r
@@ -314,7 +262,7 @@ Returns:
     }\r
 \r
     EntryPos--;\r
-    Status = FatAccessEntry (Parent, READ_DATA, EntryPos, &LfnEntry);\r
+    Status = FatAccessEntry (Parent, ReadData, EntryPos, &LfnEntry);\r
     if (EFI_ERROR (Status) ||\r
         LfnEntry.Attributes != FAT_ATTRIBUTE_LFN ||\r
         LfnEntry.MustBeZero != 0 ||\r
@@ -349,34 +297,30 @@ Returns:
     // Fail to get the long file name from long file name entry,\r
     // get the file name from short name\r
     //\r
-    FatGetFileNameViaCaseFlag (DirEnt, LfnBuffer);\r
+    FatGetFileNameViaCaseFlag (\r
+      DirEnt,\r
+      LfnBuffer,\r
+      ARRAY_SIZE (LfnBuffer)\r
+      );\r
   }\r
 \r
   DirEnt->FileString = AllocateCopyPool (StrSize (LfnBuffer), LfnBuffer);\r
 }\r
 \r
+/**\r
+\r
+  Add this directory entry node to the list of directory entries and hash table.\r
+\r
+  @param  ODir                  - The parent OFile which needs to be updated.\r
+  @param  DirEnt                - The directory entry to be added.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 FatAddDirEnt (\r
   IN FAT_ODIR             *ODir,\r
   IN FAT_DIRENT           *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Add this directory entry node to the list of directory entries and hash table.\r
-\r
-Arguments:\r
-\r
-  ODir                  - The parent OFile which needs to be updated.\r
-  DirEnt                - The directory entry to be added.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   if (DirEnt->Link.BackLink == NULL) {\r
     DirEnt->Link.BackLink = &ODir->ChildList;\r
@@ -385,30 +329,24 @@ Returns:
   FatInsertToHashTable (ODir, DirEnt);\r
 }\r
 \r
+/**\r
+\r
+  Load from disk the next directory entry at current end of directory position.\r
+\r
+  @param  OFile                 - The parent OFile.\r
+  @param  PtrDirEnt             - The directory entry that is loaded.\r
+\r
+  @retval EFI_SUCCESS           - Load the directory entry successfully.\r
+  @retval EFI_OUT_OF_RESOURCES  - Out of resource.\r
+  @return other                 - An error occurred when reading the directory entries.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatLoadNextDirEnt (\r
   IN  FAT_OFILE           *OFile,\r
   OUT FAT_DIRENT          **PtrDirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Load from disk the next directory entry at current end of directory position\r
-\r
-Arguments:\r
-\r
-  OFile                 - The parent OFile.\r
-  PtrDirEnt             - The directory entry that is loaded.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Load the directory entry successfully.\r
-  EFI_OUT_OF_RESOURCES  - Out of resource.\r
-  other                 - An error occurred when reading the directory entries.\r
-\r
---*/\r
 {\r
   EFI_STATUS          Status;\r
   FAT_DIRENT          *DirEnt;\r
@@ -430,7 +368,7 @@ Returns:
     //\r
     // Read the next directory entry until we find a valid directory entry (excluding lfn entry)\r
     //\r
-    Status = FatAccessEntry (OFile, READ_DATA, ODir->CurrentEndPos, &Entry);\r
+    Status = FatAccessEntry (OFile, ReadData, ODir->CurrentEndPos, &Entry);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -450,7 +388,7 @@ Returns:
     // Although FAT spec states this field is always 0 for FAT12 & FAT16, some applications\r
     // might use it for some special usage, it is safer to zero it in memory for FAT12 & FAT16.\r
     //\r
-    if (OFile->Volume->FatType != FAT32) {\r
+    if (OFile->Volume->FatType != Fat32) {\r
       Entry.FileClusterHigh = 0;\r
     }\r
 \r
@@ -493,6 +431,19 @@ Done:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Get the directory entry's info into Buffer.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  DirEnt                - The corresponding directory entry.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing file info.\r
+\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
+\r
+**/\r
 EFI_STATUS\r
 FatGetDirEntInfo (\r
   IN     FAT_VOLUME         *Volume,\r
@@ -500,25 +451,6 @@ FatGetDirEntInfo (
   IN OUT UINTN              *BufferSize,\r
      OUT VOID               *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the directory entry's info into Buffer.\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  DirEnt                - The corresponding directory entry.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing file info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the file info successfully.\r
-  EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
-\r
---*/\r
 {\r
   UINTN               Size;\r
   UINTN               NameSize;\r
@@ -563,6 +495,18 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Search the directory for the directory entry whose filename is FileNameString.\r
+\r
+  @param  OFile                 - The parent OFile whose directory is to be searched.\r
+  @param  FileNameString        - The filename to be searched.\r
+  @param  PtrDirEnt             - pointer to the directory entry if found.\r
+\r
+  @retval EFI_SUCCESS           - Find the directory entry or not found.\r
+  @return other                 - An error occurred when reading the directory entries.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatSearchODir (\r
@@ -570,24 +514,6 @@ FatSearchODir (
   IN  CHAR16         *FileNameString,\r
   OUT FAT_DIRENT     **PtrDirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Search the directory for the directory entry whose filename is FileNameString.\r
-\r
-Arguments:\r
-\r
-  OFile                 - The parent OFile whose directory is to be searched.\r
-  FileNameString        - The filename to be searched.\r
-  PtrDirEnt             - pointer to the directory entry if found.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Find the directory entry or not found.\r
-  other                 - An error occurred when reading the directory entries.\r
-\r
---*/\r
 {\r
   BOOLEAN     PossibleShortName;\r
   CHAR8       File8Dot3Name[FAT_NAME_LEN];\r
@@ -635,25 +561,17 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-VOID\r
-FatResetODirCursor (\r
-  IN FAT_OFILE    *OFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Set the OFile's current directory cursor to the list head.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The directory OFile whose directory cursor is reset.\r
-\r
-Returns:\r
+  @param OFile                 - The directory OFile whose directory cursor is reset.\r
 \r
-  None.\r
-\r
---*/\r
+**/\r
+VOID\r
+FatResetODirCursor (\r
+  IN FAT_OFILE    *OFile\r
+  )\r
 {\r
   FAT_ODIR  *ODir;\r
 \r
@@ -663,28 +581,22 @@ Returns:
   ODir->CurrentPos    = 0;\r
 }\r
 \r
-EFI_STATUS\r
-FatGetNextDirEnt (\r
-  IN  FAT_OFILE     *OFile,\r
-  OUT FAT_DIRENT    **PtrDirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Set the directory's cursor to the next and get the next directory entry.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The parent OFile.\r
-  PtrDirEnt             - The next directory entry.\r
+  @param  OFile                 - The parent OFile.\r
+  @param PtrDirEnt             - The next directory entry.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           - We get the next directory entry successfully.\r
+  @return other                 - An error occurred when get next directory entry.\r
 \r
-  EFI_SUCCESS           - We get the next directory entry successfully.\r
-  other                 - An error occurred when get next directory entry.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatGetNextDirEnt (\r
+  IN  FAT_OFILE     *OFile,\r
+  OUT FAT_DIRENT    **PtrDirEnt\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_DIRENT  *DirEnt;\r
@@ -723,28 +635,20 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Set the directory entry count according to the filename.\r
+\r
+  @param  OFile                 - The corresponding OFile.\r
+  @param  DirEnt                - The directory entry to be set.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 FatSetEntryCount (\r
   IN FAT_OFILE    *OFile,\r
   IN FAT_DIRENT   *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set the directory entry count according to the filename.\r
-\r
-Arguments:\r
-\r
-  OFile                 - The corresponding OFile.\r
-  DirEnt                - The directory entry to be set.\r
-\r
-Returns:\r
-\r
-  None.\r
-\r
---*/\r
 {\r
   CHAR16  *FileString;\r
   CHAR8   *File8Dot3Name;\r
@@ -788,54 +692,42 @@ Returns:
   }\r
 }\r
 \r
+/**\r
+\r
+  Append a zero cluster to the current OFile.\r
+\r
+  @param  OFile        - The directory OFile which needs to be updated.\r
+\r
+  @retval EFI_SUCCESS  - Append a zero cluster to the OFile successfully.\r
+  @return other        - An error occurred when appending the zero cluster.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatExpandODir (\r
   IN FAT_OFILE  *OFile\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Append a zero cluster to the current OFile.\r
-\r
-Arguments:\r
+{\r
+  return FatExpandOFile (OFile, OFile->FileSize + OFile->Volume->ClusterSize);\r
+}\r
 \r
-  OFile        - The directory OFile which needs to be updated.\r
+/**\r
 \r
-Returns:\r
+  Search the Root OFile for the possible volume label.\r
 \r
-  EFI_SUCCESS  - Append a zero cluster to the OFile successfully.\r
-  other        - An error occurred when appending the zero cluster.\r
+  @param  Root                  - The Root OFile.\r
+  @param  DirEnt                - The returned directory entry of volume label.\r
 \r
---*/\r
-{\r
-  return FatExpandOFile (OFile, OFile->FileSize + OFile->Volume->ClusterSize);\r
-}\r
+  @retval EFI_SUCCESS           - The search process is completed successfully.\r
+  @return other                 - An error occurred when searching volume label.\r
 \r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatSeekVolumeId (\r
   IN  FAT_OFILE            *Root,\r
   OUT FAT_DIRENT           *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Search the Root OFile for the possible volume label.\r
-\r
-Arguments:\r
-\r
-  Root                  - The Root OFile.\r
-  DirEnt                - The returned directory entry of volume label.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The search process is completed successfully.\r
-  other                 - An error occurred when searching volume label.\r
-\r
---*/\r
 {\r
   EFI_STATUS          Status;\r
   UINTN               EntryPos;\r
@@ -845,7 +737,7 @@ Returns:
   Entry           = &DirEnt->Entry;\r
   DirEnt->Invalid = TRUE;\r
   do {\r
-    Status = FatAccessEntry (Root, READ_DATA, EntryPos, Entry);\r
+    Status = FatAccessEntry (Root, ReadData, EntryPos, Entry);\r
     if (EFI_ERROR (Status)) {\r
       return Status;\r
     }\r
@@ -862,33 +754,27 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
-EFI_STATUS\r
-FatFirstFitInsertDirEnt (\r
-  IN FAT_OFILE    *OFile,\r
-  IN FAT_DIRENT   *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Use First Fit Algorithm to insert directory entry.\r
   Only this function will erase "E5" entries in a directory.\r
   In view of safest recovery, this function will only be triggered\r
   when maximum directory entry number has reached.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The corresponding OFile.\r
-  DirEnt                - The directory entry to be inserted.\r
+  @param  OFile                 - The corresponding OFile.\r
+  @param  DirEnt                - The directory entry to be inserted.\r
 \r
-Returns:\r
+  @retval EFI_SUCCESS           - The directory entry has been successfully inserted.\r
+  @retval EFI_VOLUME_FULL       - The directory can not hold more directory entries.\r
+  @return Others                - Some error occurred when inserting new directory entries.\r
 \r
-  EFI_SUCCESS           - The directory entry has been successfully inserted.\r
-  EFI_VOLUME_FULL       - The directory can not hold more directory entries.\r
-  Others                - Some error occurred when inserting new directory entries.\r
-\r
---*/\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+FatFirstFitInsertDirEnt (\r
+  IN FAT_OFILE    *OFile,\r
+  IN FAT_DIRENT   *DirEnt\r
+  )\r
 {\r
   EFI_STATUS      Status;\r
   FAT_ODIR        *ODir;\r
@@ -944,30 +830,24 @@ Done:
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  Find the new directory entry position for the directory entry.\r
+\r
+  @param  OFile                 - The corresponding OFile.\r
+  @param  DirEnt                - The directory entry whose new position is to be set.\r
+\r
+  @retval EFI_SUCCESS           - The new directory entry position is successfully found.\r
+  @retval EFI_VOLUME_FULL       - The directory has reach its maximum capacity.\r
+  @return other                 - An error occurred when reading the directory entry.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 FatNewEntryPos (\r
   IN FAT_OFILE    *OFile,\r
   IN FAT_DIRENT   *DirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Find the new directory entry position for the directory entry.\r
-\r
-Arguments:\r
-\r
-  OFile                 - The corresponding OFile.\r
-  DirEnt                - The directory entry whose new position is to be set.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The new directory entry position is successfully found.\r
-  EFI_VOLUME_FULL       - The directory has reach its maximum capacity.\r
-  other                 - An error occurred when reading the directory entry.\r
-\r
---*/\r
 {\r
   EFI_STATUS  Status;\r
   FAT_ODIR    *ODir;\r
@@ -1015,28 +895,22 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-EFI_STATUS\r
-FatGetVolumeEntry (\r
-  IN FAT_VOLUME           *Volume,\r
-  IN CHAR16               *Name\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get the directory entry for the volume.\r
 \r
-Arguments:\r
+  @param  Volume                - FAT file system volume.\r
+  @param  Name                  - The file name of the volume.\r
 \r
-  Volume                - FAT file system volume.\r
-  Name                  - The file name of the volume.\r
+  @retval EFI_SUCCESS           - Update the volume with the directory entry sucessfully.\r
+  @return others                - An error occurred when getting volume label.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS           - Update the volume with the directory entry sucessfully.\r
-  others                - An error occurred when getting volume label.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatGetVolumeEntry (\r
+  IN FAT_VOLUME           *Volume,\r
+  IN CHAR16               *Name\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_DIRENT  LabelDirEnt;\r
@@ -1052,29 +926,23 @@ Returns:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatSetVolumeEntry (\r
-  IN FAT_VOLUME           *Volume,\r
-  IN CHAR16               *Name\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Set the relevant directory entry into disk for the volume.\r
 \r
-Arguments:\r
+  @param  Volume              - FAT file system volume.\r
+  @param  Name                - The new file name of the volume.\r
 \r
-  Volume              - FAT file system volume.\r
-  Name                - The new file name of the volume.\r
+  @retval EFI_SUCCESS         - Update the Volume sucessfully.\r
+  @retval EFI_UNSUPPORTED     - The input label is not a valid volume label.\r
+  @return other               - An error occurred when setting volume label.\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS         - Update the Volume sucessfully.\r
-  EFI_UNSUPPORTED     - The input label is not a valid volume label.\r
-  other               - An error occurred when setting volume label.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatSetVolumeEntry (\r
+  IN FAT_VOLUME           *Volume,\r
+  IN CHAR16               *Name\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_DIRENT  LabelDirEnt;\r
@@ -1109,26 +977,20 @@ Returns:
   return FatStoreDirEnt (Root, &LabelDirEnt);\r
 }\r
 \r
-EFI_STATUS\r
-FatCreateDotDirEnts (\r
-  IN FAT_OFILE          *OFile\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Create "." and ".." directory entries in the newly-created parent OFile.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The parent OFile.\r
-\r
-Returns:\r
+  @param  OFile                 - The parent OFile.\r
 \r
-  EFI_SUCCESS           - The dot directory entries are successfully created.\r
-  other                 - An error occurred when creating the directory entry.\r
+  @retval EFI_SUCCESS           - The dot directory entries are successfully created.\r
+  @return other                 - An error occurred when creating the directory entry.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatCreateDotDirEnts (\r
+  IN FAT_OFILE          *OFile\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_DIRENT  *DirEnt;\r
@@ -1153,6 +1015,20 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Create a directory entry in the parent OFile.\r
+\r
+  @param  OFile                 - The parent OFile.\r
+  @param  FileName              - The filename of the newly-created directory entry.\r
+  @param  Attributes            - The attribute of the newly-created directory entry.\r
+  @param  PtrDirEnt             - The pointer to the newly-created directory entry.\r
+\r
+  @retval EFI_SUCCESS           - The directory entry is successfully created.\r
+  @retval EFI_OUT_OF_RESOURCES  - Not enough memory to create the directory entry.\r
+  @return other                 - An error occurred when creating the directory entry.\r
+\r
+**/\r
 EFI_STATUS\r
 FatCreateDirEnt (\r
   IN  FAT_OFILE         *OFile,\r
@@ -1160,31 +1036,12 @@ FatCreateDirEnt (
   IN  UINT8             Attributes,\r
   OUT FAT_DIRENT        **PtrDirEnt\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Create a directory entry in the parent OFile.\r
-\r
-Arguments:\r
-\r
-  OFile                 - The parent OFile.\r
-  FileName              - The filename of the newly-created directory entry.\r
-  Attributes            - The attribute of the newly-created directory entry.\r
-  PtrDirEnt             - The pointer to the newly-created directory entry.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - The directory entry is successfully created.\r
-  EFI_OUT_OF_RESOURCES  - Not enough memory to create the directory entry.\r
-  other                 - An error occurred when creating the directory entry.\r
-\r
---*/\r
 {\r
   FAT_DIRENT  *DirEnt;\r
   FAT_ODIR    *ODir;\r
   EFI_STATUS  Status;\r
 \r
+  ASSERT (OFile != NULL);\r
   ODir = OFile->ODir;\r
   ASSERT (ODir != NULL);\r
   DirEnt = AllocateZeroPool (sizeof (FAT_DIRENT));\r
@@ -1221,28 +1078,22 @@ Done:
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-FatRemoveDirEnt (\r
-  IN FAT_OFILE    *OFile,\r
-  IN FAT_DIRENT   *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Remove this directory entry node from the list of directory entries and hash table.\r
 \r
-Arguments:\r
-\r
-  OFile                - The parent OFile.\r
-  DirEnt               - The directory entry to be removed.\r
-\r
-Returns:\r
+  @param  OFile                - The parent OFile.\r
+  @param  DirEnt               - The directory entry to be removed.\r
 \r
-  EFI_SUCCESS          - The directory entry is successfully removed.\r
-  other                - An error occurred when removing the directory entry.\r
+  @retval EFI_SUCCESS          - The directory entry is successfully removed.\r
+  @return other                - An error occurred when removing the directory entry.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatRemoveDirEnt (\r
+  IN FAT_OFILE    *OFile,\r
+  IN FAT_DIRENT   *DirEnt\r
+  )\r
 {\r
   FAT_ODIR  *ODir;\r
 \r
@@ -1266,29 +1117,23 @@ Returns:
   return FatStoreDirEnt (OFile, DirEnt);\r
 }\r
 \r
-EFI_STATUS\r
-FatOpenDirEnt (\r
-  IN FAT_OFILE         *Parent,\r
-  IN FAT_DIRENT        *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Open the directory entry to get the OFile.\r
 \r
-Arguments:\r
-\r
-  OFile                 - The parent OFile.\r
-  DirEnt                - The directory entry to be opened.\r
-\r
-Returns:\r
+  @param  Parent                - The parent OFile.\r
+  @param  DirEnt                - The directory entry to be opened.\r
 \r
-  EFI_SUCCESS           - The directory entry is successfully opened.\r
-  EFI_OUT_OF_RESOURCES  - not enough memory to allocate a new OFile.\r
-  other                 - An error occurred when opening the directory entry.\r
+  @retval EFI_SUCCESS           - The directory entry is successfully opened.\r
+  @retval EFI_OUT_OF_RESOURCES  - not enough memory to allocate a new OFile.\r
+  @return other                 - An error occurred when opening the directory entry.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatOpenDirEnt (\r
+  IN FAT_OFILE         *Parent,\r
+  IN FAT_DIRENT        *DirEnt\r
+  )\r
 {\r
   FAT_OFILE   *OFile;\r
   FAT_VOLUME  *Volume;\r
@@ -1322,7 +1167,7 @@ Returns:
       Volume                = VOLUME_FROM_ROOT_DIRENT (DirEnt);\r
       Volume->Root          = OFile;\r
       OFile->FileCluster    = Volume->RootCluster;\r
-      if (Volume->FatType  != FAT32) {\r
+      if (Volume->FatType  != Fat32) {\r
         OFile->IsFixedRootDir  = TRUE;\r
       }\r
     }\r
@@ -1351,33 +1196,24 @@ Returns:
   return EFI_SUCCESS;\r
 }\r
 \r
-VOID\r
-FatCloseDirEnt (\r
-  IN FAT_DIRENT        *DirEnt\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Close the directory entry and free the OFile.\r
 \r
-Arguments:\r
+  @param  DirEnt               - The directory entry to be closed.\r
 \r
-  DirEnt               - The directory entry to be closed.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS          - The directory entry is successfully opened.\r
-  Other                - An error occurred when opening the directory entry.\r
-\r
---*/\r
+**/\r
+VOID\r
+FatCloseDirEnt (\r
+  IN FAT_DIRENT        *DirEnt\r
+  )\r
 {\r
   FAT_OFILE   *OFile;\r
   FAT_VOLUME  *Volume;\r
 \r
   OFile   = DirEnt->OFile;\r
-  Volume  = OFile->Volume;\r
   ASSERT (OFile != NULL);\r
+  Volume  = OFile->Volume;\r
 \r
   if (OFile->ODir != NULL) {\r
     FatDiscardODir (OFile);\r
@@ -1399,38 +1235,33 @@ Returns:
   }\r
 }\r
 \r
-EFI_STATUS\r
-FatLocateOFile (\r
-  IN OUT FAT_OFILE        **PtrOFile,\r
-  IN     CHAR16           *FileName,\r
-  IN     UINT8            Attributes,\r
-     OUT CHAR16           *NewFileName\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Traverse filename and open all OFiles that can be opened.\r
   Update filename pointer to the component that can't be opened.\r
   If more than one name component remains, returns an error;\r
   otherwise, return the remaining name component so that the caller might choose to create it.\r
 \r
-Arguments:\r
-  PtrOFile              - As input, the reference OFile; as output, the located OFile.\r
-  FileName              - The file name relevant to the OFile.\r
-  Attributes            - The attribute of the destination OFile.\r
-  NewFileName           - The remaining file name.\r
-\r
-Returns:\r
+  @param  PtrOFile              - As input, the reference OFile; as output, the located OFile.\r
+  @param  FileName              - The file name relevant to the OFile.\r
+  @param  Attributes            - The attribute of the destination OFile.\r
+  @param  NewFileName           - The remaining file name.\r
 \r
-  EFI_NOT_FOUND         - The file name can't be opened and there is more than one\r
+  @retval EFI_NOT_FOUND         - The file name can't be opened and there is more than one\r
                           components within the name left (this means the name can\r
                           not be created either).\r
-  EFI_INVALID_PARAMETER - The parameter is not valid.\r
-  EFI_SUCCESS           - Open the file successfully.\r
-  other                 - An error occured when locating the OFile.\r
+  @retval EFI_INVALID_PARAMETER - The parameter is not valid.\r
+  @retval EFI_SUCCESS           - Open the file successfully.\r
+  @return other                 - An error occured when locating the OFile.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+FatLocateOFile (\r
+  IN OUT FAT_OFILE        **PtrOFile,\r
+  IN     CHAR16           *FileName,\r
+  IN     UINT8            Attributes,\r
+     OUT CHAR16           *NewFileName\r
+  )\r
 {\r
   EFI_STATUS  Status;\r
   FAT_VOLUME  *Volume;\r