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