10#ifndef _FATFILESYSTEM_H_
11#define _FATFILESYSTEM_H_
17#define FAT_INFO_SIGNATURE 0x41615252
18#define FAT_INFO_BEGIN_SIGNATURE 0x61417272
19#define FAT_INFO_END_SIGNATURE 0xAA550000
23#define FAT_CLUSTER_SPECIAL_EXT (MAX_UINTN & (~0xF))
24#define FAT_CLUSTER_SPECIAL ((FAT_CLUSTER_SPECIAL_EXT) | 0x07)
25#define FAT_CLUSTER_FREE 0
26#define FAT_CLUSTER_RESERVED (FAT_CLUSTER_SPECIAL)
27#define FAT_CLUSTER_BAD (FAT_CLUSTER_SPECIAL)
28#define FAT_CLUSTER_LAST (-1)
29#define FAT_END_OF_FAT_CHAIN(Cluster) ((Cluster) > (FAT_CLUSTER_SPECIAL))
30#define FAT_MIN_CLUSTER 2
31#define FAT_MAX_FAT12_CLUSTER 0xFF5
32#define FAT_MAX_FAT16_CLUSTER 0xFFF5
33#define FAT_CLUSTER_SPECIAL_FAT12 0xFF7
34#define FAT_CLUSTER_SPECIAL_FAT16 0xFFF7
35#define FAT_CLUSTER_SPECIAL_FAT32 0x0FFFFFF7
36#define FAT_CLUSTER_MASK_FAT12 0xFFF
37#define FAT_CLUSTER_UNMASK_FAT12 0xF000
38#define FAT_CLUSTER_MASK_FAT32 0x0FFFFFFF
39#define FAT_CLUSTER_UNMASK_FAT32 0xF0000000
40#define FAT_POS_FAT12(a) ((a) * 3 / 2)
41#define FAT_POS_FAT16(a) ((a) * 2)
42#define FAT_POS_FAT32(a) ((a) * 4)
43#define FAT_ODD_CLUSTER_FAT12(a) (((a) & 1) != 0)
48#define FAT_ATTRIBUTE_READ_ONLY 0x01
49#define FAT_ATTRIBUTE_HIDDEN 0x02
50#define FAT_ATTRIBUTE_SYSTEM 0x04
51#define FAT_ATTRIBUTE_VOLUME_ID 0x08
52#define FAT_ATTRIBUTE_DIRECTORY 0x10
53#define FAT_ATTRIBUTE_ARCHIVE 0x20
54#define FAT_ATTRIBUTE_DEVICE 0x40
55#define FAT_ATTRIBUTE_LFN 0x0F
59#define FAT_LFN_LAST 0x40
60#define MAX_LFN_ENTRIES 20
61#define LFN_CHAR1_LEN 5
62#define LFN_CHAR2_LEN 6
63#define LFN_CHAR3_LEN 2
64#define LFN_CHAR_TOTAL (LFN_CHAR1_LEN + LFN_CHAR2_LEN + LFN_CHAR3_LEN)
65#define LFN_ENTRY_NUMBER(a) (((a) + LFN_CHAR_TOTAL - 1) / LFN_CHAR_TOTAL)
69#define FAT_MAIN_NAME_LEN 8
70#define FAT_EXTEND_NAME_LEN 3
71#define FAT_NAME_LEN (FAT_MAIN_NAME_LEN + FAT_EXTEND_NAME_LEN)
75#define FAT_ENTRY_INFO_OFFSET 13
76#define DELETE_ENTRY_MARK 0xE5
77#define EMPTY_ENTRY_MARK 0x00
82#define FAT16_DIRTY_MASK 0x7fff
83#define FAT32_DIRTY_MASK 0xf7ffffff
87#define FAT_CASE_MIXED 0x01
88#define FAT_CASE_NAME_LOWER 0x08
89#define FAT_CASE_EXT_LOWER 0x10
95 UINT8 SectorsPerCluster;
96 UINT16 ReservedSectors;
101 UINT16 SectorsPerFat;
102 UINT16 SectorsPerTrack;
104 UINT32 HiddenSectors;
109 UINT8 PhysicalDriveNumber;
118 UINT32 LargeSectorsPerFat;
119 UINT16 ExtendedFlags;
121 UINT32 RootDirFirstCluster;
123 UINT16 BackupBootSector;
125 UINT8 PhysicalDriveNumber;
153 UINT8 ExtraBootCode[480];
154 UINT32 InfoBeginSignature;
157 UINT32 InfoEndSignature;
163#define FAT_MAX_YEAR_FROM_1980 0x7f
171 UINT16 DoubleSecond : 5;
185 UINT8 CreateMillisecond;
188 UINT16 FileClusterHigh;