fatfs.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*++
  2. Copyright (c) 2014 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. fatfs.h
  9. Abstract:
  10. This header contains internal definitions for the FAT file system driver
  11. in the UEFI core.
  12. Author:
  13. Evan Green 21-Mar-2014
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. //
  19. // --------------------------------------------------------------------- Macros
  20. //
  21. //
  22. // This macro returns a pointer to the FAT volume data given a pointer to the
  23. // Simple File System protocol instance.
  24. //
  25. #define EFI_FAT_VOLUME_FROM_THIS(_SimpleFileSystem) \
  26. PARENT_STRUCTURE(_SimpleFileSystem, EFI_FAT_VOLUME, SimpleFileSystem)
  27. //
  28. // This macro returns a pointer to the FAT file data given a pointer to the
  29. // File protocol instance.
  30. //
  31. #define EFI_FAT_FILE_FROM_THIS(_File) \
  32. PARENT_STRUCTURE(_File, EFI_FAT_FILE, FileProtocol)
  33. //
  34. // ---------------------------------------------------------------- Definitions
  35. //
  36. #define EFI_FAT_VOLUME_MAGIC 0x56746146 // 'VtaF'
  37. #define EFI_FAT_FILE_MAGIC 0x46746146 // 'FtaF'
  38. #define EFI_FAT_DIRECTORY_ENTRY_SIZE 300
  39. //
  40. // ------------------------------------------------------ Data Type Definitions
  41. //
  42. /*++
  43. Structure Description:
  44. This structure stores internal data regarding a FAT volume.
  45. Members:
  46. Magic - Stores the constant value EFI_FAT_VOLUME_MAGIC.
  47. FatVolume - Stores a pointer to the FAT library volume handle.
  48. Handle - Stores the handle the simple file system protocol is installed on.
  49. DiskIo - Stores a pointer to the underlying disk I/O protocol used.
  50. BlockIo - Stores a pointer to the underlying block I/O protocol.
  51. BlockSize - Stores the block size of the underlying block I/O device.
  52. MediaId - Stores the identifier of the media when this file system was
  53. mounted.
  54. RootDirectoryId - Stores the ID of the root directory. This is almost
  55. always 2 for FAT file systems.
  56. ReadOnly - Stores a boolean indicating if the volume is mounted read only.
  57. SimpleFileSystem - Stores the simple file system protocol data.
  58. OpenFiles - Stores the count of open files on this volume.
  59. --*/
  60. typedef struct _EFI_FAT_VOLUME {
  61. UINT32 Magic;
  62. VOID *FatVolume;
  63. EFI_HANDLE Handle;
  64. EFI_DISK_IO_PROTOCOL *DiskIo;
  65. EFI_BLOCK_IO_PROTOCOL *BlockIo;
  66. UINT32 BlockSize;
  67. UINT32 MediaId;
  68. UINT64 RootDirectoryId;
  69. BOOLEAN ReadOnly;
  70. EFI_SIMPLE_FILE_SYSTEM_PROTOCOL SimpleFileSystem;
  71. UINTN OpenFiles;
  72. } EFI_FAT_VOLUME, *PEFI_FAT_VOLUME;
  73. /*++
  74. Structure Description:
  75. This structure stores internal data regarding a FAT volume.
  76. Members:
  77. Magic - Stores the constant value EFI_FAT_VOLUME_MAGIC.
  78. MediaId - Stores the media ID of the volume when the file was opened.
  79. FileProtocol - Stores the file protocol for this file.
  80. Volume - Stores a pointer back to the volume.
  81. IsRoot - Stores a boolean indicating if this is the root directory.
  82. IsOpenForRead - Stores a boolean indicating whether the file is open for
  83. read access.
  84. IsDirty - Stores a boolean indicating if the file properties need to be
  85. written out to disk.
  86. DirectoryFileId - Stores the file ID of the directory this file resides in.
  87. FileName - Stores a pointer to the name of the file.
  88. Properties - Stores the file properties.
  89. FatFile - Stores a pointer to the FAT library file information.
  90. SeekInformation - Stores the file seek information.
  91. CurrentOffset - Stores the current file offset.
  92. --*/
  93. typedef struct _EFI_FAT_FILE {
  94. UINT32 Magic;
  95. UINT32 MediaId;
  96. EFI_FILE_PROTOCOL FileProtocol;
  97. PEFI_FAT_VOLUME Volume;
  98. BOOLEAN IsRoot;
  99. BOOLEAN IsOpenForRead;
  100. BOOLEAN IsDirty;
  101. UINT64 DirectoryFileId;
  102. CHAR8 *FileName;
  103. FILE_PROPERTIES Properties;
  104. VOID *FatFile;
  105. FAT_SEEK_INFORMATION SeekInformation;
  106. UINT64 CurrentOffset;
  107. } EFI_FAT_FILE, *PEFI_FAT_FILE;
  108. //
  109. // -------------------------------------------------------------------- Globals
  110. //
  111. //
  112. // -------------------------------------------------------- Function Prototypes
  113. //