From b1f6a7c636fca9eda65a3045302de577c00e438d Mon Sep 17 00:00:00 2001 From: klu2 Date: Wed, 16 Jul 2008 09:40:06 +0000 Subject: [PATCH] Fix function comment to follows doxygen format. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5499 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Pei/BootMode/BootMode.c | 76 +- MdeModulePkg/Core/Pei/Dependency/dependency.c | 80 +- MdeModulePkg/Core/Pei/Dependency/dependency.h | 15 +- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 158 +-- MdeModulePkg/Core/Pei/FwVol/FwVol.c | 398 +++--- MdeModulePkg/Core/Pei/Hob/Hob.c | 101 +- MdeModulePkg/Core/Pei/Image/Image.c | 317 ++--- MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 146 +-- MdeModulePkg/Core/Pei/PeiMain.h | 1152 ++++++----------- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 53 +- MdeModulePkg/Core/Pei/Ppi/Ppi.c | 243 ++-- MdeModulePkg/Core/Pei/Reset/Reset.c | 37 +- MdeModulePkg/Core/Pei/Security/Security.c | 131 +- MdeModulePkg/Core/Pei/StatusCode/StatusCode.c | 50 +- 14 files changed, 1103 insertions(+), 1854 deletions(-) diff --git a/MdeModulePkg/Core/Pei/BootMode/BootMode.c b/MdeModulePkg/Core/Pei/BootMode/BootMode.c index afa3c89ebc..eac541d574 100644 --- a/MdeModulePkg/Core/Pei/BootMode/BootMode.c +++ b/MdeModulePkg/Core/Pei/BootMode/BootMode.c @@ -1,6 +1,11 @@ /** @file - -Copyright (c) 2006, Intel Corporation + This module provide function for ascertaining and updating the boot mode: + GetBootMode() + SetBootMode() + See PI Speicifcation volume I, chapter 9 Boot Paths for addtional information + on the boot mode. + +Copyright (c) 2006 - 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 @@ -9,47 +14,28 @@ 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: - - BootMode.c - -Abstract: +**/ - EFI PEI Core Boot Mode services +#include +/** + This service enables PEIMs to ascertain the present value of the boot mode. + @param PeiServices The PEI core services table. + @param BootMode A pointer to contain the value of the boot mode. -Revision History + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. **/ - -#include - EFI_STATUS EFIAPI PeiGetBootMode ( - IN CONST EFI_PEI_SERVICES **PeiServices, - OUT EFI_BOOT_MODE *BootMode + IN CONST EFI_PEI_SERVICES **PeiServices, + OUT EFI_BOOT_MODE *BootMode ) -/*++ - -Routine Description: - - This service enables PEIMs to ascertain the present value of the boot mode. - -Arguments: - - PeiServices - The PEI core services table. - BootMode - A pointer to contain the value of the boot mode. - -Returns: - - EFI_SUCCESS - The boot mode was returned successfully. - EFI_INVALID_PARAMETER - BootMode is NULL. - ---*/ { - PEI_CORE_INSTANCE *PrivateData; + PEI_CORE_INSTANCE *PrivateData; EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; @@ -68,28 +54,22 @@ Returns: } +/** + This service enables PEIMs to update the boot mode variable. + + + @param PeiServices - The PEI core services table. + @param BootMode - The value of the boot mode to set. + + @return EFI_SUCCESS - The value was successfully updated + +**/ EFI_STATUS EFIAPI PeiSetBootMode ( IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_BOOT_MODE BootMode ) -/*++ - -Routine Description: - - This service enables PEIMs to update the boot mode variable. - -Arguments: - - PeiServices - The PEI core services table. - BootMode - The value of the boot mode to set. - -Returns: - - EFI_SUCCESS - The value was successfully updated - ---*/ { PEI_CORE_INSTANCE *PrivateData; EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; diff --git a/MdeModulePkg/Core/Pei/Dependency/dependency.c b/MdeModulePkg/Core/Pei/Dependency/dependency.c index 54006675f4..8146c19ca3 100644 --- a/MdeModulePkg/Core/Pei/Dependency/dependency.c +++ b/MdeModulePkg/Core/Pei/Dependency/dependency.c @@ -1,4 +1,9 @@ /** @file + PEI Dispatcher Dependency Evaluator + + This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine + if a driver can be scheduled for execution. The criteria for + schedulability is that the dependency expression is satisfied. Copyright (c) 2006, Intel Corporation All rights reserved. This program and the accompanying materials @@ -9,47 +14,30 @@ 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: - - dependency.c - -Abstract: - - PEI Dispatcher Dependency Evaluator - - This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine - if a driver can be scheduled for execution. The criteria for - schedulability is that the dependency expression is satisfied. - **/ #include #include "dependency.h" -STATIC -BOOLEAN -IsPpiInstalled ( - IN EFI_PEI_SERVICES **PeiServices, - IN EVAL_STACK_ENTRY *Stack - ) -/*++ - -Routine Description: +/** This routine determines if a PPI has been installed. The truth value of a GUID is determined by if the PPI has been published and can be queried from the PPI database. -Arguments: - PeiServices - The PEI core services table. - Stack - Reference to EVAL_STACK_ENTRY that contains PPI GUID to check -Returns: + @param PeiServices The PEI core services table. + @param Stack Reference to EVAL_STACK_ENTRY that contains PPI GUID to check - True if the PPI is already installed. - False if the PPI has yet to be installed. + @retval TRUE if the PPI is already installed. + @retval FALSE if the PPI has yet to be installed. ---*/ +**/ +BOOLEAN +IsPpiInstalled ( + IN EFI_PEI_SERVICES **PeiServices, + IN EVAL_STACK_ENTRY *Stack + ) { VOID *PeiInstance; EFI_STATUS Status; @@ -86,15 +74,7 @@ Returns: return TRUE; } - -BOOLEAN -PeimDispatchReadiness ( - IN EFI_PEI_SERVICES **PeiServices, - IN VOID *DependencyExpression - ) -/*++ - -Routine Description: +/** This is the POSTFIX version of the dependency evaluator. When a PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on @@ -103,22 +83,22 @@ Routine Description: some time savings as not all PPIs must be checked for certain operation types (AND, OR). -Arguments: - PeiServices - Calling context. + @param PeiServices Calling context. + @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to + the BNF described above and is stored in postfix notation. - DependencyExpression - Pointer to a dependency expression. The Grammar adheres to - the BNF described above and is stored in postfix notation. -Returns: + @retval TRUE if it is a well-formed Grammar + @retval FALSE if the dependency expression overflows the evaluation stack + if the dependency expression underflows the evaluation stack + if the dependency expression is not a well-formed Grammar. - Status = EFI_SUCCESS if it is a well-formed Grammar - EFI_INVALID_PARAMETER if the dependency expression overflows - the evaluation stack - EFI_INVALID_PARAMETER if the dependency expression underflows - the evaluation stack - EFI_INVALID_PARAMETER if the dependency expression is not a - well-formed Grammar. ---*/ +**/ +BOOLEAN +PeimDispatchReadiness ( + IN EFI_PEI_SERVICES **PeiServices, + IN VOID *DependencyExpression + ) { DEPENDENCY_EXPRESSION_OPERAND *Iterator; EVAL_STACK_ENTRY *StackPtr; diff --git a/MdeModulePkg/Core/Pei/Dependency/dependency.h b/MdeModulePkg/Core/Pei/Dependency/dependency.h index c1644a4a94..c15fd0d816 100644 --- a/MdeModulePkg/Core/Pei/Dependency/dependency.h +++ b/MdeModulePkg/Core/Pei/Dependency/dependency.h @@ -1,6 +1,8 @@ /** @file - -Copyright (c) 2006, Intel Corporation + This module contains data specific to dependency expressions + and local function prototypes. + +Copyright (c) 2006 - 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 @@ -9,15 +11,6 @@ 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: - - dependency.h - -Abstract: - - This module contains data specific to dependency expressions - and local function prototypes. - **/ #ifndef _PEI_DEPENDENCY_H_ diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index f5ce4dee61..481cf5d02e 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -1,5 +1,6 @@ /** @file - + EFI PEI Core dispatch services + Copyright (c) 2006, 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 @@ -9,23 +10,13 @@ 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: - - Dispatcher.c - -Abstract: - - EFI PEI Core dispatch services - -Revision History - **/ #include -// -//CAR is filled with this initial value during SEC phase -// +/// +/// CAR is filled with this initial value during SEC phase +/// #define INIT_CAR_VALUE 0x5AA55AA5 typedef struct { @@ -33,27 +24,21 @@ typedef struct { EFI_HANDLE Handle; } PEIM_FILE_HANDLE_EXTENDED_DATA; -VOID -DiscoverPeimsAndOrderWithApriori ( - IN PEI_CORE_INSTANCE *Private, - IN EFI_PEI_FV_HANDLE VolumeHandle - ) -/*++ - -Routine Description: +/** Discover all Peims and optional Apriori file in one FV. There is at most one Apriori file in one FV. -Arguments: - Private - Pointer to the private data passed in from caller - VolumeHandle - Fv handle. -Returns: + @param Private - Pointer to the private data passed in from caller + @param VolumeHandle - Fv handle. - NONE - ---*/ +**/ +VOID +DiscoverPeimsAndOrderWithApriori ( + IN PEI_CORE_INSTANCE *Private, + IN EFI_PEI_FV_HANDLE VolumeHandle + ) { EFI_STATUS Status; EFI_PEI_FV_HANDLE FileHandle; @@ -187,6 +172,13 @@ Returns: } +/** + Shadow PeiCore module from flash to installed memory. + + @param PeiServices Pointer to PeiService table + @param PrivateInMem PeiCore's private data structure + +**/ VOID* ShadowPeiCore( EFI_PEI_SERVICES **PeiServices, @@ -226,32 +218,23 @@ ShadowPeiCore( return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint); } -VOID -PeiDispatcher ( - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, - IN PEI_CORE_INSTANCE *Private - ) - -/*++ - -Routine Description: - +/** Conduct PEIM dispatch. -Arguments: - - SecCoreData - Points to a data structure containing information about the PEI core's operating + @param SecCoreData Points to a data structure containing information about the PEI core's operating environment, such as the size and location of temporary RAM, the stack location and the BFV location. - PrivateData - Pointer to the private data passed in from caller - DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data. - -Returns: + @param Private Pointer to the private data passed in from caller - EFI_SUCCESS - Successfully dispatched PEIM. - EFI_NOT_FOUND - The dispatch failed. + @retval EFI_SUCCESS - Successfully dispatched PEIM. + @retval EFI_NOT_FOUND - The dispatch failed. ---*/ +**/ +VOID +PeiDispatcher ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN PEI_CORE_INSTANCE *Private + ) { EFI_STATUS Status; UINT32 Index1; @@ -674,32 +657,25 @@ Returns: } -VOID -InitializeDispatcherData ( - IN PEI_CORE_INSTANCE *PrivateData, - IN PEI_CORE_INSTANCE *OldCoreData, - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData - ) -/*++ - -Routine Description: - +/** Initialize the Dispatcher's data members -Arguments: - - PeiServices - The PEI core services table. - OldCoreData - Pointer to old core data (before switching stack). + @param PrivateData PeiCore's private data structure + @param OldCoreData Old data from SecCore NULL if being run in non-permament memory mode. - SecCoreData - Points to a data structure containing information about the PEI core's operating + @param SecCoreData Points to a data structure containing information about the PEI core's operating environment, such as the size and location of temporary RAM, the stack location and the BFV location. -Returns: - - None. + @return None. ---*/ +**/ +VOID +InitializeDispatcherData ( + IN PEI_CORE_INSTANCE *PrivateData, + IN PEI_CORE_INSTANCE *OldCoreData, + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData + ) { if (OldCoreData == NULL) { PeiInitializeFv (PrivateData, SecCoreData); @@ -708,29 +684,25 @@ Returns: return; } +/** + This routine parses the Dependency Expression, if available, and + decides if the module can be executed. + + + @param Private PeiCore's private data structure + @param FileHandle PEIM's file handle + @param PeimCount Peim count in all dispatched PEIMs. + @retval TRUE Can be dispatched + @retval FALSE Cannot be dispatched + +**/ BOOLEAN DepexSatisfied ( IN PEI_CORE_INSTANCE *Private, IN EFI_PEI_FILE_HANDLE FileHandle, IN UINTN PeimCount ) -/*++ - -Routine Description: - - This routine parses the Dependency Expression, if available, and - decides if the module can be executed. - -Arguments: - PeiServices - The PEI Service Table - CurrentPeimAddress - Address of the PEIM Firmware File under investigation - -Returns: - TRUE - Can be dispatched - FALSE - Cannot be dispatched - ---*/ { EFI_STATUS Status; VOID *DepexData; @@ -768,11 +740,11 @@ Returns: This routine enable a PEIM to register itself to shadow when PEI Foundation discovery permanent memory. - @param FileHandle File handle of a PEIM. + @param FileHandle File handle of a PEIM. - @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself. - @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself. - @retval EFI_SUCCESS Successfully to register itself. + @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself. + @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself. + @retval EFI_SUCCESS Successfully to register itself. **/ EFI_STATUS @@ -803,18 +775,16 @@ PeiRegisterForShadow ( return EFI_SUCCESS; } - - /** Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob. - @param PeiServices Pointer to the PEI Core Services Table. - @param FileHandle File handle of a Fv type file. + @param PeiServices Pointer to the PEI Core Services Table. + @param FvFileHandle File handle of a Fv type file. @param AuthenticationState Pointer to attestation authentication state of image. - @retval EFI_NOT_FOUND FV image can't be found. - @retval EFI_SUCCESS Successfully to process it. + @retval EFI_NOT_FOUND FV image can't be found. + @retval EFI_SUCCESS Successfully to process it. **/ EFI_STATUS diff --git a/MdeModulePkg/Core/Pei/FwVol/FwVol.c b/MdeModulePkg/Core/Pei/FwVol/FwVol.c index 1af4a76036..d5af3a0b1d 100644 --- a/MdeModulePkg/Core/Pei/FwVol/FwVol.c +++ b/MdeModulePkg/Core/Pei/FwVol/FwVol.c @@ -1,5 +1,6 @@ /** @file - + Pei Core Firmware File System service routines. + Copyright (c) 2006 - 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 @@ -15,7 +16,7 @@ Module Name: Abstract: - Pei Core Firmware File System service routines. + **/ @@ -31,28 +32,22 @@ STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyOnFvInfoList = { #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)) -STATIC -EFI_FFS_FILE_STATE -GetFileState( - IN UINT8 ErasePolarity, - IN EFI_FFS_FILE_HEADER *FfsHeader - ) -/*++ - -Routine Description: - +/** Returns the highest bit set of the State field -Arguments: - ErasePolarity - Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY - in the Attributes field. - FfsHeader - Pointer to FFS File Header. + @param ErasePolarity Erase Polarity as defined by EFI_FVB2_ERASE_POLARITY + in the Attributes field. + @param FfsHeader Pointer to FFS File Header. -Returns: - Returns the highest bit in the State field + @return Returns the highest bit in the State field ---*/ +**/ +EFI_FFS_FILE_STATE +GetFileState( + IN UINT8 ErasePolarity, + IN EFI_FFS_FILE_HEADER *FfsHeader + ) { EFI_FFS_FILE_STATE FileState; EFI_FFS_FILE_STATE HighestBit; @@ -71,48 +66,37 @@ Returns: return HighestBit; } -STATIC +/** + Calculates the checksum of the header of a file. + + @param FileHeader Pointer to FFS File Header. + + @return Checksum of the header. + The header is zero byte checksum. + Zero means the header is good. + Non-zero means the header is bad. +**/ UINT8 CalculateHeaderChecksum ( IN EFI_FFS_FILE_HEADER *FileHeader ) -/*++ - -Routine Description: - - Calculates the checksum of the header of a file. - -Arguments: - - FileHeader - Pointer to FFS File Header. - -Returns: - Checksum of the header. - - The header is zero byte checksum. - - Zero means the header is good. - - Non-zero means the header is bad. - - -Bugbug: For PEI performance reason, we comments this code at this time. ---*/ { - UINT8 *ptr; + UINT8 *Ptr; UINTN Index; UINT8 Sum; Sum = 0; - ptr = (UINT8 *)FileHeader; + Ptr = (UINT8 *)FileHeader; for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) { - Sum = (UINT8)(Sum + ptr[Index]); - Sum = (UINT8)(Sum + ptr[Index+1]); - Sum = (UINT8)(Sum + ptr[Index+2]); - Sum = (UINT8)(Sum + ptr[Index+3]); + Sum = (UINT8)(Sum + Ptr[Index]); + Sum = (UINT8)(Sum + Ptr[Index+1]); + Sum = (UINT8)(Sum + Ptr[Index+2]); + Sum = (UINT8)(Sum + Ptr[Index+3]); } for (; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) { - Sum = (UINT8)(Sum + ptr[Index]); + Sum = (UINT8)(Sum + Ptr[Index]); } // @@ -127,7 +111,15 @@ Bugbug: For PEI performance reason, we comments this code at this time. return Sum; } -STATIC +/** + Find FV handler according some FileHandle in that FV. + + @param FileHandle Handle of file image + @param VolumeHandle Handle of FV + + @return EDES_TODO: Add description for return value + +**/ BOOLEAN EFIAPI PeiFileHandleToVolume ( @@ -151,7 +143,23 @@ PeiFileHandleToVolume ( return FALSE; } +/** + Given the input file pointer, search for the next matching file in the + FFS volume as defined by SearchType. The search starts from FileHeader inside + the Firmware Volume defined by FwVolHeader. + + + @param FvHandle Pointer to the FV header of the volume to search + @param FileName File name + @param SearchType Filter to find only files of this type. + Type EFI_FV_FILETYPE_ALL causes no filtering to be done. + @param FileHandle This parameter must point to a valid FFS volume. + @param AprioriFile Pointer to AprioriFile image in this FV if has + @return EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to search given file + +**/ EFI_STATUS PeiFindFileEx ( IN CONST EFI_PEI_FV_HANDLE FvHandle, @@ -160,28 +168,6 @@ PeiFindFileEx ( IN OUT EFI_PEI_FILE_HANDLE *FileHandle, IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume as defined by SearchType. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - SearchType - Filter to find only files of this type. - Type EFI_FV_FILETYPE_ALL causes no filtering to be done. - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. - FileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file found. - Flag - Indicator for if this is for PEI Dispath search - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ { EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; EFI_FFS_FILE_HEADER **FileHeader; @@ -297,25 +283,22 @@ Returns: return EFI_NOT_FOUND; } +/** + + Initialize PeiCore Fv List. + + + @param PrivateData - Pointer to PEI_CORE_INSTANCE. + @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF. + + @return NONE + +**/ VOID PeiInitializeFv ( IN PEI_CORE_INSTANCE *PrivateData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData ) -/*++ - -Routine Description: - - Initialize PeiCore Fv List. - -Arguments: - PrivateData - Pointer to PEI_CORE_INSTANCE. - SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF. - -Returns: - NONE - ---*/ { EFI_STATUS Status; // @@ -340,6 +323,17 @@ Returns: } +/** + Process Firmware Volum Information once FvInfoPPI install. + + + @param PeiServices - General purpose services available to every PEIM. + @param NotifyDescriptor EDES_TODO: Add parameter description + @param Ppi EDES_TODO: Add parameter description + + @retval EFI_SUCCESS if the interface could be successfully installed + +**/ EFI_STATUS EFIAPI FirmwareVolmeInfoPpiNotifyCallback ( @@ -347,22 +341,6 @@ FirmwareVolmeInfoPpiNotifyCallback ( IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi ) -/*++ - -Routine Description: - - Process Firmware Volum Information once FvInfoPPI install. - -Arguments: - - PeiServices - General purpose services available to every PEIM. - -Returns: - - Status - EFI_SUCCESS if the interface could be successfully - installed - ---*/ { UINT8 FvCount; EFI_PEI_FIRMWARE_VOLUME_INFO_PPI *Fv; @@ -434,6 +412,22 @@ Returns: return EFI_SUCCESS; } +/** + + Go through the file to search SectionType section, + when meeting an encapsuled section. + + + @param PeiServices - General purpose services available to every PEIM. + SearchType - Filter to find only section of this type. + @param SectionType EDES_TODO: Add parameter description + @param Section - From where to search. + @param SectionSize - The file size to search. + @param OutputBuffer - Pointer to the section to search. + + @return EFI_STATUS + +**/ EFI_STATUS PeiFfsProcessSection ( IN CONST EFI_PEI_SERVICES **PeiServices, @@ -442,24 +436,6 @@ PeiFfsProcessSection ( IN UINTN SectionSize, OUT VOID **OutputBuffer ) -/*++ - -Routine Description: - - Go through the file to search SectionType section, - when meeting an encapsuled section. - -Arguments: - PeiServices - General purpose services available to every PEIM. - SearchType - Filter to find only section of this type. - Section - From where to search. - SectionSize - The file size to search. - OutputBuffer - Pointer to the section to search. - -Returns: - EFI_STATUS - ---*/ { EFI_STATUS Status; UINT32 SectionLength; @@ -571,6 +547,21 @@ Returns: } +/** + Given the input file pointer, search for the next matching section in the + FFS volume. + + + @param PeiServices Pointer to the PEI Core Services Table. + @param SectionType Filter to find only sections of this type. + @param FileHandle Pointer to the current file to search. + @param SectionData Pointer to the Section matching SectionType in FfsFileHeader. + NULL if section not found + + @retval EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to find section data in given file + +**/ EFI_STATUS EFIAPI PeiFfsFindSectionData ( @@ -579,24 +570,6 @@ PeiFfsFindSectionData ( IN EFI_PEI_FILE_HANDLE FileHandle, IN OUT VOID **SectionData ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching section in the - FFS volume. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - SearchType - Filter to find only sections of this type. - FfsFileHeader - Pointer to the current file to search. - SectionData - Pointer to the Section matching SectionType in FfsFileHeader. - - NULL if section not found - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ { EFI_FFS_FILE_HEADER *FfsFileHeader; UINT32 FileSize; @@ -622,7 +595,22 @@ Returns: ); } +/** + Given the input file pointer, search for the next matching file in the + FFS volume as defined by SearchType. The search starts from FileHeader inside + the Firmware Volume defined by FwVolHeader. + + @param PeiServices Pointer to the PEI Core Services Table. + @param SearchType Filter to find only files of this type. + Type EFI_FV_FILETYPE_ALL causes no filtering to be done. + @param VolumeHandle Pointer to the FV header of the volume to search. + @param FileHandle Pointer to the current file from which to begin searching. + This pointer will be updated upon return to reflect the file found. + @retval EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to find next file in given volume + +**/ EFI_STATUS EFIAPI PeiFfsFindNextFile ( @@ -631,35 +619,22 @@ PeiFfsFindNextFile ( IN EFI_PEI_FV_HANDLE VolumeHandle, IN OUT EFI_PEI_FILE_HANDLE *FileHandle ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume as defined by SearchType. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - - SearchType - Filter to find only files of this type. - Type EFI_FV_FILETYPE_ALL causes no filtering to be done. - - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. - - FileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file found. - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ { return PeiFindFileEx (VolumeHandle, NULL, SearchType, FileHandle, NULL); } +/** + search the firmware volumes by index + + @param PeiServices The PEI core services table. + @param Instance Instance of FV to find + @param VolumeHandle Pointer to found Volume. + + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL + @retval EFI_SUCCESS Firmware volume instance successfully found. + +**/ EFI_STATUS EFIAPI PeiFvFindNextVolume ( @@ -667,30 +642,6 @@ PeiFvFindNextVolume ( IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *VolumeHandle ) -/*++ - -Routine Description: - - Return the firmware volumes. - - BugBug -- Move this to the location of this code to where the - other FV and FFS support code lives. - Also, update to use FindFV for instances #'s >= 1. - -Arguments: - - PeiServices - The PEI core services table. - Instance - Instance of FV to find - FwVolHeader - Pointer to contain the data to return - -Returns: - Pointer to the Firmware Volume instance requested - - EFI_INVALID_PARAMETER - FwVolHeader is NULL - - EFI_SUCCESS - Firmware volume instance successfully found. - ---*/ { PEI_CORE_INSTANCE *Private; @@ -709,6 +660,19 @@ Returns: } +/** + + Given the input VolumeHandle, search for the next matching name file. + + + @param FileName - File name to search. + @param VolumeHandle - The current FV to search. + @param FileHandle - Pointer to the file matching name in VolumeHandle. + - NULL if file not found + + @return EFI_STATUS + +**/ EFI_STATUS EFIAPI PeiFfsFindFileByName ( @@ -716,22 +680,6 @@ PeiFfsFindFileByName ( IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle ) -/*++ - -Routine Description: - - Given the input VolumeHandle, search for the next matching name file. - -Arguments: - - FileName - File name to search. - VolumeHandle - The current FV to search. - FileHandle - Pointer to the file matching name in VolumeHandle. - - NULL if file not found -Returns: - EFI_STATUS - ---*/ { EFI_STATUS Status; if ((VolumeHandle == NULL) || (FileName == NULL) || (FileHandle == NULL)) { @@ -744,26 +692,24 @@ Returns: return Status; } +/** + + Returns information about a specific file. + + + @param FileHandle - The handle to file. + @param FileInfo - Pointer to the file information. + + @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo. + @retval EFI_SUCCESS Success to collect file info. + +**/ EFI_STATUS EFIAPI PeiFfsGetFileInfo ( IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo ) -/*++ - -Routine Description: - - Collect information of given file. - -Arguments: - FileHandle - The handle to file. - FileInfo - Pointer to the file information. - -Returns: - EFI_STATUS - ---*/ { UINT8 FileState; UINT8 ErasePolarity; @@ -811,26 +757,22 @@ Returns: } +/** + + Collect information of given Fv Volume. + + @param VolumeHandle - The handle to Fv Volume. + @param VolumeInfo - The pointer to volume information. + + @retval EFI_INVALID_PARAMETER VolumeInfo is NULL + @retval EFI_SUCCESS Success to collect fv info. +**/ EFI_STATUS EFIAPI PeiFfsGetVolumeInfo ( IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo ) -/*++ - -Routine Description: - - Collect information of given Fv Volume. - -Arguments: - VolumeHandle - The handle to Fv Volume. - VolumeInfo - The pointer to volume information. - -Returns: - EFI_STATUS - ---*/ { EFI_FIRMWARE_VOLUME_HEADER FwVolHeader; EFI_FIRMWARE_VOLUME_EXT_HEADER *FwVolExHeaderInfo; diff --git a/MdeModulePkg/Core/Pei/Hob/Hob.c b/MdeModulePkg/Core/Pei/Hob/Hob.c index c353fa5bfa..aa38228bec 100644 --- a/MdeModulePkg/Core/Pei/Hob/Hob.c +++ b/MdeModulePkg/Core/Pei/Hob/Hob.c @@ -1,5 +1,6 @@ /** @file - + This module provide Hand-Off Block manupulation. + Copyright (c) 2006, 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 @@ -9,42 +10,29 @@ 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: +**/ - Hob.c +#include -Abstract: +/** - EFI PEI Core HOB services + Gets the pointer to the HOB List. -**/ -#include + @param PeiServices The PEI core services table. + @param HobList Pointer to the HOB List. + + @retval EFI_SUCCESS Get the pointer of HOB List + @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published + @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode) +**/ EFI_STATUS EFIAPI PeiGetHobList ( IN CONST EFI_PEI_SERVICES **PeiServices, IN OUT VOID **HobList ) -/*++ - -Routine Description: - - Gets the pointer to the HOB List. - -Arguments: - - PeiServices - The PEI core services table. - HobList - Pointer to the HOB List. - -Returns: - - EFI_SUCCESS - Get the pointer of HOB List - EFI_NOT_AVAILABLE_YET - the HOB List is not yet published - EFI_INVALID_PARAMETER - HobList is NULL (in debug mode) - ---*/ { PEI_CORE_INSTANCE *PrivateData; @@ -68,6 +56,20 @@ Returns: } +/** + Add a new HOB to the HOB List. + + @param PeiServices - The PEI core services table. + @param Type - Type of the new HOB. + @param Length - Length of the new HOB to allocate. + @param Hob - Pointer to the new HOB. + + @return EFI_SUCCESS Success to create hob. + @retval EFI_INVALID_PARAMETER if Hob is NULL + @retval EFI_NOT_AVAILABLE_YET if HobList is still not available. + @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist. + +**/ EFI_STATUS EFIAPI PeiCreateHob ( @@ -76,27 +78,6 @@ PeiCreateHob ( IN UINT16 Length, IN OUT VOID **Hob ) -/*++ - -Routine Description: - - Add a new HOB to the HOB List. - -Arguments: - - PeiServices - The PEI core services table. - Type - Type of the new HOB. - Length - Length of the new HOB to allocate. - Hob - Pointer to the new HOB. - -Returns: - - Status - EFI_SUCCESS - - EFI_INVALID_PARAMETER if Hob is NULL - - EFI_NOT_AVAILABLE_YET if HobList is still not available. - - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist. - ---*/ { EFI_STATUS Status; EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob; @@ -142,29 +123,23 @@ Returns: } +/** + + Builds a Handoff Information Table HOB + + @param BootMode - Current Bootmode + @param MemoryBegin - Start Memory Address. + @param MemoryLength - Length of Memory. + + @return EFI_SUCCESS Always success to initialize HOB. + +**/ EFI_STATUS PeiCoreBuildHobHandoffInfoTable ( IN EFI_BOOT_MODE BootMode, IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength ) -/*++ - -Routine Description: - - Builds a Handoff Information Table HOB - -Arguments: - - BootMode - Current Bootmode - MemoryBegin - Start Memory Address. - MemoryLength - Length of Memory. - -Returns: - - EFI_SUCCESS - ---*/ { EFI_HOB_HANDOFF_INFO_TABLE *Hob; EFI_HOB_GENERIC_HEADER *HobEnd; diff --git a/MdeModulePkg/Core/Pei/Image/Image.c b/MdeModulePkg/Core/Pei/Image/Image.c index 98553eb10c..d08fee42e1 100644 --- a/MdeModulePkg/Core/Pei/Image/Image.c +++ b/MdeModulePkg/Core/Pei/Image/Image.c @@ -1,5 +1,6 @@ /** @file - + Pei Core Load Image Support + Copyright (c) 2006 - 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 @@ -9,37 +10,25 @@ 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: - - Image.c - -Abstract: - - Pei Core Load Image Support - **/ #include -/*++ - -Routine Description: - - Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file - -Arguments: - - FileHandle - The handle to the PE/COFF file - FileOffset - The offset, in bytes, into the file to read - ReadSize - The number of bytes to read from the file starting at FileOffset - Buffer - A pointer to the buffer to read the data into. - -Returns: +/** + Routine for loading file image. - EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset + @param PeiServices The PEI core services table. + @param FileHandle Pointer to the FFS file header of the image. + @param ImageAddressArg Pointer to PE/TE image. + @param ImageSizeArg Size of PE/TE image. + @param EntryPoint Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. ---*/ + @retval EFI_SUCCESS - Image is successfully loaded. + @retval EFI_NOT_FOUND - Fail to locate necessary PPI + @retval Others - Fail to load file. +**/ EFI_STATUS PeiLoadImageLoadImage ( IN EFI_PEI_SERVICES **PeiServices, @@ -49,30 +38,21 @@ PeiLoadImageLoadImage ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - Routine for loading file image. - -Arguments: - - PeiServices - The PEI core services table. - FileHandle - Pointer to the FFS file header of the image. - ImageAddressArg - Pointer to PE/TE image. - ImageSizeArg - Size of PE/TE image. - EntryPoint - Pointer to entry point of specified image file for output. - AuthenticationState - Pointer to attestation authentication state of image. +; -Returns: +/** + The wrapper function of PeiLoadImageLoadImage(). - Status - EFI_SUCCESS - Image is successfully loaded. - EFI_NOT_FOUND - Fail to locate necessary PPI - Others - Fail to load file. + @param This - Pointer to EFI_PEI_LOAD_FILE_PPI. + @param FileHandle - Pointer to the FFS file header of the image. + @param ImageAddressArg - Pointer to PE/TE image. + @param ImageSizeArg - Size of PE/TE image. + @param EntryPoint - Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. ---*/ -; + @return Status of PeiLoadImageLoadImage(). +**/ EFI_STATUS EFIAPI PeiLoadImageLoadImageWrapper ( @@ -83,27 +63,6 @@ PeiLoadImageLoadImageWrapper ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - The wrapper function of PeiLoadImageLoadImage(). - -Arguments: - - This - Pointer to EFI_PEI_LOAD_FILE_PPI. - PeiServices - The PEI core services table. - FileHandle - Pointer to the FFS file header of the image. - ImageAddressArg - Pointer to PE/TE image. - ImageSizeArg - Size of PE/TE image. - EntryPoint - Pointer to entry point of specified image file for output. - AuthenticationState - Pointer to attestation authentication state of image. - -Returns: - - EFI_STATUS. - ---*/ ; STATIC EFI_PEI_LOAD_FILE_PPI mPeiLoadImagePpi = { @@ -117,6 +76,19 @@ STATIC EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = { &mPeiLoadImagePpi }; +/** + + Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file + + + @param FileHandle - The handle to the PE/COFF file + @param FileOffset - The offset, in bytes, into the file to read + @param ReadSize - The number of bytes to read from the file starting at FileOffset + @param Buffer - A pointer to the buffer to read the data into. + + @return EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset + +**/ EFI_STATUS EFIAPI PeiImageRead ( @@ -125,24 +97,6 @@ PeiImageRead ( IN OUT UINTN *ReadSize, OUT VOID *Buffer ) -/*++ - -Routine Description: - - Support routine for the PE/COFF Loader that reads a buffer from a PE/COFF file - -Arguments: - - FileHandle - The handle to the PE/COFF file - FileOffset - The offset, in bytes, into the file to read - ReadSize - The number of bytes to read from the file starting at FileOffset - Buffer - A pointer to the buffer to read the data into. - -Returns: - - EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/COFF file starting at FileOffset - ---*/ { CHAR8 *Destination8; CHAR8 *Source8; @@ -158,27 +112,19 @@ Returns: return EFI_SUCCESS; } -EFI_STATUS -GetImageReadFunction ( - IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext - ) -/*++ - -Routine Description: - - Support routine to return the Image Read - -Arguments: - - PeiServices - PEI Services Table +/** - ImageContext - The context of the image being loaded + Support routine to return the Image Read. -Returns: + @param ImageContext - The context of the image being loaded - EFI_SUCCESS - If Image function location is found + @retval EFI_SUCCESS - If Image function location is found ---*/ +**/ +EFI_STATUS +GetImageReadFunction ( + IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext + ) { VOID* MemoryBuffer; @@ -192,7 +138,20 @@ Returns: return EFI_SUCCESS; } -STATIC +/** + + Loads and relocates a PE/COFF image into memory. + + + @param Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated + @param ImageAddress - The base address of the relocated PE/COFF image + @param ImageSize - The size of the relocated PE/COFF image + @param EntryPoint - The entry point of the relocated PE/COFF image + + @retval EFI_SUCCESS The file was loaded and relocated + @retval EFI_OUT_OF_RESOURCES There was not enough memory to load and relocate the PE/COFF file + +**/ EFI_STATUS LoadAndRelocatePeCoffImage ( IN VOID *Pe32Data, @@ -200,29 +159,6 @@ LoadAndRelocatePeCoffImage ( OUT UINT64 *ImageSize, OUT EFI_PHYSICAL_ADDRESS *EntryPoint ) -/*++ - -Routine Description: - - Loads and relocates a PE/COFF image into memory. - -Arguments: - - Pe32Data - The base address of the PE/COFF file that is to be loaded and relocated - - ImageAddress - The base address of the relocated PE/COFF image - - ImageSize - The size of the relocated PE/COFF image - - EntryPoint - The entry point of the relocated PE/COFF image - -Returns: - - EFI_SUCCESS - The file was loaded and relocated - - EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file - ---*/ { EFI_STATUS Status; PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; @@ -286,6 +222,21 @@ Returns: return EFI_SUCCESS; } +/** + Routine for loading file image. + + @param PeiServices The PEI core services table. + @param FileHandle Pointer to the FFS file header of the image. + @param ImageAddressArg Pointer to PE/TE image. + @param ImageSizeArg Size of PE/TE image. + @param EntryPoint Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. + + @retval EFI_SUCCESS - Image is successfully loaded. + @retval EFI_NOT_FOUND - Fail to locate necessary PPI + @retval Others - Fail to load file. + +**/ EFI_STATUS PeiLoadImageLoadImage ( IN EFI_PEI_SERVICES **PeiServices, @@ -295,28 +246,6 @@ PeiLoadImageLoadImage ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - Routine for loading file image. - -Arguments: - - PeiServices - The PEI core services table. - FileHandle - Pointer to the FFS file header of the image. - ImageAddressArg - Pointer to PE/TE image. - ImageSizeArg - Size of PE/TE image. - EntryPoint - Pointer to entry point of specified image file for output. - AuthenticationState - Pointer to attestation authentication state of image. - -Returns: - - Status - EFI_SUCCESS - Image is successfully loaded. - EFI_NOT_FOUND - Fail to locate necessary PPI - Others - Fail to load file. - ---*/ { EFI_STATUS Status; VOID *Pe32Data; @@ -464,6 +393,19 @@ Returns: } +/** + The wrapper function of PeiLoadImageLoadImage(). + + @param This - Pointer to EFI_PEI_LOAD_FILE_PPI. + @param FileHandle - Pointer to the FFS file header of the image. + @param ImageAddressArg - Pointer to PE/TE image. + @param ImageSizeArg - Size of PE/TE image. + @param EntryPoint - Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. + + @return Status of PeiLoadImageLoadImage(). + +**/ EFI_STATUS EFIAPI PeiLoadImageLoadImageWrapper ( @@ -474,27 +416,6 @@ PeiLoadImageLoadImageWrapper ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - The wrapper function of PeiLoadImageLoadImage(). - -Arguments: - - This - Pointer to EFI_PEI_LOAD_FILE_PPI. - PeiServices - The PEI core services table. - FileHandle - Pointer to the FFS file header of the image. - ImageAddressArg - Pointer to PE/TE image. - ImageSizeArg - Size of PE/TE image. - EntryPoint - Pointer to entry point of specified image file for output. - AuthenticationState - Pointer to attestation authentication state of image. - -Returns: - - EFI_STATUS. - ---*/ { return PeiLoadImageLoadImage ( GetPeiServicesTablePointer (), @@ -506,6 +427,21 @@ Returns: ); } +/** + + Routine for load image file. + + + @param PeiServices - The PEI core services table. + @param FileHandle - Pointer to the FFS file header of the image. + @param EntryPoint - Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. + + @retval EFI_SUCCESS - Image is successfully loaded. + @retval EFI_NOT_FOUND - Fail to locate necessary PPI + @retval Others - Fail to load file. + +**/ EFI_STATUS PeiLoadImage ( IN EFI_PEI_SERVICES **PeiServices, @@ -513,26 +449,6 @@ PeiLoadImage ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - Routine for load image file. - -Arguments: - - PeiServices - The PEI core services table. - FileHandle - Pointer to the FFS file header of the image. - EntryPoint - Pointer to entry point of specified image file for output. - AuthenticationState - Pointer to attestation authentication state of image. - -Returns: - - Status - EFI_SUCCESS - Image is successfully loaded. - EFI_NOT_FOUND - Fail to locate necessary PPI - Others - Fail to load file. - ---*/ { EFI_STATUS PpiStatus; EFI_STATUS Status; @@ -585,27 +501,20 @@ Returns: } -VOID -InitializeImageServices ( - IN PEI_CORE_INSTANCE *PrivateData, - IN PEI_CORE_INSTANCE *OldCoreData - ) -/*++ - -Routine Description: +/** Install Pei Load File PPI. -Arguments: - PrivateData - Pointer to PEI_CORE_INSTANCE. - OldCoreData - Pointer to PEI_CORE_INSTANCE. + @param PrivateData - Pointer to PEI_CORE_INSTANCE. + @param OldCoreData - Pointer to PEI_CORE_INSTANCE. -Returns: - - NONE. - ---*/ +**/ +VOID +InitializeImageServices ( + IN PEI_CORE_INSTANCE *PrivateData, + IN PEI_CORE_INSTANCE *OldCoreData + ) { if (OldCoreData == NULL) { // diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c index f4212c849e..58c5d81517 100644 --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c @@ -1,5 +1,6 @@ /** @file - + EFI PEI Core memory services + Copyright (c) 2006, 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 @@ -9,45 +10,29 @@ 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: - - MemoryServices.c - -Abstract: - - EFI PEI Core memory services - **/ #include -VOID -InitializeMemoryServices ( - IN PEI_CORE_INSTANCE *PrivateData, - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, - IN PEI_CORE_INSTANCE *OldCoreData - ) -/*++ - -Routine Description: +/** Initialize the memory services. -Arguments: - PeiServices - The PEI core services table. - SecCoreData - Points to a data structure containing information about the PEI core's operating + @param PrivateData Add parameter description + @param SecCoreData Points to a data structure containing information about the PEI core's operating environment, such as the size and location of temporary RAM, the stack location and the BFV location. - - OldCoreData - Pointer to the PEI Core data. + @param OldCoreData Pointer to the PEI Core data. NULL if being run in non-permament memory mode. -Returns: - - None - ---*/ +**/ +VOID +InitializeMemoryServices ( + IN PEI_CORE_INSTANCE *PrivateData, + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN PEI_CORE_INSTANCE *OldCoreData + ) { PrivateData->SwitchStackSignal = FALSE; @@ -85,6 +70,18 @@ Returns: return; } +/** + + Install the permanent memory is now available. + Creates HOB (PHIT and Stack). + + @param PeiServices - The PEI core services table. + @param MemoryBegin - Start of memory address. + @param MemoryLength - Length of memory. + + @return EFI_SUCCESS Always success. + +**/ EFI_STATUS EFIAPI PeiInstallPeiMemory ( @@ -92,24 +89,6 @@ PeiInstallPeiMemory ( IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength ) -/*++ - -Routine Description: - - Install the permanent memory is now available. - Creates HOB (PHIT and Stack). - -Arguments: - - PeiServices - The PEI core services table. - MemoryBegin - Start of memory address. - MemoryLength - Length of memory. - -Returns: - - Status - EFI_SUCCESS - ---*/ { PEI_CORE_INSTANCE *PrivateData; @@ -125,6 +104,24 @@ Returns: return EFI_SUCCESS; } +/** + + Memory allocation service on permanent memory, + not usable prior to the memory installation. + + + @param PeiServices - The PEI core services table. + @param MemoryType - Type of memory to allocate. + @param Pages - Number of pages to allocate. + @param Memory - Pointer of memory allocated. + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available + @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement + to allocate the number of pages. + +**/ EFI_STATUS EFIAPI PeiAllocatePages ( @@ -133,29 +130,6 @@ PeiAllocatePages ( IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory ) -/*++ - -Routine Description: - - Memory allocation service on permanent memory, - not usable prior to the memory installation. - -Arguments: - - PeiServices - The PEI core services table. - MemoryType - Type of memory to allocate. - Pages - Number of pages to allocate. - Memory - Pointer of memory allocated. - -Returns: - - Status - EFI_SUCCESS The allocation was successful - EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported. - EFI_NOT_AVAILABLE_YET Called with permanent memory not available - EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement - to allocate the number of pages. - ---*/ { PEI_CORE_INSTANCE *PrivateData; EFI_PEI_HOB_POINTERS Hob; @@ -232,7 +206,20 @@ Returns: } } +/** + + Memory allocation service on the CAR. + + @param PeiServices - The PEI core services table. + @param Size - Amount of memory required + @param Buffer - Address of pointer to the buffer + + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement + to allocate the requested size. + +**/ EFI_STATUS EFIAPI PeiAllocatePool ( @@ -240,27 +227,6 @@ PeiAllocatePool ( IN UINTN Size, OUT VOID **Buffer ) -/*++ - -Routine Description: - - Memory allocation service on the CAR. - -Arguments: - - PeiServices - The PEI core services table. - - Size - Amount of memory required - - Buffer - Address of pointer to the buffer - -Returns: - - Status - EFI_SUCCESS The allocation was successful - EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement - to allocate the requested size. - ---*/ { EFI_STATUS Status; EFI_HOB_MEMORY_POOL *Hob; diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h index ca48a51fbd..8e87aaae05 100644 --- a/MdeModulePkg/Core/Pei/PeiMain.h +++ b/MdeModulePkg/Core/Pei/PeiMain.h @@ -1,5 +1,6 @@ /** @file - + Definition of Pei Core Structures and Services + Copyright (c) 2006 - 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 @@ -9,16 +10,6 @@ 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: - - PeiMain.h - -Abstract: - - Definition of Pei Core Structures and Services - -Revision History - **/ #ifndef _PEI_MAIN_H_ @@ -58,9 +49,9 @@ Revision History #define PEI_CORE_INTERNAL_FFS_FILE_DISPATCH_TYPE 0xff -// -// Pei Core private data structures -// +/// +/// Pei Core private data structures +/// typedef union { EFI_PEI_PPI_DESCRIPTOR *Ppi; EFI_PEI_NOTIFY_DESCRIPTOR *Notify; @@ -150,9 +141,6 @@ typedef struct{ #define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \ CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE) -// -// BUGBUG: Where does this go really? -// typedef EFI_STATUS (EFIAPI *PEI_CORE_ENTRY_POINT)( @@ -161,9 +149,9 @@ EFI_STATUS IN PEI_CORE_INSTANCE *OldCoreData ); -// -// Union of temporarily used function pointers (to save stack space) -// +/// +/// Union of temporarily used function pointers (to save stack space) +/// typedef union { PEI_CORE_ENTRY_POINT PeiCore; EFI_PEIM_ENTRY_POINT2 PeimEntry; @@ -185,47 +173,42 @@ typedef struct { // // PeiCore function // -EFI_STATUS -EFIAPI -PeiCore ( - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, - IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList, - IN VOID *Data - ) -/*++ - -Routine Description: +/** The entry routine to Pei Core, invoked by PeiMain during transition from SEC to PEI. After switching stack in the PEI core, it will restart with the old core data. -Arguments: - PeiStartupDescriptor - Information and services provided by SEC phase. - OldCoreData - Pointer to old core data that is used to initialize the + @param SecCoreData Points to a data structure containing information about the PEI core's operating + environment, 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 Data Pointer to old core data that is used to initialize the core's data areas. -Returns: + @retval EFI_NOT_FOUND Never reach - This function never returns - EFI_NOT_FOUND - Never reach - ---*/ +**/ +EFI_STATUS +EFIAPI +PeiCore ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList, + IN VOID *Data + ) ; // // Dispatcher support functions // -BOOLEAN -PeimDispatchReadiness ( - IN EFI_PEI_SERVICES **PeiServices, - IN VOID *DependencyExpression - ) -/*++ - -Routine Description: +/** This is the POSTFIX version of the dependency evaluator. When a PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on @@ -234,208 +217,117 @@ Routine Description: some time savings as not all PPIs must be checked for certain operation types (AND, OR). -Arguments: - PeiServices - Calling context. + @param PeiServices Calling context. + @param DependencyExpression Pointer to a dependency expression. The Grammar adheres to + the BNF described above and is stored in postfix notation. - DependencyExpression - Pointer to a dependency expression. The Grammar adheres to - the BNF described above and is stored in postfix notation. + @retval TRUE if it is a well-formed Grammar + @retval FALSE if the dependency expression overflows the evaluation stack + if the dependency expression underflows the evaluation stack + if the dependency expression is not a well-formed Grammar. -Returns: - - Status = EFI_SUCCESS if it is a well-formed Grammar - EFI_INVALID_PARAMETER if the dependency expression overflows - the evaluation stack - EFI_INVALID_PARAMETER if the dependency expression underflows - the evaluation stack - EFI_INVALID_PARAMETER if the dependency expression is not a - well-formed Grammar. ---*/ +**/ +BOOLEAN +PeimDispatchReadiness ( + IN EFI_PEI_SERVICES **PeiServices, + IN VOID *DependencyExpression + ) ; +/** + Conduct PEIM dispatch. + + @param SecCoreData Points to a data structure containing information about the PEI core's operating + environment, such as the size and location of temporary RAM, the stack location and + the BFV location. + PrivateData - Pointer to the private data passed in from caller + DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data. + @param Private EDES_TODO: Add parameter description + @retval EFI_SUCCESS Successfully dispatched PEIM. + @retval EFI_NOT_FOUND The dispatch failed. + +**/ VOID PeiDispatcher ( IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData ) +; -/*++ - -Routine Description: - - Conduct PEIM dispatch. - -Arguments: - - PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR - PrivateData - Pointer to the private data passed in from caller - DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data. - -Returns: - - EFI_SUCCESS - Successfully dispatched PEIM. - EFI_NOT_FOUND - The dispatch failed. +/** + Initialize the Dispatcher's data members ---*/ -; + @param PrivateData PeiCore's private data structure + @param OldCoreData Old data from SecCore + NULL if being run in non-permament memory mode. + @param SecCoreData Points to a data structure containing information about the PEI core's operating + environment, such as the size and location of temporary RAM, the stack location and + the BFV location. + @return None. +**/ VOID InitializeDispatcherData ( IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_INSTANCE *OldCoreData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData ) -/*++ - -Routine Description: - - Initialize the Dispatcher's data members - -Arguments: - - PeiServices - The PEI core services table. - OldCoreData - Pointer to old core data (before switching stack). - NULL if being run in non-permament memory mode. - PeiStartupDescriptor - Information and services provided by SEC phase. - - -Returns: - - None - ---*/ -; - - -EFI_STATUS -FindNextPeim ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, - IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader - ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. - - PeimFileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file found. - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ -; - -BOOLEAN -Dispatched ( - IN UINT8 CurrentPeim, - IN UINT32 DispatchedPeimBitMap - ) -/*++ - -Routine Description: - - This routine checks to see if a particular PEIM has been dispatched during - the PEI core dispatch. - -Arguments: - CurrentPeim - The PEIM/FV in the bit array to check. - DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV. - -Returns: - TRUE if PEIM already dispatched - FALSE if not - ---*/ ; -VOID -SetDispatched ( - IN EFI_PEI_SERVICES **PeiServices, - IN UINT8 CurrentPeim, - OUT UINT32 *DispatchedPeimBitMap - ) -/*++ - -Routine Description: - - This routine sets a PEIM as having been dispatched once its entry - point has been invoked. - -Arguments: +/** + This routine parses the Dependency Expression, if available, and + decides if the module can be executed. - PeiServices - The PEI core services table. - CurrentPeim - The PEIM/FV in the bit array to check. - DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV. -Returns: - None + @param Private PeiCore's private data structure + @param FileHandle PEIM's file handle + @param PeimCount Peim count in all dispatched PEIMs. ---*/ -; + @retval TRUE Can be dispatched + @retval FALSE Cannot be dispatched +**/ BOOLEAN DepexSatisfied ( IN PEI_CORE_INSTANCE *Private, IN EFI_PEI_FILE_HANDLE FileHandle, IN UINTN PeimCount ) -/*++ - -Routine Description: - - This routine parses the Dependency Expression, if available, and - decides if the module can be executed. - -Arguments: - PeiServices - The PEI Service Table - CurrentPeimAddress - Address of the PEIM Firmware File under investigation - -Returns: - TRUE - Can be dispatched - FALSE - Cannot be dispatched - ---*/ ; // // PPI support functions // +/** + + Initialize PPI services. + + + @param PrivateData Pointer to the PEI Core data. + @param OldCoreData Pointer to old PEI Core data. + NULL if being run in non-permament memory mode. + +**/ VOID InitializePpiServices ( IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_INSTANCE *OldCoreData ) -/*++ - -Routine Description: - - Initialize PPI services. - -Arguments: +; - PeiServices - The PEI core services table. - OldCoreData - Pointer to the PEI Core data. - NULL if being run in non-permament memory mode. +/** -Returns: - Nothing + Migrate the Hob list from the CAR stack to PEI installed memory. ---*/ -; + @param PeiServices The PEI core services table. + @param OldCheckingBottom The old checking bottom. + @param OldCheckingTop The old checking top. + @param NewHandOffHob The new handoff HOB list. +**/ VOID ConvertPpiPointers ( IN CONST EFI_PEI_SERVICES **PeiServices, @@ -443,51 +335,43 @@ ConvertPpiPointers ( IN UINTN OldCheckingTop, IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob ) -/*++ - -Routine Description: - - Migrate the Hob list from the CAR stack to PEI installed memory. +; -Arguments: +/** - PeiServices - The PEI core services table. - OldCheckingBottom - The old checking bottom. - OldCheckingTop - The old checking top. - NewHandOffHob - The new handoff HOB list. + Install PPI services. -Returns: + @param PeiServices - Pointer to the PEI Service Table + @param PpiList - Pointer to a list of PEI PPI Descriptors. ---*/ -; + @retval EFI_SUCCESS - if all PPIs in PpiList are successfully installed. + @retval EFI_INVALID_PARAMETER - if PpiList is NULL pointer + @retval EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid + @retval EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI +**/ EFI_STATUS EFIAPI PeiInstallPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList ) -/*++ - -Routine Description: - - Install PPI services. +; -Arguments: +/** - PeiServices - Pointer to the PEI Service Table - PpiList - Pointer to a list of PEI PPI Descriptors. + Re-Install PPI services. -Returns: + @param PeiServices - Pointer to the PEI Service Table + @param OldPpi - Pointer to the old PEI PPI Descriptors. + @param NewPpi - Pointer to the new PEI PPI Descriptors. - EFI_SUCCESS - if all PPIs in PpiList are successfully installed. - EFI_INVALID_PARAMETER - if PpiList is NULL pointer - EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid - EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI - ---*/ -; + @retval EFI_SUCCESS - if the operation was successful + @retval EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL + @retval EFI_INVALID_PARAMETER - if NewPpi is not valid + @retval EFI_NOT_FOUND - if the PPI was not in the database +**/ EFI_STATUS EFIAPI PeiReInstallPpi ( @@ -495,28 +379,24 @@ PeiReInstallPpi ( IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi ) -/*++ - -Routine Description: - - Re-Install PPI services. +; -Arguments: +/** - PeiServices - Pointer to the PEI Service Table - OldPpi - Pointer to the old PEI PPI Descriptors. - NewPpi - Pointer to the new PEI PPI Descriptors. + Locate a given named PPI. -Returns: - EFI_SUCCESS - if the operation was successful - EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL - EFI_INVALID_PARAMETER - if NewPpi is not valid - EFI_NOT_FOUND - if the PPI was not in the database + @param PeiServices - Pointer to the PEI Service Table + @param Guid - Pointer to GUID of the PPI. + @param Instance - Instance Number to discover. + @param PpiDescriptor - Pointer to reference the found descriptor. If not NULL, + returns a pointer to the descriptor (includes flags, etc) + @param Ppi - Pointer to reference the found PPI ---*/ -; + @retval EFI_SUCCESS if the PPI is in the database + @retval EFI_NOT_FOUND if the PPI is not in the database +**/ EFI_STATUS EFIAPI PeiLocatePpi ( @@ -526,73 +406,54 @@ PeiLocatePpi ( IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi ) -/*++ - -Routine Description: +; - Locate a given named PPI. +/** -Arguments: + Install a notification for a given PPI. - PeiServices - Pointer to the PEI Service Table - Guid - Pointer to GUID of the PPI. - Instance - Instance Number to discover. - PpiDescriptor - Pointer to reference the found descriptor. If not NULL, - returns a pointer to the descriptor (includes flags, etc) - Ppi - Pointer to reference the found PPI -Returns: + @param PeiServices - Pointer to the PEI Service Table + @param NotifyList - Pointer to list of Descriptors to notify upon. - Status - EFI_SUCCESS if the PPI is in the database - EFI_NOT_FOUND if the PPI is not in the database ---*/ -; + @retval EFI_SUCCESS if successful + @retval EFI_OUT_OF_RESOURCES if no space in the database + @retval EFI_INVALID_PARAMETER if not a good decriptor +**/ EFI_STATUS EFIAPI PeiNotifyPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList ) -/*++ - -Routine Description: - - Install a notification for a given PPI. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - NotifyList - Pointer to list of Descriptors to notify upon. +; -Returns: +/** - Status - EFI_SUCCESS if successful - EFI_OUT_OF_RESOURCES if no space in the database - EFI_INVALID_PARAMETER if not a good decriptor + Process the Notify List at dispatch level. ---*/ -; + @param PrivateData PeiCore's private data structure. +**/ VOID ProcessNotifyList ( IN PEI_CORE_INSTANCE *PrivateData ) -/*++ - -Routine Description: - - Process the Notify List at dispatch level. - -Arguments: +; - PeiServices - Pointer to the PEI Service Table +/** -Returns: + Dispatch notifications. ---*/ -; + @param PrivateData PeiCore's private data structure + @param NotifyType Type of notify to fire. + @param InstallStartIndex Install Beginning index. + @param InstallStopIndex Install Ending index. + @param NotifyStartIndex Notify Beginning index. + @param NotifyStopIndex Notify Ending index. +**/ VOID DispatchNotify ( IN PEI_CORE_INSTANCE *PrivateData, @@ -602,178 +463,138 @@ DispatchNotify ( IN INTN NotifyStartIndex, IN INTN NotifyStopIndex ) -/*++ - -Routine Description: - - Dispatch notifications. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - NotifyType - Type of notify to fire. - InstallStartIndex - Install Beginning index. - InstallStopIndex - Install Ending index. - NotifyStartIndex - Notify Beginning index. - NotifyStopIndex - Notify Ending index. - -Returns: None - ---*/ ; // // Boot mode support functions // +/** + This service enables PEIMs to ascertain the present value of the boot mode. + + @param PeiServices The PEI core services table. + @param BootMode A pointer to contain the value of the boot mode. + + @retval EFI_SUCCESS The boot mode was returned successfully. + @retval EFI_INVALID_PARAMETER BootMode is NULL. + +**/ EFI_STATUS EFIAPI PeiGetBootMode ( IN CONST EFI_PEI_SERVICES **PeiServices, IN OUT EFI_BOOT_MODE *BootMode ) -/*++ - -Routine Description: - - This service enables PEIMs to ascertain the present value of the boot mode. +; -Arguments: +/** + This service enables PEIMs to update the boot mode variable. - PeiServices - The PEI core services table. - BootMode - A pointer to contain the value of the boot mode. -Returns: + @param PeiServices - The PEI core services table. + @param BootMode - The value of the boot mode to set. - EFI_SUCCESS - The boot mode was returned successfully. - EFI_INVALID_PARAMETER - BootMode is NULL. - ---*/ -; + @return EFI_SUCCESS - The value was successfully updated +**/ EFI_STATUS EFIAPI PeiSetBootMode ( IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_BOOT_MODE BootMode ) -/*++ - -Routine Description: - - This service enables PEIMs to update the boot mode variable. - -Arguments: - - PeiServices - The PEI core services table. - BootMode - The value of the boot mode to set. - -Returns: - - EFI_SUCCESS - The value was successfully updated - ---*/ ; // // Security support functions // +/** + + Initialize the security services. + + + @param PeiServices - The PEI core services table. + @param OldCoreData - Pointer to the old core data. + NULL if being run in non-permament memory mode. + +**/ VOID InitializeSecurityServices ( IN EFI_PEI_SERVICES **PeiServices, IN PEI_CORE_INSTANCE *OldCoreData ) -/*++ - -Routine Description: - - Initialize the security services. - -Arguments: +; - PeiServices - The PEI core services table. - OldCoreData - Pointer to the old core data. - NULL if being run in non-permament memory mode. -Returns: +/** + Verify a Firmware volume - None + @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration ---*/ -; + @retval EFI_SUCCESS - Firmware Volume is legal + @retval EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test +**/ EFI_STATUS VerifyFv ( IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress ) -/*++ - -Routine Description: - - Provide a callout to the OEM FV verification service. - -Arguments: +; - CurrentFvAddress - Pointer to the FV under investigation. +/** -Returns: + Provide a callout to the security verification service. - Status - EFI_SUCCESS ---*/ -; + @param PrivateData PeiCore's private data structure + @param VolumeHandle Handle of FV + @param FileHandle Handle of PEIM's ffs + @retval EFI_SUCCESS Image is OK + @retval EFI_SECURITY_VIOLATION Image is illegal +**/ EFI_STATUS VerifyPeim ( IN PEI_CORE_INSTANCE *PrivateData, IN EFI_PEI_FV_HANDLE VolumeHandle, IN EFI_PEI_FILE_HANDLE FileHandle ) -/*++ - -Routine Description: - - Provide a callout to the security verification service. - -Arguments: +; - PeiServices - The PEI core services table. - CurrentPeimAddress - Pointer to the Firmware File under investigation. +/** -Returns: + Gets the pointer to the HOB List. - EFI_SUCCESS - Image is OK - EFI_SECURITY_VIOLATION - Image is illegal ---*/ -; + @param PeiServices The PEI core services table. + @param HobList Pointer to the HOB List. + @retval EFI_SUCCESS Get the pointer of HOB List + @retval EFI_NOT_AVAILABLE_YET the HOB List is not yet published + @retval EFI_INVALID_PARAMETER HobList is NULL (in debug mode) +**/ EFI_STATUS EFIAPI PeiGetHobList ( IN CONST EFI_PEI_SERVICES **PeiServices, IN OUT VOID **HobList ) -/*++ - -Routine Description: - - Gets the pointer to the HOB List. - -Arguments: - - PeiServices - The PEI core services table. - HobList - Pointer to the HOB List. +; -Returns: +/** + Add a new HOB to the HOB List. - EFI_SUCCESS - Get the pointer of HOB List - EFI_NOT_AVAILABLE_YET - the HOB List is not yet published - EFI_INVALID_PARAMETER - HobList is NULL (in debug mode) + @param PeiServices - The PEI core services table. + @param Type - Type of the new HOB. + @param Length - Length of the new HOB to allocate. + @param Hob - Pointer to the new HOB. ---*/ -; + @return EFI_SUCCESS Success to create hob. + @retval EFI_INVALID_PARAMETER if Hob is NULL + @retval EFI_NOT_AVAILABLE_YET if HobList is still not available. + @retval EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist. +**/ EFI_STATUS EFIAPI PeiCreateHob ( @@ -782,58 +603,47 @@ PeiCreateHob ( IN UINT16 Length, IN OUT VOID **Hob ) -/*++ - -Routine Description: - - Add a new HOB to the HOB List. - -Arguments: +; - PeiServices - The PEI core services table. - Type - Type of the new HOB. - Length - Length of the new HOB to allocate. - Hob - Pointer to the new HOB. +/** -Returns: + Builds a Handoff Information Table HOB - Status - EFI_SUCCESS - - EFI_INVALID_PARAMETER if Hob is NULL - - EFI_NOT_AVAILABLE_YET if HobList is still not available. - - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist. + @param BootMode - Current Bootmode + @param MemoryBegin - Start Memory Address. + @param MemoryLength - Length of Memory. ---*/ -; + @return EFI_SUCCESS Always success to initialize HOB. +**/ EFI_STATUS PeiCoreBuildHobHandoffInfoTable ( IN EFI_BOOT_MODE BootMode, IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength ) -/*++ - -Routine Description: - - Builds a Handoff Information Table HOB - -Arguments: - - BootMode - Current Bootmode - MemoryBegin - Start Memory Address. - MemoryLength - Length of Memory. - -Returns: - - EFI_SUCCESS - ---*/ ; // // FFS Fw Volume support functions // +/** + Given the input file pointer, search for the next matching file in the + FFS volume as defined by SearchType. The search starts from FileHeader inside + the Firmware Volume defined by FwVolHeader. + + + @param PeiServices Pointer to the PEI Core Services Table. + @param SearchType Filter to find only files of this type. + Type EFI_FV_FILETYPE_ALL causes no filtering to be done. + @param VolumeHandle Pointer to the FV header of the volume to search. + @param FileHandle Pointer to the current file from which to begin searching. + This pointer will be updated upon return to reflect the file found. + @retval EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to find next file in given volume + +**/ EFI_STATUS EFIAPI PeiFfsFindNextFile ( @@ -842,32 +652,23 @@ PeiFfsFindNextFile ( IN EFI_PEI_FV_HANDLE FwVolHeader, IN OUT EFI_PEI_FILE_HANDLE *FileHeader ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume as defined by SearchType. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - - SearchType - Filter to find only files of this type. - Type EFI_FV_FILETYPE_ALL causes no filtering to be done. +; - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. +/** + Given the input file pointer, search for the next matching section in the + FFS volume. - FileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file found. -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS + @param PeiServices Pointer to the PEI Core Services Table. + @param SectionType Filter to find only sections of this type. + @param FileHandle Pointer to the current file to search. + @param SectionData Pointer to the Section matching SectionType in FfsFileHeader. + NULL if section not found ---*/ -; + @retval EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to find section data in given file +**/ EFI_STATUS EFIAPI PeiFfsFindSectionData ( @@ -876,26 +677,19 @@ PeiFfsFindSectionData ( IN EFI_PEI_FILE_HANDLE FfsFileHeader, IN OUT VOID **SectionData ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching section in the - FFS volume. +; -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - SearchType - Filter to find only sections of this type. - FfsFileHeader - Pointer to the current file to search. - SectionData - Pointer to the Section matching SectionType in FfsFileHeader. - - NULL if section not found +/** + search the firmware volumes by index -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS + @param PeiServices The PEI core services table. + @param Instance Instance of FV to find + @param VolumeHandle Pointer to found Volume. ---*/ -; + @retval EFI_INVALID_PARAMETER FwVolHeader is NULL + @retval EFI_SUCCESS Firmware volume instance successfully found. +**/ EFI_STATUS EFIAPI PeiFvFindNextVolume ( @@ -903,61 +697,44 @@ PeiFvFindNextVolume ( IN UINTN Instance, IN OUT EFI_PEI_FV_HANDLE *FwVolHeader ) -/*++ - -Routine Description: - - Return the BFV location - - BugBug -- Move this to the location of this code to where the - other FV and FFS support code lives. - Also, update to use FindFV for instances #'s >= 1. - -Arguments: - - PeiServices - The PEI core services table. - Instance - Instance of FV to find - FwVolHeader - Pointer to contain the data to return - -Returns: - Pointer to the Firmware Volume instance requested - - EFI_INVALID_PARAMETER - FwVolHeader is NULL - - EFI_SUCCESS - Firmware volume instance successfully found. - ---*/ ; // // Memory support functions // +/** + + Initialize the memory services. + + + @param PrivateData Add parameter description + @param SecCoreData Points to a data structure containing information about the PEI core's operating + environment, such as the size and location of temporary RAM, the stack location and + the BFV location. + @param OldCoreData Pointer to the PEI Core data. + NULL if being run in non-permament memory mode. + +**/ VOID InitializeMemoryServices ( IN PEI_CORE_INSTANCE *PrivateData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *OldCoreData ) -/*++ - -Routine Description: - - Initialize the memory services. - -Arguments: +; - PeiServices - The PEI core services table. - PeiStartupDescriptor - Information and services provided by SEC phase. - OldCoreData - Pointer to the PEI Core data. - NULL if being run in non-permament memory mode. +/** -Returns: + Install the permanent memory is now available. + Creates HOB (PHIT and Stack). - None + @param PeiServices - The PEI core services table. + @param MemoryBegin - Start of memory address. + @param MemoryLength - Length of memory. ---*/ -; + @return EFI_SUCCESS Always success. +**/ EFI_STATUS EFIAPI PeiInstallPeiMemory ( @@ -965,26 +742,26 @@ PeiInstallPeiMemory ( IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength ) -/*++ - -Routine Description: - - Install the permanent memory is now available. - Creates HOB (PHIT and Stack). +; -Arguments: +/** - PeiServices - The PEI core services table. - MemoryBegin - Start of memory address. - MemoryLength - Length of memory. + Memory allocation service on permanent memory, + not usable prior to the memory installation. -Returns: - Status - EFI_SUCCESS + @param PeiServices - The PEI core services table. + @param MemoryType - Type of memory to allocate. + @param Pages - Number of pages to allocate. + @param Memory - Pointer of memory allocated. ---*/ -; + @retval EFI_SUCCESS The allocation was successful + @retval EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported. + @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available + @retval EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement + to allocate the number of pages. +**/ EFI_STATUS EFIAPI PeiAllocatePages ( @@ -993,32 +770,22 @@ PeiAllocatePages ( IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory ) -/*++ - -Routine Description: - - Memory allocation service on permanent memory, - not usable prior to the memory installation. +; -Arguments: +/** - PeiServices - The PEI core services table. - Type - Type of allocation. - MemoryType - Type of memory to allocate. - Pages - Number of pages to allocate. - Memory - Pointer of memory allocated. + Memory allocation service on the CAR. -Returns: - Status - EFI_SUCCESS The allocation was successful - EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported. - EFI_NOT_AVAILABLE_YET Called with permanent memory not available - EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement - to allocate the number of pages. + @param PeiServices - The PEI core services table. + @param Size - Amount of memory required + @param Buffer - Address of pointer to the buffer ---*/ -; + @retval EFI_SUCCESS The allocation was successful + @retval EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement + to allocate the requested size. +**/ EFI_STATUS EFIAPI PeiAllocatePool ( @@ -1026,29 +793,23 @@ PeiAllocatePool ( IN UINTN Size, OUT VOID **Buffer ) -/*++ - -Routine Description: - - Memory allocation service on the CAR. - -Arguments: - - PeiServices - The PEI core services table. +; - Size - Amount of memory required +/** - Buffer - Address of pointer to the buffer + Routine for load image file. -Returns: - Status - EFI_SUCCESS The allocation was successful - EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement - to allocate the requested size. + @param PeiServices - The PEI core services table. + @param FileHandle - Pointer to the FFS file header of the image. + @param EntryPoint - Pointer to entry point of specified image file for output. + @param AuthenticationState - Pointer to attestation authentication state of image. ---*/ -; + @retval EFI_SUCCESS - Image is successfully loaded. + @retval EFI_NOT_FOUND - Fail to locate necessary PPI + @retval Others - Fail to load file. +**/ EFI_STATUS PeiLoadImage ( IN EFI_PEI_SERVICES **PeiServices, @@ -1056,28 +817,24 @@ PeiLoadImage ( OUT EFI_PHYSICAL_ADDRESS *EntryPoint, OUT UINT32 *AuthenticationState ) -/*++ - -Routine Description: - - Get entry point of a Peim file. - -Arguments: - - PeiServices - Calling context. - - PeimFileHeader - Peim file's header. +; - EntryPoint - Entry point of that Peim file. +/** -Returns: + Core version of the Status Code reporter - Status code. ---*/ -; + @param PeiServices The PEI core services table. + @param CodeType Type of Status Code. + @param Value Value to output for Status Code. + @param Instance Instance Number of this status code. + @param CallerId ID of the caller of this status code. + @param Data Optional data associated with this status code. + @retval EFI_SUCCESS if status code is successfully reported + @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed +**/ EFI_STATUS EFIAPI PeiReportStatusCode ( @@ -1088,81 +845,56 @@ PeiReportStatusCode ( IN CONST EFI_GUID *CallerId, IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL ) -/*++ - -Routine Description: - - Core version of the Status Code reporter - -Arguments: - - PeiServices - The PEI core services table. - - CodeType - Type of Status Code. - - Value - Value to output for Status Code. - - Instance - Instance Number of this status code. - - CallerId - ID of the caller of this status code. +; - Data - Optional data associated with this status code. +/** -Returns: + Core version of the Reset System - Status - EFI_SUCCESS if status code is successfully reported - - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed ---*/ -; + @param PeiServices - The PEI core services table. + @retval EFI_NOT_AVAILABLE_YET PPI not available yet. + @retval EFI_DEVICE_ERROR Did not reset system. + Otherwise, resets the system. +**/ EFI_STATUS EFIAPI PeiResetSystem ( IN CONST EFI_PEI_SERVICES **PeiServices ) -/*++ - -Routine Description: - - Core version of the Reset System - -Arguments: +; - PeiServices - The PEI core services table. +/** -Returns: + Initialize PeiCore Fv List. - Status - EFI_NOT_AVAILABLE_YET. PPI not available yet. - - EFI_DEVICE_ERROR. Did not reset system. - Otherwise, resets the system. + @param PrivateData - Pointer to PEI_CORE_INSTANCE. + @param SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF. ---*/ -; + @return NONE +**/ VOID PeiInitializeFv ( IN PEI_CORE_INSTANCE *PrivateData, IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData ) -/*++ - -Routine Description: +; - Initialize PeiCore Fv List. +/** + Process Firmware Volum Information once FvInfoPPI install. -Arguments: - PrivateData - Pointer to PEI_CORE_INSTANCE. - SecCoreData - Pointer to EFI_SEC_PEI_HAND_OFF. -Returns: - NONE + @param PeiServices - General purpose services available to every PEIM. + @param NotifyDescriptor EDES_TODO: Add parameter description + @param Ppi EDES_TODO: Add parameter description ---*/ -; + @retval EFI_SUCCESS if the interface could be successfully installed +**/ EFI_STATUS EFIAPI FirmwareVolmeInfoPpiNotifyCallback ( @@ -1170,25 +902,21 @@ FirmwareVolmeInfoPpiNotifyCallback ( IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi ) -/*++ - -Routine Description: - - Process Firmware Volum Information once FvInfoPPI install. - -Arguments: +; - PeiServices - General purpose services available to every PEIM. +/** -Returns: + Given the input VolumeHandle, search for the next matching name file. - Status - EFI_SUCCESS if the interface could be successfully - installed ---*/ -; + @param FileName - File name to search. + @param VolumeHandle - The current FV to search. + @param FileHandle - Pointer to the file matching name in VolumeHandle. + - NULL if file not found + @return EFI_STATUS +**/ EFI_STATUS EFIAPI PeiFfsFindFileByName ( @@ -1196,103 +924,55 @@ PeiFfsFindFileByName ( IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_PEI_FILE_HANDLE *FileHandle ) -/*++ +; -Routine Description: +/** - Given the input VolumeHandle, search for the next matching name file. + Returns information about a specific file. -Arguments: - FileName - File name to search. - VolumeHandle - The current FV to search. - FileHandle - Pointer to the file matching name in VolumeHandle. - - NULL if file not found -Returns: - EFI_STATUS - ---*/ -; + @param FileHandle - The handle to file. + @param FileInfo - Pointer to the file information. + @retval EFI_INVALID_PARAMETER Invalid FileHandle or FileInfo. + @retval EFI_SUCCESS Success to collect file info. +**/ EFI_STATUS EFIAPI PeiFfsGetFileInfo ( IN EFI_PEI_FILE_HANDLE FileHandle, OUT EFI_FV_FILE_INFO *FileInfo ) -/*++ - -Routine Description: +; - Collect information of given file. +/** -Arguments: - FileHandle - The handle to file. - FileInfo - Pointer to the file information. + Collect information of given Fv Volume. -Returns: - EFI_STATUS - ---*/ -; + @param VolumeHandle - The handle to Fv Volume. + @param VolumeInfo - The pointer to volume information. + @retval EFI_INVALID_PARAMETER VolumeInfo is NULL + @retval EFI_SUCCESS Success to collect fv info. +**/ EFI_STATUS EFIAPI PeiFfsGetVolumeInfo ( IN EFI_PEI_FV_HANDLE VolumeHandle, OUT EFI_FV_INFO *VolumeInfo ) -/*++ - -Routine Description: - - Collect information of given Fv Volume. - -Arguments: - VolumeHandle - The handle to Fv Volume. - VolumeInfo - The pointer to volume information. - -Returns: - EFI_STATUS - ---*/ -; - - -EFI_STATUS -EFIAPI -PeiRegisterForShadow ( - IN EFI_PEI_FILE_HANDLE FileHandle - ) -/*++ - -Routine Description: - - This routine enable a PEIM to register itself to shadow when PEI Foundation - discovery permanent memory. - -Arguments: - FileHandle - File handle of a PEIM. - -Returns: - EFI_NOT_FOUND - The file handle doesn't point to PEIM itself. - EFI_ALREADY_STARTED - Indicate that the PEIM has been registered itself. - EFI_SUCCESS - Successfully to register itself. - ---*/ ; - /** This routine enable a PEIM to register itself to shadow when PEI Foundation discovery permanent memory. - @param FileHandle File handle of a PEIM. + @param FileHandle File handle of a PEIM. - @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself. - @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself. - @retval EFI_SUCCESS Successfully to register itself. + @retval EFI_NOT_FOUND The file handle doesn't point to PEIM itself. + @retval EFI_ALREADY_STARTED Indicate that the PEIM has been registered itself. + @retval EFI_SUCCESS Successfully to register itself. **/ EFI_STATUS @@ -1302,6 +982,23 @@ PeiRegisterForShadow ( ) ; +/** + Given the input file pointer, search for the next matching file in the + FFS volume as defined by SearchType. The search starts from FileHeader inside + the Firmware Volume defined by FwVolHeader. + + + @param FvHandle Pointer to the FV header of the volume to search + @param FileName File name + @param SearchType Filter to find only files of this type. + Type EFI_FV_FILETYPE_ALL causes no filtering to be done. + @param FileHandle This parameter must point to a valid FFS volume. + @param AprioriFile Pointer to AprioriFile image in this FV if has + + @return EFI_NOT_FOUND No files matching the search criteria were found + @retval EFI_SUCCESS Success to search given file + +**/ EFI_STATUS PeiFindFileEx ( IN CONST EFI_PEI_FV_HANDLE FvHandle, @@ -1310,63 +1007,34 @@ PeiFindFileEx ( IN OUT EFI_PEI_FILE_HANDLE *FileHandle, IN OUT EFI_PEI_FV_HANDLE *AprioriFile OPTIONAL ) -/*++ - -Routine Description: - Given the input file pointer, search for the next matching file in the - FFS volume as defined by SearchType. The search starts from FileHeader inside - the Firmware Volume defined by FwVolHeader. - -Arguments: - PeiServices - Pointer to the PEI Core Services Table. - SearchType - Filter to find only files of this type. - Type EFI_FV_FILETYPE_ALL causes no filtering to be done. - FwVolHeader - Pointer to the FV header of the volume to search. - This parameter must point to a valid FFS volume. - FileHeader - Pointer to the current file from which to begin searching. - This pointer will be updated upon return to reflect the file found. - Flag - Indicator for if this is for PEI Dispath search - -Returns: - EFI_NOT_FOUND - No files matching the search criteria were found - EFI_SUCCESS - ---*/ ; -VOID -InitializeImageServices ( - IN PEI_CORE_INSTANCE *PrivateData, - IN PEI_CORE_INSTANCE *OldCoreData - ) -/*++ - -Routine Description: +/** Install Pei Load File PPI. -Arguments: - - PrivateData - Pointer to PEI_CORE_INSTANCE. - OldCoreData - Pointer to PEI_CORE_INSTANCE. -Returns: + @param PrivateData - Pointer to PEI_CORE_INSTANCE. + @param OldCoreData - Pointer to PEI_CORE_INSTANCE. - NONE. - ---*/ +**/ +VOID +InitializeImageServices ( + IN PEI_CORE_INSTANCE *PrivateData, + IN PEI_CORE_INSTANCE *OldCoreData + ) ; /** Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob. - @param PeiServices Pointer to the PEI Core Services Table. - @param FileHandle File handle of a Fv type file. + @param PeiServices Pointer to the PEI Core Services Table. + @param FileHandle File handle of a Fv type file. @param AuthenticationState Pointer to attestation authentication state of image. - @retval EFI_NOT_FOUND FV image can't be found. - @retval EFI_SUCCESS Successfully to process it. + @retval EFI_NOT_FOUND FV image can't be found. + @retval EFI_SUCCESS Successfully to process it. **/ EFI_STATUS diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index 85dbbd1a6a..056165e689 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -1,5 +1,6 @@ /** @file - + Pei Core Main Entry Point + Copyright (c) 2006, 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 @@ -9,21 +10,11 @@ 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: - - PeiMain.c - -Abstract: - - Pei Core Main Entry Point - -Revision History - **/ #include -static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { +STATIC EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), &gEfiPeiMemoryDiscoveredPpiGuid, NULL @@ -33,7 +24,7 @@ static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { // Pei Core Module Variables // // -static EFI_PEI_SERVICES mPS = { +STATIC EFI_PEI_SERVICES gPs = { { PEI_SERVICES_SIGNATURE, PEI_SERVICES_REVISION, @@ -74,41 +65,35 @@ static EFI_PEI_SERVICES mPS = { PeiRegisterForShadow }; -EFI_STATUS -EFIAPI -PeiCore ( - IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, - IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, - IN VOID *Data - ) -/*++ - -Routine Description: +/** The entry routine to Pei Core, invoked by PeiMain during transition from SEC to PEI. After switching stack in the PEI core, it will restart with the old core data. -Arguments: - SecCoreData - Points to a data structure containing information about the PEI core's operating + @param SecCoreData Points to a data structure containing information about the PEI core's operating environment, such as the size and location of temporary RAM, the stack location and the BFV location. - PpiList - Points to a list of one or more PPI descriptors to be installed initially by the PEI core. + @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 - Data - Pointer to old core data that is used to initialize the + @param Data Pointer to old core data that is used to initialize the core's data areas. -Returns: + @retval EFI_NOT_FOUND Never reach - This function never returns - EFI_NOT_FOUND - Never reach - ---*/ +**/ +EFI_STATUS +EFIAPI +PeiCore ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, + IN VOID *Data + ) { PEI_CORE_INSTANCE PrivateData; EFI_STATUS Status; @@ -144,14 +129,14 @@ Returns: CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo; PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg; - CopyMem (&PrivateData.ServiceTableShadow, &mPS, sizeof (mPS)); + CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs)); PrivateData.ServiceTableShadow.CpuIo = CpuIo; PrivateData.ServiceTableShadow.PciCfg = PciCfg; } else { ZeroMem (&PrivateData, sizeof (PEI_CORE_INSTANCE)); PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE; - CopyMem (&PrivateData.ServiceTableShadow, &mPS, sizeof (mPS)); + CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs)); } PrivateData.PS = &PrivateData.ServiceTableShadow; diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index feae0fbb9f..fa60d82a5b 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -1,5 +1,6 @@ /** @file - + EFI PEI Core PPI services + Copyright (c) 2006, 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 @@ -9,51 +10,43 @@ 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: - - Ppi.c +**/ -Abstract: +#include - EFI PEI Core PPI services +/** -Revision History + Initialize PPI services. -**/ -#include + @param PrivateData Pointer to the PEI Core data. + @param OldCoreData Pointer to old PEI Core data. + NULL if being run in non-permament memory mode. +**/ VOID InitializePpiServices ( IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_INSTANCE *OldCoreData ) -/*++ - -Routine Description: - - Initialize PPI services. - -Arguments: - - PeiServices - The PEI core services table. - OldCoreData - Pointer to the PEI Core data. - NULL if being run in non-permament memory mode. - -Returns: - Nothing - ---*/ { if (OldCoreData == NULL) { PrivateData->PpiData.NotifyListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; PrivateData->PpiData.DispatchListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; PrivateData->PpiData.LastDispatchedNotify = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; } - - return; } +/** + + Migrate the Hob list from the CAR stack to PEI installed memory. + + @param PeiServices The PEI core services table. + @param OldCheckingBottom The old checking bottom. + @param OldCheckingTop The old checking top. + @param NewHandOffHob The new handoff HOB list. + +**/ VOID ConvertPpiPointers ( IN CONST EFI_PEI_SERVICES **PeiServices, @@ -61,22 +54,6 @@ ConvertPpiPointers ( IN UINTN OldCheckingTop, IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob ) -/*++ - -Routine Description: - - Migrate the Hob list from the CAR stack to PEI installed memory. - -Arguments: - - PeiServices - The PEI core services table. - OldCheckingBottom - The old checking bottom. - OldCheckingTop - The old checking top. - NewHandOffHob - The new handoff HOB list. - -Returns: - ---*/ { PEI_CORE_INSTANCE *PrivateData; UINT8 Index; @@ -132,33 +109,25 @@ Returns: } } +/** + Install PPI services. + @param PeiServices - Pointer to the PEI Service Table + @param PpiList - Pointer to a list of PEI PPI Descriptors. + + @retval EFI_SUCCESS - if all PPIs in PpiList are successfully installed. + @retval EFI_INVALID_PARAMETER - if PpiList is NULL pointer + @retval EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid + @retval EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI + +**/ EFI_STATUS EFIAPI PeiInstallPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList ) -/*++ - -Routine Description: - - Install PPI services. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - PpiList - Pointer to a list of PEI PPI Descriptors. - -Returns: - - EFI_SUCCESS - if all PPIs in PpiList are successfully installed. - EFI_INVALID_PARAMETER - if PpiList is NULL pointer - EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid - EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI - ---*/ { PEI_CORE_INSTANCE *PrivateData; INTN Index; @@ -230,7 +199,20 @@ Returns: return EFI_SUCCESS; } +/** + + Re-Install PPI services. + + @param PeiServices - Pointer to the PEI Service Table + @param OldPpi - Pointer to the old PEI PPI Descriptors. + @param NewPpi - Pointer to the new PEI PPI Descriptors. + @retval EFI_SUCCESS - if the operation was successful + @retval EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL + @retval EFI_INVALID_PARAMETER - if NewPpi is not valid + @retval EFI_NOT_FOUND - if the PPI was not in the database + +**/ EFI_STATUS EFIAPI PeiReInstallPpi ( @@ -238,26 +220,6 @@ PeiReInstallPpi ( IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi ) -/*++ - -Routine Description: - - Re-Install PPI services. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - OldPpi - Pointer to the old PEI PPI Descriptors. - NewPpi - Pointer to the new PEI PPI Descriptors. - -Returns: - - EFI_SUCCESS - if the operation was successful - EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL - EFI_INVALID_PARAMETER - if NewPpi is not valid - EFI_NOT_FOUND - if the PPI was not in the database - ---*/ { PEI_CORE_INSTANCE *PrivateData; INTN Index; @@ -308,7 +270,22 @@ Returns: return EFI_SUCCESS; } +/** + + Locate a given named PPI. + + @param PeiServices - Pointer to the PEI Service Table + @param Guid - Pointer to GUID of the PPI. + @param Instance - Instance Number to discover. + @param PpiDescriptor - Pointer to reference the found descriptor. If not NULL, + returns a pointer to the descriptor (includes flags, etc) + @param Ppi - Pointer to reference the found PPI + + @retval EFI_SUCCESS if the PPI is in the database + @retval EFI_NOT_FOUND if the PPI is not in the database + +**/ EFI_STATUS EFIAPI PeiLocatePpi ( @@ -318,26 +295,6 @@ PeiLocatePpi ( IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi ) -/*++ - -Routine Description: - - Locate a given named PPI. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - Guid - Pointer to GUID of the PPI. - Instance - Instance Number to discover. - PpiDescriptor - Pointer to reference the found descriptor. If not NULL, - returns a pointer to the descriptor (includes flags, etc) - Ppi - Pointer to reference the found PPI - -Returns: - - Status - EFI_SUCCESS if the PPI is in the database - EFI_NOT_FOUND if the PPI is not in the database ---*/ { PEI_CORE_INSTANCE *PrivateData; INTN Index; @@ -383,31 +340,25 @@ Returns: return EFI_NOT_FOUND; } +/** + Install a notification for a given PPI. + + + @param PeiServices - Pointer to the PEI Service Table + @param NotifyList - Pointer to list of Descriptors to notify upon. + + @retval EFI_SUCCESS if successful + @retval EFI_OUT_OF_RESOURCES if no space in the database + @retval EFI_INVALID_PARAMETER if not a good decriptor + +**/ EFI_STATUS EFIAPI PeiNotifyPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList ) -/*++ - -Routine Description: - - Install a notification for a given PPI. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - NotifyList - Pointer to list of Descriptors to notify upon. - -Returns: - - Status - EFI_SUCCESS if successful - EFI_OUT_OF_RESOURCES if no space in the database - EFI_INVALID_PARAMETER if not a good decriptor - ---*/ { PEI_CORE_INSTANCE *PrivateData; INTN Index; @@ -507,24 +458,17 @@ Returns: } -VOID -ProcessNotifyList ( - IN PEI_CORE_INSTANCE *PrivateData - ) -/*++ - -Routine Description: +/** Process the Notify List at dispatch level. -Arguments: - - PeiServices - Pointer to the PEI Service Table - -Returns: - ---*/ + @param PrivateData PeiCore's private data structure. +**/ +VOID +ProcessNotifyList ( + IN PEI_CORE_INSTANCE *PrivateData + ) { INTN TempValue; @@ -577,6 +521,18 @@ Returns: return; } +/** + + Dispatch notifications. + + @param PrivateData PeiCore's private data structure + @param NotifyType Type of notify to fire. + @param InstallStartIndex Install Beginning index. + @param InstallStopIndex Install Ending index. + @param NotifyStartIndex Notify Beginning index. + @param NotifyStopIndex Notify Ending index. + +**/ VOID DispatchNotify ( IN PEI_CORE_INSTANCE *PrivateData, @@ -586,25 +542,6 @@ DispatchNotify ( IN INTN NotifyStartIndex, IN INTN NotifyStopIndex ) -/*++ - -Routine Description: - - Dispatch notifications. - -Arguments: - - PeiServices - Pointer to the PEI Service Table - NotifyType - Type of notify to fire. - InstallStartIndex - Install Beginning index. - InstallStopIndex - Install Ending index. - NotifyStartIndex - Notify Beginning index. - NotifyStopIndex - Notify Ending index. - -Returns: None - ---*/ - { INTN Index1; INTN Index2; diff --git a/MdeModulePkg/Core/Pei/Reset/Reset.c b/MdeModulePkg/Core/Pei/Reset/Reset.c index 4fcb59f372..f71a23375f 100644 --- a/MdeModulePkg/Core/Pei/Reset/Reset.c +++ b/MdeModulePkg/Core/Pei/Reset/Reset.c @@ -1,5 +1,6 @@ /** @file - + Pei Core Reset System Support + Copyright (c) 2006, 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 @@ -9,43 +10,27 @@ 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: +**/ - Reset.c +#include -Abstract: +/** - Pei Core Reset System Support + Core version of the Reset System -Revision History -**/ + @param PeiServices - The PEI core services table. -#include + @retval EFI_NOT_AVAILABLE_YET PPI not available yet. + @retval EFI_DEVICE_ERROR Did not reset system. + Otherwise, resets the system. +**/ EFI_STATUS EFIAPI PeiResetSystem ( IN CONST EFI_PEI_SERVICES **PeiServices ) -/*++ - -Routine Description: - - Core version of the Reset System - -Arguments: - - PeiServices - The PEI core services table. - -Returns: - - Status - EFI_NOT_AVAILABLE_YET. PPI not available yet. - - EFI_DEVICE_ERROR. Did not reset system. - - Otherwise, resets the system. - ---*/ { EFI_STATUS Status; EFI_PEI_RESET_PPI *ResetPpi; diff --git a/MdeModulePkg/Core/Pei/Security/Security.c b/MdeModulePkg/Core/Pei/Security/Security.c index ac02f594f3..cf33447602 100644 --- a/MdeModulePkg/Core/Pei/Security/Security.c +++ b/MdeModulePkg/Core/Pei/Security/Security.c @@ -1,5 +1,6 @@ /** @file - + EFI PEI Core Security services + Copyright (c) 2006, 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 @@ -9,19 +10,21 @@ 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: +**/ - Security.c +#include -Abstract: +/** - EFI PEI Core Security services + Provide a callback for when the security PPI is installed. -**/ + @param PeiServices - The PEI core services table. + @param NotifyDescriptor - The descriptor for the notification event. + @param Ppi - Pointer to the PPI in question. -#include + @return Always success -STATIC +**/ EFI_STATUS EFIAPI SecurityPpiNotifyCallback ( @@ -30,33 +33,27 @@ SecurityPpiNotifyCallback ( IN VOID *Ppi ); -static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = { +STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = { EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, &gEfiPeiSecurity2PpiGuid, SecurityPpiNotifyCallback }; -VOID -InitializeSecurityServices ( - IN EFI_PEI_SERVICES **PeiServices, - IN PEI_CORE_INSTANCE *OldCoreData - ) -/*++ - -Routine Description: +/** Initialize the security services. -Arguments: - PeiServices - The PEI core services table. - OldCoreData - Pointer to the old core data. - NULL if being run in non-permament memory mode. -Returns: + @param PeiServices - The PEI core services table. + @param OldCoreData - Pointer to the old core data. + NULL if being run in non-permament memory mode. - None - ---*/ +**/ +VOID +InitializeSecurityServices ( + IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CORE_INSTANCE *OldCoreData + ) { if (OldCoreData == NULL) { PeiServicesNotifyPpi (&mNotifyList); @@ -64,7 +61,17 @@ Returns: return; } -STATIC +/** + + Provide a callback for when the security PPI is installed. + + @param PeiServices - The PEI core services table. + @param NotifyDescriptor - The descriptor for the notification event. + @param Ppi - Pointer to the PPI in question. + + @return Always success + +**/ EFI_STATUS EFIAPI SecurityPpiNotifyCallback ( @@ -72,23 +79,6 @@ SecurityPpiNotifyCallback ( IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi ) -/*++ - -Routine Description: - - Provide a callback for when the security PPI is installed. - -Arguments: - - PeiServices - The PEI core services table. - NotifyDescriptor - The descriptor for the notification event. - Ppi - Pointer to the PPI in question. - -Returns: - - EFI_SUCCESS - The function is successfully processed. - ---*/ { PEI_CORE_INSTANCE *PrivateData; @@ -106,29 +96,25 @@ Returns: return EFI_SUCCESS; } -EFI_STATUS -VerifyPeim ( - IN PEI_CORE_INSTANCE *PrivateData, - IN EFI_PEI_FV_HANDLE VolumeHandle, - IN EFI_PEI_FILE_HANDLE FileHandle - ) -/*++ - -Routine Description: +/** Provide a callout to the security verification service. -Arguments: - PeiServices - The PEI core services table. - CurrentPeimAddress - Pointer to the Firmware File under investigation. + @param PrivateData PeiCore's private data structure + @param VolumeHandle Handle of FV + @param FileHandle Handle of PEIM's ffs -Returns: + @retval EFI_SUCCESS Image is OK + @retval EFI_SECURITY_VIOLATION Image is illegal - EFI_SUCCESS - Image is OK - EFI_SECURITY_VIOLATION - Image is illegal - ---*/ +**/ +EFI_STATUS +VerifyPeim ( + IN PEI_CORE_INSTANCE *PrivateData, + IN EFI_PEI_FV_HANDLE VolumeHandle, + IN EFI_PEI_FILE_HANDLE FileHandle + ) { EFI_STATUS Status; UINT32 AuthenticationStatus; @@ -161,26 +147,19 @@ Returns: } +/** + Verify a Firmware volume. + + @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration + + @retval EFI_SUCCESS - Firmware Volume is legal + @retval EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test + +**/ EFI_STATUS VerifyFv ( IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress ) -/*++ - -Routine Description: - - Verify a Firmware volume - -Arguments: - - CurrentFvAddress - Pointer to the current Firmware Volume under consideration - -Returns: - - EFI_SUCCESS - Firmware Volume is legal - EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test - ---*/ { // // Right now just pass the test. Future can authenticate and/or check the diff --git a/MdeModulePkg/Core/Pei/StatusCode/StatusCode.c b/MdeModulePkg/Core/Pei/StatusCode/StatusCode.c index bd8cb26e61..8e271d5e63 100644 --- a/MdeModulePkg/Core/Pei/StatusCode/StatusCode.c +++ b/MdeModulePkg/Core/Pei/StatusCode/StatusCode.c @@ -1,5 +1,6 @@ /** @file - + Pei Core Status Code Support + Copyright (c) 2006, 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 @@ -9,20 +10,26 @@ 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: +**/ - StatusCode.c +#include -Abstract: +/** - Pei Core Status Code Support + Core version of the Status Code reporter -Revision History -**/ + @param PeiServices The PEI core services table. + @param CodeType Type of Status Code. + @param Value Value to output for Status Code. + @param Instance Instance Number of this status code. + @param CallerId ID of the caller of this status code. + @param Data Optional data associated with this status code. -#include + @retval EFI_SUCCESS if status code is successfully reported + @retval EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed +**/ EFI_STATUS EFIAPI PeiReportStatusCode ( @@ -33,32 +40,6 @@ PeiReportStatusCode ( IN CONST EFI_GUID *CallerId, IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL ) -/*++ - -Routine Description: - - Core version of the Status Code reporter - -Arguments: - - PeiServices - The PEI core services table. - - CodeType - Type of Status Code. - - Value - Value to output for Status Code. - - Instance - Instance Number of this status code. - - CallerId - ID of the caller of this status code. - - Data - Optional data associated with this status code. - -Returns: - - Status - EFI_SUCCESS if status code is successfully reported - - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed - ---*/ { EFI_STATUS Status; EFI_PEI_PROGRESS_CODE_PPI *StatusCodePpi; @@ -87,7 +68,6 @@ Returns: return Status; } - return EFI_NOT_AVAILABLE_YET; } -- 2.39.2