]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Guid/Btt.h
MdePkg FirmwareManagement.h: Fix typo EFI_SECURITY_VIOLATIO
[mirror_edk2.git] / MdePkg / Include / Guid / Btt.h
CommitLineData
0fbca22f
RN
1/** @file\r
2 Block Translation Table (BTT) metadata layout definition.\r
3\r
4 BTT is a layout and set of rules for doing block I/O that provide powerfail\r
5 write atomicity of a single block.\r
6\r
7Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
8This program and the accompanying materials are licensed and made available under\r
9the terms and conditions of the BSD License that accompanies this distribution.\r
10The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php.\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 @par Revision Reference:\r
17 This metadata layout definition was introduced in UEFI Specification 2.7.\r
18\r
19**/\r
20\r
21#ifndef _BTT_H_\r
22#define _BTT_H_\r
23\r
24///\r
25/// The BTT layout and behavior is described by the GUID as below.\r
26///\r
27#define EFI_BTT_ABSTRACTION_GUID \\r
28 { \\r
29 0x18633bfc, 0x1735, 0x4217, { 0x8a, 0xc9, 0x17, 0x23, 0x92, 0x82, 0xd3, 0xf8 } \\r
30 }\r
31\r
32//\r
33// Alignment of all BTT structures\r
34//\r
35#define EFI_BTT_ALIGNMENT 4096\r
36\r
37#define EFI_BTT_INFO_UNUSED_LEN 3968\r
38\r
39#define EFI_BTT_INFO_BLOCK_SIG_LEN 16\r
40\r
41///\r
42/// Indicate inconsistent metadata or lost metadata due to unrecoverable media errors.\r
43///\r
44#define EFI_BTT_INFO_BLOCK_FLAGS_ERROR 0x00000001\r
45\r
46#define EFI_BTT_INFO_BLOCK_MAJOR_VERSION 2\r
47#define EFI_BTT_INFO_BLOCK_MINOR_VERSION 0\r
48\r
49///\r
50/// Block Translation Table (BTT) Info Block\r
51///\r
52typedef struct _EFI_BTT_INFO_BLOCK {\r
53 ///\r
54 /// Signature of the BTT Index Block data structure.\r
55 /// Shall be "BTT_ARENA_INFO\0\0".\r
56 ///\r
57 CHAR8 Sig[EFI_BTT_INFO_BLOCK_SIG_LEN];\r
58\r
59 ///\r
60 /// UUID identifying this BTT instance.\r
61 ///\r
62 GUID Uuid;\r
63\r
64 ///\r
65 /// UUID of containing namespace.\r
66 ///\r
67 GUID ParentUuid;\r
68\r
69 ///\r
70 /// Attributes of this BTT Info Block.\r
71 ///\r
72 UINT32 Flags;\r
73\r
74 ///\r
75 /// Major version number. Currently at version 2.\r
76 ///\r
77 UINT16 Major;\r
78\r
79 ///\r
80 /// Minor version number. Currently at version 0.\r
81 ///\r
82 UINT16 Minor;\r
83\r
84 ///\r
85 /// Advertised LBA size in bytes. I/O requests shall be in this size chunk.\r
86 ///\r
87 UINT32 ExternalLbaSize;\r
88\r
89 ///\r
90 /// Advertised number of LBAs in this arena.\r
91 ///\r
92 UINT32 ExternalNLba;\r
93\r
94 ///\r
95 /// Internal LBA size shall be greater than or equal to ExternalLbaSize and shall not be smaller than 512 bytes.\r
96 ///\r
97 UINT32 InternalLbaSize;\r
98\r
99 ///\r
100 /// Number of internal blocks in the arena data area.\r
101 ///\r
102 UINT32 InternalNLba;\r
103\r
104 ///\r
105 /// Number of free blocks maintained for writes to this arena.\r
106 ///\r
107 UINT32 NFree;\r
108\r
109 ///\r
110 /// The size of this info block in bytes.\r
111 ///\r
112 UINT32 InfoSize;\r
113\r
114 ///\r
115 /// Offset of next arena, relative to the beginning of this arena.\r
116 ///\r
117 UINT64 NextOff;\r
118\r
119 ///\r
120 /// Offset of the data area for this arena, relative to the beginning of this arena.\r
121 ///\r
122 UINT64 DataOff;\r
123\r
124 ///\r
125 /// Offset of the map for this arena, relative to the beginning of this arena.\r
126 ///\r
127 UINT64 MapOff;\r
128\r
129 ///\r
130 /// Offset of the flog for this arena, relative to the beginning of this arena.\r
131 ///\r
132 UINT64 FlogOff;\r
133\r
134 ///\r
135 /// Offset of the backup copy of this arena's info block, relative to the beginning of this arena.\r
136 ///\r
137 UINT64 InfoOff;\r
138\r
139 ///\r
140 /// Shall be zero.\r
141 ///\r
142 CHAR8 Unused[EFI_BTT_INFO_UNUSED_LEN];\r
143\r
144 ///\r
145 /// 64-bit Fletcher64 checksum of all fields.\r
146 ///\r
147 UINT64 Checksum;\r
148} EFI_BTT_INFO_BLOCK;\r
149\r
150///\r
151/// BTT Map entry maps an LBA that indexes into the arena, to its actual location.\r
152///\r
153typedef struct _EFI_BTT_MAP_ENTRY {\r
154 ///\r
155 /// Post-map LBA number (block number in this arena's data area)\r
156 ///\r
157 UINT32 PostMapLba : 30;\r
158\r
159 ///\r
160 /// When set and Zero is not set, reads on this block return an error.\r
161 /// When set and Zero is set, indicate a map entry in its normal, non-error state.\r
162 ///\r
163 UINT32 Error : 1;\r
164\r
165 ///\r
166 /// When set and Error is not set, reads on this block return a full block of zeros.\r
167 /// When set and Error is set, indicate a map entry in its normal, non-error state.\r
168 ///\r
169 UINT32 Zero : 1;\r
170} EFI_BTT_MAP_ENTRY;\r
171\r
172///\r
173/// Alignment of each flog structure\r
174///\r
175#define EFI_BTT_FLOG_ENTRY_ALIGNMENT 64\r
176\r
177///\r
178/// The BTT Flog is both a free list and a log.\r
179/// The Flog size is determined by the EFI_BTT_INFO_BLOCK.NFree which determines how many of these flog\r
180/// entries there are.\r
181/// The Flog location is the highest aligned address in the arena after space for the backup info block.\r
182///\r
183typedef struct _EFI_BTT_FLOG {\r
184 ///\r
185 /// Last pre-map LBA written using this flog entry.\r
186 ///\r
187 UINT32 Lba0;\r
188\r
189 ///\r
190 /// Old post-map LBA.\r
191 ///\r
192 UINT32 OldMap0;\r
193\r
194 ///\r
195 /// New post-map LBA.\r
196 ///\r
197 UINT32 NewMap0;\r
198\r
199 ///\r
200 /// The Seq0 field in each flog entry is used to determine which set of fields is newer between the two sets\r
201 /// (Lba0, OldMap0, NewMpa0, Seq0 vs Lba1, Oldmap1, NewMap1, Seq1).\r
202 ///\r
203 UINT32 Seq0;\r
204\r
205 ///\r
206 /// Alternate lba entry.\r
207 ///\r
208 UINT32 Lba1;\r
209\r
210 ///\r
211 /// Alternate old entry.\r
212 ///\r
213 UINT32 OldMap1;\r
214\r
215 ///\r
216 /// Alternate new entry.\r
217 ///\r
218 UINT32 NewMap1;\r
219\r
220 ///\r
221 /// Alternate Seq entry.\r
222 ///\r
223 UINT32 Seq1;\r
224} EFI_BTT_FLOG;\r
225\r
226extern GUID gEfiBttAbstractionGuid;\r
227\r
228#endif //_BTT_H_\r