]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h
MdeModulePkg/Variable: Parameterize GetNextVariableInternal () stores
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableParsing.h
1 /** @file
2 Functions in this module are associated with variable parsing operations and
3 are intended to be usable across variable driver source files.
4
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _VARIABLE_PARSING_H_
11 #define _VARIABLE_PARSING_H_
12
13 #include <Guid/ImageAuthentication.h>
14 #include "Variable.h"
15
16 /**
17
18 This code checks if variable header is valid or not.
19
20 @param[in] Variable Pointer to the Variable Header.
21 @param[in] VariableStoreEnd Pointer to the Variable Store End.
22
23 @retval TRUE Variable header is valid.
24 @retval FALSE Variable header is not valid.
25
26 **/
27 BOOLEAN
28 IsValidVariableHeader (
29 IN VARIABLE_HEADER *Variable,
30 IN VARIABLE_HEADER *VariableStoreEnd
31 );
32
33 /**
34
35 This code gets the current status of Variable Store.
36
37 @param[in] VarStoreHeader Pointer to the Variable Store Header.
38
39 @retval EfiRaw Variable store status is raw.
40 @retval EfiValid Variable store status is valid.
41 @retval EfiInvalid Variable store status is invalid.
42
43 **/
44 VARIABLE_STORE_STATUS
45 GetVariableStoreStatus (
46 IN VARIABLE_STORE_HEADER *VarStoreHeader
47 );
48
49 /**
50 This code gets the size of variable header.
51
52 @return Size of variable header in bytes in type UINTN.
53
54 **/
55 UINTN
56 GetVariableHeaderSize (
57 VOID
58 );
59
60 /**
61
62 This code gets the size of name of variable.
63
64 @param Variable Pointer to the Variable Header.
65
66 @return UINTN Size of variable in bytes.
67
68 **/
69 UINTN
70 NameSizeOfVariable (
71 IN VARIABLE_HEADER *Variable
72 );
73
74 /**
75 This code sets the size of name of variable.
76
77 @param[in] Variable Pointer to the Variable Header.
78 @param[in] NameSize Name size to set.
79
80 **/
81 VOID
82 SetNameSizeOfVariable (
83 IN VARIABLE_HEADER *Variable,
84 IN UINTN NameSize
85 );
86
87 /**
88
89 This code gets the size of variable data.
90
91 @param Variable Pointer to the Variable Header.
92
93 @return Size of variable in bytes.
94
95 **/
96 UINTN
97 DataSizeOfVariable (
98 IN VARIABLE_HEADER *Variable
99 );
100
101 /**
102 This code sets the size of variable data.
103
104 @param[in] Variable Pointer to the Variable Header.
105 @param[in] DataSize Data size to set.
106
107 **/
108 VOID
109 SetDataSizeOfVariable (
110 IN VARIABLE_HEADER *Variable,
111 IN UINTN DataSize
112 );
113
114 /**
115
116 This code gets the pointer to the variable name.
117
118 @param Variable Pointer to the Variable Header.
119
120 @return Pointer to Variable Name which is Unicode encoding.
121
122 **/
123 CHAR16 *
124 GetVariableNamePtr (
125 IN VARIABLE_HEADER *Variable
126 );
127
128 /**
129 This code gets the pointer to the variable guid.
130
131 @param Variable Pointer to the Variable Header.
132
133 @return A EFI_GUID* pointer to Vendor Guid.
134
135 **/
136 EFI_GUID *
137 GetVendorGuidPtr (
138 IN VARIABLE_HEADER *Variable
139 );
140
141 /**
142
143 This code gets the pointer to the variable data.
144
145 @param Variable Pointer to the Variable Header.
146
147 @return Pointer to Variable Data.
148
149 **/
150 UINT8 *
151 GetVariableDataPtr (
152 IN VARIABLE_HEADER *Variable
153 );
154
155 /**
156 This code gets the variable data offset related to variable header.
157
158 @param Variable Pointer to the Variable Header.
159
160 @return Variable Data offset.
161
162 **/
163 UINTN
164 GetVariableDataOffset (
165 IN VARIABLE_HEADER *Variable
166 );
167
168 /**
169
170 This code gets the pointer to the next variable header.
171
172 @param Variable Pointer to the Variable Header.
173
174 @return Pointer to next variable header.
175
176 **/
177 VARIABLE_HEADER *
178 GetNextVariablePtr (
179 IN VARIABLE_HEADER *Variable
180 );
181
182 /**
183
184 Gets the pointer to the first variable header in given variable store area.
185
186 @param[in] VarStoreHeader Pointer to the Variable Store Header.
187
188 @return Pointer to the first variable header.
189
190 **/
191 VARIABLE_HEADER *
192 GetStartPointer (
193 IN VARIABLE_STORE_HEADER *VarStoreHeader
194 );
195
196 /**
197
198 Gets the pointer to the end of the variable storage area.
199
200 This function gets pointer to the end of the variable storage
201 area, according to the input variable store header.
202
203 @param[in] VarStoreHeader Pointer to the Variable Store Header.
204
205 @return Pointer to the end of the variable storage area.
206
207 **/
208 VARIABLE_HEADER *
209 GetEndPointer (
210 IN VARIABLE_STORE_HEADER *VarStoreHeader
211 );
212
213 /**
214 Compare two EFI_TIME data.
215
216
217 @param[in] FirstTime A pointer to the first EFI_TIME data.
218 @param[in] SecondTime A pointer to the second EFI_TIME data.
219
220 @retval TRUE The FirstTime is not later than the SecondTime.
221 @retval FALSE The FirstTime is later than the SecondTime.
222
223 **/
224 BOOLEAN
225 VariableCompareTimeStampInternal (
226 IN EFI_TIME *FirstTime,
227 IN EFI_TIME *SecondTime
228 );
229
230 /**
231 Find the variable in the specified variable store.
232
233 @param[in] VariableName Name of the variable to be found
234 @param[in] VendorGuid Vendor GUID to be found.
235 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
236 check at runtime when searching variable.
237 @param[in, out] PtrTrack Variable Track Pointer structure that contains Variable Information.
238
239 @retval EFI_SUCCESS Variable found successfully
240 @retval EFI_NOT_FOUND Variable not found
241 **/
242 EFI_STATUS
243 FindVariableEx (
244 IN CHAR16 *VariableName,
245 IN EFI_GUID *VendorGuid,
246 IN BOOLEAN IgnoreRtCheck,
247 IN OUT VARIABLE_POINTER_TRACK *PtrTrack
248 );
249
250 /**
251 This code finds the next available variable.
252
253 Caution: This function may receive untrusted input.
254 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
255
256 @param[in] VariableName Pointer to variable name.
257 @param[in] VendorGuid Variable Vendor Guid.
258 @param[in] VariableStoreList A list of variable stores that should be used to get the next variable.
259 The maximum number of entries is the max value of VARIABLE_STORE_TYPE.
260 @param[out] VariablePtr Pointer to variable header address.
261
262 @retval EFI_SUCCESS The function completed successfully.
263 @retval EFI_NOT_FOUND The next variable was not found.
264 @retval EFI_INVALID_PARAMETER If VariableName is nt an empty string, while VendorGuid is NULL.
265 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
266 GUID of an existing variable.
267
268 **/
269 EFI_STATUS
270 EFIAPI
271 VariableServiceGetNextVariableInternal (
272 IN CHAR16 *VariableName,
273 IN EFI_GUID *VendorGuid,
274 IN VARIABLE_STORE_HEADER **VariableStoreList,
275 OUT VARIABLE_HEADER **VariablePtr
276 );
277
278 /**
279 Routine used to track statistical information about variable usage.
280 The data is stored in the EFI system table so it can be accessed later.
281 VariableInfo.efi can dump out the table. Only Boot Services variable
282 accesses are tracked by this code. The PcdVariableCollectStatistics
283 build flag controls if this feature is enabled.
284
285 A read that hits in the cache will have Read and Cache true for
286 the transaction. Data is allocated by this routine, but never
287 freed.
288
289 @param[in] VariableName Name of the Variable to track.
290 @param[in] VendorGuid Guid of the Variable to track.
291 @param[in] Volatile TRUE if volatile FALSE if non-volatile.
292 @param[in] Read TRUE if GetVariable() was called.
293 @param[in] Write TRUE if SetVariable() was called.
294 @param[in] Delete TRUE if deleted via SetVariable().
295 @param[in] Cache TRUE for a cache hit.
296
297 **/
298 VOID
299 UpdateVariableInfo (
300 IN CHAR16 *VariableName,
301 IN EFI_GUID *VendorGuid,
302 IN BOOLEAN Volatile,
303 IN BOOLEAN Read,
304 IN BOOLEAN Write,
305 IN BOOLEAN Delete,
306 IN BOOLEAN Cache
307 );
308
309 #endif