]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / Variable.h
1 /** @file
2 The internal header file includes the common header files, defines
3 internal structure and functions used by Variable modules.
4
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _VARIABLE_H_
11 #define _VARIABLE_H_
12
13 #include <PiDxe.h>
14 #include <Protocol/VariableWrite.h>
15 #include <Protocol/FaultTolerantWrite.h>
16 #include <Protocol/FirmwareVolumeBlock.h>
17 #include <Protocol/Variable.h>
18 #include <Protocol/VariableLock.h>
19 #include <Protocol/VarCheck.h>
20 #include <Library/PcdLib.h>
21 #include <Library/HobLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/DxeServicesTableLib.h>
24 #include <Library/UefiRuntimeLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/BaseMemoryLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/BaseLib.h>
30 #include <Library/SynchronizationLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/AuthVariableLib.h>
33 #include <Library/VarCheckLib.h>
34 #include <Library/VariableFlashInfoLib.h>
35 #include <Library/SafeIntLib.h>
36 #include <Guid/GlobalVariable.h>
37 #include <Guid/EventGroup.h>
38 #include <Guid/VariableFormat.h>
39 #include <Guid/SystemNvDataGuid.h>
40 #include <Guid/FaultTolerantWrite.h>
41 #include <Guid/VarErrorFlag.h>
42
43 #include "PrivilegePolymorphic.h"
44
45 #define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE |\
46 EFI_VARIABLE_BOOTSERVICE_ACCESS | \
47 EFI_VARIABLE_RUNTIME_ACCESS | \
48 EFI_VARIABLE_HARDWARE_ERROR_RECORD | \
49 EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS | \
50 EFI_VARIABLE_APPEND_WRITE)
51
52 ///
53 /// The size of a 3 character ISO639 language code.
54 ///
55 #define ISO_639_2_ENTRY_SIZE 3
56
57 typedef enum {
58 VariableStoreTypeVolatile,
59 VariableStoreTypeHob,
60 VariableStoreTypeNv,
61 VariableStoreTypeMax
62 } VARIABLE_STORE_TYPE;
63
64 typedef struct {
65 UINT32 PendingUpdateOffset;
66 UINT32 PendingUpdateLength;
67 VARIABLE_STORE_HEADER *Store;
68 } VARIABLE_RUNTIME_CACHE;
69
70 typedef struct {
71 BOOLEAN *ReadLock;
72 BOOLEAN *PendingUpdate;
73 BOOLEAN *HobFlushComplete;
74 VARIABLE_RUNTIME_CACHE VariableRuntimeHobCache;
75 VARIABLE_RUNTIME_CACHE VariableRuntimeNvCache;
76 VARIABLE_RUNTIME_CACHE VariableRuntimeVolatileCache;
77 } VARIABLE_RUNTIME_CACHE_CONTEXT;
78
79 typedef struct {
80 VARIABLE_HEADER *CurrPtr;
81 //
82 // If both ADDED and IN_DELETED_TRANSITION variable are present,
83 // InDeletedTransitionPtr will point to the IN_DELETED_TRANSITION one.
84 // Otherwise, CurrPtr will point to the ADDED or IN_DELETED_TRANSITION one,
85 // and InDeletedTransitionPtr will be NULL at the same time.
86 //
87 VARIABLE_HEADER *InDeletedTransitionPtr;
88 VARIABLE_HEADER *EndPtr;
89 VARIABLE_HEADER *StartPtr;
90 BOOLEAN Volatile;
91 } VARIABLE_POINTER_TRACK;
92
93 typedef struct {
94 EFI_PHYSICAL_ADDRESS HobVariableBase;
95 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
96 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
97 VARIABLE_RUNTIME_CACHE_CONTEXT VariableRuntimeCacheContext;
98 EFI_LOCK VariableServicesLock;
99 UINT32 ReentrantState;
100 BOOLEAN AuthFormat;
101 BOOLEAN AuthSupport;
102 BOOLEAN EmuNvMode;
103 } VARIABLE_GLOBAL;
104
105 typedef struct {
106 VARIABLE_GLOBAL VariableGlobal;
107 UINTN VolatileLastVariableOffset;
108 UINTN NonVolatileLastVariableOffset;
109 UINTN CommonVariableSpace;
110 UINTN CommonMaxUserVariableSpace;
111 UINTN CommonRuntimeVariableSpace;
112 UINTN CommonVariableTotalSize;
113 UINTN CommonUserVariableTotalSize;
114 UINTN HwErrVariableTotalSize;
115 UINTN MaxVariableSize;
116 UINTN MaxAuthVariableSize;
117 UINTN MaxVolatileVariableSize;
118 UINTN ScratchBufferSize;
119 CHAR8 *PlatformLangCodes;
120 CHAR8 *LangCodes;
121 CHAR8 *PlatformLang;
122 CHAR8 Lang[ISO_639_2_ENTRY_SIZE + 1];
123 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbInstance;
124 } VARIABLE_MODULE_GLOBAL;
125
126 /**
127 Flush the HOB variable to flash.
128
129 @param[in] VariableName Name of variable has been updated or deleted.
130 @param[in] VendorGuid Guid of variable has been updated or deleted.
131
132 **/
133 VOID
134 FlushHobVariableToFlash (
135 IN CHAR16 *VariableName,
136 IN EFI_GUID *VendorGuid
137 );
138
139 /**
140 Writes a buffer to variable storage space, in the working block.
141
142 This function writes a buffer to variable storage space into a firmware
143 volume block device. The destination is specified by the parameter
144 VariableBase. Fault Tolerant Write protocol is used for writing.
145
146 @param VariableBase Base address of the variable to write.
147 @param VariableBuffer Point to the variable data buffer.
148
149 @retval EFI_SUCCESS The function completed successfully.
150 @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
151 @retval EFI_ABORTED The function could not complete successfully.
152
153 **/
154 EFI_STATUS
155 FtwVariableSpace (
156 IN EFI_PHYSICAL_ADDRESS VariableBase,
157 IN VARIABLE_STORE_HEADER *VariableBuffer
158 );
159
160 /**
161 Finds variable in storage blocks of volatile and non-volatile storage areas.
162
163 This code finds variable in storage blocks of volatile and non-volatile storage areas.
164 If VariableName is an empty string, then we just return the first
165 qualified variable without comparing VariableName and VendorGuid.
166 If IgnoreRtCheck is TRUE, then we ignore the EFI_VARIABLE_RUNTIME_ACCESS attribute check
167 at runtime when searching existing variable, only VariableName and VendorGuid are compared.
168 Otherwise, variables without EFI_VARIABLE_RUNTIME_ACCESS are not visible at runtime.
169
170 @param[in] VariableName Name of the variable to be found.
171 @param[in] VendorGuid Vendor GUID to be found.
172 @param[out] PtrTrack VARIABLE_POINTER_TRACK structure for output,
173 including the range searched and the target position.
174 @param[in] Global Pointer to VARIABLE_GLOBAL structure, including
175 base of volatile variable storage area, base of
176 NV variable storage area, and a lock.
177 @param[in] IgnoreRtCheck Ignore EFI_VARIABLE_RUNTIME_ACCESS attribute
178 check at runtime when searching variable.
179
180 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string, while
181 VendorGuid is NULL.
182 @retval EFI_SUCCESS Variable successfully found.
183 @retval EFI_NOT_FOUND Variable not found
184
185 **/
186 EFI_STATUS
187 FindVariable (
188 IN CHAR16 *VariableName,
189 IN EFI_GUID *VendorGuid,
190 OUT VARIABLE_POINTER_TRACK *PtrTrack,
191 IN VARIABLE_GLOBAL *Global,
192 IN BOOLEAN IgnoreRtCheck
193 );
194
195 /**
196 This function is to check if the remaining variable space is enough to set
197 all Variables from argument list successfully. The purpose of the check
198 is to keep the consistency of the Variables to be in variable storage.
199
200 Note: Variables are assumed to be in same storage.
201 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
202 so follow the argument sequence to check the Variables.
203
204 @param[in] Attributes Variable attributes for Variable entries.
205 @param[in] Marker VA_LIST style variable argument list.
206 The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
207 A NULL terminates the list. The VariableSize of
208 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
209 It will be changed to variable total size as output.
210
211 @retval TRUE Have enough variable space to set the Variables successfully.
212 @retval FALSE No enough variable space to set the Variables successfully.
213
214 **/
215 BOOLEAN
216 EFIAPI
217 CheckRemainingSpaceForConsistencyInternal (
218 IN UINT32 Attributes,
219 IN VA_LIST Marker
220 );
221
222 /**
223 Update the variable region with Variable information. If EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is set,
224 index of associated public key is needed.
225
226 @param[in] VariableName Name of variable.
227 @param[in] VendorGuid Guid of variable.
228 @param[in] Data Variable data.
229 @param[in] DataSize Size of data. 0 means delete.
230 @param[in] Attributes Attributes of the variable.
231 @param[in] KeyIndex Index of associated public key.
232 @param[in] MonotonicCount Value of associated monotonic count.
233 @param[in, out] Variable The variable information that is used to keep track of variable usage.
234
235 @param[in] TimeStamp Value of associated TimeStamp.
236
237 @retval EFI_SUCCESS The update operation is success.
238 @retval EFI_OUT_OF_RESOURCES Variable region is full, cannot write other data into this region.
239
240 **/
241 EFI_STATUS
242 UpdateVariable (
243 IN CHAR16 *VariableName,
244 IN EFI_GUID *VendorGuid,
245 IN VOID *Data,
246 IN UINTN DataSize,
247 IN UINT32 Attributes OPTIONAL,
248 IN UINT32 KeyIndex OPTIONAL,
249 IN UINT64 MonotonicCount OPTIONAL,
250 IN OUT VARIABLE_POINTER_TRACK *Variable,
251 IN EFI_TIME *TimeStamp OPTIONAL
252 );
253
254 /**
255 Return TRUE if ExitBootServices () has been called.
256
257 @retval TRUE If ExitBootServices () has been called.
258 **/
259 BOOLEAN
260 AtRuntime (
261 VOID
262 );
263
264 /**
265 Initializes a basic mutual exclusion lock.
266
267 This function initializes a basic mutual exclusion lock to the released state
268 and returns the lock. Each lock provides mutual exclusion access at its task
269 priority level. Since there is no preemption or multiprocessor support in EFI,
270 acquiring the lock only consists of raising to the locks TPL.
271 If Lock is NULL, then ASSERT().
272 If Priority is not a valid TPL value, then ASSERT().
273
274 @param Lock A pointer to the lock data structure to initialize.
275 @param Priority EFI TPL is associated with the lock.
276
277 @return The lock.
278
279 **/
280 EFI_LOCK *
281 InitializeLock (
282 IN OUT EFI_LOCK *Lock,
283 IN EFI_TPL Priority
284 );
285
286 /**
287 Acquires lock only at boot time. Simply returns at runtime.
288
289 This is a temperary function that will be removed when
290 EfiAcquireLock() in UefiLib can handle the call in UEFI
291 Runtimer driver in RT phase.
292 It calls EfiAcquireLock() at boot time, and simply returns
293 at runtime.
294
295 @param Lock A pointer to the lock to acquire.
296
297 **/
298 VOID
299 AcquireLockOnlyAtBootTime (
300 IN EFI_LOCK *Lock
301 );
302
303 /**
304 Releases lock only at boot time. Simply returns at runtime.
305
306 This is a temperary function which will be removed when
307 EfiReleaseLock() in UefiLib can handle the call in UEFI
308 Runtimer driver in RT phase.
309 It calls EfiReleaseLock() at boot time and simply returns
310 at runtime.
311
312 @param Lock A pointer to the lock to release.
313
314 **/
315 VOID
316 ReleaseLockOnlyAtBootTime (
317 IN EFI_LOCK *Lock
318 );
319
320 /**
321 Retrieve the FVB protocol interface by HANDLE.
322
323 @param[in] FvBlockHandle The handle of FVB protocol that provides services for
324 reading, writing, and erasing the target block.
325 @param[out] FvBlock The interface of FVB protocol
326
327 @retval EFI_SUCCESS The interface information for the specified protocol was returned.
328 @retval EFI_UNSUPPORTED The device does not support the FVB protocol.
329 @retval EFI_INVALID_PARAMETER FvBlockHandle is not a valid EFI_HANDLE or FvBlock is NULL.
330
331 **/
332 EFI_STATUS
333 GetFvbByHandle (
334 IN EFI_HANDLE FvBlockHandle,
335 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvBlock
336 );
337
338 /**
339 Function returns an array of handles that support the FVB protocol
340 in a buffer allocated from pool.
341
342 @param[out] NumberHandles The number of handles returned in Buffer.
343 @param[out] Buffer A pointer to the buffer to return the requested
344 array of handles that support FVB protocol.
345
346 @retval EFI_SUCCESS The array of handles was returned in Buffer, and the number of
347 handles in Buffer was returned in NumberHandles.
348 @retval EFI_NOT_FOUND No FVB handle was found.
349 @retval EFI_OUT_OF_RESOURCES There is not enough pool memory to store the matching results.
350 @retval EFI_INVALID_PARAMETER NumberHandles is NULL or Buffer is NULL.
351
352 **/
353 EFI_STATUS
354 GetFvbCountAndBuffer (
355 OUT UINTN *NumberHandles,
356 OUT EFI_HANDLE **Buffer
357 );
358
359 /**
360 Initializes variable store area for non-volatile and volatile variable.
361
362 @retval EFI_SUCCESS Function successfully executed.
363 @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.
364
365 **/
366 EFI_STATUS
367 VariableCommonInitialize (
368 VOID
369 );
370
371 /**
372 This function reclaims variable storage if free size is below the threshold.
373
374 **/
375 VOID
376 ReclaimForOS (
377 VOID
378 );
379
380 /**
381 Get maximum variable size, covering both non-volatile and volatile variables.
382
383 @return Maximum variable size.
384
385 **/
386 UINTN
387 GetMaxVariableSize (
388 VOID
389 );
390
391 /**
392 Initializes variable write service.
393
394 @retval EFI_SUCCESS Function successfully executed.
395 @retval Others Fail to initialize the variable service.
396
397 **/
398 EFI_STATUS
399 VariableWriteServiceInitialize (
400 VOID
401 );
402
403 /**
404 Retrieve the SMM Fault Tolerent Write protocol interface.
405
406 @param[out] FtwProtocol The interface of SMM Ftw protocol
407
408 @retval EFI_SUCCESS The SMM SAR protocol instance was found and returned in SarProtocol.
409 @retval EFI_NOT_FOUND The SMM SAR protocol instance was not found.
410 @retval EFI_INVALID_PARAMETER SarProtocol is NULL.
411
412 **/
413 EFI_STATUS
414 GetFtwProtocol (
415 OUT VOID **FtwProtocol
416 );
417
418 /**
419 Get the proper fvb handle and/or fvb protocol by the given Flash address.
420
421 @param[in] Address The Flash address.
422 @param[out] FvbHandle In output, if it is not NULL, it points to the proper FVB handle.
423 @param[out] FvbProtocol In output, if it is not NULL, it points to the proper FVB protocol.
424
425 **/
426 EFI_STATUS
427 GetFvbInfoByAddress (
428 IN EFI_PHYSICAL_ADDRESS Address,
429 OUT EFI_HANDLE *FvbHandle OPTIONAL,
430 OUT EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL **FvbProtocol OPTIONAL
431 );
432
433 /**
434
435 This code finds variable in storage blocks (Volatile or Non-Volatile).
436
437 Caution: This function may receive untrusted input.
438 This function may be invoked in SMM mode, and datasize and data are external input.
439 This function will do basic validation, before parse the data.
440
441 @param VariableName Name of Variable to be found.
442 @param VendorGuid Variable vendor GUID.
443 @param Attributes Attribute value of the variable found.
444 @param DataSize Size of Data found. If size is less than the
445 data, this value contains the required size.
446 @param Data The buffer to return the contents of the variable. May be NULL
447 with a zero DataSize in order to determine the size buffer needed.
448
449 @return EFI_INVALID_PARAMETER Invalid parameter.
450 @return EFI_SUCCESS Find the specified variable.
451 @return EFI_NOT_FOUND Not found.
452 @return EFI_BUFFER_TO_SMALL DataSize is too small for the result.
453
454 **/
455 EFI_STATUS
456 EFIAPI
457 VariableServiceGetVariable (
458 IN CHAR16 *VariableName,
459 IN EFI_GUID *VendorGuid,
460 OUT UINT32 *Attributes OPTIONAL,
461 IN OUT UINTN *DataSize,
462 OUT VOID *Data OPTIONAL
463 );
464
465 /**
466
467 This code Finds the Next available variable.
468
469 Caution: This function may receive untrusted input.
470 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
471
472 @param VariableNameSize The size of the VariableName buffer. The size must be large
473 enough to fit input string supplied in VariableName buffer.
474 @param VariableName Pointer to variable name.
475 @param VendorGuid Variable Vendor Guid.
476
477 @retval EFI_SUCCESS The function completed successfully.
478 @retval EFI_NOT_FOUND The next variable was not found.
479 @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.
480 VariableNameSize has been updated with the size needed to complete the request.
481 @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.
482 @retval EFI_INVALID_PARAMETER VariableName is NULL.
483 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
484 @retval EFI_INVALID_PARAMETER The input values of VariableName and VendorGuid are not a name and
485 GUID of an existing variable.
486 @retval EFI_INVALID_PARAMETER Null-terminator is not found in the first VariableNameSize bytes of
487 the input VariableName buffer.
488
489 **/
490 EFI_STATUS
491 EFIAPI
492 VariableServiceGetNextVariableName (
493 IN OUT UINTN *VariableNameSize,
494 IN OUT CHAR16 *VariableName,
495 IN OUT EFI_GUID *VendorGuid
496 );
497
498 /**
499
500 This code sets variable in storage blocks (Volatile or Non-Volatile).
501
502 Caution: This function may receive untrusted input.
503 This function may be invoked in SMM mode, and datasize and data are external input.
504 This function will do basic validation, before parse the data.
505 This function will parse the authentication carefully to avoid security issues, like
506 buffer overflow, integer overflow.
507 This function will check attribute carefully to avoid authentication bypass.
508
509 @param VariableName Name of Variable to be found.
510 @param VendorGuid Variable vendor GUID.
511 @param Attributes Attribute value of the variable found
512 @param DataSize Size of Data found. If size is less than the
513 data, this value contains the required size.
514 @param Data Data pointer.
515
516 @return EFI_INVALID_PARAMETER Invalid parameter.
517 @return EFI_SUCCESS Set successfully.
518 @return EFI_OUT_OF_RESOURCES Resource not enough to set variable.
519 @return EFI_NOT_FOUND Not found.
520 @return EFI_WRITE_PROTECTED Variable is read-only.
521
522 **/
523 EFI_STATUS
524 EFIAPI
525 VariableServiceSetVariable (
526 IN CHAR16 *VariableName,
527 IN EFI_GUID *VendorGuid,
528 IN UINT32 Attributes,
529 IN UINTN DataSize,
530 IN VOID *Data
531 );
532
533 /**
534
535 This code returns information about the EFI variables.
536
537 Caution: This function may receive untrusted input.
538 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
539
540 @param Attributes Attributes bitmask to specify the type of variables
541 on which to return information.
542 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
543 for the EFI variables associated with the attributes specified.
544 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
545 for EFI variables associated with the attributes specified.
546 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
547 associated with the attributes specified.
548
549 @return EFI_SUCCESS Query successfully.
550
551 **/
552 EFI_STATUS
553 EFIAPI
554 VariableServiceQueryVariableInfoInternal (
555 IN UINT32 Attributes,
556 OUT UINT64 *MaximumVariableStorageSize,
557 OUT UINT64 *RemainingVariableStorageSize,
558 OUT UINT64 *MaximumVariableSize
559 );
560
561 /**
562
563 This code returns information about the EFI variables.
564
565 Caution: This function may receive untrusted input.
566 This function may be invoked in SMM mode. This function will do basic validation, before parse the data.
567
568 @param Attributes Attributes bitmask to specify the type of variables
569 on which to return information.
570 @param MaximumVariableStorageSize Pointer to the maximum size of the storage space available
571 for the EFI variables associated with the attributes specified.
572 @param RemainingVariableStorageSize Pointer to the remaining size of the storage space available
573 for EFI variables associated with the attributes specified.
574 @param MaximumVariableSize Pointer to the maximum size of an individual EFI variables
575 associated with the attributes specified.
576
577 @return EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
578 @return EFI_SUCCESS Query successfully.
579 @return EFI_UNSUPPORTED The attribute is not supported on this platform.
580
581 **/
582 EFI_STATUS
583 EFIAPI
584 VariableServiceQueryVariableInfo (
585 IN UINT32 Attributes,
586 OUT UINT64 *MaximumVariableStorageSize,
587 OUT UINT64 *RemainingVariableStorageSize,
588 OUT UINT64 *MaximumVariableSize
589 );
590
591 /**
592 Mark a variable that will become read-only after leaving the DXE phase of execution.
593
594 @param[in] This The VARIABLE_LOCK_PROTOCOL instance.
595 @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
596 @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
597
598 @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
599 as pending to be read-only.
600 @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
601 Or VariableName is an empty string.
602 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
603 already been signaled.
604 @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
605 **/
606 EFI_STATUS
607 EFIAPI
608 VariableLockRequestToLock (
609 IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
610 IN CHAR16 *VariableName,
611 IN EFI_GUID *VendorGuid
612 );
613
614 /**
615 Register SetVariable check handler.
616
617 @param[in] Handler Pointer to check handler.
618
619 @retval EFI_SUCCESS The SetVariable check handler was registered successfully.
620 @retval EFI_INVALID_PARAMETER Handler is NULL.
621 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
622 already been signaled.
623 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
624 @retval EFI_UNSUPPORTED This interface is not implemented.
625 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
626
627 **/
628 EFI_STATUS
629 EFIAPI
630 VarCheckRegisterSetVariableCheckHandler (
631 IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
632 );
633
634 /**
635 Variable property set.
636
637 @param[in] Name Pointer to the variable name.
638 @param[in] Guid Pointer to the vendor GUID.
639 @param[in] VariableProperty Pointer to the input variable property.
640
641 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
642 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
643 or the fields of VariableProperty are not valid.
644 @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
645 already been signaled.
646 @retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
647
648 **/
649 EFI_STATUS
650 EFIAPI
651 VarCheckVariablePropertySet (
652 IN CHAR16 *Name,
653 IN EFI_GUID *Guid,
654 IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
655 );
656
657 /**
658 Variable property get.
659
660 @param[in] Name Pointer to the variable name.
661 @param[in] Guid Pointer to the vendor GUID.
662 @param[out] VariableProperty Pointer to the output variable property.
663
664 @retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
665 @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
666 @retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
667
668 **/
669 EFI_STATUS
670 EFIAPI
671 VarCheckVariablePropertyGet (
672 IN CHAR16 *Name,
673 IN EFI_GUID *Guid,
674 OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
675 );
676
677 /**
678 Initialize variable quota.
679
680 **/
681 VOID
682 InitializeVariableQuota (
683 VOID
684 );
685
686 extern VARIABLE_MODULE_GLOBAL *mVariableModuleGlobal;
687 extern EFI_FIRMWARE_VOLUME_HEADER *mNvFvHeaderCache;
688 extern VARIABLE_STORE_HEADER *mNvVariableCache;
689 extern VARIABLE_INFO_ENTRY *gVariableInfo;
690 extern BOOLEAN mEndOfDxe;
691 extern VAR_CHECK_REQUEST_SOURCE mRequestSource;
692
693 extern AUTH_VAR_LIB_CONTEXT_OUT mAuthContextOut;
694
695 /**
696 Finds variable in storage blocks of volatile and non-volatile storage areas.
697
698 This code finds variable in storage blocks of volatile and non-volatile storage areas.
699 If VariableName is an empty string, then we just return the first
700 qualified variable without comparing VariableName and VendorGuid.
701
702 @param[in] VariableName Name of the variable to be found.
703 @param[in] VendorGuid Variable vendor GUID to be found.
704 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
705 output of the variable found.
706
707 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
708 while VendorGuid is NULL.
709 @retval EFI_SUCCESS Variable successfully found.
710 @retval EFI_NOT_FOUND Variable not found
711
712 **/
713 EFI_STATUS
714 EFIAPI
715 VariableExLibFindVariable (
716 IN CHAR16 *VariableName,
717 IN EFI_GUID *VendorGuid,
718 OUT AUTH_VARIABLE_INFO *AuthVariableInfo
719 );
720
721 /**
722 Finds next variable in storage blocks of volatile and non-volatile storage areas.
723
724 This code finds next variable in storage blocks of volatile and non-volatile storage areas.
725 If VariableName is an empty string, then we just return the first
726 qualified variable without comparing VariableName and VendorGuid.
727
728 @param[in] VariableName Name of the variable to be found.
729 @param[in] VendorGuid Variable vendor GUID to be found.
730 @param[out] AuthVariableInfo Pointer to AUTH_VARIABLE_INFO structure for
731 output of the next variable.
732
733 @retval EFI_INVALID_PARAMETER If VariableName is not an empty string,
734 while VendorGuid is NULL.
735 @retval EFI_SUCCESS Variable successfully found.
736 @retval EFI_NOT_FOUND Variable not found
737
738 **/
739 EFI_STATUS
740 EFIAPI
741 VariableExLibFindNextVariable (
742 IN CHAR16 *VariableName,
743 IN EFI_GUID *VendorGuid,
744 OUT AUTH_VARIABLE_INFO *AuthVariableInfo
745 );
746
747 /**
748 Update the variable region with Variable information.
749
750 @param[in] AuthVariableInfo Pointer AUTH_VARIABLE_INFO structure for
751 input of the variable.
752
753 @retval EFI_SUCCESS The update operation is success.
754 @retval EFI_INVALID_PARAMETER Invalid parameter.
755 @retval EFI_WRITE_PROTECTED Variable is write-protected.
756 @retval EFI_OUT_OF_RESOURCES There is not enough resource.
757
758 **/
759 EFI_STATUS
760 EFIAPI
761 VariableExLibUpdateVariable (
762 IN AUTH_VARIABLE_INFO *AuthVariableInfo
763 );
764
765 /**
766 Get scratch buffer.
767
768 @param[in, out] ScratchBufferSize Scratch buffer size. If input size is greater than
769 the maximum supported buffer size, this value contains
770 the maximum supported buffer size as output.
771 @param[out] ScratchBuffer Pointer to scratch buffer address.
772
773 @retval EFI_SUCCESS Get scratch buffer successfully.
774 @retval EFI_UNSUPPORTED If input size is greater than the maximum supported buffer size.
775
776 **/
777 EFI_STATUS
778 EFIAPI
779 VariableExLibGetScratchBuffer (
780 IN OUT UINTN *ScratchBufferSize,
781 OUT VOID **ScratchBuffer
782 );
783
784 /**
785 This function is to check if the remaining variable space is enough to set
786 all Variables from argument list successfully. The purpose of the check
787 is to keep the consistency of the Variables to be in variable storage.
788
789 Note: Variables are assumed to be in same storage.
790 The set sequence of Variables will be same with the sequence of VariableEntry from argument list,
791 so follow the argument sequence to check the Variables.
792
793 @param[in] Attributes Variable attributes for Variable entries.
794 @param ... The variable argument list with type VARIABLE_ENTRY_CONSISTENCY *.
795 A NULL terminates the list. The VariableSize of
796 VARIABLE_ENTRY_CONSISTENCY is the variable data size as input.
797 It will be changed to variable total size as output.
798
799 @retval TRUE Have enough variable space to set the Variables successfully.
800 @retval FALSE No enough variable space to set the Variables successfully.
801
802 **/
803 BOOLEAN
804 EFIAPI
805 VariableExLibCheckRemainingSpaceForConsistency (
806 IN UINT32 Attributes,
807 ...
808 );
809
810 /**
811 Return TRUE if at OS runtime.
812
813 @retval TRUE If at OS runtime.
814 @retval FALSE If at boot time.
815
816 **/
817 BOOLEAN
818 EFIAPI
819 VariableExLibAtRuntime (
820 VOID
821 );
822
823 #endif