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