Commit | Line | Data |
---|---|---|
0c18794e | 1 | /** @file\r |
2 | The internal header file includes the common header files, defines\r | |
3 | internal structure and functions used by Variable modules.\r | |
4 | \r | |
83758cdc | 5 | Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r |
0c18794e | 6 | This program and the accompanying materials \r |
7 | are licensed and made available under the terms and conditions of the BSD License \r | |
8 | which accompanies this distribution. The full text of the license may be found at \r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _VARIABLE_H_\r | |
17 | #define _VARIABLE_H_\r | |
18 | \r | |
19 | #include <PiDxe.h>\r | |
20 | #include <Protocol/VariableWrite.h>\r | |
21 | #include <Protocol/FaultTolerantWrite.h>\r | |
22 | #include <Protocol/FirmwareVolumeBlock.h>\r | |
23 | #include <Protocol/Variable.h>\r | |
24 | #include <Library/PcdLib.h>\r | |
9a000b46 | 25 | #include <Library/HobLib.h>\r |
0c18794e | 26 | #include <Library/UefiDriverEntryPoint.h>\r |
27 | #include <Library/DxeServicesTableLib.h>\r | |
28 | #include <Library/UefiRuntimeLib.h>\r | |
29 | #include <Library/DebugLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/UefiBootServicesTableLib.h>\r | |
32 | #include <Library/UefiLib.h>\r | |
33 | #include <Library/BaseLib.h>\r | |
34 | #include <Library/SynchronizationLib.h>\r | |
35 | #include <Library/MemoryAllocationLib.h>\r | |
36 | #include <Library/BaseCryptLib.h>\r | |
37 | #include <Library/PlatformSecureLib.h>\r | |
38 | #include <Guid/GlobalVariable.h>\r | |
39 | #include <Guid/EventGroup.h>\r | |
40 | #include <Guid/AuthenticatedVariableFormat.h>\r | |
41 | #include <Guid/ImageAuthentication.h>\r | |
4d832aab | 42 | #include <Guid/SystemNvDataGuid.h>\r |
a5f15e30 | 43 | #include <Guid/HardwareErrorVariable.h>\r |
0c18794e | 44 | \r |
45 | #define VARIABLE_RECLAIM_THRESHOLD (1024)\r | |
275beb2b | 46 | #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE | \\r |
47 | EFI_VARIABLE_BOOTSERVICE_ACCESS | \\r | |
48 | EFI_VARIABLE_RUNTIME_ACCESS | \\r | |
49 | EFI_VARIABLE_HARDWARE_ERROR_RECORD | \\r | |
50 | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS | \\r | |
51 | EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \\r | |
52 | EFI_VARIABLE_APPEND_WRITE)\r | |
0c18794e | 53 | \r |
54 | ///\r | |
55 | /// The size of a 3 character ISO639 language code.\r | |
56 | ///\r | |
57 | #define ISO_639_2_ENTRY_SIZE 3\r | |
58 | \r | |
9a000b46 RN |
59 | typedef enum {\r |
60 | VariableStoreTypeVolatile,\r | |
61 | VariableStoreTypeHob,\r | |
62 | VariableStoreTypeNv,\r | |
63 | VariableStoreTypeMax\r | |
64 | } VARIABLE_STORE_TYPE;\r | |
65 | \r | |
0c18794e | 66 | typedef struct {\r |
67 | VARIABLE_HEADER *CurrPtr;\r | |
23b06935 SZ |
68 | //\r |
69 | // If both ADDED and IN_DELETED_TRANSITION variable are present,\r | |
70 | // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.\r | |
71 | // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,\r | |
72 | // and InDeletedTransitionPtr will be NULL at the same time.\r | |
73 | //\r | |
74 | VARIABLE_HEADER *InDeletedTransitionPtr;\r | |
0c18794e | 75 | VARIABLE_HEADER *EndPtr;\r |
76 | VARIABLE_HEADER *StartPtr;\r | |
77 | BOOLEAN Volatile;\r | |
78 | } VARIABLE_POINTER_TRACK;\r | |
79 | \r | |
80 | typedef struct {\r | |
9a000b46 | 81 | EFI_PHYSICAL_ADDRESS HobVariableBase;\r |
0c18794e | 82 | EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r |
83 | EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r | |
84 | EFI_LOCK VariableServicesLock;\r | |
85 | UINT32 ReentrantState;\r | |
86 | } VARIABLE_GLOBAL;\r | |
87 | \r | |
88 | typedef struct {\r | |
89 | VARIABLE_GLOBAL VariableGlobal;\r | |
90 | UINTN VolatileLastVariableOffset;\r | |
91 | UINTN NonVolatileLastVariableOffset;\r | |
92 | UINTN CommonVariableTotalSize;\r | |
93 | UINTN HwErrVariableTotalSize;\r | |
94 | CHAR8 *PlatformLangCodes;\r | |
95 | CHAR8 *LangCodes;\r | |
96 | CHAR8 *PlatformLang;\r | |
97 | CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];\r | |
98 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;\r | |
99 | } VARIABLE_MODULE_GLOBAL;\r | |
100 | \r | |
101 | typedef struct {\r | |
102 | EFI_GUID *Guid;\r | |
103 | CHAR16 *Name;\r | |
104 | UINT32 Attributes;\r | |
105 | UINTN DataSize;\r | |
106 | VOID *Data;\r | |
107 | } VARIABLE_CACHE_ENTRY;\r | |
108 | \r | |
335e2681 SZ |
109 | /**\r |
110 | Flush the HOB variable to flash.\r | |
111 | \r | |
112 | @param[in] VariableName Name of variable has been updated or deleted.\r | |
113 | @param[in] VendorGuid Guid of variable has been updated or deleted.\r | |
114 | \r | |
115 | **/\r | |
116 | VOID\r | |
117 | FlushHobVariableToFlash (\r | |
118 | IN CHAR16 *VariableName,\r | |
119 | IN EFI_GUID *VendorGuid\r | |
120 | );\r | |
121 | \r | |
0c18794e | 122 | /**\r |
123 | Writes a buffer to variable storage space, in the working block.\r | |
124 | \r | |
125 | This function writes a buffer to variable storage space into a firmware\r | |
126 | volume block device. The destination is specified by the parameter\r | |
127 | VariableBase. Fault Tolerant Write protocol is used for writing.\r | |
128 | \r | |
129 | @param VariableBase Base address of the variable to write.\r | |
130 | @param Buffer Point to the data buffer.\r | |
131 | @param BufferSize The number of bytes of the data Buffer.\r | |
132 | \r | |
133 | @retval EFI_SUCCESS The function completed successfully.\r | |
134 | @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.\r | |
135 | @retval EFI_ABORTED The function could not complete successfully.\r | |
136 | \r | |
137 | **/\r | |
138 | EFI_STATUS\r | |
139 | FtwVariableSpace (\r | |
140 | IN EFI_PHYSICAL_ADDRESS VariableBase,\r | |
141 | IN UINT8 *Buffer,\r | |
142 | IN UINTN BufferSize\r | |
143 | );\r | |
144 | \r | |
145 | /**\r | |
146 | Finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
147 | \r | |
148 | This code finds variable in storage blocks of volatile and non-volatile storage areas.\r | |
149 | If VariableName is an empty string, then we just return the first\r | |
150 | qualified variable without comparing VariableName and VendorGuid.\r | |
9622df63 SZ |
151 | If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check\r |
152 | at runtime when searching existing variable, only VariableName and VendorGuid are compared.\r | |
153 | Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.\r | |
0c18794e | 154 | \r |
ecc722ad | 155 | @param[in] VariableName Name of the variable to be found.\r |
156 | @param[in] VendorGuid Vendor GUID to be found.\r | |
157 | @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,\r | |
0c18794e | 158 | including the range searched and the target position.\r |
ecc722ad | 159 | @param[in] Global Pointer to VARIABLE_GLOBAL structure, including\r |
0c18794e | 160 | base of volatile variable storage area, base of\r |
161 | NV variable storage area, and a lock.\r | |
9622df63 SZ |
162 | @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute\r |
163 | check at runtime when searching variable.\r | |
0c18794e | 164 | \r |
165 | @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while\r | |
166 | VendorGuid is NULL.\r | |
167 | @retval EFI_SUCCESS Variable successfully found.\r | |
ecc722ad | 168 | @retval EFI_NOT_FOUND Variable not found\r |
0c18794e | 169 | \r |
170 | **/\r | |
171 | EFI_STATUS\r | |
172 | FindVariable (\r | |
173 | IN CHAR16 *VariableName,\r | |
174 | IN EFI_GUID *VendorGuid,\r | |
175 | OUT VARIABLE_POINTER_TRACK *PtrTrack,\r | |
ecc722ad | 176 | IN VARIABLE_GLOBAL *Global,\r |
9622df63 | 177 | IN BOOLEAN IgnoreRtCheck\r |
0c18794e | 178 | );\r |
179 | \r | |
180 | /**\r | |
181 | \r | |
182 | This code gets the pointer to the variable data.\r | |
183 | \r | |
184 | @param Variable Pointer to the Variable Header.\r | |
185 | \r | |
186 | @return Pointer to Variable Data.\r | |
187 | \r | |
188 | **/\r | |
189 | UINT8 *\r | |
190 | GetVariableDataPtr (\r | |
191 | IN VARIABLE_HEADER *Variable\r | |
192 | );\r | |
193 | \r | |
194 | /**\r | |
195 | \r | |
196 | This code gets the size of variable data.\r | |
197 | \r | |
198 | @param Variable Pointer to the Variable Header.\r | |
199 | \r | |
200 | @return Size of variable in bytes.\r | |
201 | \r | |
202 | **/\r | |
203 | UINTN\r | |
204 | DataSizeOfVariable (\r | |
205 | IN VARIABLE_HEADER *Variable\r | |
206 | );\r | |
207 | \r | |
208 | /**\r | |
209 | Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,\r | |
210 | index of associated public key is needed.\r | |
211 | \r | |
212 | @param[in] VariableName Name of variable.\r | |
213 | @param[in] VendorGuid Guid of variable.\r | |
214 | @param[in] Data Variable data.\r | |
215 | @param[in] DataSize Size of data. 0 means delete.\r | |
216 | @param[in] Attributes Attributes of the variable.\r | |
217 | @param[in] KeyIndex Index of associated public key.\r | |
218 | @param[in] MonotonicCount Value of associated monotonic count.\r | |
23b06935 | 219 | @param[in, out] Variable The variable information that is used to keep track of variable usage.\r |
0c18794e | 220 | \r |
221 | @param[in] TimeStamp Value of associated TimeStamp.\r | |
222 | \r | |
223 | @retval EFI_SUCCESS The update operation is success.\r | |
224 | @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.\r | |
225 | \r | |
226 | **/\r | |
227 | EFI_STATUS\r | |
228 | UpdateVariable (\r | |
229 | IN CHAR16 *VariableName,\r | |
230 | IN EFI_GUID *VendorGuid,\r | |
231 | IN VOID *Data,\r | |
232 | IN UINTN DataSize,\r | |
233 | IN UINT32 Attributes OPTIONAL,\r | |
234 | IN UINT32 KeyIndex OPTIONAL,\r | |
235 | IN UINT64 MonotonicCount OPTIONAL,\r | |
23b06935 | 236 | IN OUT VARIABLE_POINTER_TRACK *Variable,\r |
0c18794e | 237 | IN EFI_TIME *TimeStamp OPTIONAL \r |
238 | );\r | |
239 | \r | |
240 | \r | |
241 | /**\r | |
242 | Return TRUE if ExitBootServices () has been called.\r | |
243 | \r | |
244 | @retval TRUE If ExitBootServices () has been called.\r | |
245 | **/\r | |
246 | BOOLEAN\r | |
247 | AtRuntime (\r | |
248 | VOID\r | |
249 | );\r | |
250 | \r | |
251 | /**\r | |
252 | Initializes a basic mutual exclusion lock.\r | |
253 | \r | |
254 | This function initializes a basic mutual exclusion lock to the released state \r | |
255 | and returns the lock. Each lock provides mutual exclusion access at its task \r | |
256 | priority level. Since there is no preemption or multiprocessor support in EFI,\r | |
257 | acquiring the lock only consists of raising to the locks TPL.\r | |
258 | If Lock is NULL, then ASSERT().\r | |
259 | If Priority is not a valid TPL value, then ASSERT().\r | |
260 | \r | |
261 | @param Lock A pointer to the lock data structure to initialize.\r | |
262 | @param Priority EFI TPL is associated with the lock.\r | |
263 | \r | |
264 | @return The lock.\r | |
265 | \r | |
266 | **/\r | |
267 | EFI_LOCK *\r | |
268 | InitializeLock (\r | |
269 | IN OUT EFI_LOCK *Lock,\r | |
270 | IN EFI_TPL Priority\r | |
271 | );\r | |
272 | \r | |
273 | \r | |
274 | /**\r | |
275 | Acquires lock only at boot time. Simply returns at runtime.\r | |
276 | \r | |
277 | This is a temperary function that will be removed when\r | |
278 | EfiAcquireLock() in UefiLib can handle the call in UEFI\r | |
279 | Runtimer driver in RT phase.\r | |
280 | It calls EfiAcquireLock() at boot time, and simply returns\r | |
281 | at runtime.\r | |
282 | \r | |
283 | @param Lock A pointer to the lock to acquire.\r | |
284 | \r | |
285 | **/\r | |
286 | VOID\r | |
287 | AcquireLockOnlyAtBootTime (\r | |
288 | IN EFI_LOCK *Lock\r | |
289 | );\r | |
290 | \r | |
291 | \r | |
292 | /**\r | |
293 | Releases lock only at boot time. Simply returns at runtime.\r | |
294 | \r | |
295 | This is a temperary function which will be removed when\r | |
296 | EfiReleaseLock() in UefiLib can handle the call in UEFI\r | |
297 | Runtimer driver in RT phase.\r | |
298 | It calls EfiReleaseLock() at boot time and simply returns\r | |
299 | at runtime.\r | |
300 | \r | |
301 | @param Lock A pointer to the lock to release.\r | |
302 | \r | |
303 | **/\r | |
304 | VOID\r | |
305 | ReleaseLockOnlyAtBootTime (\r | |
306 | IN EFI_LOCK *Lock\r | |
307 | ); \r | |
308 | \r | |
309 | /**\r | |
310 | Retrive the FVB protocol interface by HANDLE.\r | |
311 | \r | |
312 | @param[in] FvBlockHandle The handle of FVB protocol that provides services for\r | |
313 | reading, writing, and erasing the target block.\r | |
314 | @param[out] FvBlock The interface of FVB protocol\r | |
315 | \r | |
316 | @retval EFI_SUCCESS The interface information for the specified protocol was returned.\r | |
317 | @retval EFI_UNSUPPORTED The device does not support the FVB protocol.\r | |
318 | @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.\r | |
319 | \r | |
320 | **/\r | |
321 | EFI_STATUS\r | |
322 | GetFvbByHandle (\r | |
323 | IN EFI_HANDLE FvBlockHandle,\r | |
324 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock\r | |
325 | );\r | |
326 | \r | |
327 | \r | |
328 | /**\r | |
329 | Retrive the Swap Address Range protocol interface.\r | |
330 | \r | |
331 | @param[out] SarProtocol The interface of SAR protocol\r | |
332 | \r | |
333 | @retval EFI_SUCCESS The SAR protocol instance was found and returned in SarProtocol.\r | |
334 | @retval EFI_NOT_FOUND The SAR protocol instance was not found.\r | |
335 | @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r | |
336 | \r | |
337 | **/\r | |
338 | EFI_STATUS\r | |
339 | GetSarProtocol (\r | |
340 | OUT VOID **SarProtocol\r | |
341 | );\r | |
342 | \r | |
343 | /**\r | |
344 | Function returns an array of handles that support the FVB protocol\r | |
345 | in a buffer allocated from pool. \r | |
346 | \r | |
347 | @param[out] NumberHandles The number of handles returned in Buffer.\r | |
348 | @param[out] Buffer A pointer to the buffer to return the requested\r | |
349 | array of handles that support FVB protocol.\r | |
350 | \r | |
351 | @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of\r | |
352 | handles in Buffer was returned in NumberHandles.\r | |
353 | @retval EFI_NOT_FOUND No FVB handle was found.\r | |
354 | @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.\r | |
355 | @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.\r | |
356 | \r | |
357 | **/\r | |
358 | EFI_STATUS\r | |
359 | GetFvbCountAndBuffer (\r | |
360 | OUT UINTN *NumberHandles,\r | |
361 | OUT EFI_HANDLE **Buffer\r | |
362 | );\r | |
363 | \r | |
364 | /**\r | |
365 | Initializes variable store area for non-volatile and volatile variable.\r | |
366 | \r | |
367 | @retval EFI_SUCCESS Function successfully executed.\r | |
368 | @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r | |
369 | \r | |
370 | **/\r | |
371 | EFI_STATUS\r | |
372 | VariableCommonInitialize (\r | |
373 | VOID\r | |
374 | );\r | |
375 | \r | |
83758cdc | 376 | /**\r |
377 | \r | |
378 | Variable store garbage collection and reclaim operation.\r | |
379 | \r | |
380 | If ReclaimPubKeyStore is FALSE, reclaim variable space by deleting the obsoleted varaibles.\r | |
381 | If ReclaimPubKeyStore is TRUE, reclaim invalid key in public key database and update the PubKeyIndex\r | |
382 | for all the count-based authenticate variable in NV storage.\r | |
383 | \r | |
ca5a7d87 | 384 | @param[in] VariableBase Base address of variable store.\r |
385 | @param[out] LastVariableOffset Offset of last variable.\r | |
386 | @param[in] IsVolatile The variable store is volatile or not;\r | |
387 | if it is non-volatile, need FTW.\r | |
388 | @param[in, out] UpdatingPtrTrack Pointer to updating variable pointer track structure.\r | |
389 | @param[in] ReclaimPubKeyStore Reclaim for public key database or not.\r | |
390 | @param[in] ReclaimAnyway If TRUE, do reclaim anyway.\r | |
83758cdc | 391 | \r |
83758cdc | 392 | @return EFI_SUCCESS Reclaim operation has finished successfully.\r |
ca5a7d87 | 393 | @return EFI_OUT_OF_RESOURCES No enough memory resources.\r |
394 | @return EFI_DEVICE_ERROR The public key database doesn't exist.\r | |
83758cdc | 395 | @return Others Unexpect error happened during reclaim operation.\r |
396 | \r | |
397 | **/\r | |
398 | EFI_STATUS\r | |
399 | Reclaim (\r | |
ca5a7d87 | 400 | IN EFI_PHYSICAL_ADDRESS VariableBase,\r |
401 | OUT UINTN *LastVariableOffset,\r | |
402 | IN BOOLEAN IsVolatile,\r | |
403 | IN OUT VARIABLE_POINTER_TRACK *UpdatingPtrTrack,\r | |
404 | IN BOOLEAN ReclaimPubKeyStore,\r | |
405 | IN BOOLEAN ReclaimAnyway\r | |
83758cdc | 406 | );\r |
407 | \r | |
0c18794e | 408 | /**\r |
409 | This function reclaims variable storage if free size is below the threshold.\r | |
410 | \r | |
411 | **/\r | |
412 | VOID\r | |
413 | ReclaimForOS(\r | |
414 | VOID\r | |
415 | ); \r | |
416 | \r | |
417 | \r | |
418 | /**\r | |
419 | Initializes variable write service after FVB was ready.\r | |
420 | \r | |
421 | @retval EFI_SUCCESS Function successfully executed.\r | |
422 | @retval Others Fail to initialize the variable service.\r | |
423 | \r | |
424 | **/\r | |
425 | EFI_STATUS\r | |
426 | VariableWriteServiceInitialize (\r | |
427 | VOID\r | |
428 | );\r | |
429 | \r | |
430 | /**\r | |
431 | Retrive the SMM Fault Tolerent Write protocol interface.\r | |
432 | \r | |
433 | @param[out] FtwProtocol The interface of SMM Ftw protocol\r | |
434 | \r | |
435 | @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.\r | |
436 | @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.\r | |
437 | @retval EFI_INVALID_PARAMETER SarProtocol is NULL.\r | |
438 | \r | |
439 | **/\r | |
440 | EFI_STATUS\r | |
441 | GetFtwProtocol (\r | |
442 | OUT VOID **FtwProtocol\r | |
443 | );\r | |
444 | \r | |
445 | /**\r | |
446 | Get the proper fvb handle and/or fvb protocol by the given Flash address.\r | |
447 | \r | |
448 | @param[in] Address The Flash address.\r | |
449 | @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.\r | |
450 | @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.\r | |
451 | \r | |
452 | **/\r | |
453 | EFI_STATUS\r | |
454 | GetFvbInfoByAddress (\r | |
455 | IN EFI_PHYSICAL_ADDRESS Address,\r | |
456 | OUT EFI_HANDLE *FvbHandle OPTIONAL,\r | |
457 | OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL\r | |
458 | );\r | |
459 | \r | |
460 | /**\r | |
461 | \r | |
462 | This code finds variable in storage blocks (Volatile or Non-Volatile).\r | |
463 | \r | |
dc204d5a JY |
464 | Caution: This function may receive untrusted input.\r |
465 | This function may be invoked in SMM mode, and datasize and data are external input.\r | |
466 | This function will do basic validation, before parse the data.\r | |
467 | \r | |
0c18794e | 468 | @param VariableName Name of Variable to be found.\r |
469 | @param VendorGuid Variable vendor GUID.\r | |
470 | @param Attributes Attribute value of the variable found.\r | |
471 | @param DataSize Size of Data found. If size is less than the\r | |
472 | data, this value contains the required size.\r | |
473 | @param Data Data pointer.\r | |
474 | \r | |
475 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
476 | @return EFI_SUCCESS Find the specified variable.\r | |
477 | @return EFI_NOT_FOUND Not found.\r | |
478 | @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r | |
479 | \r | |
480 | **/\r | |
481 | EFI_STATUS\r | |
482 | EFIAPI\r | |
483 | VariableServiceGetVariable (\r | |
484 | IN CHAR16 *VariableName,\r | |
485 | IN EFI_GUID *VendorGuid,\r | |
486 | OUT UINT32 *Attributes OPTIONAL,\r | |
487 | IN OUT UINTN *DataSize,\r | |
488 | OUT VOID *Data\r | |
489 | );\r | |
490 | \r | |
491 | /**\r | |
492 | \r | |
493 | This code Finds the Next available variable.\r | |
494 | \r | |
dc204d5a JY |
495 | Caution: This function may receive untrusted input.\r |
496 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
497 | \r | |
0c18794e | 498 | @param VariableNameSize Size of the variable name.\r |
499 | @param VariableName Pointer to variable name.\r | |
500 | @param VendorGuid Variable Vendor Guid.\r | |
501 | \r | |
502 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
503 | @return EFI_SUCCESS Find the specified variable.\r | |
504 | @return EFI_NOT_FOUND Not found.\r | |
505 | @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.\r | |
506 | \r | |
507 | **/\r | |
508 | EFI_STATUS\r | |
509 | EFIAPI\r | |
510 | VariableServiceGetNextVariableName (\r | |
511 | IN OUT UINTN *VariableNameSize,\r | |
512 | IN OUT CHAR16 *VariableName,\r | |
513 | IN OUT EFI_GUID *VendorGuid\r | |
514 | );\r | |
515 | \r | |
516 | /**\r | |
517 | \r | |
518 | This code sets variable in storage blocks (Volatile or Non-Volatile).\r | |
519 | \r | |
dc204d5a JY |
520 | Caution: This function may receive untrusted input.\r |
521 | This function may be invoked in SMM mode, and datasize and data are external input.\r | |
522 | This function will do basic validation, before parse the data.\r | |
523 | This function will parse the authentication carefully to avoid security issues, like\r | |
524 | buffer overflow, integer overflow.\r | |
525 | This function will check attribute carefully to avoid authentication bypass.\r | |
526 | \r | |
0c18794e | 527 | @param VariableName Name of Variable to be found.\r |
528 | @param VendorGuid Variable vendor GUID.\r | |
529 | @param Attributes Attribute value of the variable found\r | |
530 | @param DataSize Size of Data found. If size is less than the\r | |
531 | data, this value contains the required size.\r | |
532 | @param Data Data pointer.\r | |
533 | \r | |
534 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
535 | @return EFI_SUCCESS Set successfully.\r | |
536 | @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.\r | |
537 | @return EFI_NOT_FOUND Not found.\r | |
538 | @return EFI_WRITE_PROTECTED Variable is read-only.\r | |
539 | \r | |
540 | **/\r | |
541 | EFI_STATUS\r | |
542 | EFIAPI\r | |
543 | VariableServiceSetVariable (\r | |
544 | IN CHAR16 *VariableName,\r | |
545 | IN EFI_GUID *VendorGuid,\r | |
546 | IN UINT32 Attributes,\r | |
547 | IN UINTN DataSize,\r | |
548 | IN VOID *Data\r | |
549 | );\r | |
550 | \r | |
551 | /**\r | |
552 | \r | |
553 | This code returns information about the EFI variables.\r | |
554 | \r | |
dc204d5a JY |
555 | Caution: This function may receive untrusted input.\r |
556 | This function may be invoked in SMM mode. This function will do basic validation, before parse the data.\r | |
557 | \r | |
0c18794e | 558 | @param Attributes Attributes bitmask to specify the type of variables\r |
559 | on which to return information.\r | |
560 | @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
561 | for the EFI variables associated with the attributes specified.\r | |
562 | @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available\r | |
563 | for EFI variables associated with the attributes specified.\r | |
564 | @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables\r | |
565 | associated with the attributes specified.\r | |
566 | \r | |
567 | @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.\r | |
568 | @return EFI_SUCCESS Query successfully.\r | |
569 | @return EFI_UNSUPPORTED The attribute is not supported on this platform.\r | |
570 | \r | |
571 | **/\r | |
572 | EFI_STATUS\r | |
573 | EFIAPI\r | |
574 | VariableServiceQueryVariableInfo (\r | |
575 | IN UINT32 Attributes,\r | |
576 | OUT UINT64 *MaximumVariableStorageSize,\r | |
577 | OUT UINT64 *RemainingVariableStorageSize,\r | |
578 | OUT UINT64 *MaximumVariableSize\r | |
579 | ); \r | |
580 | \r | |
581 | extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;\r | |
582 | \r | |
583 | #endif\r |