]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/VariableFormat.h
0db3a22f34ff4b409d9cd9be5ad09237d87a15c7
[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 - 2010, 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 extern EFI_GUID gEfiVariableGuid;
23
24 ///
25 /// Alignment of variable name and data, according to the architecture:
26 /// * For IA-32 and Intel(R) 64 architectures: 1.
27 /// * For IA-64 architecture: 8.
28 ///
29 #if defined (MDE_CPU_IPF)
30 #define ALIGNMENT 8
31 #else
32 #define ALIGNMENT 1
33 #endif
34
35 //
36 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
37 //
38 #if (ALIGNMENT == 1)
39 #define GET_PAD_SIZE(a) (0)
40 #else
41 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
42 #endif
43
44 ///
45 /// Alignment of Variable Data Header in Variable Store region.
46 ///
47 #define HEADER_ALIGNMENT 4
48 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
49
50 ///
51 /// Status of Variable Store Region.
52 ///
53 typedef enum {
54 EfiRaw,
55 EfiValid,
56 EfiInvalid,
57 EfiUnknown
58 } VARIABLE_STORE_STATUS;
59
60 #pragma pack(1)
61
62 #define VARIABLE_STORE_SIGNATURE EFI_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 /// Single Variable Data Header Structure.
110 ///
111 typedef struct {
112 ///
113 /// Variable Data Start Flag.
114 ///
115 UINT16 StartId;
116 ///
117 /// Variable State defined above.
118 ///
119 UINT8 State;
120 UINT8 Reserved;
121 ///
122 /// Attributes of variable defined in UEFI specification.
123 ///
124 UINT32 Attributes;
125 ///
126 /// Size of variable null-terminated Unicode string name.
127 ///
128 UINT32 NameSize;
129 ///
130 /// Size of the variable data without this header.
131 ///
132 UINT32 DataSize;
133 ///
134 /// A unique identifier for the vendor that produces and consumes this varaible.
135 ///
136 EFI_GUID VendorGuid;
137 } VARIABLE_HEADER;
138
139 #pragma pack()
140
141 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
142
143 ///
144 /// This structure contains the variable list that is put in EFI system table.
145 /// The variable driver collects all variables that were used at boot service time and produces this list.
146 /// This is an optional feature to dump all used variables in shell environment.
147 ///
148 struct _VARIABLE_INFO_ENTRY {
149 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
150 EFI_GUID VendorGuid; ///< Guid of Variable.
151 CHAR16 *Name; ///< Name of Variable.
152 UINT32 Attributes; ///< Attributes of variable defined in UEFI specification.
153 UINT32 ReadCount; ///< Number of times to read this variable.
154 UINT32 WriteCount; ///< Number of times to write this variable.
155 UINT32 DeleteCount; ///< Number of times to delete this variable.
156 UINT32 CacheCount; ///< Number of times that cache hits this variable.
157 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
158 };
159
160 //
161 // This structure is used for SMM variable. the collected statistics data is saved in SMRAM. It can be got from
162 // SMI handler. The communication buffer should be:
163 // EFI_SMM_COMMUNICATE_HEADER + SMM_VARIABLE_COMMUNICATE_HEADER + payload.
164 //
165 typedef struct {
166 UINTN Function;
167 EFI_STATUS ReturnStatus;
168 UINT8 Data[1];
169 } SMM_VARIABLE_COMMUNICATE_HEADER;
170
171 //
172 // The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
173 //
174 #define SMM_VARIABLE_FUNCTION_GET_VARIABLE 1
175 //
176 // The payload for this function is SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME.
177 //
178 #define SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME 2
179 //
180 // The payload for this function is SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE.
181 //
182 #define SMM_VARIABLE_FUNCTION_SET_VARIABLE 3
183 //
184 // The payload for this function is SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO.
185 //
186 #define SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO 4
187 //
188 // It is a notify event, no extra payload for this function.
189 //
190 #define SMM_VARIABLE_FUNCTION_READY_TO_BOOT 5
191 //
192 // It is a notify event, no extra payload for this function.
193 //
194 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE 6
195 //
196 // The payload for this function is VARIABLE_INFO_ENTRY. The GUID in EFI_SMM_COMMUNICATE_HEADER
197 // is gEfiSmmVariableProtocolGuid.
198 //
199 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS 7
200
201 ///
202 /// Size of SMM communicate header, without including the payload.
203 ///
204 #define SMM_COMMUNICATE_HEADER_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data))
205
206 ///
207 /// Size of SMM variable communicate header, without including the payload.
208 ///
209 #define SMM_VARIABLE_COMMUNICATE_HEADER_SIZE (OFFSET_OF (SMM_VARIABLE_COMMUNICATE_HEADER, Data))
210
211 ///
212 /// This structure is used to communicate with SMI handler by SetVariable and GetVariable.
213 ///
214 typedef struct {
215 EFI_GUID Guid;
216 UINTN DataSize;
217 UINTN NameSize;
218 UINT32 Attributes;
219 CHAR16 Name[1];
220 } SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE;
221
222 ///
223 /// This structure is used to communicate with SMI handler by GetNextVariableName.
224 ///
225 typedef struct {
226 EFI_GUID Guid;
227 UINTN NameSize;
228 CHAR16 Name[1];
229 } SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME;
230
231 ///
232 /// This structure is used to communicate with SMI handler by QueryVariableInfo.
233 ///
234 typedef struct {
235 UINT64 MaximumVariableStorageSize;
236 UINT64 RemainingVariableStorageSize;
237 UINT64 MaximumVariableSize;
238 UINT32 Attributes;
239 } SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO;
240
241 ///
242 /// This structure is used to communicate with SMI handler to get variable statistics information.
243 ///
244 typedef VARIABLE_INFO_ENTRY SMM_VARIABLE_COMMUNICATE_VARIABLE_INFO_ENTRY;
245
246 #endif // _EFI_VARIABLE_H_