]>
Commit | Line | Data |
---|---|---|
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 | |
7 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r | |
9344f092 | 8 | SPDX-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 | |
2f88bd3a | 29 | #define EFI_BTT_ALIGNMENT 4096\r |
0fbca22f | 30 | \r |
2f88bd3a | 31 | #define EFI_BTT_INFO_UNUSED_LEN 3968\r |
0fbca22f | 32 | \r |
2f88bd3a | 33 | #define EFI_BTT_INFO_BLOCK_SIG_LEN 16\r |
0fbca22f RN |
34 | \r |
35 | ///\r | |
36 | /// Indicate inconsistent metadata or lost metadata due to unrecoverable media errors.\r | |
37 | ///\r | |
2f88bd3a | 38 | #define EFI_BTT_INFO_BLOCK_FLAGS_ERROR 0x00000001\r |
0fbca22f | 39 | \r |
2f88bd3a MK |
40 | #define EFI_BTT_INFO_BLOCK_MAJOR_VERSION 2\r |
41 | #define EFI_BTT_INFO_BLOCK_MINOR_VERSION 0\r | |
0fbca22f RN |
42 | \r |
43 | ///\r | |
44 | /// Block Translation Table (BTT) Info Block\r | |
45 | ///\r | |
46 | typedef 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 | |
2f88bd3a | 51 | CHAR8 Sig[EFI_BTT_INFO_BLOCK_SIG_LEN];\r |
0fbca22f RN |
52 | \r |
53 | ///\r | |
54 | /// UUID identifying this BTT instance.\r | |
55 | ///\r | |
2f88bd3a | 56 | GUID Uuid;\r |
0fbca22f RN |
57 | \r |
58 | ///\r | |
59 | /// UUID of containing namespace.\r | |
60 | ///\r | |
2f88bd3a | 61 | GUID ParentUuid;\r |
0fbca22f RN |
62 | \r |
63 | ///\r | |
64 | /// Attributes of this BTT Info Block.\r | |
65 | ///\r | |
2f88bd3a | 66 | UINT32 Flags;\r |
0fbca22f RN |
67 | \r |
68 | ///\r | |
69 | /// Major version number. Currently at version 2.\r | |
70 | ///\r | |
2f88bd3a | 71 | UINT16 Major;\r |
0fbca22f RN |
72 | \r |
73 | ///\r | |
74 | /// Minor version number. Currently at version 0.\r | |
75 | ///\r | |
2f88bd3a | 76 | UINT16 Minor;\r |
0fbca22f RN |
77 | \r |
78 | ///\r | |
79 | /// Advertised LBA size in bytes. I/O requests shall be in this size chunk.\r | |
80 | ///\r | |
2f88bd3a | 81 | UINT32 ExternalLbaSize;\r |
0fbca22f RN |
82 | \r |
83 | ///\r | |
84 | /// Advertised number of LBAs in this arena.\r | |
85 | ///\r | |
2f88bd3a | 86 | UINT32 ExternalNLba;\r |
0fbca22f RN |
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 | |
2f88bd3a | 91 | UINT32 InternalLbaSize;\r |
0fbca22f RN |
92 | \r |
93 | ///\r | |
94 | /// Number of internal blocks in the arena data area.\r | |
95 | ///\r | |
2f88bd3a | 96 | UINT32 InternalNLba;\r |
0fbca22f RN |
97 | \r |
98 | ///\r | |
99 | /// Number of free blocks maintained for writes to this arena.\r | |
100 | ///\r | |
2f88bd3a | 101 | UINT32 NFree;\r |
0fbca22f RN |
102 | \r |
103 | ///\r | |
104 | /// The size of this info block in bytes.\r | |
105 | ///\r | |
2f88bd3a | 106 | UINT32 InfoSize;\r |
0fbca22f RN |
107 | \r |
108 | ///\r | |
109 | /// Offset of next arena, relative to the beginning of this arena.\r | |
110 | ///\r | |
2f88bd3a | 111 | UINT64 NextOff;\r |
0fbca22f RN |
112 | \r |
113 | ///\r | |
114 | /// Offset of the data area for this arena, relative to the beginning of this arena.\r | |
115 | ///\r | |
2f88bd3a | 116 | UINT64 DataOff;\r |
0fbca22f RN |
117 | \r |
118 | ///\r | |
119 | /// Offset of the map for this arena, relative to the beginning of this arena.\r | |
120 | ///\r | |
2f88bd3a | 121 | UINT64 MapOff;\r |
0fbca22f RN |
122 | \r |
123 | ///\r | |
124 | /// Offset of the flog for this arena, relative to the beginning of this arena.\r | |
125 | ///\r | |
2f88bd3a | 126 | UINT64 FlogOff;\r |
0fbca22f RN |
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 | |
2f88bd3a | 131 | UINT64 InfoOff;\r |
0fbca22f RN |
132 | \r |
133 | ///\r | |
134 | /// Shall be zero.\r | |
135 | ///\r | |
2f88bd3a | 136 | CHAR8 Unused[EFI_BTT_INFO_UNUSED_LEN];\r |
0fbca22f RN |
137 | \r |
138 | ///\r | |
139 | /// 64-bit Fletcher64 checksum of all fields.\r | |
140 | ///\r | |
2f88bd3a | 141 | UINT64 Checksum;\r |
0fbca22f RN |
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 | |
147 | typedef struct _EFI_BTT_MAP_ENTRY {\r | |
148 | ///\r | |
149 | /// Post-map LBA number (block number in this arena's data area)\r | |
150 | ///\r | |
2f88bd3a | 151 | UINT32 PostMapLba : 30;\r |
0fbca22f RN |
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 | |
2f88bd3a | 157 | UINT32 Error : 1;\r |
0fbca22f RN |
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 | |
2f88bd3a | 163 | UINT32 Zero : 1;\r |
0fbca22f RN |
164 | } EFI_BTT_MAP_ENTRY;\r |
165 | \r | |
166 | ///\r | |
167 | /// Alignment of each flog structure\r | |
168 | ///\r | |
2f88bd3a | 169 | #define EFI_BTT_FLOG_ENTRY_ALIGNMENT 64\r |
0fbca22f RN |
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 | |
177 | typedef struct _EFI_BTT_FLOG {\r | |
178 | ///\r | |
179 | /// Last pre-map LBA written using this flog entry.\r | |
180 | ///\r | |
2f88bd3a | 181 | UINT32 Lba0;\r |
0fbca22f RN |
182 | \r |
183 | ///\r | |
184 | /// Old post-map LBA.\r | |
185 | ///\r | |
2f88bd3a | 186 | UINT32 OldMap0;\r |
0fbca22f RN |
187 | \r |
188 | ///\r | |
189 | /// New post-map LBA.\r | |
190 | ///\r | |
2f88bd3a | 191 | UINT32 NewMap0;\r |
0fbca22f RN |
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 | |
2f88bd3a | 197 | UINT32 Seq0;\r |
0fbca22f RN |
198 | \r |
199 | ///\r | |
200 | /// Alternate lba entry.\r | |
201 | ///\r | |
2f88bd3a | 202 | UINT32 Lba1;\r |
0fbca22f RN |
203 | \r |
204 | ///\r | |
205 | /// Alternate old entry.\r | |
206 | ///\r | |
2f88bd3a | 207 | UINT32 OldMap1;\r |
0fbca22f RN |
208 | \r |
209 | ///\r | |
210 | /// Alternate new entry.\r | |
211 | ///\r | |
2f88bd3a | 212 | UINT32 NewMap1;\r |
0fbca22f RN |
213 | \r |
214 | ///\r | |
215 | /// Alternate Seq entry.\r | |
216 | ///\r | |
2f88bd3a | 217 | UINT32 Seq1;\r |
0fbca22f RN |
218 | } EFI_BTT_FLOG;\r |
219 | \r | |
2f88bd3a | 220 | extern GUID gEfiBttAbstractionGuid;\r |
0fbca22f RN |
221 | \r |
222 | #endif //_BTT_H_\r |