Add Linux version of GenBootSector for DuetPkg to generate Boot image.Now only floppy...
[efi/basetools/.git] / Source / C / GnuGenBootSector / FatFormat.h
1 /** @file\r
2 \r
3   Fat file system structure and definition.\r
4 \r
5 Copyright 2006 - 2008, Intel Corporation                                                         \r
6 All rights reserved. This program and the accompanying materials                          \r
7 are licensed and made available under the terms and conditions of the BSD License         \r
8 which accompanies this distribution.  The full text of the license may be found at        \r
9 http://opensource.org/licenses/bsd-license.php                                            \r
10                                                                                           \r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
13 \r
14 --*/\r
15 \r
16 #ifndef _FAT_BPB_H_\r
17 #define _FAT_BPB_H_\r
18 \r
19 #include "CommonLib.h"\r
20 \r
21 #pragma pack(1)\r
22 \r
23 typedef struct {\r
24   //\r
25   // Fat common field\r
26   //\r
27   UINT8              BS_jmpBoot[3];\r
28   CHAR8              BS_OEMName[8];\r
29   UINT16             BPB_BytsPerSec;\r
30   UINT8              BPB_SecPerClus;\r
31   UINT16             BPB_RsvdSecCnt;\r
32   UINT8              BPB_NumFATs;\r
33   UINT16             BPB_RootEntCnt;\r
34   UINT16             BPB_TotSec16;\r
35   UINT8              BPB_Media;\r
36   UINT16             BPB_FATSz16;\r
37   UINT16             BPB_SecPerTrk;\r
38   UINT16             BPB_NumHeads;\r
39   UINT32             BPB_HiddSec;\r
40   UINT32             BPB_TotSec32;\r
41 \r
42   //\r
43   // Fat12/16 specific field\r
44   //\r
45   UINT8              BS_DrvNum;\r
46   UINT8              BS_Reserved1;\r
47   UINT8              BS_BootSig;\r
48   UINT32             BS_VolID;\r
49   CHAR8              BS_VolLab[11];\r
50   CHAR8              BS_FilSysType[8];\r
51 \r
52   //\r
53   // Boot Code and Data\r
54   //\r
55   UINT8              Reserved[448];\r
56 \r
57   //\r
58   // Fat common signature - 0xAA55\r
59   //\r
60   UINT16             Signature;\r
61 } FAT12_16_BPB_STRUCT;\r
62 \r
63 typedef struct {\r
64   //\r
65   // Fat common field\r
66   //\r
67   UINT8              BS_jmpBoot[3];\r
68   CHAR8              BS_OEMName[8];\r
69   UINT16             BPB_BytsPerSec;\r
70   UINT8              BPB_SecPerClus;\r
71   UINT16             BPB_RsvdSecCnt;\r
72   UINT8              BPB_NumFATs;\r
73   UINT16             BPB_RootEntCnt;\r
74   UINT16             BPB_TotSec16;\r
75   UINT8              BPB_Media;\r
76   UINT16             BPB_FATSz16;\r
77   UINT16             BPB_SecPerTrk;\r
78   UINT16             BPB_NumHeads;\r
79   UINT32             BPB_HiddSec;\r
80   UINT32             BPB_TotSec32;\r
81 \r
82   //\r
83   // Fat32 specific field\r
84   //\r
85   UINT32             BPB_FATSz32;\r
86   UINT16             BPB_ExtFlags;\r
87   UINT16             BPB_FSVer;\r
88   UINT32             BPB_RootClus;\r
89   UINT16             BPB_FSInfo;\r
90   UINT16             BPB_BkBootSec;\r
91   UINT8              BPB_Reserved[12];\r
92   UINT8              BS_DrvNum;\r
93   UINT8              BS_Reserved1;\r
94   UINT8              BS_BootSig;\r
95   UINT32             BS_VolID;\r
96   CHAR8              BS_VolLab[11];\r
97   CHAR8              BS_FilSysType[8];\r
98 \r
99   //\r
100   // Boot Code and Data\r
101   //\r
102   UINT8              Reserved[420];\r
103 \r
104   //\r
105   // Fat common signature - 0xAA55\r
106   //\r
107   UINT16             Signature;\r
108 } FAT32_BPB_STRUCT;\r
109 \r
110 typedef union {\r
111   FAT12_16_BPB_STRUCT   Fat12_16;\r
112   FAT32_BPB_STRUCT      Fat32;\r
113 } FAT_BPB_STRUCT;\r
114 \r
115 typedef enum {\r
116   FatTypeUnknown,\r
117   FatTypeFat12,\r
118   FatTypeFat16,\r
119   FatTypeFat32,\r
120   FatTypeMax\r
121 } FAT_TYPE;\r
122 \r
123 typedef struct {\r
124   CHAR8              DIR_Name[11];\r
125   UINT8              DIR_Attr;\r
126   UINT8              DIR_NTRes;\r
127   UINT8              DIR_CrtTimeTenth;\r
128   UINT16             DIR_CrtTime;\r
129   UINT16             DIR_CrtDate;\r
130   UINT16             DIR_LstAccDate;\r
131   UINT16             DIR_FstClusHI;\r
132   UINT16             DIR_WrtTime;\r
133   UINT16             DIR_WrtDate;\r
134   UINT16             DIR_FstClusLO;\r
135   UINT32             DIR_FileSize;\r
136 } FAT_DIRECTORY_ENTRY;\r
137 \r
138 #pragma pack()\r
139 \r
140 #define FAT_MAX_FAT12_CLUSTER         0xFF5\r
141 #define FAT_MAX_FAT16_CLUSTER         0xFFF5\r
142 \r
143 #define FAT_BS_SIGNATURE      0xAA55\r
144 #define FAT_BS_BOOTSIG        0x29\r
145 #define FAT_BS_JMP1           0xEB\r
146 #define FAT_BS_JMP2           0xE9\r
147 #define FAT_FILSYSTYPE        "FAT     "\r
148 #define FAT12_FILSYSTYPE      "FAT12   "\r
149 #define FAT16_FILSYSTYPE      "FAT16   "\r
150 #define FAT32_FILSYSTYPE      "FAT32   "\r
151 \r
152 #endif\r