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