]> git.proxmox.com Git - mirror_edk2.git/blob - FatPkg/EnhancedFatDxe/Fat.h
9490868ea756a8e8c9a549d561b8d48e345a438f
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Fat.h
1 /** @file
2 Main header file for EFI FAT file system driver.
3
4 Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _FAT_H_
16 #define _FAT_H_
17
18 #include <Uefi.h>
19
20 #include <Guid/FileInfo.h>
21 #include <Guid/FileSystemInfo.h>
22 #include <Guid/FileSystemVolumeLabelInfo.h>
23 #include <Protocol/BlockIo.h>
24 #include <Protocol/DiskIo.h>
25 #include <Protocol/DiskIo2.h>
26 #include <Protocol/SimpleFileSystem.h>
27 #include <Protocol/UnicodeCollation.h>
28
29 #include <Library/PcdLib.h>
30 #include <Library/DebugLib.h>
31 #include <Library/UefiLib.h>
32 #include <Library/BaseLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/UefiDriverEntryPoint.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiRuntimeServicesTableLib.h>
38
39 #include "FatFileSystem.h"
40
41 //
42 // The FAT signature
43 //
44 #define FAT_VOLUME_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'v')
45 #define FAT_IFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'i')
46 #define FAT_ODIR_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'd')
47 #define FAT_DIRENT_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'e')
48 #define FAT_OFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'o')
49 #define FAT_TASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'T')
50 #define FAT_SUBTASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'S')
51
52 #define ASSERT_VOLUME_LOCKED(a) ASSERT_LOCKED (&FatFsLock)
53
54 #define IFILE_FROM_FHAND(a) CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)
55
56 #define DIRENT_FROM_LINK(a) CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)
57
58 #define VOLUME_FROM_ROOT_DIRENT(a) CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)
59
60 #define VOLUME_FROM_VOL_INTERFACE(a) CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);
61
62 #define ODIR_FROM_DIRCACHELINK(a) CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)
63
64 #define OFILE_FROM_CHECKLINK(a) CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)
65
66 #define OFILE_FROM_CHILDLINK(a) CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)
67
68 //
69 // Minimum sector size is 512B, Maximum sector size is 4096B
70 // Max sectors per cluster is 128
71 //
72 #define MAX_BLOCK_ALIGNMENT 12
73 #define MIN_BLOCK_ALIGNMENT 9
74 #define MAX_SECTORS_PER_CLUSTER_ALIGNMENT 7
75
76 //
77 // Efi Time Definition
78 //
79 #define IS_LEAP_YEAR(a) (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))
80
81 //
82 // Minimum fat page size is 8K, maximum fat page alignment is 32K
83 // Minimum data page size is 8K, maximum fat page alignment is 64K
84 //
85 #define FAT_FATCACHE_PAGE_MIN_ALIGNMENT 13
86 #define FAT_FATCACHE_PAGE_MAX_ALIGNMENT 15
87 #define FAT_DATACACHE_PAGE_MIN_ALIGNMENT 13
88 #define FAT_DATACACHE_PAGE_MAX_ALIGNMENT 16
89 #define FAT_DATACACHE_GROUP_COUNT 64
90 #define FAT_FATCACHE_GROUP_MIN_COUNT 1
91 #define FAT_FATCACHE_GROUP_MAX_COUNT 16
92
93 //
94 // Used in 8.3 generation algorithm
95 //
96 #define MAX_SPEC_RETRY 4
97 #define SPEC_BASE_TAG_LEN 6
98 #define HASH_BASE_TAG_LEN 2
99 #define HASH_VALUE_TAG_LEN (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)
100
101 //
102 // Path name separator is back slash
103 //
104 #define PATH_NAME_SEPARATOR L'\\'
105
106
107 #define EFI_PATH_STRING_LENGTH 260
108 #define EFI_FILE_STRING_LENGTH 255
109 #define FAT_MAX_ALLOCATE_SIZE 0xA00000
110 #define LC_ISO_639_2_ENTRY_SIZE 3
111 #define MAX_LANG_CODE_SIZE 100
112
113 #define FAT_MAX_DIR_CACHE_COUNT 8
114 #define FAT_MAX_DIRENTRY_COUNT 0xFFFF
115 typedef CHAR8 LC_ISO_639_2;
116
117 //
118 // The fat types we support
119 //
120 typedef enum {
121 Fat12,
122 Fat16,
123 Fat32,
124 FatUndefined
125 } FAT_VOLUME_TYPE;
126
127 typedef enum {
128 CacheFat,
129 CacheData,
130 CacheMaxType
131 } CACHE_DATA_TYPE;
132
133 //
134 // Used in FatDiskIo
135 //
136 typedef enum {
137 ReadDisk = 0, // raw disk read
138 WriteDisk = 1, // raw disk write
139 ReadFat = 2, // read fat cache
140 WriteFat = 3, // write fat cache
141 ReadData = 6, // read data cache
142 WriteData = 7 // write data cache
143 } IO_MODE;
144
145 #define CACHE_ENABLED(a) ((a) >= 2)
146 #define RAW_ACCESS(a) ((IO_MODE)((a) & 0x1))
147 #define CACHE_TYPE(a) ((CACHE_DATA_TYPE)((a) >> 2))
148
149 //
150 // Disk cache tag
151 //
152 typedef struct {
153 UINTN PageNo;
154 UINTN RealSize;
155 BOOLEAN Dirty;
156 } CACHE_TAG;
157
158 typedef struct {
159 UINT64 BaseAddress;
160 UINT64 LimitAddress;
161 UINT8 *CacheBase;
162 BOOLEAN Dirty;
163 UINT8 PageAlignment;
164 UINTN GroupMask;
165 CACHE_TAG CacheTag[FAT_DATACACHE_GROUP_COUNT];
166 } DISK_CACHE;
167
168 //
169 // Hash table size
170 //
171 #define HASH_TABLE_SIZE 0x400
172 #define HASH_TABLE_MASK (HASH_TABLE_SIZE - 1)
173
174 //
175 // The directory entry for opened directory
176 //
177
178 typedef struct _FAT_DIRENT FAT_DIRENT;
179 typedef struct _FAT_ODIR FAT_ODIR;
180 typedef struct _FAT_OFILE FAT_OFILE;
181 typedef struct _FAT_VOLUME FAT_VOLUME;
182
183 struct _FAT_DIRENT {
184 UINTN Signature;
185 UINT16 EntryPos; // The position of this directory entry in the parent directory file
186 UINT8 EntryCount; // The count of the directory entry in the parent directory file
187 BOOLEAN Invalid; // Indicate whether this directory entry is valid
188 CHAR16 *FileString; // The unicode long file name for this directory entry
189 FAT_OFILE *OFile; // The OFile of the corresponding directory entry
190 FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename
191 FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename
192 LIST_ENTRY Link; // Connection of every directory entry
193 FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk
194 };
195
196 struct _FAT_ODIR {
197 UINTN Signature;
198 UINT32 CurrentEndPos; // Current end position of the directory
199 UINT32 CurrentPos; // Current position of the directory
200 LIST_ENTRY *CurrentCursor; // Current directory entry pointer
201 LIST_ENTRY ChildList; // List of all directory entries
202 BOOLEAN EndOfDir; // Indicate whether we have reached the end of the directory
203 LIST_ENTRY DirCacheLink; // Linked in Volume->DirCacheList when discarded
204 UINTN DirCacheTag; // The identification of the directory when in directory cache
205 FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];
206 FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];
207 };
208
209 typedef struct {
210 UINTN Signature;
211 EFI_FILE_PROTOCOL Handle;
212 UINT64 Position;
213 BOOLEAN ReadOnly;
214 FAT_OFILE *OFile;
215 LIST_ENTRY Tasks; // List of all FAT_TASKs
216 LIST_ENTRY Link; // Link to other IFiles
217 } FAT_IFILE;
218
219 typedef struct {
220 UINTN Signature;
221 EFI_FILE_IO_TOKEN *FileIoToken;
222 FAT_IFILE *IFile;
223 LIST_ENTRY Subtasks; // List of all FAT_SUBTASKs
224 LIST_ENTRY Link; // Link to other FAT_TASKs
225 } FAT_TASK;
226
227 typedef struct {
228 UINTN Signature;
229 EFI_DISK_IO2_TOKEN DiskIo2Token;
230 FAT_TASK *Task;
231 BOOLEAN Write;
232 UINT64 Offset;
233 VOID *Buffer;
234 UINTN BufferSize;
235 LIST_ENTRY Link;
236 } FAT_SUBTASK;
237
238 //
239 // FAT_OFILE - Each opened file
240 //
241 struct _FAT_OFILE {
242 UINTN Signature;
243 FAT_VOLUME *Volume;
244 //
245 // A permanant error code to return to all accesses to
246 // this opened file
247 //
248 EFI_STATUS Error;
249 //
250 // A list of the IFILE instances for this OFile
251 //
252 LIST_ENTRY Opens;
253
254 //
255 // The dynamic infomation
256 //
257 UINTN FileSize;
258 UINTN FileCluster;
259 UINTN FileCurrentCluster;
260 UINTN FileLastCluster;
261
262 //
263 // Dirty is set if there have been any updates to the
264 // file
265 // Archive is set if the archive attribute in the file's
266 // directory entry needs to be set when performing flush
267 // PreserveLastMod is set if the last modification of the
268 // file is specified by SetInfo API
269 //
270 BOOLEAN Dirty;
271 BOOLEAN IsFixedRootDir;
272 BOOLEAN PreserveLastModification;
273 BOOLEAN Archive;
274 //
275 // Set by an OFile SetPosition
276 //
277 UINTN Position; // within file
278 UINT64 PosDisk; // on the disk
279 UINTN PosRem; // remaining in this disk run
280 //
281 // The opened parent, full path length and currently opened child files
282 //
283 FAT_OFILE *Parent;
284 UINTN FullPathLen;
285 LIST_ENTRY ChildHead;
286 LIST_ENTRY ChildLink;
287
288 //
289 // The opened directory structure for a directory; if this
290 // OFile represents a file, then ODir = NULL
291 //
292 FAT_ODIR *ODir;
293 //
294 // The directory entry for the Ofile
295 //
296 FAT_DIRENT *DirEnt;
297
298 //
299 // Link in Volume's reference list
300 //
301 LIST_ENTRY CheckLink;
302 };
303
304 struct _FAT_VOLUME {
305 UINTN Signature;
306
307 EFI_HANDLE Handle;
308 BOOLEAN Valid;
309 BOOLEAN DiskError;
310
311 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL VolumeInterface;
312
313 //
314 // If opened, the parent handle and BlockIo interface
315 //
316 EFI_BLOCK_IO_PROTOCOL *BlockIo;
317 EFI_DISK_IO_PROTOCOL *DiskIo;
318 EFI_DISK_IO2_PROTOCOL *DiskIo2;
319 UINT32 MediaId;
320 BOOLEAN ReadOnly;
321
322 //
323 // Computed values from fat bpb info
324 //
325 UINT64 VolumeSize;
326 UINT64 FatPos; // Disk pos of fat tables
327 UINT64 RootPos; // Disk pos of root directory
328 UINT64 FirstClusterPos; // Disk pos of first cluster
329 UINTN FatSize; // Number of bytes in each fat
330 UINTN MaxCluster; // Max cluster number
331 UINTN ClusterSize; // Cluster size of fat partition
332 UINT8 ClusterAlignment; // Equal to log_2 (clustersize);
333 FAT_VOLUME_TYPE FatType;
334
335 //
336 // Current part of fat table that's present
337 //
338 UINT64 FatEntryPos; // Location of buffer
339 UINTN FatEntrySize; // Size of buffer
340 UINT32 FatEntryBuffer; // The buffer
341 FAT_INFO_SECTOR FatInfoSector; // Free cluster info
342 UINTN FreeInfoPos; // Pos with the free cluster info
343 BOOLEAN FreeInfoValid; // If free cluster info is valid
344 //
345 // Unpacked Fat BPB info
346 //
347 UINTN NumFats;
348 UINTN RootEntries; // < FAT32, root dir is fixed size
349 UINTN RootCluster; // >= FAT32, root cluster chain head
350 //
351 // info for marking the volume dirty or not
352 //
353 BOOLEAN FatDirty; // If fat-entries have been updated
354 UINT32 DirtyValue;
355 UINT32 NotDirtyValue;
356
357 //
358 // The root directory entry and opened root file
359 //
360 FAT_DIRENT RootDirEnt;
361 //
362 // File Name of root OFile, it is empty string
363 //
364 CHAR16 RootFileString[1];
365 FAT_OFILE *Root;
366
367 //
368 // New OFiles are added to this list so they
369 // can be cleaned up if they aren't referenced.
370 //
371 LIST_ENTRY CheckRef;
372
373 //
374 // Directory cache List
375 //
376 LIST_ENTRY DirCacheList;
377 UINTN DirCacheCount;
378
379 //
380 // Disk Cache for this volume
381 //
382 VOID *CacheBuffer;
383 DISK_CACHE DiskCache[CacheMaxType];
384 };
385
386 //
387 // Function Prototypes
388 //
389
390 /**
391
392 Implements Open() of Simple File System Protocol.
393
394 @param FHand - File handle of the file serves as a starting reference point.
395 @param NewHandle - Handle of the file that is newly opened.
396 @param FileName - File name relative to FHand.
397 @param OpenMode - Open mode.
398 @param Attributes - Attributes to set if the file is created.
399
400
401 @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.
402 The OpenMode is not supported.
403 The Attributes is not the valid attributes.
404 @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
405 @retval EFI_SUCCESS - Open the file successfully.
406 @return Others - The status of open file.
407
408 **/
409 EFI_STATUS
410 EFIAPI
411 FatOpen (
412 IN EFI_FILE_PROTOCOL *FHand,
413 OUT EFI_FILE_PROTOCOL **NewHandle,
414 IN CHAR16 *FileName,
415 IN UINT64 OpenMode,
416 IN UINT64 Attributes
417 )
418 ;
419
420 /**
421
422 Implements OpenEx() of Simple File System Protocol.
423
424 @param FHand - File handle of the file serves as a starting reference point.
425 @param NewHandle - Handle of the file that is newly opened.
426 @param FileName - File name relative to FHand.
427 @param OpenMode - Open mode.
428 @param Attributes - Attributes to set if the file is created.
429 @param Token - A pointer to the token associated with the transaction.
430
431 @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.
432 The OpenMode is not supported.
433 The Attributes is not the valid attributes.
434 @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
435 @retval EFI_SUCCESS - Open the file successfully.
436 @return Others - The status of open file.
437
438 **/
439 EFI_STATUS
440 EFIAPI
441 FatOpenEx (
442 IN EFI_FILE_PROTOCOL *FHand,
443 OUT EFI_FILE_PROTOCOL **NewHandle,
444 IN CHAR16 *FileName,
445 IN UINT64 OpenMode,
446 IN UINT64 Attributes,
447 IN OUT EFI_FILE_IO_TOKEN *Token
448 )
449 ;
450
451 /**
452
453 Get the file's position of the file
454
455 @param FHand - The handle of file.
456 @param Position - The file's position of the file.
457
458 @retval EFI_SUCCESS - Get the info successfully.
459 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
460 @retval EFI_UNSUPPORTED - The open file is not a file.
461
462 **/
463 EFI_STATUS
464 EFIAPI
465 FatGetPosition (
466 IN EFI_FILE_PROTOCOL *FHand,
467 OUT UINT64 *Position
468 )
469 ;
470
471 /**
472
473 Get the some types info of the file into Buffer
474
475 @param FHand - The handle of file.
476 @param Type - The type of the info.
477 @param BufferSize - Size of Buffer.
478 @param Buffer - Buffer containing volume info.
479
480 @retval EFI_SUCCESS - Get the info successfully.
481 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
482
483 **/
484 EFI_STATUS
485 EFIAPI
486 FatGetInfo (
487 IN EFI_FILE_PROTOCOL *FHand,
488 IN EFI_GUID *Type,
489 IN OUT UINTN *BufferSize,
490 OUT VOID *Buffer
491 )
492 ;
493
494 /**
495
496 Set the some types info of the file into Buffer.
497
498 @param FHand - The handle of file.
499 @param Type - The type of the info.
500 @param BufferSize - Size of Buffer.
501 @param Buffer - Buffer containing volume info.
502
503 @retval EFI_SUCCESS - Set the info successfully.
504 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
505
506 **/
507 EFI_STATUS
508 EFIAPI
509 FatSetInfo (
510 IN EFI_FILE_PROTOCOL *FHand,
511 IN EFI_GUID *Type,
512 IN UINTN BufferSize,
513 IN VOID *Buffer
514 )
515 ;
516
517 /**
518
519 Flushes all data associated with the file handle.
520
521 @param FHand - Handle to file to flush
522
523 @retval EFI_SUCCESS - Flushed the file successfully
524 @retval EFI_WRITE_PROTECTED - The volume is read only
525 @retval EFI_ACCESS_DENIED - The volume is not read only
526 but the file is read only
527 @return Others - Flushing of the file is failed
528
529 **/
530 EFI_STATUS
531 EFIAPI
532 FatFlush (
533 IN EFI_FILE_PROTOCOL *FHand
534 )
535 ;
536
537 /**
538
539 Flushes all data associated with the file handle.
540
541 @param FHand - Handle to file to flush.
542 @param Token - A pointer to the token associated with the transaction.
543
544 @retval EFI_SUCCESS - Flushed the file successfully.
545 @retval EFI_WRITE_PROTECTED - The volume is read only.
546 @retval EFI_ACCESS_DENIED - The file is read only.
547 @return Others - Flushing of the file failed.
548
549 **/
550 EFI_STATUS
551 EFIAPI
552 FatFlushEx (
553 IN EFI_FILE_PROTOCOL *FHand,
554 IN EFI_FILE_IO_TOKEN *Token
555 )
556 ;
557
558 /**
559
560 Flushes & Closes the file handle.
561
562 @param FHand - Handle to the file to delete.
563
564 @retval EFI_SUCCESS - Closed the file successfully.
565
566 **/
567 EFI_STATUS
568 EFIAPI
569 FatClose (
570 IN EFI_FILE_PROTOCOL *FHand
571 )
572 ;
573
574 /**
575
576 Deletes the file & Closes the file handle.
577
578 @param FHand - Handle to the file to delete.
579
580 @retval EFI_SUCCESS - Delete the file successfully.
581 @retval EFI_WARN_DELETE_FAILURE - Fail to delete the file.
582
583 **/
584 EFI_STATUS
585 EFIAPI
586 FatDelete (
587 IN EFI_FILE_PROTOCOL *FHand
588 )
589 ;
590
591 /**
592
593 Set the file's position of the file.
594
595 @param FHand - The handle of file
596 @param Position - The file's position of the file
597
598 @retval EFI_SUCCESS - Set the info successfully
599 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file
600 @retval EFI_UNSUPPORTED - Set a directory with a not-zero position
601
602 **/
603 EFI_STATUS
604 EFIAPI
605 FatSetPosition (
606 IN EFI_FILE_PROTOCOL *FHand,
607 IN UINT64 Position
608 )
609 ;
610
611 /**
612
613 Get the file info.
614
615 @param FHand - The handle of the file.
616 @param BufferSize - Size of Buffer.
617 @param Buffer - Buffer containing read data.
618
619 @retval EFI_SUCCESS - Get the file info successfully.
620 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
621 @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
622 @return other - An error occurred when operation the disk.
623
624 **/
625 EFI_STATUS
626 EFIAPI
627 FatRead (
628 IN EFI_FILE_PROTOCOL *FHand,
629 IN OUT UINTN *BufferSize,
630 OUT VOID *Buffer
631 )
632 ;
633
634 /**
635
636 Get the file info.
637
638 @param FHand - The handle of the file.
639 @param Token - A pointer to the token associated with the transaction.
640
641 @retval EFI_SUCCESS - Get the file info successfully.
642 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
643 @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
644 @return other - An error occurred when operation the disk.
645
646 **/
647 EFI_STATUS
648 EFIAPI
649 FatReadEx (
650 IN EFI_FILE_PROTOCOL *FHand,
651 IN OUT EFI_FILE_IO_TOKEN *Token
652 )
653 ;
654
655 /**
656
657 Set the file info.
658
659 @param FHand - The handle of the file.
660 @param BufferSize - Size of Buffer.
661 @param Buffer - Buffer containing write data.
662
663 @retval EFI_SUCCESS - Set the file info successfully.
664 @retval EFI_WRITE_PROTECTED - The disk is write protected.
665 @retval EFI_ACCESS_DENIED - The file is read-only.
666 @retval EFI_DEVICE_ERROR - The OFile is not valid.
667 @retval EFI_UNSUPPORTED - The open file is not a file.
668 - The writing file size is larger than 4GB.
669 @return other - An error occurred when operation the disk.
670
671 **/
672 EFI_STATUS
673 EFIAPI
674 FatWrite (
675 IN EFI_FILE_PROTOCOL *FHand,
676 IN OUT UINTN *BufferSize,
677 IN VOID *Buffer
678 )
679 ;
680
681 /**
682
683 Get the file info.
684
685 @param FHand - The handle of the file.
686 @param Token - A pointer to the token associated with the transaction.
687
688 @retval EFI_SUCCESS - Get the file info successfully.
689 @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
690 @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
691 @return other - An error occurred when operation the disk.
692
693 **/
694 EFI_STATUS
695 EFIAPI
696 FatWriteEx (
697 IN EFI_FILE_PROTOCOL *FHand,
698 IN OUT EFI_FILE_IO_TOKEN *Token
699 )
700 ;
701
702 //
703 // DiskCache.c
704 //
705 EFI_STATUS
706 FatInitializeDiskCache (
707 IN FAT_VOLUME *Volume
708 );
709
710 EFI_STATUS
711 FatAccessCache (
712 IN FAT_VOLUME *Volume,
713 IN CACHE_DATA_TYPE CacheDataType,
714 IN IO_MODE IoMode,
715 IN UINT64 Offset,
716 IN UINTN BufferSize,
717 IN OUT UINT8 *Buffer,
718 IN FAT_TASK *Task
719 );
720
721 EFI_STATUS
722 FatVolumeFlushCache (
723 IN FAT_VOLUME *Volume,
724 IN FAT_TASK *Task
725 );
726
727 //
728 // Flush.c
729 //
730 EFI_STATUS
731 FatOFileFlush (
732 IN FAT_OFILE *OFile
733 );
734
735 BOOLEAN
736 FatCheckOFileRef (
737 IN FAT_OFILE *OFile
738 );
739
740 VOID
741 FatSetVolumeError (
742 IN FAT_OFILE *OFile,
743 IN EFI_STATUS Status
744 );
745
746 EFI_STATUS
747 FatIFileClose (
748 FAT_IFILE *IFile
749 );
750
751 EFI_STATUS
752 FatCleanupVolume (
753 IN FAT_VOLUME *Volume,
754 IN FAT_OFILE *OFile,
755 IN EFI_STATUS EfiStatus,
756 IN FAT_TASK *Task
757 );
758
759 //
760 // FileSpace.c
761 //
762 EFI_STATUS
763 FatShrinkEof (
764 IN FAT_OFILE *OFile
765 );
766
767 EFI_STATUS
768 FatGrowEof (
769 IN FAT_OFILE *OFile,
770 IN UINT64 NewSizeInBytes
771 );
772
773 UINTN
774 FatPhysicalDirSize (
775 IN FAT_VOLUME *Volume,
776 IN UINTN Cluster
777 );
778
779 UINT64
780 FatPhysicalFileSize (
781 IN FAT_VOLUME *Volume,
782 IN UINTN RealSize
783 );
784
785 EFI_STATUS
786 FatOFilePosition (
787 IN FAT_OFILE *OFile,
788 IN UINTN Position,
789 IN UINTN PosLimit
790 );
791
792 VOID
793 FatComputeFreeInfo (
794 IN FAT_VOLUME *Volume
795 );
796
797 //
798 // Init.c
799 //
800 EFI_STATUS
801 FatAllocateVolume (
802 IN EFI_HANDLE Handle,
803 IN EFI_DISK_IO_PROTOCOL *DiskIo,
804 IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
805 IN EFI_BLOCK_IO_PROTOCOL *BlockIo
806 );
807
808 EFI_STATUS
809 FatOpenDevice (
810 IN OUT FAT_VOLUME *Volume
811 );
812
813 EFI_STATUS
814 FatAbandonVolume (
815 IN FAT_VOLUME *Volume
816 );
817
818 //
819 // Misc.c
820 //
821 FAT_TASK *
822 FatCreateTask (
823 FAT_IFILE *IFile,
824 EFI_FILE_IO_TOKEN *Token
825 );
826
827 VOID
828 FatDestroyTask (
829 FAT_TASK *Task
830 );
831
832 VOID
833 FatWaitNonblockingTask (
834 FAT_IFILE *IFile
835 );
836
837 LIST_ENTRY *
838 FatDestroySubtask (
839 FAT_SUBTASK *Subtask
840 );
841
842 EFI_STATUS
843 FatQueueTask (
844 IN FAT_IFILE *IFile,
845 IN FAT_TASK *Task
846 );
847
848 EFI_STATUS
849 FatAccessVolumeDirty (
850 IN FAT_VOLUME *Volume,
851 IN IO_MODE IoMode,
852 IN VOID *DirtyValue
853 );
854
855 EFI_STATUS
856 FatDiskIo (
857 IN FAT_VOLUME *Volume,
858 IN IO_MODE IoMode,
859 IN UINT64 Offset,
860 IN UINTN BufferSize,
861 IN OUT VOID *Buffer,
862 IN FAT_TASK *Task
863 );
864
865 VOID
866 FatAcquireLock (
867 VOID
868 );
869
870 VOID
871 FatReleaseLock (
872 VOID
873 );
874
875 EFI_STATUS
876 FatAcquireLockOrFail (
877 VOID
878 );
879
880 VOID
881 FatFreeDirEnt (
882 IN FAT_DIRENT *DirEnt
883 );
884
885 VOID
886 FatFreeVolume (
887 IN FAT_VOLUME *Volume
888 );
889
890 VOID
891 FatEfiTimeToFatTime (
892 IN EFI_TIME *ETime,
893 OUT FAT_DATE_TIME *FTime
894 );
895
896 VOID
897 FatFatTimeToEfiTime (
898 IN FAT_DATE_TIME *FTime,
899 OUT EFI_TIME *ETime
900 );
901
902 VOID
903 FatGetCurrentFatTime (
904 OUT FAT_DATE_TIME *FatTime
905 );
906
907 BOOLEAN
908 FatIsValidTime (
909 IN EFI_TIME *Time
910 );
911
912 //
913 // UnicodeCollation.c
914 //
915 EFI_STATUS
916 InitializeUnicodeCollationSupport (
917 IN EFI_HANDLE AgentHandle
918 );
919
920 VOID
921 FatFatToStr (
922 IN UINTN FatSize,
923 IN CHAR8 *Fat,
924 OUT CHAR16 *String
925 );
926
927 BOOLEAN
928 FatStrToFat (
929 IN CHAR16 *String,
930 IN UINTN FatSize,
931 OUT CHAR8 *Fat
932 );
933
934 VOID
935 FatStrLwr (
936 IN CHAR16 *Str
937 );
938
939 VOID
940 FatStrUpr (
941 IN CHAR16 *Str
942 );
943
944 INTN
945 FatStriCmp (
946 IN CHAR16 *Str1,
947 IN CHAR16 *Str2
948 );
949
950 //
951 // Open.c
952 //
953 EFI_STATUS
954 FatOFileOpen (
955 IN FAT_OFILE *OFile,
956 OUT FAT_IFILE **NewIFile,
957 IN CHAR16 *FileName,
958 IN UINT64 OpenMode,
959 IN UINT8 Attributes
960 );
961
962 EFI_STATUS
963 FatAllocateIFile (
964 IN FAT_OFILE *OFile,
965 OUT FAT_IFILE **PtrIFile
966 );
967
968 //
969 // OpenVolume.c
970 //
971 EFI_STATUS
972 EFIAPI
973 FatOpenVolume (
974 IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
975 OUT EFI_FILE_PROTOCOL **File
976 );
977
978 //
979 // ReadWrite.c
980 //
981 EFI_STATUS
982 FatAccessOFile (
983 IN FAT_OFILE *OFile,
984 IN IO_MODE IoMode,
985 IN UINTN Position,
986 IN UINTN *DataBufferSize,
987 IN UINT8 *UserBuffer,
988 IN FAT_TASK *Task
989 );
990
991 EFI_STATUS
992 FatExpandOFile (
993 IN FAT_OFILE *OFile,
994 IN UINT64 ExpandedSize
995 );
996
997 EFI_STATUS
998 FatWriteZeroPool (
999 IN FAT_OFILE *OFile,
1000 IN UINTN WritePos
1001 );
1002
1003 EFI_STATUS
1004 FatTruncateOFile (
1005 IN FAT_OFILE *OFile,
1006 IN UINTN TruncatedSize
1007 );
1008
1009 //
1010 // DirectoryManage.c
1011 //
1012 VOID
1013 FatResetODirCursor (
1014 IN FAT_OFILE *OFile
1015 );
1016
1017 EFI_STATUS
1018 FatGetNextDirEnt (
1019 IN FAT_OFILE *OFile,
1020 OUT FAT_DIRENT **PtrDirEnt
1021 );
1022
1023 EFI_STATUS
1024 FatRemoveDirEnt (
1025 IN FAT_OFILE *OFile,
1026 IN FAT_DIRENT *DirEnt
1027 );
1028
1029 EFI_STATUS
1030 FatStoreDirEnt (
1031 IN FAT_OFILE *OFile,
1032 IN FAT_DIRENT *DirEnt
1033 );
1034
1035 EFI_STATUS
1036 FatCreateDirEnt (
1037 IN FAT_OFILE *OFile,
1038 IN CHAR16 *FileName,
1039 IN UINT8 Attributes,
1040 OUT FAT_DIRENT **PtrDirEnt
1041 );
1042
1043 BOOLEAN
1044 FatIsDotDirEnt (
1045 IN FAT_DIRENT *DirEnt
1046 );
1047
1048 VOID
1049 FatUpdateDirEntClusterSizeInfo (
1050 IN FAT_OFILE *OFile
1051 );
1052
1053 VOID
1054 FatCloneDirEnt (
1055 IN FAT_DIRENT *DirEnt1,
1056 IN FAT_DIRENT *DirEnt2
1057 );
1058
1059 EFI_STATUS
1060 FatGetDirEntInfo (
1061 IN FAT_VOLUME *Volume,
1062 IN FAT_DIRENT *DirEnt,
1063 IN OUT UINTN *BufferSize,
1064 OUT VOID *Buffer
1065 );
1066
1067 EFI_STATUS
1068 FatOpenDirEnt (
1069 IN FAT_OFILE *OFile,
1070 IN FAT_DIRENT *DirEnt
1071 );
1072
1073 EFI_STATUS
1074 FatCreateDotDirEnts (
1075 IN FAT_OFILE *OFile
1076 );
1077
1078 VOID
1079 FatCloseDirEnt (
1080 IN FAT_DIRENT *DirEnt
1081 );
1082
1083 EFI_STATUS
1084 FatLocateOFile (
1085 IN OUT FAT_OFILE **PtrOFile,
1086 IN CHAR16 *FileName,
1087 IN UINT8 Attributes,
1088 OUT CHAR16 *NewFileName
1089 );
1090
1091 EFI_STATUS
1092 FatGetVolumeEntry (
1093 IN FAT_VOLUME *Volume,
1094 IN CHAR16 *Name
1095 );
1096
1097 EFI_STATUS
1098 FatSetVolumeEntry (
1099 IN FAT_VOLUME *Volume,
1100 IN CHAR16 *Name
1101 );
1102
1103 //
1104 // Hash.c
1105 //
1106 FAT_DIRENT **
1107 FatLongNameHashSearch (
1108 IN FAT_ODIR *ODir,
1109 IN CHAR16 *LongNameString
1110 );
1111
1112 FAT_DIRENT **
1113 FatShortNameHashSearch (
1114 IN FAT_ODIR *ODir,
1115 IN CHAR8 *ShortNameString
1116 );
1117
1118 VOID
1119 FatInsertToHashTable (
1120 IN FAT_ODIR *ODir,
1121 IN FAT_DIRENT *DirEnt
1122 );
1123
1124 VOID
1125 FatDeleteFromHashTable (
1126 IN FAT_ODIR *ODir,
1127 IN FAT_DIRENT *DirEnt
1128 );
1129
1130 //
1131 // FileName.c
1132 //
1133 BOOLEAN
1134 FatCheckIs8Dot3Name (
1135 IN CHAR16 *FileName,
1136 OUT CHAR8 *File8Dot3Name
1137 );
1138
1139 VOID
1140 FatCreate8Dot3Name (
1141 IN FAT_OFILE *Parent,
1142 IN FAT_DIRENT *DirEnt
1143 );
1144
1145 VOID
1146 FatNameToStr (
1147 IN CHAR8 *FatName,
1148 IN UINTN Len,
1149 IN UINTN LowerCase,
1150 IN CHAR16 *Str
1151 );
1152
1153 VOID
1154 FatSetCaseFlag (
1155 IN FAT_DIRENT *DirEnt
1156 );
1157
1158 VOID
1159 FatGetFileNameViaCaseFlag (
1160 IN FAT_DIRENT *DirEnt,
1161 IN OUT CHAR16 *FileString,
1162 IN UINTN FileStringMax
1163 );
1164
1165 UINT8
1166 FatCheckSum (
1167 IN CHAR8 *ShortNameString
1168 );
1169
1170 CHAR16*
1171 FatGetNextNameComponent (
1172 IN CHAR16 *Path,
1173 OUT CHAR16 *Name
1174 );
1175
1176 BOOLEAN
1177 FatFileNameIsValid (
1178 IN CHAR16 *InputFileName,
1179 OUT CHAR16 *OutputFileName
1180 );
1181
1182 //
1183 // DirectoryCache.c
1184 //
1185 VOID
1186 FatDiscardODir (
1187 IN FAT_OFILE *OFile
1188 );
1189
1190 VOID
1191 FatRequestODir (
1192 IN FAT_OFILE *OFile
1193 );
1194
1195 VOID
1196 FatCleanupODirCache (
1197 IN FAT_VOLUME *Volume
1198 );
1199
1200 //
1201 // Global Variables
1202 //
1203 extern EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding;
1204 extern EFI_COMPONENT_NAME_PROTOCOL gFatComponentName;
1205 extern EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2;
1206 extern EFI_LOCK FatFsLock;
1207 extern EFI_LOCK FatTaskLock;
1208 extern EFI_FILE_PROTOCOL FatFileInterface;
1209
1210 #endif