]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Guid/VariableFormat.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Include / Guid / VariableFormat.h
CommitLineData
5f597758 1/** @file\r
e9b67286 2 The variable data structures are related to EDK II-specific implementation of UEFI variables.\r
3 VariableFormat.h defines variable data headers and variable storage region headers.\r
3cfb790c 4\r
de005223 5Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
3cfb790c 7\r
8**/\r
9\r
10#ifndef __VARIABLE_FORMAT_H__\r
11#define __VARIABLE_FORMAT_H__\r
12\r
3709c4cd 13#define EFI_VARIABLE_GUID \\r
14 { 0xddcf3616, 0x3275, 0x4164, { 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d } }\r
15\r
1fe6c125
SZ
16#define EFI_AUTHENTICATED_VARIABLE_GUID \\r
17 { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } }\r
18\r
1436aea4
MK
19extern EFI_GUID gEfiVariableGuid;\r
20extern EFI_GUID gEfiAuthenticatedVariableGuid;\r
3709c4cd 21\r
ebafc55b 22///\r
e9b67286 23/// Alignment of variable name and data, according to the architecture:\r
64a80549 24/// * For IA-32 and Intel(R) 64 architectures: 1.\r
ebafc55b 25///\r
1436aea4 26#define ALIGNMENT 1\r
3cfb790c 27\r
e5618791 28//\r
e9b67286 29// GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.\r
e5618791 30//\r
d4cb8e71 31#if (ALIGNMENT == 1)\r
1436aea4 32#define GET_PAD_SIZE(a) (0)\r
e5618791 33#else\r
1436aea4 34#define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))\r
e5618791
LG
35#endif\r
36\r
37///\r
64a80549 38/// Alignment of Variable Data Header in Variable Store region.\r
e5618791 39///\r
9cad030b 40#define HEADER_ALIGNMENT 4\r
e5618791 41#define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))\r
9cad030b 42\r
ebafc55b 43///\r
64a80549 44/// Status of Variable Store Region.\r
ebafc55b 45///\r
3cfb790c 46typedef enum {\r
47 EfiRaw,\r
48 EfiValid,\r
49 EfiInvalid,\r
50 EfiUnknown\r
51} VARIABLE_STORE_STATUS;\r
52\r
3cfb790c 53#pragma pack(1)\r
54\r
1436aea4 55#define VARIABLE_STORE_SIGNATURE EFI_VARIABLE_GUID\r
1fe6c125 56#define AUTHENTICATED_VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID\r
ebafc55b
LG
57\r
58///\r
64a80549 59/// Variable Store Header Format and State.\r
ebafc55b 60///\r
1436aea4
MK
61#define VARIABLE_STORE_FORMATTED 0x5a\r
62#define VARIABLE_STORE_HEALTHY 0xfe\r
ebafc55b
LG
63\r
64///\r
64a80549 65/// Variable Store region header.\r
ebafc55b 66///\r
3cfb790c 67typedef struct {\r
ebafc55b
LG
68 ///\r
69 /// Variable store region signature.\r
70 ///\r
1436aea4 71 EFI_GUID Signature;\r
ebafc55b 72 ///\r
b6477d82 73 /// Size of entire variable store,\r
3709c4cd 74 /// including size of variable store header but not including the size of FvHeader.\r
ebafc55b 75 ///\r
1436aea4 76 UINT32 Size;\r
ebafc55b 77 ///\r
64a80549 78 /// Variable region format state.\r
ebafc55b 79 ///\r
1436aea4 80 UINT8 Format;\r
ebafc55b 81 ///\r
64a80549 82 /// Variable region healthy state.\r
ebafc55b 83 ///\r
1436aea4
MK
84 UINT8 State;\r
85 UINT16 Reserved;\r
86 UINT32 Reserved1;\r
3cfb790c 87} VARIABLE_STORE_HEADER;\r
88\r
ebafc55b 89///\r
64a80549 90/// Variable data start flag.\r
ebafc55b 91///\r
1436aea4 92#define VARIABLE_DATA 0x55AA\r
ebafc55b
LG
93\r
94///\r
64a80549 95/// Variable State flags.\r
ebafc55b 96///\r
1436aea4
MK
97#define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.\r
98#define VAR_DELETED 0xfd ///< Variable is obsolete.\r
99#define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.\r
100#define VAR_ADDED 0x3f ///< Variable has been completely added.\r
ebafc55b 101\r
b6477d82
SZ
102///\r
103/// Variable Attribute combinations.\r
104///\r
1436aea4
MK
105#define VARIABLE_ATTRIBUTE_NV_BS (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)\r
106#define VARIABLE_ATTRIBUTE_BS_RT (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)\r
107#define VARIABLE_ATTRIBUTE_BS_RT_AT (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)\r
108#define VARIABLE_ATTRIBUTE_NV_BS_RT (VARIABLE_ATTRIBUTE_BS_RT | EFI_VARIABLE_NON_VOLATILE)\r
109#define VARIABLE_ATTRIBUTE_NV_BS_RT_HR (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_HARDWARE_ERROR_RECORD)\r
110#define VARIABLE_ATTRIBUTE_NV_BS_RT_AT (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS)\r
111#define VARIABLE_ATTRIBUTE_AT EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\r
112#define VARIABLE_ATTRIBUTE_NV_BS_RT_HR_AT (VARIABLE_ATTRIBUTE_NV_BS_RT_HR | VARIABLE_ATTRIBUTE_AT)\r
4073f85d
ZC
113///\r
114/// EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and should be considered as reserved\r
115///\r
1436aea4
MK
116#define VARIABLE_ATTRIBUTE_AT_AW (EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)\r
117#define VARIABLE_ATTRIBUTE_NV_BS_RT_AW (VARIABLE_ATTRIBUTE_NV_BS_RT | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS)\r
118#define VARIABLE_ATTRIBUTE_NV_BS_RT_HR_AT_AW (VARIABLE_ATTRIBUTE_NV_BS_RT_HR | VARIABLE_ATTRIBUTE_AT_AW)\r
b6477d82 119\r
ebafc55b 120///\r
64a80549 121/// Single Variable Data Header Structure.\r
ebafc55b 122///\r
3cfb790c 123typedef struct {\r
ebafc55b 124 ///\r
64a80549 125 /// Variable Data Start Flag.\r
ebafc55b 126 ///\r
3cfb790c 127 UINT16 StartId;\r
ebafc55b 128 ///\r
64a80549 129 /// Variable State defined above.\r
ebafc55b 130 ///\r
3cfb790c 131 UINT8 State;\r
132 UINT8 Reserved;\r
ebafc55b 133 ///\r
64a80549 134 /// Attributes of variable defined in UEFI specification.\r
ebafc55b 135 ///\r
3cfb790c 136 UINT32 Attributes;\r
ebafc55b 137 ///\r
64a80549 138 /// Size of variable null-terminated Unicode string name.\r
ebafc55b 139 ///\r
3cfb790c 140 UINT32 NameSize;\r
ebafc55b 141 ///\r
64a80549 142 /// Size of the variable data without this header.\r
ebafc55b 143 ///\r
3cfb790c 144 UINT32 DataSize;\r
ebafc55b 145 ///\r
e9b67286 146 /// A unique identifier for the vendor that produces and consumes this varaible.\r
ebafc55b 147 ///\r
3cfb790c 148 EFI_GUID VendorGuid;\r
149} VARIABLE_HEADER;\r
150\r
1fe6c125
SZ
151///\r
152/// Single Authenticated Variable Data Header Structure.\r
153///\r
154typedef struct {\r
155 ///\r
156 /// Variable Data Start Flag.\r
157 ///\r
158 UINT16 StartId;\r
159 ///\r
160 /// Variable State defined above.\r
161 ///\r
162 UINT8 State;\r
163 UINT8 Reserved;\r
164 ///\r
165 /// Attributes of variable defined in UEFI specification.\r
166 ///\r
167 UINT32 Attributes;\r
168 ///\r
169 /// Associated monotonic count value against replay attack.\r
170 ///\r
171 UINT64 MonotonicCount;\r
172 ///\r
173 /// Associated TimeStamp value against replay attack.\r
174 ///\r
175 EFI_TIME TimeStamp;\r
176 ///\r
177 /// Index of associated public key in database.\r
178 ///\r
179 UINT32 PubKeyIndex;\r
180 ///\r
181 /// Size of variable null-terminated Unicode string name.\r
182 ///\r
183 UINT32 NameSize;\r
184 ///\r
185 /// Size of the variable data without this header.\r
186 ///\r
187 UINT32 DataSize;\r
188 ///\r
189 /// A unique identifier for the vendor that produces and consumes this varaible.\r
190 ///\r
191 EFI_GUID VendorGuid;\r
192} AUTHENTICATED_VARIABLE_HEADER;\r
193\r
b6477d82
SZ
194typedef struct {\r
195 EFI_GUID *Guid;\r
196 CHAR16 *Name;\r
197 UINTN VariableSize;\r
198} VARIABLE_ENTRY_CONSISTENCY;\r
199\r
3cfb790c 200#pragma pack()\r
201\r
1436aea4 202typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;\r
3709c4cd 203\r
204///\r
205/// This structure contains the variable list that is put in EFI system table.\r
e9b67286 206/// The variable driver collects all variables that were used at boot service time and produces this list.\r
b6477d82 207/// This is an optional feature to dump all used variables in shell environment.\r
3709c4cd 208///\r
209struct _VARIABLE_INFO_ENTRY {\r
1436aea4
MK
210 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.\r
211 EFI_GUID VendorGuid; ///< Guid of Variable.\r
212 CHAR16 *Name; ///< Name of Variable.\r
213 UINT32 Attributes; ///< Attributes of variable defined in UEFI specification.\r
214 UINT32 ReadCount; ///< Number of times to read this variable.\r
215 UINT32 WriteCount; ///< Number of times to write this variable.\r
216 UINT32 DeleteCount; ///< Number of times to delete this variable.\r
217 UINT32 CacheCount; ///< Number of times that cache hits this variable.\r
218 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.\r
3709c4cd 219};\r
220\r
3cfb790c 221#endif // _EFI_VARIABLE_H_\r