Build the registered guid HOB and SystemTable to record the GUID itself in PeiExtractGuidedSectionLib and DxeExtractGuidedSectionLib, and also state the restriction in BaseExtractGuidedSectionLib.

Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13930 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lzeng14
2012-11-08 01:12:56 +00:00
parent 17dd0f2bb1
commit 8472f1f59d
8 changed files with 190 additions and 31 deletions

View File

@ -490,6 +490,53 @@ ChildIsType (
}
}
/**
Verify the Guided Section GUID by checking if there is the Guided Section GUID configuration table recorded the GUID itself.
@param GuidedSectionGuid The Guided Section GUID.
@param GuidedSectionExtraction A pointer to the pointer to the supported Guided Section Extraction Protocol
for the Guided Section.
@return TRUE The GuidedSectionGuid could be identified, and the pointer to
the Guided Section Extraction Protocol will be returned to *GuidedSectionExtraction.
@return FALSE The GuidedSectionGuid could not be identified, or
the Guided Section Extraction Protocol has not been installed yet.
**/
BOOLEAN
VerifyGuidedSectionGuid (
IN EFI_GUID *GuidedSectionGuid,
OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSectionExtraction
)
{
EFI_GUID *GuidRecorded;
VOID *Interface;
EFI_STATUS Status;
//
// Check if there is the Guided Section GUID configuration table recorded the GUID itself.
//
Status = EfiGetSystemConfigurationTable (GuidedSectionGuid, (VOID **) &GuidRecorded);
if (Status == EFI_SUCCESS) {
if (CompareGuid (GuidRecorded, GuidedSectionGuid)) {
//
// Found the recorded GuidedSectionGuid.
//
Status = CoreLocateProtocol (GuidedSectionGuid, NULL, (VOID **) &Interface);
if (!EFI_ERROR (Status) && Interface != NULL) {
//
// Found the supported Guided Section Extraction Porotocol for the Guided Section.
//
*GuidedSectionExtraction = (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *) Interface;
return TRUE;
}
return FALSE;
}
}
return FALSE;
}
/**
RPN callback function. Initializes the section stream
when GUIDED_SECTION_EXTRACTION_PROTOCOL is installed.
@ -517,12 +564,11 @@ NotifyGuidedExtraction (
GuidedHeader = (EFI_GUID_DEFINED_SECTION *) (Context->ParentStream->StreamBuffer + Context->ChildNode->OffsetInStream);
ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);
Status = gBS->LocateProtocol (Context->ChildNode->EncapsulationGuid, NULL, (VOID **)&GuidedExtraction);
if (EFI_ERROR (Status)) {
if (!VerifyGuidedSectionGuid (Context->ChildNode->EncapsulationGuid, &GuidedExtraction)) {
return;
}
Status = GuidedExtraction->ExtractSection (
GuidedExtraction,
GuidedHeader,
@ -793,8 +839,7 @@ CreateChildNode (
Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;
GuidedSectionAttributes = GuidedHeader->Attributes;
}
Status = CoreLocateProtocol (Node->EncapsulationGuid, NULL, (VOID **)&GuidedExtraction);
if (!EFI_ERROR (Status) && GuidedExtraction != NULL) {
if (VerifyGuidedSectionGuid (Node->EncapsulationGuid, &GuidedExtraction)) {
//
// NewStreamBuffer is always allocated by ExtractSection... No caller
// allocation here.