TianoCore EDK2 master
Loading...
Searching...
No Matches
FatLiteFmt.h
Go to the documentation of this file.
1
10#ifndef _FAT_FMT_H_
11#define _FAT_FMT_H_
12
13//
14// Definitions
15//
16#define FAT_ATTR_READ_ONLY 0x01
17#define FAT_ATTR_HIDDEN 0x02
18#define FAT_ATTR_SYSTEM 0x04
19#define FAT_ATTR_VOLUME_ID 0x08
20#define FAT_ATTR_DIRECTORY 0x10
21#define FAT_ATTR_ARCHIVE 0x20
22#define FAT_ATTR_LFN (FAT_ATTR_READ_ONLY | FAT_ATTR_HIDDEN | FAT_ATTR_SYSTEM | FAT_ATTR_VOLUME_ID)
23
24#define FAT_CLUSTER_SPECIAL ((MAX_UINT32 &~0xF) | 0x7)
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
30#define DELETE_ENTRY_MARK 0xE5
31#define EMPTY_ENTRY_MARK 0x00
32
33#define FAT_CLUSTER_FUNCTIONAL(Cluster) (((Cluster) == 0) || ((Cluster) >= FAT_CLUSTER_SPECIAL))
34#define FAT_CLUSTER_END_OF_CHAIN(Cluster) ((Cluster) > (FAT_CLUSTER_SPECIAL))
35
36//
37// Directory Entry
38//
39#pragma pack(1)
40
41typedef struct {
42 UINT16 Day : 5;
43 UINT16 Month : 4;
44 UINT16 Year : 7; // From 1980
45} FAT_DATE;
46
47typedef struct {
48 UINT16 DoubleSecond : 5;
49 UINT16 Minute : 6;
50 UINT16 Hour : 5;
51} FAT_TIME;
52
53typedef struct {
54 FAT_TIME Time;
55 FAT_DATE Date;
57
58typedef struct {
59 CHAR8 FileName[11]; // 8.3 filename
60 UINT8 Attributes;
61 UINT8 CaseFlag;
62 UINT8 CreateMillisecond; // (creation milliseconds - ignored)
63 FAT_DATE_TIME FileCreateTime;
64 FAT_DATE FileLastAccess;
65 UINT16 FileClusterHigh; // >= FAT32
66 FAT_DATE_TIME FileModificationTime;
67 UINT16 FileCluster;
68 UINT32 FileSize;
70
71#pragma pack()
72//
73// Boot Sector
74//
75#pragma pack(1)
76
77typedef struct {
78 UINT8 Ia32Jump[3];
79 CHAR8 OemId[8];
80
81 UINT16 SectorSize;
82 UINT8 SectorsPerCluster;
83 UINT16 ReservedSectors;
84 UINT8 NoFats;
85 UINT16 RootEntries; // < FAT32, root dir is fixed size
86 UINT16 Sectors;
87 UINT8 Media; // (ignored)
88 UINT16 SectorsPerFat; // < FAT32
89 UINT16 SectorsPerTrack; // (ignored)
90 UINT16 Heads; // (ignored)
91 UINT32 HiddenSectors; // (ignored)
92 UINT32 LargeSectors; // => FAT32
93 UINT8 PhysicalDriveNumber; // (ignored)
94 UINT8 CurrentHead; // holds boot_sector_dirty bit
95 UINT8 Signature; // (ignored)
96 CHAR8 Id[4];
97 CHAR8 FatLabel[11];
98 CHAR8 SystemId[8];
100
101typedef struct {
102 UINT8 Ia32Jump[3];
103 CHAR8 OemId[8];
104
105 UINT16 SectorSize;
106 UINT8 SectorsPerCluster;
107 UINT16 ReservedSectors;
108 UINT8 NoFats;
109 UINT16 RootEntries; // < FAT32, root dir is fixed size
110 UINT16 Sectors;
111 UINT8 Media; // (ignored)
112 UINT16 SectorsPerFat; // < FAT32
113 UINT16 SectorsPerTrack; // (ignored)
114 UINT16 Heads; // (ignored)
115 UINT32 HiddenSectors; // (ignored)
116 UINT32 LargeSectors; // Used if Sectors==0
117 UINT32 LargeSectorsPerFat; // FAT32
118 UINT16 ExtendedFlags; // FAT32 (ignored)
119 UINT16 FsVersion; // FAT32 (ignored)
120 UINT32 RootDirFirstCluster; // FAT32
121 UINT16 FsInfoSector; // FAT32
122 UINT16 BackupBootSector; // FAT32
123 UINT8 Reserved[12]; // FAT32 (ignored)
124 UINT8 PhysicalDriveNumber; // (ignored)
125 UINT8 CurrentHead; // holds boot_sector_dirty bit
126 UINT8 Signature; // (ignored)
127 CHAR8 Id[4];
128 CHAR8 FatLabel[11];
129 CHAR8 SystemId[8];
131
132#pragma pack()
133
134#endif