-/*++\r
+/** @file\r
+ Routines dealing with disk spaces and FAT table entries.\r
\r
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
\r
-Module Name:\r
\r
- FileSpace.c\r
+**/\r
\r
-Abstract:\r
+#include "Fat.h"\r
\r
- Routines dealing with disk spaces and FAT table entries\r
\r
-Revision History\r
+/**\r
\r
---*/\r
+ Get the FAT entry of the volume, which is identified with the Index.\r
\r
-#include "Fat.h"\r
+ @param Volume - FAT file system volume.\r
+ @param Index - The index of the FAT entry of the volume.\r
\r
+ @return The buffer of the FAT entry\r
\r
+**/\r
STATIC\r
VOID *\r
FatLoadFatEntry (\r
IN FAT_VOLUME *Volume,\r
IN UINTN Index\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the FAT entry of the volume, which is identified with the Index.\r
-\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
- Index - The index of the FAT entry of the volume.\r
-\r
-Returns:\r
-\r
- The buffer of the FAT entry\r
-\r
---*/\r
{\r
UINTN Pos;\r
EFI_STATUS Status;\r
return &Volume->FatEntryBuffer;\r
}\r
\r
+/**\r
+\r
+ Get the FAT entry value of the volume, which is identified with the Index.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Index - The index of the FAT entry of the volume.\r
+\r
+ @return The value of the FAT entry.\r
+\r
+**/\r
STATIC\r
UINTN\r
FatGetFatEntry (\r
IN FAT_VOLUME *Volume,\r
IN UINTN Index\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the FAT entry value of the volume, which is identified with the Index.\r
-\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
- Index - The index of the FAT entry of the volume.\r
-\r
-Returns:\r
-\r
- The value of the FAT entry.\r
-\r
---*/\r
{\r
VOID *Pos;\r
UINT8 *En12;\r
return Accum;\r
}\r
\r
+/**\r
+\r
+ Set the FAT entry value of the volume, which is identified with the Index.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Index - The index of the FAT entry of the volume.\r
+ @param Value - The new value of the FAT entry.\r
+\r
+ @retval EFI_SUCCESS - Set the new FAT entry value sucessfully.\r
+ @retval EFI_VOLUME_CORRUPTED - The FAT type of the volume is error.\r
+ @return other - An error occurred when operation the FAT entries.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
FatSetFatEntry (\r
IN UINTN Index,\r
IN UINTN Value\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Set the FAT entry value of the volume, which is identified with the Index.\r
-\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
- Index - The index of the FAT entry of the volume.\r
- Value - The new value of the FAT entry.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - Set the new FAT entry value sucessfully.\r
- EFI_VOLUME_CORRUPTED - The FAT type of the volume is error.\r
- other - An error occurred when operation the FAT entries.\r
-\r
---*/\r
{\r
VOID *Pos;\r
UINT8 *En12;\r
return Status;\r
}\r
\r
+/**\r
+\r
+ Free the cluster clain.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Cluster - The first cluster of cluster chain.\r
+\r
+ @retval EFI_SUCCESS - The cluster chain is freed successfully.\r
+ @retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
FatFreeClusters (\r
IN FAT_VOLUME *Volume,\r
IN UINTN Cluster\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Free the cluster clain.\r
-\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
- Cluster - The first cluster of cluster chain.\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - The cluster chain is freed successfully.\r
- EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r
-\r
---*/\r
{\r
UINTN LastCluster;\r
\r
return EFI_SUCCESS;\r
}\r
\r
-STATIC\r
-UINTN\r
-FatAllocateCluster (\r
- IN FAT_VOLUME *Volume\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Allocate a free cluster and return the cluster index.\r
\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
+ @param Volume - FAT file system volume.\r
\r
-Returns:\r
+ @return The index of the free cluster\r
\r
- The index of the free cluster\r
-\r
---*/\r
+**/\r
+STATIC\r
+UINTN\r
+FatAllocateCluster (\r
+ IN FAT_VOLUME *Volume\r
+ )\r
{\r
UINTN Cluster;\r
\r
return Cluster;\r
}\r
\r
+/**\r
+\r
+ Count the number of clusters given a size.\r
+\r
+ @param Volume - The file system volume.\r
+ @param Size - The size in bytes.\r
+\r
+ @return The number of the clusters.\r
+\r
+**/\r
STATIC\r
UINTN\r
FatSizeToClusters (\r
IN FAT_VOLUME *Volume,\r
IN UINTN Size\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Count the number of clusters given a size\r
-\r
-Arguments:\r
-\r
- Volume - The file system volume.\r
- Size - The size in bytes.\r
-\r
-Returns:\r
-\r
- The number of the clusters.\r
-\r
---*/\r
{\r
UINTN Clusters;\r
\r
return Clusters;\r
}\r
\r
-EFI_STATUS\r
-FatShrinkEof (\r
- IN FAT_OFILE *OFile\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Shrink the end of the open file base on the file size.\r
\r
-Arguments:\r
-\r
- OFile - The open file.\r
+ @param OFile - The open file.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS - Shrinked sucessfully.\r
+ @retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r
\r
- EFI_SUCCESS - Shrinked sucessfully.\r
- EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatShrinkEof (\r
+ IN FAT_OFILE *OFile\r
+ )\r
{\r
FAT_VOLUME *Volume;\r
UINTN NewSize;\r
return FatFreeClusters (Volume, Cluster);\r
}\r
\r
-EFI_STATUS\r
-FatGrowEof (\r
- IN FAT_OFILE *OFile,\r
- IN UINT64 NewSizeInBytes\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Grow the end of the open file base on the NewSizeInBytes.\r
\r
-Arguments:\r
-\r
- OFile - The open file.\r
- NewSizeInBytes - The new size in bytes of the open file.\r
+ @param OFile - The open file.\r
+ @param NewSizeInBytes - The new size in bytes of the open file.\r
\r
-Returns:\r
+ @retval EFI_SUCCESS - The file is grown sucessfully.\r
+ @retval EFI_UNSUPPORTED - The file size is larger than 4GB.\r
+ @retval EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.\r
+ @retval EFI_VOLUME_FULL - The volume is full and can not grow the file.\r
\r
- EFI_SUCCESS - The file is grown sucessfully.\r
- EFI_UNSUPPORTED - The file size is larger than 4GB.\r
- EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.\r
- EFI_VOLUME_FULL - The volume is full and can not grow the file.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatGrowEof (\r
+ IN FAT_OFILE *OFile,\r
+ IN UINT64 NewSizeInBytes\r
+ )\r
{\r
FAT_VOLUME *Volume;\r
EFI_STATUS Status;\r
return Status;\r
}\r
\r
-EFI_STATUS\r
-FatOFilePosition (\r
- IN FAT_OFILE *OFile,\r
- IN UINTN Position,\r
- IN UINTN PosLimit\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Seek OFile to requested position, and calculate the number of\r
consecutive clusters from the position in the file\r
\r
-Arguments:\r
-\r
- OFile - The open file.\r
- Position - The file's position which will be accessed.\r
- PosLimit - The maximum length current reading/writing may access\r
+ @param OFile - The open file.\r
+ @param Position - The file's position which will be accessed.\r
+ @param PosLimit - The maximum length current reading/writing may access\r
\r
-Returns:\r
+ @retval EFI_SUCCESS - Set the info successfully.\r
+ @retval EFI_VOLUME_CORRUPTED - Cluster chain corrupt.\r
\r
- EFI_SUCCESS - Set the info successfully.\r
- EFI_VOLUME_CORRUPTED - Cluster chain corrupt.\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatOFilePosition (\r
+ IN FAT_OFILE *OFile,\r
+ IN UINTN Position,\r
+ IN UINTN PosLimit\r
+ )\r
{\r
FAT_VOLUME *Volume;\r
UINTN ClusterSize;\r
return EFI_SUCCESS;\r
}\r
\r
-UINTN\r
-FatPhysicalDirSize (\r
- IN FAT_VOLUME *Volume,\r
- IN UINTN Cluster\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the size of directory of the open file\r
+/**\r
\r
-Arguments:\r
+ Get the size of directory of the open file.\r
\r
- Volume - The File System Volume.\r
- Cluster - The Starting cluster.\r
+ @param Volume - The File System Volume.\r
+ @param Cluster - The Starting cluster.\r
\r
-Returns:\r
-\r
- The physical size of the file starting at the input cluster, if there is error in the\r
+ @return The physical size of the file starting at the input cluster, if there is error in the\r
cluster chain, the return value is 0.\r
\r
---*/\r
+**/\r
+UINTN\r
+FatPhysicalDirSize (\r
+ IN FAT_VOLUME *Volume,\r
+ IN UINTN Cluster\r
+ )\r
{\r
UINTN Size;\r
ASSERT_VOLUME_LOCKED (Volume);\r
return Size;\r
}\r
\r
+/**\r
+\r
+ Get the physical size of a file on the disk.\r
+\r
+ @param Volume - The file system volume.\r
+ @param RealSize - The real size of a file.\r
+\r
+ @return The physical size of a file on the disk.\r
+\r
+**/\r
UINT64\r
FatPhysicalFileSize (\r
IN FAT_VOLUME *Volume,\r
IN UINTN RealSize\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Get the physical size of a file on the disk.\r
-\r
-Arguments:\r
-\r
- Volume - The file system volume.\r
- RealSize - The real size of a file.\r
-\r
-Returns:\r
-\r
- The physical size of a file on the disk.\r
-\r
---*/\r
{\r
UINTN ClusterSizeMask;\r
UINT64 PhysicalSize;\r
return PhysicalSize;\r
}\r
\r
-VOID\r
-FatComputeFreeInfo (\r
- IN FAT_VOLUME *Volume\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
\r
Update the free cluster info of FatInfoSector of the volume.\r
\r
-Arguments:\r
-\r
- Volume - FAT file system volume.\r
-\r
-Returns:\r
-\r
- None.\r
+ @param Volume - FAT file system volume.\r
\r
---*/\r
+**/\r
+VOID\r
+FatComputeFreeInfo (\r
+ IN FAT_VOLUME *Volume\r
+ )\r
{\r
UINTN Index;\r
\r