From 878ddf1fc3540a715f63594ed22b6929e881afb4 Mon Sep 17 00:00:00 2001 From: bbahnsen Date: Fri, 21 Apr 2006 22:54:32 +0000 Subject: Initial import. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Crc32SectionExtract/Dxe/Crc32SectionExtract.c | 234 +++++++++++++++++++++ .../Dxe/Crc32SectionExtract.dxs | 28 +++ .../Crc32SectionExtract/Dxe/Crc32SectionExtract.h | 65 ++++++ .../Dxe/Crc32SectionExtract.mbd | 40 ++++ .../Dxe/Crc32SectionExtract.msa | 61 ++++++ .../Crc32SectionExtract/Dxe/GuidedSection.c | 75 +++++++ .../Crc32SectionExtract/Dxe/GuidedSection.h | 53 +++++ .../Crc32SectionExtract/Dxe/build.xml | 47 +++++ 8 files changed, 603 insertions(+) create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.c create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.dxs create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.h create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.c create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.h create mode 100644 EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/build.xml (limited to 'EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction') diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.c b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.c new file mode 100644 index 0000000000..dc7ed07baa --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.c @@ -0,0 +1,234 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Crc32SectionExtract.c + +Abstract: + + Implements GUIDed section extraction protocol interface with + a specific GUID: CRC32. + + Please refer to the Tiano File Image Format Specification, + FV spec 0.3.6 + +--*/ + + +#include +#include + +EFI_STATUS +InitializeCrc32GuidedSectionExtractionProtocol ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ); + +EFI_STATUS +InitializeCrc32GuidedSectionExtractionProtocol ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +/*++ + +Routine Description: + + Entry point of the CRC32 GUIDed section extraction protocol. + Creates and initializes an instance of the GUIDed section + extraction protocol with CRC32 GUID. + +Arguments: + + ImageHandle EFI_HANDLE: A handle for the image that is initializing + this driver + SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table + +Returns: + + EFI_SUCCESS: Driver initialized successfully + EFI_LOAD_ERROR: Failed to Initialize or has been loaded + EFI_OUT_OF_RESOURCES: Could not allocate needed resources + +--*/ +{ + EFI_STATUS Status; + EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *Crc32GuidedSep; + EFI_HANDLE Handle; + + // + // Call all constructors per produced protocols + // + Status = GuidedSectionExtractionProtocolConstructor ( + &Crc32GuidedSep, + (EFI_EXTRACT_GUIDED_SECTION) Crc32ExtractSection + ); + if (EFI_ERROR (Status)) { + if (Crc32GuidedSep != NULL) { + gBS->FreePool (Crc32GuidedSep); + } + + return Status; + } + // + // Pass in a NULL to install to a new handle + // + Handle = NULL; + Status = gBS->InstallProtocolInterface ( + &Handle, + &gEfiCrc32GuidedSectionExtractionProtocolGuid, + EFI_NATIVE_INTERFACE, + Crc32GuidedSep + ); + if (EFI_ERROR (Status)) { + gBS->FreePool (Crc32GuidedSep); + return EFI_LOAD_ERROR; + } + + return EFI_SUCCESS; +} + +STATIC +UINT32 +GetSectionLength ( + IN EFI_COMMON_SECTION_HEADER *CommonHeader + ) +/*++ + + Routine Description: + Get a length of section. + + Parameters: + CommonHeader - Pointer to the common section header. + + Return Value: + The length of the section, including the section header. + +--*/ +// TODO: function comment is missing 'Arguments:' +// TODO: function comment is missing 'Returns:' +// TODO: CommonHeader - add argument and description to function comment +{ + UINT32 Size; + + Size = *(UINT32 *) CommonHeader->Size & 0x00FFFFFF; + + return Size; +} + +STATIC +EFI_STATUS +Crc32ExtractSection ( + IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This, + IN VOID *InputSection, + OUT VOID **OutputBuffer, + OUT UINTN *OutputSize, + OUT UINT32 *AuthenticationStatus + ) +/*++ + + Routine Description: + This function reads and extracts contents of a section from an + encapsulating section. + + Parameters: + This - Indicates the calling context. + InputSection - Buffer containing the input GUIDed section + to be processed. + OutputBuffer - *OutputBuffer is allocated from boot services + pool memory and containing the new section + stream. The caller is responsible for freeing + this buffer. + AuthenticationStatus - Pointer to a caller allocated UINT32 that + indicates the authentication status of the + output buffer + + Return Value: + EFI_SUCCESS + EFI_OUT_OF_RESOURCES + EFI_INVALID_PARAMETER + EFI_NOT_AVAILABLE_YET + +--*/ +// TODO: function comment is missing 'Arguments:' +// TODO: function comment is missing 'Returns:' +// TODO: This - add argument and description to function comment +// TODO: InputSection - add argument and description to function comment +// TODO: OutputBuffer - add argument and description to function comment +// TODO: OutputSize - add argument and description to function comment +// TODO: AuthenticationStatus - add argument and description to function comment +// TODO: EFI_INVALID_PARAMETER - add return value to function comment +// TODO: EFI_INVALID_PARAMETER - add return value to function comment +// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment +// TODO: EFI_SUCCESS - add return value to function comment +{ + EFI_STATUS Status; + CRC32_SECTION_HEADER *Crc32SectionHeader; + EFI_GUID_DEFINED_SECTION *GuidedSectionHeader; + UINT8 *Image; + UINT32 Crc32Checksum; + VOID *DummyInterface; + + if (OutputBuffer == NULL) { + return EFI_INVALID_PARAMETER; + } + + *OutputBuffer = NULL; + + // + // Points to the section header + // + Crc32SectionHeader = (CRC32_SECTION_HEADER *) InputSection; + GuidedSectionHeader = (EFI_GUID_DEFINED_SECTION *) InputSection; + + // + // Check if the GUID is a CRC32 section GUID + // + if (!CompareGuid ( + &(GuidedSectionHeader->SectionDefinitionGuid), + &gEfiCrc32GuidedSectionExtractionProtocolGuid + )) { + return EFI_INVALID_PARAMETER; + } + + Image = (UINT8 *) InputSection + (UINT32) (GuidedSectionHeader->DataOffset); + *OutputSize = GetSectionLength ((EFI_COMMON_SECTION_HEADER *) InputSection) - (UINT32) GuidedSectionHeader->DataOffset; + + Status = gBS->AllocatePool (EfiBootServicesData, *OutputSize, OutputBuffer); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + // + // Implictly CRC32 GUIDed section should have STATUS_VALID bit set + // + ASSERT (GuidedSectionHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID); + *AuthenticationStatus = EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED; + + // + // Check whether there exists EFI_SECURITY_POLICY_PROTOCOL_GUID. + // + Status = gBS->LocateProtocol (&gEfiSecurityPolicyProtocolGuid, NULL, &DummyInterface); + if (!EFI_ERROR (Status)) { + *AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE | EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE; + } else { + // + // Calculate CRC32 Checksum of Image + // + gBS->CalculateCrc32 (Image, *OutputSize, &Crc32Checksum); + if (Crc32Checksum != Crc32SectionHeader->CRC32Checksum) { + *AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_TEST_FAILED | EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED; + } + } + + CopyMem (*OutputBuffer, Image, *OutputSize); + + return EFI_SUCCESS; +} diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.dxs b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.dxs new file mode 100644 index 0000000000..033ff94ac3 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.dxs @@ -0,0 +1,28 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Crc32SectionExtraction.dxs + +Abstract: + + Dependency expression file. + +--*/ + +#include +#include "DxeDepex.h" + +DEPENDENCY_START + EFI_RUNTIME_ARCH_PROTOCOL_GUID +DEPENDENCY_END + diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.h b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.h new file mode 100644 index 0000000000..8e32d6d7bb --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.h @@ -0,0 +1,65 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + Crc32SectionExtract.h + +Abstract: + + Header file for Crc32SectionExtract.c + Please refer to Tiano File Image Format specification + FV spec 0.3.6 + +--*/ + +#ifndef _CRC32_GUIDED_SECTION_EXTRACTION_H +#define _CRC32_GUIDED_SECTION_EXTRACTION_H + +typedef struct { + EFI_GUID_DEFINED_SECTION GuidedSectionHeader; + UINT32 CRC32Checksum; +} CRC32_SECTION_HEADER; + +// +// Function prototype declarations +// +STATIC +EFI_STATUS +Crc32ExtractSection ( + IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *This, + IN VOID *InputSection, + OUT VOID **OutputBuffer, + OUT UINTN *OutputSize, + OUT UINT32 *AuthenticationStatus + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + This - TODO: add argument description + InputSection - TODO: add argument description + OutputBuffer - TODO: add argument description + OutputSize - TODO: add argument description + AuthenticationStatus - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +#endif diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd new file mode 100644 index 0000000000..67ea3cd4b9 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.mbd @@ -0,0 +1,40 @@ + + + + + Crc32SectionExtract + 51C9F40C-5243-4473-B265-B3C8FFAFF9FA + 0 + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 2006-03-12 17:09 + 2006-03-19 15:19 + + + UefiBootServicesTableLib + UefiMemoryLib + UefiLib + UefiDriverEntryPoint + DxeReportStatusCodeLib + BaseDebugLibReportStatusCode + EdkDxePrintLib + BaseLib + + diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa new file mode 100644 index 0000000000..da82d561a0 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/Crc32SectionExtract.msa @@ -0,0 +1,61 @@ + + + + + Crc32SectionExtract + DXE_DRIVER + BS_DRIVER + 51C9F40C-5243-4473-B265-B3C8FFAFF9FA + 0 + Component description file for DiskIo module. + FIX ME! + Copyright (c) 2004-2006, Intel Corporation + + All rights reserved. This program and the accompanying materials + 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 + http://opensource.org/licenses/bsd-license.php + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + 0 + 2006-03-12 17:09 + 2006-03-19 15:19 + + + DebugLib + UefiDriverEntryPoint + UefiLib + BaseLib + BaseMemoryLib + UefiBootServicesTableLib + + + Crc32SectionExtract.c + Crc32SectionExtract.h + GuidedSection.c + GuidedSection.h + + + MdePkg + EdkModulePkg + + + SecurityPolicy + Crc32GuidedSectionExtraction + + + + InitializeCrc32GuidedSectionExtractionProtocol + + + diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.c b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.c new file mode 100644 index 0000000000..3c3f22f760 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.c @@ -0,0 +1,75 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSection.c + +Abstract: + + GUIDed section extraction protocol implementation. + This contains the common constructor of GUIDed section + extraction protocol. GUID specific implementation of each + GUIDed section extraction protocol can be found in other + files under the same directory. + + Please refer to the Tiano File Image Format Specification, + FV spec 0.3.6 + + Acronyms used Meaning + + +--*/ + + +#include "Common/FirmwareFileSystem.h" + +EFI_STATUS +GuidedSectionExtractionProtocolConstructor ( + OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSep, + IN EFI_EXTRACT_GUIDED_SECTION ExtractSection + ) +/*++ + +Routine Description: + + Constructor for the GUIDed section extraction protocol. Initializes + instance data. + +Arguments: + + This Instance to construct + +Returns: + + EFI_SUCCESS: Instance initialized. + +--*/ +// TODO: GuidedSep - add argument and description to function comment +// TODO: ExtractSection - add argument and description to function comment +// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment +{ + EFI_STATUS Status; + + *GuidedSep = NULL; + Status = gBS->AllocatePool ( + EfiBootServicesData, + sizeof (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL), + (VOID **) GuidedSep + ); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + (*GuidedSep)->ExtractSection = ExtractSection; + + return EFI_SUCCESS; +} diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.h b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.h new file mode 100644 index 0000000000..1399edf4f6 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/GuidedSection.h @@ -0,0 +1,53 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +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 +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + GuidedSection.h + +Abstract: + + Header file for GuidedSection.c + Please refer to Tiano File Image Format specification + FV spec 0.3.6 + +--*/ + +#ifndef _GUIDED_SECTION_EXTRACTION_H +#define _GUIDED_SECTION_EXTRACTION_H + +// +// Function prototype declarations +// +EFI_STATUS +GuidedSectionExtractionProtocolConstructor ( + OUT EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL **GuidedSep, + IN EFI_EXTRACT_GUIDED_SECTION ExtractSection + ) +/*++ + +Routine Description: + + TODO: Add function description + +Arguments: + + GuidedSep - TODO: add argument description + ExtractSection - TODO: add argument description + +Returns: + + TODO: add return values + +--*/ +; + +#endif diff --git a/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/build.xml b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/build.xml new file mode 100644 index 0000000000..7582701719 --- /dev/null +++ b/EdkModulePkg/Universal/FirmwareVolume/GuidedSectionExtraction/Crc32SectionExtract/Dxe/build.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3