]>
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 | |
52 | @return Size of variable header in bytes in type UINTN.\r | |
53 | \r | |
54 | **/\r | |
55 | UINTN\r | |
56 | GetVariableHeaderSize (\r | |
57 | VOID\r | |
58 | );\r | |
59 | \r | |
60 | /**\r | |
61 | \r | |
62 | This code gets the size of name of variable.\r | |
63 | \r | |
64 | @param Variable Pointer to the Variable Header.\r | |
65 | \r | |
66 | @return UINTN Size of variable in bytes.\r | |
67 | \r | |
68 | **/\r | |
69 | UINTN\r | |
70 | NameSizeOfVariable (\r | |
71 | IN VARIABLE_HEADER *Variable\r | |
72 | );\r | |
73 | \r | |
74 | /**\r | |
75 | This code sets the size of name of variable.\r | |
76 | \r | |
77 | @param[in] Variable Pointer to the Variable Header.\r | |
78 | @param[in] NameSize Name size to set.\r | |
79 | \r | |
80 | **/\r | |
81 | VOID\r | |
82 | SetNameSizeOfVariable (\r | |
83 | IN VARIABLE_HEADER *Variable,\r | |
84 | IN UINTN NameSize\r | |
85 | );\r | |
86 | \r | |
87 | /**\r | |
88 | \r | |
89 | This code gets the size of variable data.\r | |
90 | \r | |
91 | @param Variable Pointer to the Variable Header.\r | |
92 | \r | |
93 | @return Size of variable in bytes.\r | |
94 | \r | |
95 | **/\r | |
96 | UINTN\r | |
97 | DataSizeOfVariable (\r | |
98 | IN VARIABLE_HEADER *Variable\r | |
99 | );\r | |
100 | \r | |
101 | /**\r | |
102 | This code sets the size of variable data.\r | |
103 | \r | |
104 | @param[in] Variable Pointer to the Variable Header.\r | |
105 | @param[in] DataSize Data size to set.\r | |
106 | \r | |
107 | **/\r | |
108 | VOID\r | |
109 | SetDataSizeOfVariable (\r | |
110 | IN VARIABLE_HEADER *Variable,\r | |
111 | IN UINTN DataSize\r | |
112 | );\r | |
113 | \r | |
114 | /**\r | |
115 | \r | |
116 | This code gets the pointer to the variable name.\r | |
117 | \r | |
118 | @param Variable Pointer to the Variable Header.\r | |
119 | \r | |
120 | @return Pointer to Variable Name which is Unicode encoding.\r | |
121 | \r | |
122 | **/\r | |
123 | CHAR16 *\r | |
124 | GetVariableNamePtr (\r | |
125 | IN VARIABLE_HEADER *Variable\r | |
126 | );\r | |
127 | \r | |
128 | /**\r | |
129 | This code gets the pointer to the variable guid.\r | |
130 | \r | |
131 | @param Variable Pointer to the Variable Header.\r | |
132 | \r | |
133 | @return A EFI_GUID* pointer to Vendor Guid.\r | |
134 | \r | |
135 | **/\r | |
136 | EFI_GUID *\r | |
137 | GetVendorGuidPtr (\r | |
138 | IN VARIABLE_HEADER *Variable\r | |
139 | );\r | |
140 | \r | |
141 | /**\r | |
142 | \r | |
143 | This code gets the pointer to the variable data.\r | |
144 | \r | |
145 | @param Variable Pointer to the Variable Header.\r | |
146 | \r | |
147 | @return Pointer to Variable Data.\r | |
148 | \r | |
149 | **/\r | |
150 | UINT8 *\r | |
151 | GetVariableDataPtr (\r | |
152 | IN VARIABLE_HEADER *Variable\r | |
153 | );\r | |
154 | \r | |
155 | /**\r | |
156 | This code gets the variable data offset related to variable header.\r | |
157 | \r | |
158 | @param Variable Pointer to the Variable Header.\r | |
159 | \r | |
160 | @return Variable Data offset.\r | |
161 | \r | |
162 | **/\r | |
163 | UINTN\r | |
164 | GetVariableDataOffset (\r | |
165 | IN VARIABLE_HEADER *Variable\r | |
166 | );\r | |
167 | \r | |
168 | /**\r | |
169 | \r | |
170 | This code gets the pointer to the next variable header.\r | |
171 | \r | |
172 | @param Variable Pointer to the Variable Header.\r | |
173 | \r | |
174 | @return Pointer to next variable header.\r | |
175 | \r | |
176 | **/\r | |
177 | VARIABLE_HEADER *\r | |
178 | GetNextVariablePtr (\r | |
179 | IN VARIABLE_HEADER *Variable\r | |
180 | );\r | |
181 | \r | |
182 | /**\r | |
183 | \r | |
184 | Gets the pointer to the first variable header in given variable store area.\r | |
185 | \r | |
186 | @param[in] VarStoreHeader Pointer to the Variable Store Header.\r | |
187 | \r | |
188 | @return Pointer to the first variable header.\r | |
189 | \r | |
190 | **/\r | |
191 | VARIABLE_HEADER *\r | |
192 | GetStartPointer (\r | |
193 | IN VARIABLE_STORE_HEADER *VarStoreHeader\r | |
194 | );\r | |
195 | \r | |
196 | /**\r | |
197 | \r | |
198 | Gets the pointer to the end of the variable storage area.\r | |
199 | \r | |
200 | This function gets pointer to the end of the variable storage\r | |
201 | area, according to the input variable store header.\r | |
202 | \r | |
203 | @param[in] VarStoreHeader Pointer to the Variable Store Header.\r | |
204 | \r | |
205 | @return Pointer to the end of the variable storage area.\r | |
206 | \r | |
207 | **/\r | |
208 | VARIABLE_HEADER *\r | |
209 | GetEndPointer (\r | |
210 | IN VARIABLE_STORE_HEADER *VarStoreHeader\r | |
211 | );\r | |
212 | \r | |
213 | /**\r | |
214 | Compare two EFI_TIME data.\r | |
215 | \r | |
216 | \r | |
217 | @param[in] FirstTime A pointer to the first EFI_TIME data.\r | |
218 | @param[in] SecondTime A pointer to the second EFI_TIME data.\r | |
219 | \r | |
220 | @retval TRUE The FirstTime is not later than the SecondTime.\r | |
221 | @retval FALSE The FirstTime is later than the SecondTime.\r | |
222 | \r | |
223 | **/\r | |
224 | BOOLEAN\r | |
225 | VariableCompareTimeStampInternal (\r | |
226 | IN EFI_TIME *FirstTime,\r | |
227 | IN EFI_TIME *SecondTime\r | |
228 | );\r | |
229 | \r | |
230 | /**\r | |
231 | Find the variable in the specified variable store.\r | |
232 | \r | |
233 | @param[in] VariableName Name of the variable to be found\r | |
234 | @param[in] VendorGuid Vendor GUID to be found.\r | |
235 | @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute\r | |
236 | check at runtime when searching variable.\r | |
237 | @param[in, out] PtrTrack Variable Track Pointer structure that contains Variable Information.\r | |
238 | \r | |
239 | @retval EFI_SUCCESS Variable found successfully\r | |
240 | @retval EFI_NOT_FOUND Variable not found\r | |
241 | **/\r | |
242 | EFI_STATUS\r | |
243 | FindVariableEx (\r | |
244 | IN CHAR16 *VariableName,\r | |
245 | IN EFI_GUID *VendorGuid,\r | |
246 | IN BOOLEAN IgnoreRtCheck,\r | |
247 | IN OUT VARIABLE_POINTER_TRACK *PtrTrack\r | |
248 | );\r | |
249 | \r | |
250 | /**\r | |
f8ff4cca | 251 | This code finds the next available variable.\r |
20a27a64 MK |
252 | \r |
253 | Caution: This function may receive untrusted input.\r | |
254 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
255 | \r | |
f8ff4cca MK |
256 | @param[in] VariableName Pointer to variable name.\r |
257 | @param[in] VendorGuid Variable Vendor Guid.\r | |
258 | @param[in] VariableStoreList A list of variable stores that should be used to get the next variable.\r | |
259 | The maximum number of entries is the max value of VARIABLE_STORE_TYPE.\r | |
260 | @param[out] VariablePtr Pointer to variable header address.\r | |
20a27a64 MK |
261 | \r |
262 | @retval EFI_SUCCESS The function completed successfully.\r | |
263 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
f8ff4cca | 264 | @retval EFI_INVALID_PARAMETER If VariableName is nt an empty string, while VendorGuid is NULL.\r |
20a27a64 MK |
265 | @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and\r |
266 | GUID of an existing variable.\r | |
267 | \r | |
268 | **/\r | |
269 | EFI_STATUS\r | |
270 | EFIAPI\r | |
271 | VariableServiceGetNextVariableInternal (\r | |
272 | IN CHAR16 *VariableName,\r | |
273 | IN EFI_GUID *VendorGuid,\r | |
f8ff4cca | 274 | IN VARIABLE_STORE_HEADER **VariableStoreList,\r |
20a27a64 MK |
275 | OUT VARIABLE_HEADER **VariablePtr\r |
276 | );\r | |
277 | \r | |
278 | /**\r | |
279 | Routine used to track statistical information about variable usage.\r | |
280 | The data is stored in the EFI system table so it can be accessed later.\r | |
281 | VariableInfo.efi can dump out the table. Only Boot Services variable\r | |
282 | accesses are tracked by this code. The PcdVariableCollectStatistics\r | |
283 | build flag controls if this feature is enabled.\r | |
284 | \r | |
285 | A read that hits in the cache will have Read and Cache true for\r | |
286 | the transaction. Data is allocated by this routine, but never\r | |
287 | freed.\r | |
288 | \r | |
8d53adbe MK |
289 | @param[in] VariableName Name of the Variable to track.\r |
290 | @param[in] VendorGuid Guid of the Variable to track.\r | |
291 | @param[in] Volatile TRUE if volatile FALSE if non-volatile.\r | |
292 | @param[in] Read TRUE if GetVariable() was called.\r | |
293 | @param[in] Write TRUE if SetVariable() was called.\r | |
294 | @param[in] Delete TRUE if deleted via SetVariable().\r | |
295 | @param[in] Cache TRUE for a cache hit.\r | |
296 | @param[in,out] VariableInfo Pointer to a pointer of VARIABLE_INFO_ENTRY structures.\r | |
20a27a64 MK |
297 | \r |
298 | **/\r | |
299 | VOID\r | |
300 | UpdateVariableInfo (\r | |
301 | IN CHAR16 *VariableName,\r | |
302 | IN EFI_GUID *VendorGuid,\r | |
303 | IN BOOLEAN Volatile,\r | |
304 | IN BOOLEAN Read,\r | |
305 | IN BOOLEAN Write,\r | |
306 | IN BOOLEAN Delete,\r | |
8d53adbe MK |
307 | IN BOOLEAN Cache,\r |
308 | IN OUT VARIABLE_INFO_ENTRY **VariableInfo\r | |
20a27a64 MK |
309 | );\r |
310 | \r | |
311 | #endif\r |