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