--- /dev/null
+/** @file\r
+ Block Translation Table (BTT) metadata layout definition.\r
+\r
+ BTT is a layout and set of rules for doing block I/O that provide powerfail\r
+ write atomicity of a single block.\r
+\r
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+ @par Revision Reference:\r
+ This metadata layout definition was introduced in UEFI Specification 2.7.\r
+\r
+**/\r
+\r
+#ifndef _BTT_H_\r
+#define _BTT_H_\r
+\r
+///\r
+/// The BTT layout and behavior is described by the GUID as below.\r
+///\r
+#define EFI_BTT_ABSTRACTION_GUID \\r
+ { \\r
+ 0x18633bfc, 0x1735, 0x4217, { 0x8a, 0xc9, 0x17, 0x23, 0x92, 0x82, 0xd3, 0xf8 } \\r
+ }\r
+\r
+//\r
+// Alignment of all BTT structures\r
+//\r
+#define EFI_BTT_ALIGNMENT 4096\r
+\r
+#define EFI_BTT_INFO_UNUSED_LEN 3968\r
+\r
+#define EFI_BTT_INFO_BLOCK_SIG_LEN 16\r
+\r
+///\r
+/// Indicate inconsistent metadata or lost metadata due to unrecoverable media errors.\r
+///\r
+#define EFI_BTT_INFO_BLOCK_FLAGS_ERROR 0x00000001\r
+\r
+#define EFI_BTT_INFO_BLOCK_MAJOR_VERSION 2\r
+#define EFI_BTT_INFO_BLOCK_MINOR_VERSION 0\r
+\r
+///\r
+/// Block Translation Table (BTT) Info Block\r
+///\r
+typedef struct _EFI_BTT_INFO_BLOCK {\r
+ ///\r
+ /// Signature of the BTT Index Block data structure.\r
+ /// Shall be "BTT_ARENA_INFO\0\0".\r
+ ///\r
+ CHAR8 Sig[EFI_BTT_INFO_BLOCK_SIG_LEN];\r
+\r
+ ///\r
+ /// UUID identifying this BTT instance.\r
+ ///\r
+ GUID Uuid;\r
+\r
+ ///\r
+ /// UUID of containing namespace.\r
+ ///\r
+ GUID ParentUuid;\r
+\r
+ ///\r
+ /// Attributes of this BTT Info Block.\r
+ ///\r
+ UINT32 Flags;\r
+\r
+ ///\r
+ /// Major version number. Currently at version 2.\r
+ ///\r
+ UINT16 Major;\r
+\r
+ ///\r
+ /// Minor version number. Currently at version 0.\r
+ ///\r
+ UINT16 Minor;\r
+\r
+ ///\r
+ /// Advertised LBA size in bytes. I/O requests shall be in this size chunk.\r
+ ///\r
+ UINT32 ExternalLbaSize;\r
+\r
+ ///\r
+ /// Advertised number of LBAs in this arena.\r
+ ///\r
+ UINT32 ExternalNLba;\r
+\r
+ ///\r
+ /// Internal LBA size shall be greater than or equal to ExternalLbaSize and shall not be smaller than 512 bytes.\r
+ ///\r
+ UINT32 InternalLbaSize;\r
+\r
+ ///\r
+ /// Number of internal blocks in the arena data area.\r
+ ///\r
+ UINT32 InternalNLba;\r
+\r
+ ///\r
+ /// Number of free blocks maintained for writes to this arena.\r
+ ///\r
+ UINT32 NFree;\r
+\r
+ ///\r
+ /// The size of this info block in bytes.\r
+ ///\r
+ UINT32 InfoSize;\r
+\r
+ ///\r
+ /// Offset of next arena, relative to the beginning of this arena.\r
+ ///\r
+ UINT64 NextOff;\r
+\r
+ ///\r
+ /// Offset of the data area for this arena, relative to the beginning of this arena.\r
+ ///\r
+ UINT64 DataOff;\r
+\r
+ ///\r
+ /// Offset of the map for this arena, relative to the beginning of this arena.\r
+ ///\r
+ UINT64 MapOff;\r
+\r
+ ///\r
+ /// Offset of the flog for this arena, relative to the beginning of this arena.\r
+ ///\r
+ UINT64 FlogOff;\r
+\r
+ ///\r
+ /// Offset of the backup copy of this arena's info block, relative to the beginning of this arena.\r
+ ///\r
+ UINT64 InfoOff;\r
+\r
+ ///\r
+ /// Shall be zero.\r
+ ///\r
+ CHAR8 Unused[EFI_BTT_INFO_UNUSED_LEN];\r
+\r
+ ///\r
+ /// 64-bit Fletcher64 checksum of all fields.\r
+ ///\r
+ UINT64 Checksum;\r
+} EFI_BTT_INFO_BLOCK;\r
+\r
+///\r
+/// BTT Map entry maps an LBA that indexes into the arena, to its actual location.\r
+///\r
+typedef struct _EFI_BTT_MAP_ENTRY {\r
+ ///\r
+ /// Post-map LBA number (block number in this arena's data area)\r
+ ///\r
+ UINT32 PostMapLba : 30;\r
+\r
+ ///\r
+ /// When set and Zero is not set, reads on this block return an error.\r
+ /// When set and Zero is set, indicate a map entry in its normal, non-error state.\r
+ ///\r
+ UINT32 Error : 1;\r
+\r
+ ///\r
+ /// When set and Error is not set, reads on this block return a full block of zeros.\r
+ /// When set and Error is set, indicate a map entry in its normal, non-error state.\r
+ ///\r
+ UINT32 Zero : 1;\r
+} EFI_BTT_MAP_ENTRY;\r
+\r
+///\r
+/// Alignment of each flog structure\r
+///\r
+#define EFI_BTT_FLOG_ENTRY_ALIGNMENT 64\r
+\r
+///\r
+/// The BTT Flog is both a free list and a log.\r
+/// The Flog size is determined by the EFI_BTT_INFO_BLOCK.NFree which determines how many of these flog\r
+/// entries there are.\r
+/// The Flog location is the highest aligned address in the arena after space for the backup info block.\r
+///\r
+typedef struct _EFI_BTT_FLOG {\r
+ ///\r
+ /// Last pre-map LBA written using this flog entry.\r
+ ///\r
+ UINT32 Lba0;\r
+\r
+ ///\r
+ /// Old post-map LBA.\r
+ ///\r
+ UINT32 OldMap0;\r
+\r
+ ///\r
+ /// New post-map LBA.\r
+ ///\r
+ UINT32 NewMap0;\r
+\r
+ ///\r
+ /// The Seq0 field in each flog entry is used to determine which set of fields is newer between the two sets\r
+ /// (Lba0, OldMap0, NewMpa0, Seq0 vs Lba1, Oldmap1, NewMap1, Seq1).\r
+ ///\r
+ UINT32 Seq0;\r
+\r
+ ///\r
+ /// Alternate lba entry.\r
+ ///\r
+ UINT32 Lba1;\r
+\r
+ ///\r
+ /// Alternate old entry.\r
+ ///\r
+ UINT32 OldMap1;\r
+\r
+ ///\r
+ /// Alternate new entry.\r
+ ///\r
+ UINT32 NewMap1;\r
+\r
+ ///\r
+ /// Alternate Seq entry.\r
+ ///\r
+ UINT32 Seq1;\r
+} EFI_BTT_FLOG;\r
+\r
+extern GUID gEfiBttAbstractionGuid;\r
+\r
+#endif //_BTT_H_\r