MdeModulePkg: Apply uncrustify changes

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737

Apply uncrustify changes to .c/.h files in the MdeModulePkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:02 -08:00
committed by mergify[bot]
parent 7c7184e201
commit 1436aea4d5
994 changed files with 107608 additions and 101311 deletions

View File

@@ -29,25 +29,22 @@ PeiGetBootMode (
IN OUT EFI_BOOT_MODE *BootMode
)
{
PEI_CORE_INSTANCE *PrivateData;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
PEI_CORE_INSTANCE *PrivateData;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
if (BootMode == NULL) {
return EFI_INVALID_PARAMETER;
}
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
HandOffHob = (PrivateData->HobList.HandoffInformationTable);
*BootMode = HandOffHob->BootMode;
HandOffHob = (PrivateData->HobList.HandoffInformationTable);
*BootMode = HandOffHob->BootMode;
return EFI_SUCCESS;
}
/**
This service enables PEIMs to update the boot mode variable.
@@ -65,16 +62,14 @@ PeiSetBootMode (
IN EFI_BOOT_MODE BootMode
)
{
PEI_CORE_INSTANCE *PrivateData;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
PEI_CORE_INSTANCE *PrivateData;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
HandOffHob = (PrivateData->HobList.HandoffInformationTable);
HandOffHob = (PrivateData->HobList.HandoffInformationTable);
HandOffHob->BootMode = BootMode;
return EFI_SUCCESS;
}

View File

@@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// This default instance of EFI_PEI_CPU_IO_PPI install assigned to EFI_PEI_SERVICE.CpuIo
/// when PeiCore's initialization.
///
EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi = {
EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi = {
{
PeiDefaultMemRead,
PeiDefaultMemWrite
@@ -66,12 +66,12 @@ EFI_PEI_CPU_IO_PPI gPeiDefaultCpuIoPpi = {
EFI_STATUS
EFIAPI
PeiDefaultMemRead (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -99,12 +99,12 @@ PeiDefaultMemRead (
EFI_STATUS
EFIAPI
PeiDefaultMemWrite (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -131,12 +131,12 @@ PeiDefaultMemWrite (
EFI_STATUS
EFIAPI
PeiDefaultIoRead (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -163,12 +163,12 @@ PeiDefaultIoRead (
EFI_STATUS
EFIAPI
PeiDefaultIoWrite (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN EFI_PEI_CPU_IO_PPI_WIDTH Width,
IN UINT64 Address,
IN UINTN Count,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -189,9 +189,9 @@ PeiDefaultIoWrite (
UINT8
EFIAPI
PeiDefaultIoRead8 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -212,9 +212,9 @@ PeiDefaultIoRead8 (
UINT16
EFIAPI
PeiDefaultIoRead16 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -235,9 +235,9 @@ PeiDefaultIoRead16 (
UINT32
EFIAPI
PeiDefaultIoRead32 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -258,9 +258,9 @@ PeiDefaultIoRead32 (
UINT64
EFIAPI
PeiDefaultIoRead64 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -279,10 +279,10 @@ PeiDefaultIoRead64 (
VOID
EFIAPI
PeiDefaultIoWrite8 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT8 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT8 Data
)
{
}
@@ -300,10 +300,10 @@ PeiDefaultIoWrite8 (
VOID
EFIAPI
PeiDefaultIoWrite16 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT16 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT16 Data
)
{
}
@@ -321,10 +321,10 @@ PeiDefaultIoWrite16 (
VOID
EFIAPI
PeiDefaultIoWrite32 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT32 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT32 Data
)
{
}
@@ -342,10 +342,10 @@ PeiDefaultIoWrite32 (
VOID
EFIAPI
PeiDefaultIoWrite64 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT64 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT64 Data
)
{
}
@@ -366,9 +366,9 @@ PeiDefaultIoWrite64 (
UINT8
EFIAPI
PeiDefaultMemRead8 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -390,9 +390,9 @@ PeiDefaultMemRead8 (
UINT16
EFIAPI
PeiDefaultMemRead16 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -414,9 +414,9 @@ PeiDefaultMemRead16 (
UINT32
EFIAPI
PeiDefaultMemRead32 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -438,9 +438,9 @@ PeiDefaultMemRead32 (
UINT64
EFIAPI
PeiDefaultMemRead64 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address
)
{
return 0;
@@ -460,10 +460,10 @@ PeiDefaultMemRead64 (
VOID
EFIAPI
PeiDefaultMemWrite8 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT8 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT8 Data
)
{
}
@@ -482,10 +482,10 @@ PeiDefaultMemWrite8 (
VOID
EFIAPI
PeiDefaultMemWrite16 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT16 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT16 Data
)
{
}
@@ -504,10 +504,10 @@ PeiDefaultMemWrite16 (
VOID
EFIAPI
PeiDefaultMemWrite32 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT32 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT32 Data
)
{
}
@@ -526,10 +526,10 @@ PeiDefaultMemWrite32 (
VOID
EFIAPI
PeiDefaultMemWrite64 (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT64 Data
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_CPU_IO_PPI *This,
IN UINT64 Address,
IN UINT64 Data
)
{
}

View File

@@ -49,19 +49,19 @@ IsPpiInstalled (
// possibilities of alignment faults for cross-compilation
// environments such as Intel?Itanium(TM).
//
CopyMem(&PpiGuid, Stack->Operator, sizeof(EFI_GUID));
CopyMem (&PpiGuid, Stack->Operator, sizeof (EFI_GUID));
//
// Check if the PPI is installed.
//
Status = PeiServicesLocatePpi(
Status = PeiServicesLocatePpi (
&PpiGuid, // GUID
0, // INSTANCE
NULL, // EFI_PEI_PPI_DESCRIPTOR
&PeiInstance // PPI
);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return FALSE;
}
@@ -90,22 +90,20 @@ IsPpiInstalled (
**/
BOOLEAN
PeimDispatchReadiness (
IN EFI_PEI_SERVICES **PeiServices,
IN VOID *DependencyExpression
IN EFI_PEI_SERVICES **PeiServices,
IN VOID *DependencyExpression
)
{
DEPENDENCY_EXPRESSION_OPERAND *Iterator;
EVAL_STACK_ENTRY *StackPtr;
EVAL_STACK_ENTRY EvalStack[MAX_GRAMMAR_SIZE];
Iterator = DependencyExpression;
Iterator = DependencyExpression;
StackPtr = EvalStack;
while (TRUE) {
switch (*(Iterator++)) {
//
// For performance reason we put the frequently used items in front of
// the rarely used items
@@ -125,8 +123,8 @@ PeimDispatchReadiness (
// Push the pointer to the PUSH opcode operator (pointer to PPI GUID)
// We will evaluate if the PPI is installed on the POP operation.
//
StackPtr->Operator = (VOID *) Iterator;
Iterator = Iterator + sizeof (EFI_GUID);
StackPtr->Operator = (VOID *)Iterator;
Iterator = Iterator + sizeof (EFI_GUID);
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = %a\n", StackPtr->Operator, IsPpiInstalled (PeiServices, StackPtr) ? "TRUE" : "FALSE"));
StackPtr++;
break;
@@ -138,6 +136,7 @@ PeimDispatchReadiness (
} else {
DEBUG ((DEBUG_DISPATCH, " OR\n"));
}
//
// Check to make sure the dependency grammar doesn't underflow the
// EvalStack on the two POPs for the AND operation. Don't need to
@@ -166,15 +165,16 @@ PeimDispatchReadiness (
//
if (*(Iterator - 1) == EFI_DEP_AND) {
if (!(IsPpiInstalled (PeiServices, StackPtr))) {
(StackPtr-1)->Result = FALSE;
(StackPtr-1)->Result = FALSE;
(StackPtr-1)->Operator = NULL;
}
} else {
if (IsPpiInstalled (PeiServices, StackPtr)) {
(StackPtr-1)->Result = TRUE;
(StackPtr-1)->Result = TRUE;
(StackPtr-1)->Operator = NULL;
}
}
break;
case (EFI_DEP_END):
@@ -188,6 +188,7 @@ PeimDispatchReadiness (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE;
}
DEBUG ((DEBUG_DISPATCH, " RESULT = %a\n", IsPpiInstalled (PeiServices, StackPtr) ? "TRUE" : "FALSE"));
return IsPpiInstalled (PeiServices, StackPtr);
@@ -203,7 +204,8 @@ PeimDispatchReadiness (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE;
}
(StackPtr-1)->Result = (BOOLEAN) !IsPpiInstalled (PeiServices, (StackPtr-1));
(StackPtr-1)->Result = (BOOLEAN) !IsPpiInstalled (PeiServices, (StackPtr-1));
(StackPtr-1)->Operator = NULL;
break;
@@ -214,6 +216,7 @@ PeimDispatchReadiness (
} else {
DEBUG ((DEBUG_DISPATCH, " FALSE\n"));
}
//
// Check to make sure the dependency grammar doesn't overflow the
// EvalStack on the push
@@ -222,6 +225,7 @@ PeimDispatchReadiness (
DEBUG ((DEBUG_DISPATCH, " RESULT = FALSE (Underflow Error)\n"));
return FALSE;
}
//
// Iterator has increased by 1 after we retrieve the operand, so here we
// should get the value pointed by (Iterator - 1), in order to obtain the
@@ -232,6 +236,7 @@ PeimDispatchReadiness (
} else {
StackPtr->Result = FALSE;
}
StackPtr->Operator = NULL;
StackPtr++;
break;

View File

@@ -10,7 +10,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _PEI_DEPENDENCY_H_
#define _PEI_DEPENDENCY_H_
#define MAX_GRAMMAR_SIZE 64
//
@@ -19,8 +18,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
typedef UINT8 DEPENDENCY_EXPRESSION_OPERAND;
typedef struct {
BOOLEAN Result;
VOID *Operator;
BOOLEAN Result;
VOID *Operator;
} EVAL_STACK_ENTRY;
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -14,19 +14,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
#define PEI_FW_VOL_SIGNATURE SIGNATURE_32('P','F','W','V')
typedef struct {
UINTN Signature;
BOOLEAN IsFfs3Fv;
EFI_PEI_FIRMWARE_VOLUME_PPI Fv;
UINTN Signature;
BOOLEAN IsFfs3Fv;
EFI_PEI_FIRMWARE_VOLUME_PPI Fv;
} PEI_FW_VOL_INSTANCE;
#define PEI_FW_VOL_INSTANCE_FROM_FV_THIS(a) \
CR(a, PEI_FW_VOL_INSTANCE, Fv, PEI_FW_VOL_SIGNATURE)
/**
Process a firmware volume and create a volume handle.
@@ -54,10 +52,10 @@ typedef struct {
EFI_STATUS
EFIAPI
PeiFfsFvPpiProcessVolume (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN VOID *Buffer,
IN UINTN BufferSize,
OUT EFI_PEI_FV_HANDLE *FvHandle
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN VOID *Buffer,
IN UINTN BufferSize,
OUT EFI_PEI_FV_HANDLE *FvHandle
);
/**
@@ -85,10 +83,10 @@ PeiFfsFvPpiProcessVolume (
EFI_STATUS
EFIAPI
PeiFfsFvPpiFindFileByType (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_FV_FILETYPE SearchType,
IN EFI_PEI_FV_HANDLE FvHandle,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_FV_FILETYPE SearchType,
IN EFI_PEI_FV_HANDLE FvHandle,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle
);
/**
@@ -119,10 +117,10 @@ PeiFfsFvPpiFindFileByType (
EFI_STATUS
EFIAPI
PeiFfsFvPpiFindFileByName (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN CONST EFI_GUID *FileName,
IN EFI_PEI_FV_HANDLE *FvHandle,
OUT EFI_PEI_FILE_HANDLE *FileHandle
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN CONST EFI_GUID *FileName,
IN EFI_PEI_FV_HANDLE *FvHandle,
OUT EFI_PEI_FILE_HANDLE *FileHandle
);
/**
@@ -147,10 +145,10 @@ PeiFfsFvPpiFindFileByName (
EFI_STATUS
EFIAPI
PeiFfsFvPpiFindSectionByType (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_SECTION_TYPE SearchType,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_SECTION_TYPE SearchType,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData
);
/**
@@ -179,12 +177,12 @@ PeiFfsFvPpiFindSectionByType (
EFI_STATUS
EFIAPI
PeiFfsFvPpiFindSectionByType2 (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_SECTION_TYPE SearchType,
IN UINTN SearchInstance,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData,
OUT UINT32 *AuthenticationStatus
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_SECTION_TYPE SearchType,
IN UINTN SearchInstance,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT VOID **SectionData,
OUT UINT32 *AuthenticationStatus
);
/**
@@ -209,9 +207,9 @@ PeiFfsFvPpiFindSectionByType2 (
EFI_STATUS
EFIAPI
PeiFfsFvPpiGetFileInfo (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO *FileInfo
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO *FileInfo
);
/**
@@ -236,9 +234,9 @@ PeiFfsFvPpiGetFileInfo (
EFI_STATUS
EFIAPI
PeiFfsFvPpiGetFileInfo2 (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO2 *FileInfo
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_FV_FILE_INFO2 *FileInfo
);
/**
@@ -258,9 +256,9 @@ PeiFfsFvPpiGetFileInfo2 (
EFI_STATUS
EFIAPI
PeiFfsFvPpiGetVolumeInfo (
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FV_HANDLE FvHandle,
OUT EFI_FV_INFO *VolumeInfo
IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
IN EFI_PEI_FV_HANDLE FvHandle,
OUT EFI_FV_INFO *VolumeInfo
);
/**
@@ -295,11 +293,11 @@ FvHandleToCoreHandle (
**/
EFI_STATUS
FindFileEx (
IN CONST EFI_PEI_FV_HANDLE FvHandle,
IN CONST EFI_GUID *FileName OPTIONAL,
IN EFI_FV_FILETYPE SearchType,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
IN OUT EFI_PEI_FILE_HANDLE *AprioriFile OPTIONAL
IN CONST EFI_PEI_FV_HANDLE FvHandle,
IN CONST EFI_GUID *FileName OPTIONAL,
IN EFI_FV_FILETYPE SearchType,
IN OUT EFI_PEI_FILE_HANDLE *FileHandle,
IN OUT EFI_PEI_FILE_HANDLE *AprioriFile OPTIONAL
);
/**
@@ -342,11 +340,11 @@ AddUnknownFormatFvInfo (
**/
EFI_STATUS
FindUnknownFormatFvInfo (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_GUID *Format,
OUT VOID **FvInfo,
OUT UINT32 *FvInfoSize,
OUT UINT32 *AuthenticationStatus
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_GUID *Format,
OUT VOID **FvInfo,
OUT UINT32 *FvInfoSize,
OUT UINT32 *AuthenticationStatus
);
/**
@@ -364,9 +362,9 @@ FindUnknownFormatFvInfo (
EFI_STATUS
EFIAPI
ThirdPartyFvPpiNotifyCallback (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
);
#endif

View File

@@ -24,29 +24,29 @@ EFI_STATUS
EFIAPI
PeiGetHobList (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN OUT VOID **HobList
IN OUT VOID **HobList
)
{
PEI_CORE_INSTANCE *PrivateData;
PEI_CORE_INSTANCE *PrivateData;
//
// Only check this parameter in debug mode
//
DEBUG_CODE_BEGIN ();
if (HobList == NULL) {
return EFI_INVALID_PARAMETER;
}
if (HobList == NULL) {
return EFI_INVALID_PARAMETER;
}
DEBUG_CODE_END ();
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
*HobList = PrivateData->HobList.Raw;
*HobList = PrivateData->HobList.Raw;
return EFI_SUCCESS;
}
/**
Add a new HOB to the HOB List.
@@ -65,19 +65,18 @@ EFI_STATUS
EFIAPI
PeiCreateHob (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN UINT16 Type,
IN UINT16 Length,
IN OUT VOID **Hob
IN UINT16 Type,
IN UINT16 Length,
IN OUT VOID **Hob
)
{
EFI_STATUS Status;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
EFI_HOB_GENERIC_HEADER *HobEnd;
EFI_PHYSICAL_ADDRESS FreeMemory;
EFI_STATUS Status;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
EFI_HOB_GENERIC_HEADER *HobEnd;
EFI_PHYSICAL_ADDRESS FreeMemory;
Status = PeiGetHobList (PeiServices, Hob);
if (EFI_ERROR(Status)) {
if (EFI_ERROR (Status)) {
return Status;
}
@@ -89,7 +88,8 @@ PeiCreateHob (
if (0x10000 - Length <= 0x7) {
return EFI_INVALID_PARAMETER;
}
Length = (UINT16)((Length + 0x7) & (~0x7));
Length = (UINT16)((Length + 0x7) & (~0x7));
FreeMemory = HandOffHob->EfiFreeMemoryTop -
HandOffHob->EfiFreeMemoryBottom;
@@ -101,19 +101,19 @@ PeiCreateHob (
return EFI_OUT_OF_RESOURCES;
}
*Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
((EFI_HOB_GENERIC_HEADER*) *Hob)->HobType = Type;
((EFI_HOB_GENERIC_HEADER*) *Hob)->HobLength = Length;
((EFI_HOB_GENERIC_HEADER*) *Hob)->Reserved = 0;
*Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;
((EFI_HOB_GENERIC_HEADER *)*Hob)->HobType = Type;
((EFI_HOB_GENERIC_HEADER *)*Hob)->HobLength = Length;
((EFI_HOB_GENERIC_HEADER *)*Hob)->Reserved = 0;
HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN) *Hob + Length);
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)*Hob + Length);
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
HobEnd->HobLength = (UINT16) sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->HobLength = (UINT16)sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
HobEnd++;
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
return EFI_SUCCESS;
}
@@ -130,26 +130,27 @@ PeiCreateHob (
**/
EFI_STATUS
PeiInstallSecHobData (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_HOB_GENERIC_HEADER *SecHobList
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_HOB_GENERIC_HEADER *SecHobList
)
{
EFI_STATUS Status;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
EFI_PEI_HOB_POINTERS HobStart;
EFI_PEI_HOB_POINTERS Hob;
UINTN SecHobListLength;
EFI_PHYSICAL_ADDRESS FreeMemory;
EFI_HOB_GENERIC_HEADER *HobEnd;
EFI_STATUS Status;
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
EFI_PEI_HOB_POINTERS HobStart;
EFI_PEI_HOB_POINTERS Hob;
UINTN SecHobListLength;
EFI_PHYSICAL_ADDRESS FreeMemory;
EFI_HOB_GENERIC_HEADER *HobEnd;
HandOffHob = NULL;
Status = PeiGetHobList (PeiServices, (VOID **) &HandOffHob);
if (EFI_ERROR(Status)) {
Status = PeiGetHobList (PeiServices, (VOID **)&HandOffHob);
if (EFI_ERROR (Status)) {
return Status;
}
ASSERT (HandOffHob != NULL);
HobStart.Raw = (UINT8 *) SecHobList;
HobStart.Raw = (UINT8 *)SecHobList;
//
// The HobList must not contain a EFI_HOB_HANDOFF_INFO_TABLE HOB (PHIT) HOB.
//
@@ -158,8 +159,10 @@ PeiInstallSecHobData (
// Calculate the SEC HOB List length,
// not including the terminated HOB(EFI_HOB_TYPE_END_OF_HOB_LIST).
//
for (Hob.Raw = HobStart.Raw; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob));
SecHobListLength = (UINTN) Hob.Raw - (UINTN) HobStart.Raw;
for (Hob.Raw = HobStart.Raw; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
}
SecHobListLength = (UINTN)Hob.Raw - (UINTN)HobStart.Raw;
//
// The length must be 8-bytes aligned.
//
@@ -175,17 +178,17 @@ PeiInstallSecHobData (
return EFI_OUT_OF_RESOURCES;
}
Hob.Raw = (UINT8 *) (UINTN) HandOffHob->EfiEndOfHobList;
Hob.Raw = (UINT8 *)(UINTN)HandOffHob->EfiEndOfHobList;
CopyMem (Hob.Raw, HobStart.Raw, SecHobListLength);
HobEnd = (EFI_HOB_GENERIC_HEADER *) ((UINTN) Hob.Raw + SecHobListLength);
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob.Raw + SecHobListLength);
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
HobEnd->HobLength = (UINT16) sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->HobLength = (UINT16)sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
HobEnd++;
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
return EFI_SUCCESS;
}
@@ -208,27 +211,27 @@ PeiCoreBuildHobHandoffInfoTable (
IN UINT64 MemoryLength
)
{
EFI_HOB_HANDOFF_INFO_TABLE *Hob;
EFI_HOB_GENERIC_HEADER *HobEnd;
EFI_HOB_HANDOFF_INFO_TABLE *Hob;
EFI_HOB_GENERIC_HEADER *HobEnd;
Hob = (VOID *)(UINTN)MemoryBegin;
HobEnd = (EFI_HOB_GENERIC_HEADER*) (Hob+1);
Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
Hob->Header.HobLength = (UINT16) sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
Hob->Header.Reserved = 0;
Hob = (VOID *)(UINTN)MemoryBegin;
HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
Hob->Header.HobLength = (UINT16)sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
Hob->Header.Reserved = 0;
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
HobEnd->HobLength = (UINT16) sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
HobEnd->HobLength = (UINT16)sizeof (EFI_HOB_GENERIC_HEADER);
HobEnd->Reserved = 0;
Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
Hob->BootMode = BootMode;
Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
Hob->BootMode = BootMode;
Hob->EfiMemoryTop = MemoryBegin + MemoryLength;
Hob->EfiMemoryBottom = MemoryBegin;
Hob->EfiFreeMemoryTop = MemoryBegin + MemoryLength;
Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd + 1);
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd + 1);
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
return EFI_SUCCESS;
}

View File

@@ -8,13 +8,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PeiMain.h"
EFI_PEI_LOAD_FILE_PPI mPeiLoadImagePpi = {
EFI_PEI_LOAD_FILE_PPI mPeiLoadImagePpi = {
PeiLoadImageLoadImageWrapper
};
EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {
EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiLoadFilePpiGuid,
&mPeiLoadImagePpi
@@ -36,17 +34,17 @@ EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {
EFI_STATUS
EFIAPI
PeiImageRead (
IN VOID *FileHandle,
IN UINTN FileOffset,
IN UINTN *ReadSize,
OUT VOID *Buffer
IN VOID *FileHandle,
IN UINTN FileOffset,
IN UINTN *ReadSize,
OUT VOID *Buffer
)
{
CHAR8 *Destination8;
CHAR8 *Source8;
CHAR8 *Destination8;
CHAR8 *Source8;
Destination8 = Buffer;
Source8 = (CHAR8 *) ((UINTN) FileHandle + FileOffset);
Destination8 = Buffer;
Source8 = (CHAR8 *)((UINTN)FileHandle + FileOffset);
if (Destination8 != Source8) {
CopyMem (Destination8, Source8, *ReadSize);
}
@@ -68,59 +66,61 @@ PeiImageRead (
**/
EFI_STATUS
CheckAndMarkFixLoadingMemoryUsageBitMap (
IN PEI_CORE_INSTANCE *Private,
IN EFI_PHYSICAL_ADDRESS ImageBase,
IN UINT32 ImageSize
IN PEI_CORE_INSTANCE *Private,
IN EFI_PHYSICAL_ADDRESS ImageBase,
IN UINT32 ImageSize
)
{
UINT32 DxeCodePageNumber;
UINT64 ReservedCodeSize;
EFI_PHYSICAL_ADDRESS PeiCodeBase;
UINT32 BaseOffsetPageNumber;
UINT32 TopOffsetPageNumber;
UINT32 Index;
UINT64 *MemoryUsageBitMap;
UINT32 DxeCodePageNumber;
UINT64 ReservedCodeSize;
EFI_PHYSICAL_ADDRESS PeiCodeBase;
UINT32 BaseOffsetPageNumber;
UINT32 TopOffsetPageNumber;
UINT32 Index;
UINT64 *MemoryUsageBitMap;
//
// The reserved code range includes RuntimeCodePage range, Boot time code range and PEI code range.
//
DxeCodePageNumber = PcdGet32 (PcdLoadFixAddressBootTimeCodePageNumber);
DxeCodePageNumber += PcdGet32 (PcdLoadFixAddressRuntimeCodePageNumber);
ReservedCodeSize = EFI_PAGES_TO_SIZE (DxeCodePageNumber + PcdGet32 (PcdLoadFixAddressPeiCodePageNumber));
PeiCodeBase = Private->LoadModuleAtFixAddressTopAddress - ReservedCodeSize;
//
// The reserved code range includes RuntimeCodePage range, Boot time code range and PEI code range.
//
DxeCodePageNumber = PcdGet32(PcdLoadFixAddressBootTimeCodePageNumber);
DxeCodePageNumber += PcdGet32(PcdLoadFixAddressRuntimeCodePageNumber);
ReservedCodeSize = EFI_PAGES_TO_SIZE(DxeCodePageNumber + PcdGet32(PcdLoadFixAddressPeiCodePageNumber));
PeiCodeBase = Private->LoadModuleAtFixAddressTopAddress - ReservedCodeSize;
//
// Test the memory range for loading the image in the PEI code range.
//
if (((Private->LoadModuleAtFixAddressTopAddress - EFI_PAGES_TO_SIZE (DxeCodePageNumber)) < (ImageBase + ImageSize)) ||
(PeiCodeBase > ImageBase))
{
return EFI_NOT_FOUND;
}
//
// Test the memory range for loading the image in the PEI code range.
//
if ((Private->LoadModuleAtFixAddressTopAddress - EFI_PAGES_TO_SIZE(DxeCodePageNumber)) < (ImageBase + ImageSize) ||
(PeiCodeBase > ImageBase)) {
return EFI_NOT_FOUND;
}
//
// Test if the memory is available or not.
//
MemoryUsageBitMap = Private->PeiCodeMemoryRangeUsageBitMap;
BaseOffsetPageNumber = EFI_SIZE_TO_PAGES ((UINT32)(ImageBase - PeiCodeBase));
TopOffsetPageNumber = EFI_SIZE_TO_PAGES ((UINT32)(ImageBase + ImageSize - PeiCodeBase));
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index++) {
if ((MemoryUsageBitMap[Index / 64] & LShiftU64 (1, (Index % 64))) != 0) {
//
// This page is already used.
//
return EFI_NOT_FOUND;
}
}
//
// Test if the memory is available or not.
//
MemoryUsageBitMap = Private->PeiCodeMemoryRangeUsageBitMap;
BaseOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase - PeiCodeBase));
TopOffsetPageNumber = EFI_SIZE_TO_PAGES((UINT32)(ImageBase + ImageSize - PeiCodeBase));
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
if ((MemoryUsageBitMap[Index / 64] & LShiftU64(1, (Index % 64))) != 0) {
//
// This page is already used.
//
return EFI_NOT_FOUND;
}
}
//
// Being here means the memory range is available. So mark the bits for the memory range
//
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index++) {
MemoryUsageBitMap[Index / 64] |= LShiftU64 (1, (Index % 64));
}
//
// Being here means the memory range is available. So mark the bits for the memory range
//
for (Index = BaseOffsetPageNumber; Index < TopOffsetPageNumber; Index ++) {
MemoryUsageBitMap[Index / 64] |= LShiftU64(1, (Index % 64));
}
return EFI_SUCCESS;
return EFI_SUCCESS;
}
/**
Get the fixed loading address from image header assigned by build tool. This function only be called
@@ -135,109 +135,114 @@ CheckAndMarkFixLoadingMemoryUsageBitMap (
**/
EFI_STATUS
GetPeCoffImageFixLoadingAssignedAddress(
GetPeCoffImageFixLoadingAssignedAddress (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
IN PEI_CORE_INSTANCE *Private
)
{
UINTN SectionHeaderOffset;
EFI_STATUS Status;
EFI_IMAGE_SECTION_HEADER SectionHeader;
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;
EFI_PHYSICAL_ADDRESS FixLoadingAddress;
UINT16 Index;
UINTN Size;
UINT16 NumberOfSections;
UINT64 ValueInSectionHeader;
UINTN SectionHeaderOffset;
EFI_STATUS Status;
EFI_IMAGE_SECTION_HEADER SectionHeader;
EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr;
EFI_PHYSICAL_ADDRESS FixLoadingAddress;
UINT16 Index;
UINTN Size;
UINT16 NumberOfSections;
UINT64 ValueInSectionHeader;
FixLoadingAddress = 0;
Status = EFI_NOT_FOUND;
FixLoadingAddress = 0;
Status = EFI_NOT_FOUND;
//
// Get PeHeader pointer
//
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8 *)ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
if (ImageContext->IsTeImage) {
//
// for TE image, the fix loading address is saved in first section header that doesn't point
// to code section.
//
SectionHeaderOffset = sizeof (EFI_TE_IMAGE_HEADER);
NumberOfSections = ImgHdr->Te.NumberOfSections;
} else {
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
}
//
// Get PeHeader pointer
//
ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((CHAR8* )ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
if (ImageContext->IsTeImage) {
//
// for TE image, the fix loading address is saved in first section header that doesn't point
// to code section.
//
SectionHeaderOffset = sizeof (EFI_TE_IMAGE_HEADER);
NumberOfSections = ImgHdr->Te.NumberOfSections;
} else {
SectionHeaderOffset = ImageContext->PeCoffHeaderOffset +
sizeof (UINT32) +
sizeof (EFI_IMAGE_FILE_HEADER) +
ImgHdr->Pe32.FileHeader.SizeOfOptionalHeader;
NumberOfSections = ImgHdr->Pe32.FileHeader.NumberOfSections;
}
//
// Get base address from the first section header that doesn't point to code section.
//
for (Index = 0; Index < NumberOfSections; Index++) {
//
// Read section header from file
//
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
Status = ImageContext->ImageRead (
ImageContext->Handle,
SectionHeaderOffset,
&Size,
&SectionHeader
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get base address from the first section header that doesn't point to code section.
//
for (Index = 0; Index < NumberOfSections; Index++) {
//
// Read section header from file
//
Size = sizeof (EFI_IMAGE_SECTION_HEADER);
Status = ImageContext->ImageRead (
ImageContext->Handle,
SectionHeaderOffset,
&Size,
&SectionHeader
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = EFI_NOT_FOUND;
Status = EFI_NOT_FOUND;
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
//
// Build tool will save the address in PointerToRelocations & PointerToLineNumbers fields in the first section header
// that doesn't point to code section in image header, as well as ImageBase field of image header. A notable thing is
// that for PEIM, the value in ImageBase field may not be equal to the value in PointerToRelocations & PointerToLineNumbers because
// for XIP PEIM, ImageBase field holds the image base address running on the Flash. And PointerToRelocations & PointerToLineNumbers
// hold the image base address when it is shadow to the memory. And there is an assumption that when the feature is enabled, if a
// module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers fields should NOT be Zero, or
// else, these 2 fields should be set to Zero
//
ValueInSectionHeader = ReadUnaligned64((UINT64*)&SectionHeader.PointerToRelocations);
if (ValueInSectionHeader != 0) {
//
// Found first section header that doesn't point to code section.
//
if ((INT64)PcdGet64(PcdLoadModuleAtFixAddressEnable) > 0) {
//
// When LMFA feature is configured as Load Module at Fixed Absolute Address mode, PointerToRelocations & PointerToLineNumbers field
// hold the absolute address of image base running in memory
//
FixLoadingAddress = ValueInSectionHeader;
} else {
//
// When LMFA feature is configured as Load Module at Fixed offset mode, PointerToRelocations & PointerToLineNumbers field
// hold the offset relative to a platform-specific top address.
//
FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(Private->LoadModuleAtFixAddressTopAddress + (INT64)ValueInSectionHeader);
}
//
// Check if the memory range is available.
//
Status = CheckAndMarkFixLoadingMemoryUsageBitMap (Private, FixLoadingAddress, (UINT32) ImageContext->ImageSize);
if (!EFI_ERROR(Status)) {
//
// The assigned address is valid. Return the specified loading address
//
ImageContext->ImageAddress = FixLoadingAddress;
}
}
break;
}
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status= %r \n", (VOID *)(UINTN)FixLoadingAddress, Status));
return Status;
if ((SectionHeader.Characteristics & EFI_IMAGE_SCN_CNT_CODE) == 0) {
//
// Build tool will save the address in PointerToRelocations & PointerToLineNumbers fields in the first section header
// that doesn't point to code section in image header, as well as ImageBase field of image header. A notable thing is
// that for PEIM, the value in ImageBase field may not be equal to the value in PointerToRelocations & PointerToLineNumbers because
// for XIP PEIM, ImageBase field holds the image base address running on the Flash. And PointerToRelocations & PointerToLineNumbers
// hold the image base address when it is shadow to the memory. And there is an assumption that when the feature is enabled, if a
// module is assigned a loading address by tools, PointerToRelocations & PointerToLineNumbers fields should NOT be Zero, or
// else, these 2 fields should be set to Zero
//
ValueInSectionHeader = ReadUnaligned64 ((UINT64 *)&SectionHeader.PointerToRelocations);
if (ValueInSectionHeader != 0) {
//
// Found first section header that doesn't point to code section.
//
if ((INT64)PcdGet64 (PcdLoadModuleAtFixAddressEnable) > 0) {
//
// When LMFA feature is configured as Load Module at Fixed Absolute Address mode, PointerToRelocations & PointerToLineNumbers field
// hold the absolute address of image base running in memory
//
FixLoadingAddress = ValueInSectionHeader;
} else {
//
// When LMFA feature is configured as Load Module at Fixed offset mode, PointerToRelocations & PointerToLineNumbers field
// hold the offset relative to a platform-specific top address.
//
FixLoadingAddress = (EFI_PHYSICAL_ADDRESS)(Private->LoadModuleAtFixAddressTopAddress + (INT64)ValueInSectionHeader);
}
//
// Check if the memory range is available.
//
Status = CheckAndMarkFixLoadingMemoryUsageBitMap (Private, FixLoadingAddress, (UINT32)ImageContext->ImageSize);
if (!EFI_ERROR (Status)) {
//
// The assigned address is valid. Return the specified loading address
//
ImageContext->ImageAddress = FixLoadingAddress;
}
}
break;
}
SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
}
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED INFO: Loading module at fixed address 0x%11p. Status= %r \n", (VOID *)(UINTN)FixLoadingAddress, Status));
return Status;
}
/**
Loads and relocates a PE/COFF image into memory.
@@ -258,30 +263,30 @@ GetPeCoffImageFixLoadingAssignedAddress(
**/
EFI_STATUS
LoadAndRelocatePeCoffImage (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN VOID *Pe32Data,
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
OUT UINT64 *ImageSize,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
IN EFI_PEI_FILE_HANDLE FileHandle,
IN VOID *Pe32Data,
OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
OUT UINT64 *ImageSize,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint
)
{
EFI_STATUS Status;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PEI_CORE_INSTANCE *Private;
UINT64 AlignImageSize;
BOOLEAN IsXipImage;
EFI_STATUS ReturnStatus;
BOOLEAN IsS3Boot;
BOOLEAN IsPeiModule;
BOOLEAN IsRegisterForShadow;
EFI_FV_FILE_INFO FileInfo;
EFI_STATUS Status;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
PEI_CORE_INSTANCE *Private;
UINT64 AlignImageSize;
BOOLEAN IsXipImage;
EFI_STATUS ReturnStatus;
BOOLEAN IsS3Boot;
BOOLEAN IsPeiModule;
BOOLEAN IsRegisterForShadow;
EFI_FV_FILE_INFO FileInfo;
Private = PEI_CORE_INSTANCE_FROM_PS_THIS (GetPeiServicesTablePointer ());
ReturnStatus = EFI_SUCCESS;
IsXipImage = FALSE;
ZeroMem (&ImageContext, sizeof (ImageContext));
ImageContext.Handle = Pe32Data;
ImageContext.Handle = Pe32Data;
ImageContext.ImageRead = PeiImageRead;
Status = PeCoffLoaderGetImageInfo (&ImageContext);
@@ -296,16 +301,18 @@ LoadAndRelocatePeCoffImage (
if (Private->HobList.HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) {
IsS3Boot = TRUE;
}
IsRegisterForShadow = FALSE;
if ((Private->CurrentFileHandle == FileHandle)
&& (Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] == PEIM_STATE_REGISTER_FOR_SHADOW)) {
if ( (Private->CurrentFileHandle == FileHandle)
&& (Private->Fv[Private->CurrentPeimFvCount].PeimState[Private->CurrentPeimCount] == PEIM_STATE_REGISTER_FOR_SHADOW))
{
IsRegisterForShadow = TRUE;
}
//
// XIP image that ImageAddress is same to Image handle.
//
if (ImageContext.ImageAddress == (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data) {
if (ImageContext.ImageAddress == (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data) {
IsXipImage = TRUE;
}
@@ -319,9 +326,10 @@ LoadAndRelocatePeCoffImage (
// Check whether the file type is PEI module.
//
IsPeiModule = FALSE;
if (FileInfo.FileType == EFI_FV_FILETYPE_PEI_CORE ||
FileInfo.FileType == EFI_FV_FILETYPE_PEIM ||
FileInfo.FileType == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER) {
if ((FileInfo.FileType == EFI_FV_FILETYPE_PEI_CORE) ||
(FileInfo.FileType == EFI_FV_FILETYPE_PEIM) ||
(FileInfo.FileType == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER))
{
IsPeiModule = TRUE;
}
@@ -332,14 +340,15 @@ LoadAndRelocatePeCoffImage (
((!IsPeiModule) || PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) ||
(!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) ||
(IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))
) {
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN) Pe32Data));
)
{
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "The image at 0x%08x without reloc section can't be loaded into memory\n", (UINTN)Pe32Data));
}
//
// Set default base address to current image address.
//
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data;
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data;
//
// Allocate Memory for the image when memory is ready, and image is relocatable.
@@ -350,12 +359,13 @@ LoadAndRelocatePeCoffImage (
((!IsPeiModule) || PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) ||
(!IsS3Boot && (PcdGetBool (PcdShadowPeimOnBoot) || IsRegisterForShadow)) ||
(IsS3Boot && PcdGetBool (PcdShadowPeimOnS3Boot)))
) {
)
{
//
// Allocate more buffer to avoid buffer overflow.
//
if (ImageContext.IsTeImage) {
AlignImageSize = ImageContext.ImageSize + ((EFI_TE_IMAGE_HEADER *) Pe32Data)->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
AlignImageSize = ImageContext.ImageSize + ((EFI_TE_IMAGE_HEADER *)Pe32Data)->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER);
} else {
AlignImageSize = ImageContext.ImageSize;
}
@@ -364,38 +374,44 @@ LoadAndRelocatePeCoffImage (
AlignImageSize += ImageContext.SectionAlignment;
}
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
Status = GetPeCoffImageFixLoadingAssignedAddress(&ImageContext, Private);
if (EFI_ERROR (Status)){
if ((PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) && (Private->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
Status = GetPeCoffImageFixLoadingAssignedAddress (&ImageContext, Private);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO|DEBUG_LOAD, "LOADING MODULE FIXED ERROR: Failed to load module at fixed address. \n"));
//
// The PEIM is not assigned valid address, try to allocate page to load it.
//
Status = PeiServicesAllocatePages (EfiBootServicesCode,
EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize),
&ImageContext.ImageAddress);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
EFI_SIZE_TO_PAGES ((UINT32)AlignImageSize),
&ImageContext.ImageAddress
);
}
} else {
Status = PeiServicesAllocatePages (EfiBootServicesCode,
EFI_SIZE_TO_PAGES ((UINT32) AlignImageSize),
&ImageContext.ImageAddress);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
EFI_SIZE_TO_PAGES ((UINT32)AlignImageSize),
&ImageContext.ImageAddress
);
}
if (!EFI_ERROR (Status)) {
//
// Adjust the Image Address to make sure it is section alignment.
//
if (ImageContext.SectionAlignment > EFI_PAGE_SIZE) {
ImageContext.ImageAddress =
(ImageContext.ImageAddress + ImageContext.SectionAlignment - 1) &
~((UINTN)ImageContext.SectionAlignment - 1);
(ImageContext.ImageAddress + ImageContext.SectionAlignment - 1) &
~((UINTN)ImageContext.SectionAlignment - 1);
}
//
// Fix alignment requirement when Load IPF TeImage into memory.
// Skip the reserved space for the stripped PeHeader when load TeImage into memory.
//
if (ImageContext.IsTeImage) {
ImageContext.ImageAddress = ImageContext.ImageAddress +
((EFI_TE_IMAGE_HEADER *) Pe32Data)->StrippedSize -
((EFI_TE_IMAGE_HEADER *)Pe32Data)->StrippedSize -
sizeof (EFI_TE_IMAGE_HEADER);
}
} else {
@@ -406,8 +422,8 @@ LoadAndRelocatePeCoffImage (
//
// XIP image can still be invoked.
//
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data;
ReturnStatus = EFI_WARN_BUFFER_TOO_SMALL;
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data;
ReturnStatus = EFI_WARN_BUFFER_TOO_SMALL;
} else {
//
// Non XIP image can't be loaded because no enough memory is allocated.
@@ -424,10 +440,12 @@ LoadAndRelocatePeCoffImage (
Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {
if (ImageContext.ImageError == IMAGE_ERROR_INVALID_SECTION_ALIGNMENT) {
DEBUG ((DEBUG_ERROR, "PEIM Image Address 0x%11p doesn't meet with section alignment 0x%x.\n", (VOID*)(UINTN)ImageContext.ImageAddress, ImageContext.SectionAlignment));
DEBUG ((DEBUG_ERROR, "PEIM Image Address 0x%11p doesn't meet with section alignment 0x%x.\n", (VOID *)(UINTN)ImageContext.ImageAddress, ImageContext.SectionAlignment));
}
return Status;
}
//
// Relocate the image in our new buffer
//
@@ -439,7 +457,7 @@ LoadAndRelocatePeCoffImage (
//
// Flush the instruction cache so the image data is written before we execute it
//
if (ImageContext.ImageAddress != (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data) {
if (ImageContext.ImageAddress != (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data) {
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
}
@@ -462,15 +480,15 @@ LoadAndRelocatePeCoffImage (
**/
EFI_STATUS
LoadAndRelocatePeCoffImageInPlace (
IN VOID *Pe32Data,
IN VOID *ImageAddress
IN VOID *Pe32Data,
IN VOID *ImageAddress
)
{
EFI_STATUS Status;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
EFI_STATUS Status;
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
ZeroMem (&ImageContext, sizeof (ImageContext));
ImageContext.Handle = Pe32Data;
ImageContext.Handle = Pe32Data;
ImageContext.ImageRead = PeiImageRead;
Status = PeCoffLoaderGetImageInfo (&ImageContext);
@@ -479,7 +497,7 @@ LoadAndRelocatePeCoffImageInPlace (
return Status;
}
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN) ImageAddress;
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)ImageAddress;
//
// Load the image in place
@@ -502,7 +520,7 @@ LoadAndRelocatePeCoffImageInPlace (
//
// Flush the instruction cache so the image data is written before we execute it
//
if (ImageContext.ImageAddress != (EFI_PHYSICAL_ADDRESS)(UINTN) Pe32Data) {
if (ImageContext.ImageAddress != (EFI_PHYSICAL_ADDRESS)(UINTN)Pe32Data) {
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);
}
@@ -525,10 +543,10 @@ PeiGetPe32Data (
OUT VOID **Pe32Data
)
{
EFI_STATUS Status;
EFI_SECTION_TYPE SearchType1;
EFI_SECTION_TYPE SearchType2;
UINT32 AuthenticationState;
EFI_STATUS Status;
EFI_SECTION_TYPE SearchType1;
EFI_SECTION_TYPE SearchType2;
UINT32 AuthenticationState;
*Pe32Data = NULL;
@@ -563,6 +581,7 @@ PeiGetPe32Data (
&AuthenticationState
);
}
return Status;
}
@@ -588,22 +607,22 @@ PeiGetPe32Data (
**/
EFI_STATUS
PeiLoadImageLoadImage (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg OPTIONAL,
OUT UINT64 *ImageSizeArg OPTIONAL,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
OUT UINT32 *AuthenticationState
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_FILE_HANDLE FileHandle,
OUT EFI_PHYSICAL_ADDRESS *ImageAddressArg OPTIONAL,
OUT UINT64 *ImageSizeArg OPTIONAL,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
OUT UINT32 *AuthenticationState
)
{
EFI_STATUS Status;
VOID *Pe32Data;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
EFI_PHYSICAL_ADDRESS ImageEntryPoint;
UINT16 Machine;
EFI_SECTION_TYPE SearchType1;
EFI_SECTION_TYPE SearchType2;
EFI_STATUS Status;
VOID *Pe32Data;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
EFI_PHYSICAL_ADDRESS ImageEntryPoint;
UINT16 Machine;
EFI_SECTION_TYPE SearchType1;
EFI_SECTION_TYPE SearchType2;
*EntryPoint = 0;
ImageSize = 0;
@@ -654,12 +673,12 @@ PeiLoadImageLoadImage (
// If memory is installed, perform the shadow operations
//
Status = LoadAndRelocatePeCoffImage (
FileHandle,
Pe32Data,
&ImageAddress,
&ImageSize,
&ImageEntryPoint
);
FileHandle,
Pe32Data,
&ImageAddress,
&ImageSize,
&ImageEntryPoint
);
if (EFI_ERROR (Status)) {
return Status;
@@ -668,7 +687,7 @@ PeiLoadImageLoadImage (
//
// Got the entry point from the loaded Pe32Data
//
Pe32Data = (VOID *) ((UINTN) ImageAddress);
Pe32Data = (VOID *)((UINTN)ImageAddress);
*EntryPoint = ImageEntryPoint;
Machine = PeCoffLoaderGetMachineType (Pe32Data);
@@ -688,71 +707,70 @@ PeiLoadImageLoadImage (
}
DEBUG_CODE_BEGIN ();
CHAR8 *AsciiString;
CHAR8 EfiFileName[512];
INT32 Index;
INT32 StartIndex;
CHAR8 *AsciiString;
CHAR8 EfiFileName[512];
INT32 Index;
INT32 StartIndex;
//
// Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
//
if (Machine != EFI_IMAGE_MACHINE_IA64) {
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint));
} else {
//
// Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
// For IPF Image, the real entry point should be print.
//
if (Machine != EFI_IMAGE_MACHINE_IA64) {
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)*EntryPoint));
} else {
//
// For IPF Image, the real entry point should be print.
//
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint)));
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Loading PEIM at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN)ImageAddress, (VOID *)(UINTN)(*(UINT64 *)(UINTN)*EntryPoint)));
}
//
// Print Module Name by PeImage PDB file name.
//
AsciiString = PeCoffLoaderGetPdbPointer (Pe32Data);
if (AsciiString != NULL) {
StartIndex = 0;
for (Index = 0; AsciiString[Index] != 0; Index++) {
if ((AsciiString[Index] == '\\') || (AsciiString[Index] == '/')) {
StartIndex = Index + 1;
}
}
//
// Print Module Name by PeImage PDB file name.
// Copy the PDB file name to our temporary string, and replace .pdb with .efi
// The PDB file name is limited in the range of 0~511.
// If the length is bigger than 511, trim the redundant characters to avoid overflow in array boundary.
//
AsciiString = PeCoffLoaderGetPdbPointer (Pe32Data);
if (AsciiString != NULL) {
StartIndex = 0;
for (Index = 0; AsciiString[Index] != 0; Index++) {
if (AsciiString[Index] == '\\' || AsciiString[Index] == '/') {
StartIndex = Index + 1;
}
for (Index = 0; Index < sizeof (EfiFileName) - 4; Index++) {
EfiFileName[Index] = AsciiString[Index + StartIndex];
if (EfiFileName[Index] == 0) {
EfiFileName[Index] = '.';
}
//
// Copy the PDB file name to our temporary string, and replace .pdb with .efi
// The PDB file name is limited in the range of 0~511.
// If the length is bigger than 511, trim the redundant characters to avoid overflow in array boundary.
//
for (Index = 0; Index < sizeof (EfiFileName) - 4; Index++) {
EfiFileName[Index] = AsciiString[Index + StartIndex];
if (EfiFileName[Index] == 0) {
EfiFileName[Index] = '.';
}
if (EfiFileName[Index] == '.') {
EfiFileName[Index + 1] = 'e';
EfiFileName[Index + 2] = 'f';
EfiFileName[Index + 3] = 'i';
EfiFileName[Index + 4] = 0;
break;
}
if (EfiFileName[Index] == '.') {
EfiFileName[Index + 1] = 'e';
EfiFileName[Index + 2] = 'f';
EfiFileName[Index + 3] = 'i';
EfiFileName[Index + 4] = 0;
break;
}
if (Index == sizeof (EfiFileName) - 4) {
EfiFileName[Index] = 0;
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName));
}
if (Index == sizeof (EfiFileName) - 4) {
EfiFileName[Index] = 0;
}
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "%a", EfiFileName));
}
DEBUG_CODE_END ();
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "\n"));
return EFI_SUCCESS;
}
/**
The wrapper function of PeiLoadImageLoadImage().
@@ -811,7 +829,7 @@ RelocationIsStrip (
//
// DOS image header is present, so read the PE header after the DOS image header.
//
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + (UINTN)((DosHdr->e_lfanew) & 0x0ffff));
} else {
//
// DOS image header is not present, so PE header is at the image base.
@@ -836,7 +854,7 @@ RelocationIsStrip (
} else {
return FALSE;
}
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
} else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
if ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0) {
return TRUE;
} else {
@@ -865,20 +883,20 @@ RelocationIsStrip (
**/
EFI_STATUS
PeiLoadImage (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_FILE_HANDLE FileHandle,
IN UINT8 PeimState,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
OUT UINT32 *AuthenticationState
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_FILE_HANDLE FileHandle,
IN UINT8 PeimState,
OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
OUT UINT32 *AuthenticationState
)
{
EFI_STATUS PpiStatus;
EFI_STATUS Status;
UINTN Index;
EFI_PEI_LOAD_FILE_PPI *LoadFile;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
BOOLEAN IsStrip;
EFI_STATUS PpiStatus;
EFI_STATUS Status;
UINTN Index;
EFI_PEI_LOAD_FILE_PPI *LoadFile;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
BOOLEAN IsStrip;
IsStrip = FALSE;
//
@@ -895,19 +913,19 @@ PeiLoadImage (
);
if (!EFI_ERROR (PpiStatus)) {
Status = LoadFile->LoadFile (
LoadFile,
FileHandle,
&ImageAddress,
&ImageSize,
EntryPoint,
AuthenticationState
);
if (!EFI_ERROR (Status) || Status == EFI_WARN_BUFFER_TOO_SMALL) {
LoadFile,
FileHandle,
&ImageAddress,
&ImageSize,
EntryPoint,
AuthenticationState
);
if (!EFI_ERROR (Status) || (Status == EFI_WARN_BUFFER_TOO_SMALL)) {
//
// The shadowed PEIM must be relocatable.
//
if (PeimState == PEIM_STATE_REGISTER_FOR_SHADOW) {
IsStrip = RelocationIsStrip ((VOID *) (UINTN) ImageAddress);
IsStrip = RelocationIsStrip ((VOID *)(UINTN)ImageAddress);
ASSERT (!IsStrip);
if (IsStrip) {
return EFI_UNSUPPORTED;
@@ -917,20 +935,21 @@ PeiLoadImage (
//
// The image to be started must have the machine type supported by PeiCore.
//
ASSERT (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *) (UINTN) ImageAddress)));
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *) (UINTN) ImageAddress))) {
ASSERT (EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *)(UINTN)ImageAddress)));
if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (PeCoffLoaderGetMachineType ((VOID *)(UINTN)ImageAddress))) {
return EFI_UNSUPPORTED;
}
return EFI_SUCCESS;
}
}
Index++;
} while (!EFI_ERROR (PpiStatus));
return PpiStatus;
}
/**
Install Pei Load File PPI.
@@ -942,8 +961,8 @@ PeiLoadImage (
**/
VOID
InitializeImageServices (
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_INSTANCE *OldCoreData
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_INSTANCE *OldCoreData
)
{
if (OldCoreData == NULL) {

View File

@@ -27,22 +27,20 @@ InitializeMemoryServices (
IN PEI_CORE_INSTANCE *OldCoreData
)
{
PrivateData->SwitchStackSignal = FALSE;
PrivateData->SwitchStackSignal = FALSE;
//
// First entering PeiCore, following code will initialized some field
// in PeiCore's private data according to hand off data from SEC core.
//
if (OldCoreData == NULL) {
PrivateData->PeiMemoryInstalled = FALSE;
PrivateData->HobList.Raw = SecCoreData->PeiTemporaryRamBase;
PeiCoreBuildHobHandoffInfoTable (
BOOT_WITH_FULL_CONFIGURATION,
(EFI_PHYSICAL_ADDRESS) (UINTN) SecCoreData->PeiTemporaryRamBase,
(UINTN) SecCoreData->PeiTemporaryRamSize
(EFI_PHYSICAL_ADDRESS)(UINTN)SecCoreData->PeiTemporaryRamBase,
(UINTN)SecCoreData->PeiTemporaryRamSize
);
//
@@ -78,7 +76,7 @@ PeiInstallPeiMemory (
IN UINT64 MemoryLength
)
{
PEI_CORE_INSTANCE *PrivateData;
PEI_CORE_INSTANCE *PrivateData;
DEBUG ((DEBUG_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength));
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
@@ -98,7 +96,7 @@ PeiInstallPeiMemory (
PrivateData->PhysicalMemoryLength = MemoryLength;
PrivateData->FreePhysicalMemoryTop = MemoryBegin + MemoryLength;
PrivateData->SwitchStackSignal = TRUE;
PrivateData->SwitchStackSignal = TRUE;
return EFI_SUCCESS;
}
@@ -113,25 +111,26 @@ PeiInstallPeiMemory (
**/
VOID
MigrateMemoryPages (
IN PEI_CORE_INSTANCE *Private,
IN BOOLEAN TemporaryRamMigrated
IN PEI_CORE_INSTANCE *Private,
IN BOOLEAN TemporaryRamMigrated
)
{
EFI_PHYSICAL_ADDRESS NewMemPagesBase;
EFI_PHYSICAL_ADDRESS MemPagesBase;
EFI_PHYSICAL_ADDRESS NewMemPagesBase;
EFI_PHYSICAL_ADDRESS MemPagesBase;
Private->MemoryPages.Size = (UINTN) (Private->HobList.HandoffInformationTable->EfiMemoryTop -
Private->HobList.HandoffInformationTable->EfiFreeMemoryTop);
Private->MemoryPages.Size = (UINTN)(Private->HobList.HandoffInformationTable->EfiMemoryTop -
Private->HobList.HandoffInformationTable->EfiFreeMemoryTop);
if (Private->MemoryPages.Size == 0) {
//
// No any memory page allocated in pre-memory phase.
//
return;
}
Private->MemoryPages.Base = Private->HobList.HandoffInformationTable->EfiFreeMemoryTop;
ASSERT (Private->MemoryPages.Size <= Private->FreePhysicalMemoryTop);
NewMemPagesBase = Private->FreePhysicalMemoryTop - Private->MemoryPages.Size;
NewMemPagesBase = Private->FreePhysicalMemoryTop - Private->MemoryPages.Size;
NewMemPagesBase &= ~(UINT64)EFI_PAGE_MASK;
ASSERT (NewMemPagesBase >= Private->PhysicalMemoryBegin);
//
@@ -148,6 +147,7 @@ MigrateMemoryPages (
} else {
MemPagesBase -= Private->HeapOffset;
}
CopyMem ((VOID *)(UINTN)NewMemPagesBase, (VOID *)(UINTN)MemPagesBase, Private->MemoryPages.Size);
} else {
CopyMem ((VOID *)(UINTN)NewMemPagesBase, (VOID *)(UINTN)Private->MemoryPages.Base, Private->MemoryPages.Size);
@@ -155,13 +155,13 @@ MigrateMemoryPages (
if (NewMemPagesBase >= Private->MemoryPages.Base) {
Private->MemoryPages.OffsetPositive = TRUE;
Private->MemoryPages.Offset = (UINTN)(NewMemPagesBase - Private->MemoryPages.Base);
Private->MemoryPages.Offset = (UINTN)(NewMemPagesBase - Private->MemoryPages.Base);
} else {
Private->MemoryPages.OffsetPositive = FALSE;
Private->MemoryPages.Offset = (UINTN)(Private->MemoryPages.Base - NewMemPagesBase);
Private->MemoryPages.Offset = (UINTN)(Private->MemoryPages.Base - NewMemPagesBase);
}
DEBUG ((DEBUG_INFO, "Pages Offset = 0x%lX\n", (UINT64) Private->MemoryPages.Offset));
DEBUG ((DEBUG_INFO, "Pages Offset = 0x%lX\n", (UINT64)Private->MemoryPages.Offset));
Private->FreePhysicalMemoryTop = NewMemPagesBase;
}
@@ -174,30 +174,31 @@ MigrateMemoryPages (
**/
VOID
RemoveFvHobsInTemporaryMemory (
IN PEI_CORE_INSTANCE *Private
IN PEI_CORE_INSTANCE *Private
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
DEBUG ((DEBUG_INFO, "Removing FVs in FV HOB not already migrated to permanent memory.\n"));
for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV || GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2 || GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3) {
if ((GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) || (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV2) || (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV3)) {
FirmwareVolumeHob = Hob.FirmwareVolume;
DEBUG ((DEBUG_INFO, " Found FV HOB.\n"));
DEBUG ((
DEBUG_INFO,
" BA=%016lx L=%016lx\n",
FirmwareVolumeHob->BaseAddress,
FirmwareVolumeHob->Length
));
DEBUG_INFO,
" BA=%016lx L=%016lx\n",
FirmwareVolumeHob->BaseAddress,
FirmwareVolumeHob->Length
));
if (
!(
((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress >= Private->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS) (UINTN) FirmwareVolumeHob->BaseAddress + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop)
!(
((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress >= Private->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS)(UINTN)FirmwareVolumeHob->BaseAddress + (FirmwareVolumeHob->Length - 1)) < Private->FreePhysicalMemoryTop)
)
)
) {
{
DEBUG ((DEBUG_INFO, " Removing FV HOB to an FV in T-RAM (was not migrated).\n"));
Hob.Header->HobType = EFI_HOB_TYPE_UNUSED;
}
@@ -216,15 +217,15 @@ RemoveFvHobsInTemporaryMemory (
**/
VOID
ConvertFvHob (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob;
EFI_HOB_FIRMWARE_VOLUME3 *FirmwareVolume3Hob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2Hob;
EFI_HOB_FIRMWARE_VOLUME3 *FirmwareVolume3Hob;
DEBUG ((DEBUG_INFO, "Converting FVs in FV HOB.\n"));
@@ -257,13 +258,13 @@ ConvertFvHob (
**/
VOID
ConvertMemoryAllocationHobs (
IN PEI_CORE_INSTANCE *PrivateData
IN PEI_CORE_INSTANCE *PrivateData
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PHYSICAL_ADDRESS OldMemPagesBase;
UINTN OldMemPagesSize;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PHYSICAL_ADDRESS OldMemPagesBase;
UINTN OldMemPagesSize;
if (PrivateData->MemoryPages.Size == 0) {
//
@@ -276,12 +277,13 @@ ConvertMemoryAllocationHobs (
OldMemPagesSize = PrivateData->MemoryPages.Size;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
if ((MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress >= OldMemPagesBase) &&
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress < (OldMemPagesBase + OldMemPagesSize))
) {
)
{
if (PrivateData->MemoryPages.OffsetPositive) {
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress += PrivateData->MemoryPages.Offset;
} else {
@@ -306,22 +308,22 @@ ConvertMemoryAllocationHobs (
**/
VOID
InternalBuildMemoryAllocationHob (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN EFI_MEMORY_TYPE MemoryType
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length,
IN EFI_MEMORY_TYPE MemoryType
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
//
// Search unused(freed) memory allocation HOB.
//
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_UNUSED);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_UNUSED);
while (Hob.Raw != NULL) {
if (Hob.Header->HobLength == sizeof (EFI_HOB_MEMORY_ALLOCATION)) {
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
@@ -370,14 +372,15 @@ InternalBuildMemoryAllocationHob (
**/
VOID
UpdateOrSplitMemoryAllocationHob (
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINT64 Bytes,
IN EFI_MEMORY_TYPE MemoryType
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINT64 Bytes,
IN EFI_MEMORY_TYPE MemoryType
)
{
if ((Memory + Bytes) <
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength)) {
(MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress + MemoryAllocationHob->AllocDescriptor.MemoryLength))
{
//
// Last pages need to be split out.
//
@@ -403,8 +406,8 @@ UpdateOrSplitMemoryAllocationHob (
// Update the memory allocation HOB.
//
MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress = Memory;
MemoryAllocationHob->AllocDescriptor.MemoryLength = Bytes;
MemoryAllocationHob->AllocDescriptor.MemoryType = MemoryType;
MemoryAllocationHob->AllocDescriptor.MemoryLength = Bytes;
MemoryAllocationHob->AllocDescriptor.MemoryType = MemoryType;
}
/**
@@ -419,34 +422,34 @@ MergeFreeMemoryInMemoryAllocationHob (
VOID
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_PEI_HOB_POINTERS Hob2;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob2;
UINT64 Start;
UINT64 End;
BOOLEAN Merged;
EFI_PEI_HOB_POINTERS Hob;
EFI_PEI_HOB_POINTERS Hob2;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
EFI_HOB_MEMORY_ALLOCATION *MemoryHob2;
UINT64 Start;
UINT64 End;
BOOLEAN Merged;
Merged = FALSE;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if (Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) {
MemoryHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
Start = MemoryHob->AllocDescriptor.MemoryBaseAddress;
End = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
MemoryHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
Start = MemoryHob->AllocDescriptor.MemoryBaseAddress;
End = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
Hob2.Raw = GET_NEXT_HOB (Hob);
Hob2.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
while (Hob2.Raw != NULL) {
if (Hob2.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) {
MemoryHob2 = (EFI_HOB_MEMORY_ALLOCATION *) Hob2.Raw;
MemoryHob2 = (EFI_HOB_MEMORY_ALLOCATION *)Hob2.Raw;
if (Start == (MemoryHob2->AllocDescriptor.MemoryBaseAddress + MemoryHob2->AllocDescriptor.MemoryLength)) {
//
// Merge adjacent two free memory ranges.
//
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
Merged = TRUE;
//
// Mark MemoryHob to be unused(freed).
//
@@ -457,8 +460,8 @@ MergeFreeMemoryInMemoryAllocationHob (
// Merge adjacent two free memory ranges.
//
MemoryHob2->AllocDescriptor.MemoryBaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress;
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
MemoryHob2->AllocDescriptor.MemoryLength += MemoryHob->AllocDescriptor.MemoryLength;
Merged = TRUE;
//
// Mark MemoryHob to be unused(freed).
//
@@ -466,10 +469,12 @@ MergeFreeMemoryInMemoryAllocationHob (
break;
}
}
Hob2.Raw = GET_NEXT_HOB (Hob2);
Hob2.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob2.Raw);
}
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
@@ -492,41 +497,44 @@ MergeFreeMemoryInMemoryAllocationHob (
**/
EFI_STATUS
FindFreeMemoryFromMemoryAllocationHob (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Granularity,
OUT EFI_PHYSICAL_ADDRESS *Memory
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Granularity,
OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
UINT64 Bytes;
EFI_PHYSICAL_ADDRESS BaseAddress;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
UINT64 Bytes;
EFI_PHYSICAL_ADDRESS BaseAddress;
Bytes = LShiftU64 (Pages, EFI_PAGE_SHIFT);
BaseAddress = 0;
BaseAddress = 0;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) &&
(Hob.MemoryAllocation->AllocDescriptor.MemoryLength >= Bytes)) {
(Hob.MemoryAllocation->AllocDescriptor.MemoryLength >= Bytes))
{
//
// Found one memory allocation HOB with big enough free memory.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
BaseAddress = MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress +
MemoryAllocationHob->AllocDescriptor.MemoryLength - Bytes;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
BaseAddress = MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress +
MemoryAllocationHob->AllocDescriptor.MemoryLength - Bytes;
//
// Make sure the granularity could be satisfied.
//
BaseAddress &= ~((EFI_PHYSICAL_ADDRESS) Granularity - 1);
BaseAddress &= ~((EFI_PHYSICAL_ADDRESS)Granularity - 1);
if (BaseAddress >= MemoryAllocationHob->AllocDescriptor.MemoryBaseAddress) {
break;
}
BaseAddress = 0;
BaseAddress = 0;
MemoryAllocationHob = NULL;
}
//
// Continue to find.
//
@@ -545,6 +553,7 @@ FindFreeMemoryFromMemoryAllocationHob (
//
return FindFreeMemoryFromMemoryAllocationHob (MemoryType, Pages, Granularity, Memory);
}
return EFI_NOT_FOUND;
}
}
@@ -574,20 +583,20 @@ FindFreeMemoryFromMemoryAllocationHob (
EFI_STATUS
EFIAPI
PeiAllocatePages (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT EFI_PHYSICAL_ADDRESS *Memory
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
EFI_STATUS Status;
PEI_CORE_INSTANCE *PrivateData;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
UINTN RemainingPages;
UINTN Granularity;
UINTN Padding;
EFI_STATUS Status;
PEI_CORE_INSTANCE *PrivateData;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_PHYSICAL_ADDRESS *FreeMemoryBottom;
UINTN RemainingPages;
UINTN Granularity;
UINTN Padding;
if ((MemoryType != EfiLoaderCode) &&
(MemoryType != EfiLoaderData) &&
@@ -597,7 +606,8 @@ PeiAllocatePages (
(MemoryType != EfiBootServicesData) &&
(MemoryType != EfiACPIReclaimMemory) &&
(MemoryType != EfiReservedMemoryType) &&
(MemoryType != EfiACPIMemoryNVS)) {
(MemoryType != EfiACPIMemoryNVS))
{
return EFI_INVALID_PARAMETER;
}
@@ -613,16 +623,19 @@ PeiAllocatePages (
return EFI_NOT_AVAILABLE_YET;
}
if (RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANULARITY &&
(MemoryType == EfiACPIReclaimMemory ||
MemoryType == EfiACPIMemoryNVS ||
MemoryType == EfiRuntimeServicesCode ||
MemoryType == EfiRuntimeServicesData)) {
if ((RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANULARITY) &&
((MemoryType == EfiACPIReclaimMemory) ||
(MemoryType == EfiACPIMemoryNVS) ||
(MemoryType == EfiRuntimeServicesCode) ||
(MemoryType == EfiRuntimeServicesData)))
{
Granularity = RUNTIME_PAGE_ALLOCATION_GRANULARITY;
DEBUG ((DEBUG_INFO, "AllocatePages: aligning allocation to %d KB\n",
Granularity / SIZE_1KB));
DEBUG ((
DEBUG_INFO,
"AllocatePages: aligning allocation to %d KB\n",
Granularity / SIZE_1KB
));
}
if (!PrivateData->PeiMemoryInstalled && PrivateData->SwitchStackSignal) {
@@ -630,11 +643,11 @@ PeiAllocatePages (
// When PeiInstallMemory is called but temporary memory has *not* been moved to permanent memory,
// the AllocatePage will depend on the field of PEI_CORE_INSTANCE structure.
//
FreeMemoryTop = &(PrivateData->FreePhysicalMemoryTop);
FreeMemoryBottom = &(PrivateData->PhysicalMemoryBegin);
FreeMemoryTop = &(PrivateData->FreePhysicalMemoryTop);
FreeMemoryBottom = &(PrivateData->PhysicalMemoryBegin);
} else {
FreeMemoryTop = &(Hob.HandoffInformationTable->EfiFreeMemoryTop);
FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom);
FreeMemoryTop = &(Hob.HandoffInformationTable->EfiFreeMemoryTop);
FreeMemoryBottom = &(Hob.HandoffInformationTable->EfiFreeMemoryBottom);
}
//
@@ -642,7 +655,7 @@ PeiAllocatePages (
// If not aligned, make the allocation aligned.
//
Padding = *(FreeMemoryTop) & (Granularity - 1);
if ((UINTN) (*FreeMemoryTop - *FreeMemoryBottom) < Padding) {
if ((UINTN)(*FreeMemoryTop - *FreeMemoryBottom) < Padding) {
DEBUG ((DEBUG_ERROR, "AllocatePages failed: Out of space after padding.\n"));
return EFI_OUT_OF_RESOURCES;
}
@@ -676,9 +689,10 @@ PeiAllocatePages (
if (!EFI_ERROR (Status)) {
return Status;
}
DEBUG ((DEBUG_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64) Pages));
DEBUG ((DEBUG_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64) RemainingPages));
return EFI_OUT_OF_RESOURCES;
DEBUG ((DEBUG_ERROR, "AllocatePages failed: No 0x%lx Pages is available.\n", (UINT64)Pages));
DEBUG ((DEBUG_ERROR, "There is only left 0x%lx pages memory resource to be allocated.\n", (UINT64)RemainingPages));
return EFI_OUT_OF_RESOURCES;
} else {
//
// Update the PHIT to reflect the memory usage
@@ -713,13 +727,13 @@ PeiAllocatePages (
**/
VOID
FreeMemoryAllocationHob (
IN PEI_CORE_INSTANCE *PrivateData,
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHobToFree
IN PEI_CORE_INSTANCE *PrivateData,
IN OUT EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHobToFree
)
{
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
EFI_PEI_HOB_POINTERS Hob;
EFI_PHYSICAL_ADDRESS *FreeMemoryTop;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
Hob.Raw = PrivateData->HobList.Raw;
@@ -744,20 +758,23 @@ FreeMemoryAllocationHob (
MemoryAllocationHobToFree->Header.HobType = EFI_HOB_TYPE_UNUSED;
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType == EfiConventionalMemory) &&
(Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == *FreeMemoryTop)) {
(Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress == *FreeMemoryTop))
{
//
// Found memory allocation HOB that has EfiConventionalMemory MemoryType and
// MemoryBaseAddress == new *FreeMemoryTop.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
//
// Free memory allocation HOB iteratively.
//
@@ -783,23 +800,23 @@ FreeMemoryAllocationHob (
EFI_STATUS
EFIAPI
PeiFreePages (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN Pages
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_PHYSICAL_ADDRESS Memory,
IN UINTN Pages
)
{
PEI_CORE_INSTANCE *PrivateData;
UINT64 Bytes;
UINT64 Start;
UINT64 End;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
PEI_CORE_INSTANCE *PrivateData;
UINT64 Bytes;
UINT64 Start;
UINT64 End;
EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_MEMORY_ALLOCATION *MemoryAllocationHob;
Bytes = LShiftU64 (Pages, EFI_PAGE_SHIFT);
Start = Memory;
End = Start + Bytes - 1;
End = Start + Bytes - 1;
if (Pages == 0 || ((Start & EFI_PAGE_MASK) != 0) || (Start >= End)) {
if ((Pages == 0) || ((Start & EFI_PAGE_MASK) != 0) || (Start >= End)) {
return EFI_INVALID_PARAMETER;
}
@@ -814,17 +831,19 @@ PeiFreePages (
}
MemoryAllocationHob = NULL;
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
Hob.Raw = GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION);
while (Hob.Raw != NULL) {
if ((Hob.MemoryAllocation->AllocDescriptor.MemoryType != EfiConventionalMemory) &&
(Memory >= Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress) &&
((Memory + Bytes) <= (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength))) {
((Memory + Bytes) <= (Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress + Hob.MemoryAllocation->AllocDescriptor.MemoryLength)))
{
//
// Found the memory allocation HOB that includes the memory pages to be freed.
//
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *) Hob.Raw;
MemoryAllocationHob = (EFI_HOB_MEMORY_ALLOCATION *)Hob.Raw;
break;
}
Hob.Raw = GET_NEXT_HOB (Hob);
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw);
}
@@ -857,13 +876,13 @@ PeiFreePages (
EFI_STATUS
EFIAPI
PeiAllocatePool (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN UINTN Size,
OUT VOID **Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN UINTN Size,
OUT VOID **Buffer
)
{
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
EFI_STATUS Status;
EFI_HOB_MEMORY_POOL *Hob;
//
// If some "post-memory" PEIM wishes to allocate larger pool,

View File

@@ -17,7 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
/// This default instance of EFI_PEI_PCI_CFG2_PPI install assigned to EFI_PEI_SERVICE.PciCfg
/// when PeiCore's initialization.
///
EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi = {
EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi = {
PeiDefaultPciCfg2Read,
PeiDefaultPciCfg2Write,
PeiDefaultPciCfg2Modify
@@ -45,11 +45,11 @@ EFI_PEI_PCI_CFG2_PPI gPeiDefaultPciCfg2Ppi = {
EFI_STATUS
EFIAPI
PeiDefaultPciCfg2Read (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -76,11 +76,11 @@ PeiDefaultPciCfg2Read (
EFI_STATUS
EFIAPI
PeiDefaultPciCfg2Write (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN OUT VOID *Buffer
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN OUT VOID *Buffer
)
{
return EFI_NOT_AVAILABLE_YET;
@@ -110,12 +110,12 @@ PeiDefaultPciCfg2Write (
EFI_STATUS
EFIAPI
PeiDefaultPciCfg2Modify (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN VOID *SetBits,
IN VOID *ClearBits
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PCI_CFG2_PPI *This,
IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
IN UINT64 Address,
IN VOID *SetBits,
IN VOID *ClearBits
)
{
return EFI_NOT_AVAILABLE_YET;

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PeiMain.h"
EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiMemoryDiscoveredPpiGuid,
NULL
@@ -74,13 +74,13 @@ ShadowPeiCore (
IN PEI_CORE_INSTANCE *PrivateData
)
{
EFI_PEI_FILE_HANDLE PeiCoreFileHandle;
EFI_PHYSICAL_ADDRESS EntryPoint;
EFI_STATUS Status;
UINT32 AuthenticationState;
UINTN Index;
EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
UINTN PeiCoreFvIndex;
EFI_PEI_FILE_HANDLE PeiCoreFileHandle;
EFI_PHYSICAL_ADDRESS EntryPoint;
EFI_STATUS Status;
UINT32 AuthenticationState;
UINTN Index;
EFI_PEI_CORE_FV_LOCATION_PPI *PeiCoreFvLocationPpi;
UINTN PeiCoreFvIndex;
PeiCoreFileHandle = NULL;
//
@@ -94,20 +94,22 @@ ShadowPeiCore (
&gEfiPeiCoreFvLocationPpiGuid,
0,
NULL,
(VOID **) &PeiCoreFvLocationPpi
(VOID **)&PeiCoreFvLocationPpi
);
if (!EFI_ERROR (Status) && (PeiCoreFvLocationPpi->PeiCoreFvLocation != NULL)) {
//
// If PeiCoreFvLocation present, the PEI Core should be found from indicated FV
//
for (Index = 0; Index < PrivateData->FvCount; Index ++) {
for (Index = 0; Index < PrivateData->FvCount; Index++) {
if (PrivateData->Fv[Index].FvHandle == PeiCoreFvLocationPpi->PeiCoreFvLocation) {
PeiCoreFvIndex = Index;
break;
}
}
ASSERT (Index < PrivateData->FvCount);
}
//
// Find PEI Core from the given FV index
//
@@ -123,19 +125,19 @@ ShadowPeiCore (
// Shadow PEI Core into memory so it will run faster
//
Status = PeiLoadImage (
GetPeiServicesTablePointer (),
*((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),
PEIM_STATE_REGISTER_FOR_SHADOW,
&EntryPoint,
&AuthenticationState
);
GetPeiServicesTablePointer (),
*((EFI_PEI_FILE_HANDLE *)&PeiCoreFileHandle),
PEIM_STATE_REGISTER_FOR_SHADOW,
&EntryPoint,
&AuthenticationState
);
ASSERT_EFI_ERROR (Status);
//
// Compute the PeiCore's function address after shadowed PeiCore.
// _ModuleEntryPoint is PeiCore main function entry
//
return (PEICORE_FUNCTION_POINTER)((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);
return (PEICORE_FUNCTION_POINTER)((UINTN)EntryPoint + (UINTN)PeiCore - (UINTN)_ModuleEntryPoint);
}
/**
@@ -160,28 +162,28 @@ ShadowPeiCore (
VOID
EFIAPI
PeiCore (
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreDataPtr,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
IN VOID *Data
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreDataPtr,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList,
IN VOID *Data
)
{
PEI_CORE_INSTANCE PrivateData;
EFI_SEC_PEI_HAND_OFF *SecCoreData;
EFI_SEC_PEI_HAND_OFF NewSecCoreData;
EFI_STATUS Status;
PEI_CORE_TEMP_POINTERS TempPtr;
PEI_CORE_INSTANCE *OldCoreData;
EFI_PEI_CPU_IO_PPI *CpuIo;
EFI_PEI_PCI_CFG2_PPI *PciCfg;
EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;
UINTN Index;
PEI_CORE_INSTANCE PrivateData;
EFI_SEC_PEI_HAND_OFF *SecCoreData;
EFI_SEC_PEI_HAND_OFF NewSecCoreData;
EFI_STATUS Status;
PEI_CORE_TEMP_POINTERS TempPtr;
PEI_CORE_INSTANCE *OldCoreData;
EFI_PEI_CPU_IO_PPI *CpuIo;
EFI_PEI_PCI_CFG2_PPI *PciCfg;
EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
EFI_PEI_TEMPORARY_RAM_DONE_PPI *TemporaryRamDonePpi;
UINTN Index;
//
// Retrieve context passed into PEI Core
//
OldCoreData = (PEI_CORE_INSTANCE *) Data;
SecCoreData = (EFI_SEC_PEI_HAND_OFF *) SecCoreDataPtr;
OldCoreData = (PEI_CORE_INSTANCE *)Data;
SecCoreData = (EFI_SEC_PEI_HAND_OFF *)SecCoreDataPtr;
//
// Perform PEI Core phase specific actions.
@@ -206,59 +208,73 @@ PeiCore (
if (OldCoreData->HeapOffsetPositive) {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw + OldCoreData->HeapOffset);
if (OldCoreData->UnknownFvInfo != NULL) {
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *)((UINT8 *)OldCoreData->UnknownFvInfo + OldCoreData->HeapOffset);
}
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->CurrentFvFileHandles + OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);
OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.PpiList.PpiPtrs + OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs + OldCoreData->HeapOffset);
}
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *)((UINT8 *)OldCoreData->Fv + OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
OldCoreData->Fv[Index].PeimState = (UINT8 *)OldCoreData->Fv[Index].PeimState + OldCoreData->HeapOffset;
}
if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->Fv[Index].FvFileHandles + OldCoreData->HeapOffset);
}
}
OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid + OldCoreData->HeapOffset);
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
OldCoreData->TempFileGuid = (EFI_GUID *)((UINT8 *)OldCoreData->TempFileGuid + OldCoreData->HeapOffset);
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->TempFileHandles + OldCoreData->HeapOffset);
} else {
OldCoreData->HobList.Raw = (VOID *)(OldCoreData->HobList.Raw - OldCoreData->HeapOffset);
if (OldCoreData->UnknownFvInfo != NULL) {
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *) ((UINT8 *) OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
OldCoreData->UnknownFvInfo = (PEI_CORE_UNKNOW_FORMAT_FV_INFO *)((UINT8 *)OldCoreData->UnknownFvInfo - OldCoreData->HeapOffset);
}
if (OldCoreData->CurrentFvFileHandles != NULL) {
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
OldCoreData->CurrentFvFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->CurrentFvFileHandles - OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.PpiList.PpiPtrs != NULL) {
OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);
OldCoreData->PpiData.PpiList.PpiPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.PpiList.PpiPtrs - OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs != NULL) {
OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.CallbackNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
}
if (OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs != NULL) {
OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *) ((UINT8 *) OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs = (PEI_PPI_LIST_POINTERS *)((UINT8 *)OldCoreData->PpiData.DispatchNotifyList.NotifyPtrs - OldCoreData->HeapOffset);
}
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *) ((UINT8 *) OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index ++) {
OldCoreData->Fv = (PEI_CORE_FV_HANDLE *)((UINT8 *)OldCoreData->Fv - OldCoreData->HeapOffset);
for (Index = 0; Index < OldCoreData->FvCount; Index++) {
if (OldCoreData->Fv[Index].PeimState != NULL) {
OldCoreData->Fv[Index].PeimState = (UINT8 *) OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
OldCoreData->Fv[Index].PeimState = (UINT8 *)OldCoreData->Fv[Index].PeimState - OldCoreData->HeapOffset;
}
if (OldCoreData->Fv[Index].FvFileHandles != NULL) {
OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
OldCoreData->Fv[Index].FvFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->Fv[Index].FvFileHandles - OldCoreData->HeapOffset);
}
}
OldCoreData->TempFileGuid = (EFI_GUID *) ((UINT8 *) OldCoreData->TempFileGuid - OldCoreData->HeapOffset);
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *) ((UINT8 *) OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
OldCoreData->TempFileGuid = (EFI_GUID *)((UINT8 *)OldCoreData->TempFileGuid - OldCoreData->HeapOffset);
OldCoreData->TempFileHandles = (EFI_PEI_FILE_HANDLE *)((UINT8 *)OldCoreData->TempFileHandles - OldCoreData->HeapOffset);
}
//
@@ -276,10 +292,11 @@ PeiCore (
//
HandoffInformationTable = OldCoreData->HobList.HandoffInformationTable;
if (OldCoreData->HeapOffsetPositive) {
HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList + OldCoreData->HeapOffset;
HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList + OldCoreData->HeapOffset;
} else {
HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList - OldCoreData->HeapOffset;
HandoffInformationTable->EfiEndOfHobList = HandoffInformationTable->EfiEndOfHobList - OldCoreData->HeapOffset;
}
HandoffInformationTable->EfiMemoryTop = OldCoreData->PhysicalMemoryBegin + OldCoreData->PhysicalMemoryLength;
HandoffInformationTable->EfiMemoryBottom = OldCoreData->PhysicalMemoryBegin;
HandoffInformationTable->EfiFreeMemoryTop = OldCoreData->FreePhysicalMemoryTop;
@@ -306,22 +323,23 @@ PeiCore (
//
OldCoreData->PeimDispatcherReenter = TRUE;
if (PcdGet64(PcdLoadModuleAtFixAddressEnable) != 0 && (OldCoreData->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
if ((PcdGet64 (PcdLoadModuleAtFixAddressEnable) != 0) && (OldCoreData->HobList.HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME)) {
//
// if Loading Module at Fixed Address is enabled, allocate the PEI code memory range usage bit map array.
// Every bit in the array indicate the status of the corresponding memory page available or not
//
OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32(PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof(UINT64));
OldCoreData->PeiCodeMemoryRangeUsageBitMap = AllocateZeroPool (((PcdGet32 (PcdLoadFixAddressPeiCodePageNumber)>>6) + 1)*sizeof (UINT64));
}
//
// Shadow PEI Core. When permanent memory is available, shadow
// PEI Core and PEIMs to get high performance.
//
OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER) (UINTN) PeiCore;
OldCoreData->ShadowedPeiCore = (PEICORE_FUNCTION_POINTER)(UINTN)PeiCore;
if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes) ||
(HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnS3Boot)) ||
(HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME && PcdGetBool (PcdShadowPeimOnBoot))) {
((HandoffInformationTable->BootMode == BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnS3Boot)) ||
((HandoffInformationTable->BootMode != BOOT_ON_S3_RESUME) && PcdGetBool (PcdShadowPeimOnBoot)))
{
OldCoreData->ShadowedPeiCore = ShadowPeiCore (OldCoreData);
}
@@ -334,7 +352,7 @@ PeiCore (
// Should never reach here.
//
ASSERT (FALSE);
CpuDeadLoop();
CpuDeadLoop ();
UNREACHABLE ();
}
@@ -347,8 +365,8 @@ PeiCore (
CopyMem (&PrivateData, OldCoreData, sizeof (PrivateData));
CpuIo = (VOID*)PrivateData.ServiceTableShadow.CpuIo;
PciCfg = (VOID*)PrivateData.ServiceTableShadow.PciCfg;
CpuIo = (VOID *)PrivateData.ServiceTableShadow.CpuIo;
PciCfg = (VOID *)PrivateData.ServiceTableShadow.PciCfg;
CopyMem (&PrivateData.ServiceTableShadow, &gPs, sizeof (gPs));
@@ -374,7 +392,7 @@ PeiCore (
//
// Initialize PEI Core Services
//
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
InitializeMemoryServices (&PrivateData, SecCoreData, OldCoreData);
//
// Update performance measurements
@@ -387,7 +405,6 @@ PeiCore (
//
PERF_CROSSMODULE_BEGIN ("PEI");
PERF_INMODULE_BEGIN ("PreMem");
} else {
PERF_INMODULE_END ("PreMem");
PERF_INMODULE_BEGIN ("PostMem");
@@ -397,8 +414,8 @@ PeiCore (
// Complete PEI Core Service initialization
//
InitializeSecurityServices (&PrivateData.Ps, OldCoreData);
InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);
InitializeImageServices (&PrivateData, OldCoreData);
InitializeDispatcherData (&PrivateData, OldCoreData, SecCoreData);
InitializeImageServices (&PrivateData, OldCoreData);
//
// Perform PEI Core Phase specific actions
@@ -416,7 +433,7 @@ PeiCore (
// If SEC provided the PpiList, process it.
//
if (PpiList != NULL) {
ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);
ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps, PpiList);
}
} else {
if (PcdGetBool (PcdMigrateTemporaryRamFirmwareVolumes)) {
@@ -443,7 +460,7 @@ PeiCore (
&gEfiTemporaryRamDonePpiGuid,
0,
NULL,
(VOID**)&TemporaryRamDonePpi
(VOID **)&TemporaryRamDonePpi
);
if (!EFI_ERROR (Status)) {
//
@@ -475,7 +492,7 @@ PeiCore (
//
// Check if InstallPeiMemory service was called on non-S3 resume boot path.
//
ASSERT(PrivateData.PeiMemoryInstalled == TRUE);
ASSERT (PrivateData.PeiMemoryInstalled == TRUE);
}
//
@@ -518,7 +535,7 @@ PeiCore (
// Should never reach here.
//
ASSERT_EFI_ERROR (Status);
CpuDeadLoop();
CpuDeadLoop ();
UNREACHABLE ();
}

View File

@@ -21,19 +21,20 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
VOID
ConvertPointer (
IN OUT VOID **Pointer,
IN UINTN TempBottom,
IN UINTN TempTop,
IN UINTN Offset,
IN BOOLEAN OffsetPositive
IN OUT VOID **Pointer,
IN UINTN TempBottom,
IN UINTN TempTop,
IN UINTN Offset,
IN BOOLEAN OffsetPositive
)
{
if (((UINTN) *Pointer < TempTop) &&
((UINTN) *Pointer >= TempBottom)) {
if (((UINTN)*Pointer < TempTop) &&
((UINTN)*Pointer >= TempBottom))
{
if (OffsetPositive) {
*Pointer = (VOID *) ((UINTN) *Pointer + Offset);
*Pointer = (VOID *)((UINTN)*Pointer + Offset);
} else {
*Pointer = (VOID *) ((UINTN) *Pointer - Offset);
*Pointer = (VOID *)((UINTN)*Pointer - Offset);
}
}
}
@@ -55,7 +56,7 @@ ConvertPointerInRanges (
IN OUT VOID **Pointer
)
{
UINT8 IndexHole;
UINT8 IndexHole;
if (PrivateData->MemoryPages.Size != 0) {
//
@@ -96,7 +97,7 @@ ConvertPointerInRanges (
//
// Convert PPI pointer in old TempRam Hole
//
for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) {
for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole++) {
if (PrivateData->HoleData[IndexHole].Size == 0) {
continue;
}
@@ -139,12 +140,12 @@ ConvertSinglePpiPointer (
// 2. Convert the pointer to the GUID in the PPI or NOTIFY descriptor
// from the old TempRam to the relocated physical memory.
//
ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Guid);
ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **)&PpiPointer->Ppi->Guid);
//
// 3. Convert the pointer to the PPI interface structure in the PPI descriptor
// from the old TempRam to the relocated physical memory.
//
ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Ppi);
ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **)&PpiPointer->Ppi->Ppi);
}
/**
@@ -162,7 +163,7 @@ ConvertPpiPointers (
IN PEI_CORE_INSTANCE *PrivateData
)
{
UINT8 Index;
UINT8 Index;
//
// Convert normal PPIs.
@@ -210,10 +211,10 @@ ConvertPpiPointers (
**/
VOID
ConvertPpiPointersFv (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle,
IN UINTN FvSize
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN OrgFvHandle,
IN UINTN FvHandle,
IN UINTN FvSize
)
{
UINT8 Index;
@@ -229,18 +230,18 @@ ConvertPpiPointersFv (
if (FvHandle > OrgFvHandle) {
OffsetPositive = TRUE;
Offset = FvHandle - OrgFvHandle;
Offset = FvHandle - OrgFvHandle;
} else {
OffsetPositive = FALSE;
Offset = OrgFvHandle - FvHandle;
Offset = OrgFvHandle - FvHandle;
}
DEBUG ((DEBUG_VERBOSE, "Converting PPI pointers in FV.\n"));
DEBUG ((
DEBUG_VERBOSE,
" OrgFvHandle at 0x%08x. FvHandle at 0x%08x. FvSize = 0x%x\n",
(UINTN) OrgFvHandle,
(UINTN) FvHandle,
(UINTN)OrgFvHandle,
(UINTN)FvHandle,
FvSize
));
DEBUG ((
@@ -251,46 +252,46 @@ ConvertPpiPointersFv (
));
for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
ConvertPointer (
(VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Guid,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Notify,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Guid,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Notify,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
}
for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
ConvertPointer (
(VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
(VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
(VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Notify,
(VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Notify,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
@@ -300,21 +301,21 @@ ConvertPpiPointersFv (
for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
ConvertPointer (
(VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
(VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
(VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
OffsetPositive
);
ConvertPointer (
(VOID **) &PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi,
(VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi,
OrgFvHandle,
OrgFvHandle + FvSize,
Offset,
@@ -331,7 +332,8 @@ ConvertPpiPointersFv (
if ((((INT32 *)Guid)[0] == ((INT32 *)GuidCheckList[GuidIndex])[0]) &&
(((INT32 *)Guid)[1] == ((INT32 *)GuidCheckList[GuidIndex])[1]) &&
(((INT32 *)Guid)[2] == ((INT32 *)GuidCheckList[GuidIndex])[2]) &&
(((INT32 *)Guid)[3] == ((INT32 *)GuidCheckList[GuidIndex])[3])) {
(((INT32 *)Guid)[3] == ((INT32 *)GuidCheckList[GuidIndex])[3]))
{
FvInfoPpi = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi;
DEBUG ((DEBUG_VERBOSE, " FvInfo: %p -> ", FvInfoPpi->FvInfo));
if ((UINTN)FvInfoPpi->FvInfo == OrgFvHandle) {
@@ -344,6 +346,7 @@ ConvertPpiPointersFv (
);
DEBUG ((DEBUG_VERBOSE, "%p", FvInfoPpi->FvInfo));
}
DEBUG ((DEBUG_VERBOSE, "\n"));
break;
}
@@ -360,11 +363,11 @@ ConvertPpiPointersFv (
**/
VOID
DumpPpiList (
IN PEI_CORE_INSTANCE *PrivateData
IN PEI_CORE_INSTANCE *PrivateData
)
{
DEBUG_CODE_BEGIN ();
UINTN Index;
UINTN Index;
if (PrivateData == NULL) {
return;
@@ -376,46 +379,51 @@ DumpPpiList (
"CallbackNotify[%2d] {%g} at 0x%x (%a)\n",
Index,
PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Guid,
(UINTN) PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
(UINTN)PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
(
!(
((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
!(
((EFI_PHYSICAL_ADDRESS)(UINTN)PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS)((UINTN)PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
? "CAR" : "Post-Memory"
)
)
));
}
for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
DEBUG ((DEBUG_VERBOSE,
"DispatchNotify[%2d] {%g} at 0x%x (%a)\n",
Index,
PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
(UINTN) PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
(
!(
((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw >=PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
DEBUG ((
DEBUG_VERBOSE,
"DispatchNotify[%2d] {%g} at 0x%x (%a)\n",
Index,
PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
(UINTN)PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
(
!(
((EFI_PHYSICAL_ADDRESS)(UINTN)PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS)((UINTN)PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw) + sizeof (EFI_PEI_NOTIFY_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
? "CAR" : "Post-Memory"
)
));
));
}
for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
DEBUG ((DEBUG_VERBOSE,
"PPI[%2d] {%g} at 0x%x (%a)\n",
Index,
PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
(UINTN) PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
(
!(
((EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS) ((UINTN) PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw) + sizeof (EFI_PEI_PPI_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
DEBUG ((
DEBUG_VERBOSE,
"PPI[%2d] {%g} at 0x%x (%a)\n",
Index,
PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
(UINTN)PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
(
!(
((EFI_PHYSICAL_ADDRESS)(UINTN)PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
(((EFI_PHYSICAL_ADDRESS)((UINTN)PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw) + sizeof (EFI_PEI_PPI_DESCRIPTOR)) < PrivateData->FreePhysicalMemoryTop)
)
? "CAR" : "Post-Memory"
)
));
));
}
DEBUG_CODE_END ();
}
@@ -444,21 +452,21 @@ InternalPeiInstallPpi (
IN BOOLEAN Single
)
{
PEI_CORE_INSTANCE *PrivateData;
PEI_PPI_LIST *PpiListPointer;
UINTN Index;
UINTN LastCount;
VOID *TempPtr;
PEI_CORE_INSTANCE *PrivateData;
PEI_PPI_LIST *PpiListPointer;
UINTN Index;
UINTN LastCount;
VOID *TempPtr;
if (PpiList == NULL) {
return EFI_INVALID_PARAMETER;
}
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
PpiListPointer = &PrivateData->PpiData.PpiList;
Index = PpiListPointer->CurrentCount;
LastCount = Index;
Index = PpiListPointer->CurrentCount;
LastCount = Index;
//
// This is loop installs all PPI descriptors in the PpiList. It is terminated
@@ -466,7 +474,7 @@ InternalPeiInstallPpi (
// EFI_PEI_PPI_DESCRIPTOR in the list.
//
for (;;) {
for ( ; ;) {
//
// Check if it is a valid PPI.
// If not, rollback list to exclude all in this list.
@@ -474,8 +482,8 @@ InternalPeiInstallPpi (
//
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
PpiListPointer->CurrentCount = LastCount;
DEBUG((DEBUG_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
return EFI_INVALID_PARAMETER;
DEBUG ((DEBUG_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
return EFI_INVALID_PARAMETER;
}
if (Index >= PpiListPointer->MaxCount) {
@@ -491,12 +499,12 @@ InternalPeiInstallPpi (
PpiListPointer->PpiPtrs,
sizeof (PEI_PPI_LIST_POINTERS) * PpiListPointer->MaxCount
);
PpiListPointer->PpiPtrs = TempPtr;
PpiListPointer->PpiPtrs = TempPtr;
PpiListPointer->MaxCount = PpiListPointer->MaxCount + PPI_GROWTH_STEP;
}
DEBUG((DEBUG_INFO, "Install PPI: %g\n", PpiList->Guid));
PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) PpiList;
DEBUG ((DEBUG_INFO, "Install PPI: %g\n", PpiList->Guid));
PpiListPointer->PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *)PpiList;
Index++;
PpiListPointer->CurrentCount++;
@@ -506,12 +514,14 @@ InternalPeiInstallPpi (
//
break;
} else if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)
{
//
// Continue until the end of the PPI List.
//
break;
}
//
// Go to the next descriptor.
//
@@ -583,19 +593,18 @@ PeiReInstallPpi (
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
)
{
PEI_CORE_INSTANCE *PrivateData;
UINTN Index;
PEI_CORE_INSTANCE *PrivateData;
UINTN Index;
if ((OldPpi == NULL) || (NewPpi == NULL)) {
return EFI_INVALID_PARAMETER;
}
if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
return EFI_INVALID_PARAMETER;
return EFI_INVALID_PARAMETER;
}
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
//
// Find the old PPI instance in the database. If we can not find it,
@@ -606,6 +615,7 @@ PeiReInstallPpi (
break;
}
}
if (Index == PrivateData->PpiData.PpiList.CurrentCount) {
return EFI_NOT_FOUND;
}
@@ -613,8 +623,8 @@ PeiReInstallPpi (
//
// Replace the old PPI with the new one.
//
DEBUG((DEBUG_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
DEBUG ((DEBUG_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *)NewPpi;
//
// Process any callback level notifies for the newly installed PPI.
@@ -650,26 +660,25 @@ PeiReInstallPpi (
EFI_STATUS
EFIAPI
PeiLocatePpi (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_GUID *Guid,
IN UINTN Instance,
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
IN OUT VOID **Ppi
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_GUID *Guid,
IN UINTN Instance,
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
IN OUT VOID **Ppi
)
{
PEI_CORE_INSTANCE *PrivateData;
UINTN Index;
EFI_GUID *CheckGuid;
EFI_PEI_PPI_DESCRIPTOR *TempPtr;
PEI_CORE_INSTANCE *PrivateData;
UINTN Index;
EFI_GUID *CheckGuid;
EFI_PEI_PPI_DESCRIPTOR *TempPtr;
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
//
// Search the data base for the matching instance of the GUIDed PPI.
//
for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
TempPtr = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi;
CheckGuid = TempPtr->Guid;
//
@@ -680,9 +689,9 @@ PeiLocatePpi (
if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&
(((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&
(((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&
(((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) {
(((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3]))
{
if (Instance == 0) {
if (PpiDescriptor != NULL) {
*PpiDescriptor = TempPtr;
}
@@ -691,9 +700,9 @@ PeiLocatePpi (
*Ppi = TempPtr->Ppi;
}
return EFI_SUCCESS;
}
Instance--;
}
}
@@ -738,15 +747,15 @@ InternalPeiNotifyPpi (
return EFI_INVALID_PARAMETER;
}
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
CallbackNotifyListPointer = &PrivateData->PpiData.CallbackNotifyList;
CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
LastCallbackNotifyCount = CallbackNotifyIndex;
CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
LastCallbackNotifyCount = CallbackNotifyIndex;
DispatchNotifyListPointer = &PrivateData->PpiData.DispatchNotifyList;
DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
LastDispatchNotifyCount = DispatchNotifyIndex;
DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
LastDispatchNotifyCount = DispatchNotifyIndex;
//
// This is loop installs all Notify descriptors in the NotifyList. It is
@@ -754,15 +763,15 @@ InternalPeiNotifyPpi (
// EFI_PEI_NOTIFY_DESCRIPTOR in the list.
//
for (;;) {
for ( ; ;) {
//
// If some of the PPI data is invalid restore original Notify PPI database value
//
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
DEBUG((DEBUG_ERROR, "ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid, NotifyList->Notify));
return EFI_INVALID_PARAMETER;
CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
DEBUG ((DEBUG_ERROR, "ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid, NotifyList->Notify));
return EFI_INVALID_PARAMETER;
}
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
@@ -780,9 +789,10 @@ InternalPeiNotifyPpi (
sizeof (PEI_PPI_LIST_POINTERS) * CallbackNotifyListPointer->MaxCount
);
CallbackNotifyListPointer->NotifyPtrs = TempPtr;
CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
}
CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
CallbackNotifyListPointer->NotifyPtrs[CallbackNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *)NotifyList;
CallbackNotifyIndex++;
CallbackNotifyListPointer->CurrentCount++;
} else {
@@ -800,14 +810,15 @@ InternalPeiNotifyPpi (
sizeof (PEI_PPI_LIST_POINTERS) * DispatchNotifyListPointer->MaxCount
);
DispatchNotifyListPointer->NotifyPtrs = TempPtr;
DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
}
DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
DispatchNotifyListPointer->NotifyPtrs[DispatchNotifyIndex].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *)NotifyList;
DispatchNotifyIndex++;
DispatchNotifyListPointer->CurrentCount++;
}
DEBUG((DEBUG_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
DEBUG ((DEBUG_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
if (Single) {
//
@@ -815,12 +826,14 @@ InternalPeiNotifyPpi (
//
break;
} else if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)
{
//
// Continue until the end of the Notify List.
//
break;
}
//
// Go to the next descriptor.
//
@@ -839,7 +852,7 @@ InternalPeiNotifyPpi (
CallbackNotifyListPointer->CurrentCount
);
return EFI_SUCCESS;
return EFI_SUCCESS;
}
/**
@@ -878,7 +891,7 @@ ProcessDispatchNotifyList (
IN PEI_CORE_INSTANCE *PrivateData
)
{
UINTN TempValue;
UINTN TempValue;
while (TRUE) {
//
@@ -927,6 +940,7 @@ ProcessDispatchNotifyList (
break;
}
}
return;
}
@@ -945,18 +959,18 @@ ProcessDispatchNotifyList (
VOID
ProcessNotify (
IN PEI_CORE_INSTANCE *PrivateData,
IN UINTN NotifyType,
IN INTN InstallStartIndex,
IN INTN InstallStopIndex,
IN INTN NotifyStartIndex,
IN INTN NotifyStopIndex
IN UINTN NotifyType,
IN INTN InstallStartIndex,
IN INTN InstallStopIndex,
IN INTN NotifyStartIndex,
IN INTN NotifyStopIndex
)
{
INTN Index1;
INTN Index2;
EFI_GUID *SearchGuid;
EFI_GUID *CheckGuid;
EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
INTN Index1;
INTN Index2;
EFI_GUID *SearchGuid;
EFI_GUID *CheckGuid;
EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
@@ -977,13 +991,16 @@ ProcessNotify (
if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&
(((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&
(((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&
(((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {
DEBUG ((DEBUG_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n",
(((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3]))
{
DEBUG ((
DEBUG_INFO,
"Notify: PPI Guid: %g, Peim notify entry point: %p\n",
SearchGuid,
NotifyDescriptor->Notify
));
NotifyDescriptor->Notify (
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
(EFI_PEI_SERVICES **)GetPeiServicesTablePointer (),
NotifyDescriptor,
(PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
);
@@ -1002,20 +1019,20 @@ ProcessNotify (
**/
VOID
ProcessPpiListFromSec (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
IN CONST EFI_PEI_SERVICES **PeiServices,
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
)
{
EFI_STATUS Status;
EFI_SEC_HOB_DATA_PPI *SecHobDataPpi;
EFI_HOB_GENERIC_HEADER *SecHobList;
EFI_STATUS Status;
EFI_SEC_HOB_DATA_PPI *SecHobDataPpi;
EFI_HOB_GENERIC_HEADER *SecHobList;
for (;;) {
for ( ; ;) {
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) != 0) {
//
// It is a notification PPI.
//
Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *) PpiList, TRUE);
Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *)PpiList, TRUE);
ASSERT_EFI_ERROR (Status);
} else {
//
@@ -1041,7 +1058,7 @@ ProcessPpiListFromSec (
// returned into the HOB list. It does this after installing all PPIs passed from SEC
// into the PPI database and before dispatching any PEIMs.
//
Status = PeiLocatePpi (PeiServices, &gEfiSecHobDataPpiGuid, 0, NULL, (VOID **) &SecHobDataPpi);
Status = PeiLocatePpi (PeiServices, &gEfiSecHobDataPpiGuid, 0, NULL, (VOID **)&SecHobDataPpi);
if (!EFI_ERROR (Status)) {
Status = SecHobDataPpi->GetHobs (SecHobDataPpi, &SecHobList);
if (!EFI_ERROR (Status)) {
@@ -1061,8 +1078,8 @@ ProcessPpiListFromSec (
**/
VOID
ConvertPeiCorePpiPointers (
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_FV_HANDLE *CoreFvHandle
IN PEI_CORE_INSTANCE *PrivateData,
IN PEI_CORE_FV_HANDLE *CoreFvHandle
)
{
EFI_FV_FILE_INFO FileInfo;
@@ -1080,11 +1097,11 @@ ConvertPeiCorePpiPointers (
// Find the PEI Core in the BFV in temporary memory.
//
Status = CoreFvHandle->FvPpi->FindFileByType (
CoreFvHandle->FvPpi,
EFI_FV_FILETYPE_PEI_CORE,
CoreFvHandle->FvHandle,
&PeiCoreFileHandle
);
CoreFvHandle->FvPpi,
EFI_FV_FILETYPE_PEI_CORE,
CoreFvHandle->FvHandle,
&PeiCoreFileHandle
);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
@@ -1097,21 +1114,21 @@ ConvertPeiCorePpiPointers (
//
// Find PEI Core EntryPoint in the BFV in temporary memory.
//
Status = PeCoffLoaderGetEntryPoint ((VOID *) (UINTN) PeiCoreImageBase, &PeiCoreEntryPoint);
Status = PeCoffLoaderGetEntryPoint ((VOID *)(UINTN)PeiCoreImageBase, &PeiCoreEntryPoint);
ASSERT_EFI_ERROR (Status);
OrgImageBase = (UINTN) PeiCoreImageBase;
MigratedImageBase = (UINTN) _ModuleEntryPoint - ((UINTN) PeiCoreEntryPoint - (UINTN) PeiCoreImageBase);
OrgImageBase = (UINTN)PeiCoreImageBase;
MigratedImageBase = (UINTN)_ModuleEntryPoint - ((UINTN)PeiCoreEntryPoint - (UINTN)PeiCoreImageBase);
//
// Size of loaded PEI_CORE in permanent memory.
//
PeiCoreModuleSize = (UINTN)FileInfo.BufferSize - ((UINTN) OrgImageBase - (UINTN) FileInfo.Buffer);
PeiCoreModuleSize = (UINTN)FileInfo.BufferSize - ((UINTN)OrgImageBase - (UINTN)FileInfo.Buffer);
//
// Migrate PEI_CORE PPI pointers from temporary memory to newly
// installed PEI_CORE in permanent memory.
//
ConvertPpiPointersFv (PrivateData, (UINTN) OrgImageBase, (UINTN) MigratedImageBase, PeiCoreModuleSize);
ConvertPpiPointersFv (PrivateData, (UINTN)OrgImageBase, (UINTN)MigratedImageBase, PeiCoreModuleSize);
}
}

View File

@@ -59,7 +59,7 @@ PeiResetSystem (
//
// No reset PPIs are available yet.
//
return EFI_NOT_AVAILABLE_YET;
return EFI_NOT_AVAILABLE_YET;
}
/**

View File

@@ -8,11 +8,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PeiMain.h"
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiPeiSecurity2PpiGuid,
SecurityPpiNotifyCallback
EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
&gEfiPeiSecurity2PpiGuid,
SecurityPpiNotifyCallback
};
/**
@@ -25,13 +24,14 @@ EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
**/
VOID
InitializeSecurityServices (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_CORE_INSTANCE *OldCoreData
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_CORE_INSTANCE *OldCoreData
)
{
if (OldCoreData == NULL) {
PeiServicesNotifyPpi (&mNotifyList);
}
return;
}
@@ -55,7 +55,7 @@ SecurityPpiNotifyCallback (
IN VOID *Ppi
)
{
PEI_CORE_INSTANCE *PrivateData;
PEI_CORE_INSTANCE *PrivateData;
//
// Get PEI Core private data
@@ -68,6 +68,7 @@ SecurityPpiNotifyCallback (
if (PrivateData->PrivateSecurityPpi == NULL) {
PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY2_PPI *)Ppi;
}
return EFI_SUCCESS;
}
@@ -85,14 +86,14 @@ SecurityPpiNotifyCallback (
**/
EFI_STATUS
VerifyPeim (
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_PEI_FV_HANDLE VolumeHandle,
IN EFI_PEI_FILE_HANDLE FileHandle,
IN UINT32 AuthenticationStatus
IN PEI_CORE_INSTANCE *PrivateData,
IN EFI_PEI_FV_HANDLE VolumeHandle,
IN EFI_PEI_FILE_HANDLE FileHandle,
IN UINT32 AuthenticationStatus
)
{
EFI_STATUS Status;
BOOLEAN DeferExecution;
EFI_STATUS Status;
BOOLEAN DeferExecution;
Status = EFI_NOT_FOUND;
if (PrivateData->PrivateSecurityPpi == NULL) {
@@ -109,7 +110,7 @@ VerifyPeim (
// Check to see if the image is OK
//
Status = PrivateData->PrivateSecurityPpi->AuthenticationState (
(CONST EFI_PEI_SERVICES **) &PrivateData->Ps,
(CONST EFI_PEI_SERVICES **)&PrivateData->Ps,
PrivateData->PrivateSecurityPpi,
AuthenticationStatus,
VolumeHandle,
@@ -120,10 +121,10 @@ VerifyPeim (
Status = EFI_SECURITY_VIOLATION;
}
}
return Status;
}
/**
Verify a Firmware volume.

View File

@@ -27,16 +27,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
EFI_STATUS
EFIAPI
PeiReportStatusCode (
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN CONST EFI_GUID *CallerId,
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
IN CONST EFI_GUID *CallerId,
IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
)
{
EFI_STATUS Status;
EFI_PEI_PROGRESS_CODE_PPI *StatusCodePpi;
EFI_STATUS Status;
EFI_PEI_PROGRESS_CODE_PPI *StatusCodePpi;
//
// Locate StatusCode Ppi.
@@ -50,19 +50,16 @@ PeiReportStatusCode (
if (!EFI_ERROR (Status)) {
Status = StatusCodePpi->ReportStatusCode (
PeiServices,
CodeType,
Value,
Instance,
CallerId,
Data
);
PeiServices,
CodeType,
Value,
Instance,
CallerId,
Data
);
return Status;
return Status;
}
return EFI_NOT_AVAILABLE_YET;
return EFI_NOT_AVAILABLE_YET;
}