diff --git a/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.c b/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.c new file mode 100644 index 0000000000..00e971f3e1 --- /dev/null +++ b/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.c @@ -0,0 +1,110 @@ +/** @file + Module produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV. + + UEFI PI Spec supersedes Intel's Framework Specs. + EFI_FIRMWARE_VOLUME_INFO_PPI defined in PI spec is required by PI PEI core to dispatch PEIMs or find DXE core + in the FV. + This module produces produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV. + This module is used on platform when both of these two conditions are true: + 1) Framework platform module produces FV HOB but does not build EFI_FIRMWARE_VOLUME_INFO_PPI. + 2) The platform has PI PEI core that cosumes EFI_FIRMWARE_VOLUME_INFO_PPI to dispatch PEIMs or DXE core + in FVs other than Boot Fimware Volume. + +Copyright (c) 2008 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: + +**/ + +#include +#include +#include +#include +#include +#include +#include + + +/** + Check if there is a matching EFI_PEI_FIRMWARE_VOLUME_INFO_PPI for the FV described by FvHob. + + This function located all existing instance of EFI_PEI_FIRMWARE_VOLUME_INFO_PPI in the platform. + Then it compare the base address of the FVs found with that of FvHob. If a matching base address is + found, the function return TRUE. Otherwise, FALSE is returned. + + If a matching base address of FV is found but the length of FV does not match, then ASSERT (). + + @param FvHob The FV Hob. + + @retval TRUE A instance of EFI_PEI_FIRMWARE_VOLUME_INFO_PPI is already installed. + +**/ +BOOLEAN +FvInfoPpiInstalled ( + EFI_HOB_FIRMWARE_VOLUME * FvHob + ) +{ + EFI_STATUS Status; + UINTN Idx; + EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *FvInfoPpi; + + for (Idx = 0; ; Idx++) { + Status = PeiServicesLocatePpi ( + &gEfiPeiFirmwareVolumeInfoPpiGuid, + Idx, + NULL, + (VOID **) &FvInfoPpi + ); + if (!EFI_ERROR (Status)) { + if (FvHob->BaseAddress == (EFI_PHYSICAL_ADDRESS) (UINTN) FvInfoPpi->FvInfo) { + ASSERT (FvHob->Length == (UINT64) FvInfoPpi->FvInfoSize); + return TRUE; + } + } else { + break; + } + } + + return FALSE; +} + +/** + PEIM's standard entry point. + + @param FfsHeader Image's header + @param PeiServices Pointer of EFI_PEI_SERVICES + @return EFI_SUCESS This entry point always return successfully. + +**/ +EFI_STATUS +EFIAPI +FvHobtoFvInfoThunkEntry ( + IN EFI_PEI_FILE_HANDLE FfsHeader, + IN CONST EFI_PEI_SERVICES **PeiServices + ) +{ + EFI_PEI_HOB_POINTERS HobPointer; + + for (HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_FV, GetHobList ()); + HobPointer.Raw != NULL; + HobPointer.Raw = GetNextHob (EFI_HOB_TYPE_FV, GET_NEXT_HOB (HobPointer))) { + if (!FvInfoPpiInstalled (HobPointer.FirmwareVolume)) { + PiLibInstallFvInfoPpi ( + &(((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) HobPointer.FirmwareVolume->BaseAddress)->FileSystemGuid), + (VOID *) (UINTN) HobPointer.FirmwareVolume->BaseAddress, + (UINT32) HobPointer.FirmwareVolume->Length, + NULL, + NULL + ); + } + } + + return EFI_SUCCESS; +} + diff --git a/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.inf b/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.inf new file mode 100644 index 0000000000..2ab47abd29 --- /dev/null +++ b/EdkCompatibilityPkg/Compatibility/FvHobToFvInfoThunk/FvHobToFvInfoThunk.inf @@ -0,0 +1,62 @@ +#/** @file +# Module produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV. +# +# UEFI PI Spec supersedes Intel's Framework Specs. +# EFI_FIRMWARE_VOLUME_INFO_PPI defined in PI spec is required by PI PEI core to dispatch PEIMs or find DXE cores +# in the FV. +# This module produces produces EFI_FIRMWARE_VOLUME_INFO_PPI based on each FV HOB if no such PPI exist for the FV. +# This module is used on platform when both of these two conditions are true: +# 1) Framework platform module produces FV HOB but does not build EFI_FIRMWARE_VOLUME_INFO_PPI. +# 2) The platform has PI PEI core that cosumes EFI_FIRMWARE_VOLUME_INFO_PPI to dispatch PEIMs in FVs other +# than Boot Fimware Volume. +# +# +# Copyright (c) 2007, 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. +# +# +#**/ + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = FvHobToFvInfoThunk + FILE_GUID = 9E00A9F6-B88E-4ab5-A825-15970E12731A + MODULE_TYPE = PEIM + VERSION_STRING = 1.0 + EDK_RELEASE_VERSION = 0x00020000 + EFI_SPECIFICATION_VERSION = 0x00020000 + + ENTRY_POINT = FvHobtoFvInfoThunkEntry + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources.common] + FvHobtoFvInfoThunk.c + +[Packages] + MdePkg/MdePkg.dec + IntelFrameworkPkg/IntelFrameworkPkg.dec + +[LibraryClasses] + PeimEntryPoint + PeiServicesLib + PeiServicesTablePointerLib + DebugLib + HobLib + PeiPiLib + +[Ppis] + gEfiPeiFirmwareVolumeInfoPpiGuid + +[Depex] + gEfiPeiMemoryDiscoveredPpiGuid