mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-21 20:54:29 +02:00
MdeModulePkg: Adding support for authenticated variable
storage data format REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4857 NVS needs to support both authenticated and non-authenticated header for NV region. PcdNvStoreDefaultValueBuffer can have variables with data format of the type Authenticated variable storage and this change provides the support to differentiate between the normal variable storage and authenticated variable storage for the hii database to consume and update the setup variables accordingly Signed-off-by: nikhil p sheshagiri <nikhil.p.sheshagiri@intel.com>
This commit is contained in:
parent
56dfab9a8a
commit
acce74762b
@ -564,6 +564,45 @@ IsEfiVarStoreQuestion (
|
|||||||
return EfiVarStoreNumber;
|
return EfiVarStoreNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Find the matched variable from the input variable storage.
|
||||||
|
|
||||||
|
@param[in] VariableStorage Point to the variable storage header.
|
||||||
|
@param[in] VarGuid A unique identifier for the variable.
|
||||||
|
@param[in] VarAttribute The attributes bitmask for the variable.
|
||||||
|
@param[in] VarName A Null-terminated ascii string that is the name of the variable.
|
||||||
|
|
||||||
|
@return Pointer to the matched variable header or NULL if not found.
|
||||||
|
**/
|
||||||
|
AUTHENTICATED_VARIABLE_HEADER *
|
||||||
|
AuthFindVariableData (
|
||||||
|
IN VARIABLE_STORE_HEADER *VariableStorage,
|
||||||
|
IN EFI_GUID *VarGuid,
|
||||||
|
IN UINT32 VarAttribute,
|
||||||
|
IN CHAR16 *VarName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AUTHENTICATED_VARIABLE_HEADER *VariableHeader;
|
||||||
|
AUTHENTICATED_VARIABLE_HEADER *VariableEnd;
|
||||||
|
|
||||||
|
VariableEnd = (AUTHENTICATED_VARIABLE_HEADER *)((UINT8 *)VariableStorage + VariableStorage->Size);
|
||||||
|
VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)(VariableStorage + 1);
|
||||||
|
VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN (VariableHeader);
|
||||||
|
while (VariableHeader < VariableEnd) {
|
||||||
|
if (CompareGuid (&VariableHeader->VendorGuid, VarGuid) &&
|
||||||
|
(VariableHeader->Attributes == VarAttribute) &&
|
||||||
|
(StrCmp (VarName, (CHAR16 *)(VariableHeader + 1)) == 0))
|
||||||
|
{
|
||||||
|
return VariableHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)((UINT8 *)VariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + VariableHeader->NameSize + VariableHeader->DataSize);
|
||||||
|
VariableHeader = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN (VariableHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Find the matched variable from the input variable storage.
|
Find the matched variable from the input variable storage.
|
||||||
|
|
||||||
@ -626,6 +665,7 @@ FindQuestionDefaultSetting (
|
|||||||
IN BOOLEAN BitFieldQuestion
|
IN BOOLEAN BitFieldQuestion
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
AUTHENTICATED_VARIABLE_HEADER *AuthVariableHeader;
|
||||||
VARIABLE_HEADER *VariableHeader;
|
VARIABLE_HEADER *VariableHeader;
|
||||||
VARIABLE_STORE_HEADER *VariableStorage;
|
VARIABLE_STORE_HEADER *VariableStorage;
|
||||||
LIST_ENTRY *Link;
|
LIST_ENTRY *Link;
|
||||||
@ -645,6 +685,7 @@ FindQuestionDefaultSetting (
|
|||||||
PCD_DEFAULT_DATA *DataHeader;
|
PCD_DEFAULT_DATA *DataHeader;
|
||||||
PCD_DEFAULT_INFO *DefaultInfo;
|
PCD_DEFAULT_INFO *DefaultInfo;
|
||||||
PCD_DATA_DELTA *DeltaData;
|
PCD_DATA_DELTA *DeltaData;
|
||||||
|
BOOLEAN VarCheck;
|
||||||
|
|
||||||
if (gSkuId == 0xFFFFFFFFFFFFFFFF) {
|
if (gSkuId == 0xFFFFFFFFFFFFFFFF) {
|
||||||
gSkuId = LibPcdGetSku ();
|
gSkuId = LibPcdGetSku ();
|
||||||
@ -750,6 +791,46 @@ FindQuestionDefaultSetting (
|
|||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VarCheck = (BOOLEAN)(CompareGuid (&VariableStorage->Signature, &gEfiAuthenticatedVariableGuid));
|
||||||
|
|
||||||
|
if (VarCheck) {
|
||||||
|
//
|
||||||
|
// Find the question default value from the variable storage
|
||||||
|
//
|
||||||
|
AuthVariableHeader = AuthFindVariableData (VariableStorage, &EfiVarStore->Guid, EfiVarStore->Attributes, (CHAR16 *)EfiVarStore->Name);
|
||||||
|
if (AuthVariableHeader == NULL) {
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartBit = 0;
|
||||||
|
EndBit = 0;
|
||||||
|
ByteOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
|
||||||
|
if (BitFieldQuestion) {
|
||||||
|
BitOffset = IfrQuestionHdr->VarStoreInfo.VarOffset;
|
||||||
|
ByteOffset = BitOffset / 8;
|
||||||
|
BitWidth = Width;
|
||||||
|
StartBit = BitOffset % 8;
|
||||||
|
EndBit = StartBit + BitWidth - 1;
|
||||||
|
Width = EndBit / 8 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AuthVariableHeader->DataSize < ByteOffset + Width) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Copy the question value
|
||||||
|
//
|
||||||
|
if (ValueBuffer != NULL) {
|
||||||
|
if (BitFieldQuestion) {
|
||||||
|
CopyMem (&BufferValue, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + ByteOffset, Width);
|
||||||
|
BitFieldVal = BitFieldRead32 (BufferValue, StartBit, EndBit);
|
||||||
|
CopyMem (ValueBuffer, &BitFieldVal, Width);
|
||||||
|
} else {
|
||||||
|
CopyMem (ValueBuffer, (UINT8 *)AuthVariableHeader + sizeof (AUTHENTICATED_VARIABLE_HEADER) + AuthVariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
//
|
//
|
||||||
// Find the question default value from the variable storage
|
// Find the question default value from the variable storage
|
||||||
//
|
//
|
||||||
@ -786,6 +867,7 @@ FindQuestionDefaultSetting (
|
|||||||
CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
|
CopyMem (ValueBuffer, (UINT8 *)VariableHeader + sizeof (VARIABLE_HEADER) + VariableHeader->NameSize + IfrQuestionHdr->VarStoreInfo.VarOffset, Width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@
|
|||||||
gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
|
gEfiHiiImageDecoderNameJpegGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
|
||||||
gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
|
gEfiHiiImageDecoderNamePngGuid |gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## SOMETIMES_CONSUMES ## GUID
|
||||||
gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID
|
gEdkiiIfrBitVarstoreGuid ## SOMETIMES_CONSUMES ## GUID
|
||||||
|
gEfiAuthenticatedVariableGuid ## CONSUMES ## GUID
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
TRUE
|
TRUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user