+/*++\r
+\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+Module Name:\r
+\r
+ PeiMain.h\r
+\r
+Abstract:\r
+\r
+ Definition of Pei Core Structures and Services\r
+\r
+Revision History\r
+\r
+--*/\r
+\r
+#ifndef _PEI_MAIN_H_\r
+#define _PEI_MAIN_H_\r
+\r
+//\r
+// Include common header file for this module.\r
+//\r
+#include "CommonHeader.h"\r
+\r
+extern EFI_GUID gEfiPeiCorePrivateGuid;\r
+\r
+//\r
+// Pei Core private data structures\r
+//\r
+typedef union {\r
+ EFI_PEI_PPI_DESCRIPTOR *Ppi;\r
+ EFI_PEI_NOTIFY_DESCRIPTOR *Notify;\r
+ VOID *Raw;\r
+} PEI_PPI_LIST_POINTERS;\r
+\r
+#define PEI_STACK_SIZE 0x20000\r
+\r
+#define MAX_PPI_DESCRIPTORS 64\r
+\r
+typedef struct {\r
+ INTN PpiListEnd;\r
+ INTN NotifyListEnd;\r
+ INTN DispatchListEnd;\r
+ INTN LastDispatchedInstall;\r
+ INTN LastDispatchedNotify;\r
+ PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];\r
+} PEI_PPI_DATABASE;\r
+\r
+typedef struct {\r
+ UINT8 CurrentPeim;\r
+ UINT8 CurrentFv;\r
+ UINT32 DispatchedPeimBitMap;\r
+ UINT32 PreviousPeimBitMap;\r
+ EFI_FFS_FILE_HEADER *CurrentPeimAddress;\r
+ EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress;\r
+ EFI_FIRMWARE_VOLUME_HEADER *BootFvAddress;\r
+ EFI_PEI_FIND_FV_PPI *FindFv;\r
+} PEI_CORE_DISPATCH_DATA;\r
+\r
+\r
+//\r
+// Pei Core private data structure instance\r
+//\r
+\r
+#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')\r
+\r
+typedef struct{\r
+ UINTN Signature;\r
+ EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow\r
+ PEI_PPI_DATABASE PpiData;\r
+ PEI_CORE_DISPATCH_DATA DispatchData;\r
+ EFI_PEI_HOB_POINTERS HobList;\r
+ BOOLEAN SwitchStackSignal;\r
+ BOOLEAN PeiMemoryInstalled;\r
+ EFI_PHYSICAL_ADDRESS StackBase;\r
+ UINT64 StackSize;\r
+ VOID *BottomOfCarHeap;\r
+ VOID *TopOfCarHeap;\r
+ VOID *CpuIo;\r
+ EFI_PEI_SECURITY_PPI *PrivateSecurityPpi;\r
+ EFI_PEI_SERVICES ServiceTableShadow;\r
+ UINTN SizeOfCacheAsRam;\r
+ VOID *MaxTopOfCarHeap;\r
+} PEI_CORE_INSTANCE;\r
+\r
+//\r
+// Pei Core Instance Data Macros\r
+//\r
+\r
+#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \\r
+ CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)\r
+\r
+//\r
+// BUGBUG: Where does this go really?\r
+//\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *PEI_CORE_ENTRY_POINT)(\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r
+ IN PEI_CORE_INSTANCE *OldCoreData\r
+ );\r
+\r
+//\r
+// Union of temporarily used function pointers (to save stack space)\r
+//\r
+typedef union {\r
+ PEI_CORE_ENTRY_POINT PeiCore;\r
+ EFI_PEIM_ENTRY_POINT PeimEntry;\r
+ EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;\r
+ EFI_DXE_IPL_PPI *DxeIpl;\r
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r
+ VOID *Raw;\r
+} PEI_CORE_TEMP_POINTERS;\r
+\r
+\r
+//\r
+// PeiCore function\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeiCore (\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r
+ IN VOID *Data\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ The entry routine to Pei Core, invoked by PeiMain during transition\r
+ from SEC to PEI. After switching stack in the PEI core, it will restart\r
+ with the old core data.\r
+\r
+Arguments:\r
+\r
+ PeiStartupDescriptor - Information and services provided by SEC phase.\r
+ OldCoreData - Pointer to old core data that is used to initialize the\r
+ core's data areas.\r
+\r
+Returns:\r
+\r
+ This function never returns\r
+ EFI_NOT_FOUND - Never reach\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Dispatcher support functions\r
+//\r
+\r
+EFI_STATUS\r
+PeimDispatchReadiness (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN VOID *DependencyExpression,\r
+ IN OUT BOOLEAN *Runnable\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This is the POSTFIX version of the dependency evaluator. When a\r
+ PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on\r
+ the evaluation stack. When that entry is poped from the evaluation\r
+ stack, the PPI is checked if it is installed. This method allows\r
+ some time savings as not all PPIs must be checked for certain\r
+ operation types (AND, OR).\r
+\r
+Arguments:\r
+\r
+ PeiServices - Calling context.\r
+\r
+ DependencyExpression - Pointer to a dependency expression. The Grammar adheres to\r
+ the BNF described above and is stored in postfix notation.\r
+ Runnable - is True if the driver can be scheduled and False if the driver\r
+ cannot be scheduled. This is the value that the schedulers\r
+ should use for deciding the state of the driver.\r
+\r
+Returns:\r
+\r
+ Status = EFI_SUCCESS if it is a well-formed Grammar\r
+ EFI_INVALID_PARAMETER if the dependency expression overflows\r
+ the evaluation stack\r
+ EFI_INVALID_PARAMETER if the dependency expression underflows\r
+ the evaluation stack\r
+ EFI_INVALID_PARAMETER if the dependency expression is not a\r
+ well-formed Grammar.\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+PeiDispatcher (\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
+ IN PEI_CORE_DISPATCH_DATA *DispatchData\r
+ )\r
+\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Conduct PEIM dispatch.\r
+\r
+Arguments:\r
+\r
+ PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR\r
+ PrivateData - Pointer to the private data passed in from caller\r
+ DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Successfully dispatched PEIM.\r
+ EFI_NOT_FOUND - The dispatch failed.\r
+\r
+--*/\r
+;\r
+\r
+\r
+VOID\r
+InitializeDispatcherData (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN PEI_CORE_INSTANCE *OldCoreData,\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize the Dispatcher's data members\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ OldCoreData - Pointer to old core data (before switching stack).\r
+ NULL if being run in non-permament memory mode.\r
+ PeiStartupDescriptor - Information and services provided by SEC phase.\r
+\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+FindNextPeim (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
+ IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Given the input file pointer, search for the next matching file in the\r
+ FFS volume. The search starts from FileHeader inside\r
+ the Firmware Volume defined by FwVolHeader.\r
+\r
+Arguments:\r
+ PeiServices - Pointer to the PEI Core Services Table.\r
+\r
+ FwVolHeader - Pointer to the FV header of the volume to search.\r
+ This parameter must point to a valid FFS volume.\r
+\r
+ PeimFileHeader - Pointer to the current file from which to begin searching.\r
+ This pointer will be updated upon return to reflect the file found.\r
+\r
+Returns:\r
+ EFI_NOT_FOUND - No files matching the search criteria were found\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+Dispatched (\r
+ IN UINT8 CurrentPeim,\r
+ IN UINT32 DispatchedPeimBitMap\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine checks to see if a particular PEIM has been dispatched during\r
+ the PEI core dispatch.\r
+\r
+Arguments:\r
+ CurrentPeim - The PEIM/FV in the bit array to check.\r
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.\r
+\r
+Returns:\r
+ TRUE if PEIM already dispatched\r
+ FALSE if not\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+SetDispatched (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINT8 CurrentPeim,\r
+ OUT UINT32 *DispatchedPeimBitMap\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine sets a PEIM as having been dispatched once its entry\r
+ point has been invoked.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ CurrentPeim - The PEIM/FV in the bit array to check.\r
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.\r
+\r
+Returns:\r
+ None\r
+\r
+--*/\r
+;\r
+\r
+BOOLEAN\r
+DepexSatisfied (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN VOID *CurrentPeimAddress\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This routine parses the Dependency Expression, if available, and\r
+ decides if the module can be executed.\r
+\r
+Arguments:\r
+ PeiServices - The PEI Service Table\r
+ CurrentPeimAddress - Address of the PEIM Firmware File under investigation\r
+\r
+Returns:\r
+ TRUE - Can be dispatched\r
+ FALSE - Cannot be dispatched\r
+\r
+--*/\r
+;\r
+\r
+#if defined (MDE_CPU_IPF)\r
+ //\r
+ // In Ipf we should make special changes for the PHIT pointers to support\r
+ // recovery boot in cache mode.\r
+ //\r
+#define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)\r
+#define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFFULL\r
+VOID\r
+SwitchToCacheMode (\r
+ IN PEI_CORE_INSTANCE *CoreData\r
+)\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.\r
+\r
+Arguments:\r
+\r
+ CoreData - The PEI core Private Data\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+#else\r
+\r
+#define SWITCH_TO_CACHE_MODE(CoreData)\r
+\r
+#endif\r
+\r
+//\r
+// PPI support functions\r
+//\r
+VOID\r
+InitializePpiServices (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN PEI_CORE_INSTANCE *OldCoreData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize PPI services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ OldCoreData - Pointer to the PEI Core data.\r
+ NULL if being run in non-permament memory mode.\r
+\r
+Returns:\r
+ Nothing\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+ConvertPpiPointers (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,\r
+ IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Migrate the Hob list from the CAR stack to PEI installed memory.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ OldHandOffHob - The old handoff HOB list.\r
+ NewHandOffHob - The new handoff HOB list.\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiInstallPpi (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Install PPI services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+ PpiList - Pointer to a list of PEI PPI Descriptors.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - if all PPIs in PpiList are successfully installed.\r
+ EFI_INVALID_PARAMETER - if PpiList is NULL pointer\r
+ EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid\r
+ EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiReInstallPpi (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r
+ IN EFI_PEI_PPI_DESCRIPTOR *NewPpi\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Re-Install PPI services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+ OldPpi - Pointer to the old PEI PPI Descriptors.\r
+ NewPpi - Pointer to the new PEI PPI Descriptors.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - if the operation was successful\r
+ EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL\r
+ EFI_INVALID_PARAMETER - if NewPpi is not valid\r
+ EFI_NOT_FOUND - if the PPI was not in the database\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiLocatePpi (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_GUID *Guid,\r
+ IN UINTN Instance,\r
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r
+ IN OUT VOID **Ppi\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Locate a given named PPI.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+ Guid - Pointer to GUID of the PPI.\r
+ Instance - Instance Number to discover.\r
+ PpiDescriptor - Pointer to reference the found descriptor. If not NULL,\r
+ returns a pointer to the descriptor (includes flags, etc)\r
+ Ppi - Pointer to reference the found PPI\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if the PPI is in the database\r
+ EFI_NOT_FOUND if the PPI is not in the database\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiNotifyPpi (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Install a notification for a given PPI.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+ NotifyList - Pointer to list of Descriptors to notify upon.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if successful\r
+ EFI_OUT_OF_RESOURCES if no space in the database\r
+ EFI_INVALID_PARAMETER if not a good decriptor\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+ProcessNotifyList (\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Process the Notify List at dispatch level.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+\r
+Returns:\r
+\r
+--*/\r
+;\r
+\r
+VOID\r
+DispatchNotify (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINTN NotifyType,\r
+ IN INTN InstallStartIndex,\r
+ IN INTN InstallStopIndex,\r
+ IN INTN NotifyStartIndex,\r
+ IN INTN NotifyStopIndex\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Dispatch notifications.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Pointer to the PEI Service Table\r
+ NotifyType - Type of notify to fire.\r
+ InstallStartIndex - Install Beginning index.\r
+ InstallStopIndex - Install Ending index.\r
+ NotifyStartIndex - Notify Beginning index.\r
+ NotifyStopIndex - Notify Ending index.\r
+\r
+Returns: None\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Boot mode support functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetBootMode (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT EFI_BOOT_MODE *BootMode\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This service enables PEIMs to ascertain the present value of the boot mode.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ BootMode - A pointer to contain the value of the boot mode.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The boot mode was returned successfully.\r
+ EFI_INVALID_PARAMETER - BootMode is NULL.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiSetBootMode (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_BOOT_MODE BootMode\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ This service enables PEIMs to update the boot mode variable.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ BootMode - The value of the boot mode to set.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - The value was successfully updated\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Security support functions\r
+//\r
+VOID\r
+InitializeSecurityServices (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN PEI_CORE_INSTANCE *OldCoreData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize the security services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ OldCoreData - Pointer to the old core data.\r
+ NULL if being run in non-permament memory mode.\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+VerifyFv (\r
+ IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Provide a callout to the OEM FV verification service.\r
+\r
+Arguments:\r
+\r
+ CurrentFvAddress - Pointer to the FV under investigation.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+VerifyPeim (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_FFS_FILE_HEADER *CurrentPeimAddress\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Provide a callout to the security verification service.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ CurrentPeimAddress - Pointer to the Firmware File under investigation.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Image is OK\r
+ EFI_SECURITY_VIOLATION - Image is illegal\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiGetHobList (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN OUT VOID **HobList\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Gets the pointer to the HOB List.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ HobList - Pointer to the HOB List.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS - Get the pointer of HOB List\r
+ EFI_NOT_AVAILABLE_YET - the HOB List is not yet published\r
+ EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiCreateHob (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINT16 Type,\r
+ IN UINT16 Length,\r
+ IN OUT VOID **Hob\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Add a new HOB to the HOB List.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ Type - Type of the new HOB.\r
+ Length - Length of the new HOB to allocate.\r
+ Hob - Pointer to the new HOB.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS\r
+ - EFI_INVALID_PARAMETER if Hob is NULL\r
+ - EFI_NOT_AVAILABLE_YET if HobList is still not available.\r
+ - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiCoreBuildHobHandoffInfoTable (\r
+ IN EFI_BOOT_MODE BootMode,\r
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
+ IN UINT64 MemoryLength\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Builds a Handoff Information Table HOB\r
+\r
+Arguments:\r
+\r
+ BootMode - Current Bootmode\r
+ MemoryBegin - Start Memory Address.\r
+ MemoryLength - Length of Memory.\r
+\r
+Returns:\r
+\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+\r
+//\r
+// FFS Fw Volume support functions\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFindNextFile (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINT8 SearchType,\r
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,\r
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Given the input file pointer, search for the next matching file in the\r
+ FFS volume as defined by SearchType. The search starts from FileHeader inside\r
+ the Firmware Volume defined by FwVolHeader.\r
+\r
+Arguments:\r
+ PeiServices - Pointer to the PEI Core Services Table.\r
+\r
+ SearchType - Filter to find only files of this type.\r
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.\r
+\r
+ FwVolHeader - Pointer to the FV header of the volume to search.\r
+ This parameter must point to a valid FFS volume.\r
+\r
+ FileHeader - Pointer to the current file from which to begin searching.\r
+ This pointer will be updated upon return to reflect the file found.\r
+\r
+Returns:\r
+ EFI_NOT_FOUND - No files matching the search criteria were found\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFfsFindSectionData (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_SECTION_TYPE SectionType,\r
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,\r
+ IN OUT VOID **SectionData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+ Given the input file pointer, search for the next matching section in the\r
+ FFS volume.\r
+\r
+Arguments:\r
+ PeiServices - Pointer to the PEI Core Services Table.\r
+ SearchType - Filter to find only sections of this type.\r
+ FfsFileHeader - Pointer to the current file to search.\r
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.\r
+ - NULL if section not found\r
+\r
+Returns:\r
+ EFI_NOT_FOUND - No files matching the search criteria were found\r
+ EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiFvFindNextVolume (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINTN Instance,\r
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Return the BFV location\r
+\r
+ BugBug -- Move this to the location of this code to where the\r
+ other FV and FFS support code lives.\r
+ Also, update to use FindFV for instances #'s >= 1.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ Instance - Instance of FV to find\r
+ FwVolHeader - Pointer to contain the data to return\r
+\r
+Returns:\r
+ Pointer to the Firmware Volume instance requested\r
+\r
+ EFI_INVALID_PARAMETER - FwVolHeader is NULL\r
+\r
+ EFI_SUCCESS - Firmware volume instance successfully found.\r
+\r
+--*/\r
+;\r
+\r
+//\r
+// Memory support functions\r
+//\r
+VOID\r
+InitializeMemoryServices (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,\r
+ IN PEI_CORE_INSTANCE *OldCoreData\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Initialize the memory services.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ PeiStartupDescriptor - Information and services provided by SEC phase.\r
+ OldCoreData - Pointer to the PEI Core data.\r
+ NULL if being run in non-permament memory mode.\r
+\r
+Returns:\r
+\r
+ None\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiInstallPeiMemory (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,\r
+ IN UINT64 MemoryLength\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Install the permanent memory is now available.\r
+ Creates HOB (PHIT and Stack).\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ MemoryBegin - Start of memory address.\r
+ MemoryLength - Length of memory.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiAllocatePages (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_MEMORY_TYPE MemoryType,\r
+ IN UINTN Pages,\r
+ OUT EFI_PHYSICAL_ADDRESS *Memory\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Memory allocation service on permanent memory,\r
+ not usable prior to the memory installation.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+ Type - Type of allocation.\r
+ MemoryType - Type of memory to allocate.\r
+ Pages - Number of pages to allocate.\r
+ Memory - Pointer of memory allocated.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS The allocation was successful\r
+ EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.\r
+ EFI_NOT_AVAILABLE_YET Called with permanent memory not available\r
+ EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement\r
+ to allocate the number of pages.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiAllocatePool (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN UINTN Size,\r
+ OUT VOID **Buffer\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Memory allocation service on the CAR.\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+\r
+ Size - Amount of memory required\r
+\r
+ Buffer - Address of pointer to the buffer\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS The allocation was successful\r
+ EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement\r
+ to allocate the requested size.\r
+\r
+--*/\r
+;\r
+\r
+EFI_STATUS\r
+PeiLoadImage (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_FFS_FILE_HEADER *PeimFileHeader,\r
+ OUT VOID **EntryPoint\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Get entry point of a Peim file.\r
+\r
+Arguments:\r
+\r
+ PeiServices - Calling context.\r
+\r
+ PeimFileHeader - Peim file's header.\r
+\r
+ EntryPoint - Entry point of that Peim file.\r
+\r
+Returns:\r
+\r
+ Status code.\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiReportStatusCode (\r
+ IN EFI_PEI_SERVICES **PeiServices,\r
+ IN EFI_STATUS_CODE_TYPE CodeType,\r
+ IN EFI_STATUS_CODE_VALUE Value,\r
+ IN UINT32 Instance,\r
+ IN EFI_GUID *CallerId,\r
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Core version of the Status Code reporter\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+\r
+ CodeType - Type of Status Code.\r
+\r
+ Value - Value to output for Status Code.\r
+\r
+ Instance - Instance Number of this status code.\r
+\r
+ CallerId - ID of the caller of this status code.\r
+\r
+ Data - Optional data associated with this status code.\r
+\r
+Returns:\r
+\r
+ Status - EFI_SUCCESS if status code is successfully reported\r
+ - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed\r
+\r
+--*/\r
+;\r
+\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PeiResetSystem (\r
+ IN EFI_PEI_SERVICES **PeiServices\r
+ )\r
+/*++\r
+\r
+Routine Description:\r
+\r
+ Core version of the Reset System\r
+\r
+Arguments:\r
+\r
+ PeiServices - The PEI core services table.\r
+\r
+Returns:\r
+\r
+ Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.\r
+ - EFI_DEVICE_ERROR. Did not reset system.\r
+\r
+ Otherwise, resets the system.\r
+\r
+--*/\r
+;\r
+\r
+/**\r
+ Transfers control to a function starting with a new stack.\r
+\r
+ Transfers control to the function specified by EntryPoint using the new stack\r
+ specified by NewStack and passing in the parameters specified by Context1 and\r
+ Context2. Context1 and Context2 are optional and may be NULL. The function\r
+ EntryPoint must never return.\r
+\r
+ If EntryPoint is NULL, then ASSERT().\r
+ If NewStack is NULL, then ASSERT().\r
+\r
+ @param EntryPoint A pointer to function to call with the new stack.\r
+ @param Context1 A pointer to the context to pass into the EntryPoint\r
+ function.\r
+ @param Context2 A pointer to the context to pass into the EntryPoint\r
+ function.\r
+ @param NewStack A pointer to the new stack to use for the EntryPoint\r
+ function.\r
+ @param NewBsp A pointer to the new BSP for the EntryPoint on IPF. It's\r
+ Reserved on other architectures.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiSwitchStacks (\r
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
+ IN VOID *Context1, OPTIONAL\r
+ IN VOID *Context2, OPTIONAL\r
+ IN VOID *NewStack,\r
+ IN VOID *NewBsp\r
+ );\r
+\r
+#endif\r