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 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #ifndef _FAT_H_
|
---|
10 | #define _FAT_H_
|
---|
11 |
|
---|
12 | #include <Uefi.h>
|
---|
13 |
|
---|
14 | #include <Guid/FileInfo.h>
|
---|
15 | #include <Guid/FileSystemInfo.h>
|
---|
16 | #include <Guid/FileSystemVolumeLabelInfo.h>
|
---|
17 | #include <Protocol/BlockIo.h>
|
---|
18 | #include <Protocol/DiskIo.h>
|
---|
19 | #include <Protocol/DiskIo2.h>
|
---|
20 | #include <Protocol/SimpleFileSystem.h>
|
---|
21 | #include <Protocol/UnicodeCollation.h>
|
---|
22 |
|
---|
23 | #include <Library/PcdLib.h>
|
---|
24 | #include <Library/DebugLib.h>
|
---|
25 | #include <Library/UefiLib.h>
|
---|
26 | #include <Library/BaseLib.h>
|
---|
27 | #include <Library/BaseMemoryLib.h>
|
---|
28 | #include <Library/MemoryAllocationLib.h>
|
---|
29 | #include <Library/UefiDriverEntryPoint.h>
|
---|
30 | #include <Library/UefiBootServicesTableLib.h>
|
---|
31 | #include <Library/UefiRuntimeServicesTableLib.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 | //
|
---|
88 | // Used in 8.3 generation algorithm
|
---|
89 | //
|
---|
90 | #define MAX_SPEC_RETRY 4
|
---|
91 | #define SPEC_BASE_TAG_LEN 6
|
---|
92 | #define HASH_BASE_TAG_LEN 2
|
---|
93 | #define HASH_VALUE_TAG_LEN (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)
|
---|
94 |
|
---|
95 | //
|
---|
96 | // Path name separator is back slash
|
---|
97 | //
|
---|
98 | #define PATH_NAME_SEPARATOR L'\\'
|
---|
99 |
|
---|
100 | #define EFI_PATH_STRING_LENGTH 260
|
---|
101 | #define EFI_FILE_STRING_LENGTH 255
|
---|
102 | #define FAT_MAX_ALLOCATE_SIZE 0xA00000
|
---|
103 | #define LC_ISO_639_2_ENTRY_SIZE 3
|
---|
104 | #define MAX_LANG_CODE_SIZE 100
|
---|
105 |
|
---|
106 | #define FAT_MAX_DIR_CACHE_COUNT 8
|
---|
107 | #define FAT_MAX_DIRENTRY_COUNT 0xFFFF
|
---|
108 | typedef CHAR8 LC_ISO_639_2;
|
---|
109 |
|
---|
110 | //
|
---|
111 | // The fat types we support
|
---|
112 | //
|
---|
113 | typedef enum {
|
---|
114 | Fat12,
|
---|
115 | Fat16,
|
---|
116 | Fat32,
|
---|
117 | FatUndefined
|
---|
118 | } FAT_VOLUME_TYPE;
|
---|
119 |
|
---|
120 | typedef enum {
|
---|
121 | CacheFat,
|
---|
122 | CacheData,
|
---|
123 | CacheMaxType
|
---|
124 | } CACHE_DATA_TYPE;
|
---|
125 |
|
---|
126 | //
|
---|
127 | // Used in FatDiskIo
|
---|
128 | //
|
---|
129 | typedef enum {
|
---|
130 | ReadDisk = 0, // raw disk read
|
---|
131 | WriteDisk = 1, // raw disk write
|
---|
132 | ReadFat = 2, // read fat cache
|
---|
133 | WriteFat = 3, // write fat cache
|
---|
134 | ReadData = 6, // read data cache
|
---|
135 | WriteData = 7 // write data cache
|
---|
136 | } IO_MODE;
|
---|
137 |
|
---|
138 | #define CACHE_ENABLED(a) ((a) >= 2)
|
---|
139 | #define RAW_ACCESS(a) ((IO_MODE)((a) & 0x1))
|
---|
140 | #define CACHE_TYPE(a) ((CACHE_DATA_TYPE)((a) >> 2))
|
---|
141 |
|
---|
142 | //
|
---|
143 | // Disk cache tag
|
---|
144 | //
|
---|
145 | typedef struct {
|
---|
146 | UINTN PageNo;
|
---|
147 | UINTN RealSize;
|
---|
148 | BOOLEAN Dirty;
|
---|
149 | } CACHE_TAG;
|
---|
150 |
|
---|
151 | typedef struct {
|
---|
152 | UINT64 BaseAddress;
|
---|
153 | UINT64 LimitAddress;
|
---|
154 | UINT8 *CacheBase;
|
---|
155 | BOOLEAN Dirty;
|
---|
156 | UINT8 PageAlignment;
|
---|
157 | UINTN GroupMask;
|
---|
158 | CACHE_TAG CacheTag[FAT_DATACACHE_GROUP_COUNT];
|
---|
159 | } DISK_CACHE;
|
---|
160 |
|
---|
161 | //
|
---|
162 | // Hash table size
|
---|
163 | //
|
---|
164 | #define HASH_TABLE_SIZE 0x400
|
---|
165 | #define HASH_TABLE_MASK (HASH_TABLE_SIZE - 1)
|
---|
166 |
|
---|
167 | //
|
---|
168 | // The directory entry for opened directory
|
---|
169 | //
|
---|
170 |
|
---|
171 | typedef struct _FAT_DIRENT FAT_DIRENT;
|
---|
172 | typedef struct _FAT_ODIR FAT_ODIR;
|
---|
173 | typedef struct _FAT_OFILE FAT_OFILE;
|
---|
174 | typedef struct _FAT_VOLUME FAT_VOLUME;
|
---|
175 |
|
---|
176 | struct _FAT_DIRENT {
|
---|
177 | UINTN Signature;
|
---|
178 | UINT16 EntryPos; // The position of this directory entry in the parent directory file
|
---|
179 | UINT8 EntryCount; // The count of the directory entry in the parent directory file
|
---|
180 | BOOLEAN Invalid; // Indicate whether this directory entry is valid
|
---|
181 | CHAR16 *FileString; // The unicode long file name for this directory entry
|
---|
182 | FAT_OFILE *OFile; // The OFile of the corresponding directory entry
|
---|
183 | FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename
|
---|
184 | FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename
|
---|
185 | LIST_ENTRY Link; // Connection of every directory entry
|
---|
186 | FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk
|
---|
187 | };
|
---|
188 |
|
---|
189 | struct _FAT_ODIR {
|
---|
190 | UINTN Signature;
|
---|
191 | UINT32 CurrentEndPos; // Current end position of the directory
|
---|
192 | UINT32 CurrentPos; // Current position of the directory
|
---|
193 | LIST_ENTRY *CurrentCursor; // Current directory entry pointer
|
---|
194 | LIST_ENTRY ChildList; // List of all directory entries
|
---|
195 | BOOLEAN EndOfDir; // Indicate whether we have reached the end of the directory
|
---|
196 | LIST_ENTRY DirCacheLink; // Linked in Volume->DirCacheList when discarded
|
---|
197 | UINTN DirCacheTag; // The identification of the directory when in directory cache
|
---|
198 | FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];
|
---|
199 | FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];
|
---|
200 | };
|
---|
201 |
|
---|
202 | typedef struct {
|
---|
203 | UINTN Signature;
|
---|
204 | EFI_FILE_PROTOCOL Handle;
|
---|
205 | UINT64 Position;
|
---|
206 | BOOLEAN ReadOnly;
|
---|
207 | FAT_OFILE *OFile;
|
---|
208 | LIST_ENTRY Tasks; // List of all FAT_TASKs
|
---|
209 | LIST_ENTRY Link; // Link to other IFiles
|
---|
210 | } FAT_IFILE;
|
---|
211 |
|
---|
212 | typedef struct {
|
---|
213 | UINTN Signature;
|
---|
214 | EFI_FILE_IO_TOKEN *FileIoToken;
|
---|
215 | FAT_IFILE *IFile;
|
---|
216 | LIST_ENTRY Subtasks; // List of all FAT_SUBTASKs
|
---|
217 | LIST_ENTRY Link; // Link to other FAT_TASKs
|
---|
218 | } FAT_TASK;
|
---|
219 |
|
---|
220 | typedef struct {
|
---|
221 | UINTN Signature;
|
---|
222 | EFI_DISK_IO2_TOKEN DiskIo2Token;
|
---|
223 | FAT_TASK *Task;
|
---|
224 | BOOLEAN Write;
|
---|
225 | UINT64 Offset;
|
---|
226 | VOID *Buffer;
|
---|
227 | UINTN BufferSize;
|
---|
228 | LIST_ENTRY Link;
|
---|
229 | } FAT_SUBTASK;
|
---|
230 |
|
---|
231 | //
|
---|
232 | // FAT_OFILE - Each opened file
|
---|
233 | //
|
---|
234 | struct _FAT_OFILE {
|
---|
235 | UINTN Signature;
|
---|
236 | FAT_VOLUME *Volume;
|
---|
237 | //
|
---|
238 | // A permanent error code to return to all accesses to
|
---|
239 | // this opened file
|
---|
240 | //
|
---|
241 | EFI_STATUS Error;
|
---|
242 | //
|
---|
243 | // A list of the IFILE instances for this OFile
|
---|
244 | //
|
---|
245 | LIST_ENTRY Opens;
|
---|
246 |
|
---|
247 | //
|
---|
248 | // The dynamic information
|
---|
249 | //
|
---|
250 | UINTN FileSize;
|
---|
251 | UINTN FileCluster;
|
---|
252 | UINTN FileCurrentCluster;
|
---|
253 | UINTN FileLastCluster;
|
---|
254 |
|
---|
255 | //
|
---|
256 | // Dirty is set if there have been any updates to the
|
---|
257 | // file
|
---|
258 | // Archive is set if the archive attribute in the file's
|
---|
259 | // directory entry needs to be set when performing flush
|
---|
260 | // PreserveLastMod is set if the last modification of the
|
---|
261 | // file is specified by SetInfo API
|
---|
262 | //
|
---|
263 | BOOLEAN Dirty;
|
---|
264 | BOOLEAN IsFixedRootDir;
|
---|
265 | BOOLEAN PreserveLastModification;
|
---|
266 | BOOLEAN Archive;
|
---|
267 | //
|
---|
268 | // Set by an OFile SetPosition
|
---|
269 | //
|
---|
270 | UINTN Position; // within file
|
---|
271 | UINT64 PosDisk; // on the disk
|
---|
272 | UINTN PosRem; // remaining in this disk run
|
---|
273 | //
|
---|
274 | // The opened parent, full path length and currently opened child files
|
---|
275 | //
|
---|
276 | FAT_OFILE *Parent;
|
---|
277 | UINTN FullPathLen;
|
---|
278 | LIST_ENTRY ChildHead;
|
---|
279 | LIST_ENTRY ChildLink;
|
---|
280 |
|
---|
281 | //
|
---|
282 | // The opened directory structure for a directory; if this
|
---|
283 | // OFile represents a file, then ODir = NULL
|
---|
284 | //
|
---|
285 | FAT_ODIR *ODir;
|
---|
286 | //
|
---|
287 | // The directory entry for the Ofile
|
---|
288 | //
|
---|
289 | FAT_DIRENT *DirEnt;
|
---|
290 |
|
---|
291 | //
|
---|
292 | // Link in Volume's reference list
|
---|
293 | //
|
---|
294 | LIST_ENTRY CheckLink;
|
---|
295 | };
|
---|
296 |
|
---|
297 | struct _FAT_VOLUME {
|
---|
298 | UINTN Signature;
|
---|
299 |
|
---|
300 | EFI_HANDLE Handle;
|
---|
301 | BOOLEAN Valid;
|
---|
302 | BOOLEAN DiskError;
|
---|
303 |
|
---|
304 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL VolumeInterface;
|
---|
305 |
|
---|
306 | //
|
---|
307 | // If opened, the parent handle and BlockIo interface
|
---|
308 | //
|
---|
309 | EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
---|
310 | EFI_DISK_IO_PROTOCOL *DiskIo;
|
---|
311 | EFI_DISK_IO2_PROTOCOL *DiskIo2;
|
---|
312 | UINT32 MediaId;
|
---|
313 | BOOLEAN ReadOnly;
|
---|
314 |
|
---|
315 | //
|
---|
316 | // Computed values from fat bpb info
|
---|
317 | //
|
---|
318 | UINT64 VolumeSize;
|
---|
319 | UINT64 FatPos; // Disk pos of fat tables
|
---|
320 | UINT64 RootPos; // Disk pos of root directory
|
---|
321 | UINT64 FirstClusterPos; // Disk pos of first cluster
|
---|
322 | UINTN FatSize; // Number of bytes in each fat
|
---|
323 | UINTN MaxCluster; // Max cluster number
|
---|
324 | UINTN ClusterSize; // Cluster size of fat partition
|
---|
325 | UINT8 ClusterAlignment; // Equal to log_2 (clustersize);
|
---|
326 | FAT_VOLUME_TYPE FatType;
|
---|
327 |
|
---|
328 | //
|
---|
329 | // Current part of fat table that's present
|
---|
330 | //
|
---|
331 | UINT64 FatEntryPos; // Location of buffer
|
---|
332 | UINTN FatEntrySize; // Size of buffer
|
---|
333 | UINT32 FatEntryBuffer; // The buffer
|
---|
334 | FAT_INFO_SECTOR FatInfoSector; // Free cluster info
|
---|
335 | UINTN FreeInfoPos; // Pos with the free cluster info
|
---|
336 | BOOLEAN FreeInfoValid; // If free cluster info is valid
|
---|
337 | //
|
---|
338 | // Unpacked Fat BPB info
|
---|
339 | //
|
---|
340 | UINTN NumFats;
|
---|
341 | UINTN RootEntries; // < FAT32, root dir is fixed size
|
---|
342 | UINTN RootCluster; // >= FAT32, root cluster chain head
|
---|
343 | //
|
---|
344 | // info for marking the volume dirty or not
|
---|
345 | //
|
---|
346 | BOOLEAN FatDirty; // If fat-entries have been updated
|
---|
347 | UINT32 DirtyValue;
|
---|
348 | UINT32 NotDirtyValue;
|
---|
349 |
|
---|
350 | //
|
---|
351 | // The root directory entry and opened root file
|
---|
352 | //
|
---|
353 | FAT_DIRENT RootDirEnt;
|
---|
354 | //
|
---|
355 | // File Name of root OFile, it is empty string
|
---|
356 | //
|
---|
357 | CHAR16 RootFileString[1];
|
---|
358 | FAT_OFILE *Root;
|
---|
359 |
|
---|
360 | //
|
---|
361 | // New OFiles are added to this list so they
|
---|
362 | // can be cleaned up if they aren't referenced.
|
---|
363 | //
|
---|
364 | LIST_ENTRY CheckRef;
|
---|
365 |
|
---|
366 | //
|
---|
367 | // Directory cache List
|
---|
368 | //
|
---|
369 | LIST_ENTRY DirCacheList;
|
---|
370 | UINTN DirCacheCount;
|
---|
371 |
|
---|
372 | //
|
---|
373 | // Disk Cache for this volume
|
---|
374 | //
|
---|
375 | VOID *CacheBuffer;
|
---|
376 | DISK_CACHE DiskCache[CacheMaxType];
|
---|
377 | };
|
---|
378 |
|
---|
379 | //
|
---|
380 | // Function Prototypes
|
---|
381 | //
|
---|
382 |
|
---|
383 | /**
|
---|
384 |
|
---|
385 | Implements Open() of Simple File System Protocol.
|
---|
386 |
|
---|
387 | @param FHand - File handle of the file serves as a starting reference point.
|
---|
388 | @param NewHandle - Handle of the file that is newly opened.
|
---|
389 | @param FileName - File name relative to FHand.
|
---|
390 | @param OpenMode - Open mode.
|
---|
391 | @param Attributes - Attributes to set if the file is created.
|
---|
392 |
|
---|
393 |
|
---|
394 | @retval 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 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
|
---|
398 | @retval EFI_SUCCESS - Open the file successfully.
|
---|
399 | @return Others - The status of open file.
|
---|
400 |
|
---|
401 | **/
|
---|
402 | EFI_STATUS
|
---|
403 | EFIAPI
|
---|
404 | FatOpen (
|
---|
405 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
406 | OUT EFI_FILE_PROTOCOL **NewHandle,
|
---|
407 | IN CHAR16 *FileName,
|
---|
408 | IN UINT64 OpenMode,
|
---|
409 | IN UINT64 Attributes
|
---|
410 | )
|
---|
411 | ;
|
---|
412 |
|
---|
413 | /**
|
---|
414 |
|
---|
415 | Implements OpenEx() of Simple File System Protocol.
|
---|
416 |
|
---|
417 | @param FHand - File handle of the file serves as a starting reference point.
|
---|
418 | @param NewHandle - Handle of the file that is newly opened.
|
---|
419 | @param FileName - File name relative to FHand.
|
---|
420 | @param OpenMode - Open mode.
|
---|
421 | @param Attributes - Attributes to set if the file is created.
|
---|
422 | @param Token - A pointer to the token associated with the transaction.
|
---|
423 |
|
---|
424 | @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.
|
---|
425 | The OpenMode is not supported.
|
---|
426 | The Attributes is not the valid attributes.
|
---|
427 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
|
---|
428 | @retval EFI_SUCCESS - Open the file successfully.
|
---|
429 | @return Others - The status of open file.
|
---|
430 |
|
---|
431 | **/
|
---|
432 | EFI_STATUS
|
---|
433 | EFIAPI
|
---|
434 | FatOpenEx (
|
---|
435 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
436 | OUT EFI_FILE_PROTOCOL **NewHandle,
|
---|
437 | IN CHAR16 *FileName,
|
---|
438 | IN UINT64 OpenMode,
|
---|
439 | IN UINT64 Attributes,
|
---|
440 | IN OUT EFI_FILE_IO_TOKEN *Token
|
---|
441 | )
|
---|
442 | ;
|
---|
443 |
|
---|
444 | /**
|
---|
445 |
|
---|
446 | Get the file's position of the file
|
---|
447 |
|
---|
448 | @param FHand - The handle of file.
|
---|
449 | @param Position - The file's position of the file.
|
---|
450 |
|
---|
451 | @retval EFI_SUCCESS - Get the info successfully.
|
---|
452 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
453 | @retval EFI_UNSUPPORTED - The open file is not a file.
|
---|
454 |
|
---|
455 | **/
|
---|
456 | EFI_STATUS
|
---|
457 | EFIAPI
|
---|
458 | FatGetPosition (
|
---|
459 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
460 | OUT UINT64 *Position
|
---|
461 | )
|
---|
462 | ;
|
---|
463 |
|
---|
464 | /**
|
---|
465 |
|
---|
466 | Get the some types info of the file into Buffer
|
---|
467 |
|
---|
468 | @param FHand - The handle of file.
|
---|
469 | @param Type - The type of the info.
|
---|
470 | @param BufferSize - Size of Buffer.
|
---|
471 | @param Buffer - Buffer containing volume info.
|
---|
472 |
|
---|
473 | @retval EFI_SUCCESS - Get the info successfully.
|
---|
474 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
475 |
|
---|
476 | **/
|
---|
477 | EFI_STATUS
|
---|
478 | EFIAPI
|
---|
479 | FatGetInfo (
|
---|
480 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
481 | IN EFI_GUID *Type,
|
---|
482 | IN OUT UINTN *BufferSize,
|
---|
483 | OUT VOID *Buffer
|
---|
484 | )
|
---|
485 | ;
|
---|
486 |
|
---|
487 | /**
|
---|
488 |
|
---|
489 | Set the some types info of the file into Buffer.
|
---|
490 |
|
---|
491 | @param FHand - The handle of file.
|
---|
492 | @param Type - The type of the info.
|
---|
493 | @param BufferSize - Size of Buffer.
|
---|
494 | @param Buffer - Buffer containing volume info.
|
---|
495 |
|
---|
496 | @retval EFI_SUCCESS - Set the info successfully.
|
---|
497 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
498 |
|
---|
499 | **/
|
---|
500 | EFI_STATUS
|
---|
501 | EFIAPI
|
---|
502 | FatSetInfo (
|
---|
503 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
504 | IN EFI_GUID *Type,
|
---|
505 | IN UINTN BufferSize,
|
---|
506 | IN VOID *Buffer
|
---|
507 | )
|
---|
508 | ;
|
---|
509 |
|
---|
510 | /**
|
---|
511 |
|
---|
512 | Flushes all data associated with the file handle.
|
---|
513 |
|
---|
514 | @param FHand - Handle to file to flush
|
---|
515 |
|
---|
516 | @retval EFI_SUCCESS - Flushed the file successfully
|
---|
517 | @retval EFI_WRITE_PROTECTED - The volume is read only
|
---|
518 | @retval EFI_ACCESS_DENIED - The volume is not read only
|
---|
519 | but the file is read only
|
---|
520 | @return Others - Flushing of the file is failed
|
---|
521 |
|
---|
522 | **/
|
---|
523 | EFI_STATUS
|
---|
524 | EFIAPI
|
---|
525 | FatFlush (
|
---|
526 | IN EFI_FILE_PROTOCOL *FHand
|
---|
527 | )
|
---|
528 | ;
|
---|
529 |
|
---|
530 | /**
|
---|
531 |
|
---|
532 | Flushes all data associated with the file handle.
|
---|
533 |
|
---|
534 | @param FHand - Handle to file to flush.
|
---|
535 | @param Token - A pointer to the token associated with the transaction.
|
---|
536 |
|
---|
537 | @retval EFI_SUCCESS - Flushed the file successfully.
|
---|
538 | @retval EFI_WRITE_PROTECTED - The volume is read only.
|
---|
539 | @retval EFI_ACCESS_DENIED - The file is read only.
|
---|
540 | @return Others - Flushing of the file failed.
|
---|
541 |
|
---|
542 | **/
|
---|
543 | EFI_STATUS
|
---|
544 | EFIAPI
|
---|
545 | FatFlushEx (
|
---|
546 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
547 | IN EFI_FILE_IO_TOKEN *Token
|
---|
548 | )
|
---|
549 | ;
|
---|
550 |
|
---|
551 | /**
|
---|
552 |
|
---|
553 | Flushes & Closes the file handle.
|
---|
554 |
|
---|
555 | @param FHand - Handle to the file to delete.
|
---|
556 |
|
---|
557 | @retval EFI_SUCCESS - Closed the file successfully.
|
---|
558 |
|
---|
559 | **/
|
---|
560 | EFI_STATUS
|
---|
561 | EFIAPI
|
---|
562 | FatClose (
|
---|
563 | IN EFI_FILE_PROTOCOL *FHand
|
---|
564 | )
|
---|
565 | ;
|
---|
566 |
|
---|
567 | /**
|
---|
568 |
|
---|
569 | Deletes the file & Closes the file handle.
|
---|
570 |
|
---|
571 | @param FHand - Handle to the file to delete.
|
---|
572 |
|
---|
573 | @retval EFI_SUCCESS - Delete the file successfully.
|
---|
574 | @retval EFI_WARN_DELETE_FAILURE - Fail to delete the file.
|
---|
575 |
|
---|
576 | **/
|
---|
577 | EFI_STATUS
|
---|
578 | EFIAPI
|
---|
579 | FatDelete (
|
---|
580 | IN EFI_FILE_PROTOCOL *FHand
|
---|
581 | )
|
---|
582 | ;
|
---|
583 |
|
---|
584 | /**
|
---|
585 |
|
---|
586 | Set the file's position of the file.
|
---|
587 |
|
---|
588 | @param FHand - The handle of file
|
---|
589 | @param Position - The file's position of the file
|
---|
590 |
|
---|
591 | @retval EFI_SUCCESS - Set the info successfully
|
---|
592 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file
|
---|
593 | @retval EFI_UNSUPPORTED - Set a directory with a not-zero position
|
---|
594 |
|
---|
595 | **/
|
---|
596 | EFI_STATUS
|
---|
597 | EFIAPI
|
---|
598 | FatSetPosition (
|
---|
599 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
600 | IN UINT64 Position
|
---|
601 | )
|
---|
602 | ;
|
---|
603 |
|
---|
604 | /**
|
---|
605 |
|
---|
606 | Get the file info.
|
---|
607 |
|
---|
608 | @param FHand - The handle of the file.
|
---|
609 | @param BufferSize - Size of Buffer.
|
---|
610 | @param Buffer - Buffer containing read data.
|
---|
611 |
|
---|
612 | @retval EFI_SUCCESS - Get the file info successfully.
|
---|
613 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
614 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
---|
615 | @return other - An error occurred when operation the disk.
|
---|
616 |
|
---|
617 | **/
|
---|
618 | EFI_STATUS
|
---|
619 | EFIAPI
|
---|
620 | FatRead (
|
---|
621 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
622 | IN OUT UINTN *BufferSize,
|
---|
623 | OUT VOID *Buffer
|
---|
624 | )
|
---|
625 | ;
|
---|
626 |
|
---|
627 | /**
|
---|
628 |
|
---|
629 | Get the file info.
|
---|
630 |
|
---|
631 | @param FHand - The handle of the file.
|
---|
632 | @param Token - A pointer to the token associated with the transaction.
|
---|
633 |
|
---|
634 | @retval EFI_SUCCESS - Get the file info successfully.
|
---|
635 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
636 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
---|
637 | @return other - An error occurred when operation the disk.
|
---|
638 |
|
---|
639 | **/
|
---|
640 | EFI_STATUS
|
---|
641 | EFIAPI
|
---|
642 | FatReadEx (
|
---|
643 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
644 | IN OUT EFI_FILE_IO_TOKEN *Token
|
---|
645 | )
|
---|
646 | ;
|
---|
647 |
|
---|
648 | /**
|
---|
649 |
|
---|
650 | Set the file info.
|
---|
651 |
|
---|
652 | @param FHand - The handle of the file.
|
---|
653 | @param BufferSize - Size of Buffer.
|
---|
654 | @param Buffer - Buffer containing write data.
|
---|
655 |
|
---|
656 | @retval EFI_SUCCESS - Set the file info successfully.
|
---|
657 | @retval EFI_WRITE_PROTECTED - The disk is write protected.
|
---|
658 | @retval EFI_ACCESS_DENIED - The file is read-only.
|
---|
659 | @retval EFI_DEVICE_ERROR - The OFile is not valid.
|
---|
660 | @retval EFI_UNSUPPORTED - The open file is not a file.
|
---|
661 | - The writing file size is larger than 4GB.
|
---|
662 | @return other - An error occurred when operation the disk.
|
---|
663 |
|
---|
664 | **/
|
---|
665 | EFI_STATUS
|
---|
666 | EFIAPI
|
---|
667 | FatWrite (
|
---|
668 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
669 | IN OUT UINTN *BufferSize,
|
---|
670 | IN VOID *Buffer
|
---|
671 | )
|
---|
672 | ;
|
---|
673 |
|
---|
674 | /**
|
---|
675 |
|
---|
676 | Get the file info.
|
---|
677 |
|
---|
678 | @param FHand - The handle of the file.
|
---|
679 | @param Token - A pointer to the token associated with the transaction.
|
---|
680 |
|
---|
681 | @retval EFI_SUCCESS - Get the file info successfully.
|
---|
682 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
---|
683 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
---|
684 | @return other - An error occurred when operation the disk.
|
---|
685 |
|
---|
686 | **/
|
---|
687 | EFI_STATUS
|
---|
688 | EFIAPI
|
---|
689 | FatWriteEx (
|
---|
690 | IN EFI_FILE_PROTOCOL *FHand,
|
---|
691 | IN OUT EFI_FILE_IO_TOKEN *Token
|
---|
692 | )
|
---|
693 | ;
|
---|
694 |
|
---|
695 | //
|
---|
696 | // DiskCache.c
|
---|
697 | //
|
---|
698 |
|
---|
699 | /**
|
---|
700 |
|
---|
701 | Initialize the disk cache according to Volume's FatType.
|
---|
702 |
|
---|
703 | @param Volume - FAT file system volume.
|
---|
704 |
|
---|
705 | @retval EFI_SUCCESS - The disk cache is successfully initialized.
|
---|
706 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to allocate disk cache.
|
---|
707 |
|
---|
708 | **/
|
---|
709 | EFI_STATUS
|
---|
710 | FatInitializeDiskCache (
|
---|
711 | IN FAT_VOLUME *Volume
|
---|
712 | );
|
---|
713 |
|
---|
714 | /**
|
---|
715 |
|
---|
716 | Read BufferSize bytes from the position of Offset into Buffer,
|
---|
717 | or write BufferSize bytes from Buffer into the position of Offset.
|
---|
718 |
|
---|
719 | Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into
|
---|
720 | the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):
|
---|
721 |
|
---|
722 | 1. Access of FAT cache (CACHE_FAT): Access the data in the FAT cache, if there is cache
|
---|
723 | page hit, just return the cache page; else update the related cache page and return
|
---|
724 | the right cache page.
|
---|
725 | 2. Access of Data cache (CACHE_DATA):
|
---|
726 | The access data will be divided into UnderRun data, Aligned data and OverRun data;
|
---|
727 | The UnderRun data and OverRun data will be accessed by the Data cache,
|
---|
728 | but the Aligned data will be accessed with disk directly.
|
---|
729 |
|
---|
730 | @param Volume - FAT file system volume.
|
---|
731 | @param CacheDataType - The type of cache: CACHE_DATA or CACHE_FAT.
|
---|
732 | @param IoMode - Indicate the type of disk access.
|
---|
733 | @param Offset - The starting byte offset to read from.
|
---|
734 | @param BufferSize - Size of Buffer.
|
---|
735 | @param Buffer - Buffer containing cache data.
|
---|
736 | @param Task point to task instance.
|
---|
737 |
|
---|
738 | @retval EFI_SUCCESS - The data was accessed correctly.
|
---|
739 | @retval EFI_MEDIA_CHANGED - The MediaId does not match the current device.
|
---|
740 | @return Others - An error occurred when accessing cache.
|
---|
741 |
|
---|
742 | **/
|
---|
743 | EFI_STATUS
|
---|
744 | FatAccessCache (
|
---|
745 | IN FAT_VOLUME *Volume,
|
---|
746 | IN CACHE_DATA_TYPE CacheDataType,
|
---|
747 | IN IO_MODE IoMode,
|
---|
748 | IN UINT64 Offset,
|
---|
749 | IN UINTN BufferSize,
|
---|
750 | IN OUT UINT8 *Buffer,
|
---|
751 | IN FAT_TASK *Task
|
---|
752 | );
|
---|
753 |
|
---|
754 | /**
|
---|
755 |
|
---|
756 | Flush all the dirty cache back, include the FAT cache and the Data cache.
|
---|
757 |
|
---|
758 | @param Volume - FAT file system volume.
|
---|
759 | @param Task point to task instance.
|
---|
760 |
|
---|
761 | @retval EFI_SUCCESS - Flush all the dirty cache back successfully
|
---|
762 | @return other - An error occurred when writing the data into the disk
|
---|
763 |
|
---|
764 | **/
|
---|
765 | EFI_STATUS
|
---|
766 | FatVolumeFlushCache (
|
---|
767 | IN FAT_VOLUME *Volume,
|
---|
768 | IN FAT_TASK *Task
|
---|
769 | );
|
---|
770 |
|
---|
771 | //
|
---|
772 | // Flush.c
|
---|
773 | //
|
---|
774 |
|
---|
775 | /**
|
---|
776 |
|
---|
777 | Flush the data associated with an open file.
|
---|
778 | In this implementation, only last Mod/Access time is updated.
|
---|
779 |
|
---|
780 | @param OFile - The open file.
|
---|
781 |
|
---|
782 | @retval EFI_SUCCESS - The OFile is flushed successfully.
|
---|
783 | @return Others - An error occurred when flushing this OFile.
|
---|
784 |
|
---|
785 | **/
|
---|
786 | EFI_STATUS
|
---|
787 | FatOFileFlush (
|
---|
788 | IN FAT_OFILE *OFile
|
---|
789 | );
|
---|
790 |
|
---|
791 | /**
|
---|
792 |
|
---|
793 | Check the references of the OFile.
|
---|
794 | If the OFile (that is checked) is no longer
|
---|
795 | referenced, then it is freed.
|
---|
796 |
|
---|
797 | @param OFile - The OFile to be checked.
|
---|
798 |
|
---|
799 | @retval TRUE - The OFile is not referenced and freed.
|
---|
800 | @retval FALSE - The OFile is kept.
|
---|
801 |
|
---|
802 | **/
|
---|
803 | BOOLEAN
|
---|
804 | FatCheckOFileRef (
|
---|
805 | IN FAT_OFILE *OFile
|
---|
806 | );
|
---|
807 |
|
---|
808 | /**
|
---|
809 |
|
---|
810 | Set the OFile and its child OFile with the error Status
|
---|
811 |
|
---|
812 | @param OFile - The OFile whose permanent error code is to be set.
|
---|
813 | @param Status - Error code to be set.
|
---|
814 |
|
---|
815 | **/
|
---|
816 | VOID
|
---|
817 | FatSetVolumeError (
|
---|
818 | IN FAT_OFILE *OFile,
|
---|
819 | IN EFI_STATUS Status
|
---|
820 | );
|
---|
821 |
|
---|
822 | /**
|
---|
823 |
|
---|
824 | Close the open file instance.
|
---|
825 |
|
---|
826 | @param IFile - Open file instance.
|
---|
827 |
|
---|
828 | @retval EFI_SUCCESS - Closed the file successfully.
|
---|
829 |
|
---|
830 | **/
|
---|
831 | EFI_STATUS
|
---|
832 | FatIFileClose (
|
---|
833 | FAT_IFILE *IFile
|
---|
834 | );
|
---|
835 |
|
---|
836 | /**
|
---|
837 |
|
---|
838 | Set error status for a specific OFile, reference checking the volume.
|
---|
839 | If volume is already marked as invalid, and all resources are freed
|
---|
840 | after reference checking, the file system protocol is uninstalled and
|
---|
841 | the volume structure is freed.
|
---|
842 |
|
---|
843 | @param Volume - the Volume that is to be reference checked and unlocked.
|
---|
844 | @param OFile - the OFile whose permanent error code is to be set.
|
---|
845 | @param EfiStatus - error code to be set.
|
---|
846 | @param Task point to task instance.
|
---|
847 |
|
---|
848 | @retval EFI_SUCCESS - Clean up the volume successfully.
|
---|
849 | @return Others - Cleaning up of the volume is failed.
|
---|
850 |
|
---|
851 | **/
|
---|
852 | EFI_STATUS
|
---|
853 | FatCleanupVolume (
|
---|
854 | IN FAT_VOLUME *Volume,
|
---|
855 | IN FAT_OFILE *OFile,
|
---|
856 | IN EFI_STATUS EfiStatus,
|
---|
857 | IN FAT_TASK *Task
|
---|
858 | );
|
---|
859 |
|
---|
860 | //
|
---|
861 | // FileSpace.c
|
---|
862 | //
|
---|
863 |
|
---|
864 | /**
|
---|
865 |
|
---|
866 | Shrink the end of the open file base on the file size.
|
---|
867 |
|
---|
868 | @param OFile - The open file.
|
---|
869 |
|
---|
870 | @retval EFI_SUCCESS - Shrinked successfully.
|
---|
871 | @retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.
|
---|
872 |
|
---|
873 | **/
|
---|
874 | EFI_STATUS
|
---|
875 | FatShrinkEof (
|
---|
876 | IN FAT_OFILE *OFile
|
---|
877 | );
|
---|
878 |
|
---|
879 | /**
|
---|
880 |
|
---|
881 | Grow the end of the open file base on the NewSizeInBytes.
|
---|
882 |
|
---|
883 | @param OFile - The open file.
|
---|
884 | @param NewSizeInBytes - The new size in bytes of the open file.
|
---|
885 |
|
---|
886 | @retval EFI_SUCCESS - The file is grown successfully.
|
---|
887 | @retval EFI_UNSUPPORTED - The file size is larger than 4GB.
|
---|
888 | @retval EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.
|
---|
889 | @retval EFI_VOLUME_FULL - The volume is full and can not grow the file.
|
---|
890 |
|
---|
891 | **/
|
---|
892 | EFI_STATUS
|
---|
893 | FatGrowEof (
|
---|
894 | IN FAT_OFILE *OFile,
|
---|
895 | IN UINT64 NewSizeInBytes
|
---|
896 | );
|
---|
897 |
|
---|
898 | /**
|
---|
899 |
|
---|
900 | Get the size of directory of the open file.
|
---|
901 |
|
---|
902 | @param Volume - The File System Volume.
|
---|
903 | @param Cluster - The Starting cluster.
|
---|
904 |
|
---|
905 | @return The physical size of the file starting at the input cluster, if there is error in the
|
---|
906 | cluster chain, the return value is 0.
|
---|
907 |
|
---|
908 | **/
|
---|
909 | UINTN
|
---|
910 | FatPhysicalDirSize (
|
---|
911 | IN FAT_VOLUME *Volume,
|
---|
912 | IN UINTN Cluster
|
---|
913 | );
|
---|
914 |
|
---|
915 | /**
|
---|
916 |
|
---|
917 | Get the physical size of a file on the disk.
|
---|
918 |
|
---|
919 | @param Volume - The file system volume.
|
---|
920 | @param RealSize - The real size of a file.
|
---|
921 |
|
---|
922 | @return The physical size of a file on the disk.
|
---|
923 |
|
---|
924 | **/
|
---|
925 | UINT64
|
---|
926 | FatPhysicalFileSize (
|
---|
927 | IN FAT_VOLUME *Volume,
|
---|
928 | IN UINTN RealSize
|
---|
929 | );
|
---|
930 |
|
---|
931 | /**
|
---|
932 |
|
---|
933 | Seek OFile to requested position, and calculate the number of
|
---|
934 | consecutive clusters from the position in the file
|
---|
935 |
|
---|
936 | @param OFile - The open file.
|
---|
937 | @param Position - The file's position which will be accessed.
|
---|
938 | @param PosLimit - The maximum length current reading/writing may access
|
---|
939 |
|
---|
940 | @retval EFI_SUCCESS - Set the info successfully.
|
---|
941 | @retval EFI_VOLUME_CORRUPTED - Cluster chain corrupt.
|
---|
942 |
|
---|
943 | **/
|
---|
944 | EFI_STATUS
|
---|
945 | FatOFilePosition (
|
---|
946 | IN FAT_OFILE *OFile,
|
---|
947 | IN UINTN Position,
|
---|
948 | IN UINTN PosLimit
|
---|
949 | );
|
---|
950 |
|
---|
951 | /**
|
---|
952 |
|
---|
953 | Update the free cluster info of FatInfoSector of the volume.
|
---|
954 |
|
---|
955 | @param Volume - FAT file system volume.
|
---|
956 |
|
---|
957 | **/
|
---|
958 | VOID
|
---|
959 | FatComputeFreeInfo (
|
---|
960 | IN FAT_VOLUME *Volume
|
---|
961 | );
|
---|
962 |
|
---|
963 | //
|
---|
964 | // Init.c
|
---|
965 | //
|
---|
966 |
|
---|
967 | /**
|
---|
968 |
|
---|
969 | Allocates volume structure, detects FAT file system, installs protocol,
|
---|
970 | and initialize cache.
|
---|
971 |
|
---|
972 | @param Handle - The handle of parent device.
|
---|
973 | @param DiskIo - The DiskIo of parent device.
|
---|
974 | @param DiskIo2 - The DiskIo2 of parent device.
|
---|
975 | @param BlockIo - The BlockIo of parent device.
|
---|
976 |
|
---|
977 | @retval EFI_SUCCESS - Allocate a new volume successfully.
|
---|
978 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
---|
979 | @return Others - Allocating a new volume failed.
|
---|
980 |
|
---|
981 | **/
|
---|
982 | EFI_STATUS
|
---|
983 | FatAllocateVolume (
|
---|
984 | IN EFI_HANDLE Handle,
|
---|
985 | IN EFI_DISK_IO_PROTOCOL *DiskIo,
|
---|
986 | IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
|
---|
987 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo
|
---|
988 | );
|
---|
989 |
|
---|
990 | /**
|
---|
991 |
|
---|
992 | Detects FAT file system on Disk and set relevant fields of Volume.
|
---|
993 |
|
---|
994 | @param Volume - The volume structure.
|
---|
995 |
|
---|
996 | @retval EFI_SUCCESS - The Fat File System is detected successfully
|
---|
997 | @retval EFI_UNSUPPORTED - The volume is not FAT file system.
|
---|
998 | @retval EFI_VOLUME_CORRUPTED - The volume is corrupted.
|
---|
999 |
|
---|
1000 | **/
|
---|
1001 | EFI_STATUS
|
---|
1002 | FatOpenDevice (
|
---|
1003 | IN OUT FAT_VOLUME *Volume
|
---|
1004 | );
|
---|
1005 |
|
---|
1006 | /**
|
---|
1007 |
|
---|
1008 | Called by FatDriverBindingStop(), Abandon the volume.
|
---|
1009 |
|
---|
1010 | @param Volume - The volume to be abandoned.
|
---|
1011 |
|
---|
1012 | @retval EFI_SUCCESS - Abandoned the volume successfully.
|
---|
1013 | @return Others - Can not uninstall the protocol interfaces.
|
---|
1014 |
|
---|
1015 | **/
|
---|
1016 | EFI_STATUS
|
---|
1017 | FatAbandonVolume (
|
---|
1018 | IN FAT_VOLUME *Volume
|
---|
1019 | );
|
---|
1020 |
|
---|
1021 | //
|
---|
1022 | // Misc.c
|
---|
1023 | //
|
---|
1024 |
|
---|
1025 | /**
|
---|
1026 |
|
---|
1027 | Create the task
|
---|
1028 |
|
---|
1029 | @param IFile - The instance of the open file.
|
---|
1030 | @param Token - A pointer to the token associated with the transaction.
|
---|
1031 |
|
---|
1032 | @return FAT_TASK * - Return the task instance.
|
---|
1033 |
|
---|
1034 | **/
|
---|
1035 | FAT_TASK *
|
---|
1036 | FatCreateTask (
|
---|
1037 | FAT_IFILE *IFile,
|
---|
1038 | EFI_FILE_IO_TOKEN *Token
|
---|
1039 | );
|
---|
1040 |
|
---|
1041 | /**
|
---|
1042 |
|
---|
1043 | Destroy the task.
|
---|
1044 |
|
---|
1045 | @param Task - The task to be destroyed.
|
---|
1046 |
|
---|
1047 | **/
|
---|
1048 | VOID
|
---|
1049 | FatDestroyTask (
|
---|
1050 | FAT_TASK *Task
|
---|
1051 | );
|
---|
1052 |
|
---|
1053 | /**
|
---|
1054 |
|
---|
1055 | Wait all non-blocking requests complete.
|
---|
1056 |
|
---|
1057 | @param IFile - The instance of the open file.
|
---|
1058 |
|
---|
1059 | **/
|
---|
1060 | VOID
|
---|
1061 | FatWaitNonblockingTask (
|
---|
1062 | FAT_IFILE *IFile
|
---|
1063 | );
|
---|
1064 |
|
---|
1065 | /**
|
---|
1066 |
|
---|
1067 | Remove the subtask from subtask list.
|
---|
1068 |
|
---|
1069 | @param Subtask - The subtask to be removed.
|
---|
1070 |
|
---|
1071 | @return LIST_ENTRY * - The next node in the list.
|
---|
1072 |
|
---|
1073 | **/
|
---|
1074 | LIST_ENTRY *
|
---|
1075 | FatDestroySubtask (
|
---|
1076 | FAT_SUBTASK *Subtask
|
---|
1077 | );
|
---|
1078 |
|
---|
1079 | /**
|
---|
1080 |
|
---|
1081 | Execute the task.
|
---|
1082 |
|
---|
1083 | @param IFile - The instance of the open file.
|
---|
1084 | @param Task - The task to be executed.
|
---|
1085 |
|
---|
1086 | @retval EFI_SUCCESS - The task was executed successfully.
|
---|
1087 | @return other - An error occurred when executing the task.
|
---|
1088 |
|
---|
1089 | **/
|
---|
1090 | EFI_STATUS
|
---|
1091 | FatQueueTask (
|
---|
1092 | IN FAT_IFILE *IFile,
|
---|
1093 | IN FAT_TASK *Task
|
---|
1094 | );
|
---|
1095 |
|
---|
1096 | /**
|
---|
1097 |
|
---|
1098 | Set the volume as dirty or not.
|
---|
1099 |
|
---|
1100 | @param Volume - FAT file system volume.
|
---|
1101 | @param IoMode - The access mode.
|
---|
1102 | @param DirtyValue - Set the volume as dirty or not.
|
---|
1103 |
|
---|
1104 | @retval EFI_SUCCESS - Set the new FAT entry value successfully.
|
---|
1105 | @return other - An error occurred when operation the FAT entries.
|
---|
1106 |
|
---|
1107 | **/
|
---|
1108 | EFI_STATUS
|
---|
1109 | FatAccessVolumeDirty (
|
---|
1110 | IN FAT_VOLUME *Volume,
|
---|
1111 | IN IO_MODE IoMode,
|
---|
1112 | IN VOID *DirtyValue
|
---|
1113 | );
|
---|
1114 |
|
---|
1115 | /**
|
---|
1116 |
|
---|
1117 | General disk access function.
|
---|
1118 |
|
---|
1119 | @param Volume - FAT file system volume.
|
---|
1120 | @param IoMode - The access mode (disk read/write or cache access).
|
---|
1121 | @param Offset - The starting byte offset to read from.
|
---|
1122 | @param BufferSize - Size of Buffer.
|
---|
1123 | @param Buffer - Buffer containing read data.
|
---|
1124 | @param Task point to task instance.
|
---|
1125 |
|
---|
1126 | @retval EFI_SUCCESS - The operation is performed successfully.
|
---|
1127 | @retval EFI_VOLUME_CORRUPTED - The access is
|
---|
1128 | @return Others - The status of read/write the disk
|
---|
1129 |
|
---|
1130 | **/
|
---|
1131 | EFI_STATUS
|
---|
1132 | FatDiskIo (
|
---|
1133 | IN FAT_VOLUME *Volume,
|
---|
1134 | IN IO_MODE IoMode,
|
---|
1135 | IN UINT64 Offset,
|
---|
1136 | IN UINTN BufferSize,
|
---|
1137 | IN OUT VOID *Buffer,
|
---|
1138 | IN FAT_TASK *Task
|
---|
1139 | );
|
---|
1140 |
|
---|
1141 | /**
|
---|
1142 |
|
---|
1143 | Lock the volume.
|
---|
1144 |
|
---|
1145 | **/
|
---|
1146 | VOID
|
---|
1147 | FatAcquireLock (
|
---|
1148 | VOID
|
---|
1149 | );
|
---|
1150 |
|
---|
1151 | /**
|
---|
1152 |
|
---|
1153 | Unlock the volume.
|
---|
1154 |
|
---|
1155 | **/
|
---|
1156 | VOID
|
---|
1157 | FatReleaseLock (
|
---|
1158 | VOID
|
---|
1159 | );
|
---|
1160 |
|
---|
1161 | /**
|
---|
1162 |
|
---|
1163 | Lock the volume.
|
---|
1164 | If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
|
---|
1165 | Otherwise, EFI_SUCCESS is returned.
|
---|
1166 |
|
---|
1167 | @retval EFI_SUCCESS - The volume is locked.
|
---|
1168 | @retval EFI_ACCESS_DENIED - The volume could not be locked because it is already locked.
|
---|
1169 |
|
---|
1170 | **/
|
---|
1171 | EFI_STATUS
|
---|
1172 | FatAcquireLockOrFail (
|
---|
1173 | VOID
|
---|
1174 | );
|
---|
1175 |
|
---|
1176 | /**
|
---|
1177 |
|
---|
1178 | Free directory entry.
|
---|
1179 |
|
---|
1180 | @param DirEnt - The directory entry to be freed.
|
---|
1181 |
|
---|
1182 | **/
|
---|
1183 | VOID
|
---|
1184 | FatFreeDirEnt (
|
---|
1185 | IN FAT_DIRENT *DirEnt
|
---|
1186 | );
|
---|
1187 |
|
---|
1188 | /**
|
---|
1189 |
|
---|
1190 | Free volume structure (including the contents of directory cache and disk cache).
|
---|
1191 |
|
---|
1192 | @param Volume - The volume structure to be freed.
|
---|
1193 |
|
---|
1194 | **/
|
---|
1195 | VOID
|
---|
1196 | FatFreeVolume (
|
---|
1197 | IN FAT_VOLUME *Volume
|
---|
1198 | );
|
---|
1199 |
|
---|
1200 | /**
|
---|
1201 |
|
---|
1202 | Translate EFI time to FAT time.
|
---|
1203 |
|
---|
1204 | @param ETime - The time of EFI_TIME.
|
---|
1205 | @param FTime - The time of FAT_DATE_TIME.
|
---|
1206 |
|
---|
1207 | **/
|
---|
1208 | VOID
|
---|
1209 | FatEfiTimeToFatTime (
|
---|
1210 | IN EFI_TIME *ETime,
|
---|
1211 | OUT FAT_DATE_TIME *FTime
|
---|
1212 | );
|
---|
1213 |
|
---|
1214 | /**
|
---|
1215 |
|
---|
1216 | Translate Fat time to EFI time.
|
---|
1217 |
|
---|
1218 | @param FTime - The time of FAT_DATE_TIME.
|
---|
1219 | @param ETime - The time of EFI_TIME..
|
---|
1220 |
|
---|
1221 | **/
|
---|
1222 | VOID
|
---|
1223 | FatFatTimeToEfiTime (
|
---|
1224 | IN FAT_DATE_TIME *FTime,
|
---|
1225 | OUT EFI_TIME *ETime
|
---|
1226 | );
|
---|
1227 |
|
---|
1228 | /**
|
---|
1229 |
|
---|
1230 | Get Current FAT time.
|
---|
1231 |
|
---|
1232 | @param FatTime - Current FAT time.
|
---|
1233 |
|
---|
1234 | **/
|
---|
1235 | VOID
|
---|
1236 | FatGetCurrentFatTime (
|
---|
1237 | OUT FAT_DATE_TIME *FatTime
|
---|
1238 | );
|
---|
1239 |
|
---|
1240 | /**
|
---|
1241 |
|
---|
1242 | Check whether a time is valid.
|
---|
1243 |
|
---|
1244 | @param Time - The time of EFI_TIME.
|
---|
1245 |
|
---|
1246 | @retval TRUE - The time is valid.
|
---|
1247 | @retval FALSE - The time is not valid.
|
---|
1248 |
|
---|
1249 | **/
|
---|
1250 | BOOLEAN
|
---|
1251 | FatIsValidTime (
|
---|
1252 | IN EFI_TIME *Time
|
---|
1253 | );
|
---|
1254 |
|
---|
1255 | //
|
---|
1256 | // UnicodeCollation.c
|
---|
1257 | //
|
---|
1258 |
|
---|
1259 | /**
|
---|
1260 | Initialize Unicode Collation support.
|
---|
1261 |
|
---|
1262 | It tries to locate Unicode Collation 2 protocol and matches it with current
|
---|
1263 | platform language code. If for any reason the first attempt fails, it then tries to
|
---|
1264 | use Unicode Collation Protocol.
|
---|
1265 |
|
---|
1266 | @param AgentHandle The handle used to open Unicode Collation (2) protocol.
|
---|
1267 |
|
---|
1268 | @retval EFI_SUCCESS The Unicode Collation (2) protocol has been successfully located.
|
---|
1269 | @retval Others The Unicode Collation (2) protocol has not been located.
|
---|
1270 |
|
---|
1271 | **/
|
---|
1272 | EFI_STATUS
|
---|
1273 | InitializeUnicodeCollationSupport (
|
---|
1274 | IN EFI_HANDLE AgentHandle
|
---|
1275 | );
|
---|
1276 |
|
---|
1277 | /**
|
---|
1278 | Convert FAT string to unicode string.
|
---|
1279 |
|
---|
1280 | @param FatSize The size of FAT string.
|
---|
1281 | @param Fat The FAT string.
|
---|
1282 | @param String The unicode string.
|
---|
1283 |
|
---|
1284 | @return None.
|
---|
1285 |
|
---|
1286 | **/
|
---|
1287 | VOID
|
---|
1288 | FatFatToStr (
|
---|
1289 | IN UINTN FatSize,
|
---|
1290 | IN CHAR8 *Fat,
|
---|
1291 | OUT CHAR16 *String
|
---|
1292 | );
|
---|
1293 |
|
---|
1294 | /**
|
---|
1295 | Convert unicode string to Fat string.
|
---|
1296 |
|
---|
1297 | @param String The unicode string.
|
---|
1298 | @param FatSize The size of the FAT string.
|
---|
1299 | @param Fat The FAT string.
|
---|
1300 |
|
---|
1301 | @retval TRUE Convert successfully.
|
---|
1302 | @retval FALSE Convert error.
|
---|
1303 |
|
---|
1304 | **/
|
---|
1305 | BOOLEAN
|
---|
1306 | FatStrToFat (
|
---|
1307 | IN CHAR16 *String,
|
---|
1308 | IN UINTN FatSize,
|
---|
1309 | OUT CHAR8 *Fat
|
---|
1310 | );
|
---|
1311 |
|
---|
1312 | /**
|
---|
1313 | Lowercase a string
|
---|
1314 |
|
---|
1315 | @param Str The string which will be lower-cased.
|
---|
1316 |
|
---|
1317 | **/
|
---|
1318 | VOID
|
---|
1319 | FatStrLwr (
|
---|
1320 | IN CHAR16 *Str
|
---|
1321 | );
|
---|
1322 |
|
---|
1323 | /**
|
---|
1324 | Uppercase a string.
|
---|
1325 |
|
---|
1326 | @param Str The string which will be upper-cased.
|
---|
1327 |
|
---|
1328 | **/
|
---|
1329 | VOID
|
---|
1330 | FatStrUpr (
|
---|
1331 | IN CHAR16 *Str
|
---|
1332 | );
|
---|
1333 |
|
---|
1334 | /**
|
---|
1335 | Performs a case-insensitive comparison of two Null-terminated Unicode strings.
|
---|
1336 |
|
---|
1337 | @param Str1 A pointer to a Null-terminated Unicode string.
|
---|
1338 | @param Str2 A pointer to a Null-terminated Unicode string.
|
---|
1339 |
|
---|
1340 | @retval 0 S1 is equivalent to S2.
|
---|
1341 | @retval >0 S1 is lexically greater than S2.
|
---|
1342 | @retval <0 S1 is lexically less than S2.
|
---|
1343 | **/
|
---|
1344 | INTN
|
---|
1345 | FatStriCmp (
|
---|
1346 | IN CHAR16 *Str1,
|
---|
1347 | IN CHAR16 *Str2
|
---|
1348 | );
|
---|
1349 |
|
---|
1350 | //
|
---|
1351 | // Open.c
|
---|
1352 | //
|
---|
1353 |
|
---|
1354 | /**
|
---|
1355 |
|
---|
1356 | Open a file for a file name relative to an existing OFile.
|
---|
1357 | The IFile of the newly opened file is passed out.
|
---|
1358 |
|
---|
1359 | @param OFile - The file that serves as a starting reference point.
|
---|
1360 | @param NewIFile - The newly generated IFile instance.
|
---|
1361 | @param FileName - The file name relative to the OFile.
|
---|
1362 | @param OpenMode - Open mode.
|
---|
1363 | @param Attributes - Attributes to set if the file is created.
|
---|
1364 |
|
---|
1365 |
|
---|
1366 | @retval EFI_SUCCESS - Open the file successfully.
|
---|
1367 | @retval EFI_INVALID_PARAMETER - The open mode is conflict with the attributes
|
---|
1368 | or the file name is not valid.
|
---|
1369 | @retval EFI_NOT_FOUND - Conflicts between dir intention and attribute.
|
---|
1370 | @retval EFI_WRITE_PROTECTED - Can't open for write if the volume is read only.
|
---|
1371 | @retval EFI_ACCESS_DENIED - If the file's attribute is read only, and the
|
---|
1372 | open is for read-write fail it.
|
---|
1373 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
---|
1374 |
|
---|
1375 | **/
|
---|
1376 | EFI_STATUS
|
---|
1377 | FatOFileOpen (
|
---|
1378 | IN FAT_OFILE *OFile,
|
---|
1379 | OUT FAT_IFILE **NewIFile,
|
---|
1380 | IN CHAR16 *FileName,
|
---|
1381 | IN UINT64 OpenMode,
|
---|
1382 | IN UINT8 Attributes
|
---|
1383 | );
|
---|
1384 |
|
---|
1385 | /**
|
---|
1386 |
|
---|
1387 | Create an Open instance for the existing OFile.
|
---|
1388 | The IFile of the newly opened file is passed out.
|
---|
1389 |
|
---|
1390 | @param OFile - The file that serves as a starting reference point.
|
---|
1391 | @param PtrIFile - The newly generated IFile instance.
|
---|
1392 |
|
---|
1393 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for the IFile
|
---|
1394 | @retval EFI_SUCCESS - Create the new IFile for the OFile successfully
|
---|
1395 |
|
---|
1396 | **/
|
---|
1397 | EFI_STATUS
|
---|
1398 | FatAllocateIFile (
|
---|
1399 | IN FAT_OFILE *OFile,
|
---|
1400 | OUT FAT_IFILE **PtrIFile
|
---|
1401 | );
|
---|
1402 |
|
---|
1403 | //
|
---|
1404 | // OpenVolume.c
|
---|
1405 | //
|
---|
1406 |
|
---|
1407 | /**
|
---|
1408 |
|
---|
1409 | Implements Simple File System Protocol interface function OpenVolume().
|
---|
1410 |
|
---|
1411 | @param This - Calling context.
|
---|
1412 | @param File - the Root Directory of the volume.
|
---|
1413 |
|
---|
1414 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
---|
1415 | @retval EFI_VOLUME_CORRUPTED - The FAT type is error.
|
---|
1416 | @retval EFI_SUCCESS - Open the volume successfully.
|
---|
1417 |
|
---|
1418 | **/
|
---|
1419 | EFI_STATUS
|
---|
1420 | EFIAPI
|
---|
1421 | FatOpenVolume (
|
---|
1422 | IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
|
---|
1423 | OUT EFI_FILE_PROTOCOL **File
|
---|
1424 | );
|
---|
1425 |
|
---|
1426 | //
|
---|
1427 | // ReadWrite.c
|
---|
1428 | //
|
---|
1429 |
|
---|
1430 | /**
|
---|
1431 |
|
---|
1432 | This function reads data from a file or writes data to a file.
|
---|
1433 | It uses OFile->PosRem to determine how much data can be accessed in one time.
|
---|
1434 |
|
---|
1435 | @param OFile - The open file.
|
---|
1436 | @param IoMode - Indicate whether the access mode is reading or writing.
|
---|
1437 | @param Position - The position where data will be accessed.
|
---|
1438 | @param DataBufferSize - Size of Buffer.
|
---|
1439 | @param UserBuffer - Buffer containing data.
|
---|
1440 | @param Task point to task instance.
|
---|
1441 |
|
---|
1442 | @retval EFI_SUCCESS - Access the data successfully.
|
---|
1443 | @return other - An error occurred when operating on the disk.
|
---|
1444 |
|
---|
1445 | **/
|
---|
1446 | EFI_STATUS
|
---|
1447 | FatAccessOFile (
|
---|
1448 | IN FAT_OFILE *OFile,
|
---|
1449 | IN IO_MODE IoMode,
|
---|
1450 | IN UINTN Position,
|
---|
1451 | IN UINTN *DataBufferSize,
|
---|
1452 | IN UINT8 *UserBuffer,
|
---|
1453 | IN FAT_TASK *Task
|
---|
1454 | );
|
---|
1455 |
|
---|
1456 | /**
|
---|
1457 |
|
---|
1458 | Expand OFile by appending zero bytes at the end of OFile.
|
---|
1459 |
|
---|
1460 | @param OFile - The open file.
|
---|
1461 | @param ExpandedSize - The number of zero bytes appended at the end of the file.
|
---|
1462 |
|
---|
1463 | @retval EFI_SUCCESS - The file is expanded successfully.
|
---|
1464 | @return other - An error occurred when expanding file.
|
---|
1465 |
|
---|
1466 | **/
|
---|
1467 | EFI_STATUS
|
---|
1468 | FatExpandOFile (
|
---|
1469 | IN FAT_OFILE *OFile,
|
---|
1470 | IN UINT64 ExpandedSize
|
---|
1471 | );
|
---|
1472 |
|
---|
1473 | /**
|
---|
1474 |
|
---|
1475 | Write zero pool from the WritePos to the end of OFile.
|
---|
1476 |
|
---|
1477 | @param OFile - The open file to write zero pool.
|
---|
1478 | @param WritePos - The number of zero bytes written.
|
---|
1479 |
|
---|
1480 | @retval EFI_SUCCESS - Write the zero pool successfully.
|
---|
1481 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to perform the operation.
|
---|
1482 | @return other - An error occurred when writing disk.
|
---|
1483 |
|
---|
1484 | **/
|
---|
1485 | EFI_STATUS
|
---|
1486 | FatWriteZeroPool (
|
---|
1487 | IN FAT_OFILE *OFile,
|
---|
1488 | IN UINTN WritePos
|
---|
1489 | );
|
---|
1490 |
|
---|
1491 | /**
|
---|
1492 |
|
---|
1493 | Truncate the OFile to smaller file size.
|
---|
1494 |
|
---|
1495 | @param OFile - The open file.
|
---|
1496 | @param TruncatedSize - The new file size.
|
---|
1497 |
|
---|
1498 | @retval EFI_SUCCESS - The file is truncated successfully.
|
---|
1499 | @return other - An error occurred when truncating file.
|
---|
1500 |
|
---|
1501 | **/
|
---|
1502 | EFI_STATUS
|
---|
1503 | FatTruncateOFile (
|
---|
1504 | IN FAT_OFILE *OFile,
|
---|
1505 | IN UINTN TruncatedSize
|
---|
1506 | );
|
---|
1507 |
|
---|
1508 | //
|
---|
1509 | // DirectoryManage.c
|
---|
1510 | //
|
---|
1511 |
|
---|
1512 | /**
|
---|
1513 |
|
---|
1514 | Set the OFile's current directory cursor to the list head.
|
---|
1515 |
|
---|
1516 | @param OFile - The directory OFile whose directory cursor is reset.
|
---|
1517 |
|
---|
1518 | **/
|
---|
1519 | VOID
|
---|
1520 | FatResetODirCursor (
|
---|
1521 | IN FAT_OFILE *OFile
|
---|
1522 | );
|
---|
1523 |
|
---|
1524 | /**
|
---|
1525 |
|
---|
1526 | Set the directory's cursor to the next and get the next directory entry.
|
---|
1527 |
|
---|
1528 | @param OFile - The parent OFile.
|
---|
1529 | @param PtrDirEnt - The next directory entry.
|
---|
1530 |
|
---|
1531 | @retval EFI_SUCCESS - We get the next directory entry successfully.
|
---|
1532 | @return other - An error occurred when get next directory entry.
|
---|
1533 |
|
---|
1534 | **/
|
---|
1535 | EFI_STATUS
|
---|
1536 | FatGetNextDirEnt (
|
---|
1537 | IN FAT_OFILE *OFile,
|
---|
1538 | OUT FAT_DIRENT **PtrDirEnt
|
---|
1539 | );
|
---|
1540 |
|
---|
1541 | /**
|
---|
1542 |
|
---|
1543 | Remove this directory entry node from the list of directory entries and hash table.
|
---|
1544 |
|
---|
1545 | @param OFile - The parent OFile.
|
---|
1546 | @param DirEnt - The directory entry to be removed.
|
---|
1547 |
|
---|
1548 | @retval EFI_SUCCESS - The directory entry is successfully removed.
|
---|
1549 | @return other - An error occurred when removing the directory entry.
|
---|
1550 |
|
---|
1551 | **/
|
---|
1552 | EFI_STATUS
|
---|
1553 | FatRemoveDirEnt (
|
---|
1554 | IN FAT_OFILE *OFile,
|
---|
1555 | IN FAT_DIRENT *DirEnt
|
---|
1556 | );
|
---|
1557 |
|
---|
1558 | /**
|
---|
1559 |
|
---|
1560 | Save the directory entry to disk.
|
---|
1561 |
|
---|
1562 | @param OFile - The parent OFile which needs to update.
|
---|
1563 | @param DirEnt - The directory entry to be saved.
|
---|
1564 |
|
---|
1565 | @retval EFI_SUCCESS - Store the directory entry successfully.
|
---|
1566 | @return other - An error occurred when writing the directory entry.
|
---|
1567 |
|
---|
1568 | **/
|
---|
1569 | EFI_STATUS
|
---|
1570 | FatStoreDirEnt (
|
---|
1571 | IN FAT_OFILE *OFile,
|
---|
1572 | IN FAT_DIRENT *DirEnt
|
---|
1573 | );
|
---|
1574 |
|
---|
1575 | /**
|
---|
1576 |
|
---|
1577 | Create a directory entry in the parent OFile.
|
---|
1578 |
|
---|
1579 | @param OFile - The parent OFile.
|
---|
1580 | @param FileName - The filename of the newly-created directory entry.
|
---|
1581 | @param Attributes - The attribute of the newly-created directory entry.
|
---|
1582 | @param PtrDirEnt - The pointer to the newly-created directory entry.
|
---|
1583 |
|
---|
1584 | @retval EFI_SUCCESS - The directory entry is successfully created.
|
---|
1585 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to create the directory entry.
|
---|
1586 | @return other - An error occurred when creating the directory entry.
|
---|
1587 |
|
---|
1588 | **/
|
---|
1589 | EFI_STATUS
|
---|
1590 | FatCreateDirEnt (
|
---|
1591 | IN FAT_OFILE *OFile,
|
---|
1592 | IN CHAR16 *FileName,
|
---|
1593 | IN UINT8 Attributes,
|
---|
1594 | OUT FAT_DIRENT **PtrDirEnt
|
---|
1595 | );
|
---|
1596 |
|
---|
1597 | /**
|
---|
1598 |
|
---|
1599 | Determine whether the directory entry is "." or ".." entry.
|
---|
1600 |
|
---|
1601 | @param DirEnt - The corresponding directory entry.
|
---|
1602 |
|
---|
1603 | @retval TRUE - The directory entry is "." or ".." directory entry
|
---|
1604 | @retval FALSE - The directory entry is not "." or ".." directory entry
|
---|
1605 |
|
---|
1606 | **/
|
---|
1607 | BOOLEAN
|
---|
1608 | FatIsDotDirEnt (
|
---|
1609 | IN FAT_DIRENT *DirEnt
|
---|
1610 | );
|
---|
1611 |
|
---|
1612 | /**
|
---|
1613 |
|
---|
1614 | Set the OFile's cluster and size info in its directory entry.
|
---|
1615 |
|
---|
1616 | @param OFile - The corresponding OFile.
|
---|
1617 |
|
---|
1618 | **/
|
---|
1619 | VOID
|
---|
1620 | FatUpdateDirEntClusterSizeInfo (
|
---|
1621 | IN FAT_OFILE *OFile
|
---|
1622 | );
|
---|
1623 |
|
---|
1624 | /**
|
---|
1625 |
|
---|
1626 | Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.
|
---|
1627 |
|
---|
1628 | @param DirEnt1 - The destination directory entry.
|
---|
1629 | @param DirEnt2 - The source directory entry.
|
---|
1630 |
|
---|
1631 | **/
|
---|
1632 | VOID
|
---|
1633 | FatCloneDirEnt (
|
---|
1634 | IN FAT_DIRENT *DirEnt1,
|
---|
1635 | IN FAT_DIRENT *DirEnt2
|
---|
1636 | );
|
---|
1637 |
|
---|
1638 | /**
|
---|
1639 |
|
---|
1640 | Get the directory entry's info into Buffer.
|
---|
1641 |
|
---|
1642 | @param Volume - FAT file system volume.
|
---|
1643 | @param DirEnt - The corresponding directory entry.
|
---|
1644 | @param BufferSize - Size of Buffer.
|
---|
1645 | @param Buffer - Buffer containing file info.
|
---|
1646 |
|
---|
1647 | @retval EFI_SUCCESS - Get the file info successfully.
|
---|
1648 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.
|
---|
1649 |
|
---|
1650 | **/
|
---|
1651 | EFI_STATUS
|
---|
1652 | FatGetDirEntInfo (
|
---|
1653 | IN FAT_VOLUME *Volume,
|
---|
1654 | IN FAT_DIRENT *DirEnt,
|
---|
1655 | IN OUT UINTN *BufferSize,
|
---|
1656 | OUT VOID *Buffer
|
---|
1657 | );
|
---|
1658 |
|
---|
1659 | /**
|
---|
1660 |
|
---|
1661 | Open the directory entry to get the OFile.
|
---|
1662 |
|
---|
1663 | @param Parent - The parent OFile.
|
---|
1664 | @param DirEnt - The directory entry to be opened.
|
---|
1665 |
|
---|
1666 | @retval EFI_SUCCESS - The directory entry is successfully opened.
|
---|
1667 | @retval EFI_OUT_OF_RESOURCES - not enough memory to allocate a new OFile.
|
---|
1668 | @return other - An error occurred when opening the directory entry.
|
---|
1669 |
|
---|
1670 | **/
|
---|
1671 | EFI_STATUS
|
---|
1672 | FatOpenDirEnt (
|
---|
1673 | IN FAT_OFILE *OFile,
|
---|
1674 | IN FAT_DIRENT *DirEnt
|
---|
1675 | );
|
---|
1676 |
|
---|
1677 | /**
|
---|
1678 |
|
---|
1679 | Create "." and ".." directory entries in the newly-created parent OFile.
|
---|
1680 |
|
---|
1681 | @param OFile - The parent OFile.
|
---|
1682 |
|
---|
1683 | @retval EFI_SUCCESS - The dot directory entries are successfully created.
|
---|
1684 | @return other - An error occurred when creating the directory entry.
|
---|
1685 |
|
---|
1686 | **/
|
---|
1687 | EFI_STATUS
|
---|
1688 | FatCreateDotDirEnts (
|
---|
1689 | IN FAT_OFILE *OFile
|
---|
1690 | );
|
---|
1691 |
|
---|
1692 | /**
|
---|
1693 |
|
---|
1694 | Close the directory entry and free the OFile.
|
---|
1695 |
|
---|
1696 | @param DirEnt - The directory entry to be closed.
|
---|
1697 |
|
---|
1698 | **/
|
---|
1699 | VOID
|
---|
1700 | FatCloseDirEnt (
|
---|
1701 | IN FAT_DIRENT *DirEnt
|
---|
1702 | );
|
---|
1703 |
|
---|
1704 | /**
|
---|
1705 |
|
---|
1706 | Traverse filename and open all OFiles that can be opened.
|
---|
1707 | Update filename pointer to the component that can't be opened.
|
---|
1708 | If more than one name component remains, returns an error;
|
---|
1709 | otherwise, return the remaining name component so that the caller might choose to create it.
|
---|
1710 |
|
---|
1711 | @param PtrOFile - As input, the reference OFile; as output, the located OFile.
|
---|
1712 | @param FileName - The file name relevant to the OFile.
|
---|
1713 | @param Attributes - The attribute of the destination OFile.
|
---|
1714 | @param NewFileName - The remaining file name.
|
---|
1715 |
|
---|
1716 | @retval EFI_NOT_FOUND - The file name can't be opened and there is more than one
|
---|
1717 | components within the name left (this means the name can
|
---|
1718 | not be created either).
|
---|
1719 | @retval EFI_INVALID_PARAMETER - The parameter is not valid.
|
---|
1720 | @retval EFI_SUCCESS - Open the file successfully.
|
---|
1721 | @return other - An error occurred when locating the OFile.
|
---|
1722 |
|
---|
1723 | **/
|
---|
1724 | EFI_STATUS
|
---|
1725 | FatLocateOFile (
|
---|
1726 | IN OUT FAT_OFILE **PtrOFile,
|
---|
1727 | IN CHAR16 *FileName,
|
---|
1728 | IN UINT8 Attributes,
|
---|
1729 | OUT CHAR16 *NewFileName
|
---|
1730 | );
|
---|
1731 |
|
---|
1732 | /**
|
---|
1733 |
|
---|
1734 | Get the directory entry for the volume.
|
---|
1735 |
|
---|
1736 | @param Volume - FAT file system volume.
|
---|
1737 | @param Name - The file name of the volume.
|
---|
1738 |
|
---|
1739 | @retval EFI_SUCCESS - Update the volume with the directory entry successfully.
|
---|
1740 | @return others - An error occurred when getting volume label.
|
---|
1741 |
|
---|
1742 | **/
|
---|
1743 | EFI_STATUS
|
---|
1744 | FatGetVolumeEntry (
|
---|
1745 | IN FAT_VOLUME *Volume,
|
---|
1746 | IN CHAR16 *Name
|
---|
1747 | );
|
---|
1748 |
|
---|
1749 | /**
|
---|
1750 |
|
---|
1751 | Set the relevant directory entry into disk for the volume.
|
---|
1752 |
|
---|
1753 | @param Volume - FAT file system volume.
|
---|
1754 | @param Name - The new file name of the volume.
|
---|
1755 |
|
---|
1756 | @retval EFI_SUCCESS - Update the Volume successfully.
|
---|
1757 | @retval EFI_UNSUPPORTED - The input label is not a valid volume label.
|
---|
1758 | @return other - An error occurred when setting volume label.
|
---|
1759 |
|
---|
1760 | **/
|
---|
1761 | EFI_STATUS
|
---|
1762 | FatSetVolumeEntry (
|
---|
1763 | IN FAT_VOLUME *Volume,
|
---|
1764 | IN CHAR16 *Name
|
---|
1765 | );
|
---|
1766 |
|
---|
1767 | //
|
---|
1768 | // Hash.c
|
---|
1769 | //
|
---|
1770 |
|
---|
1771 | /**
|
---|
1772 |
|
---|
1773 | Search the long name hash table for the directory entry.
|
---|
1774 |
|
---|
1775 | @param ODir - The directory to be searched.
|
---|
1776 | @param LongNameString - The long name string to search.
|
---|
1777 |
|
---|
1778 | @return The previous long name hash node of the directory entry.
|
---|
1779 |
|
---|
1780 | **/
|
---|
1781 | FAT_DIRENT **
|
---|
1782 | FatLongNameHashSearch (
|
---|
1783 | IN FAT_ODIR *ODir,
|
---|
1784 | IN CHAR16 *LongNameString
|
---|
1785 | );
|
---|
1786 |
|
---|
1787 | /**
|
---|
1788 |
|
---|
1789 | Search the short name hash table for the directory entry.
|
---|
1790 |
|
---|
1791 | @param ODir - The directory to be searched.
|
---|
1792 | @param ShortNameString - The short name string to search.
|
---|
1793 |
|
---|
1794 | @return The previous short name hash node of the directory entry.
|
---|
1795 |
|
---|
1796 | **/
|
---|
1797 | FAT_DIRENT **
|
---|
1798 | FatShortNameHashSearch (
|
---|
1799 | IN FAT_ODIR *ODir,
|
---|
1800 | IN CHAR8 *ShortNameString
|
---|
1801 | );
|
---|
1802 |
|
---|
1803 | /**
|
---|
1804 |
|
---|
1805 | Insert directory entry to hash table.
|
---|
1806 |
|
---|
1807 | @param ODir - The parent directory.
|
---|
1808 | @param DirEnt - The directory entry node.
|
---|
1809 |
|
---|
1810 | **/
|
---|
1811 | VOID
|
---|
1812 | FatInsertToHashTable (
|
---|
1813 | IN FAT_ODIR *ODir,
|
---|
1814 | IN FAT_DIRENT *DirEnt
|
---|
1815 | );
|
---|
1816 |
|
---|
1817 | /**
|
---|
1818 |
|
---|
1819 | Delete directory entry from hash table.
|
---|
1820 |
|
---|
1821 | @param ODir - The parent directory.
|
---|
1822 | @param DirEnt - The directory entry node.
|
---|
1823 |
|
---|
1824 | **/
|
---|
1825 | VOID
|
---|
1826 | FatDeleteFromHashTable (
|
---|
1827 | IN FAT_ODIR *ODir,
|
---|
1828 | IN FAT_DIRENT *DirEnt
|
---|
1829 | );
|
---|
1830 |
|
---|
1831 | //
|
---|
1832 | // FileName.c
|
---|
1833 | //
|
---|
1834 |
|
---|
1835 | /**
|
---|
1836 |
|
---|
1837 | This function checks whether the input FileName is a valid 8.3 short name.
|
---|
1838 | If the input FileName is a valid 8.3, the output is the 8.3 short name;
|
---|
1839 | otherwise, the output is the base tag of 8.3 short name.
|
---|
1840 |
|
---|
1841 | @param FileName - The input unicode filename.
|
---|
1842 | @param File8Dot3Name - The output ascii 8.3 short name or base tag of 8.3 short name.
|
---|
1843 |
|
---|
1844 | @retval TRUE - The input unicode filename is a valid 8.3 short name.
|
---|
1845 | @retval FALSE - The input unicode filename is not a valid 8.3 short name.
|
---|
1846 |
|
---|
1847 | **/
|
---|
1848 | BOOLEAN
|
---|
1849 | FatCheckIs8Dot3Name (
|
---|
1850 | IN CHAR16 *FileName,
|
---|
1851 | OUT CHAR8 *File8Dot3Name
|
---|
1852 | );
|
---|
1853 |
|
---|
1854 | /**
|
---|
1855 |
|
---|
1856 | This function generates 8Dot3 name from user specified name for a newly created file.
|
---|
1857 |
|
---|
1858 | @param Parent - The parent directory.
|
---|
1859 | @param DirEnt - The directory entry whose 8Dot3Name needs to be generated.
|
---|
1860 |
|
---|
1861 | **/
|
---|
1862 | VOID
|
---|
1863 | FatCreate8Dot3Name (
|
---|
1864 | IN FAT_OFILE *Parent,
|
---|
1865 | IN FAT_DIRENT *DirEnt
|
---|
1866 | );
|
---|
1867 |
|
---|
1868 | /**
|
---|
1869 |
|
---|
1870 | Convert the ascii fat name to the unicode string and strip trailing spaces,
|
---|
1871 | and if necessary, convert the unicode string to lower case.
|
---|
1872 |
|
---|
1873 | @param FatName - The Char8 string needs to be converted.
|
---|
1874 | @param Len - The length of the fat name.
|
---|
1875 | @param LowerCase - Indicate whether to convert the string to lower case.
|
---|
1876 | @param Str - The result of the conversion.
|
---|
1877 |
|
---|
1878 | **/
|
---|
1879 | VOID
|
---|
1880 | FatNameToStr (
|
---|
1881 | IN CHAR8 *FatName,
|
---|
1882 | IN UINTN Len,
|
---|
1883 | IN UINTN LowerCase,
|
---|
1884 | IN CHAR16 *Str
|
---|
1885 | );
|
---|
1886 |
|
---|
1887 | /**
|
---|
1888 |
|
---|
1889 | Set the caseflag value for the directory entry.
|
---|
1890 |
|
---|
1891 | @param DirEnt - The logical directory entry whose caseflag value is to be set.
|
---|
1892 |
|
---|
1893 | **/
|
---|
1894 | VOID
|
---|
1895 | FatSetCaseFlag (
|
---|
1896 | IN FAT_DIRENT *DirEnt
|
---|
1897 | );
|
---|
1898 |
|
---|
1899 | /**
|
---|
1900 |
|
---|
1901 | Convert the 8.3 ASCII fat name to cased Unicode string according to case flag.
|
---|
1902 |
|
---|
1903 | @param DirEnt - The corresponding directory entry.
|
---|
1904 | @param FileString - The output Unicode file name.
|
---|
1905 | @param FileStringMax The max length of FileString.
|
---|
1906 |
|
---|
1907 | **/
|
---|
1908 | VOID
|
---|
1909 | FatGetFileNameViaCaseFlag (
|
---|
1910 | IN FAT_DIRENT *DirEnt,
|
---|
1911 | IN OUT CHAR16 *FileString,
|
---|
1912 | IN UINTN FileStringMax
|
---|
1913 | );
|
---|
1914 |
|
---|
1915 | /**
|
---|
1916 |
|
---|
1917 | Get the Check sum for a short name.
|
---|
1918 |
|
---|
1919 | @param ShortNameString - The short name for a file.
|
---|
1920 |
|
---|
1921 | @retval Sum - UINT8 checksum.
|
---|
1922 |
|
---|
1923 | **/
|
---|
1924 | UINT8
|
---|
1925 | FatCheckSum (
|
---|
1926 | IN CHAR8 *ShortNameString
|
---|
1927 | );
|
---|
1928 |
|
---|
1929 | /**
|
---|
1930 |
|
---|
1931 | Takes Path as input, returns the next name component
|
---|
1932 | in Name, and returns the position after Name (e.g., the
|
---|
1933 | start of the next name component)
|
---|
1934 |
|
---|
1935 | @param Path - The path of one file.
|
---|
1936 | @param Name - The next name component in Path.
|
---|
1937 |
|
---|
1938 | The position after Name in the Path
|
---|
1939 |
|
---|
1940 | **/
|
---|
1941 | CHAR16 *
|
---|
1942 | FatGetNextNameComponent (
|
---|
1943 | IN CHAR16 *Path,
|
---|
1944 | OUT CHAR16 *Name
|
---|
1945 | );
|
---|
1946 |
|
---|
1947 | /**
|
---|
1948 |
|
---|
1949 | Check whether the IFileName is valid long file name. If the IFileName is a valid
|
---|
1950 | long file name, then we trim the possible leading blanks and leading/trailing dots.
|
---|
1951 | the trimmed filename is stored in OutputFileName
|
---|
1952 |
|
---|
1953 | @param InputFileName - The input file name.
|
---|
1954 | @param OutputFileName - The output file name.
|
---|
1955 |
|
---|
1956 | @retval TRUE - The InputFileName is a valid long file name.
|
---|
1957 | @retval FALSE - The InputFileName is not a valid long file name.
|
---|
1958 |
|
---|
1959 | **/
|
---|
1960 | BOOLEAN
|
---|
1961 | FatFileNameIsValid (
|
---|
1962 | IN CHAR16 *InputFileName,
|
---|
1963 | OUT CHAR16 *OutputFileName
|
---|
1964 | );
|
---|
1965 |
|
---|
1966 | //
|
---|
1967 | // DirectoryCache.c
|
---|
1968 | //
|
---|
1969 |
|
---|
1970 | /**
|
---|
1971 |
|
---|
1972 | Discard the directory structure when an OFile will be freed.
|
---|
1973 | Volume will cache this directory if the OFile does not represent a deleted file.
|
---|
1974 |
|
---|
1975 | @param OFile - The OFile whose directory structure is to be discarded.
|
---|
1976 |
|
---|
1977 | **/
|
---|
1978 | VOID
|
---|
1979 | FatDiscardODir (
|
---|
1980 | IN FAT_OFILE *OFile
|
---|
1981 | );
|
---|
1982 |
|
---|
1983 | /**
|
---|
1984 |
|
---|
1985 | Request the directory structure when an OFile is newly generated.
|
---|
1986 | If the directory structure is cached by volume, then just return this directory;
|
---|
1987 | Otherwise, allocate a new one for OFile.
|
---|
1988 |
|
---|
1989 | @param OFile - The OFile which requests directory structure.
|
---|
1990 |
|
---|
1991 | **/
|
---|
1992 | VOID
|
---|
1993 | FatRequestODir (
|
---|
1994 | IN FAT_OFILE *OFile
|
---|
1995 | );
|
---|
1996 |
|
---|
1997 | /**
|
---|
1998 |
|
---|
1999 | Clean up all the cached directory structures when the volume is going to be abandoned.
|
---|
2000 |
|
---|
2001 | @param Volume - FAT file system volume.
|
---|
2002 |
|
---|
2003 | **/
|
---|
2004 | VOID
|
---|
2005 | FatCleanupODirCache (
|
---|
2006 | IN FAT_VOLUME *Volume
|
---|
2007 | );
|
---|
2008 |
|
---|
2009 | //
|
---|
2010 | // Global Variables
|
---|
2011 | //
|
---|
2012 | extern EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding;
|
---|
2013 | extern EFI_COMPONENT_NAME_PROTOCOL gFatComponentName;
|
---|
2014 | extern EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2;
|
---|
2015 | extern EFI_LOCK FatFsLock;
|
---|
2016 | extern EFI_LOCK FatTaskLock;
|
---|
2017 | extern EFI_FILE_PROTOCOL FatFileInterface;
|
---|
2018 |
|
---|
2019 | #endif
|
---|