1 /** @file 2 This file defines NvDataFv GUID and FTW working block structures. 3 The NvDataFv GUID can be used as FileSystemGuid in EFI_FIRMWARE_VOLUME_HEADER if 4 this FV image contains NV data, such as NV variable data. 5 This file also defines WorkingBlockSignature GUID for FTW working block signature. 6 7 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR> 8 This program and the accompanying materials are licensed and made available under 9 the terms and conditions of the BSD License that accompanies this distribution. 10 The full text of the license may be found at 11 http://opensource.org/licenses/bsd-license.php. 12 13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 15 16 **/ 17 18 #ifndef __SYSTEM_NV_DATA_GUID_H__ 19 #define __SYSTEM_NV_DATA_GUID_H__ 20 21 #define EFI_SYSTEM_NV_DATA_FV_GUID \ 22 {0xfff12b8d, 0x7696, 0x4c8b, {0xa9, 0x85, 0x27, 0x47, 0x7, 0x5b, 0x4f, 0x50} } 23 24 #define EDKII_WORKING_BLOCK_SIGNATURE_GUID \ 25 {0x9e58292b, 0x7c68, 0x497d, {0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95} } 26 27 extern EFI_GUID gEfiSystemNvDataFvGuid; 28 extern EFI_GUID gEdkiiWorkingBlockSignatureGuid; 29 30 #define WORKING_BLOCK_VALID 0x1 31 #define WORKING_BLOCK_INVALID 0x2 32 33 /// 34 /// The EDKII Fault tolerant working block header. 35 /// The header is immediately followed by the write queue data. 36 /// 37 typedef struct { 38 /// 39 /// FTW working block signature. 40 /// Its value has be updated from gEfiSystemNvDataFvGuid to gEdkiiWorkingBlockSignatureGuid, 41 /// because its write queue data format has been updated to support the crossing archs. 42 /// 43 EFI_GUID Signature; 44 /// 45 /// 32bit CRC calculated for this header. 46 /// 47 UINT32 Crc; 48 /// 49 /// Working block valid bit. 50 /// 51 UINT8 WorkingBlockValid : 1; 52 UINT8 WorkingBlockInvalid : 1; 53 UINT8 Reserved : 6; 54 UINT8 Reserved3[3]; 55 /// 56 /// Total size of the following write queue range. 57 /// 58 UINT64 WriteQueueSize; 59 /// 60 /// Write Queue data. 61 /// 62 /// EFI_FAULT_TOLERANT_WRITE_HEADER FtwHeader; 63 /// EFI_FAULT_TOLERANT_WRITE_RECORD FtwRecord[FtwHeader.NumberOfWrites] 64 /// EFI_FAULT_TOLERANT_WRITE_HEADER FtwHeader2; 65 /// EFI_FAULT_TOLERANT_WRITE_RECORD FtwRecord2[FtwHeader2.NumberOfWrites] 66 /// ... 67 /// 68 } EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER; 69 70 #define FTW_VALID_STATE 0 71 #define FTW_INVALID_STATE 1 72 73 // 74 // EFI Fault tolerant block update write queue entry. 75 // 76 typedef struct { 77 UINT8 HeaderAllocated : 1; 78 UINT8 WritesAllocated : 1; 79 UINT8 Complete : 1; 80 UINT8 Reserved : 5; 81 EFI_GUID CallerId; 82 UINT64 NumberOfWrites; 83 UINT64 PrivateDataSize; 84 } EFI_FAULT_TOLERANT_WRITE_HEADER; 85 86 // 87 // EFI Fault tolerant block update write queue record. 88 // 89 typedef struct { 90 UINT8 BootBlockUpdate : 1; 91 UINT8 SpareComplete : 1; 92 UINT8 DestinationComplete : 1; 93 UINT8 Reserved : 5; 94 EFI_LBA Lba; 95 UINT64 Offset; 96 UINT64 Length; 97 // 98 // Relative offset to spare block. 99 // 100 INT64 RelativeOffset; 101 // 102 // UINT8 PrivateData[PrivateDataSize] 103 // 104 } EFI_FAULT_TOLERANT_WRITE_RECORD; 105 106 #define FTW_RECORD_SIZE(PrivateDataSize) (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + (UINTN) PrivateDataSize) 107 108 #define FTW_RECORD_TOTAL_SIZE(NumberOfWrites, PrivateDataSize) \ 109 ((UINTN) (NumberOfWrites) * (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + (UINTN) PrivateDataSize)) 110 111 #define FTW_WRITE_TOTAL_SIZE(NumberOfWrites, PrivateDataSize) \ 112 ( \ 113 sizeof (EFI_FAULT_TOLERANT_WRITE_HEADER) + (UINTN) (NumberOfWrites) * \ 114 (sizeof (EFI_FAULT_TOLERANT_WRITE_RECORD) + (UINTN) PrivateDataSize) \ 115 ) 116 117 #endif 118