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