/** @file\r
Definition of Pei Core Structures and Services\r
\r
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
#include <Ppi/MemoryDiscovered.h>\r
#include <Ppi/StatusCode.h>\r
#include <Ppi/Reset.h>\r
+#include <Ppi/Reset2.h>\r
#include <Ppi/FirmwareVolume.h>\r
#include <Ppi/FirmwareVolumeInfo.h>\r
+#include <Ppi/FirmwareVolumeInfo2.h>\r
#include <Ppi/Decompress.h>\r
#include <Ppi/GuidedSectionExtraction.h>\r
#include <Ppi/LoadFile.h>\r
#include <Ppi/Security2.h>\r
#include <Ppi/TemporaryRamSupport.h>\r
+#include <Ppi/TemporaryRamDone.h>\r
+#include <Ppi/SecHobData.h>\r
#include <Library/DebugLib.h>\r
#include <Library/PeiCoreEntryPoint.h>\r
#include <Library/BaseLib.h>\r
/// \r
INTN LastDispatchedNotify;\r
///\r
- /// Ppi database.\r
+ /// Ppi database has the PcdPeiCoreMaxPpiSupported number of entries.\r
///\r
- PEI_PPI_LIST_POINTERS PpiListPtrs[FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)];\r
+ PEI_PPI_LIST_POINTERS *PpiListPtrs;\r
} PEI_PPI_DATABASE;\r
\r
\r
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;\r
EFI_PEI_FIRMWARE_VOLUME_PPI *FvPpi;\r
EFI_PEI_FV_HANDLE FvHandle;\r
- UINT8 PeimState[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
- EFI_PEI_FILE_HANDLE FvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
+ //\r
+ // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+ //\r
+ UINT8 *PeimState;\r
+ //\r
+ // Ponter to the buffer with the PcdPeiCoreMaxPeimPerFv number of Entries.\r
+ //\r
+ EFI_PEI_FILE_HANDLE *FvFileHandles;\r
BOOLEAN ScanFv;\r
+ UINT32 AuthenticationStatus;\r
} PEI_CORE_FV_HANDLE;\r
\r
typedef struct {\r
EFI_GUID FvFormat;\r
VOID *FvInfo;\r
UINT32 FvInfoSize;\r
+ UINT32 AuthenticationStatus;\r
EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor;\r
} PEI_CORE_UNKNOW_FORMAT_FV_INFO;\r
\r
EFI_COMMON_SECTION_HEADER* Section[CACHE_SETION_MAX_NUMBER];\r
VOID* SectionData[CACHE_SETION_MAX_NUMBER];\r
UINTN SectionSize[CACHE_SETION_MAX_NUMBER];\r
+ UINT32 AuthenticationStatus[CACHE_SETION_MAX_NUMBER];\r
UINTN AllSectionCount;\r
UINTN SectionIndex;\r
} CACHE_SECTION_DATA;\r
\r
+#define HOLE_MAX_NUMBER 0x3\r
+typedef struct {\r
+ EFI_PHYSICAL_ADDRESS Base;\r
+ UINTN Size;\r
+ UINTN Offset;\r
+ BOOLEAN OffsetPositive;\r
+} HOLE_MEMORY_DATA;\r
+\r
///\r
/// Forward declaration for PEI_CORE_INSTANCE\r
///\r
UINTN FvCount;\r
\r
///\r
- /// The instance arrary for FVs which contains FFS and could be dispatched by PeiCore.\r
+ /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+ /// Each entry is for one FV which contains FFS and could be dispatched by PeiCore.\r
///\r
- PEI_CORE_FV_HANDLE Fv[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
- PEI_CORE_UNKNOW_FORMAT_FV_INFO UnknownFvInfo[FixedPcdGet32 (PcdPeiCoreMaxFvSupported)];\r
+ PEI_CORE_FV_HANDLE *Fv;\r
+\r
+ ///\r
+ /// Pointer to the buffer with the PcdPeiCoreMaxFvSupported number of entries.\r
+ /// Each entry is for one FV which could not be dispatched by PeiCore.\r
+ ///\r
+ PEI_CORE_UNKNOW_FORMAT_FV_INFO *UnknownFvInfo;\r
UINTN UnknownFvInfoCount;\r
\r
- EFI_PEI_FILE_HANDLE CurrentFvFileHandles[FixedPcdGet32 (PcdPeiCoreMaxPeimPerFv)];\r
+ ///\r
+ /// Pointer to the buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+ ///\r
+ EFI_PEI_FILE_HANDLE *CurrentFvFileHandles;\r
UINTN AprioriCount;\r
UINTN CurrentPeimFvCount;\r
UINTN CurrentPeimCount;\r
BOOLEAN HeapOffsetPositive;\r
UINTN StackOffset;\r
BOOLEAN StackOffsetPositive;\r
+ //\r
+ // Information for migrating memory pages allocated in pre-memory phase.\r
+ //\r
+ HOLE_MEMORY_DATA MemoryPages;\r
PEICORE_FUNCTION_POINTER ShadowedPeiCore;\r
CACHE_SECTION_DATA CacheSection;\r
//\r
// This field points to the shadowed image read function\r
//\r
PE_COFF_LOADER_READ_FILE ShadowedImageRead;\r
+\r
+ //\r
+ // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv + 1 number of entries.\r
+ //\r
+ EFI_PEI_FILE_HANDLE *FileHandles;\r
+ //\r
+ // Pointer to the temp buffer with the PcdPeiCoreMaxPeimPerFv number of entries.\r
+ //\r
+ EFI_GUID *FileGuid;\r
+\r
+ //\r
+ // Temp Memory Range is not covered by PeiTempMem and Stack.\r
+ // Those Memory Range will be migrated into physical memory.\r
+ //\r
+ HOLE_MEMORY_DATA HoleData[HOLE_MAX_NUMBER];\r
};\r
\r
///\r
\r
/**\r
\r
- Migrate the Hob list from the temporary memory stack to PEI installed memory.\r
+ Migrate the Hob list from the temporary memory to PEI installed memory.\r
\r
@param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
and location of temporary RAM, the stack location and the BFV location.\r
IN INTN NotifyStopIndex\r
);\r
\r
+/**\r
+ Process PpiList from SEC phase.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+ These PPI's will be installed and/or immediately signaled if they are notification type.\r
+\r
+**/\r
+VOID\r
+ProcessPpiListFromSec (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r
+ );\r
+\r
//\r
// Boot mode support functions\r
//\r
);\r
\r
/**\r
-\r
Provide a callout to the security verification service.\r
\r
-\r
@param PrivateData PeiCore's private data structure\r
@param VolumeHandle Handle of FV\r
@param FileHandle Handle of PEIM's ffs\r
+ @param AuthenticationStatus Authentication status\r
\r
@retval EFI_SUCCESS Image is OK\r
@retval EFI_SECURITY_VIOLATION Image is illegal\r
-\r
+ @retval EFI_NOT_FOUND If security PPI is not installed.\r
**/\r
EFI_STATUS\r
VerifyPeim (\r
IN PEI_CORE_INSTANCE *PrivateData,\r
IN EFI_PEI_FV_HANDLE VolumeHandle,\r
- IN EFI_PEI_FILE_HANDLE FileHandle\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ IN UINT32 AuthenticationStatus\r
);\r
\r
/**\r
IN UINT64 MemoryLength\r
);\r
\r
+/**\r
+ Install SEC HOB data to the HOB List.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param SecHobList Pointer to SEC HOB List.\r
+\r
+ @return EFI_SUCCESS Success to install SEC HOB data.\r
+ @retval EFI_OUT_OF_RESOURCES If there is no more memory to grow the Hoblist.\r
+\r
+**/\r
+EFI_STATUS\r
+PeiInstallSecHobData (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_HOB_GENERIC_HEADER *SecHobList\r
+ );\r
+\r
\r
//\r
// FFS Fw Volume support functions\r
OUT VOID **SectionData\r
);\r
\r
+/**\r
+ Searches for the next matching section within the specified file.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param SectionType The value of the section type to find.\r
+ @param SectionInstance Section instance to find.\r
+ @param FileHandle Handle of the firmware file to search.\r
+ @param SectionData A pointer to the discovered section, if successful.\r
+ @param AuthenticationStatus A pointer to the authentication status for this section.\r
+\r
+ @retval EFI_SUCCESS The section was found.\r
+ @retval EFI_NOT_FOUND The section was not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFindSectionData3 (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN UINTN SectionInstance,\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ OUT VOID **SectionData,\r
+ OUT UINT32 *AuthenticationStatus\r
+ );\r
+\r
/**\r
Search the firmware volumes by index\r
\r
);\r
\r
/**\r
+ Migrate memory pages allocated in pre-memory phase.\r
+ Copy memory pages at temporary heap top to permanent heap top.\r
\r
- Memory allocation service on permanent memory,\r
- not usable prior to the memory installation.\r
+ @param[in] Private Pointer to the private data passed in from caller.\r
+ @param[in] TemporaryRamMigrated Temporary memory has been migrated to permanent memory.\r
\r
+**/\r
+VOID\r
+MigrateMemoryPages (\r
+ IN PEI_CORE_INSTANCE *Private,\r
+ IN BOOLEAN TemporaryRamMigrated\r
+ );\r
\r
- @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
- @param MemoryType Type of memory to allocate.\r
- @param Pages Number of pages to allocate.\r
- @param Memory Pointer of memory allocated.\r
+/**\r
+ Migrate MemoryBaseAddress in memory allocation HOBs\r
+ from the temporary memory to PEI installed memory.\r
\r
- @retval EFI_SUCCESS The allocation was successful\r
- @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
- @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
- @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
- to allocate the number of pages.\r
+ @param[in] PrivateData Pointer to PeiCore's private data structure.\r
+\r
+**/\r
+VOID\r
+ConvertMemoryAllocationHobs (\r
+ IN PEI_CORE_INSTANCE *PrivateData\r
+ );\r
+\r
+/**\r
+ The purpose of the service is to publish an interface that allows\r
+ PEIMs to allocate memory ranges that are managed by the PEI Foundation.\r
+\r
+ Prior to InstallPeiMemory() being called, PEI will allocate pages from the heap.\r
+ After InstallPeiMemory() is called, PEI will allocate pages within the region\r
+ of memory provided by InstallPeiMemory() service in a best-effort fashion.\r
+ Location-specific allocations are not managed by the PEI foundation code.\r
+\r
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param MemoryType The type of memory to allocate.\r
+ @param Pages The number of contiguous 4 KB pages to allocate.\r
+ @param Memory Pointer to a physical address. On output, the address is set to the base\r
+ of the page range that was allocated.\r
+\r
+ @retval EFI_SUCCESS The memory range was successfully allocated.\r
+ @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.\r
+ @retval EFI_INVALID_PARAMETER Type is not equal to EfiLoaderCode, EfiLoaderData, EfiRuntimeServicesCode,\r
+ EfiRuntimeServicesData, EfiBootServicesCode, EfiBootServicesData,\r
+ EfiACPIReclaimMemory, EfiReservedMemoryType, or EfiACPIMemoryNVS.\r
\r
**/\r
EFI_STATUS\r
EFIAPI\r
PeiAllocatePages (\r
- IN CONST EFI_PEI_SERVICES **PeiServices,\r
- IN EFI_MEMORY_TYPE MemoryType,\r
- IN UINTN Pages,\r
- OUT EFI_PHYSICAL_ADDRESS *Memory\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN UINTN Pages,\r
+ OUT EFI_PHYSICAL_ADDRESS *Memory\r
+ );\r
+\r
+/**\r
+ Frees memory pages.\r
+\r
+ @param[in] PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+ @param[in] Memory The base physical address of the pages to be freed.\r
+ @param[in] Pages The number of contiguous 4 KB pages to free.\r
+\r
+ @retval EFI_SUCCESS The requested pages were freed.\r
+ @retval EFI_INVALID_PARAMETER Memory is not a page-aligned address or Pages is invalid.\r
+ @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r
+ AllocatePages().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFreePages (\r
+ IN CONST EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PHYSICAL_ADDRESS Memory,\r
+ IN UINTN Pages\r
);\r
\r
/**\r
IN CONST EFI_PEI_SERVICES **PeiServices\r
);\r
\r
+/**\r
+ Resets the entire platform.\r
+\r
+ @param[in] ResetType The type of reset to perform.\r
+ @param[in] ResetStatus The status code for the reset.\r
+ @param[in] DataSize The size, in bytes, of ResetData.\r
+ @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r
+ the data buffer starts with a Null-terminated string, optionally\r
+ followed by additional binary data. The string is a description\r
+ that the caller may use to further indicate the reason for the\r
+ system reset. ResetData is only valid if ResetStatus is something\r
+ other than EFI_SUCCESS unless the ResetType is EfiResetPlatformSpecific\r
+ where a minimum amount of ResetData is always required.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiResetSystem2 (\r
+ IN EFI_RESET_TYPE ResetType,\r
+ IN EFI_STATUS ResetStatus,\r
+ IN UINTN DataSize,\r
+ IN VOID *ResetData OPTIONAL\r
+ );\r
+\r
/**\r
\r
Initialize PeiCore Fv List.\r
OUT EFI_FV_FILE_INFO *FileInfo\r
);\r
\r
+/**\r
+ Returns information about a specific file.\r
+\r
+ @param FileHandle Handle of the file.\r
+ @param FileInfo Upon exit, points to the file's information.\r
+\r
+ @retval EFI_INVALID_PARAMETER If FileInfo is NULL.\r
+ @retval EFI_INVALID_PARAMETER If FileHandle does not represent a valid file.\r
+ @retval EFI_SUCCESS File information returned.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI \r
+PeiFfsGetFileInfo2 (\r
+ IN EFI_PEI_FILE_HANDLE FileHandle,\r
+ OUT EFI_FV_FILE_INFO2 *FileInfo\r
+ );\r
+\r
/**\r
Returns information about the specified volume.\r
\r
@param OldCoreData Pointer to Old PeiCore's private data.\r
If NULL, PeiCore is entered at first time, stack/heap in temporary memory.\r
If not NULL, PeiCore is entered at second time, stack/heap has been moved\r
- to permenent memory.\r
+ to permanent memory.\r
\r
**/\r
VOID\r
);\r
\r
/**\r
- Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+ Get Fv image from the FV type file, then install FV INFO(2) ppi, Build FV hob.\r
\r
+ @param PrivateData PeiCore's private data structure\r
@param ParentFvCoreHandle Pointer of EFI_CORE_FV_HANDLE to parent Fv image that contain this Fv image.\r
@param ParentFvFileHandle File handle of a Fv type file that contain this Fv image.\r
\r
@retval EFI_NOT_FOUND FV image can't be found.\r
@retval EFI_SUCCESS Successfully to process it.\r
@retval EFI_OUT_OF_RESOURCES Can not allocate page when aligning FV image\r
+ @retval EFI_SECURITY_VIOLATION Image is illegal\r
@retval Others Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\r
\r
**/\r
EFI_STATUS\r
ProcessFvFile (\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
IN PEI_CORE_FV_HANDLE *ParentFvCoreHandle,\r
IN EFI_PEI_FILE_HANDLE ParentFvFileHandle\r
);\r
/**\r
After PeiCore image is shadowed into permanent memory, all build-in FvPpi should\r
be re-installed with the instance in permanent memory and all cached FvPpi pointers in \r
- PrivateData->Fv[] array should be fixed up to be pointed to the one in permenant\r
+ PrivateData->Fv[] array should be fixed up to be pointed to the one in permanent\r
memory.\r
\r
@param PrivateData Pointer to PEI_CORE_INSTANCE.\r