From: lgao4 Date: Thu, 5 Mar 2009 05:05:57 +0000 (+0000) Subject: Update PeiCore to handle FvImage with PI FV extension header X-Git-Tag: edk2-stable201903~18445 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=97b2c9b51469851f2637526b138be5776ac029e8 Update PeiCore to handle FvImage with PI FV extension header Update Capsule PCDs PcdMaxSizePopulateCapsule and PcdMaxSizeNonPopulateCapsule to the flexible PCD type. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7805 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index db1fe4bc84..9caa890082 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -85,6 +85,12 @@ DiscoverPeimsAndOrderWithApriori ( Private->CurrentFvFileHandles[PeimCount] = FileHandle; } + + // + // Check whether the count of Peims exceeds the max support PEIMs in a FV image + // If more Peims are required in a FV image, PcdPeiCoreMaxPeimPerFv can be set to a larger value in DSC file. + // + ASSERT (PeimCount < FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)); Private->AprioriCount = 0; if (AprioriFileHandle != NULL) { @@ -377,7 +383,7 @@ PeiDispatcher ( // // For Fv type file, Produce new FV PPI and FV hob // - Status = ProcessFvFile (PeiServices, PeimFileHandle, &AuthenticationState); + Status = ProcessFvFile (PeiServices, VolumeHandle, PeimFileHandle, &AuthenticationState); } else { // // For PEIM driver, Load its entry point diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index cf1f8d55f2..d4162057e7 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -151,7 +151,6 @@ PeiFindFileEx ( EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; EFI_FFS_FILE_HEADER **FileHeader; EFI_FFS_FILE_HEADER *FfsFileHeader; - EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo; UINT32 FileLength; UINT32 FileOccupiedSize; UINT32 FileOffset; @@ -176,10 +175,6 @@ PeiFindFileEx ( // if ((*FileHeader == NULL) || (FileName != NULL)) { FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength); - if (FwVolHeader->ExtHeaderOffset != 0) { - FwVolExHeaderInfo = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(((UINT8 *)FwVolHeader) + FwVolHeader->ExtHeaderOffset); - FfsFileHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FwVolExHeaderInfo) + FwVolExHeaderInfo->ExtHeaderSize); - } } else { // // Length is 24 bits wide so mask upper 8 bits @@ -332,11 +327,16 @@ FirmwareVolmeInfoPpiNotifyCallback ( PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); if (PrivateData->FvCount >= FixedPcdGet32 (PcdPeiCoreMaxFvSupported)) { + DEBUG ((EFI_D_ERROR, "The number of Fv Images (%d) exceed the max supported FVs (%d) in Pei", PrivateData->FvCount + 1, FixedPcdGet32 (PcdPeiCoreMaxFvSupported))); + DEBUG ((EFI_D_ERROR, "PcdPeiCoreMaxFvSupported value need be reconfigurated in DSC")); ASSERT (FALSE); } Fv = (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *)Ppi; + // + // Only add FileSystem2 Fv to Fv list + // if (CompareGuid (&Fv->FvFormat, &gEfiFirmwareFileSystem2Guid)) { for (FvCount = 0; FvCount < PrivateData->FvCount; FvCount ++) { if ((UINTN)PrivateData->Fv[FvCount].FvHeader == (UINTN)Fv->FvInfo) { @@ -352,9 +352,6 @@ FirmwareVolmeInfoPpiNotifyCallback ( PrivateData->Fv[PrivateData->FvCount++].FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv->FvInfo; - // - // Only add FileSystem2 Fv to the All list - // PrivateData->AllFv[PrivateData->AllFvCount++] = (EFI_PEI_FV_HANDLE)Fv->FvInfo; DEBUG ((EFI_D_INFO, "The %dth FvImage start address is 0x%11p and size is 0x%08x\n", (UINT32)PrivateData->AllFvCount, (VOID *) Fv->FvInfo, Fv->FvInfoSize)); @@ -387,7 +384,7 @@ FirmwareVolmeInfoPpiNotifyCallback ( // // Process FvFile to install FvInfo ppi and build FvHob // - ProcessFvFile ((CONST EFI_PEI_SERVICES **) PeiServices, FileHandle, &AuthenticationStatus); + ProcessFvFile ((CONST EFI_PEI_SERVICES **) PeiServices, (EFI_PEI_FV_HANDLE)Fv->FvInfo, FileHandle, &AuthenticationStatus); } } while (FileHandle != NULL); } @@ -809,6 +806,7 @@ PeiFfsGetVolumeInfo ( if (FwVolHeader.Signature != EFI_FVH_SIGNATURE) { return EFI_INVALID_PARAMETER; } + ZeroMem (VolumeInfo, sizeof (EFI_FV_INFO)); VolumeInfo->FvAttributes = FwVolHeader.Attributes; VolumeInfo->FvStart = (VOID *) VolumeHandle; VolumeInfo->FvSize = FwVolHeader.FvLength; @@ -825,7 +823,8 @@ PeiFfsGetVolumeInfo ( Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. - @param FvFileHandle File handle of a Fv type file. + @param ParentFvHandle Fv handle to parent Fv image that contain this Fv image. + @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image. @param AuthenticationState Pointer to attestation authentication state of image. @@ -838,13 +837,15 @@ PeiFfsGetVolumeInfo ( EFI_STATUS ProcessFvFile ( IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_FILE_HANDLE FvFileHandle, + IN EFI_PEI_FV_HANDLE ParentFvHandle, + IN EFI_PEI_FILE_HANDLE ParentFvFileHandle, OUT UINT32 *AuthenticationState ) { EFI_STATUS Status; EFI_PEI_FV_HANDLE FvImageHandle; EFI_FV_INFO FvImageInfo; + EFI_FV_INFO ParentFvImageInfo; UINT32 FvAlignment; VOID *FvBuffer; EFI_PEI_HOB_POINTERS HobPtr; @@ -858,7 +859,7 @@ ProcessFvFile ( // HobPtr.Raw = GetHobList (); while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) { - if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) { + if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)ParentFvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) { // // this FILE has been dispatched, it will not be dispatched again. // @@ -873,14 +874,20 @@ ProcessFvFile ( Status = PeiFfsFindSectionData ( PeiServices, EFI_SECTION_FIRMWARE_VOLUME_IMAGE, - FvFileHandle, + ParentFvFileHandle, (VOID **)&FvImageHandle ); if (EFI_ERROR (Status)) { return Status; } - + + // + // Collect Parent FvImage Info. + // + Status = PeiFfsGetVolumeInfo (ParentFvHandle, &ParentFvImageInfo); + ASSERT_EFI_ERROR (Status); + // // Collect FvImage Info. // @@ -907,7 +914,8 @@ ProcessFvFile ( // // Update FvImageInfo after reload FvImage to new aligned memory // - PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo); + Status = PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo); + ASSERT_EFI_ERROR (Status); } // @@ -917,8 +925,8 @@ ProcessFvFile ( NULL, FvImageInfo.FvStart, (UINT32) FvImageInfo.FvSize, - &(FvImageInfo.FvName), - &(((EFI_FFS_FILE_HEADER*)FvFileHandle)->Name) + &ParentFvImageInfo.FvName, + &(((EFI_FFS_FILE_HEADER*)ParentFvFileHandle)->Name) ); // @@ -936,8 +944,8 @@ ProcessFvFile ( BuildFv2Hob ( (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart, FvImageInfo.FvSize, - &FvImageInfo.FvName, - &(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name) + &ParentFvImageInfo.FvName, + &(((EFI_FFS_FILE_HEADER *)ParentFvFileHandle)->Name) ); return EFI_SUCCESS; diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index e629b2368a..453f230233 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -1006,7 +1006,8 @@ InitializeImageServices ( Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob. @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. - @param FvFileHandle File handle of a Fv type file. + @param ParentFvHandle Fv handle to parent Fv image that contain this Fv file. + @param ParentFvFileHandle File handle of a Fv type file that contain this Fv image. @param AuthenticationState Pointer to attestation authentication state of image. If return 0, means pass security checking. @@ -1017,7 +1018,8 @@ InitializeImageServices ( EFI_STATUS ProcessFvFile ( IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_FILE_HANDLE FvFileHandle, + IN EFI_PEI_FV_HANDLE ParentFvHandle, + IN EFI_PEI_FILE_HANDLE ParentFvFileHandle, OUT UINT32 *AuthenticationState ); diff --git a/MdeModulePkg/Core/Pei/PeiMain.inf b/MdeModulePkg/Core/Pei/PeiMain.inf index 52b0bf21ca..7a95ce0ae3 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.inf +++ b/MdeModulePkg/Core/Pei/PeiMain.inf @@ -88,7 +88,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeimPerFv ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPpiSupported ## CONSUMES - gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeimDispatch ## CONSUMES + gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeimDispatch ## CONSUMES gEfiMdePkgTokenSpaceGuid.PcdStatusCodeValuePeiCoreEntry ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxPeiStackSize ## CONSUMES diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 6feab63412..ffed6cf2dd 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -151,6 +151,7 @@ PeiInstallPpi ( // // Since PpiData is used for NotifyList and PpiList, max resource // is reached if the Install reaches the NotifyList + // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement. // if (Index == PrivateData->PpiData.NotifyListEnd + 1) { return EFI_OUT_OF_RESOURCES; @@ -392,6 +393,7 @@ PeiNotifyPpi ( // // Since PpiData is used for NotifyList and InstallList, max resource // is reached if the Install reaches the PpiList + // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement. // if (Index == PrivateData->PpiData.PpiListEnd - 1) { return EFI_OUT_OF_RESOURCES; diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9aa71b0b6e..18dc6cf381 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -30,17 +30,20 @@ [LibraryClasses.common] ## @libraryclass IpIo layer upon EFI IP4 Protocol. + # Ihis library is only intended to be used by UEFI network stack modules. IpIoLib|Include/Library/IpIoLib.h ## @libraryclass Basic function for UEFI network stack. + # Ihis library is only intended to be used by UEFI network stack modules. NetLib|Include/Library/NetLib.h - - ## @libraryclass Defines a set of methods to reset whole system. - ResetSystemLib|Include/Library/ResetSystemLib.h ## @libraryclass The helper routines to access UDP service. + # Ihis library is only intended to be used by UEFI network stack modules. UdpIoLib|Include/Library/UdpIoLib.h + ## @libraryclass Defines a set of methods to reset whole system. + ResetSystemLib|Include/Library/ResetSystemLib.h + ## @libraryclass Defines a set of methods related do S3 mode. S3Lib|Include/Library/S3Lib.h @@ -48,6 +51,7 @@ RecoveryLib|Include/Library/RecoveryLib.h ## @libraryclass Basic platform driver override functions. + # Ihis library is only intended to be used by Platform Driver Override Dxe Driver and Application. PlatformDriverOverrideLib|Include/Library/PlatformDriverOverrideLib.h ## @libraryclass Provides HII related functions. @@ -91,9 +95,11 @@ gPcdDataBaseHobGuid = { 0xEA296D92, 0x0B69, 0x423C, { 0x8C, 0x28, 0x33, 0xB4, 0xE0, 0xA9, 0x12, 0x68 }} ## Guid for EDKII implementation GUIDed opcodes + # Include/Guid/MdeModuleHii.h gEfiIfrTianoGuid = { 0xf0b1735, 0x87a0, 0x4193, {0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }} ## Guid for Framework vfr GUIDed opcodes. + # Include/Guid/MdeModuleHii.h gEfiIfrFrameworkGuid = { 0x31ca5d1a, 0xd511, 0x4931, { 0xb7, 0x82, 0xae, 0x6b, 0x2b, 0x17, 0x8c, 0xd7 }} ## Guid to specify the System Non Volatile FV @@ -292,15 +298,7 @@ # to store PCD value. # gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0|UINT32|0x00010010 - - ## Indicate the max size of the populated capsule image that the platform can support. - # The default max size is 100MB (0x6400000) for more than one large capsule images. - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x6400000|UINT32|0x0001001e - - ## Indicate the max size of the non-populated capsule image that the platform can support. - # The default max size is 10MB (0xa00000) for the casule image without populated flag setting. - gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0xa00000|UINT32|0x0001001f - + ## Maximum number of FV is supported by PeiCore's dispatching. gEfiMdeModulePkgTokenSpaceGuid.PcdPeiCoreMaxFvSupported|6|UINT32|0x00010030 @@ -343,6 +341,14 @@ ## gEfiMdeModulePkgTokenSpaceGuid.PcdHelloWorldPrintTimes|1|UINT32|0x40000005 + ## Indicate the max size of the populated capsule image that the platform can support. + # The default max size is 100MB (0x6400000) for more than one large capsule images. + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule|0x6400000|UINT32|0x0001001e + + ## Indicate the max size of the non-populated capsule image that the platform can support. + # The default max size is 10MB (0xa00000) for the casule image without populated flag setting. + gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|0xa00000|UINT32|0x0001001f + [PcdsFixedAtBuild,PcdsPatchableInModule] ## Maximun number of performance log entries during PEI phase. gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries|40|UINT8|0x0001002f diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf index 8aadd1af85..2ab29ba339 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf @@ -55,7 +55,7 @@ [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset -[FixedPcd] +[Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizePopulateCapsule || PcdSupportUpdateCapsuleReset ## Populate Image requires reset support. diff --git a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c index f0e82ae602..2bf456cd97 100644 --- a/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c +++ b/MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleService.c @@ -247,9 +247,9 @@ QueryCapsuleCapabilities ( // The support max capsule image size // if ((CapsuleHeader->Flags & CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE) != 0) { - *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizePopulateCapsule); + *MaxiumCapsuleSize = PcdGet32(PcdMaxSizePopulateCapsule); } else { - *MaxiumCapsuleSize = FixedPcdGet32(PcdMaxSizeNonPopulateCapsule); + *MaxiumCapsuleSize = PcdGet32(PcdMaxSizeNonPopulateCapsule); } return EFI_SUCCESS;