Add core FFS3 support, ExtractGuidedSectionLib/GuidedSectionExtractionLib/PiFirmwareFile.h.
Signed-off-by: lzeng14 Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12582 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
59d88f42ca
commit
30f001ca5f
|
@ -1,8 +1,8 @@
|
||||||
/** @file
|
/** @file
|
||||||
UEFI and Tiano Custom Decompress Library
|
UEFI and Tiano Custom Decompress Library
|
||||||
Tt will do Tiano or UEFI decompress with different verison parameter.
|
It will do Tiano or UEFI decompress with different verison parameter.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -897,25 +897,47 @@ TianoDecompressGetInfo (
|
||||||
return RETURN_INVALID_PARAMETER;
|
return RETURN_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CompareGuid (
|
if (IS_SECTION2 (InputSection)) {
|
||||||
&gTianoCustomDecompressGuid,
|
if (!CompareGuid (
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&gTianoCustomDecompressGuid,
|
||||||
return RETURN_INVALID_PARAMETER;
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
}
|
return RETURN_INVALID_PARAMETER;
|
||||||
//
|
}
|
||||||
// Get guid attribute of guid section.
|
//
|
||||||
//
|
// Get guid attribute of guid section.
|
||||||
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
//
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call Tiano GetInfo to get the required size info.
|
// Call Tiano GetInfo to get the required size info.
|
||||||
//
|
//
|
||||||
return UefiDecompressGetInfo (
|
return UefiDecompressGetInfo (
|
||||||
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
(*(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & 0x00ffffff) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
OutputBufferSize,
|
OutputBufferSize,
|
||||||
ScratchBufferSize
|
ScratchBufferSize
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gTianoCustomDecompressGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Get guid attribute of guid section.
|
||||||
|
//
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Call Tiano GetInfo to get the required size info.
|
||||||
|
//
|
||||||
|
return UefiDecompressGetInfo (
|
||||||
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
|
SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
|
OutputBufferSize,
|
||||||
|
ScratchBufferSize
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -963,26 +985,49 @@ TianoDecompress (
|
||||||
ASSERT (OutputBuffer != NULL);
|
ASSERT (OutputBuffer != NULL);
|
||||||
ASSERT (InputSection != NULL);
|
ASSERT (InputSection != NULL);
|
||||||
|
|
||||||
if (!CompareGuid (
|
if (IS_SECTION2 (InputSection)) {
|
||||||
&gTianoCustomDecompressGuid,
|
if (!CompareGuid (
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&gTianoCustomDecompressGuid,
|
||||||
return RETURN_INVALID_PARAMETER;
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
}
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set Authentication to Zero.
|
// Set Authentication to Zero.
|
||||||
//
|
//
|
||||||
*AuthenticationStatus = 0;
|
*AuthenticationStatus = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Call Tiano Decompress to get the raw data
|
// Call Tiano Decompress to get the raw data
|
||||||
//
|
//
|
||||||
return UefiTianoDecompress (
|
return UefiTianoDecompress (
|
||||||
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
*OutputBuffer,
|
*OutputBuffer,
|
||||||
ScratchBuffer,
|
ScratchBuffer,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gTianoCustomDecompressGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set Authentication to Zero.
|
||||||
|
//
|
||||||
|
*AuthenticationStatus = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Call Tiano Decompress to get the raw data
|
||||||
|
//
|
||||||
|
return UefiTianoDecompress (
|
||||||
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
|
*OutputBuffer,
|
||||||
|
ScratchBuffer,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1000,5 +1045,5 @@ TianoDecompressLibConstructor (
|
||||||
&gTianoCustomDecompressGuid,
|
&gTianoCustomDecompressGuid,
|
||||||
TianoDecompressGetInfo,
|
TianoDecompressGetInfo,
|
||||||
TianoDecompress
|
TianoDecompress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces
|
It wraps Lzma decompress interfaces to GUIDed Section Extraction interfaces
|
||||||
and registers them into GUIDed handler table.
|
and registers them into GUIDed handler table.
|
||||||
|
|
||||||
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -63,20 +63,37 @@ LzmaGuidedSectionGetInfo (
|
||||||
ASSERT (ScratchBufferSize != NULL);
|
ASSERT (ScratchBufferSize != NULL);
|
||||||
ASSERT (SectionAttribute != NULL);
|
ASSERT (SectionAttribute != NULL);
|
||||||
|
|
||||||
if (!CompareGuid (
|
if (IS_SECTION2 (InputSection)) {
|
||||||
&gLzmaCustomDecompressGuid,
|
if (!CompareGuid (
|
||||||
|
&gLzmaCustomDecompressGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
|
||||||
|
|
||||||
|
return LzmaUefiDecompressGetInfo (
|
||||||
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
|
SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
|
OutputBufferSize,
|
||||||
|
ScratchBufferSize
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gLzmaCustomDecompressGuid,
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
return RETURN_INVALID_PARAMETER;
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
||||||
|
|
||||||
|
return LzmaUefiDecompressGetInfo (
|
||||||
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
|
SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
|
OutputBufferSize,
|
||||||
|
ScratchBufferSize
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
|
||||||
|
|
||||||
return LzmaUefiDecompressGetInfo (
|
|
||||||
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
|
||||||
SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
|
||||||
OutputBufferSize,
|
|
||||||
ScratchBufferSize
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,23 +141,43 @@ LzmaGuidedSectionExtraction (
|
||||||
ASSERT (OutputBuffer != NULL);
|
ASSERT (OutputBuffer != NULL);
|
||||||
ASSERT (InputSection != NULL);
|
ASSERT (InputSection != NULL);
|
||||||
|
|
||||||
if (!CompareGuid (
|
if (IS_SECTION2 (InputSection)) {
|
||||||
&gLzmaCustomDecompressGuid,
|
if (!CompareGuid (
|
||||||
|
&gLzmaCustomDecompressGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return RETURN_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Authentication is set to Zero, which may be ignored.
|
||||||
|
//
|
||||||
|
*AuthenticationStatus = 0;
|
||||||
|
|
||||||
|
return LzmaUefiDecompress (
|
||||||
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
|
SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset,
|
||||||
|
*OutputBuffer,
|
||||||
|
ScratchBuffer
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gLzmaCustomDecompressGuid,
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
return RETURN_INVALID_PARAMETER;
|
return RETURN_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Authentication is set to Zero, which may be ignored.
|
// Authentication is set to Zero, which may be ignored.
|
||||||
//
|
//
|
||||||
*AuthenticationStatus = 0;
|
*AuthenticationStatus = 0;
|
||||||
|
|
||||||
return LzmaUefiDecompress (
|
return LzmaUefiDecompress (
|
||||||
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
(UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset,
|
||||||
*OutputBuffer,
|
*OutputBuffer,
|
||||||
ScratchBuffer
|
ScratchBuffer
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
to parse CRC32 encapsulation section and extract raw data.
|
to parse CRC32 encapsulation section and extract raw data.
|
||||||
It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value.
|
It uses UEFI boot service CalculateCrc32 to authenticate 32 bit CRC value.
|
||||||
|
|
||||||
Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -23,8 +23,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
#include <Library/UefiBootServicesTableLib.h>
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
|
||||||
#define EFI_SECITON_SIZE_MASK 0x00ffffff
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// CRC32 Guided Section header
|
/// CRC32 Guided Section header
|
||||||
///
|
///
|
||||||
|
@ -33,6 +31,11 @@ typedef struct {
|
||||||
UINT32 CRC32Checksum; ///< 32bit CRC check sum
|
UINT32 CRC32Checksum; ///< 32bit CRC check sum
|
||||||
} CRC32_SECTION_HEADER;
|
} CRC32_SECTION_HEADER;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
EFI_GUID_DEFINED_SECTION2 GuidedSectionHeader; ///< EFI guided section header
|
||||||
|
UINT32 CRC32Checksum; ///< 32bit CRC check sum
|
||||||
|
} CRC32_SECTION2_HEADER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
GetInfo gets raw data size and attribute of the input guided section.
|
GetInfo gets raw data size and attribute of the input guided section.
|
||||||
|
@ -58,21 +61,37 @@ Crc32GuidedSectionGetInfo (
|
||||||
OUT UINT16 *SectionAttribute
|
OUT UINT16 *SectionAttribute
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
if (IS_SECTION2 (InputSection)) {
|
||||||
// Check whether the input guid section is recognized.
|
//
|
||||||
//
|
// Check whether the input guid section is recognized.
|
||||||
if (!CompareGuid (
|
//
|
||||||
&gEfiCrc32GuidedSectionExtractionGuid,
|
if (!CompareGuid (
|
||||||
|
&gEfiCrc32GuidedSectionExtractionGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Retrieve the size and attribute of the input section data.
|
||||||
|
//
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes;
|
||||||
|
*ScratchBufferSize = 0;
|
||||||
|
*OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Check whether the input guid section is recognized.
|
||||||
|
//
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gEfiCrc32GuidedSectionExtractionGuid,
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Retrieve the size and attribute of the input section data.
|
||||||
|
//
|
||||||
|
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
||||||
|
*ScratchBufferSize = 0;
|
||||||
|
*OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// Retrieve the size and attribute of the input section data.
|
|
||||||
//
|
|
||||||
*SectionAttribute = ((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes;
|
|
||||||
*ScratchBufferSize = 0;
|
|
||||||
*OutputBufferSize = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & EFI_SECITON_SIZE_MASK;
|
|
||||||
*OutputBufferSize -= ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -104,37 +123,61 @@ Crc32GuidedSectionHandler (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
CRC32_SECTION_HEADER *Crc32SectionHeader;
|
UINT32 SectionCrc32Checksum;
|
||||||
UINT32 Crc32Checksum;
|
UINT32 Crc32Checksum;
|
||||||
UINT32 OutputBufferSize;
|
UINT32 OutputBufferSize;
|
||||||
VOID *DummyInterface;
|
VOID *DummyInterface;
|
||||||
|
|
||||||
//
|
if (IS_SECTION2 (InputSection)) {
|
||||||
// Check whether the input guid section is recognized.
|
//
|
||||||
//
|
// Check whether the input guid section is recognized.
|
||||||
if (!CompareGuid (
|
//
|
||||||
&gEfiCrc32GuidedSectionExtractionGuid,
|
if (!CompareGuid (
|
||||||
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
&gEfiCrc32GuidedSectionExtractionGuid,
|
||||||
return EFI_INVALID_PARAMETER;
|
&(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid))) {
|
||||||
}
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get section Crc32 checksum.
|
||||||
|
//
|
||||||
|
SectionCrc32Checksum = ((CRC32_SECTION2_HEADER *) InputSection)->CRC32Checksum;
|
||||||
|
*OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
|
||||||
|
OutputBufferSize = SECTION2_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION2 *) InputSection)->DataOffset;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
|
||||||
|
//
|
||||||
|
ASSERT (((EFI_GUID_DEFINED_SECTION2 *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
|
||||||
|
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
|
||||||
|
} else {
|
||||||
|
//
|
||||||
|
// Check whether the input guid section is recognized.
|
||||||
|
//
|
||||||
|
if (!CompareGuid (
|
||||||
|
&gEfiCrc32GuidedSectionExtractionGuid,
|
||||||
|
&(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get section Crc32 checksum.
|
||||||
|
//
|
||||||
|
SectionCrc32Checksum = ((CRC32_SECTION_HEADER *) InputSection)->CRC32Checksum;
|
||||||
|
*OutputBuffer = (UINT8 *) InputSection + ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
|
||||||
|
OutputBufferSize = SECTION_SIZE (InputSection) - ((EFI_GUID_DEFINED_SECTION *) InputSection)->DataOffset;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implicitly CRC32 GUIDed section should have STATUS_VALID bit set
|
||||||
|
//
|
||||||
|
ASSERT (((EFI_GUID_DEFINED_SECTION *) InputSection)->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
|
||||||
|
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init Checksum value to Zero.
|
// Init Checksum value to Zero.
|
||||||
//
|
//
|
||||||
Crc32Checksum = 0;
|
Crc32Checksum = 0;
|
||||||
//
|
|
||||||
// Points to the Crc32 section header
|
|
||||||
//
|
|
||||||
Crc32SectionHeader = (CRC32_SECTION_HEADER *) InputSection;
|
|
||||||
*OutputBuffer = (UINT8 *) InputSection + Crc32SectionHeader->GuidedSectionHeader.DataOffset;
|
|
||||||
OutputBufferSize = *(UINT32 *) (((EFI_COMMON_SECTION_HEADER *) InputSection)->Size) & EFI_SECITON_SIZE_MASK;
|
|
||||||
OutputBufferSize -= Crc32SectionHeader->GuidedSectionHeader.DataOffset;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Implictly CRC32 GUIDed section should have STATUS_VALID bit set
|
|
||||||
//
|
|
||||||
ASSERT (Crc32SectionHeader->GuidedSectionHeader.Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID);
|
|
||||||
*AuthenticationStatus = EFI_AUTH_STATUS_IMAGE_SIGNED;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check whether there exists EFI_SECURITY_POLICY_PROTOCOL_GUID.
|
// Check whether there exists EFI_SECURITY_POLICY_PROTOCOL_GUID.
|
||||||
|
@ -151,7 +194,7 @@ Crc32GuidedSectionHandler (
|
||||||
//
|
//
|
||||||
Status = gBS->CalculateCrc32 (*OutputBuffer, OutputBufferSize, &Crc32Checksum);
|
Status = gBS->CalculateCrc32 (*OutputBuffer, OutputBufferSize, &Crc32Checksum);
|
||||||
if (Status == EFI_SUCCESS) {
|
if (Status == EFI_SUCCESS) {
|
||||||
if (Crc32Checksum != Crc32SectionHeader->CRC32Checksum) {
|
if (Crc32Checksum != SectionCrc32Checksum) {
|
||||||
//
|
//
|
||||||
// If Crc32 checksum is not matched, AUTH tested failed bit is set.
|
// If Crc32 checksum is not matched, AUTH tested failed bit is set.
|
||||||
//
|
//
|
||||||
|
|
|
@ -176,6 +176,15 @@ typedef struct {
|
||||||
UINT32 ExtendedSize;
|
UINT32 ExtendedSize;
|
||||||
} EFI_FFS_FILE_HEADER2;
|
} EFI_FFS_FILE_HEADER2;
|
||||||
|
|
||||||
|
#define IS_FFS_FILE2(FfsFileHeaderPtr) \
|
||||||
|
(((((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Attributes) & FFS_ATTRIB_LARGE_FILE) == FFS_ATTRIB_LARGE_FILE)
|
||||||
|
|
||||||
|
#define FFS_FILE_SIZE(FfsFileHeaderPtr) \
|
||||||
|
((UINT32) (*((UINT32 *) ((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Size) & 0x00ffffff))
|
||||||
|
|
||||||
|
#define FFS_FILE2_SIZE(FfsFileHeaderPtr) \
|
||||||
|
(((EFI_FFS_FILE_HEADER2 *) (UINTN) FfsFileHeaderPtr)->ExtendedSize)
|
||||||
|
|
||||||
typedef UINT8 EFI_SECTION_TYPE;
|
typedef UINT8 EFI_SECTION_TYPE;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -470,8 +479,14 @@ typedef struct {
|
||||||
CHAR16 VersionString[1];
|
CHAR16 VersionString[1];
|
||||||
} EFI_VERSION_SECTION2;
|
} EFI_VERSION_SECTION2;
|
||||||
|
|
||||||
|
#define IS_SECTION2(SectionHeaderPtr) \
|
||||||
|
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff) == 0x00ffffff)
|
||||||
|
|
||||||
#define SECTION_SIZE(SectionHeaderPtr) \
|
#define SECTION_SIZE(SectionHeaderPtr) \
|
||||||
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
|
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) (UINTN) SectionHeaderPtr)->Size) & 0x00ffffff))
|
||||||
|
|
||||||
|
#define SECTION2_SIZE(SectionHeaderPtr) \
|
||||||
|
(((EFI_COMMON_SECTION_HEADER2 *) (UINTN) SectionHeaderPtr)->ExtendedSize)
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,8 @@ typedef struct {
|
||||||
#define EFI_FV_EXT_TYPE_GUID_TYPE 0x0002
|
#define EFI_FV_EXT_TYPE_GUID_TYPE 0x0002
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This extension header provides a mapping between a GUID and an OEM file type.
|
/// This extension header EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE provides a vendor specific
|
||||||
|
/// GUID FormatType type which includes a length and a successive series of data bytes.
|
||||||
///
|
///
|
||||||
typedef struct {
|
typedef struct {
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provide generic extract guided section functions.
|
Provide generic extract guided section functions.
|
||||||
|
|
||||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -261,6 +261,7 @@ ExtractGuidedSectionGetInfo (
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check input paramter
|
// Check input paramter
|
||||||
|
@ -278,11 +279,17 @@ ExtractGuidedSectionGetInfo (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered GetInfo handler for the input guided section.
|
// Search the match registered GetInfo handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to get information for the input section data.
|
// Call the match handler to get information for the input section data.
|
||||||
//
|
//
|
||||||
|
@ -348,6 +355,7 @@ ExtractGuidedSectionDecode (
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
RETURN_STATUS Status;
|
RETURN_STATUS Status;
|
||||||
EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check input parameter
|
// Check input parameter
|
||||||
|
@ -364,11 +372,17 @@ ExtractGuidedSectionDecode (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered Extract handler for the input guided section.
|
// Search the match registered Extract handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to extract raw data for the input guided section.
|
// Call the match handler to extract raw data for the input guided section.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provide generic extract guided section functions for Dxe phase.
|
Provide generic extract guided section functions for Dxe phase.
|
||||||
|
|
||||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -259,17 +259,24 @@ ExtractGuidedSectionGetInfo (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
ASSERT (InputSection != NULL);
|
ASSERT (InputSection != NULL);
|
||||||
ASSERT (OutputBufferSize != NULL);
|
ASSERT (OutputBufferSize != NULL);
|
||||||
ASSERT (ScratchBufferSize != NULL);
|
ASSERT (ScratchBufferSize != NULL);
|
||||||
ASSERT (SectionAttribute != NULL);
|
ASSERT (SectionAttribute != NULL);
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered GetInfo handler for the input guided section.
|
// Search the match registered GetInfo handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to getinfo for the input section data.
|
// Call the match handler to getinfo for the input section data.
|
||||||
//
|
//
|
||||||
|
@ -333,6 +340,7 @@ ExtractGuidedSectionDecode (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check the input parameters
|
// Check the input parameters
|
||||||
|
@ -341,11 +349,17 @@ ExtractGuidedSectionDecode (
|
||||||
ASSERT (OutputBuffer != NULL);
|
ASSERT (OutputBuffer != NULL);
|
||||||
ASSERT (AuthenticationStatus != NULL);
|
ASSERT (AuthenticationStatus != NULL);
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered extract handler for the input guided section.
|
// Search the match registered extract handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < mNumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (&mExtractHandlerGuidTable[Index], &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (&mExtractHandlerGuidTable[Index], SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to extract raw data for the input section data.
|
// Call the match handler to extract raw data for the input section data.
|
||||||
//
|
//
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provide generic extract guided section functions for PEI phase.
|
Provide generic extract guided section functions for PEI phase.
|
||||||
|
|
||||||
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -290,6 +290,7 @@ ExtractGuidedSectionGetInfo (
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check input paramter
|
// Check input paramter
|
||||||
|
@ -306,12 +307,18 @@ ExtractGuidedSectionGetInfo (
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered GetInfo handler for the input guided section.
|
// Search the match registered GetInfo handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to get information for the input section data.
|
// Call the match handler to get information for the input section data.
|
||||||
//
|
//
|
||||||
|
@ -377,6 +384,7 @@ ExtractGuidedSectionDecode (
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
PEI_EXTRACT_GUIDED_SECTION_HANDLER_INFO *HandlerInfo;
|
||||||
|
EFI_GUID *SectionDefinitionGuid;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check input parameter
|
// Check input parameter
|
||||||
|
@ -393,11 +401,17 @@ ExtractGuidedSectionDecode (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IS_SECTION2 (InputSection)) {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION2 *) InputSection)->SectionDefinitionGuid);
|
||||||
|
} else {
|
||||||
|
SectionDefinitionGuid = &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Search the match registered Extract handler for the input guided section.
|
// Search the match registered Extract handler for the input guided section.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
for (Index = 0; Index < HandlerInfo->NumberOfExtractHandler; Index ++) {
|
||||||
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, &(((EFI_GUID_DEFINED_SECTION *) InputSection)->SectionDefinitionGuid))) {
|
if (CompareGuid (HandlerInfo->ExtractHandlerGuidTable + Index, SectionDefinitionGuid)) {
|
||||||
//
|
//
|
||||||
// Call the match handler to extract raw data for the input guided section.
|
// Call the match handler to extract raw data for the input guided section.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue