TianoCore EDK2 master
Loading...
Searching...
No Matches
Fat.h File Reference

Go to the source code of this file.

Data Structures

struct  CACHE_TAG
 
struct  DISK_CACHE
 
struct  _FAT_DIRENT
 
struct  _FAT_ODIR
 
struct  FAT_IFILE
 
struct  FAT_TASK
 
struct  FAT_SUBTASK
 
struct  _FAT_OFILE
 
struct  _FAT_VOLUME
 

Macros

#define FAT_VOLUME_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'v')
 
#define FAT_IFILE_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'i')
 
#define FAT_ODIR_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'd')
 
#define FAT_DIRENT_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'e')
 
#define FAT_OFILE_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'o')
 
#define FAT_TASK_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'T')
 
#define FAT_SUBTASK_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'S')
 
#define ASSERT_VOLUME_LOCKED(a)   ASSERT_LOCKED (&FatFsLock)
 
#define IFILE_FROM_FHAND(a)   CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)
 
#define DIRENT_FROM_LINK(a)   CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)
 
#define VOLUME_FROM_ROOT_DIRENT(a)   CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)
 
#define VOLUME_FROM_VOL_INTERFACE(a)   CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);
 
#define ODIR_FROM_DIRCACHELINK(a)   CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)
 
#define OFILE_FROM_CHECKLINK(a)   CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)
 
#define OFILE_FROM_CHILDLINK(a)   CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)
 
#define MAX_BLOCK_ALIGNMENT   12
 
#define MIN_BLOCK_ALIGNMENT   9
 
#define MAX_SECTORS_PER_CLUSTER_ALIGNMENT   7
 
#define IS_LEAP_YEAR(a)   (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))
 
#define FAT_FATCACHE_PAGE_MIN_ALIGNMENT   13
 
#define FAT_FATCACHE_PAGE_MAX_ALIGNMENT   15
 
#define FAT_DATACACHE_PAGE_MIN_ALIGNMENT   13
 
#define FAT_DATACACHE_PAGE_MAX_ALIGNMENT   16
 
#define FAT_DATACACHE_GROUP_COUNT   64
 
#define FAT_FATCACHE_GROUP_MIN_COUNT   1
 
#define FAT_FATCACHE_GROUP_MAX_COUNT   16
 
#define BITS_PER_BYTE   8
 
#define DIRTY_BITS_PER_BLOCK   ((sizeof (DIRTY_BLOCKS) * BITS_PER_BYTE))
 
#define DIRTY_BITS   ((1 << FAT_DATACACHE_PAGE_MAX_ALIGNMENT) / (1 << MIN_BLOCK_ALIGNMENT))
 
#define DIRTY_BLOCKS_SIZE   (DIRTY_BITS / sizeof (DIRTY_BLOCKS))
 
#define MAX_SPEC_RETRY   4
 
#define SPEC_BASE_TAG_LEN   6
 
#define HASH_BASE_TAG_LEN   2
 
#define HASH_VALUE_TAG_LEN   (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)
 
#define PATH_NAME_SEPARATOR   L'\\'
 
#define EFI_PATH_STRING_LENGTH   260
 
#define EFI_FILE_STRING_LENGTH   255
 
#define FAT_MAX_ALLOCATE_SIZE   0xA00000
 
#define LC_ISO_639_2_ENTRY_SIZE   3
 
#define MAX_LANG_CODE_SIZE   100
 
#define FAT_MAX_DIR_CACHE_COUNT   8
 
#define FAT_MAX_DIRENTRY_COUNT   0xFFFF
 
#define CACHE_ENABLED(a)   ((a) >= 2)
 
#define RAW_ACCESS(a)   ((IO_MODE)((a) & 0x1))
 
#define CACHE_TYPE(a)   ((CACHE_DATA_TYPE)((a) >> 2))
 
#define HASH_TABLE_SIZE   0x400
 
#define HASH_TABLE_MASK   (HASH_TABLE_SIZE - 1)
 

Typedefs

typedef UINT64 DIRTY_BLOCKS
 
typedef CHAR8 LC_ISO_639_2
 
typedef struct _FAT_DIRENT FAT_DIRENT
 
typedef struct _FAT_ODIR FAT_ODIR
 
typedef struct _FAT_OFILE FAT_OFILE
 
typedef struct _FAT_VOLUME FAT_VOLUME
 

Enumerations

enum  FAT_VOLUME_TYPE { Fat12 , Fat16 , Fat32 , FatUndefined }
 
enum  CACHE_DATA_TYPE { CacheFat , CacheData , CacheMaxType }
 
enum  IO_MODE {
  ReadDisk = 0 , WriteDisk = 1 , ReadFat = 2 , WriteFat = 3 ,
  ReadData = 6 , WriteData = 7
}
 

Functions

 STATIC_ASSERT ((((1<< FAT_DATACACHE_PAGE_MAX_ALIGNMENT)/(1<< MIN_BLOCK_ALIGNMENT)) % sizeof(DIRTY_BLOCKS))==0, "DIRTY_BLOCKS not a proper size")
 
EFI_STATUS EFIAPI FatOpen (IN EFI_FILE_PROTOCOL *FHand, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
 
EFI_STATUS EFIAPI FatOpenEx (IN EFI_FILE_PROTOCOL *FHand, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes, IN OUT EFI_FILE_IO_TOKEN *Token)
 
EFI_STATUS EFIAPI FatGetPosition (IN EFI_FILE_PROTOCOL *FHand, OUT UINT64 *Position)
 
EFI_STATUS EFIAPI FatGetInfo (IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI FatSetInfo (IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN UINTN BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI FatFlush (IN EFI_FILE_PROTOCOL *FHand)
 
EFI_STATUS EFIAPI FatFlushEx (IN EFI_FILE_PROTOCOL *FHand, IN EFI_FILE_IO_TOKEN *Token)
 
EFI_STATUS EFIAPI FatClose (IN EFI_FILE_PROTOCOL *FHand)
 
EFI_STATUS EFIAPI FatDelete (IN EFI_FILE_PROTOCOL *FHand)
 
EFI_STATUS EFIAPI FatSetPosition (IN EFI_FILE_PROTOCOL *FHand, IN UINT64 Position)
 
EFI_STATUS EFIAPI FatRead (IN EFI_FILE_PROTOCOL *FHand, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS EFIAPI FatReadEx (IN EFI_FILE_PROTOCOL *FHand, IN OUT EFI_FILE_IO_TOKEN *Token)
 
EFI_STATUS EFIAPI FatWrite (IN EFI_FILE_PROTOCOL *FHand, IN OUT UINTN *BufferSize, IN VOID *Buffer)
 
EFI_STATUS EFIAPI FatWriteEx (IN EFI_FILE_PROTOCOL *FHand, IN OUT EFI_FILE_IO_TOKEN *Token)
 
EFI_STATUS FatInitializeDiskCache (IN FAT_VOLUME *Volume)
 
EFI_STATUS FatAccessCache (IN FAT_VOLUME *Volume, IN CACHE_DATA_TYPE CacheDataType, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT UINT8 *Buffer, IN FAT_TASK *Task)
 
EFI_STATUS FatVolumeFlushCache (IN FAT_VOLUME *Volume, IN FAT_TASK *Task)
 
EFI_STATUS FatOFileFlush (IN FAT_OFILE *OFile)
 
BOOLEAN FatCheckOFileRef (IN FAT_OFILE *OFile)
 
VOID FatSetVolumeError (IN FAT_OFILE *OFile, IN EFI_STATUS Status)
 
EFI_STATUS FatIFileClose (FAT_IFILE *IFile)
 
EFI_STATUS FatCleanupVolume (IN FAT_VOLUME *Volume, IN FAT_OFILE *OFile, IN EFI_STATUS EfiStatus, IN FAT_TASK *Task)
 
EFI_STATUS FatShrinkEof (IN FAT_OFILE *OFile)
 
EFI_STATUS FatGrowEof (IN FAT_OFILE *OFile, IN UINT64 NewSizeInBytes)
 
UINTN FatPhysicalDirSize (IN FAT_VOLUME *Volume, IN UINTN Cluster)
 
UINT64 FatPhysicalFileSize (IN FAT_VOLUME *Volume, IN UINTN RealSize)
 
EFI_STATUS FatOFilePosition (IN FAT_OFILE *OFile, IN UINTN Position, IN UINTN PosLimit)
 
VOID FatComputeFreeInfo (IN FAT_VOLUME *Volume)
 
EFI_STATUS FatAllocateVolume (IN EFI_HANDLE Handle, IN EFI_DISK_IO_PROTOCOL *DiskIo, IN EFI_DISK_IO2_PROTOCOL *DiskIo2, IN EFI_BLOCK_IO_PROTOCOL *BlockIo)
 
EFI_STATUS FatOpenDevice (IN OUT FAT_VOLUME *Volume)
 
EFI_STATUS FatAbandonVolume (IN FAT_VOLUME *Volume)
 
FAT_TASKFatCreateTask (FAT_IFILE *IFile, EFI_FILE_IO_TOKEN *Token)
 
VOID FatDestroyTask (FAT_TASK *Task)
 
VOID FatWaitNonblockingTask (FAT_IFILE *IFile)
 
LIST_ENTRYFatDestroySubtask (FAT_SUBTASK *Subtask)
 
EFI_STATUS FatQueueTask (IN FAT_IFILE *IFile, IN FAT_TASK *Task)
 
EFI_STATUS FatAccessVolumeDirty (IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN VOID *DirtyValue)
 
EFI_STATUS FatDiskIo (IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN UINT64 Offset, IN UINTN BufferSize, IN OUT VOID *Buffer, IN FAT_TASK *Task)
 
VOID FatAcquireLock (VOID)
 
VOID FatReleaseLock (VOID)
 
EFI_STATUS FatAcquireLockOrFail (VOID)
 
VOID FatFreeDirEnt (IN FAT_DIRENT *DirEnt)
 
VOID FatFreeVolume (IN FAT_VOLUME *Volume)
 
VOID FatEfiTimeToFatTime (IN EFI_TIME *ETime, OUT FAT_DATE_TIME *FTime)
 
VOID FatFatTimeToEfiTime (IN FAT_DATE_TIME *FTime, OUT EFI_TIME *ETime)
 
VOID FatGetCurrentFatTime (OUT FAT_DATE_TIME *FatTime)
 
BOOLEAN FatIsValidTime (IN EFI_TIME *Time)
 
EFI_STATUS InitializeUnicodeCollationSupport (IN EFI_HANDLE AgentHandle)
 
VOID FatFatToStr (IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *String)
 
BOOLEAN FatStrToFat (IN CHAR16 *String, IN UINTN FatSize, OUT CHAR8 *Fat)
 
VOID FatStrLwr (IN CHAR16 *Str)
 
VOID FatStrUpr (IN CHAR16 *Str)
 
INTN FatStriCmp (IN CHAR16 *Str1, IN CHAR16 *Str2)
 
EFI_STATUS FatOFileOpen (IN FAT_OFILE *OFile, OUT FAT_IFILE **NewIFile, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT8 Attributes)
 
EFI_STATUS FatAllocateIFile (IN FAT_OFILE *OFile, OUT FAT_IFILE **PtrIFile)
 
EFI_STATUS EFIAPI FatOpenVolume (IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **File)
 
EFI_STATUS FatAccessOFile (IN FAT_OFILE *OFile, IN IO_MODE IoMode, IN UINTN Position, IN UINTN *DataBufferSize, IN UINT8 *UserBuffer, IN FAT_TASK *Task)
 
EFI_STATUS FatExpandOFile (IN FAT_OFILE *OFile, IN UINT64 ExpandedSize)
 
EFI_STATUS FatWriteZeroPool (IN FAT_OFILE *OFile, IN UINTN WritePos)
 
EFI_STATUS FatTruncateOFile (IN FAT_OFILE *OFile, IN UINTN TruncatedSize)
 
VOID FatResetODirCursor (IN FAT_OFILE *OFile)
 
EFI_STATUS FatGetNextDirEnt (IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
 
EFI_STATUS FatRemoveDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatStoreDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatCreateDirEnt (IN FAT_OFILE *OFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT FAT_DIRENT **PtrDirEnt)
 
BOOLEAN FatIsDotDirEnt (IN FAT_DIRENT *DirEnt)
 
VOID FatUpdateDirEntClusterSizeInfo (IN FAT_OFILE *OFile)
 
VOID FatCloneDirEnt (IN FAT_DIRENT *DirEnt1, IN FAT_DIRENT *DirEnt2)
 
EFI_STATUS FatGetDirEntInfo (IN FAT_VOLUME *Volume, IN FAT_DIRENT *DirEnt, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
EFI_STATUS FatOpenDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatCreateDotDirEnts (IN FAT_OFILE *OFile)
 
VOID FatCloseDirEnt (IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatLocateOFile (IN OUT FAT_OFILE **PtrOFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT CHAR16 *NewFileName)
 
EFI_STATUS FatGetVolumeEntry (IN FAT_VOLUME *Volume, IN CHAR16 *Name)
 
EFI_STATUS FatSetVolumeEntry (IN FAT_VOLUME *Volume, IN CHAR16 *Name)
 
FAT_DIRENT ** FatLongNameHashSearch (IN FAT_ODIR *ODir, IN CHAR16 *LongNameString)
 
FAT_DIRENT ** FatShortNameHashSearch (IN FAT_ODIR *ODir, IN CHAR8 *ShortNameString)
 
VOID FatInsertToHashTable (IN FAT_ODIR *ODir, IN FAT_DIRENT *DirEnt)
 
VOID FatDeleteFromHashTable (IN FAT_ODIR *ODir, IN FAT_DIRENT *DirEnt)
 
BOOLEAN FatCheckIs8Dot3Name (IN CHAR16 *FileName, OUT CHAR8 *File8Dot3Name)
 
VOID FatCreate8Dot3Name (IN FAT_OFILE *Parent, IN FAT_DIRENT *DirEnt)
 
VOID FatNameToStr (IN CHAR8 *FatName, IN UINTN Len, IN UINTN LowerCase, IN CHAR16 *Str)
 
VOID FatSetCaseFlag (IN FAT_DIRENT *DirEnt)
 
VOID FatGetFileNameViaCaseFlag (IN FAT_DIRENT *DirEnt, IN OUT CHAR16 *FileString, IN UINTN FileStringMax)
 
UINT8 FatCheckSum (IN CHAR8 *ShortNameString)
 
CHAR16 * FatGetNextNameComponent (IN CHAR16 *Path, OUT CHAR16 *Name)
 
BOOLEAN FatFileNameIsValid (IN CHAR16 *InputFileName, OUT CHAR16 *OutputFileName)
 
VOID FatDiscardODir (IN FAT_OFILE *OFile)
 
VOID FatRequestODir (IN FAT_OFILE *OFile)
 
VOID FatCleanupODirCache (IN FAT_VOLUME *Volume)
 

Variables

EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding
 
EFI_COMPONENT_NAME_PROTOCOL gFatComponentName
 
EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2
 
EFI_LOCK FatFsLock
 
EFI_LOCK FatTaskLock
 
EFI_FILE_PROTOCOL FatFileInterface
 

Detailed Description

Main header file for EFI FAT file system driver.

Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Fat.h.

Macro Definition Documentation

◆ ASSERT_VOLUME_LOCKED

#define ASSERT_VOLUME_LOCKED (   a)    ASSERT_LOCKED (&FatFsLock)

Definition at line 46 of file Fat.h.

◆ BITS_PER_BYTE

#define BITS_PER_BYTE   8

Definition at line 89 of file Fat.h.

◆ CACHE_ENABLED

#define CACHE_ENABLED (   a)    ((a) >= 2)

Definition at line 151 of file Fat.h.

◆ CACHE_TYPE

#define CACHE_TYPE (   a)    ((CACHE_DATA_TYPE)((a) >> 2))

Definition at line 153 of file Fat.h.

◆ DIRENT_FROM_LINK

#define DIRENT_FROM_LINK (   a)    CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)

Definition at line 50 of file Fat.h.

◆ DIRTY_BITS

#define DIRTY_BITS   ((1 << FAT_DATACACHE_PAGE_MAX_ALIGNMENT) / (1 << MIN_BLOCK_ALIGNMENT))

Definition at line 93 of file Fat.h.

◆ DIRTY_BITS_PER_BLOCK

#define DIRTY_BITS_PER_BLOCK   ((sizeof (DIRTY_BLOCKS) * BITS_PER_BYTE))

Definition at line 90 of file Fat.h.

◆ DIRTY_BLOCKS_SIZE

#define DIRTY_BLOCKS_SIZE   (DIRTY_BITS / sizeof (DIRTY_BLOCKS))

Definition at line 96 of file Fat.h.

◆ EFI_FILE_STRING_LENGTH

#define EFI_FILE_STRING_LENGTH   255

Definition at line 114 of file Fat.h.

◆ EFI_PATH_STRING_LENGTH

#define EFI_PATH_STRING_LENGTH   260

Definition at line 113 of file Fat.h.

◆ FAT_DATACACHE_GROUP_COUNT

#define FAT_DATACACHE_GROUP_COUNT   64

Definition at line 83 of file Fat.h.

◆ FAT_DATACACHE_PAGE_MAX_ALIGNMENT

#define FAT_DATACACHE_PAGE_MAX_ALIGNMENT   16

Definition at line 82 of file Fat.h.

◆ FAT_DATACACHE_PAGE_MIN_ALIGNMENT

#define FAT_DATACACHE_PAGE_MIN_ALIGNMENT   13

Definition at line 81 of file Fat.h.

◆ FAT_DIRENT_SIGNATURE

#define FAT_DIRENT_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'e')

Definition at line 41 of file Fat.h.

◆ FAT_FATCACHE_GROUP_MAX_COUNT

#define FAT_FATCACHE_GROUP_MAX_COUNT   16

Definition at line 85 of file Fat.h.

◆ FAT_FATCACHE_GROUP_MIN_COUNT

#define FAT_FATCACHE_GROUP_MIN_COUNT   1

Definition at line 84 of file Fat.h.

◆ FAT_FATCACHE_PAGE_MAX_ALIGNMENT

#define FAT_FATCACHE_PAGE_MAX_ALIGNMENT   15

Definition at line 80 of file Fat.h.

◆ FAT_FATCACHE_PAGE_MIN_ALIGNMENT

#define FAT_FATCACHE_PAGE_MIN_ALIGNMENT   13

Definition at line 79 of file Fat.h.

◆ FAT_IFILE_SIGNATURE

#define FAT_IFILE_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'i')

Definition at line 39 of file Fat.h.

◆ FAT_MAX_ALLOCATE_SIZE

#define FAT_MAX_ALLOCATE_SIZE   0xA00000

Definition at line 115 of file Fat.h.

◆ FAT_MAX_DIR_CACHE_COUNT

#define FAT_MAX_DIR_CACHE_COUNT   8

Definition at line 119 of file Fat.h.

◆ FAT_MAX_DIRENTRY_COUNT

#define FAT_MAX_DIRENTRY_COUNT   0xFFFF

Definition at line 120 of file Fat.h.

◆ FAT_ODIR_SIGNATURE

#define FAT_ODIR_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'd')

Definition at line 40 of file Fat.h.

◆ FAT_OFILE_SIGNATURE

#define FAT_OFILE_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'o')

Definition at line 42 of file Fat.h.

◆ FAT_SUBTASK_SIGNATURE

#define FAT_SUBTASK_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'S')

Definition at line 44 of file Fat.h.

◆ FAT_TASK_SIGNATURE

#define FAT_TASK_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'T')

Definition at line 43 of file Fat.h.

◆ FAT_VOLUME_SIGNATURE

#define FAT_VOLUME_SIGNATURE   SIGNATURE_32 ('f', 'a', 't', 'v')

Definition at line 38 of file Fat.h.

◆ HASH_BASE_TAG_LEN

#define HASH_BASE_TAG_LEN   2

Definition at line 105 of file Fat.h.

◆ HASH_TABLE_MASK

#define HASH_TABLE_MASK   (HASH_TABLE_SIZE - 1)

Definition at line 180 of file Fat.h.

◆ HASH_TABLE_SIZE

#define HASH_TABLE_SIZE   0x400

Definition at line 179 of file Fat.h.

◆ HASH_VALUE_TAG_LEN

#define HASH_VALUE_TAG_LEN   (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)

Definition at line 106 of file Fat.h.

◆ IFILE_FROM_FHAND

#define IFILE_FROM_FHAND (   a)    CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)

Definition at line 48 of file Fat.h.

◆ IS_LEAP_YEAR

#define IS_LEAP_YEAR (   a)    (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))

Definition at line 73 of file Fat.h.

◆ LC_ISO_639_2_ENTRY_SIZE

#define LC_ISO_639_2_ENTRY_SIZE   3

Definition at line 116 of file Fat.h.

◆ MAX_BLOCK_ALIGNMENT

#define MAX_BLOCK_ALIGNMENT   12

Definition at line 66 of file Fat.h.

◆ MAX_LANG_CODE_SIZE

#define MAX_LANG_CODE_SIZE   100

Definition at line 117 of file Fat.h.

◆ MAX_SECTORS_PER_CLUSTER_ALIGNMENT

#define MAX_SECTORS_PER_CLUSTER_ALIGNMENT   7

Definition at line 68 of file Fat.h.

◆ MAX_SPEC_RETRY

#define MAX_SPEC_RETRY   4

Definition at line 103 of file Fat.h.

◆ MIN_BLOCK_ALIGNMENT

#define MIN_BLOCK_ALIGNMENT   9

Definition at line 67 of file Fat.h.

◆ ODIR_FROM_DIRCACHELINK

#define ODIR_FROM_DIRCACHELINK (   a)    CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)

Definition at line 56 of file Fat.h.

◆ OFILE_FROM_CHECKLINK

#define OFILE_FROM_CHECKLINK (   a)    CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)

Definition at line 58 of file Fat.h.

◆ OFILE_FROM_CHILDLINK

#define OFILE_FROM_CHILDLINK (   a)    CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)

Definition at line 60 of file Fat.h.

◆ PATH_NAME_SEPARATOR

#define PATH_NAME_SEPARATOR   L'\\'

Definition at line 111 of file Fat.h.

◆ RAW_ACCESS

#define RAW_ACCESS (   a)    ((IO_MODE)((a) & 0x1))

Definition at line 152 of file Fat.h.

◆ SPEC_BASE_TAG_LEN

#define SPEC_BASE_TAG_LEN   6

Definition at line 104 of file Fat.h.

◆ VOLUME_FROM_ROOT_DIRENT

#define VOLUME_FROM_ROOT_DIRENT (   a)    CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)

Definition at line 52 of file Fat.h.

◆ VOLUME_FROM_VOL_INTERFACE

#define VOLUME_FROM_VOL_INTERFACE (   a)    CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);

Definition at line 54 of file Fat.h.

Typedef Documentation

◆ DIRTY_BLOCKS

typedef UINT64 DIRTY_BLOCKS

Definition at line 88 of file Fat.h.

◆ FAT_DIRENT

typedef struct _FAT_DIRENT FAT_DIRENT

Definition at line 186 of file Fat.h.

◆ FAT_ODIR

typedef struct _FAT_ODIR FAT_ODIR

Definition at line 187 of file Fat.h.

◆ FAT_OFILE

typedef struct _FAT_OFILE FAT_OFILE

Definition at line 188 of file Fat.h.

◆ FAT_VOLUME

typedef struct _FAT_VOLUME FAT_VOLUME

Definition at line 189 of file Fat.h.

◆ LC_ISO_639_2

typedef CHAR8 LC_ISO_639_2

Definition at line 121 of file Fat.h.

Enumeration Type Documentation

◆ CACHE_DATA_TYPE

enum CACHE_DATA_TYPE

Definition at line 133 of file Fat.h.

◆ FAT_VOLUME_TYPE

enum FAT_VOLUME_TYPE

Definition at line 126 of file Fat.h.

◆ IO_MODE

enum IO_MODE

Definition at line 142 of file Fat.h.

Function Documentation

◆ FatAbandonVolume()

EFI_STATUS FatAbandonVolume ( IN FAT_VOLUME Volume)

Called by FatDriverBindingStop(), Abandon the volume.

Parameters
Volume- The volume to be abandoned.
Return values
EFI_SUCCESS- Abandoned the volume successfully.
Returns
Others - Can not uninstall the protocol interfaces.

Definition at line 144 of file Init.c.

◆ FatAccessCache()

EFI_STATUS FatAccessCache ( IN FAT_VOLUME Volume,
IN CACHE_DATA_TYPE  CacheDataType,
IN IO_MODE  IoMode,
IN UINT64  Offset,
IN UINTN  BufferSize,
IN OUT UINT8 *  Buffer,
IN FAT_TASK Task 
)

Read BufferSize bytes from the position of Offset into Buffer, or write BufferSize bytes from Buffer into the position of Offset.

Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):

  1. Access of FAT cache (CACHE_FAT): Access the data in the FAT cache, if there is cache page hit, just return the cache page; else update the related cache page and return the right cache page.
  2. Access of Data cache (CACHE_DATA): The access data will be divided into UnderRun data, Aligned data and OverRun data; The UnderRun data and OverRun data will be accessed by the Data cache, but the Aligned data will be accessed with disk directly.
Parameters
Volume- FAT file system volume.
CacheDataType- The type of cache: CACHE_DATA or CACHE_FAT.
IoMode- Indicate the type of disk access.
Offset- The starting byte offset to read from.
BufferSize- Size of Buffer.
Buffer- Buffer containing cache data.
Taskpoint to task instance.
Return values
EFI_SUCCESS- The data was accessed correctly.
EFI_MEDIA_CHANGED- The MediaId does not match the current device.
Returns
Others - An error occurred when accessing cache.

Definition at line 493 of file DiskCache.c.

◆ FatAccessOFile()

EFI_STATUS FatAccessOFile ( IN FAT_OFILE OFile,
IN IO_MODE  IoMode,
IN UINTN  Position,
IN UINTN DataBufferSize,
IN UINT8 *  UserBuffer,
IN FAT_TASK Task 
)

This function reads data from a file or writes data to a file. It uses OFile->PosRem to determine how much data can be accessed in one time.

Parameters
OFile- The open file.
IoMode- Indicate whether the access mode is reading or writing.
Position- The position where data will be accessed.
DataBufferSize- Size of Buffer.
UserBuffer- Buffer containing data.
Taskpoint to task instance.
Return values
EFI_SUCCESS- Access the data successfully.
Returns
other - An error occurred when operating on the disk.

◆ FatAccessVolumeDirty()

EFI_STATUS FatAccessVolumeDirty ( IN FAT_VOLUME Volume,
IN IO_MODE  IoMode,
IN VOID *  DirtyValue 
)

Set the volume as dirty or not.

Parameters
Volume- FAT file system volume.
IoMode- The access mode.
DirtyValue- Set the volume as dirty or not.
Return values
EFI_SUCCESS- Set the new FAT entry value successfully.
Returns
other - An error occurred when operation the FAT entries.

Definition at line 230 of file Misc.c.

◆ FatAcquireLock()

VOID FatAcquireLock ( VOID  )

Lock the volume.

Definition at line 395 of file Misc.c.

◆ FatAcquireLockOrFail()

EFI_STATUS FatAcquireLockOrFail ( VOID  )

Lock the volume. If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned. Otherwise, EFI_SUCCESS is returned.

Return values
EFI_SUCCESS- The volume is locked.
EFI_ACCESS_DENIED- The volume could not be locked because it is already locked.

Definition at line 413 of file Misc.c.

◆ FatAllocateIFile()

EFI_STATUS FatAllocateIFile ( IN FAT_OFILE OFile,
OUT FAT_IFILE **  PtrIFile 
)

Create an Open instance for the existing OFile. The IFile of the newly opened file is passed out.

Parameters
OFile- The file that serves as a starting reference point.
PtrIFile- The newly generated IFile instance.
Return values
EFI_OUT_OF_RESOURCES- Can not allocate the memory for the IFile
EFI_SUCCESS- Create the new IFile for the OFile successfully

Definition at line 24 of file Open.c.

◆ FatAllocateVolume()

EFI_STATUS FatAllocateVolume ( IN EFI_HANDLE  Handle,
IN EFI_DISK_IO_PROTOCOL DiskIo,
IN EFI_DISK_IO2_PROTOCOL DiskIo2,
IN EFI_BLOCK_IO_PROTOCOL BlockIo 
)

Allocates volume structure, detects FAT file system, installs protocol, and initialize cache.

Parameters
Handle- The handle of parent device.
DiskIo- The DiskIo of parent device.
DiskIo2- The DiskIo2 of parent device.
BlockIo- The BlockIo of parent device.
Return values
EFI_SUCCESS- Allocate a new volume successfully.
EFI_OUT_OF_RESOURCES- Can not allocate the memory.
Returns
Others - Allocating a new volume failed.

Definition at line 27 of file Init.c.

◆ FatCheckIs8Dot3Name()

BOOLEAN FatCheckIs8Dot3Name ( IN CHAR16 *  FileName,
OUT CHAR8 *  File8Dot3Name 
)

This function checks whether the input FileName is a valid 8.3 short name. If the input FileName is a valid 8.3, the output is the 8.3 short name; otherwise, the output is the base tag of 8.3 short name.

Parameters
FileName- The input unicode filename.
File8Dot3Name- The output ascii 8.3 short name or base tag of 8.3 short name.
Return values
TRUE- The input unicode filename is a valid 8.3 short name.
FALSE- The input unicode filename is not a valid 8.3 short name.

Definition at line 25 of file FileName.c.

◆ FatCheckOFileRef()

BOOLEAN FatCheckOFileRef ( IN FAT_OFILE OFile)

Check the references of the OFile. If the OFile (that is checked) is no longer referenced, then it is freed.

Parameters
OFile- The OFile to be checked.
Return values
TRUE- The OFile is not referenced and freed.
FALSE- The OFile is kept.

Definition at line 295 of file Flush.c.

◆ FatCheckSum()

UINT8 FatCheckSum ( IN CHAR8 *  ShortNameString)

Get the Check sum for a short name.

Parameters
ShortNameString- The short name for a file.
Return values
Sum- UINT8 checksum.

Definition at line 382 of file FileName.c.

◆ FatCleanupODirCache()

VOID FatCleanupODirCache ( IN FAT_VOLUME Volume)

Clean up all the cached directory structures when the volume is going to be abandoned.

Parameters
Volume- FAT file system volume.

Definition at line 175 of file DirectoryCache.c.

◆ FatCleanupVolume()

EFI_STATUS FatCleanupVolume ( IN FAT_VOLUME Volume,
IN FAT_OFILE OFile,
IN EFI_STATUS  EfiStatus,
IN FAT_TASK Task 
)

Set error status for a specific OFile, reference checking the volume. If volume is already marked as invalid, and all resources are freed after reference checking, the file system protocol is uninstalled and the volume structure is freed.

Parameters
Volume- the Volume that is to be reference checked and unlocked.
OFile- the OFile whose permanent error code is to be set.
EfiStatus- error code to be set.
Taskpoint to task instance.
Return values
EFI_SUCCESS- Clean up the volume successfully.
Returns
Others - Cleaning up of the volume is failed.

Definition at line 382 of file Flush.c.

◆ FatCloneDirEnt()

VOID FatCloneDirEnt ( IN FAT_DIRENT DirEnt1,
IN FAT_DIRENT DirEnt2 
)

Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.

Parameters
DirEnt1- The destination directory entry.
DirEnt2- The source directory entry.

Definition at line 205 of file DirectoryManage.c.

◆ FatClose()

EFI_STATUS EFIAPI FatClose ( IN EFI_FILE_PROTOCOL FHand)

Flushes & Closes the file handle.

Parameters
FHand- Handle to the file to delete.
Return values
EFI_SUCCESS- Closed the file successfully.

Definition at line 129 of file Flush.c.

◆ FatCloseDirEnt()

VOID FatCloseDirEnt ( IN FAT_DIRENT DirEnt)

Close the directory entry and free the OFile.

Parameters
DirEnt- The directory entry to be closed.

Definition at line 1216 of file DirectoryManage.c.

◆ FatComputeFreeInfo()

VOID FatComputeFreeInfo ( IN FAT_VOLUME Volume)

Update the free cluster info of FatInfoSector of the volume.

Parameters
Volume- FAT file system volume.

Definition at line 720 of file FileSpace.c.

◆ FatCreate8Dot3Name()

VOID FatCreate8Dot3Name ( IN FAT_OFILE Parent,
IN FAT_DIRENT DirEnt 
)

This function generates 8Dot3 name from user specified name for a newly created file.

Parameters
Parent- The parent directory.
DirEnt- The directory entry whose 8Dot3Name needs to be generated.

Definition at line 169 of file FileName.c.

◆ FatCreateDirEnt()

EFI_STATUS FatCreateDirEnt ( IN FAT_OFILE OFile,
IN CHAR16 *  FileName,
IN UINT8  Attributes,
OUT FAT_DIRENT **  PtrDirEnt 
)

Create a directory entry in the parent OFile.

Parameters
OFile- The parent OFile.
FileName- The filename of the newly-created directory entry.
Attributes- The attribute of the newly-created directory entry.
PtrDirEnt- The pointer to the newly-created directory entry.
Return values
EFI_SUCCESS- The directory entry is successfully created.
EFI_OUT_OF_RESOURCES- Not enough memory to create the directory entry.
Returns
other - An error occurred when creating the directory entry.

Definition at line 1040 of file DirectoryManage.c.

◆ FatCreateDotDirEnts()

EFI_STATUS FatCreateDotDirEnts ( IN FAT_OFILE OFile)

Create "." and ".." directory entries in the newly-created parent OFile.

Parameters
OFile- The parent OFile.
Return values
EFI_SUCCESS- The dot directory entries are successfully created.
Returns
other - An error occurred when creating the directory entry.

Definition at line 997 of file DirectoryManage.c.

◆ FatCreateTask()

FAT_TASK * FatCreateTask ( FAT_IFILE IFile,
EFI_FILE_IO_TOKEN Token 
)

Create the task

Parameters
IFile- The instance of the open file.
Token- A pointer to the token associated with the transaction.
Returns
FAT_TASK * - Return the task instance.

Definition at line 24 of file Misc.c.

◆ FatDelete()

EFI_STATUS EFIAPI FatDelete ( IN EFI_FILE_PROTOCOL FHand)

Deletes the file & Closes the file handle.

Parameters
FHand- Handle to the file to delete.
Return values
EFI_SUCCESS- Delete the file successfully.
EFI_WARN_DELETE_FAILURE- Fail to delete the file.

Definition at line 24 of file Delete.c.

◆ FatDeleteFromHashTable()

VOID FatDeleteFromHashTable ( IN FAT_ODIR ODir,
IN FAT_DIRENT DirEnt 
)

Delete directory entry from hash table.

Parameters
ODir- The parent directory.
DirEnt- The directory entry node.

Definition at line 165 of file Hash.c.

◆ FatDestroySubtask()

LIST_ENTRY * FatDestroySubtask ( FAT_SUBTASK Subtask)

Remove the subtask from subtask list.

Parameters
Subtask- The subtask to be removed.
Returns
LIST_ENTRY * - The next node in the list.

Definition at line 98 of file Misc.c.

◆ FatDestroyTask()

VOID FatDestroyTask ( FAT_TASK Task)

Destroy the task.

Parameters
Task- The task to be destroyed.

Definition at line 51 of file Misc.c.

◆ FatDiscardODir()

VOID FatDiscardODir ( IN FAT_OFILE OFile)

Discard the directory structure when an OFile will be freed. Volume will cache this directory if the OFile does not represent a deleted file.

Parameters
OFile- The OFile whose directory structure is to be discarded.

Definition at line 80 of file DirectoryCache.c.

◆ FatDiskIo()

EFI_STATUS FatDiskIo ( IN FAT_VOLUME Volume,
IN IO_MODE  IoMode,
IN UINT64  Offset,
IN UINTN  BufferSize,
IN OUT VOID *  Buffer,
IN FAT_TASK Task 
)

General disk access function.

Parameters
Volume- FAT file system volume.
IoMode- The access mode (disk read/write or cache access).
Offset- The starting byte offset to read from.
BufferSize- Size of Buffer.
Buffer- Buffer containing read data.
Taskpoint to task instance.
Return values
EFI_SUCCESS- The operation is performed successfully.
EFI_VOLUME_CORRUPTED- The access is
Returns
Others - The status of read/write the disk

Definition at line 315 of file Misc.c.

◆ FatEfiTimeToFatTime()

VOID FatEfiTimeToFatTime ( IN EFI_TIME ETime,
OUT FAT_DATE_TIME FTime 
)

Translate EFI time to FAT time.

Parameters
ETime- The time of EFI_TIME.
FTime- The time of FAT_DATE_TIME.

Definition at line 487 of file Misc.c.

◆ FatExpandOFile()

EFI_STATUS FatExpandOFile ( IN FAT_OFILE OFile,
IN UINT64  ExpandedSize 
)

Expand OFile by appending zero bytes at the end of OFile.

Parameters
OFile- The open file.
ExpandedSize- The number of zero bytes appended at the end of the file.
Return values
EFI_SUCCESS- The file is expanded successfully.
Returns
other - An error occurred when expanding file.

Definition at line 537 of file ReadWrite.c.

◆ FatFatTimeToEfiTime()

VOID FatFatTimeToEfiTime ( IN FAT_DATE_TIME FTime,
OUT EFI_TIME ETime 
)

Translate Fat time to EFI time.

Parameters
FTime- The time of FAT_DATE_TIME.
ETime- The time of EFI_TIME..

Definition at line 519 of file Misc.c.

◆ FatFatToStr()

VOID FatFatToStr ( IN UINTN  FatSize,
IN CHAR8 *  Fat,
OUT CHAR16 *  String 
)

Convert FAT string to unicode string.

Parameters
FatSizeThe size of FAT string.
FatThe FAT string.
StringThe unicode string.
Returns
None.

Definition at line 227 of file UnicodeCollation.c.

◆ FatFileNameIsValid()

BOOLEAN FatFileNameIsValid ( IN CHAR16 *  InputFileName,
OUT CHAR16 *  OutputFileName 
)

Check whether the IFileName is valid long file name. If the IFileName is a valid long file name, then we trim the possible leading blanks and leading/trailing dots. the trimmed filename is stored in OutputFileName

Parameters
InputFileName- The input file name.
OutputFileName- The output file name.
Return values
TRUE- The InputFileName is a valid long file name.
FALSE- The InputFileName is not a valid long file name.

Definition at line 444 of file FileName.c.

◆ FatFlush()

EFI_STATUS EFIAPI FatFlush ( IN EFI_FILE_PROTOCOL FHand)

Flushes all data associated with the file handle.

Parameters
FHand- Handle to file to flush
Return values
EFI_SUCCESS- Flushed the file successfully
EFI_WRITE_PROTECTED- The volume is read only
EFI_ACCESS_DENIED- The volume is not read only but the file is read only
Returns
Others - Flushing of the file is failed

Flushes all data associated with the file handle.

Parameters
FHand- Handle to file to flush.
Return values
EFI_SUCCESS- Flushed the file successfully.
EFI_WRITE_PROTECTED- The volume is read only.
EFI_ACCESS_DENIED- The file is read only.
Returns
Others - Flushing of the file failed.

Definition at line 111 of file Flush.c.

◆ FatFlushEx()

EFI_STATUS EFIAPI FatFlushEx ( IN EFI_FILE_PROTOCOL FHand,
IN EFI_FILE_IO_TOKEN Token 
)

Flushes all data associated with the file handle.

Parameters
FHand- Handle to file to flush.
Token- A pointer to the token associated with the transaction.
Return values
EFI_SUCCESS- Flushed the file successfully.
EFI_WRITE_PROTECTED- The volume is read only.
EFI_ACCESS_DENIED- The file is read only.
Returns
Others - Flushing of the file failed.

Definition at line 27 of file Flush.c.

◆ FatFreeDirEnt()

VOID FatFreeDirEnt ( IN FAT_DIRENT DirEnt)

Free directory entry.

Parameters
DirEnt- The directory entry to be freed.

Definition at line 441 of file Misc.c.

◆ FatFreeVolume()

VOID FatFreeVolume ( IN FAT_VOLUME Volume)

Free volume structure (including the contents of directory cache and disk cache).

Parameters
Volume- The volume structure to be freed.

Definition at line 460 of file Misc.c.

◆ FatGetCurrentFatTime()

VOID FatGetCurrentFatTime ( OUT FAT_DATE_TIME FatNow)

Get Current FAT time.

Parameters
FatTime- Current FAT time.

Get Current FAT time.

Parameters
FatNow- Current FAT time.

Definition at line 543 of file Misc.c.

◆ FatGetDirEntInfo()

EFI_STATUS FatGetDirEntInfo ( IN FAT_VOLUME Volume,
IN FAT_DIRENT DirEnt,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Get the directory entry's info into Buffer.

Parameters
Volume- FAT file system volume.
DirEnt- The corresponding directory entry.
BufferSize- Size of Buffer.
Buffer- Buffer containing file info.
Return values
EFI_SUCCESS- Get the file info successfully.
EFI_BUFFER_TOO_SMALL- The buffer is too small.

Definition at line 448 of file DirectoryManage.c.

◆ FatGetFileNameViaCaseFlag()

VOID FatGetFileNameViaCaseFlag ( IN FAT_DIRENT DirEnt,
IN OUT CHAR16 *  FileString,
IN UINTN  FileStringMax 
)

Convert the 8.3 ASCII fat name to cased Unicode string according to case flag.

Parameters
DirEnt- The corresponding directory entry.
FileString- The output Unicode file name.
FileStringMaxThe max length of FileString.

Definition at line 348 of file FileName.c.

◆ FatGetInfo()

EFI_STATUS EFIAPI FatGetInfo ( IN EFI_FILE_PROTOCOL FHand,
IN EFI_GUID Type,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Get the some types info of the file into Buffer

Parameters
FHand- The handle of file.
Type- The type of the info.
BufferSize- Size of Buffer.
Buffer- Buffer containing volume info.
Return values
EFI_SUCCESS- Get the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.

Get the some types info of the file into Buffer.

Parameters
FHand- The handle of file.
Type- The type of the info.
BufferSize- Size of Buffer.
Buffer- Buffer containing volume info.
Return values
EFI_SUCCESS- Get the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.

Definition at line 569 of file Info.c.

◆ FatGetNextDirEnt()

EFI_STATUS FatGetNextDirEnt ( IN FAT_OFILE OFile,
OUT FAT_DIRENT **  PtrDirEnt 
)

Set the directory's cursor to the next and get the next directory entry.

Parameters
OFile- The parent OFile.
PtrDirEnt- The next directory entry.
Return values
EFI_SUCCESS- We get the next directory entry successfully.
Returns
other - An error occurred when get next directory entry.

Definition at line 597 of file DirectoryManage.c.

◆ FatGetNextNameComponent()

CHAR16 * FatGetNextNameComponent ( IN CHAR16 *  Path,
OUT CHAR16 *  Name 
)

Takes Path as input, returns the next name component in Name, and returns the position after Name (e.g., the start of the next name component)

Parameters
Path- The path of one file.
Name- The next name component in Path.

The position after Name in the Path

Definition at line 410 of file FileName.c.

◆ FatGetPosition()

EFI_STATUS EFIAPI FatGetPosition ( IN EFI_FILE_PROTOCOL FHand,
OUT UINT64 *  Position 
)

Get the file's position of the file

Parameters
FHand- The handle of file.
Position- The file's position of the file.
Return values
EFI_SUCCESS- Get the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_UNSUPPORTED- The open file is not a file.

Get the file's position of the file.

Parameters
FHand- The handle of file.
Position- The file's position of the file.
Return values
EFI_SUCCESS- Get the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_UNSUPPORTED- The open file is not a file.

Definition at line 27 of file ReadWrite.c.

◆ FatGetVolumeEntry()

EFI_STATUS FatGetVolumeEntry ( IN FAT_VOLUME Volume,
IN CHAR16 *  Name 
)

Get the directory entry for the volume.

Parameters
Volume- FAT file system volume.
Name- The file name of the volume.
Return values
EFI_SUCCESS- Update the volume with the directory entry successfully.
Returns
others - An error occurred when getting volume label.

Definition at line 916 of file DirectoryManage.c.

◆ FatGrowEof()

EFI_STATUS FatGrowEof ( IN FAT_OFILE OFile,
IN UINT64  NewSizeInBytes 
)

Grow the end of the open file base on the NewSizeInBytes.

Parameters
OFile- The open file.
NewSizeInBytes- The new size in bytes of the open file.
Return values
EFI_SUCCESS- The file is grown successfully.
EFI_UNSUPPORTED- The file size is larger than 4GB.
EFI_VOLUME_CORRUPTED- There are errors in the files' clusters.
EFI_VOLUME_FULL- The volume is full and can not grow the file.

Definition at line 429 of file FileSpace.c.

◆ FatIFileClose()

EFI_STATUS FatIFileClose ( FAT_IFILE IFile)

Close the open file instance.

Parameters
IFile- Open file instance.
Return values
EFI_SUCCESS- Closed the file successfully.

Definition at line 173 of file Flush.c.

◆ FatInitializeDiskCache()

EFI_STATUS FatInitializeDiskCache ( IN FAT_VOLUME Volume)

Initialize the disk cache according to Volume's FatType.

Parameters
Volume- FAT file system volume.
Return values
EFI_SUCCESS- The disk cache is successfully initialized.
EFI_OUT_OF_RESOURCES- Not enough memory to allocate disk cache.

Definition at line 649 of file DiskCache.c.

◆ FatInsertToHashTable()

VOID FatInsertToHashTable ( IN FAT_ODIR ODir,
IN FAT_DIRENT DirEnt 
)

Insert directory entry to hash table.

Parameters
ODir- The parent directory.
DirEnt- The directory entry node.

Definition at line 132 of file Hash.c.

◆ FatIsDotDirEnt()

BOOLEAN FatIsDotDirEnt ( IN FAT_DIRENT DirEnt)

Determine whether the directory entry is "." or ".." entry.

Parameters
DirEnt- The corresponding directory entry.
Return values
TRUE- The directory entry is "." or ".." directory entry
FALSE- The directory entry is not "." or ".." directory entry

Definition at line 143 of file DirectoryManage.c.

◆ FatIsValidTime()

BOOLEAN FatIsValidTime ( IN EFI_TIME Time)

Check whether a time is valid.

Parameters
Time- The time of EFI_TIME.
Return values
TRUE- The time is valid.
FALSE- The time is not valid.

Definition at line 573 of file Misc.c.

◆ FatLocateOFile()

EFI_STATUS FatLocateOFile ( IN OUT FAT_OFILE **  PtrOFile,
IN CHAR16 *  FileName,
IN UINT8  Attributes,
OUT CHAR16 *  NewFileName 
)

Traverse filename and open all OFiles that can be opened. Update filename pointer to the component that can't be opened. If more than one name component remains, returns an error; otherwise, return the remaining name component so that the caller might choose to create it.

Parameters
PtrOFile- As input, the reference OFile; as output, the located OFile.
FileName- The file name relevant to the OFile.
Attributes- The attribute of the destination OFile.
NewFileName- The remaining file name.
Return values
EFI_NOT_FOUND- The file name can't be opened and there is more than one components within the name left (this means the name can not be created either).
EFI_INVALID_PARAMETER- The parameter is not valid.
EFI_SUCCESS- Open the file successfully.
Returns
other - An error occurred when locating the OFile.

Definition at line 1268 of file DirectoryManage.c.

◆ FatLongNameHashSearch()

FAT_DIRENT ** FatLongNameHashSearch ( IN FAT_ODIR ODir,
IN CHAR16 *  LongNameString 
)

Search the long name hash table for the directory entry.

Parameters
ODir- The directory to be searched.
LongNameString- The long name string to search.
Returns
The previous long name hash node of the directory entry.

Definition at line 72 of file Hash.c.

◆ FatNameToStr()

VOID FatNameToStr ( IN CHAR8 *  FatName,
IN UINTN  Len,
IN UINTN  LowerCase,
IN CHAR16 *  Str 
)

Convert the ascii fat name to the unicode string and strip trailing spaces, and if necessary, convert the unicode string to lower case.

Parameters
FatName- The Char8 string needs to be converted.
Len- The length of the fat name.
LowerCase- Indicate whether to convert the string to lower case.
Str- The result of the conversion.

◆ FatOFileFlush()

EFI_STATUS FatOFileFlush ( IN FAT_OFILE OFile)

Flush the data associated with an open file. In this implementation, only last Mod/Access time is updated.

Parameters
OFile- The open file.
Return values
EFI_SUCCESS- The OFile is flushed successfully.
Returns
Others - An error occurred when flushing this OFile.

Definition at line 218 of file Flush.c.

◆ FatOFileOpen()

EFI_STATUS FatOFileOpen ( IN FAT_OFILE OFile,
OUT FAT_IFILE **  NewIFile,
IN CHAR16 *  FileName,
IN UINT64  OpenMode,
IN UINT8  Attributes 
)

Open a file for a file name relative to an existing OFile. The IFile of the newly opened file is passed out.

Parameters
OFile- The file that serves as a starting reference point.
NewIFile- The newly generated IFile instance.
FileName- The file name relative to the OFile.
OpenMode- Open mode.
Attributes- Attributes to set if the file is created.
Return values
EFI_SUCCESS- Open the file successfully.
EFI_INVALID_PARAMETER- The open mode is conflict with the attributes or the file name is not valid.
EFI_NOT_FOUND- Conflicts between dir intention and attribute.
EFI_WRITE_PROTECTED- Can't open for write if the volume is read only.
EFI_ACCESS_DENIED- If the file's attribute is read only, and the open is for read-write fail it.
EFI_OUT_OF_RESOURCES- Can not allocate the memory.

Definition at line 85 of file Open.c.

◆ FatOFilePosition()

EFI_STATUS FatOFilePosition ( IN FAT_OFILE OFile,
IN UINTN  Position,
IN UINTN  PosLimit 
)

Seek OFile to requested position, and calculate the number of consecutive clusters from the position in the file

Parameters
OFile- The open file.
Position- The file's position which will be accessed.
PosLimit- The maximum length current reading/writing may access
Return values
EFI_SUCCESS- Set the info successfully.
EFI_VOLUME_CORRUPTED- Cluster chain corrupt.

Definition at line 562 of file FileSpace.c.

◆ FatOpen()

EFI_STATUS EFIAPI FatOpen ( IN EFI_FILE_PROTOCOL FHand,
OUT EFI_FILE_PROTOCOL **  NewHandle,
IN CHAR16 *  FileName,
IN UINT64  OpenMode,
IN UINT64  Attributes 
)

Implements Open() of Simple File System Protocol.

Parameters
FHand- File handle of the file serves as a starting reference point.
NewHandle- Handle of the file that is newly opened.
FileName- File name relative to FHand.
OpenMode- Open mode.
Attributes- Attributes to set if the file is created.
Return values
EFI_INVALID_PARAMETER- The FileName is NULL or the file string is empty. The OpenMode is not supported. The Attributes is not the valid attributes.
EFI_OUT_OF_RESOURCES- Can not allocate the memory for file string.
EFI_SUCCESS- Open the file successfully.
Returns
Others - The status of open file.

Definition at line 318 of file Open.c.

◆ FatOpenDevice()

EFI_STATUS FatOpenDevice ( IN OUT FAT_VOLUME Volume)

Detects FAT file system on Disk and set relevant fields of Volume.

Parameters
Volume- The volume structure.
Return values
EFI_SUCCESS- The Fat File System is detected successfully
EFI_UNSUPPORTED- The volume is not FAT file system.
EFI_VOLUME_CORRUPTED- The volume is corrupted.

Definition at line 222 of file Init.c.

◆ FatOpenDirEnt()

EFI_STATUS FatOpenDirEnt ( IN FAT_OFILE Parent,
IN FAT_DIRENT DirEnt 
)

Open the directory entry to get the OFile.

Parameters
Parent- The parent OFile.
DirEnt- The directory entry to be opened.
Return values
EFI_SUCCESS- The directory entry is successfully opened.
EFI_OUT_OF_RESOURCES- not enough memory to allocate a new OFile.
Returns
other - An error occurred when opening the directory entry.

Definition at line 1142 of file DirectoryManage.c.

◆ FatOpenEx()

EFI_STATUS EFIAPI FatOpenEx ( IN EFI_FILE_PROTOCOL FHand,
OUT EFI_FILE_PROTOCOL **  NewHandle,
IN CHAR16 *  FileName,
IN UINT64  OpenMode,
IN UINT64  Attributes,
IN OUT EFI_FILE_IO_TOKEN Token 
)

Implements OpenEx() of Simple File System Protocol.

Parameters
FHand- File handle of the file serves as a starting reference point.
NewHandle- Handle of the file that is newly opened.
FileName- File name relative to FHand.
OpenMode- Open mode.
Attributes- Attributes to set if the file is created.
Token- A pointer to the token associated with the transaction.
Return values
EFI_INVALID_PARAMETER- The FileName is NULL or the file string is empty. The OpenMode is not supported. The Attributes is not the valid attributes.
EFI_OUT_OF_RESOURCES- Can not allocate the memory for file string.
EFI_SUCCESS- Open the file successfully.
Returns
Others - The status of open file.

Implements OpenEx() of Simple File System Protocol.

Parameters
FHand- File handle of the file serves as a starting reference point.
NewHandle- Handle of the file that is newly opened.
FileName- File name relative to FHand.
OpenMode- Open mode.
Attributes- Attributes to set if the file is created.
Token- A pointer to the token associated with the transaction.:
Return values
EFI_INVALID_PARAMETER- The FileName is NULL or the file string is empty. The OpenMode is not supported. The Attributes is not the valid attributes.
EFI_OUT_OF_RESOURCES- Can not allocate the memory for file string.
EFI_SUCCESS- Open the file successfully.
Returns
Others - The status of open file.

Definition at line 200 of file Open.c.

◆ FatOpenVolume()

EFI_STATUS EFIAPI FatOpenVolume ( IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL This,
OUT EFI_FILE_PROTOCOL **  File 
)

Implements Simple File System Protocol interface function OpenVolume().

Parameters
This- Calling context.
File- the Root Directory of the volume.
Return values
EFI_OUT_OF_RESOURCES- Can not allocate the memory.
EFI_VOLUME_CORRUPTED- The FAT type is error.
EFI_SUCCESS- Open the volume successfully.

Definition at line 25 of file OpenVolume.c.

◆ FatPhysicalDirSize()

UINTN FatPhysicalDirSize ( IN FAT_VOLUME Volume,
IN UINTN  Cluster 
)

Get the size of directory of the open file.

Parameters
Volume- The File System Volume.
Cluster- The Starting cluster.
Returns
The physical size of the file starting at the input cluster, if there is error in the cluster chain, the return value is 0.

Definition at line 654 of file FileSpace.c.

◆ FatPhysicalFileSize()

UINT64 FatPhysicalFileSize ( IN FAT_VOLUME Volume,
IN UINTN  RealSize 
)

Get the physical size of a file on the disk.

Parameters
Volume- The file system volume.
RealSize- The real size of a file.
Returns
The physical size of a file on the disk.

Definition at line 699 of file FileSpace.c.

◆ FatQueueTask()

EFI_STATUS FatQueueTask ( IN FAT_IFILE IFile,
IN FAT_TASK Task 
)

Execute the task.

Parameters
IFile- The instance of the open file.
Task- The task to be executed.
Return values
EFI_SUCCESS- The task was executed successfully.
Returns
other - An error occurred when executing the task.

Definition at line 124 of file Misc.c.

◆ FatRead()

EFI_STATUS EFIAPI FatRead ( IN EFI_FILE_PROTOCOL FHand,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Get the file info.

Parameters
FHand- The handle of the file.
BufferSize- Size of Buffer.
Buffer- Buffer containing read data.
Return values
EFI_SUCCESS- Get the file info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_VOLUME_CORRUPTED- The file type of open file is error.
Returns
other - An error occurred when operation the disk.

Definition at line 360 of file ReadWrite.c.

◆ FatReadEx()

EFI_STATUS EFIAPI FatReadEx ( IN EFI_FILE_PROTOCOL FHand,
IN OUT EFI_FILE_IO_TOKEN Token 
)

Get the file info.

Parameters
FHand- The handle of the file.
Token- A pointer to the token associated with the transaction.
Return values
EFI_SUCCESS- Get the file info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_VOLUME_CORRUPTED- The file type of open file is error.
Returns
other - An error occurred when operation the disk.

Definition at line 384 of file ReadWrite.c.

◆ FatReleaseLock()

VOID FatReleaseLock ( VOID  )

Unlock the volume.

Definition at line 426 of file Misc.c.

◆ FatRemoveDirEnt()

EFI_STATUS FatRemoveDirEnt ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Remove this directory entry node from the list of directory entries and hash table.

Parameters
OFile- The parent OFile.
DirEnt- The directory entry to be removed.
Return values
EFI_SUCCESS- The directory entry is successfully removed.
Returns
other - An error occurred when removing the directory entry.

Definition at line 1101 of file DirectoryManage.c.

◆ FatRequestODir()

VOID FatRequestODir ( IN FAT_OFILE OFile)

Request the directory structure when an OFile is newly generated. If the directory structure is cached by volume, then just return this directory; Otherwise, allocate a new one for OFile.

Parameters
OFile- The OFile which requests directory structure.

Definition at line 130 of file DirectoryCache.c.

◆ FatResetODirCursor()

VOID FatResetODirCursor ( IN FAT_OFILE OFile)

Set the OFile's current directory cursor to the list head.

Parameters
OFile- The directory OFile whose directory cursor is reset.

Definition at line 573 of file DirectoryManage.c.

◆ FatSetCaseFlag()

VOID FatSetCaseFlag ( IN FAT_DIRENT DirEnt)

Set the caseflag value for the directory entry.

Parameters
DirEnt- The logical directory entry whose caseflag value is to be set.

Definition at line 293 of file FileName.c.

◆ FatSetInfo()

EFI_STATUS EFIAPI FatSetInfo ( IN EFI_FILE_PROTOCOL FHand,
IN EFI_GUID Type,
IN UINTN  BufferSize,
IN VOID *  Buffer 
)

Set the some types info of the file into Buffer.

Parameters
FHand- The handle of file.
Type- The type of the info.
BufferSize- Size of Buffer.
Buffer- Buffer containing volume info.
Return values
EFI_SUCCESS- Set the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.

Set the some types info of the file into Buffer.

Parameters
FHand- The handle of file.
Type- The type of the info.
BufferSize- Size of Buffer
Buffer- Buffer containing volume info.
Return values
EFI_SUCCESS- Set the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.

Definition at line 594 of file Info.c.

◆ FatSetPosition()

EFI_STATUS EFIAPI FatSetPosition ( IN EFI_FILE_PROTOCOL FHand,
IN UINT64  Position 
)

Set the file's position of the file.

Parameters
FHand- The handle of file
Position- The file's position of the file
Return values
EFI_SUCCESS- Set the info successfully
EFI_DEVICE_ERROR- Can not find the OFile for the file
EFI_UNSUPPORTED- Set a directory with a not-zero position

Set the file's position of the file.

Parameters
FHand- The handle of file.
Position- The file's position of the file.
Return values
EFI_SUCCESS- Set the info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_UNSUPPORTED- Set a directory with a not-zero position.

Definition at line 64 of file ReadWrite.c.

◆ FatSetVolumeEntry()

EFI_STATUS FatSetVolumeEntry ( IN FAT_VOLUME Volume,
IN CHAR16 *  Name 
)

Set the relevant directory entry into disk for the volume.

Parameters
Volume- FAT file system volume.
Name- The new file name of the volume.
Return values
EFI_SUCCESS- Update the Volume successfully.
EFI_UNSUPPORTED- The input label is not a valid volume label.
Returns
other - An error occurred when setting volume label.

Definition at line 948 of file DirectoryManage.c.

◆ FatSetVolumeError()

VOID FatSetVolumeError ( IN FAT_OFILE OFile,
IN EFI_STATUS  Status 
)

Set the OFile and its child OFile with the error Status

Parameters
OFile- The OFile whose permanent error code is to be set.
Status- Error code to be set.

Definition at line 459 of file Flush.c.

◆ FatShortNameHashSearch()

FAT_DIRENT ** FatShortNameHashSearch ( IN FAT_ODIR ODir,
IN CHAR8 *  ShortNameString 
)

Search the short name hash table for the directory entry.

Parameters
ODir- The directory to be searched.
ShortNameString- The short name string to search.
Returns
The previous short name hash node of the directory entry.

Definition at line 103 of file Hash.c.

◆ FatShrinkEof()

EFI_STATUS FatShrinkEof ( IN FAT_OFILE OFile)

Shrink the end of the open file base on the file size.

Parameters
OFile- The open file.
Return values
EFI_SUCCESS- Shrinked successfully.
EFI_VOLUME_CORRUPTED- There are errors in the file's clusters.

Definition at line 355 of file FileSpace.c.

◆ FatStoreDirEnt()

EFI_STATUS FatStoreDirEnt ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Save the directory entry to disk.

Parameters
OFile- The parent OFile which needs to update.
DirEnt- The directory entry to be saved.
Return values
EFI_SUCCESS- Store the directory entry successfully.
Returns
other - An error occurred when writing the directory entry.

Definition at line 63 of file DirectoryManage.c.

◆ FatStriCmp()

INTN FatStriCmp ( IN CHAR16 *  S1,
IN CHAR16 *  S2 
)

Performs a case-insensitive comparison of two Null-terminated Unicode strings.

Parameters
Str1A pointer to a Null-terminated Unicode string.
Str2A pointer to a Null-terminated Unicode string.
Return values
0S1 is equivalent to S2.
>0S1 is lexically greater than S2.
<0S1 is lexically less than S2.

Performs a case-insensitive comparison of two Null-terminated Unicode strings.

Parameters
S1A pointer to a Null-terminated Unicode string.
S2A pointer to a Null-terminated Unicode string.
Return values
0S1 is equivalent to S2.
>0S1 is lexically greater than S2.
<0S1 is lexically less than S2.

Definition at line 164 of file UnicodeCollation.c.

◆ FatStrLwr()

VOID FatStrLwr ( IN CHAR16 *  Str)

Lowercase a string

Parameters
StrThe string which will be lower-cased.

◆ FatStrToFat()

BOOLEAN FatStrToFat ( IN CHAR16 *  String,
IN UINTN  FatSize,
OUT CHAR8 *  Fat 
)

Convert unicode string to Fat string.

Parameters
StringThe unicode string.
FatSizeThe size of the FAT string.
FatThe FAT string.
Return values
TRUEConvert successfully.
FALSEConvert error.

Definition at line 253 of file UnicodeCollation.c.

◆ FatStrUpr()

VOID FatStrUpr ( IN CHAR16 *  Str)

Uppercase a string.

Parameters
StrThe string which will be upper-cased.

◆ FatTruncateOFile()

EFI_STATUS FatTruncateOFile ( IN FAT_OFILE OFile,
IN UINTN  TruncatedSize 
)

Truncate the OFile to smaller file size.

Parameters
OFile- The open file.
TruncatedSize- The new file size.
Return values
EFI_SUCCESS- The file is truncated successfully.
Returns
other - An error occurred when truncating file.

Definition at line 622 of file ReadWrite.c.

◆ FatUpdateDirEntClusterSizeInfo()

VOID FatUpdateDirEntClusterSizeInfo ( IN FAT_OFILE OFile)

Set the OFile's cluster and size info in its directory entry.

Parameters
OFile- The corresponding OFile.

Definition at line 187 of file DirectoryManage.c.

◆ FatVolumeFlushCache()

EFI_STATUS FatVolumeFlushCache ( IN FAT_VOLUME Volume,
IN FAT_TASK Task 
)

Flush all the dirty cache back, include the FAT cache and the Data cache.

Parameters
Volume- FAT file system volume.
Taskpoint to task instance.
Return values
EFI_SUCCESS- Flush all the dirty cache back successfully
Returns
other - An error occurred when writing the data into the disk

Definition at line 595 of file DiskCache.c.

◆ FatWaitNonblockingTask()

VOID FatWaitNonblockingTask ( FAT_IFILE IFile)

Wait all non-blocking requests complete.

Parameters
IFile- The instance of the open file.

Definition at line 75 of file Misc.c.

◆ FatWrite()

EFI_STATUS EFIAPI FatWrite ( IN EFI_FILE_PROTOCOL FHand,
IN OUT UINTN BufferSize,
IN VOID *  Buffer 
)

Set the file info.

Parameters
FHand- The handle of the file.
BufferSize- Size of Buffer.
Buffer- Buffer containing write data.
Return values
EFI_SUCCESS- Set the file info successfully.
EFI_WRITE_PROTECTED- The disk is write protected.
EFI_ACCESS_DENIED- The file is read-only.
EFI_DEVICE_ERROR- The OFile is not valid.
EFI_UNSUPPORTED- The open file is not a file.
  • The writing file size is larger than 4GB.
Returns
other - An error occurred when operation the disk.

Write the content of buffer into files.

Parameters
FHand- The handle of the file.
BufferSize- Size of Buffer.
Buffer- Buffer containing write data.
Return values
EFI_SUCCESS- Set the file info successfully.
EFI_WRITE_PROTECTED- The disk is write protect.
EFI_ACCESS_DENIED- The file is read-only.
EFI_DEVICE_ERROR- The OFile is not valid.
EFI_UNSUPPORTED- The open file is not a file.
  • The writing file size is larger than 4GB.
Returns
other - An error occurred when operation the disk.

Definition at line 411 of file ReadWrite.c.

◆ FatWriteEx()

EFI_STATUS EFIAPI FatWriteEx ( IN EFI_FILE_PROTOCOL FHand,
IN OUT EFI_FILE_IO_TOKEN Token 
)

Get the file info.

Parameters
FHand- The handle of the file.
Token- A pointer to the token associated with the transaction.
Return values
EFI_SUCCESS- Get the file info successfully.
EFI_DEVICE_ERROR- Can not find the OFile for the file.
EFI_VOLUME_CORRUPTED- The file type of open file is error.
Returns
other - An error occurred when operation the disk.

Definition at line 435 of file ReadWrite.c.

◆ FatWriteZeroPool()

EFI_STATUS FatWriteZeroPool ( IN FAT_OFILE OFile,
IN UINTN  WritePos 
)

Write zero pool from the WritePos to the end of OFile.

Parameters
OFile- The open file to write zero pool.
WritePos- The number of zero bytes written.
Return values
EFI_SUCCESS- Write the zero pool successfully.
EFI_OUT_OF_RESOURCES- Not enough memory to perform the operation.
Returns
other - An error occurred when writing disk.

Definition at line 567 of file ReadWrite.c.

◆ InitializeUnicodeCollationSupport()

EFI_STATUS InitializeUnicodeCollationSupport ( IN EFI_HANDLE  AgentHandle)

Initialize Unicode Collation support.

It tries to locate Unicode Collation 2 protocol and matches it with current platform language code. If for any reason the first attempt fails, it then tries to use Unicode Collation Protocol.

Parameters
AgentHandleThe handle used to open Unicode Collation (2) protocol.
Return values
EFI_SUCCESSThe Unicode Collation (2) protocol has been successfully located.
OthersThe Unicode Collation (2) protocol has not been located.

Definition at line 120 of file UnicodeCollation.c.

Variable Documentation

◆ FatFileInterface

EFI_FILE_PROTOCOL FatFileInterface
extern

Definition at line 24 of file Data.c.

◆ FatFsLock

EFI_LOCK FatFsLock
extern

Definition at line 17 of file Data.c.

◆ FatTaskLock

EFI_LOCK FatTaskLock
extern

Definition at line 19 of file Data.c.

◆ gFatComponentName

EFI_COMPONENT_NAME_PROTOCOL gFatComponentName
extern

Definition at line 143 of file ComponentName.c.

◆ gFatComponentName2

EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2
extern

Definition at line 152 of file ComponentName.c.

◆ gFatDriverBinding

EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding
extern

Definition at line 116 of file Fat.c.