TianoCore EDK2 master
Loading...
Searching...
No Matches
Fat.h
Go to the documentation of this file.
1
9#ifndef _FAT_H_
10#define _FAT_H_
11
12#include <Uefi.h>
13
14#include <Guid/FileInfo.h>
15#include <Guid/FileSystemInfo.h>
17#include <Protocol/BlockIo.h>
18#include <Protocol/DiskIo.h>
19#include <Protocol/DiskIo2.h>
22
23#include <Library/PcdLib.h>
24#include <Library/DebugLib.h>
25#include <Library/UefiLib.h>
26#include <Library/BaseLib.h>
32
33#include "FatFileSystem.h"
34
35//
36// The FAT signature
37//
38#define FAT_VOLUME_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'v')
39#define FAT_IFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'i')
40#define FAT_ODIR_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'd')
41#define FAT_DIRENT_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'e')
42#define FAT_OFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'o')
43#define FAT_TASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'T')
44#define FAT_SUBTASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'S')
45
46#define ASSERT_VOLUME_LOCKED(a) ASSERT_LOCKED (&FatFsLock)
47
48#define IFILE_FROM_FHAND(a) CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)
49
50#define DIRENT_FROM_LINK(a) CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)
51
52#define VOLUME_FROM_ROOT_DIRENT(a) CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)
53
54#define VOLUME_FROM_VOL_INTERFACE(a) CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);
55
56#define ODIR_FROM_DIRCACHELINK(a) CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)
57
58#define OFILE_FROM_CHECKLINK(a) CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)
59
60#define OFILE_FROM_CHILDLINK(a) CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)
61
62//
63// Minimum sector size is 512B, Maximum sector size is 4096B
64// Max sectors per cluster is 128
65//
66#define MAX_BLOCK_ALIGNMENT 12
67#define MIN_BLOCK_ALIGNMENT 9
68#define MAX_SECTORS_PER_CLUSTER_ALIGNMENT 7
69
70//
71// Efi Time Definition
72//
73#define IS_LEAP_YEAR(a) (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))
74
75//
76// Minimum fat page size is 8K, maximum fat page alignment is 32K
77// Minimum data page size is 8K, maximum fat page alignment is 64K
78//
79#define FAT_FATCACHE_PAGE_MIN_ALIGNMENT 13
80#define FAT_FATCACHE_PAGE_MAX_ALIGNMENT 15
81#define FAT_DATACACHE_PAGE_MIN_ALIGNMENT 13
82#define FAT_DATACACHE_PAGE_MAX_ALIGNMENT 16
83#define FAT_DATACACHE_GROUP_COUNT 64
84#define FAT_FATCACHE_GROUP_MIN_COUNT 1
85#define FAT_FATCACHE_GROUP_MAX_COUNT 16
86
87// For cache block bits, use a UINT64
88typedef UINT64 DIRTY_BLOCKS;
89#define BITS_PER_BYTE 8
90#define DIRTY_BITS_PER_BLOCK ((sizeof (DIRTY_BLOCKS) * BITS_PER_BYTE))
91
92// largest cache line (64KB) / MinLbaSize (512) = 128 bits
93#define DIRTY_BITS ((1 << FAT_DATACACHE_PAGE_MAX_ALIGNMENT) / (1 << MIN_BLOCK_ALIGNMENT))
94
95// Number of DIRTY_BLOCKS to hold DIRTY_BITS bits.
96#define DIRTY_BLOCKS_SIZE (DIRTY_BITS / sizeof (DIRTY_BLOCKS))
97
98STATIC_ASSERT ((((1 << FAT_DATACACHE_PAGE_MAX_ALIGNMENT) / (1 << MIN_BLOCK_ALIGNMENT)) % sizeof (DIRTY_BLOCKS)) == 0, "DIRTY_BLOCKS not a proper size");
99
100//
101// Used in 8.3 generation algorithm
102//
103#define MAX_SPEC_RETRY 4
104#define SPEC_BASE_TAG_LEN 6
105#define HASH_BASE_TAG_LEN 2
106#define HASH_VALUE_TAG_LEN (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)
107
108//
109// Path name separator is back slash
110//
111#define PATH_NAME_SEPARATOR L'\\'
112
113#define EFI_PATH_STRING_LENGTH 260
114#define EFI_FILE_STRING_LENGTH 255
115#define FAT_MAX_ALLOCATE_SIZE 0xA00000
116#define LC_ISO_639_2_ENTRY_SIZE 3
117#define MAX_LANG_CODE_SIZE 100
118
119#define FAT_MAX_DIR_CACHE_COUNT 8
120#define FAT_MAX_DIRENTRY_COUNT 0xFFFF
121typedef CHAR8 LC_ISO_639_2;
122
123//
124// The fat types we support
125//
126typedef enum {
127 Fat12,
128 Fat16,
129 Fat32,
130 FatUndefined
131} FAT_VOLUME_TYPE;
132
133typedef enum {
134 CacheFat,
135 CacheData,
136 CacheMaxType
137} CACHE_DATA_TYPE;
138
139//
140// Used in FatDiskIo
141//
142typedef enum {
143 ReadDisk = 0, // raw disk read
144 WriteDisk = 1, // raw disk write
145 ReadFat = 2, // read fat cache
146 WriteFat = 3, // write fat cache
147 ReadData = 6, // read data cache
148 WriteData = 7 // write data cache
149} IO_MODE;
150
151#define CACHE_ENABLED(a) ((a) >= 2)
152#define RAW_ACCESS(a) ((IO_MODE)((a) & 0x1))
153#define CACHE_TYPE(a) ((CACHE_DATA_TYPE)((a) >> 2))
154
155//
156// Disk cache tag
157//
158typedef struct {
159 UINTN PageNo;
160 UINTN RealSize;
161 BOOLEAN Dirty;
162 DIRTY_BLOCKS DirtyBlocks[DIRTY_BLOCKS_SIZE];
163} CACHE_TAG;
164
165typedef struct {
166 UINT64 BaseAddress;
167 UINT64 LimitAddress;
168 UINT8 *CacheBase;
169 UINT32 BlockSize;
170 BOOLEAN Dirty;
171 UINT8 PageAlignment;
172 UINTN GroupMask;
173 CACHE_TAG CacheTag[FAT_DATACACHE_GROUP_COUNT];
174} DISK_CACHE;
175
176//
177// Hash table size
178//
179#define HASH_TABLE_SIZE 0x400
180#define HASH_TABLE_MASK (HASH_TABLE_SIZE - 1)
181
182//
183// The directory entry for opened directory
184//
185
186typedef struct _FAT_DIRENT FAT_DIRENT;
187typedef struct _FAT_ODIR FAT_ODIR;
188typedef struct _FAT_OFILE FAT_OFILE;
189typedef struct _FAT_VOLUME FAT_VOLUME;
190
192 UINTN Signature;
193 UINT16 EntryPos; // The position of this directory entry in the parent directory file
194 UINT8 EntryCount; // The count of the directory entry in the parent directory file
195 BOOLEAN Invalid; // Indicate whether this directory entry is valid
196 CHAR16 *FileString; // The unicode long file name for this directory entry
197 FAT_OFILE *OFile; // The OFile of the corresponding directory entry
198 FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename
199 FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename
200 LIST_ENTRY Link; // Connection of every directory entry
201 FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk
202};
203
204struct _FAT_ODIR {
205 UINTN Signature;
206 UINT32 CurrentEndPos; // Current end position of the directory
207 UINT32 CurrentPos; // Current position of the directory
208 LIST_ENTRY *CurrentCursor; // Current directory entry pointer
209 LIST_ENTRY ChildList; // List of all directory entries
210 BOOLEAN EndOfDir; // Indicate whether we have reached the end of the directory
211 LIST_ENTRY DirCacheLink; // Linked in Volume->DirCacheList when discarded
212 UINTN DirCacheTag; // The identification of the directory when in directory cache
213 FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];
214 FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];
215};
216
217typedef struct {
218 UINTN Signature;
219 EFI_FILE_PROTOCOL Handle;
220 UINT64 Position;
221 BOOLEAN ReadOnly;
222 FAT_OFILE *OFile;
223 LIST_ENTRY Tasks; // List of all FAT_TASKs
224 LIST_ENTRY Link; // Link to other IFiles
225} FAT_IFILE;
226
227typedef struct {
228 UINTN Signature;
229 EFI_FILE_IO_TOKEN *FileIoToken;
230 FAT_IFILE *IFile;
231 LIST_ENTRY Subtasks; // List of all FAT_SUBTASKs
232 LIST_ENTRY Link; // Link to other FAT_TASKs
233} FAT_TASK;
234
235typedef struct {
236 UINTN Signature;
237 EFI_DISK_IO2_TOKEN DiskIo2Token;
238 FAT_TASK *Task;
239 BOOLEAN Write;
240 UINT64 Offset;
241 VOID *Buffer;
242 UINTN BufferSize;
243 LIST_ENTRY Link;
245
246//
247// FAT_OFILE - Each opened file
248//
250 UINTN Signature;
251 FAT_VOLUME *Volume;
252 //
253 // A permanent error code to return to all accesses to
254 // this opened file
255 //
256 EFI_STATUS Error;
257 //
258 // A list of the IFILE instances for this OFile
259 //
260 LIST_ENTRY Opens;
261
262 //
263 // The dynamic information
264 //
265 UINTN FileSize;
266 UINTN FileCluster;
267 UINTN FileCurrentCluster;
268 UINTN FileLastCluster;
269
270 //
271 // Dirty is set if there have been any updates to the
272 // file
273 // Archive is set if the archive attribute in the file's
274 // directory entry needs to be set when performing flush
275 // PreserveLastMod is set if the last modification of the
276 // file is specified by SetInfo API
277 //
278 BOOLEAN Dirty;
279 BOOLEAN IsFixedRootDir;
280 BOOLEAN PreserveLastModification;
281 BOOLEAN Archive;
282 //
283 // Set by an OFile SetPosition
284 //
285 UINTN Position; // within file
286 UINT64 PosDisk; // on the disk
287 UINTN PosRem; // remaining in this disk run
288 //
289 // The opened parent, full path length and currently opened child files
290 //
291 FAT_OFILE *Parent;
292 UINTN FullPathLen;
293 LIST_ENTRY ChildHead;
294 LIST_ENTRY ChildLink;
295
296 //
297 // The opened directory structure for a directory; if this
298 // OFile represents a file, then ODir = NULL
299 //
300 FAT_ODIR *ODir;
301 //
302 // The directory entry for the Ofile
303 //
304 FAT_DIRENT *DirEnt;
305
306 //
307 // Link in Volume's reference list
308 //
309 LIST_ENTRY CheckLink;
310};
311
313 UINTN Signature;
314
315 EFI_HANDLE Handle;
316 BOOLEAN Valid;
317 BOOLEAN DiskError;
318
319 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL VolumeInterface;
320
321 //
322 // If opened, the parent handle and BlockIo interface
323 //
324 EFI_BLOCK_IO_PROTOCOL *BlockIo;
325 EFI_DISK_IO_PROTOCOL *DiskIo;
326 EFI_DISK_IO2_PROTOCOL *DiskIo2;
327 UINT32 MediaId;
328 BOOLEAN ReadOnly;
329
330 //
331 // Computed values from fat bpb info
332 //
333 UINT64 VolumeSize;
334 UINT64 FatPos; // Disk pos of fat tables
335 UINT64 RootPos; // Disk pos of root directory
336 UINT64 FirstClusterPos; // Disk pos of first cluster
337 UINTN FatSize; // Number of bytes in each fat
338 UINTN MaxCluster; // Max cluster number
339 UINTN ClusterSize; // Cluster size of fat partition
340 UINT8 ClusterAlignment; // Equal to log_2 (clustersize);
341 FAT_VOLUME_TYPE FatType;
342
343 //
344 // Current part of fat table that's present
345 //
346 UINT64 FatEntryPos; // Location of buffer
347 UINTN FatEntrySize; // Size of buffer
348 UINT32 FatEntryBuffer; // The buffer
349 FAT_INFO_SECTOR FatInfoSector; // Free cluster info
350 UINTN FreeInfoPos; // Pos with the free cluster info
351 BOOLEAN FreeInfoValid; // If free cluster info is valid
352 //
353 // Unpacked Fat BPB info
354 //
355 UINTN NumFats;
356 UINTN RootEntries; // < FAT32, root dir is fixed size
357 UINTN RootCluster; // >= FAT32, root cluster chain head
358 //
359 // info for marking the volume dirty or not
360 //
361 BOOLEAN FatDirty; // If fat-entries have been updated
362 UINT32 DirtyValue;
363 UINT32 NotDirtyValue;
364
365 //
366 // The root directory entry and opened root file
367 //
368 FAT_DIRENT RootDirEnt;
369 //
370 // File Name of root OFile, it is empty string
371 //
372 CHAR16 RootFileString[1];
373 FAT_OFILE *Root;
374
375 //
376 // New OFiles are added to this list so they
377 // can be cleaned up if they aren't referenced.
378 //
379 LIST_ENTRY CheckRef;
380
381 //
382 // Directory cache List
383 //
384 LIST_ENTRY DirCacheList;
385 UINTN DirCacheCount;
386
387 //
388 // Disk Cache for this volume
389 //
390 VOID *CacheBuffer;
391 DISK_CACHE DiskCache[CacheMaxType];
392};
393
394//
395// Function Prototypes
396//
397
418EFIAPI
419FatOpen (
420 IN EFI_FILE_PROTOCOL *FHand,
421 OUT EFI_FILE_PROTOCOL **NewHandle,
422 IN CHAR16 *FileName,
423 IN UINT64 OpenMode,
424 IN UINT64 Attributes
425 )
426;
427
448EFIAPI
449FatOpenEx (
450 IN EFI_FILE_PROTOCOL *FHand,
451 OUT EFI_FILE_PROTOCOL **NewHandle,
452 IN CHAR16 *FileName,
453 IN UINT64 OpenMode,
454 IN UINT64 Attributes,
456 )
457;
458
472EFIAPI
474 IN EFI_FILE_PROTOCOL *FHand,
475 OUT UINT64 *Position
476 )
477;
478
493EFIAPI
495 IN EFI_FILE_PROTOCOL *FHand,
496 IN EFI_GUID *Type,
497 IN OUT UINTN *BufferSize,
498 OUT VOID *Buffer
499 )
500;
501
516EFIAPI
518 IN EFI_FILE_PROTOCOL *FHand,
519 IN EFI_GUID *Type,
520 IN UINTN BufferSize,
521 IN VOID *Buffer
522 )
523;
524
539EFIAPI
540FatFlush (
541 IN EFI_FILE_PROTOCOL *FHand
542 )
543;
544
559EFIAPI
561 IN EFI_FILE_PROTOCOL *FHand,
562 IN EFI_FILE_IO_TOKEN *Token
563 )
564;
565
576EFIAPI
577FatClose (
578 IN EFI_FILE_PROTOCOL *FHand
579 )
580;
581
593EFIAPI
594FatDelete (
595 IN EFI_FILE_PROTOCOL *FHand
596 )
597;
598
612EFIAPI
614 IN EFI_FILE_PROTOCOL *FHand,
615 IN UINT64 Position
616 )
617;
618
634EFIAPI
635FatRead (
636 IN EFI_FILE_PROTOCOL *FHand,
637 IN OUT UINTN *BufferSize,
638 OUT VOID *Buffer
639 )
640;
641
656EFIAPI
657FatReadEx (
658 IN EFI_FILE_PROTOCOL *FHand,
660 )
661;
662
681EFIAPI
682FatWrite (
683 IN EFI_FILE_PROTOCOL *FHand,
684 IN OUT UINTN *BufferSize,
685 IN VOID *Buffer
686 )
687;
688
703EFIAPI
705 IN EFI_FILE_PROTOCOL *FHand,
707 )
708;
709
710//
711// DiskCache.c
712//
713
726 IN FAT_VOLUME *Volume
727 );
728
760 IN FAT_VOLUME *Volume,
761 IN CACHE_DATA_TYPE CacheDataType,
762 IN IO_MODE IoMode,
763 IN UINT64 Offset,
764 IN UINTN BufferSize,
765 IN OUT UINT8 *Buffer,
766 IN FAT_TASK *Task
767 );
768
782 IN FAT_VOLUME *Volume,
783 IN FAT_TASK *Task
784 );
785
786//
787// Flush.c
788//
789
803 IN FAT_OFILE *OFile
804 );
805
818BOOLEAN
820 IN FAT_OFILE *OFile
821 );
822
831VOID
833 IN FAT_OFILE *OFile,
834 IN EFI_STATUS Status
835 );
836
848 FAT_IFILE *IFile
849 );
850
869 IN FAT_VOLUME *Volume,
870 IN FAT_OFILE *OFile,
871 IN EFI_STATUS EfiStatus,
872 IN FAT_TASK *Task
873 );
874
875//
876// FileSpace.c
877//
878
891 IN FAT_OFILE *OFile
892 );
893
909 IN FAT_OFILE *OFile,
910 IN UINT64 NewSizeInBytes
911 );
912
924UINTN
926 IN FAT_VOLUME *Volume,
927 IN UINTN Cluster
928 );
929
940UINT64
942 IN FAT_VOLUME *Volume,
943 IN UINTN RealSize
944 );
945
961 IN FAT_OFILE *OFile,
962 IN UINTN Position,
963 IN UINTN PosLimit
964 );
965
973VOID
975 IN FAT_VOLUME *Volume
976 );
977
978//
979// Init.c
980//
981
999 IN EFI_HANDLE Handle,
1000 IN EFI_DISK_IO_PROTOCOL *DiskIo,
1001 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
1002 IN EFI_BLOCK_IO_PROTOCOL *BlockIo
1003 );
1004
1018 IN OUT FAT_VOLUME *Volume
1019 );
1020
1033 IN FAT_VOLUME *Volume
1034 );
1035
1036//
1037// Misc.c
1038//
1039
1050FAT_TASK *
1052 FAT_IFILE *IFile,
1053 EFI_FILE_IO_TOKEN *Token
1054 );
1055
1063VOID
1065 FAT_TASK *Task
1066 );
1067
1075VOID
1077 FAT_IFILE *IFile
1078 );
1079
1089LIST_ENTRY *
1091 FAT_SUBTASK *Subtask
1092 );
1093
1107 IN FAT_IFILE *IFile,
1108 IN FAT_TASK *Task
1109 );
1110
1125 IN FAT_VOLUME *Volume,
1126 IN IO_MODE IoMode,
1127 IN VOID *DirtyValue
1128 );
1129
1147FatDiskIo (
1148 IN FAT_VOLUME *Volume,
1149 IN IO_MODE IoMode,
1150 IN UINT64 Offset,
1151 IN UINTN BufferSize,
1152 IN OUT VOID *Buffer,
1153 IN FAT_TASK *Task
1154 );
1155
1161VOID
1163 VOID
1164 );
1165
1171VOID
1173 VOID
1174 );
1175
1188 VOID
1189 );
1190
1198VOID
1200 IN FAT_DIRENT *DirEnt
1201 );
1202
1210VOID
1212 IN FAT_VOLUME *Volume
1213 );
1214
1223VOID
1225 IN EFI_TIME *ETime,
1226 OUT FAT_DATE_TIME *FTime
1227 );
1228
1237VOID
1239 IN FAT_DATE_TIME *FTime,
1240 OUT EFI_TIME *ETime
1241 );
1242
1250VOID
1252 OUT FAT_DATE_TIME *FatTime
1253 );
1254
1265BOOLEAN
1267 IN EFI_TIME *Time
1268 );
1269
1270//
1271// UnicodeCollation.c
1272//
1273
1289 IN EFI_HANDLE AgentHandle
1290 );
1291
1302VOID
1304 IN UINTN FatSize,
1305 IN CHAR8 *Fat,
1306 OUT CHAR16 *String
1307 );
1308
1320BOOLEAN
1322 IN CHAR16 *String,
1323 IN UINTN FatSize,
1324 OUT CHAR8 *Fat
1325 );
1326
1333VOID
1335 IN CHAR16 *Str
1336 );
1337
1344VOID
1346 IN CHAR16 *Str
1347 );
1348
1359INTN
1360FatStriCmp (
1361 IN CHAR16 *Str1,
1362 IN CHAR16 *Str2
1363 );
1364
1365//
1366// Open.c
1367//
1368
1393 IN FAT_OFILE *OFile,
1394 OUT FAT_IFILE **NewIFile,
1395 IN CHAR16 *FileName,
1396 IN UINT64 OpenMode,
1397 IN UINT8 Attributes
1398 );
1399
1414 IN FAT_OFILE *OFile,
1415 OUT FAT_IFILE **PtrIFile
1416 );
1417
1418//
1419// OpenVolume.c
1420//
1421
1435EFIAPI
1438 OUT EFI_FILE_PROTOCOL **File
1439 );
1440
1441//
1442// ReadWrite.c
1443//
1444
1463 IN FAT_OFILE *OFile,
1464 IN IO_MODE IoMode,
1465 IN UINTN Position,
1466 IN UINTN *DataBufferSize,
1467 IN UINT8 *UserBuffer,
1468 IN FAT_TASK *Task
1469 );
1470
1484 IN FAT_OFILE *OFile,
1485 IN UINT64 ExpandedSize
1486 );
1487
1502 IN FAT_OFILE *OFile,
1503 IN UINTN WritePos
1504 );
1505
1519 IN FAT_OFILE *OFile,
1520 IN UINTN TruncatedSize
1521 );
1522
1523//
1524// DirectoryManage.c
1525//
1526
1534VOID
1536 IN FAT_OFILE *OFile
1537 );
1538
1552 IN FAT_OFILE *OFile,
1553 OUT FAT_DIRENT **PtrDirEnt
1554 );
1555
1569 IN FAT_OFILE *OFile,
1570 IN FAT_DIRENT *DirEnt
1571 );
1572
1586 IN FAT_OFILE *OFile,
1587 IN FAT_DIRENT *DirEnt
1588 );
1589
1606 IN FAT_OFILE *OFile,
1607 IN CHAR16 *FileName,
1608 IN UINT8 Attributes,
1609 OUT FAT_DIRENT **PtrDirEnt
1610 );
1611
1622BOOLEAN
1624 IN FAT_DIRENT *DirEnt
1625 );
1626
1634VOID
1636 IN FAT_OFILE *OFile
1637 );
1638
1647VOID
1649 IN FAT_DIRENT *DirEnt1,
1650 IN FAT_DIRENT *DirEnt2
1651 );
1652
1668 IN FAT_VOLUME *Volume,
1669 IN FAT_DIRENT *DirEnt,
1670 IN OUT UINTN *BufferSize,
1671 OUT VOID *Buffer
1672 );
1673
1688 IN FAT_OFILE *OFile,
1689 IN FAT_DIRENT *DirEnt
1690 );
1691
1704 IN FAT_OFILE *OFile
1705 );
1706
1714VOID
1716 IN FAT_DIRENT *DirEnt
1717 );
1718
1741 IN OUT FAT_OFILE **PtrOFile,
1742 IN CHAR16 *FileName,
1743 IN UINT8 Attributes,
1744 OUT CHAR16 *NewFileName
1745 );
1746
1760 IN FAT_VOLUME *Volume,
1761 IN CHAR16 *Name
1762 );
1763
1778 IN FAT_VOLUME *Volume,
1779 IN CHAR16 *Name
1780 );
1781
1782//
1783// Hash.c
1784//
1785
1796FAT_DIRENT **
1798 IN FAT_ODIR *ODir,
1799 IN CHAR16 *LongNameString
1800 );
1801
1812FAT_DIRENT **
1814 IN FAT_ODIR *ODir,
1815 IN CHAR8 *ShortNameString
1816 );
1817
1826VOID
1828 IN FAT_ODIR *ODir,
1829 IN FAT_DIRENT *DirEnt
1830 );
1831
1840VOID
1842 IN FAT_ODIR *ODir,
1843 IN FAT_DIRENT *DirEnt
1844 );
1845
1846//
1847// FileName.c
1848//
1849
1863BOOLEAN
1865 IN CHAR16 *FileName,
1866 OUT CHAR8 *File8Dot3Name
1867 );
1868
1877VOID
1879 IN FAT_OFILE *Parent,
1880 IN FAT_DIRENT *DirEnt
1881 );
1882
1894VOID
1896 IN CHAR8 *FatName,
1897 IN UINTN Len,
1898 IN UINTN LowerCase,
1899 IN CHAR16 *Str
1900 );
1901
1909VOID
1911 IN FAT_DIRENT *DirEnt
1912 );
1913
1923VOID
1925 IN FAT_DIRENT *DirEnt,
1926 IN OUT CHAR16 *FileString,
1927 IN UINTN FileStringMax
1928 );
1929
1939UINT8
1941 IN CHAR8 *ShortNameString
1942 );
1943
1956CHAR16 *
1958 IN CHAR16 *Path,
1959 OUT CHAR16 *Name
1960 );
1961
1975BOOLEAN
1977 IN CHAR16 *InputFileName,
1978 OUT CHAR16 *OutputFileName
1979 );
1980
1981//
1982// DirectoryCache.c
1983//
1984
1993VOID
1995 IN FAT_OFILE *OFile
1996 );
1997
2007VOID
2009 IN FAT_OFILE *OFile
2010 );
2011
2019VOID
2021 IN FAT_VOLUME *Volume
2022 );
2023
2024//
2025// Global Variables
2026//
2027extern EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding;
2028extern EFI_COMPONENT_NAME_PROTOCOL gFatComponentName;
2029extern EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2;
2030extern EFI_LOCK FatFsLock;
2031extern EFI_LOCK FatTaskLock;
2032extern EFI_FILE_PROTOCOL FatFileInterface;
2033
2034#endif
UINT64 UINTN
INT64 INTN
EFI_STATUS EFIAPI FatReadEx(IN EFI_FILE_PROTOCOL *FHand, IN OUT EFI_FILE_IO_TOKEN *Token)
Definition: ReadWrite.c:384
FAT_DIRENT ** FatShortNameHashSearch(IN FAT_ODIR *ODir, IN CHAR8 *ShortNameString)
Definition: Hash.c:103
BOOLEAN FatFileNameIsValid(IN CHAR16 *InputFileName, OUT CHAR16 *OutputFileName)
Definition: FileName.c:444
VOID FatFreeVolume(IN FAT_VOLUME *Volume)
Definition: Misc.c:460
EFI_STATUS FatInitializeDiskCache(IN FAT_VOLUME *Volume)
Definition: DiskCache.c:649
EFI_STATUS FatRemoveDirEnt(IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
VOID FatDestroyTask(FAT_TASK *Task)
Definition: Misc.c:51
VOID FatFatTimeToEfiTime(IN FAT_DATE_TIME *FTime, OUT EFI_TIME *ETime)
Definition: Misc.c:519
EFI_STATUS EFIAPI FatRead(IN EFI_FILE_PROTOCOL *FHand, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
Definition: ReadWrite.c:360
FAT_TASK * FatCreateTask(FAT_IFILE *IFile, EFI_FILE_IO_TOKEN *Token)
Definition: Misc.c:24
EFI_STATUS EFIAPI FatGetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
Definition: Info.c:569
EFI_STATUS FatStoreDirEnt(IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
BOOLEAN FatStrToFat(IN CHAR16 *String, IN UINTN FatSize, OUT CHAR8 *Fat)
VOID FatEfiTimeToFatTime(IN EFI_TIME *ETime, OUT FAT_DATE_TIME *FTime)
Definition: Misc.c:487
VOID FatFatToStr(IN UINTN FatSize, IN CHAR8 *Fat, OUT CHAR16 *String)
EFI_STATUS FatVolumeFlushCache(IN FAT_VOLUME *Volume, IN FAT_TASK *Task)
Definition: DiskCache.c:595
UINTN FatPhysicalDirSize(IN FAT_VOLUME *Volume, IN UINTN Cluster)
Definition: FileSpace.c:654
EFI_STATUS FatWriteZeroPool(IN FAT_OFILE *OFile, IN UINTN WritePos)
Definition: ReadWrite.c:567
EFI_STATUS FatGetDirEntInfo(IN FAT_VOLUME *Volume, IN FAT_DIRENT *DirEnt, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_STATUS FatCreateDirEnt(IN FAT_OFILE *OFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT FAT_DIRENT **PtrDirEnt)
VOID FatInsertToHashTable(IN FAT_ODIR *ODir, IN FAT_DIRENT *DirEnt)
Definition: Hash.c:132
EFI_STATUS FatQueueTask(IN FAT_IFILE *IFile, IN FAT_TASK *Task)
Definition: Misc.c:124
BOOLEAN FatIsDotDirEnt(IN FAT_DIRENT *DirEnt)
VOID FatNameToStr(IN CHAR8 *FatName, IN UINTN Len, IN UINTN LowerCase, IN CHAR16 *Str)
EFI_STATUS FatOFileFlush(IN FAT_OFILE *OFile)
Definition: Flush.c:218
EFI_STATUS EFIAPI FatWrite(IN EFI_FILE_PROTOCOL *FHand, IN OUT UINTN *BufferSize, IN VOID *Buffer)
Definition: ReadWrite.c:411
VOID FatRequestODir(IN FAT_OFILE *OFile)
EFI_STATUS FatExpandOFile(IN FAT_OFILE *OFile, IN UINT64 ExpandedSize)
Definition: ReadWrite.c:537
EFI_STATUS FatOpenDevice(IN OUT FAT_VOLUME *Volume)
Definition: Init.c:222
EFI_STATUS FatAcquireLockOrFail(VOID)
Definition: Misc.c:413
EFI_STATUS FatLocateOFile(IN OUT FAT_OFILE **PtrOFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT CHAR16 *NewFileName)
VOID FatGetFileNameViaCaseFlag(IN FAT_DIRENT *DirEnt, IN OUT CHAR16 *FileString, IN UINTN FileStringMax)
Definition: FileName.c:348
EFI_STATUS FatGrowEof(IN FAT_OFILE *OFile, IN UINT64 NewSizeInBytes)
Definition: FileSpace.c:429
EFI_STATUS FatOFilePosition(IN FAT_OFILE *OFile, IN UINTN Position, IN UINTN PosLimit)
Definition: FileSpace.c:562
VOID FatDiscardODir(IN FAT_OFILE *OFile)
LIST_ENTRY * FatDestroySubtask(FAT_SUBTASK *Subtask)
Definition: Misc.c:98
EFI_STATUS EFIAPI FatGetPosition(IN EFI_FILE_PROTOCOL *FHand, OUT UINT64 *Position)
Definition: ReadWrite.c:27
EFI_STATUS FatSetVolumeEntry(IN FAT_VOLUME *Volume, IN CHAR16 *Name)
VOID FatSetCaseFlag(IN FAT_DIRENT *DirEnt)
Definition: FileName.c:293
INTN FatStriCmp(IN CHAR16 *Str1, IN CHAR16 *Str2)
VOID FatWaitNonblockingTask(FAT_IFILE *IFile)
Definition: Misc.c:75
BOOLEAN FatIsValidTime(IN EFI_TIME *Time)
Definition: Misc.c:573
EFI_STATUS FatCreateDotDirEnts(IN FAT_OFILE *OFile)
EFI_STATUS FatGetNextDirEnt(IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
EFI_STATUS EFIAPI FatFlushEx(IN EFI_FILE_PROTOCOL *FHand, IN EFI_FILE_IO_TOKEN *Token)
Definition: Flush.c:27
VOID FatComputeFreeInfo(IN FAT_VOLUME *Volume)
Definition: FileSpace.c:720
EFI_STATUS FatGetVolumeEntry(IN FAT_VOLUME *Volume, IN CHAR16 *Name)
UINT64 FatPhysicalFileSize(IN FAT_VOLUME *Volume, IN UINTN RealSize)
Definition: FileSpace.c:699
EFI_STATUS FatIFileClose(FAT_IFILE *IFile)
Definition: Flush.c:173
EFI_STATUS FatAllocateIFile(IN FAT_OFILE *OFile, OUT FAT_IFILE **PtrIFile)
Definition: Open.c:24
BOOLEAN FatCheckOFileRef(IN FAT_OFILE *OFile)
Definition: Flush.c:295
VOID FatCleanupODirCache(IN FAT_VOLUME *Volume)
VOID FatStrLwr(IN CHAR16 *Str)
EFI_STATUS EFIAPI FatFlush(IN EFI_FILE_PROTOCOL *FHand)
Definition: Flush.c:111
EFI_STATUS EFIAPI FatOpenVolume(IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, OUT EFI_FILE_PROTOCOL **File)
Definition: OpenVolume.c:25
VOID FatCreate8Dot3Name(IN FAT_OFILE *Parent, IN FAT_DIRENT *DirEnt)
Definition: FileName.c:169
EFI_STATUS FatShrinkEof(IN FAT_OFILE *OFile)
Definition: FileSpace.c:355
EFI_STATUS EFIAPI FatDelete(IN EFI_FILE_PROTOCOL *FHand)
Definition: Delete.c:24
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)
Definition: Misc.c:315
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)
Definition: Open.c:200
VOID FatSetVolumeError(IN FAT_OFILE *OFile, IN EFI_STATUS Status)
Definition: Flush.c:459
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)
Definition: Init.c:27
EFI_STATUS FatAccessOFile(IN FAT_OFILE *OFile, IN IO_MODE IoMode, IN UINTN Position, IN UINTN *DataBufferSize, IN UINT8 *UserBuffer, IN FAT_TASK *Task)
UINT8 FatCheckSum(IN CHAR8 *ShortNameString)
Definition: FileName.c:382
VOID FatCloneDirEnt(IN FAT_DIRENT *DirEnt1, IN FAT_DIRENT *DirEnt2)
EFI_STATUS FatAccessVolumeDirty(IN FAT_VOLUME *Volume, IN IO_MODE IoMode, IN VOID *DirtyValue)
Definition: Misc.c:230
VOID FatFreeDirEnt(IN FAT_DIRENT *DirEnt)
Definition: Misc.c:441
VOID FatAcquireLock(VOID)
Definition: Misc.c:395
EFI_STATUS EFIAPI FatClose(IN EFI_FILE_PROTOCOL *FHand)
Definition: Flush.c:129
EFI_STATUS FatAbandonVolume(IN FAT_VOLUME *Volume)
Definition: Init.c:144
EFI_STATUS EFIAPI FatSetInfo(IN EFI_FILE_PROTOCOL *FHand, IN EFI_GUID *Type, IN UINTN BufferSize, IN VOID *Buffer)
Definition: Info.c:594
EFI_STATUS FatOpenDirEnt(IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
VOID FatUpdateDirEntClusterSizeInfo(IN FAT_OFILE *OFile)
VOID FatReleaseLock(VOID)
Definition: Misc.c:426
VOID FatDeleteFromHashTable(IN FAT_ODIR *ODir, IN FAT_DIRENT *DirEnt)
Definition: Hash.c:165
EFI_STATUS EFIAPI FatSetPosition(IN EFI_FILE_PROTOCOL *FHand, IN UINT64 Position)
Definition: ReadWrite.c:64
EFI_STATUS EFIAPI FatOpen(IN EFI_FILE_PROTOCOL *FHand, OUT EFI_FILE_PROTOCOL **NewHandle, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT64 Attributes)
Definition: Open.c:318
VOID FatGetCurrentFatTime(OUT FAT_DATE_TIME *FatTime)
Definition: Misc.c:543
EFI_STATUS FatTruncateOFile(IN FAT_OFILE *OFile, IN UINTN TruncatedSize)
Definition: ReadWrite.c:622
CHAR16 * FatGetNextNameComponent(IN CHAR16 *Path, OUT CHAR16 *Name)
Definition: FileName.c:410
EFI_STATUS FatOFileOpen(IN FAT_OFILE *OFile, OUT FAT_IFILE **NewIFile, IN CHAR16 *FileName, IN UINT64 OpenMode, IN UINT8 Attributes)
Definition: Open.c:85
VOID FatResetODirCursor(IN FAT_OFILE *OFile)
VOID FatStrUpr(IN CHAR16 *Str)
BOOLEAN FatCheckIs8Dot3Name(IN CHAR16 *FileName, OUT CHAR8 *File8Dot3Name)
Definition: FileName.c:25
EFI_STATUS EFIAPI FatWriteEx(IN EFI_FILE_PROTOCOL *FHand, IN OUT EFI_FILE_IO_TOKEN *Token)
Definition: ReadWrite.c:435
VOID FatCloseDirEnt(IN FAT_DIRENT *DirEnt)
EFI_STATUS FatCleanupVolume(IN FAT_VOLUME *Volume, IN FAT_OFILE *OFile, IN EFI_STATUS EfiStatus, IN FAT_TASK *Task)
Definition: Flush.c:382
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)
Definition: DiskCache.c:493
EFI_STATUS InitializeUnicodeCollationSupport(IN EFI_HANDLE AgentHandle)
FAT_DIRENT ** FatLongNameHashSearch(IN FAT_ODIR *ODir, IN CHAR16 *LongNameString)
Definition: Hash.c:72
#define STATIC_ASSERT
Definition: Base.h:808
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
Definition: Fat.h:204
Definition: Fat.h:158
Definition: Fat.h:217
Definition: Fat.h:227
Definition: Base.h:213