X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FCore%2FPei%2FPeiMain.h;h=8c7cfe4cacdf842b310cff24a2850fc7537764a9;hb=fe7819402c285c2d006b79eb66981673fedf3d04;hp=aa23cc57edae9caf6096233f78cde112c7f4682f;hpb=341a658fca6ff05deb7a9db4fbc7cc491dff473f;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index aa23cc57ed..8c7cfe4cac 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -1,8 +1,8 @@ /** @file Definition of Pei Core Structures and Services -Copyright (c) 2006 - 2010, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2014, 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 @@ -22,11 +22,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -38,12 +40,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include #include #include #include #include #include +#include #include /// @@ -87,9 +89,9 @@ typedef struct { /// INTN LastDispatchedNotify; /// - /// Ppi database. + /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries. /// - PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)]; + PEI_PPI_LIST_POINTERS *PpiListPtrs; } PEI_PPI_DATABASE; @@ -107,15 +109,23 @@ typedef struct { EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi; EFI_PEI_FV_HANDLE FvHandle; - UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)]; - EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)]; + // + // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries. + // + UINT8 *PeimState; + // + // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries. + // + EFI_PEI_FILE_HANDLE *FvFileHandles; BOOLEAN ScanFv; + UINT32 AuthenticationStatus; } PEI_CORE_FV_HANDLE; typedef struct { EFI_GUID FvFormat; VOID *FvInfo; UINT32 FvInfoSize; + UINT32 AuthenticationStatus; EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor; } PEI_CORE_UNKNOW_FORMAT_FV_INFO; @@ -124,23 +134,58 @@ typedef struct { EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER]; VOID* SectionData[CACHE_SETION_MAX_NUMBER]; UINTN SectionSize[CACHE_SETION_MAX_NUMBER]; + UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER]; UINTN AllSectionCount; UINTN SectionIndex; } CACHE_SECTION_DATA; +#define HOLE_MAX_NUMBER 0x3 +typedef struct { + EFI_PHYSICAL_ADDRESS Base; + UINTN Size; + UINTN Offset; + BOOLEAN OffsetPositive; +} HOLE_MEMORY_DATA; + +/// +/// Forward declaration for PEI_CORE_INSTANCE +/// +typedef struct _PEI_CORE_INSTANCE PEI_CORE_INSTANCE; + + +/** + Function Pointer type for PeiCore function. + @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size + and location of temporary RAM, the stack location and the BFV location. + @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core. + An empty PPI list consists of a single descriptor with the end-tag + EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization + phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such + that both the PEI Foundation and any modules can leverage the associated service + calls and/or code in these early PPIs + @param OldCoreData Pointer to old core data that is used to initialize the + core's data areas. +**/ +typedef +EFI_STATUS +(EFIAPI *PEICORE_FUNCTION_POINTER)( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, + IN PEI_CORE_INSTANCE *OldCoreData + ); #define PEI_CORE_HANDLE_SIGNATURE SIGNATURE_32('P','e','i','C') /// /// Pei Core private data structure instance /// -typedef struct{ +struct _PEI_CORE_INSTANCE { UINTN Signature; /// /// Point to ServiceTableShadow /// - EFI_PEI_SERVICES *PS; + EFI_PEI_SERVICES *Ps; PEI_PPI_DATABASE PpiData; /// @@ -149,13 +194,22 @@ typedef struct{ UINTN FvCount; /// - /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore. + /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries. + /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore. + /// + PEI_CORE_FV_HANDLE *Fv; + /// - PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)]; - PEI_CORE_UNKNOW_FORMAT_FV_INFO UnknownFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)]; + /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries. + /// Each entry is for one FV which could not be dispatched by PeiCore. + /// + PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo; UINTN UnknownFvInfoCount; - EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)]; + /// + /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries. + /// + EFI_PEI_FILE_HANDLE *CurrentFvFileHandles; UINTN AprioriCount; UINTN CurrentPeimFvCount; UINTN CurrentPeimCount; @@ -166,8 +220,6 @@ typedef struct{ EFI_PEI_HOB_POINTERS HobList; BOOLEAN SwitchStackSignal; BOOLEAN PeiMemoryInstalled; - EFI_PHYSICAL_ADDRESS StackBase; - UINT64 StackSize; VOID *CpuIo; EFI_PEI_SECURITY2_PPI *PrivateSecurityPpi; EFI_PEI_SERVICES ServiceTableShadow; @@ -175,36 +227,50 @@ typedef struct{ EFI_PHYSICAL_ADDRESS PhysicalMemoryBegin; UINT64 PhysicalMemoryLength; EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop; - VOID* ShadowedPeiCore; + UINTN HeapOffset; + BOOLEAN HeapOffsetPositive; + UINTN StackOffset; + BOOLEAN StackOffsetPositive; + PEICORE_FUNCTION_POINTER ShadowedPeiCore; CACHE_SECTION_DATA CacheSection; -} PEI_CORE_INSTANCE; + // + // For Loading modules at fixed address feature to cache the top address below which the + // Runtime code, boot time code and PEI memory will be placed. Please note that the offset between this field + // and Ps should not be changed since maybe user could get this top address by using the offet to Ps. + // + EFI_PHYSICAL_ADDRESS LoadModuleAtFixAddressTopAddress; + // + // The field is define for Loading modules at fixed address feature to tracker the PEI code + // memory range usage. It is a bit mapped array in which every bit indicates the correspoding memory page + // available or not. + // + UINT64 *PeiCodeMemoryRangeUsageBitMap; + // + // This field points to the shadowed image read function + // + PE_COFF_LOADER_READ_FILE ShadowedImageRead; + + // + // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries. + // + EFI_PEI_FILE_HANDLE *FileHandles; + // + // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries. + // + EFI_GUID *FileGuid; + + // + // Temp Memory Range is not covered by PeiTempMem and Stack. + // Those Memory Range will be migrated into phisical memory. + // + HOLE_MEMORY_DATA HoleData[HOLE_MAX_NUMBER]; +}; /// /// Pei Core Instance Data Macros /// #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \ - CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE) - -/** - Function Pointer type for PeiCore function. - @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size - and location of temporary RAM, the stack location and the BFV location. - @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core. - An empty PPI list consists of a single descriptor with the end-tag - EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. As part of its initialization - phase, the PEI Foundation will add these SEC-hosted PPIs to its PPI database such - that both the PEI Foundation and any modules can leverage the associated service - calls and/or code in these early PPIs - @param OldCoreData Pointer to old core data that is used to initialize the - core's data areas. -**/ -typedef -EFI_STATUS -(EFIAPI *PEICORE_FUNCTION_POINTER)( - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, - IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, - IN PEI_CORE_INSTANCE *OldCoreData - ); + CR(a, PEI_CORE_INSTANCE, Ps, PEI_CORE_HANDLE_SIGNATURE) /// /// Union of temporarily used function pointers (to save stack space) @@ -357,21 +423,15 @@ InitializePpiServices ( Migrate the Hob list from the temporary memory stack to PEI installed memory. - @param PrivateData Pointer to PeiCore's private data structure. - @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range - will be fixup for PpiData and PpiDescriptor pointer. - @param OldCheckingTop Top of temporary memory range. All Ppi in this range - will be fixup for PpiData and PpiDescriptor. - @param Fixup The address difference between - the new Hob list and old Hob list. + @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size + and location of temporary RAM, the stack location and the BFV location. + @param PrivateData Pointer to PeiCore's private data structure. **/ VOID ConvertPpiPointers ( - IN PEI_CORE_INSTANCE *PrivateData, - IN UINTN OldCheckingBottom, - IN UINTN OldCheckingTop, - IN INTN Fixup + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN PEI_CORE_INSTANCE *PrivateData ); /** @@ -566,23 +626,23 @@ VerifyFv ( ); /** - Provide a callout to the security verification service. - @param PrivateData PeiCore's private data structure @param VolumeHandle Handle of FV @param FileHandle Handle of PEIM's ffs + @param AuthenticationStatus Authentication status @retval EFI_SUCCESS Image is OK @retval EFI_SECURITY_VIOLATION Image is illegal - + @retval EFI_NOT_FOUND If security PPI is not installed. **/ EFI_STATUS VerifyPeim ( IN PEI_CORE_INSTANCE *PrivateData, IN EFI_PEI_FV_HANDLE VolumeHandle, - IN EFI_PEI_FILE_HANDLE FileHandle + IN EFI_PEI_FILE_HANDLE FileHandle, + IN UINT32 AuthenticationStatus ); /** @@ -697,6 +757,31 @@ PeiFfsFindSectionData ( OUT VOID **SectionData ); +/** + Searches for the next matching section within the specified file. + + @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation. + @param SectionType The value of the section type to find. + @param SectionInstance Section instance to find. + @param FileHandle Handle of the firmware file to search. + @param SectionData A pointer to the discovered section, if successful. + @param AuthenticationStatus A pointer to the authentication status for this section. + + @retval EFI_SUCCESS The section was found. + @retval EFI_NOT_FOUND The section was not found. + +**/ +EFI_STATUS +EFIAPI +PeiFfsFindSectionData3 ( + IN CONST EFI_PEI_SERVICES **PeiServices, + IN EFI_SECTION_TYPE SectionType, + IN UINTN SectionInstance, + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT VOID **SectionData, + OUT UINT32 *AuthenticationStatus + ); + /** Search the firmware volumes by index @@ -950,6 +1035,24 @@ PeiFfsGetFileInfo ( OUT EFI_FV_FILE_INFO *FileInfo ); +/** + Returns information about a specific file. + + @param FileHandle Handle of the file. + @param FileInfo Upon exit, points to the file's information. + + @retval EFI_INVALID_PARAMETER If FileInfo is NULL. + @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file. + @retval EFI_SUCCESS File information returned. + +**/ +EFI_STATUS +EFIAPI +PeiFfsGetFileInfo2 ( + IN EFI_PEI_FILE_HANDLE FileHandle, + OUT EFI_FV_FILE_INFO2 *FileInfo + ); + /** Returns information about the specified volume. @@ -1044,19 +1147,22 @@ SecurityPpiNotifyCallback ( ); /** - Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob. + Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob. + @param PrivateData PeiCore's private data structure @param ParentFvCoreHandle Pointer of EFI_CORE_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. @retval EFI_NOT_FOUND FV image can't be found. @retval EFI_SUCCESS Successfully to process it. @retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image + @retval EFI_SECURITY_VIOLATION Image is illegal @retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section **/ EFI_STATUS ProcessFvFile ( + IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle, IN EFI_PEI_FILE_HANDLE ParentFvFileHandle );