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