Fat.h 25 KB

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