fatfs.h 4.0 KB

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