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