3 Read and edit the authenticated variables.
5 Copyright (c) 2011-2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "MonotonicBasedVariable.h"
13 extern LIST_ENTRY mAllVarListEntry
;
14 extern MULTI_PLATFORM_PARAMETERS mMultiPlatformParam
;
15 extern G_EFI_FD_INFO gEfiFdInfo
;
16 EFI_GUID gEfiAuthenticatedVariableGuid
= EFI_AUTHENTICATED_VARIABLE_GUID
;
19 Gets the pointer to the first variable header in given variable store area.
21 @param VarStoreHeader Pointer to the Variable Store Header.
23 @return Pointer to the first variable header.
29 IN VARIABLE_STORE_HEADER
*VarStoreHeader
33 // The end of variable store.
35 return (VARIABLE_HEADER
*) HEADER_ALIGN (VarStoreHeader
+ 1);
40 Gets the pointer to the end of the variable storage area.
42 This function gets pointer to the end of the variable storage
43 area, according to the input variable store header.
45 @param VarStoreHeader Pointer to the Variable Store Header.
47 @return Pointer to the end of the variable storage area.
53 IN VARIABLE_STORE_HEADER
*VarStoreHeader
57 // The end of variable store
59 return (VARIABLE_HEADER
*) HEADER_ALIGN ((UINTN
) VarStoreHeader
+ VarStoreHeader
->Size
);
65 This code checks if variable header is valid or not.
67 @param Variable Pointer to the Variable Header.
69 @retval TRUE Variable header is valid.
70 @retval FALSE Variable header is not valid.
75 IsValidVariableHeader (
76 IN VARIABLE_HEADER
*Variable
79 if ((Variable
== NULL
) || (Variable
->StartId
!= VARIABLE_DATA
)) {
88 This code gets the size of name of variable.
90 @param Variable Pointer to the Variable Header.
92 @return UINTN Size of variable in bytes.
98 IN VARIABLE_HEADER
*Variable
101 if ((Variable
->State
== (UINT8
) (-1)) ||
102 (Variable
->DataSize
== (UINT32
) (-1)) ||
103 (Variable
->NameSize
== (UINT32
) (-1)) ||
104 (Variable
->Attributes
== (UINT32
) (-1))
108 return (UINTN
) Variable
->NameSize
;
113 This code gets the size of variable data.
115 @param Variable Pointer to the Variable Header.
117 @return Size of variable in bytes.
123 IN VARIABLE_HEADER
*Variable
126 if ((Variable
->State
== (UINT8
) (-1)) ||
127 (Variable
->DataSize
== (UINT32
) (-1)) ||
128 (Variable
->NameSize
== (UINT32
) (-1)) ||
129 (Variable
->Attributes
== (UINT32
) (-1))
133 return (UINTN
) Variable
->DataSize
;
138 This code gets the pointer to the variable name.
140 @param Variable Pointer to the Variable Header.
142 @return Pointer to Variable Name which is Unicode encoding.
148 IN VARIABLE_HEADER
*Variable
151 return (CHAR16
*) (Variable
+ 1);
156 This code gets the pointer to the variable data.
158 @param Variable Pointer to the Variable Header.
160 @return Pointer to Variable Data.
166 IN VARIABLE_HEADER
*Variable
172 // Be careful about pad size for alignment.
174 Value
= (UINTN
) GetVariableNamePtr (Variable
);
175 Value
+= NameSizeOfVariable (Variable
);
176 Value
+= GET_PAD_SIZE (NameSizeOfVariable (Variable
));
178 return (UINT8
*) Value
;
183 This code gets the pointer to the next variable header.
185 @param Variable Pointer to the Variable Header.
187 @return Pointer to next variable header.
193 IN VARIABLE_HEADER
*Variable
198 if (!IsValidVariableHeader (Variable
)) {
202 Value
= (UINTN
) GetVariableDataPtr (Variable
);
203 Value
+= DataSizeOfVariable (Variable
);
204 Value
+= GET_PAD_SIZE (DataSizeOfVariable (Variable
));
207 // Be careful about pad size for alignment.
209 return (VARIABLE_HEADER
*) HEADER_ALIGN (Value
);
213 Search and get a free space in the EFI variable zone
215 @param VariableStoreHeader The start of a EFI variable zone.
216 @param VarListSize The size of a variables needs to be allocated.
217 @param FreeBeginVar The dual pointer to the free NV space.
219 @retval EFI_SUCCESS Return the beginning of a free variable space.
220 @retval RETURN_BUFFER_TOO_SMALL Failed.
225 IN VARIABLE_STORE_HEADER
*VariableStoreHeader
,
226 IN UINT32 VarListSize
,
227 IN OUT CHAR8
**FreeBeginVar
231 VARIABLE_HEADER
*Variable
;
232 VARIABLE_HEADER
*EndOfVariable
;
238 EndOfVariable
= NULL
;
239 *FreeBeginVar
= NULL
;
241 if (VariableStoreHeader
== NULL
) {
242 *FreeBeginVar
= NULL
;
243 return RETURN_INVALID_PARAMETER
;
245 Variable
= GetStartPointer (VariableStoreHeader
);
246 EndOfVariable
= GetEndPointer(VariableStoreHeader
);
248 //Search the beginning of free NV
250 while (Variable
!= EndOfVariable
) {
251 BeginVar
= (CHAR8
*)Variable
;
252 Variable
= GetNextVariablePtr (Variable
);
253 if (Variable
== NULL
) {
259 // Check whether the free space is more than what we want
261 if ((CHAR8
*)BeginVar
+ VarListSize
> (CHAR8
*)EndOfVariable
) {
262 return RETURN_BUFFER_TOO_SMALL
;
265 // If not find the available space, return NULL
268 return RETURN_BUFFER_TOO_SMALL
;
270 *FreeBeginVar
= BeginVar
;
276 Search whether the variable in VarList has existed in current NV.
278 Parse the FFS or Fd image, and find the valid variable pointer.
280 @param VariableStoreHeader The start of a EFI variable zone.
281 @param VarList The pointer to the VarList
283 @retval address If the variable existed in current NV, return address
284 @return NULL Otherwise, return NULL
289 IN VARIABLE_STORE_HEADER
*VariableStoreHeader
,
290 IN FORMSET_STORAGE
*Storage
294 VARIABLE_HEADER
*Variable
;
295 VARIABLE_HEADER
*EndOfVariable
;
296 CHAR16
*VariableName
;
300 EndOfVariable
= NULL
;
303 if ((VariableStoreHeader
== NULL
) || (Storage
== NULL
) || (Storage
->Name
== NULL
)) {
306 Variable
= GetStartPointer (VariableStoreHeader
);
307 EndOfVariable
= GetEndPointer(VariableStoreHeader
);
309 // Parse and compare the variable in the NV space one by one
311 while ((Variable
!= EndOfVariable
) && (Variable
!= NULL
)) {
312 VariableName
= (CHAR16
*)((CHAR8
*)Variable
+ sizeof (VARIABLE_HEADER
));
313 if (!CompareGuid (&Variable
->VendorGuid
, &Storage
->Guid
) \
314 && !FceStrCmp (Storage
->Name
, VariableName
) \
315 && (Variable
->State
== VAR_ADDED
)) {
319 Variable
= GetNextVariablePtr (Variable
);
328 Exchange the data between Efi variable and the data of VarList when the
329 variable use the authenticated variable header
331 If VarToList is TRUE, copy the efi variable data to the VarList; Otherwise,
332 update the data from varlist to efi variable.
334 @param VarToList The flag to control the direction of exchange.
335 @param StorageListHead Decide which variale list be updated
337 @retval EFI_SUCCESS Get the address successfully.
338 @retval EFI_OUT_OF_RESOURCES No available in the EFI variable zone.
339 @retval EFI_INVALID_PARAMETER Invalid variable name.
343 IN BOOLEAN VarToList
,
344 IN LIST_ENTRY
*StorageListHead
347 EFI_FIRMWARE_VOLUME_HEADER
*VarAddr
;
348 LIST_ENTRY
*StorageLink
;
349 FORMSET_STORAGE
*Storage
;
351 CHAR8
*NewAvailableAddr
;
353 VARIABLE_HEADER
*VariableHeader
;
354 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
357 Status
= EFI_SUCCESS
;
359 NewAvailableAddr
= NULL
;
361 VariableHeader
= NULL
;
362 VarAddr
= (EFI_FIRMWARE_VOLUME_HEADER
*) gEfiFdInfo
.EfiVariableAddr
;
363 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*)((CHAR8
*)VarAddr
+ VarAddr
->HeaderLength
);
365 //Parse the variable range, and check whether there is some existed ones.
367 StorageLink
= GetFirstNode (StorageListHead
);
368 while (!IsNull (StorageListHead
, StorageLink
)) {
369 Storage
= FORMSET_STORAGE_FROM_LINK (StorageLink
);
371 // Ignore the invalid varlist node
373 if (Storage
->Buffer
== NULL
) {
374 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
378 // Report error, if the variable name is invalid.
380 if ((Storage
->Name
== NULL
) || (FceStrLen(Storage
->Name
) == 0)) {
381 printf ("Error. One variable name is NULL. Its GUID is: ");
382 PrintGuid(&(Storage
->Guid
));
383 return EFI_INVALID_PARAMETER
;
385 VariableHeader
= FindVariableInNv (
392 //Copy the data from NV to the VarList.
394 if (VariableHeader
!= NULL
) {
395 if (Storage
->Buffer
== NULL
) {
396 Storage
->Buffer
= calloc (Storage
->Size
, sizeof (CHAR8
));
397 ASSERT (Storage
->Buffer
!= NULL
);
400 // The variable in VarList is CHAR8, but in the EFI variable is CHAR16.
402 DataBase
= (CHAR8
*)GetVariableDataPtr (VariableHeader
);
411 //If existed, copy the List data to the variable in NV directly. If not found, create a new one.
413 VarNameSize
= 2 * (FceStrLen (Storage
->Name
) + 1);
415 //If this variable has existed in current FD, the data in VarList has
416 // been updated, and this variable is not authenticated type, then
417 // update it from VarList to the FD.
419 if ((VariableHeader
!= NULL
) \
420 && (Storage
->Buffer
!= NULL
)
422 if (!(VariableHeader
->Attributes
& EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
)) {
423 DataBase
= (CHAR8
*)GetVariableDataPtr (VariableHeader
);
430 printf ("Error. Not support to update authenticated variables.\n");
431 return EFI_INVALID_PARAMETER
;
433 } else if ((VariableHeader
== NULL
) && (Storage
->Buffer
!= NULL
)){
435 //If EfiVarstore is not EFI_VARIABLE_NON_VOLATILE, only skip it.
437 if (Storage
->NewEfiVarstore
438 && ((Storage
->Attributes
& EFI_VARIABLE_NON_VOLATILE
) == 0)
440 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
444 // Try to get the available zone from the efi variables
446 Status
= GetVariableVar (
448 Storage
->Size
+ sizeof (VARIABLE_HEADER
),
452 if (!EFI_ERROR (Status
)) {
454 // Create the authenticated variable header
456 VariableHeader
= (VARIABLE_HEADER
*) NewAvailableAddr
;
457 VariableHeader
->StartId
= VARIABLE_DATA
;
458 VariableHeader
->State
= VAR_ADDED
;
459 VariableHeader
->Reserved
= 0x0;
460 VariableHeader
->MonotonicCount
= 0x0;
461 VariableHeader
->PubKeyIndex
= 0x0;
462 if (Storage
->NewEfiVarstore
) {
463 VariableHeader
->Attributes
= Storage
->Attributes
;
465 VariableHeader
->Attributes
= EFI_VARIABLE_NON_VOLATILE
|EFI_VARIABLE_BOOTSERVICE_ACCESS
|EFI_VARIABLE_RUNTIME_ACCESS
;
467 VariableHeader
->NameSize
= VarNameSize
;
468 VariableHeader
->DataSize
= Storage
->Size
;
470 //Copy the Guid, variable name, and data in sequence.
473 (VOID
*)&(VariableHeader
->VendorGuid
),
477 NewAvailableAddr
= NewAvailableAddr
+ sizeof (VARIABLE_HEADER
);
479 (VOID
*) NewAvailableAddr
,
484 NewAvailableAddr
= NewAvailableAddr
+ VarNameSize
+ GET_PAD_SIZE (VarNameSize
);
486 (VOID
*) NewAvailableAddr
,
488 Storage
->Size
* sizeof (CHAR8
)
491 printf ("Error. No available space in NV ram.\n");
492 return EFI_OUT_OF_RESOURCES
;
496 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
502 Remove the variable from Efi variable
504 Found the variable with the same name in StorageListHead and remove it.
506 @param StorageListHead Decide which variale list be removed.
508 @retval EFI_SUCCESS Remove the variables successfully.
511 RemoveAuthEfiVariable (
512 IN LIST_ENTRY
*StorageListHead
515 EFI_FIRMWARE_VOLUME_HEADER
*VarAddr
;
516 LIST_ENTRY
*StorageLink
;
517 FORMSET_STORAGE
*Storage
;
518 VARIABLE_HEADER
*VariableHeader
;
519 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
521 VariableHeader
= NULL
;
522 VarAddr
= (EFI_FIRMWARE_VOLUME_HEADER
*) gEfiFdInfo
.EfiVariableAddr
;
523 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*)((CHAR8
*)VarAddr
+ VarAddr
->HeaderLength
);
525 //Parse the variable range, and check whether there is some existed ones.
527 StorageLink
= GetFirstNode (StorageListHead
);
528 while (!IsNull (StorageListHead
, StorageLink
)) {
529 Storage
= FORMSET_STORAGE_FROM_LINK (StorageLink
);
531 // Ignore the invalid varlist node
533 if (Storage
->Buffer
== NULL
) {
534 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
538 // Report error, if the variable name is invalid.
540 if ((Storage
->Name
== NULL
) || (FceStrLen(Storage
->Name
) == 0)) {
541 printf ("Error. One variable name is NULL. Its GUID is: ");
542 PrintGuid(&(Storage
->Guid
));
543 return EFI_INVALID_PARAMETER
;
545 VariableHeader
= FindVariableInNv (
549 if (VariableHeader
!= NULL
) {
550 VariableHeader
->State
= VAR_DELETED
;
552 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
558 Check the store variable is Monotonic based authenticated or not
560 @param VarToList The pointer to the header of Variable Store.
562 @retval TRUE If authenticated, return TRUE.
563 @retval FALSE Otherwise, return FALSE.
567 CheckMonotonicBasedVarStore (
568 IN VOID
*VariableStoreHeader
572 &gEfiAuthenticatedVariableGuid
,
573 &((VARIABLE_STORE_HEADER
*)VariableStoreHeader
)->Signature
)
582 Copy Monotonic-Based authenticated variable to binary in multi-platform mode
584 @param Storage The pointer to a storage in storage list.
585 @param StorageBeginning The pointer to the beginning of storage under specifed platformId and defaultId
586 @param Index The number of the storage. If the Index is 0, record the variable header to
587 the binary. Or else, only record the storage.
589 @return length The length of storage
592 CopyMonotonicBasedVariableToBinary (
593 IN FORMSET_STORAGE
*Storage
,
594 IN OUT UINT8
*StorageBeginning
,
599 CHAR8
*NewAvailableAddr
;
600 VARIABLE_HEADER
*VariableHeader
;
601 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
605 Status
= EFI_SUCCESS
;
606 NewAvailableAddr
= NULL
;
609 VariableHeader
= NULL
;
610 VariableStoreHeader
= NULL
;
612 if ((Storage
->Name
== NULL
) || (FceStrLen(Storage
->Name
) == 0)) {
613 printf ("Error. One variable name is NULL. Its GUID is: ");
614 PrintGuid(&(Storage
->Guid
));
618 // If the first storage under one specified platformId and defaultId, create the variable header
621 HeaderLength
= WriteDefaultAndPlatformId (StorageBeginning
, Storage
);
622 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*) (StorageBeginning
+ HeaderLength
);
624 //Create the Variable Storage header
626 memcpy (&(VariableStoreHeader
->Signature
), &gEfiAuthenticatedVariableGuid
, sizeof (EFI_GUID
));
627 VariableStoreHeader
->Format
= 0x5A;
628 VariableStoreHeader
->State
= 0xFE;
630 //Assign a big size here. It will be fixed after the storage under a specifed platformId and defaultId are all written.
632 VariableStoreHeader
->Size
= gEfiFdInfo
.FdSize
;
634 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*) (StorageBeginning
+ *(UINT16
*)StorageBeginning
);
636 Status
= GetVariableVar (
638 Storage
->Size
+ sizeof (VARIABLE_HEADER
),
641 if (EFI_ERROR (Status
)) {
645 // Create the variable header
647 VarNameSize
= 2 * (FceStrLen (Storage
->Name
) + 1);
648 VariableHeader
= (VARIABLE_HEADER
*) NewAvailableAddr
;
649 VariableHeader
->StartId
= VARIABLE_DATA
;
650 VariableHeader
->State
= VAR_ADDED
;
651 VariableHeader
->Reserved
= 0x0;
652 VariableHeader
->MonotonicCount
= 0x0;
653 VariableHeader
->PubKeyIndex
= 0x0;
655 if (Storage
->NewEfiVarstore
) {
656 VariableHeader
->Attributes
= Storage
->Attributes
;
658 VariableHeader
->Attributes
= EFI_VARIABLE_NON_VOLATILE
|EFI_VARIABLE_BOOTSERVICE_ACCESS
|EFI_VARIABLE_RUNTIME_ACCESS
;
660 VariableHeader
->NameSize
= VarNameSize
;
661 VariableHeader
->DataSize
= Storage
->Size
;
663 //Copy the Guid, variable name, and data in sequence.
666 (VOID
*)&(VariableHeader
->VendorGuid
),
670 NewAvailableAddr
= NewAvailableAddr
+ sizeof (VARIABLE_HEADER
);
672 (VOID
*) NewAvailableAddr
,
677 NewAvailableAddr
= NewAvailableAddr
+ VarNameSize
+ GET_PAD_SIZE (VarNameSize
);
679 (VOID
*) NewAvailableAddr
,
681 Storage
->Size
* sizeof (CHAR8
)
686 // Return the length which is from the beginning of Binary
688 return ((UINT32
) ((UINT8
*)NewAvailableAddr
- StorageBeginning
) + Storage
->Size
);
693 Read Monotonic-based authenticated variable to storage list in multi-platform mode
695 @param Binary The pointer to the header of storage under specifed platformId and defaultId
696 @param StorageListEntry The pointer to the storage list.
698 @return length The length of storage
701 ReadMonotonicBasedVariableToList (
703 IN LIST_ENTRY
*StorageListEntry
706 VARIABLE_HEADER
*EndOfVariable
;
707 VARIABLE_HEADER
*Variable
;
708 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
709 FORMSET_STORAGE
*Storage
;
710 BOOLEAN ReadIdHeaderFlag
;
712 EFI_COMMON_SECTION_HEADER
*SectionHeader
;
714 static UINT16 PreDefaultId
[MAX_PLATFORM_DEFAULT_ID_NUM
];
715 static UINT64 PrePlatformId
[MAX_PLATFORM_DEFAULT_ID_NUM
];
717 VariableStoreHeader
= NULL
;
719 ReadIdHeaderFlag
= TRUE
;
721 SectionHeader
= (EFI_COMMON_SECTION_HEADER
*)Binary
;
722 DataBase
= Binary
+ sizeof (EFI_COMMON_SECTION_HEADER
);
723 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*) (DataBase
+ *(UINT16
*)DataBase
);
724 EndOfVariable
= GetEndPointer(VariableStoreHeader
);
726 for (Variable
= GetStartPointer (VariableStoreHeader
);
727 Length
< VariableStoreHeader
->Size
;
728 Length
+= sizeof (VARIABLE_HEADER
) + Variable
->NameSize
+ Variable
->DataSize
731 // Create the storage
734 Storage
= calloc (sizeof (FORMSET_STORAGE
), sizeof (CHAR8
));
735 if (Storage
== NULL
) {
736 printf ("Allocate memory failed.\n");
740 // If access the first storage, read the platformId and defaultId
742 if (ReadIdHeaderFlag
) {
743 ReadDefaultAndPlatformIdFromBfv (DataBase
, Storage
);
744 Length
+= sizeof (VARIABLE_HEADER
) + Variable
->NameSize
+ Variable
->DataSize
;
745 ReadIdHeaderFlag
= FALSE
;
746 memcpy (PreDefaultId
, Storage
->DefaultId
, MAX_PLATFORM_DEFAULT_ID_NUM
* sizeof (UINT16
));
747 memcpy (PrePlatformId
, Storage
->PlatformId
, MAX_PLATFORM_DEFAULT_ID_NUM
* sizeof (UINT64
));
750 // Store the DefaultId and PlatformId collected from the header to Storage.
752 memcpy (Storage
->DefaultId
, PreDefaultId
, MAX_PLATFORM_DEFAULT_ID_NUM
* sizeof (UINT16
));
753 memcpy (Storage
->PlatformId
, PrePlatformId
, MAX_PLATFORM_DEFAULT_ID_NUM
* sizeof (UINT64
));
755 Storage
->Attributes
= Variable
->Attributes
;
756 Storage
->Size
= (UINT16
)Variable
->DataSize
;
757 Storage
->Name
= calloc (Variable
->NameSize
, sizeof (UINT8
));
758 ASSERT (Storage
->Name
!= NULL
);
759 Storage
->Buffer
= calloc (Variable
->DataSize
, sizeof (UINT8
));
760 ASSERT (Storage
->Buffer
!= NULL
);
763 &(Variable
->VendorGuid
),
768 (UINT8
*)Variable
+ sizeof (VARIABLE_HEADER
),
773 (UINT8
*)Variable
+ sizeof (VARIABLE_HEADER
) + Variable
->NameSize
+ GET_PAD_SIZE (Variable
->NameSize
),
774 Storage
->Size
* sizeof (CHAR8
)
777 // Assigned the value for comparison in verify mode
779 Storage
->Type
= EFI_IFR_VARSTORE_EFI_OP
;
780 Storage
->NewEfiVarstore
= TRUE
;
781 InitializeListHead (&Storage
->NameValueListHead
);
783 InsertTailList(StorageListEntry
, &Storage
->Link
);
785 // If the last variable, exit.
787 if (Variable
== EndOfVariable
) {
791 Variable
= GetNextVariablePtr (Variable
);
792 assert (Variable
!= NULL
);
795 // Return the length which is from the beginning of Binary
797 Length
= FvBufExpand3ByteSize (SectionHeader
->Size
);
803 Check whether exists the valid MonotonicBased variables in NvStorage or not.
805 @retval TRUE If existed, return TRUE.
809 ExistMonotonicBasedEfiVarOrNot (
810 IN LIST_ENTRY
*StorageListHead
813 EFI_FIRMWARE_VOLUME_HEADER
*VarAddr
;
814 LIST_ENTRY
*StorageLink
;
815 FORMSET_STORAGE
*Storage
;
816 VARIABLE_HEADER
*VariableHeader
;
817 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
819 VariableHeader
= NULL
;
820 VarAddr
= (EFI_FIRMWARE_VOLUME_HEADER
*) gEfiFdInfo
.EfiVariableAddr
;
821 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*)((CHAR8
*)VarAddr
+ VarAddr
->HeaderLength
);
823 //Parse the variable range, and check whether there is some existed ones.
825 StorageLink
= GetFirstNode (StorageListHead
);
826 while (!IsNull (StorageListHead
, StorageLink
)) {
827 Storage
= FORMSET_STORAGE_FROM_LINK (StorageLink
);
829 // Ignore the invalid varlist node
831 if ((Storage
->Buffer
== NULL
)
832 || (Storage
->Name
== NULL
)
833 || (FceStrLen(Storage
->Name
) == 0)
835 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
839 // Report error, if the variable name is invalid.
841 if ((Storage
->Name
== NULL
) || (FceStrLen(Storage
->Name
) == 0)) {
842 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
845 VariableHeader
= FindVariableInNv (
850 if ((VariableHeader
!= NULL
)) {
853 StorageLink
= GetNextNode (StorageListHead
, StorageLink
);
858 Fix the size of montonic variable header.
860 @param Binary The pointer to the header of storage under specifed platformId and defaultId
861 @param Length The length of binary.
865 FixMontonicVariableHeaderSize (
866 IN UINT8
*BinaryBeginning
,
870 VARIABLE_STORE_HEADER
*VariableStoreHeader
;
872 VariableStoreHeader
= (VARIABLE_STORE_HEADER
*) (BinaryBeginning
+ *(UINT16
*)BinaryBeginning
);
873 VariableStoreHeader
->Size
= Length
- *(UINT16
*)BinaryBeginning
;