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