UefiPayloadPkg: Apply uncrustify changes

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

Apply uncrustify changes to .c/.h files in the UefiPayloadPkg 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: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Michael Kubacki
2021-12-05 14:54:18 -08:00
committed by mergify[bot]
parent 053e878bfb
commit e5efcf8be8
76 changed files with 4281 additions and 4072 deletions

View File

@ -47,6 +47,7 @@ ReserveResourceInGcd (
Length Length
)); ));
} }
Status = gDS->AllocateMemorySpace ( Status = gDS->AllocateMemorySpace (
EfiGcdAllocateAddress, EfiGcdAllocateAddress,
GcdType, GcdType,
@ -70,6 +71,7 @@ ReserveResourceInGcd (
Length Length
)); ));
} }
Status = gDS->AllocateIoSpace ( Status = gDS->AllocateIoSpace (
EfiGcdAllocateAddress, EfiGcdAllocateAddress,
GcdType, GcdType,
@ -80,10 +82,10 @@ ReserveResourceInGcd (
NULL NULL
); );
} }
return Status; return Status;
} }
/** /**
Main entry for the bootloader support DXE module. Main entry for the bootloader support DXE module.
@ -144,4 +146,3 @@ BlDxeEntryPoint (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -5,6 +5,7 @@ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef __DXE_BOOTLOADER_SUPPORT_H__ #ifndef __DXE_BOOTLOADER_SUPPORT_H__
#define __DXE_BOOTLOADER_SUPPORT_H__ #define __DXE_BOOTLOADER_SUPPORT_H__

View File

@ -15,7 +15,7 @@
PLD_S3_COMMUNICATION mPldS3Hob; PLD_S3_COMMUNICATION mPldS3Hob;
EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *mSmramHob = NULL; EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *mSmramHob = NULL;
PLD_SMM_REGISTERS *mSmmRegisterHob = NULL;; PLD_SMM_REGISTERS *mSmmRegisterHob = NULL;
UINT64 mSmmFeatureControl = 0; UINT64 mSmmFeatureControl = 0;
/** /**
@ -47,10 +47,12 @@ SaveSmmInfoForS3 (
PldSmmInfo->Header.Header.HobLength = (UINT16)(sizeof (PLD_TO_BL_SMM_INFO) + gSmst->NumberOfCpus * sizeof (CPU_SMMBASE)); PldSmmInfo->Header.Header.HobLength = (UINT16)(sizeof (PLD_TO_BL_SMM_INFO) + gSmst->NumberOfCpus * sizeof (CPU_SMMBASE));
for (Index = 0; Index < mSmramHob->NumberOfSmmReservedRegions; Index++) { for (Index = 0; Index < mSmramHob->NumberOfSmmReservedRegions; Index++) {
if ((mPldS3Hob.CommBuffer.PhysicalStart >= mSmramHob->Descriptor[Index].PhysicalStart) && if ((mPldS3Hob.CommBuffer.PhysicalStart >= mSmramHob->Descriptor[Index].PhysicalStart) &&
(mPldS3Hob.CommBuffer.PhysicalStart < mSmramHob->Descriptor[Index].PhysicalStart + mSmramHob->Descriptor[Index].PhysicalSize)) { (mPldS3Hob.CommBuffer.PhysicalStart < mSmramHob->Descriptor[Index].PhysicalStart + mSmramHob->Descriptor[Index].PhysicalSize))
{
break; break;
} }
} }
if (Index == mSmramHob->NumberOfSmmReservedRegions) { if (Index == mSmramHob->NumberOfSmmReservedRegions) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
@ -79,6 +81,7 @@ SaveSmmInfoForS3 (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
PldSmmInfo->S3Info.CpuCount = (UINT32)gSmst->NumberOfCpus; PldSmmInfo->S3Info.CpuCount = (UINT32)gSmst->NumberOfCpus;
SmmBaseInfo = &PldSmmInfo->S3Info.SmmBase[0]; SmmBaseInfo = &PldSmmInfo->S3Info.SmmBase[0];
for (Index = 0; Index < gSmst->NumberOfCpus; Index++) { for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {
@ -96,7 +99,6 @@ SaveSmmInfoForS3 (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get specified SMI register based on given register ID Get specified SMI register based on given register ID
@ -118,6 +120,7 @@ GetRegisterById (
return &mSmmRegisterHob->Registers[Index]; return &mSmmRegisterHob->Registers[Index];
} }
} }
return NULL; return NULL;
} }
@ -147,7 +150,8 @@ LockSmiGlobalEn (
(SmiLockReg->Address.Address != 0) && (SmiLockReg->Address.Address != 0) &&
(SmiLockReg->Address.RegisterBitWidth == 1) && (SmiLockReg->Address.RegisterBitWidth == 1) &&
(SmiLockReg->Address.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) && (SmiLockReg->Address.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) &&
(SmiLockReg->Value == 1)) { (SmiLockReg->Value == 1))
{
DEBUG ((DEBUG_ERROR, "LockSmiGlobalEn ....is locked\n")); DEBUG ((DEBUG_ERROR, "LockSmiGlobalEn ....is locked\n"));
MmioOr32 ((UINT32)SmiLockReg->Address.Address, 1 << SmiLockReg->Address.RegisterBitOffset); MmioOr32 ((UINT32)SmiLockReg->Address.Address, 1 << SmiLockReg->Address.RegisterBitOffset);
@ -166,7 +170,6 @@ SmmFeatureLockOnS3 (
VOID VOID
) )
{ {
if (mSmmFeatureControl != 0) { if (mSmmFeatureControl != 0) {
return; return;
} }
@ -178,11 +181,10 @@ SmmFeatureLockOnS3 (
// //
AsmWriteMsr64 (MSR_SMM_FEATURE_CONTROL, mSmmFeatureControl | 0x5); AsmWriteMsr64 (MSR_SMM_FEATURE_CONTROL, mSmmFeatureControl | 0x5);
} }
mSmmFeatureControl = AsmReadMsr64 (MSR_SMM_FEATURE_CONTROL); mSmmFeatureControl = AsmReadMsr64 (MSR_SMM_FEATURE_CONTROL);
} }
/** /**
Function to program SMRR base and mask. Function to program SMRR base and mask.
@ -230,6 +232,7 @@ SetSmrrOnS3 (
DEBUG ((DEBUG_ERROR, "Two SMM regions are not continous.\n")); DEBUG ((DEBUG_ERROR, "Two SMM regions are not continous.\n"));
return; return;
} }
SmmSize += (UINT32)(UINTN)mSmramHob->Descriptor[1].PhysicalSize; SmmSize += (UINT32)(UINTN)mSmramHob->Descriptor[1].PhysicalSize;
} }
@ -272,7 +275,6 @@ SetSmrrOnS3 (
} }
} }
/** /**
Software SMI callback for restoring SMRR base and mask in S3 path. Software SMI callback for restoring SMRR base and mask in S3 path.
@ -302,7 +304,6 @@ BlSwSmiHandler (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Lock SMI in this SMM ready to lock event. Lock SMI in this SMM ready to lock event.
@ -328,7 +329,6 @@ BlSupportSmmReadyToLockCallback (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
The driver's entry point. The driver's entry point.
@ -380,6 +380,7 @@ BlSupportSmm (
if (mSmramHob == NULL) { if (mSmramHob == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (mSmramHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob)); CopyMem (mSmramHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob));
} else { } else {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -395,6 +396,7 @@ BlSupportSmm (
if (mSmmRegisterHob == NULL) { if (mSmmRegisterHob == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (mSmmRegisterHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob)); CopyMem (mSmmRegisterHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob));
} else { } else {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -407,6 +409,7 @@ BlSupportSmm (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
SwContext.SwSmiInputValue = (UINTN)-1; SwContext.SwSmiInputValue = (UINTN)-1;
Status = SwDispatch->Register (SwDispatch, BlSwSmiHandler, &SwContext, &SwHandle); Status = SwDispatch->Register (SwDispatch, BlSwSmiHandler, &SwContext, &SwHandle);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -428,4 +431,3 @@ BlSupportSmm (
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -5,6 +5,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef BL_SUPPORT_SMM_H_ #ifndef BL_SUPPORT_SMM_H_
#define BL_SUPPORT_SMM_H_ #define BL_SUPPORT_SMM_H_
@ -38,4 +39,3 @@ typedef struct {
} SMRR_BASE_MASK; } SMRR_BASE_MASK;
#endif #endif

View File

@ -81,6 +81,7 @@ InitVariableStore (
ASSERT (FALSE); ASSERT (FALSE);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
NvVariableInfo = (NV_VARIABLE_INFO *)GET_GUID_HOB_DATA (GuidHob); NvVariableInfo = (NV_VARIABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);
// //
@ -104,6 +105,7 @@ InitVariableStore (
if (NvVariableSize >= 0x80000000) { if (NvVariableSize >= 0x80000000) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Status = PcdSet32S (PcdFlashNvStorageVariableSize, NvVariableSize); Status = PcdSet32S (PcdFlashNvStorageVariableSize, NvVariableSize);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = PcdSet32S (PcdFlashNvStorageVariableBase, NvStorageBase); Status = PcdSet32S (PcdFlashNvStorageVariableBase, NvStorageBase);
@ -124,7 +126,6 @@ InitVariableStore (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get a heathy FV header used for variable store recovery Get a heathy FV header used for variable store recovery
@ -148,4 +149,3 @@ GetFvHeaderTemplate (
return FvHeader; return FvHeader;
} }

View File

@ -60,7 +60,6 @@ FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
} }
}; };
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = { EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
FVB_DEVICE_SIGNATURE, FVB_DEVICE_SIGNATURE,
NULL, NULL,
@ -77,7 +76,6 @@ EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
} // FwVolBlockInstance } // FwVolBlockInstance
}; };
/** /**
Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed
by mFvbModuleGlobal.FvInstance based on a index. by mFvbModuleGlobal.FvInstance based on a index.
@ -113,10 +111,8 @@ GetFvbInstance (
} }
return FwhRecord; return FwhRecord;
} }
/** /**
Get the EFI_FVB_ATTRIBUTES_2 of a FV. Get the EFI_FVB_ATTRIBUTES_2 of a FV.
@ -132,6 +128,7 @@ FvbGetVolumeAttributes (
) )
{ {
EFI_FW_VOL_INSTANCE *FwInstance; EFI_FW_VOL_INSTANCE *FwInstance;
FwInstance = GetFvbInstance (Instance); FwInstance = GetFvbInstance (Instance);
ASSERT (FwInstance != NULL); ASSERT (FwInstance != NULL);
@ -142,8 +139,6 @@ FvbGetVolumeAttributes (
return FwInstance->VolumeHeader.Attributes; return FwInstance->VolumeHeader.Attributes;
} }
/** /**
Retrieves the starting address of an LBA in an FV. It also Retrieves the starting address of an LBA in an FV. It also
return a few other attribut of the FV. return a few other attribut of the FV.
@ -202,7 +197,7 @@ FvbGetLbaAddress (
BlockLength = BlockMap->Length; BlockLength = BlockMap->Length;
} }
if ( NumBlocks == 0 || BlockLength == 0) { if ((NumBlocks == 0) || (BlockLength == 0)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -211,7 +206,7 @@ FvbGetLbaAddress (
// //
// The map entry found // The map entry found
// //
if (Lba >= StartLba && Lba < NextLba) { if ((Lba >= StartLba) && (Lba < NextLba)) {
Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength); Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
if (LbaAddress != NULL) { if (LbaAddress != NULL) {
*LbaAddress = FwhInstance->FvBase + Offset; *LbaAddress = FwhInstance->FvBase + Offset;
@ -224,6 +219,7 @@ FvbGetLbaAddress (
if (NumOfBlocks != NULL) { if (NumOfBlocks != NULL) {
*NumOfBlocks = (UINTN)(NextLba - Lba); *NumOfBlocks = (UINTN)(NextLba - Lba);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -233,7 +229,6 @@ FvbGetLbaAddress (
} }
} }
/** /**
Reads specified number of bytes into a buffer from the specified block Reads specified number of bytes into a buffer from the specified block
@ -277,6 +272,7 @@ FvbReadBlock (
if ((NumBytes == NULL) || (Buffer == NULL)) { if ((NumBytes == NULL) || (Buffer == NULL)) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
if (*NumBytes == 0) { if (*NumBytes == 0) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -309,7 +305,6 @@ FvbReadBlock (
return Status; return Status;
} }
/** /**
Writes specified number of bytes from the input buffer to the block Writes specified number of bytes from the input buffer to the block
@ -348,6 +343,7 @@ FvbWriteBlock (
if ((NumBytes == NULL) || (Buffer == NULL)) { if ((NumBytes == NULL) || (Buffer == NULL)) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
if (*NumBytes == 0) { if (*NumBytes == 0) {
return (EFI_INVALID_PARAMETER); return (EFI_INVALID_PARAMETER);
} }
@ -373,9 +369,12 @@ FvbWriteBlock (
} }
if ( LbaLength < (*NumBytes + BlockOffset)) { if ( LbaLength < (*NumBytes + BlockOffset)) {
DEBUG ((DEBUG_ERROR, DEBUG ((
DEBUG_ERROR,
"FvWriteBlock: Reducing Numbytes from 0x%x to 0x%x\n", "FvWriteBlock: Reducing Numbytes from 0x%x to 0x%x\n",
*NumBytes, (UINT32)(LbaLength - BlockOffset))); *NumBytes,
(UINT32)(LbaLength - BlockOffset)
));
*NumBytes = (UINT32)(LbaLength - BlockOffset); *NumBytes = (UINT32)(LbaLength - BlockOffset);
return EFI_BAD_BUFFER_SIZE; return EFI_BAD_BUFFER_SIZE;
} }
@ -388,7 +387,6 @@ FvbWriteBlock (
return Status; return Status;
} }
/** /**
Erases and initializes a firmware volume block Erases and initializes a firmware volume block
@ -409,7 +407,6 @@ FvbEraseBlock (
IN EFI_LBA Lba IN EFI_LBA Lba
) )
{ {
EFI_FVB_ATTRIBUTES_2 Attributes; EFI_FVB_ATTRIBUTES_2 Attributes;
UINTN LbaAddress; UINTN LbaAddress;
UINTN LbaLength; UINTN LbaLength;
@ -575,7 +572,6 @@ FvbSetVolumeAttributes (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Retrieves the physical address of the device. Retrieves the physical address of the device.
@ -606,8 +602,6 @@ FvbProtocolGetPhysicalAddress (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Retrieve the size of a logical block Retrieve the size of a logical block
@ -638,7 +632,6 @@ FvbProtocolGetBlockSize (
return FvbGetLbaAddress (FvbDevice->Instance, Lba, NULL, BlockSize, NumOfBlocks); return FvbGetLbaAddress (FvbDevice->Instance, Lba, NULL, BlockSize, NumOfBlocks);
} }
/** /**
Retrieves Volume attributes. No polarity translations are done. Retrieves Volume attributes. No polarity translations are done.
@ -663,7 +656,6 @@ FvbProtocolGetAttributes (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Sets Volume attributes. No polarity translations are done. Sets Volume attributes. No polarity translations are done.
@ -688,8 +680,6 @@ FvbProtocolSetAttributes (
return Status; return Status;
} }
/** /**
This function erases one or more blocks as denoted by the This function erases one or more blocks as denoted by the
variable argument list. The entire parameter list of blocks must be verified variable argument list. The entire parameter list of blocks must be verified
@ -771,6 +761,7 @@ FvbProtocolEraseBlocks (
VA_END (args); VA_END (args);
return Status; return Status;
} }
StartingLba++; StartingLba++;
NumOfLba--; NumOfLba--;
} }
@ -781,8 +772,6 @@ FvbProtocolEraseBlocks (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Writes data beginning at Lba:Offset from FV. The write terminates either Writes data beginning at Lba:Offset from FV. The write terminates either
when *NumBytes of data have been written, or when a block boundary is when *NumBytes of data have been written, or when a block boundary is
@ -823,14 +812,19 @@ FvbProtocolWrite (
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
Status = FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer); Status = FvbWriteBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer);
DEBUG((DEBUG_VERBOSE, DEBUG ((
DEBUG_VERBOSE,
"FvbWrite: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%x Status:%r\n", "FvbWrite: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%x Status:%r\n",
Lba, Offset, *NumBytes, Buffer, Status)); Lba,
Offset,
*NumBytes,
Buffer,
Status
));
return Status; return Status;
} }
/** /**
Reads data beginning at Lba:Offset from FV. The Read terminates either Reads data beginning at Lba:Offset from FV. The Read terminates either
when *NumBytes of data have been read, or when a block boundary is when *NumBytes of data have been read, or when a block boundary is
@ -869,15 +863,20 @@ FvbProtocolRead (
OUT UINT8 *Buffer OUT UINT8 *Buffer
) )
{ {
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
EFI_STATUS Status; EFI_STATUS Status;
FvbDevice = FVB_DEVICE_FROM_THIS (This); FvbDevice = FVB_DEVICE_FROM_THIS (This);
Status = FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer); Status = FvbReadBlock (FvbDevice->Instance, Lba, Offset, NumBytes, Buffer);
DEBUG((DEBUG_VERBOSE, DEBUG ((
DEBUG_VERBOSE,
"FvbRead: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%x, Status:%r\n", "FvbRead: Lba: 0x%lx Offset: 0x%x NumBytes: 0x%x, Buffer: 0x%x, Status:%r\n",
Lba, Offset, *NumBytes, Buffer, Status)); Lba,
Offset,
*NumBytes,
Buffer,
Status
));
return Status; return Status;
} }
@ -915,7 +914,8 @@ IsFvHeaderValid (
if ((FwVolHeader->Revision != EFI_FVH_REVISION) || if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) || (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
(FwVolHeader->FvLength == ((UINTN)-1)) || (FwVolHeader->FvLength == ((UINTN)-1)) ||
((FwVolHeader->HeaderLength & 0x01 ) !=0) ) { ((FwVolHeader->HeaderLength & 0x01) != 0))
{
DEBUG ((DEBUG_INFO, " -- >Revision = 0x%x, Signature = 0x%x\n", FwVolHeader->Revision, FwVolHeader->Signature)); DEBUG ((DEBUG_INFO, " -- >Revision = 0x%x, Signature = 0x%x\n", FwVolHeader->Revision, FwVolHeader->Signature));
DEBUG ((DEBUG_INFO, " -- >FvLength = 0x%lx, HeaderLength = 0x%x\n", FwVolHeader->FvLength, FwVolHeader->HeaderLength)); DEBUG ((DEBUG_INFO, " -- >FvLength = 0x%lx, HeaderLength = 0x%x\n", FwVolHeader->FvLength, FwVolHeader->HeaderLength));
return FALSE; return FALSE;
@ -930,7 +930,6 @@ IsFvHeaderValid (
return TRUE; return TRUE;
} }
/** /**
Get intial variable data. Get intial variable data.
@ -975,6 +974,7 @@ GetInitialVariableData (
if (Variable->StartId != VARIABLE_DATA) { if (Variable->StartId != VARIABLE_DATA) {
break; break;
} }
VariableSize = sizeof (AUTHENTICATED_VARIABLE_HEADER) + Variable->DataSize + Variable->NameSize; VariableSize = sizeof (AUTHENTICATED_VARIABLE_HEADER) + Variable->DataSize + Variable->NameSize;
Variable = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN ((UINTN)Variable + VariableSize); Variable = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN ((UINTN)Variable + VariableSize);
} }
@ -1065,6 +1065,7 @@ FvbInitialize (
if (FwVolInstance == NULL) { if (FwVolInstance == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
FwVolInstance->FvBase = (UINTN)BaseAddress; FwVolInstance->FvBase = (UINTN)BaseAddress;
CopyMem (&FwVolInstance->VolumeHeader, FvHeader, FvHeader->HeaderLength); CopyMem (&FwVolInstance->VolumeHeader, FvHeader, FvHeader->HeaderLength);

View File

@ -45,7 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS) #define EFI_FVB2_STATUS (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
typedef struct { typedef struct {
UINTN FvBase; UINTN FvBase;
UINTN NumOfBlocks; UINTN NumOfBlocks;
@ -56,7 +55,6 @@ typedef struct {
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader; EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
} EFI_FW_VOL_INSTANCE; } EFI_FW_VOL_INSTANCE;
typedef struct { typedef struct {
EFI_FW_VOL_INSTANCE *FvInstance; EFI_FW_VOL_INSTANCE *FvInstance;
UINT32 NumFv; UINT32 NumFv;

View File

@ -61,6 +61,7 @@ InstallFvbProtocol (
ASSERT (FALSE); ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
FvDevicePath = (FV_MEMMAP_DEVICE_PATH *)FvbDevice->DevicePath; FvDevicePath = (FV_MEMMAP_DEVICE_PATH *)FvbDevice->DevicePath;
FvDevicePath->MemMapDevPath.StartingAddress = FwhInstance->FvBase; FvDevicePath->MemMapDevPath.StartingAddress = FwhInstance->FvBase;
FvDevicePath->MemMapDevPath.EndingAddress = FwhInstance->FvBase + FwVolHeader->FvLength - 1; FvDevicePath->MemMapDevPath.EndingAddress = FwhInstance->FvBase + FwVolHeader->FvLength - 1;
@ -112,7 +113,6 @@ InstallFvbProtocol (
return Status; return Status;
} }
/** /**
The driver entry point for SMM Firmware Volume Block Driver. The driver entry point for SMM Firmware Volume Block Driver.

View File

@ -25,7 +25,6 @@ typedef struct {
UINT8 Data[1]; UINT8 Data[1];
} SMM_FVB_COMMUNICATE_FUNCTION_HEADER; } SMM_FVB_COMMUNICATE_FUNCTION_HEADER;
/// ///
/// Size of SMM communicate header, without including the payload. /// Size of SMM communicate header, without including the payload.
/// ///

View File

@ -50,7 +50,7 @@ GraphicsOutputQueryMode (
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
) )
{ {
if (This == NULL || Info == NULL || SizeOfInfo == NULL || ModeNumber >= This->Mode->MaxMode) { if ((This == NULL) || (Info == NULL) || (SizeOfInfo == NULL) || (ModeNumber >= This->Mode->MaxMode)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -97,8 +97,10 @@ GraphicsOutputSetMode (
Private->FrameBufferBltLibConfigure, Private->FrameBufferBltLibConfigure,
&Black, &Black,
EfiBltVideoFill, EfiBltVideoFill,
0, 0, 0,
0, 0, 0,
0,
0,
This->Mode->Info->HorizontalResolution, This->Mode->Info->HorizontalResolution,
This->Mode->Info->VerticalResolution, This->Mode->Info->VerticalResolution,
0 0
@ -159,8 +161,12 @@ GraphicsOutputBlt (
Private->FrameBufferBltLibConfigure, Private->FrameBufferBltLibConfigure,
BltBuffer, BltBuffer,
BltOperation, BltOperation,
SourceX, SourceY, SourceX,
DestinationX, DestinationY, Width, Height, SourceY,
DestinationX,
DestinationY,
Width,
Height,
Delta Delta
); );
gBS->RestoreTPL (Tpl); gBS->RestoreTPL (Tpl);
@ -236,9 +242,11 @@ GraphicsOutputDriverBindingSupported (
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
&gEfiPciIoProtocolGuid, &gEfiPciIoProtocolGuid,
@ -260,9 +268,11 @@ GraphicsOutputDriverBindingSupported (
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
gBS->CloseProtocol ( gBS->CloseProtocol (
Controller, Controller,
&gEfiDevicePathProtocolGuid, &gEfiDevicePathProtocolGuid,
@ -272,7 +282,8 @@ GraphicsOutputDriverBindingSupported (
if ((RemainingDevicePath == NULL) || if ((RemainingDevicePath == NULL) ||
IsDevicePathEnd (RemainingDevicePath) || IsDevicePathEnd (RemainingDevicePath) ||
CompareMem (RemainingDevicePath, &mGraphicsOutputAdrNode, sizeof (mGraphicsOutputAdrNode)) == 0) { (CompareMem (RemainingDevicePath, &mGraphicsOutputAdrNode, sizeof (mGraphicsOutputAdrNode)) == 0))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} else { } else {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
@ -326,14 +337,20 @@ GraphicsOutputDriverBindingStart (
DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName)); DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName));
} else { } else {
DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *)(GET_GUID_HOB_DATA (HobStart)); DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *)(GET_GUID_HOB_DATA (HobStart));
DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB:\n" DEBUG ((
DEBUG_INFO,
"[%a]: GraphicsDeviceInfo HOB:\n"
" VendorId = %04x, DeviceId = %04x,\n" " VendorId = %04x, DeviceId = %04x,\n"
" RevisionId = %02x, BarIndex = %x,\n" " RevisionId = %02x, BarIndex = %x,\n"
" SubsystemVendorId = %04x, SubsystemId = %04x\n", " SubsystemVendorId = %04x, SubsystemId = %04x\n",
gEfiCallerBaseName, gEfiCallerBaseName,
DeviceInfo->VendorId, DeviceInfo->DeviceId, DeviceInfo->VendorId,
DeviceInfo->RevisionId, DeviceInfo->BarIndex, DeviceInfo->DeviceId,
DeviceInfo->SubsystemVendorId, DeviceInfo->SubsystemId)); DeviceInfo->RevisionId,
DeviceInfo->BarIndex,
DeviceInfo->SubsystemVendorId,
DeviceInfo->SubsystemId
));
} }
// //
@ -350,6 +367,7 @@ GraphicsOutputDriverBindingStart (
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->OpenProtocol ( Status = gBS->OpenProtocol (
@ -363,6 +381,7 @@ GraphicsOutputDriverBindingStart (
if (Status == EFI_ALREADY_STARTED) { if (Status == EFI_ALREADY_STARTED) {
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
} }
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
// //
@ -377,7 +396,8 @@ GraphicsOutputDriverBindingStart (
((DeviceInfo->SubsystemVendorId != MAX_UINT16) && (DeviceInfo->SubsystemVendorId != Pci.Device.SubsystemVendorID)) || ((DeviceInfo->SubsystemVendorId != MAX_UINT16) && (DeviceInfo->SubsystemVendorId != Pci.Device.SubsystemVendorID)) ||
((DeviceInfo->SubsystemId != MAX_UINT16) && (DeviceInfo->SubsystemId != Pci.Device.SubsystemID)) ((DeviceInfo->SubsystemId != MAX_UINT16) && (DeviceInfo->SubsystemId != Pci.Device.SubsystemID))
) )
) { )
{
// //
// It's not a video device, or device infomation doesn't match. // It's not a video device, or device infomation doesn't match.
// //
@ -393,18 +413,27 @@ GraphicsOutputDriverBindingStart (
if ((DeviceInfo->BarIndex != MAX_UINT8) && (DeviceInfo->BarIndex != Index)) { if ((DeviceInfo->BarIndex != MAX_UINT8) && (DeviceInfo->BarIndex != Index)) {
continue; continue;
} }
Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID **)&Resources); Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID **)&Resources);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "[%a]: BAR[%d]: Base = %lx, Length = %lx\n", DEBUG ((
gEfiCallerBaseName, Index, Resources->AddrRangeMin, Resources->AddrLen)); DEBUG_INFO,
"[%a]: BAR[%d]: Base = %lx, Length = %lx\n",
gEfiCallerBaseName,
Index,
Resources->AddrRangeMin,
Resources->AddrLen
));
if ((Resources->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) && if ((Resources->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) &&
(Resources->Len == (UINT16)(sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3)) && (Resources->Len == (UINT16)(sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3)) &&
(Resources->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) && (Resources->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) &&
(Resources->AddrLen >= GraphicsInfo->FrameBufferSize) (Resources->AddrLen >= GraphicsInfo->FrameBufferSize)
) { )
{
if (FrameBufferBase == 0) { if (FrameBufferBase == 0) {
FrameBufferBase = Resources->AddrRangeMin; FrameBufferBase = Resources->AddrRangeMin;
} }
if (DeviceInfo->BarIndex == MAX_UINT8) { if (DeviceInfo->BarIndex == MAX_UINT8) {
if (Resources->AddrRangeMin == GraphicsInfo->FrameBufferBase) { if (Resources->AddrRangeMin == GraphicsInfo->FrameBufferBase) {
FrameBufferBase = Resources->AddrRangeMin; FrameBufferBase = Resources->AddrRangeMin;
@ -416,6 +445,7 @@ GraphicsOutputDriverBindingStart (
} }
} }
} }
if (Index == MAX_PCI_BAR) { if (Index == MAX_PCI_BAR) {
Status = EFI_UNSUPPORTED; Status = EFI_UNSUPPORTED;
} else { } else {
@ -489,6 +519,7 @@ GraphicsOutputDriverBindingStart (
); );
} }
} }
if (RETURN_ERROR (ReturnStatus)) { if (RETURN_ERROR (ReturnStatus)) {
Status = EFI_OUT_OF_RESOURCES; Status = EFI_OUT_OF_RESOURCES;
goto RestorePciAttributes; goto RestorePciAttributes;
@ -502,8 +533,10 @@ GraphicsOutputDriverBindingStart (
Status = gBS->InstallMultipleProtocolInterfaces ( Status = gBS->InstallMultipleProtocolInterfaces (
&Private->GraphicsOutputHandle, &Private->GraphicsOutputHandle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&gEfiDevicePathProtocolGuid, Private->DevicePath, &Private->GraphicsOutput,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
NULL NULL
); );
@ -521,8 +554,10 @@ GraphicsOutputDriverBindingStart (
} else { } else {
gBS->UninstallMultipleProtocolInterfaces ( gBS->UninstallMultipleProtocolInterfaces (
Private->GraphicsOutputHandle, Private->GraphicsOutputHandle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&gEfiDevicePathProtocolGuid, Private->DevicePath, &Private->GraphicsOutput,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
NULL NULL
); );
} }
@ -547,9 +582,11 @@ FreeMemory:
if (Private->DevicePath != NULL) { if (Private->DevicePath != NULL) {
FreePool (Private->DevicePath); FreePool (Private->DevicePath);
} }
if (Private->FrameBufferBltLibConfigure != NULL) { if (Private->FrameBufferBltLibConfigure != NULL) {
FreePool (Private->FrameBufferBltLibConfigure); FreePool (Private->FrameBufferBltLibConfigure);
} }
FreePool (Private); FreePool (Private);
} }
} }
@ -576,6 +613,7 @@ CloseProtocols:
Controller Controller
); );
} }
return Status; return Status;
} }
@ -605,7 +643,6 @@ GraphicsOutputDriverBindingStop (
GRAPHICS_OUTPUT_PRIVATE_DATA *Private; GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
if (NumberOfChildren == 0) { if (NumberOfChildren == 0) {
// //
// Close the PCI I/O Protocol // Close the PCI I/O Protocol
// //
@ -654,8 +691,10 @@ GraphicsOutputDriverBindingStop (
// //
Status = gBS->UninstallMultipleProtocolInterfaces ( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->GraphicsOutputHandle, Private->GraphicsOutputHandle,
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput, &gEfiGraphicsOutputProtocolGuid,
&gEfiDevicePathProtocolGuid, Private->DevicePath, &Private->GraphicsOutput,
&gEfiDevicePathProtocolGuid,
Private->DevicePath,
NULL NULL
); );
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -684,6 +723,7 @@ GraphicsOutputDriverBindingStop (
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
return Status; return Status;
} }

View File

@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _GRAPHICS_OUTPUT_DXE_H_ #ifndef _GRAPHICS_OUTPUT_DXE_H_
#define _GRAPHICS_OUTPUT_DXE_H_ #define _GRAPHICS_OUTPUT_DXE_H_
#include <PiDxe.h> #include <PiDxe.h>

View File

@ -35,7 +35,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifndef _COREBOOT_PEI_H_INCLUDED_ #ifndef _COREBOOT_PEI_H_INCLUDED_
#define _COREBOOT_PEI_H_INCLUDED_ #define _COREBOOT_PEI_H_INCLUDED_
@ -132,6 +131,7 @@ struct cb_mainboard {
UINT8 part_number_idx; UINT8 part_number_idx;
UINT8 strings[0]; UINT8 strings[0];
}; };
#define CB_TAG_VERSION 0x0004 #define CB_TAG_VERSION 0x0004
#define CB_TAG_EXTRA_VERSION 0x0005 #define CB_TAG_EXTRA_VERSION 0x0005
#define CB_TAG_BUILD 0x0006 #define CB_TAG_BUILD 0x0006

View File

@ -42,7 +42,6 @@ typedef struct {
PLD_GENERIC_REGISTER Registers[0]; PLD_GENERIC_REGISTER Registers[0];
} PLD_SMM_REGISTERS; } PLD_SMM_REGISTERS;
#pragma pack() #pragma pack()
#endif #endif

View File

@ -6,6 +6,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef BOOTLOADER_PARSE_LIB_ #ifndef BOOTLOADER_PARSE_LIB_
#define BOOTLOADER_PARSE_LIB_ #define BOOTLOADER_PARSE_LIB_
@ -20,7 +21,10 @@
#define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter) #define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter)
typedef RETURN_STATUS \ typedef RETURN_STATUS \
(*BL_MEM_INFO_CALLBACK) (MEMORY_MAP_ENTRY *MemoryMapEntry, VOID *Param); (*BL_MEM_INFO_CALLBACK) (
MEMORY_MAP_ENTRY *MemoryMapEntry,
VOID *Param
);
/** /**
This function retrieves the parameter base address from boot loader. This function retrieves the parameter base address from boot loader.
@ -100,7 +104,6 @@ ParseSerialInfo (
OUT SERIAL_PORT_INFO *SerialPortInfo OUT SERIAL_PORT_INFO *SerialPortInfo
); );
/** /**
Find the video frame buffer information Find the video frame buffer information

View File

@ -24,4 +24,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
extern VOID *gHobList; extern VOID *gHobList;
#endif #endif

View File

@ -6,7 +6,6 @@
**/ **/
#ifndef FLASHDEVICE_LIB_H_ #ifndef FLASHDEVICE_LIB_H_
#define FLASHDEVICE_LIB_H_ #define FLASHDEVICE_LIB_H_
@ -31,7 +30,6 @@ LibFvbFlashDeviceRead (
OUT UINT8 *Buffer OUT UINT8 *Buffer
); );
/** /**
Write NumBytes bytes of data from Buffer to the address specified by Write NumBytes bytes of data from Buffer to the address specified by
PAddresss. PAddresss.
@ -53,7 +51,6 @@ LibFvbFlashDeviceWrite (
IN UINT8 *Buffer IN UINT8 *Buffer
); );
/** /**
Erase the block starting at PAddress. Erase the block starting at PAddress.
@ -76,7 +73,6 @@ LibFvbFlashDeviceBlockErase (
IN UINTN LbaLength IN UINTN LbaLength
); );
/** /**
Lock or unlock the block starting at PAddress. Lock or unlock the block starting at PAddress.

View File

@ -25,4 +25,3 @@ ParsePlatformInfo (
); );
#endif // __BOOTLOADER_PLATFORM_SUPPORT_LIB__ #endif // __BOOTLOADER_PLATFORM_SUPPORT_LIB__

View File

@ -117,7 +117,6 @@ SpiReadPchSoftStrap (
OUT UINT8 *SoftStrapValue OUT UINT8 *SoftStrapValue
); );
/** /**
Read data from the flash part. Read data from the flash part.

View File

@ -8,7 +8,6 @@
#ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__ #ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__
#define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__ #define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__
/** /**
Do the platform specific action before the console is connected. Do the platform specific action before the console is connected.

View File

@ -67,6 +67,7 @@ InternalAcpiGetTimerTick (
if (mPmTimerReg == 0) { if (mPmTimerReg == 0) {
AcpiTimerLibConstructor (); AcpiTimerLibConstructor ();
} }
return IoRead32 (mPmTimerReg); return IoRead32 (mPmTimerReg);
} }

View File

@ -17,7 +17,6 @@
#include <IndustryStandard/Acpi.h> #include <IndustryStandard/Acpi.h>
#include <Coreboot.h> #include <Coreboot.h>
/** /**
Convert a packed value from cbuint64 to a UINT64 value. Convert a packed value from cbuint64 to a UINT64 value.
@ -34,7 +33,6 @@ cb_unpack64 (
return LShiftU64 (val.hi, 32) | val.lo; return LShiftU64 (val.hi, 32) | val.lo;
} }
/** /**
Returns the sum of all elements in a buffer of 16-bit values. During Returns the sum of all elements in a buffer of 16-bit values. During
calculation, the carry bits are also been added. calculation, the carry bits are also been added.
@ -75,7 +73,6 @@ CbCheckSum16 (
return (UINT16)((~Sum) & 0xFFFF); return (UINT16)((~Sum) & 0xFFFF);
} }
/** /**
Check the coreboot table if it is valid. Check the coreboot table if it is valid.
@ -118,7 +115,6 @@ IsValidCbTable (
return TRUE; return TRUE;
} }
/** /**
This function retrieves the parameter base address from boot loader. This function retrieves the parameter base address from boot loader.
@ -184,6 +180,7 @@ GetParameterBase (
CbTablePtr = (VOID *)(UINTN)((struct cb_forward *)(UINTN)Record)->forward; CbTablePtr = (VOID *)(UINTN)((struct cb_forward *)(UINTN)Record)->forward;
break; break;
} }
TmpPtr += Record->size; TmpPtr += Record->size;
} }
@ -200,7 +197,6 @@ GetParameterBase (
return CbTablePtr; return CbTablePtr;
} }
/** /**
Find coreboot record with given Tag. Find coreboot record with given Tag.
@ -231,13 +227,13 @@ FindCbTag (
TagPtr = TmpPtr; TagPtr = TmpPtr;
break; break;
} }
TmpPtr += Record->size; TmpPtr += Record->size;
} }
return TagPtr; return TagPtr;
} }
/** /**
Find the given table with TableId from the given coreboot memory Root. Find the given table with TableId from the given coreboot memory Root.
@ -266,6 +262,7 @@ FindCbMemTable (
if ((Root == NULL) || (MemTable == NULL)) { if ((Root == NULL) || (MemTable == NULL)) {
return RETURN_INVALID_PARAMETER; return RETURN_INVALID_PARAMETER;
} }
// //
// Check if the entry is CBMEM or IMD // Check if the entry is CBMEM or IMD
// and handle them separately // and handle them separately
@ -289,12 +286,18 @@ FindCbMemTable (
} else { } else {
*MemTable = (VOID *)(UINTN)Entries[Idx].start; *MemTable = (VOID *)(UINTN)Entries[Idx].start;
} }
if (MemTableSize != NULL) { if (MemTableSize != NULL) {
*MemTableSize = Entries[Idx].size; *MemTableSize = Entries[Idx].size;
} }
DEBUG ((DEBUG_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n", DEBUG ((
TableId, *MemTable, Entries[Idx].size)); DEBUG_INFO,
"Find CbMemTable Id 0x%x, base %p, size 0x%x\n",
TableId,
*MemTable,
Entries[Idx].size
));
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
} }
@ -361,8 +364,6 @@ ParseCbMemTable (
return Status; return Status;
} }
/** /**
Acquire the memory information from the coreboot table in memory. Acquire the memory information from the coreboot table in memory.
@ -399,8 +400,14 @@ ParseMemoryInfo (
MemoryMap.Size = cb_unpack64 (Range->size); MemoryMap.Size = cb_unpack64 (Range->size);
MemoryMap.Type = (UINT8)Range->type; MemoryMap.Type = (UINT8)Range->type;
MemoryMap.Flag = 0; MemoryMap.Flag = 0;
DEBUG ((DEBUG_INFO, "%d. %016lx - %016lx [%02x]\n", DEBUG ((
Index, MemoryMap.Base, MemoryMap.Base + MemoryMap.Size - 1, MemoryMap.Type)); DEBUG_INFO,
"%d. %016lx - %016lx [%02x]\n",
Index,
MemoryMap.Base,
MemoryMap.Base + MemoryMap.Size - 1,
MemoryMap.Type
));
MemInfoCallback (&MemoryMap, Params); MemInfoCallback (&MemoryMap, Params);
} }
@ -408,7 +415,6 @@ ParseMemoryInfo (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Acquire SMBIOS table from coreboot. Acquire SMBIOS table from coreboot.
@ -432,12 +438,12 @@ ParseSmbiosTable (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
SmbiosTable->SmBiosEntryPoint = (UINT64)(UINTN)MemTable; SmbiosTable->SmBiosEntryPoint = (UINT64)(UINTN)MemTable;
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Acquire ACPI table from coreboot. Acquire ACPI table from coreboot.
@ -461,12 +467,12 @@ ParseAcpiTableInfo (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
AcpiTableHob->Rsdp = (UINT64)(UINTN)MemTable; AcpiTableHob->Rsdp = (UINT64)(UINTN)MemTable;
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Find the serial port information Find the serial port information
@ -552,6 +558,7 @@ ParseGfxInfo (
} else if ((CbFbRec->blue_mask_pos == 0) && (CbFbRec->green_mask_pos == 8) && (CbFbRec->red_mask_pos == 16)) { } else if ((CbFbRec->blue_mask_pos == 0) && (CbFbRec->green_mask_pos == 8) && (CbFbRec->red_mask_pos == 16)) {
GfxMode->PixelFormat = PixelBlueGreenRedReserved8BitPerColor; GfxMode->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
} }
GfxMode->PixelInformation.RedMask = ((1 << CbFbRec->red_mask_size) - 1) << CbFbRec->red_mask_pos; GfxMode->PixelInformation.RedMask = ((1 << CbFbRec->red_mask_size) - 1) << CbFbRec->red_mask_pos;
GfxMode->PixelInformation.GreenMask = ((1 << CbFbRec->green_mask_size) - 1) << CbFbRec->green_mask_pos; GfxMode->PixelInformation.GreenMask = ((1 << CbFbRec->green_mask_size) - 1) << CbFbRec->green_mask_pos;
GfxMode->PixelInformation.BlueMask = ((1 << CbFbRec->blue_mask_size) - 1) << CbFbRec->blue_mask_pos; GfxMode->PixelInformation.BlueMask = ((1 << CbFbRec->blue_mask_size) - 1) << CbFbRec->blue_mask_pos;

View File

@ -75,8 +75,10 @@ GetNextHob (
if (Hob.Header->HobType == Type) { if (Hob.Header->HobType == Type) {
return Hob.Raw; return Hob.Raw;
} }
Hob.Raw = GET_NEXT_HOB (Hob); Hob.Raw = GET_NEXT_HOB (Hob);
} }
return NULL; return NULL;
} }
@ -141,8 +143,10 @@ GetNextGuidHob (
if (CompareGuid (Guid, &GuidHob.Guid->Name)) { if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
break; break;
} }
GuidHob.Raw = GET_NEXT_HOB (GuidHob); GuidHob.Raw = GET_NEXT_HOB (GuidHob);
} }
return GuidHob.Raw; return GuidHob.Raw;
} }

View File

@ -7,7 +7,6 @@
**/ **/
#include <Uefi.h> #include <Uefi.h>
VOID *gHobList = NULL; VOID *gHobList = NULL;

View File

@ -7,7 +7,6 @@
**/ **/
#include <Uefi.h> #include <Uefi.h>
/** /**

View File

@ -27,7 +27,6 @@ LibFvbFlashDeviceInit (
return SpiConstructor (); return SpiConstructor ();
} }
/** /**
Read NumBytes bytes of data from the address specified by Read NumBytes bytes of data from the address specified by
PAddress into Buffer. PAddress into Buffer.
@ -66,7 +65,6 @@ LibFvbFlashDeviceRead (
return SpiFlashRead (FlashRegionBios, AddrOffset, ByteCount, Buffer); return SpiFlashRead (FlashRegionBios, AddrOffset, ByteCount, Buffer);
} }
/** /**
Write NumBytes bytes of data from Buffer to the address specified by Write NumBytes bytes of data from Buffer to the address specified by
PAddresss. PAddresss.
@ -105,7 +103,6 @@ LibFvbFlashDeviceWrite (
return SpiFlashWrite (FlashRegionBios, AddrOffset, ByteCount, Buffer); return SpiFlashWrite (FlashRegionBios, AddrOffset, ByteCount, Buffer);
} }
/** /**
Erase the block starting at PAddress. Erase the block starting at PAddress.
@ -140,7 +137,6 @@ LibFvbFlashDeviceBlockErase (
return SpiFlashErase (FlashRegionBios, AddrOffset, (UINT32)LbaLength); return SpiFlashErase (FlashRegionBios, AddrOffset, (UINT32)LbaLength);
} }
/** /**
Lock or unlock the block starting at PAddress. Lock or unlock the block starting at PAddress.
@ -162,4 +158,3 @@ LibFvbFlashDeviceBlockLock (
{ {
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -35,7 +35,6 @@ GetHobList (
return mHobList; return mHobList;
} }
/** /**
Build a Handoff Information Table HOB Build a Handoff Information Table HOB
@ -203,13 +202,13 @@ GetNextHob (
if (Hob.Header->HobType == Type) { if (Hob.Header->HobType == Type) {
return Hob.Raw; return Hob.Raw;
} }
Hob.Raw = GET_NEXT_HOB (Hob); Hob.Raw = GET_NEXT_HOB (Hob);
} }
return NULL; return NULL;
} }
/** /**
Returns the first instance of a HOB type among the whole HOB list. Returns the first instance of a HOB type among the whole HOB list.
@ -233,7 +232,6 @@ GetFirstHob (
return GetNextHob (Type, HobList); return GetNextHob (Type, HobList);
} }
/** /**
This function searches the first instance of a HOB from the starting HOB pointer. This function searches the first instance of a HOB from the starting HOB pointer.
Such HOB should satisfy two conditions: Such HOB should satisfy two conditions:
@ -267,12 +265,13 @@ GetNextGuidHob (
if (CompareGuid (Guid, &GuidHob.Guid->Name)) { if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
break; break;
} }
GuidHob.Raw = GET_NEXT_HOB (GuidHob); GuidHob.Raw = GET_NEXT_HOB (GuidHob);
} }
return GuidHob.Raw; return GuidHob.Raw;
} }
/** /**
This function searches the first instance of a HOB among the whole HOB list. This function searches the first instance of a HOB among the whole HOB list.
Such HOB should satisfy two conditions: Such HOB should satisfy two conditions:
@ -299,9 +298,6 @@ GetFirstGuidHob (
return GetNextGuidHob (Guid, HobList); return GetNextGuidHob (Guid, HobList);
} }
/** /**
Builds a HOB for a loaded PE32 module. Builds a HOB for a loaded PE32 module.
@ -328,8 +324,10 @@ BuildModuleHob (
{ {
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob; EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) && ASSERT (
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)); ((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE)); Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
@ -384,7 +382,6 @@ BuildGuidHob (
return Hob + 1; return Hob + 1;
} }
/** /**
Copies a data buffer to a newly-built HOB. Copies a data buffer to a newly-built HOB.
@ -422,7 +419,6 @@ BuildGuidDataHob (
return CopyMem (HobData, Data, DataLength); return CopyMem (HobData, Data, DataLength);
} }
/** /**
Builds a Firmware Volume HOB. Builds a Firmware Volume HOB.
@ -450,7 +446,6 @@ BuildFvHob (
Hob->Length = Length; Hob->Length = Length;
} }
/** /**
Builds a EFI_HOB_TYPE_FV2 HOB. Builds a EFI_HOB_TYPE_FV2 HOB.
@ -529,7 +524,6 @@ BuildFv3Hob (
} }
} }
/** /**
Builds a HOB for the CPU. Builds a HOB for the CPU.
@ -562,7 +556,6 @@ BuildCpuHob (
ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
} }
/** /**
Builds a HOB for the Stack. Builds a HOB for the Stack.
@ -584,8 +577,10 @@ BuildStackHob (
{ {
EFI_HOB_MEMORY_ALLOCATION_STACK *Hob; EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) && ASSERT (
((Length & (EFI_PAGE_SIZE - 1)) == 0)); ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK)); Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
@ -600,7 +595,6 @@ BuildStackHob (
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved)); ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
} }
/** /**
Update the Stack Hob if the stack has been moved Update the Stack Hob if the stack has been moved
@ -636,12 +630,11 @@ UpdateStackHob (
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length; Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
break; break;
} }
Hob.Raw = GET_NEXT_HOB (Hob); Hob.Raw = GET_NEXT_HOB (Hob);
} }
} }
/** /**
Builds a HOB for the memory allocation. Builds a HOB for the memory allocation.
@ -665,8 +658,10 @@ BuildMemoryAllocationHob (
{ {
EFI_HOB_MEMORY_ALLOCATION *Hob; EFI_HOB_MEMORY_ALLOCATION *Hob;
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) && ASSERT (
((Length & (EFI_PAGE_SIZE - 1)) == 0)); ((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
((Length & (EFI_PAGE_SIZE - 1)) == 0)
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION)); Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));

View File

@ -113,4 +113,5 @@ CreateRootBridgeDevicePath (
IN UINT32 HID, IN UINT32 HID,
IN UINT32 UID IN UINT32 UID
); );
#endif #endif

View File

@ -130,18 +130,25 @@ InitRootBridge (
RootBus->NoExtendedConfigSpace = FALSE; RootBus->NoExtendedConfigSpace = FALSE;
DevicePath = AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate), DevicePath = AllocateCopyPool (
&mRootBridgeDevicePathTemplate); sizeof (mRootBridgeDevicePathTemplate),
&mRootBridgeDevicePathTemplate
);
if (DevicePath == NULL) { if (DevicePath == NULL) {
DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
DevicePath->AcpiDevicePath.UID = RootBusNumber; DevicePath->AcpiDevicePath.UID = RootBusNumber;
RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;
DEBUG ((DEBUG_INFO, DEBUG ((
DEBUG_INFO,
"%a: populated root bus %d, with room for %d subordinate bus(es)\n", "%a: populated root bus %d, with room for %d subordinate bus(es)\n",
__FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber)); __FUNCTION__,
RootBusNumber,
MaxSubBusNumber - RootBusNumber
));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -159,8 +166,11 @@ CreateRootBridgeDevicePath (
) )
{ {
CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
DevicePath = AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate),
&mRootBridgeDevicePathTemplate); DevicePath = AllocateCopyPool (
sizeof (mRootBridgeDevicePathTemplate),
&mRootBridgeDevicePathTemplate
);
ASSERT (DevicePath != NULL); ASSERT (DevicePath != NULL);
DevicePath->AcpiDevicePath.HID = HID; DevicePath->AcpiDevicePath.HID = HID;
DevicePath->AcpiDevicePath.UID = UID; DevicePath->AcpiDevicePath.UID = UID;
@ -185,6 +195,7 @@ PciHostBridgeGetRootBridges (
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo; UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo;
EFI_HOB_GUID_TYPE *GuidHob; EFI_HOB_GUID_TYPE *GuidHob;
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
// //
// Find Universal Payload PCI Root Bridge Info hob // Find Universal Payload PCI Root Bridge Info hob
// //
@ -203,6 +214,7 @@ PciHostBridgeGetRootBridges (
} }
} }
} }
return ScanForRootBridges (Count); return ScanForRootBridges (Count);
} }
@ -220,9 +232,10 @@ PciHostBridgeFreeRootBridges (
UINTN Count UINTN Count
) )
{ {
if (Bridges == NULL && Count == 0) { if ((Bridges == NULL) && (Count == 0)) {
return; return;
} }
ASSERT (Bridges != NULL && Count > 0); ASSERT (Bridges != NULL && Count > 0);
do { do {
@ -233,7 +246,6 @@ PciHostBridgeFreeRootBridges (
FreePool (Bridges); FreePool (Bridges);
} }
/** /**
Inform the platform that the resource conflict happens. Inform the platform that the resource conflict happens.

View File

@ -63,9 +63,11 @@ AdjustRootBridgeResource (
if (MemAbove4G->Base < Mem->Base) { if (MemAbove4G->Base < Mem->Base) {
Mem->Base = MemAbove4G->Base; Mem->Base = MemAbove4G->Base;
} }
if (MemAbove4G->Limit > Mem->Limit) { if (MemAbove4G->Limit > Mem->Limit) {
Mem->Limit = MemAbove4G->Limit; Mem->Limit = MemAbove4G->Limit;
} }
MemAbove4G->Base = MAX_UINT64; MemAbove4G->Base = MAX_UINT64;
MemAbove4G->Limit = 0; MemAbove4G->Limit = 0;
} }
@ -74,9 +76,11 @@ AdjustRootBridgeResource (
if (PMemAbove4G->Base < Mem->Base) { if (PMemAbove4G->Base < Mem->Base) {
Mem->Base = PMemAbove4G->Base; Mem->Base = PMemAbove4G->Base;
} }
if (PMemAbove4G->Limit > Mem->Limit) { if (PMemAbove4G->Limit > Mem->Limit) {
Mem->Limit = PMemAbove4G->Limit; Mem->Limit = PMemAbove4G->Limit;
} }
PMemAbove4G->Base = MAX_UINT64; PMemAbove4G->Base = MAX_UINT64;
PMemAbove4G->Limit = 0; PMemAbove4G->Limit = 0;
} }
@ -196,11 +200,13 @@ PcatPciRootBridgeParseBars (
for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) { for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) {
PcatPciRootBridgeBarExisted ( PcatPciRootBridgeBarExisted (
PCI_LIB_ADDRESS (Bus, Device, Function, Offset), PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
&OriginalValue, &Value &OriginalValue,
&Value
); );
if (Value == 0) { if (Value == 0) {
continue; continue;
} }
if ((Value & BIT0) == BIT0) { if ((Value & BIT0) == BIT0) {
// //
// IO Bar // IO Bar
@ -212,12 +218,14 @@ PcatPciRootBridgeParseBars (
if (!(Value & 0xFFFF0000)) { if (!(Value & 0xFFFF0000)) {
Length &= 0x0000FFFF; Length &= 0x0000FFFF;
} }
Limit = Base + Length - 1; Limit = Base + Length - 1;
if ((Base > 0) && (Base < Limit)) { if ((Base > 0) && (Base < Limit)) {
if (Io->Base > Base) { if (Io->Base > Base) {
Io->Base = Base; Io->Base = Base;
} }
if (Io->Limit < Limit) { if (Io->Limit < Limit) {
Io->Limit = Limit; Io->Limit = Limit;
} }
@ -228,7 +236,6 @@ PcatPciRootBridgeParseBars (
// Mem Bar // Mem Bar
// //
if ((Command & EFI_PCI_COMMAND_MEMORY_SPACE) != 0) { if ((Command & EFI_PCI_COMMAND_MEMORY_SPACE) != 0) {
Mask = 0xfffffff0; Mask = 0xfffffff0;
Base = OriginalValue & Mask; Base = OriginalValue & Mask;
Length = Value & Mask; Length = Value & Mask;
@ -274,6 +281,7 @@ PcatPciRootBridgeParseBars (
if (MemAperture->Base > Base) { if (MemAperture->Base > Base) {
MemAperture->Base = Base; MemAperture->Base = Base;
} }
if (MemAperture->Limit < Limit) { if (MemAperture->Limit < Limit) {
MemAperture->Limit = Limit; MemAperture->Limit = Limit;
} }
@ -315,7 +323,6 @@ ScanForRootBridges (
PCI_ROOT_BRIDGE *RootBridges; PCI_ROOT_BRIDGE *RootBridges;
UINTN BarOffsetEnd; UINTN BarOffsetEnd;
*NumberOfRootBridges = 0; *NumberOfRootBridges = 0;
RootBridges = NULL; RootBridges = NULL;
@ -338,9 +345,7 @@ ScanForRootBridges (
// Scan all the PCI devices on the primary bus of the PCI root bridge // Scan all the PCI devices on the primary bus of the PCI root bridge
// //
for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) { for (Device = 0, NumberOfDevices = 0; Device <= PCI_MAX_DEVICE; Device++) {
for (Function = 0; Function <= PCI_MAX_FUNC; Function++) { for (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
// //
// Compute the PCI configuration address of the PCI device to probe // Compute the PCI configuration address of the PCI device to probe
// //
@ -413,10 +418,12 @@ ScanForRootBridges (
Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16); Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16);
Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16); Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16);
} }
if ((Base > 0) && (Base < Limit)) { if ((Base > 0) && (Base < Limit)) {
if (Io.Base > Base) { if (Io.Base > Base) {
Io.Base = Base; Io.Base = Base;
} }
if (Io.Limit < Limit) { if (Io.Limit < Limit) {
Io.Limit = Limit; Io.Limit = Limit;
} }
@ -431,6 +438,7 @@ ScanForRootBridges (
if (Mem.Base > Base) { if (Mem.Base > Base) {
Mem.Base = Base; Mem.Base = Base;
} }
if (Mem.Limit < Limit) { if (Mem.Limit < Limit) {
Mem.Limit = Limit; Mem.Limit = Limit;
} }
@ -449,10 +457,12 @@ ScanForRootBridges (
Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32); Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
MemAperture = &PMemAbove4G; MemAperture = &PMemAbove4G;
} }
if ((Base > 0) && (Base < Limit)) { if ((Base > 0) && (Base < Limit)) {
if (MemAperture->Base > Base) { if (MemAperture->Base > Base) {
MemAperture->Base = Base; MemAperture->Base = Base;
} }
if (MemAperture->Limit < Limit) { if (MemAperture->Limit < Limit) {
MemAperture->Limit = Limit; MemAperture->Limit = Limit;
} }
@ -462,18 +472,22 @@ ScanForRootBridges (
// Look at the PPB Configuration for legacy decoding attributes // Look at the PPB Configuration for legacy decoding attributes
// //
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA) if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_ISA)
== EFI_PCI_BRIDGE_CONTROL_ISA) { == EFI_PCI_BRIDGE_CONTROL_ISA)
{
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16; Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
} }
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA) if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA)
== EFI_PCI_BRIDGE_CONTROL_VGA) { == EFI_PCI_BRIDGE_CONTROL_VGA)
{
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO; Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16) if ((Pci.Bridge.BridgeControl & EFI_PCI_BRIDGE_CONTROL_VGA_16)
!= 0) { != 0)
{
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16; Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO_16;
} }
@ -498,22 +512,30 @@ ScanForRootBridges (
OFFSET_OF (PCI_TYPE00, Device.Bar), OFFSET_OF (PCI_TYPE00, Device.Bar),
BarOffsetEnd, BarOffsetEnd,
&Io, &Io,
&Mem, &MemAbove4G, &Mem,
&PMem, &PMemAbove4G &MemAbove4G,
&PMem,
&PMemAbove4G
); );
// //
// See if the PCI device is an IDE controller // See if the PCI device is an IDE controller
// //
if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE, if (IS_CLASS2 (
PCI_CLASS_MASS_STORAGE_IDE)) { &Pci,
PCI_CLASS_MASS_STORAGE,
PCI_CLASS_MASS_STORAGE_IDE
))
{
if (Pci.Hdr.ClassCode[0] & 0x80) { if (Pci.Hdr.ClassCode[0] & 0x80) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
} }
if (Pci.Hdr.ClassCode[0] & 0x01) { if (Pci.Hdr.ClassCode[0] & 0x01) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO; Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
} }
if (Pci.Hdr.ClassCode[0] & 0x04) { if (Pci.Hdr.ClassCode[0] & 0x04) {
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO; Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
} }
@ -525,7 +547,8 @@ ScanForRootBridges (
// //
if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) || if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA) ||
IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA) IS_CLASS2 (&Pci, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA)
) { )
{
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO; Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; Attributes |= EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY; Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
@ -538,9 +561,10 @@ ScanForRootBridges (
// or ISA_POSITIVE_DECODE Bridge device // or ISA_POSITIVE_DECODE Bridge device
// //
if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) { if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA || if ((Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) ||
Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA || (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA) ||
Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) { (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE))
{
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO; Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16; Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO; Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
@ -551,7 +575,7 @@ ScanForRootBridges (
// If this device is not a multi function device, then skip the rest // If this device is not a multi function device, then skip the rest
// of this PCI device // of this PCI device
// //
if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) { if ((Function == 0) && !IS_PCI_MULTI_FUNC (&Pci)) {
break; break;
} }
} }
@ -572,9 +596,16 @@ ScanForRootBridges (
AdjustRootBridgeResource (&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G); AdjustRootBridgeResource (&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G);
InitRootBridge ( InitRootBridge (
Attributes, Attributes, 0, Attributes,
(UINT8) PrimaryBus, (UINT8) SubBus, Attributes,
&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G, 0,
(UINT8)PrimaryBus,
(UINT8)SubBus,
&Io,
&Mem,
&MemAbove4G,
&PMem,
&PMemAbove4G,
&RootBridges[*NumberOfRootBridges] &RootBridges[*NumberOfRootBridges]
); );
RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE; RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;
@ -612,15 +643,18 @@ RetrieveRootBridgeInfoFromHob (
if (PciRootBridgeInfo == NULL) { if (PciRootBridgeInfo == NULL) {
return NULL; return NULL;
} }
if (PciRootBridgeInfo->Count == 0) { if (PciRootBridgeInfo->Count == 0) {
return NULL; return NULL;
} }
Size = PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE); Size = PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE);
PciRootBridges = (PCI_ROOT_BRIDGE *)AllocatePool (Size); PciRootBridges = (PCI_ROOT_BRIDGE *)AllocatePool (Size);
ASSERT (PciRootBridges != NULL); ASSERT (PciRootBridges != NULL);
if (PciRootBridges == NULL) { if (PciRootBridges == NULL) {
return NULL; return NULL;
} }
ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE)); ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE));
// //

View File

@ -54,6 +54,7 @@ GetPciSegmentInfo (
AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
mPciSegment0.BaseAddress = AcpiBoardInfo->PcieBaseAddress; mPciSegment0.BaseAddress = AcpiBoardInfo->PcieBaseAddress;
} }
*Count = 1; *Count = 1;
return &mPciSegment0; return &mPciSegment0;
} }

View File

@ -83,7 +83,8 @@ PlatformFindLoadOption (
(StrCmp (Key->Description, Array[Index].Description) == 0) && (StrCmp (Key->Description, Array[Index].Description) == 0) &&
(CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) && (CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
(Key->OptionalDataSize == Array[Index].OptionalDataSize) && (Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
(CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) { (CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0))
{
return (INTN)Index; return (INTN)Index;
} }
} }
@ -142,6 +143,7 @@ PlatformRegisterFvBootOption (
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1); Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
EfiBootManagerFreeLoadOption (&NewOption); EfiBootManagerFreeLoadOption (&NewOption);
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount); EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
} }
@ -171,6 +173,7 @@ PlatformBootManagerBeforeConsole (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
mUniversalPayloadPlatformBootManagerOverrideInstance = NULL; mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;
} }
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) { if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
mUniversalPayloadPlatformBootManagerOverrideInstance->BeforeConsole (); mUniversalPayloadPlatformBootManagerOverrideInstance->BeforeConsole ();
return; return;
@ -236,6 +239,7 @@ PlatformBootManagerAfterConsole (
mUniversalPayloadPlatformBootManagerOverrideInstance->AfterConsole (); mUniversalPayloadPlatformBootManagerOverrideInstance->AfterConsole ();
return; return;
} }
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0; Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
White.Blue = White.Green = White.Red = White.Reserved = 0xFF; White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
@ -253,7 +257,6 @@ PlatformBootManagerAfterConsole (
L"ENTER to boot directly.\n" L"ENTER to boot directly.\n"
L"\n" L"\n"
); );
} }
/** /**
@ -270,6 +273,7 @@ PlatformBootManagerWaitCallback (
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) { if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain); mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain);
} }
return; return;
} }
@ -289,6 +293,7 @@ PlatformBootManagerUnableToBoot (
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) { if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot (); mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot ();
} }
return; return;
} }
@ -328,11 +333,13 @@ PlatformBootManagerLibConstructor (
if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) { if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) {
BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *)GET_GUID_HOB_DATA (GuidHob); BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *)GET_GUID_HOB_DATA (GuidHob);
if (BootManagerMenuFile->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, FileName)) { if (BootManagerMenuFile->Header.Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, FileName)) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
Size = sizeof (BootManagerMenuFile->FileName); Size = sizeof (BootManagerMenuFile->FileName);
Status = PcdSetPtrS (PcdBootManagerMenuFile, &Size, &BootManagerMenuFile->FileName); Status = PcdSetPtrS (PcdBootManagerMenuFile, &Size, &BootManagerMenuFile->FileName);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);

View File

@ -140,6 +140,7 @@ PrepareLpcBridgeDevicePath (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
TempDevicePath = DevicePath; TempDevicePath = DevicePath;
// //
@ -187,7 +188,7 @@ GetGopDevicePath (
UINTN GopHandleCount; UINTN GopHandleCount;
EFI_HANDLE *GopHandleBuffer; EFI_HANDLE *GopHandleBuffer;
if (PciDevicePath == NULL || GopDevicePath == NULL) { if ((PciDevicePath == NULL) || (GopDevicePath == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
@ -224,11 +225,13 @@ GetGopDevicePath (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
if (CompareMem ( if (CompareMem (
PciDevicePath, PciDevicePath,
TempDevicePath, TempDevicePath,
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
) == 0) { ) == 0)
{
// //
// In current implementation, we only enable one of the child handles // In current implementation, we only enable one of the child handles
// as console device, i.e. sotre one of the child handle's device // as console device, i.e. sotre one of the child handle's device
@ -245,6 +248,7 @@ GetGopDevicePath (
EfiBootManagerUpdateConsoleVariable (ConOut, TempDevicePath, NULL); EfiBootManagerUpdateConsoleVariable (ConOut, TempDevicePath, NULL);
} }
} }
gBS->FreePool (GopHandleBuffer); gBS->FreePool (GopHandleBuffer);
} }
@ -324,7 +328,6 @@ PreparePciSerialDevicePath (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
For every PCI instance execute a callback function. For every PCI instance execute a callback function.
@ -383,7 +386,6 @@ VisitAllInstancesOfProtocol (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
For every PCI instance execute a callback function. For every PCI instance execute a callback function.
@ -427,10 +429,8 @@ VisitingAPciInstance (
PciIo, PciIo,
&Pci &Pci
); );
} }
/** /**
For every PCI instance execute a callback function. For every PCI instance execute a callback function.
@ -452,7 +452,6 @@ VisitAllPciInstances (
); );
} }
/** /**
Do platform specific PCI Device check and add them to Do platform specific PCI Device check and add them to
ConOut, ConIn, ErrOut. ConOut, ConIn, ErrOut.
@ -491,7 +490,8 @@ DetectAndPreparePlatformPciDevicePath (
((IS_PCI_ISA_PDECODE (Pci)) && ((IS_PCI_ISA_PDECODE (Pci)) &&
(Pci->Hdr.VendorId == 0x8086) (Pci->Hdr.VendorId == 0x8086)
) )
) { )
{
// //
// Add IsaKeyboard to ConIn, // Add IsaKeyboard to ConIn,
// add IsaSerial to ConOut, ConIn, ErrOut // add IsaSerial to ConOut, ConIn, ErrOut
@ -500,6 +500,7 @@ DetectAndPreparePlatformPciDevicePath (
PrepareLpcBridgeDevicePath (Handle); PrepareLpcBridgeDevicePath (Handle);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
// //
// Here we decide which Serial device to enable in PCI bus // Here we decide which Serial device to enable in PCI bus
// //
@ -528,7 +529,6 @@ DetectAndPreparePlatformPciDevicePath (
return Status; return Status;
} }
/** /**
Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
@ -554,7 +554,6 @@ DetectAndPreparePlatformPciDevicePaths (
return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath); return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
} }
/** /**
The function will connect root bridge The function will connect root bridge
@ -611,5 +610,4 @@ PlatformConsoleInit (
// Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut // Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
// //
DetectAndPreparePlatformPciDevicePaths (FALSE); DetectAndPreparePlatformPciDevicePaths (FALSE);
} }

View File

@ -18,7 +18,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[
} }
}; };
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = { GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
{ {
{ {

View File

@ -13,7 +13,6 @@
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/HobLib.h> #include <Library/HobLib.h>
/** Library Constructor /** Library Constructor
@retval RETURN_SUCCESS Success. @retval RETURN_SUCCESS Success.
@ -75,14 +74,17 @@ PlatformHookSerialPortInitialize (
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }
Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase); Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }
Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride); Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;
} }
Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate); Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
if (RETURN_ERROR (Status)) { if (RETURN_ERROR (Status)) {
return Status; return Status;

View File

@ -26,4 +26,3 @@ ParsePlatformInfo (
{ {
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -38,14 +38,14 @@ GetParameterBase (
HandoffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)(UINTN)GET_BOOTLOADER_PARAMETER (); HandoffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)(UINTN)GET_BOOTLOADER_PARAMETER ();
if ((HandoffTable->Header.HobType == EFI_HOB_TYPE_HANDOFF) && if ((HandoffTable->Header.HobType == EFI_HOB_TYPE_HANDOFF) &&
(HandoffTable->Header.HobLength == sizeof (EFI_HOB_HANDOFF_INFO_TABLE)) && (HandoffTable->Header.HobLength == sizeof (EFI_HOB_HANDOFF_INFO_TABLE)) &&
(HandoffTable->Header.Reserved == 0)) { (HandoffTable->Header.Reserved == 0))
{
return (VOID *)HandoffTable; return (VOID *)HandoffTable;
} }
return NULL; return NULL;
} }
/** /**
This function retrieves a GUIDed HOB data from Slim Bootloader. This function retrieves a GUIDed HOB data from Slim Bootloader.
@ -137,7 +137,6 @@ ParseSmbiosTable (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Acquire ACPI table from slim bootloader. Acquire ACPI table from slim bootloader.
@ -194,7 +193,6 @@ ParseSerialInfo (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Find the video frame buffer information Find the video frame buffer information
@ -291,4 +289,3 @@ ParseMiscInfo (
return Status; return Status;
} }

View File

@ -35,8 +35,6 @@ ReleaseSpiBar0 (
{ {
} }
/** /**
This function is to enable/disable BIOS Write Protect in SMM phase. This function is to enable/disable BIOS Write Protect in SMM phase.
@ -70,7 +68,6 @@ CpuSmmDisableBiosWriteProtect (
Data32 = MmioRead32 (0xFED30880); Data32 = MmioRead32 (0xFED30880);
} }
/** /**
This function is a hook for Spi to disable BIOS Write Protect. This function is a hook for Spi to disable BIOS Write Protect.
@ -88,7 +85,6 @@ DisableBiosWriteProtect (
IN UINT8 CpuSmmBwp IN UINT8 CpuSmmBwp
) )
{ {
// //
// Write clear BC_SYNC_SS prior to change WPD from 0 to 1. // Write clear BC_SYNC_SS prior to change WPD from 0 to 1.
// //
@ -120,7 +116,6 @@ EnableBiosWriteProtect (
IN UINT8 CpuSmmBwp IN UINT8 CpuSmmBwp
) )
{ {
// //
// Disable the access to the BIOS space for write cycles // Disable the access to the BIOS space for write cycles
// //
@ -149,9 +144,11 @@ SaveAndDisableSpiPrefetchCache (
BiosCtlSave = MmioRead8 (PchSpiBase + R_SPI_BCR) & B_SPI_BCR_SRC; BiosCtlSave = MmioRead8 (PchSpiBase + R_SPI_BCR) & B_SPI_BCR_SRC;
MmioAndThenOr32 (PchSpiBase + R_SPI_BCR, \ MmioAndThenOr32 (
PchSpiBase + R_SPI_BCR, \
(UINT32)(~B_SPI_BCR_SRC), \ (UINT32)(~B_SPI_BCR_SRC), \
(UINT32) (V_SPI_BCR_SRC_PREF_DIS_CACHE_DIS << B_SPI_BCR_SRC)); (UINT32)(V_SPI_BCR_SRC_PREF_DIS_CACHE_DIS << B_SPI_BCR_SRC)
);
return BiosCtlSave; return BiosCtlSave;
} }

View File

@ -38,11 +38,9 @@
#define B_SPI_HSFS_FCERR BIT1 ///< Flash Cycle Error #define B_SPI_HSFS_FCERR BIT1 ///< Flash Cycle Error
#define B_SPI_HSFS_FDONE BIT0 ///< Flash Cycle Done #define B_SPI_HSFS_FDONE BIT0 ///< Flash Cycle Done
#define R_SPI_FADDR 0x08 ///< SPI Flash Address #define R_SPI_FADDR 0x08 ///< SPI Flash Address
#define B_SPI_FADDR_MASK 0x07FFFFFF ///< SPI Flash Address Mask (0~26bit) #define B_SPI_FADDR_MASK 0x07FFFFFF ///< SPI Flash Address Mask (0~26bit)
#define R_SPI_FDATA00 0x10 ///< SPI Data 00 (32 bits) #define R_SPI_FDATA00 0x10 ///< SPI Data 00 (32 bits)
#define R_SPI_FRAP 0x50 ///< SPI Flash Regions Access Permissions Register #define R_SPI_FRAP 0x50 ///< SPI Flash Regions Access Permissions Register
@ -57,7 +55,6 @@
#define B_SPI_FRAP_BRRA_BIOS BIT1 ///< Region Read Access for Region1 BIOS #define B_SPI_FRAP_BRRA_BIOS BIT1 ///< Region Read Access for Region1 BIOS
#define B_SPI_FRAP_BRRA_FLASHD BIT0 ///< Region Read Access for Region0 Flash Descriptor #define B_SPI_FRAP_BRRA_FLASHD BIT0 ///< Region Read Access for Region0 Flash Descriptor
#define R_SPI_FREG0_FLASHD 0x54 ///< Flash Region 0 (Flash Descriptor) (32bits) #define R_SPI_FREG0_FLASHD 0x54 ///< Flash Region 0 (Flash Descriptor) (32bits)
#define B_SPI_FREG0_LIMIT_MASK 0x7FFF0000 ///< Size, [30:16] here represents limit[26:12] #define B_SPI_FREG0_LIMIT_MASK 0x7FFF0000 ///< Size, [30:16] here represents limit[26:12]
#define N_SPI_FREG0_LIMIT 4 ///< Bit 30:16 identifies address bits [26:12] #define N_SPI_FREG0_LIMIT 4 ///< Bit 30:16 identifies address bits [26:12]
@ -88,14 +85,12 @@
#define B_SPI_FREG4_BASE_MASK 0x00007FFF ///< Base, [14:0] here represents base [26:12] #define B_SPI_FREG4_BASE_MASK 0x00007FFF ///< Base, [14:0] here represents base [26:12]
#define N_SPI_FREG4_BASE 12 ///< Bit 14:0 identifies address bits [26:2] #define N_SPI_FREG4_BASE 12 ///< Bit 14:0 identifies address bits [26:2]
#define S_SPI_FREGX 4 ///< Size of Flash Region register #define S_SPI_FREGX 4 ///< Size of Flash Region register
#define B_SPI_FREGX_LIMIT_MASK 0x7FFF0000 ///< Flash Region Limit [30:16] represents [26:12], [11:0] are assumed to be FFFh #define B_SPI_FREGX_LIMIT_MASK 0x7FFF0000 ///< Flash Region Limit [30:16] represents [26:12], [11:0] are assumed to be FFFh
#define N_SPI_FREGX_LIMIT 16 ///< Region limit bit position #define N_SPI_FREGX_LIMIT 16 ///< Region limit bit position
#define N_SPI_FREGX_LIMIT_REPR 12 ///< Region limit bit represents position #define N_SPI_FREGX_LIMIT_REPR 12 ///< Region limit bit represents position
#define B_SPI_FREGX_BASE_MASK 0x00007FFF ///< Flash Region Base, [14:0] represents [26:12] #define B_SPI_FREGX_BASE_MASK 0x00007FFF ///< Flash Region Base, [14:0] represents [26:12]
#define R_SPI_FDOC 0xB4 ///< Flash Descriptor Observability Control Register (32 bits) #define R_SPI_FDOC 0xB4 ///< Flash Descriptor Observability Control Register (32 bits)
#define B_SPI_FDOC_FDSS_MASK (BIT14 | BIT13 | BIT12) ///< Flash Descriptor Section Select #define B_SPI_FDOC_FDSS_MASK (BIT14 | BIT13 | BIT12) ///< Flash Descriptor Section Select
#define V_SPI_FDOC_FDSS_FSDM 0x0000 ///< Flash Signature and Descriptor Map #define V_SPI_FDOC_FDSS_FSDM 0x0000 ///< Flash Signature and Descriptor Map
@ -104,13 +99,11 @@
#define R_SPI_FDOD 0xB8 ///< Flash Descriptor Observability Data Register (32 bits) #define R_SPI_FDOD 0xB8 ///< Flash Descriptor Observability Data Register (32 bits)
#define R_SPI_LVSCC 0xC4 ///< Vendor Specific Component Capabilities for Component 0 (32 bits) #define R_SPI_LVSCC 0xC4 ///< Vendor Specific Component Capabilities for Component 0 (32 bits)
#define B_SPI_LVSCC_EO_64K BIT29 ///< < 64k Erase valid (EO_64k_valid) #define B_SPI_LVSCC_EO_64K BIT29 ///< < 64k Erase valid (EO_64k_valid)
#define R_SPI_UVSCC 0xC8 ///< Vendor Specific Component Capabilities for Component 1 (32 bits) #define R_SPI_UVSCC 0xC8 ///< Vendor Specific Component Capabilities for Component 1 (32 bits)
#define R_SPI_FDBAR_FLASH_MAP0 0x14 ///< Flash MAP 0 #define R_SPI_FDBAR_FLASH_MAP0 0x14 ///< Flash MAP 0
#define N_SPI_FDBAR_NC 8 ///< < Number Of Components #define N_SPI_FDBAR_NC 8 ///< < Number Of Components
#define B_SPI_FDBAR_NC 0x00000300 ///< Number Of Components #define B_SPI_FDBAR_NC 0x00000300 ///< Number Of Components
@ -118,12 +111,10 @@
#define R_SPI_FDBAR_FLASH_MAP1 0x18 ///< Flash MAP 1 #define R_SPI_FDBAR_FLASH_MAP1 0x18 ///< Flash MAP 1
#define B_SPI_FDBAR_FPSBA 0x00FF0000 ///< Flash Strap Base Address #define B_SPI_FDBAR_FPSBA 0x00FF0000 ///< Flash Strap Base Address
// //
// Flash Component Base Address (FCBA) from Flash Region 0 // Flash Component Base Address (FCBA) from Flash Region 0
// //
#define R_SPI_FCBA_FLCOMP 0x00 ///< Flash Components Register #define R_SPI_FCBA_FLCOMP 0x00 ///< Flash Components Register
#define B_SPI_FLCOMP_COMP1_MASK 0x0F ///< Flash Component 1 Density #define B_SPI_FLCOMP_COMP1_MASK 0x0F ///< Flash Component 1 Density
#endif #endif

View File

@ -73,7 +73,6 @@ typedef struct {
UINT32 Component1StartAddr; UINT32 Component1StartAddr;
} SPI_INSTANCE; } SPI_INSTANCE;
/** /**
Acquire SPI MMIO BAR Acquire SPI MMIO BAR
@ -87,7 +86,6 @@ AcquireSpiBar0 (
IN UINTN PchSpiBase IN UINTN PchSpiBase
); );
/** /**
Release SPI MMIO BAR. Do nothing. Release SPI MMIO BAR. Do nothing.
@ -101,7 +99,6 @@ ReleaseSpiBar0 (
IN UINTN PchSpiBase IN UINTN PchSpiBase
); );
/** /**
This function is a hook for Spi to disable BIOS Write Protect This function is a hook for Spi to disable BIOS Write Protect
@ -135,7 +132,6 @@ EnableBiosWriteProtect (
IN UINT8 CpuSmmBwp IN UINT8 CpuSmmBwp
); );
/** /**
This function disables SPI Prefetching and caching, This function disables SPI Prefetching and caching,
and returns previous BIOS Control Register value before disabling. and returns previous BIOS Control Register value before disabling.
@ -165,7 +161,6 @@ SetSpiBiosControlRegister (
IN UINT8 BiosCtlValue IN UINT8 BiosCtlValue
); );
/** /**
This function sends the programmed SPI command to the slave device. This function sends the programmed SPI command to the slave device.

View File

@ -24,13 +24,13 @@ GetSpiInstance (
if (mSpiInstance == NULL) { if (mSpiInstance == NULL) {
return NULL; return NULL;
} }
ZeroMem (mSpiInstance, sizeof (SPI_INSTANCE)); ZeroMem (mSpiInstance, sizeof (SPI_INSTANCE));
} }
return mSpiInstance; return mSpiInstance;
} }
/** /**
Initialize an SPI library. Initialize an SPI library.
@ -57,6 +57,7 @@ SpiConstructor (
ASSERT (FALSE); ASSERT (FALSE);
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
SpiFlashInfo = (SPI_FLASH_INFO *)GET_GUID_HOB_DATA (GuidHob); SpiFlashInfo = (SPI_FLASH_INFO *)GET_GUID_HOB_DATA (GuidHob);
// //
@ -66,6 +67,7 @@ SpiConstructor (
if (SpiInstance == NULL) { if (SpiInstance == NULL) {
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
DEBUG ((DEBUG_INFO, "SpiInstance = %08X\n", SpiInstance)); DEBUG ((DEBUG_INFO, "SpiInstance = %08X\n", SpiInstance));
SpiInstance->Signature = SC_SPI_PRIVATE_DATA_SIGNATURE; SpiInstance->Signature = SC_SPI_PRIVATE_DATA_SIGNATURE;
@ -77,9 +79,11 @@ SpiConstructor (
if ((SpiFlashInfo->SpiAddress.AddressSpaceId != EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE) || if ((SpiFlashInfo->SpiAddress.AddressSpaceId != EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE) ||
(SpiFlashInfo->SpiAddress.RegisterBitWidth != 32) || (SpiFlashInfo->SpiAddress.RegisterBitWidth != 32) ||
(SpiFlashInfo->SpiAddress.RegisterBitOffset != 0) || (SpiFlashInfo->SpiAddress.RegisterBitOffset != 0) ||
(SpiFlashInfo->SpiAddress.AccessSize != EFI_ACPI_3_0_DWORD)){ (SpiFlashInfo->SpiAddress.AccessSize != EFI_ACPI_3_0_DWORD))
{
DEBUG ((DEBUG_ERROR, "SPI FLASH HOB is not expected. need check the hob or enhance SPI flash driver.\n")); DEBUG ((DEBUG_ERROR, "SPI FLASH HOB is not expected. need check the hob or enhance SPI flash driver.\n"));
} }
SpiInstance->PchSpiBase = (UINT32)(UINTN)SpiFlashInfo->SpiAddress.Address; SpiInstance->PchSpiBase = (UINT32)(UINTN)SpiFlashInfo->SpiAddress.Address;
SpiInstance->Flags = SpiFlashInfo->Flags; SpiInstance->Flags = SpiFlashInfo->Flags;
DEBUG ((DEBUG_INFO, "PchSpiBase at 0x%x\n", SpiInstance->PchSpiBase)); DEBUG ((DEBUG_INFO, "PchSpiBase at 0x%x\n", SpiInstance->PchSpiBase));
@ -146,7 +150,6 @@ SpiConstructor (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Read data from the flash part. Read data from the flash part.
@ -453,6 +456,7 @@ SendSpiCmd (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto SendSpiCmdEnd; goto SendSpiCmdEnd;
} }
BiosCtlSave = SaveAndDisableSpiPrefetchCache (SpiBaseAddress); BiosCtlSave = SaveAndDisableSpiPrefetchCache (SpiBaseAddress);
} }
@ -467,8 +471,8 @@ SendSpiCmd (
HardwareSpiAddr = Address; HardwareSpiAddr = Address;
if ((FlashCycleType == FlashCycleRead) || if ((FlashCycleType == FlashCycleRead) ||
(FlashCycleType == FlashCycleWrite) || (FlashCycleType == FlashCycleWrite) ||
(FlashCycleType == FlashCycleErase)) { (FlashCycleType == FlashCycleErase))
{
switch (FlashRegionType) { switch (FlashRegionType) {
case FlashRegionDescriptor: case FlashRegionDescriptor:
if (FlashCycleType == FlashCycleRead) { if (FlashCycleType == FlashCycleRead) {
@ -476,6 +480,7 @@ SendSpiCmd (
} else { } else {
PermissionBit = B_SPI_FRAP_BRWA_FLASHD; PermissionBit = B_SPI_FRAP_BRWA_FLASHD;
} }
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG0_FLASHD); Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG0_FLASHD);
HardwareSpiAddr += (Data32 & B_SPI_FREG0_BASE_MASK) << N_SPI_FREG0_BASE; HardwareSpiAddr += (Data32 & B_SPI_FREG0_BASE_MASK) << N_SPI_FREG0_BASE;
LimitAddress = (Data32 & B_SPI_FREG0_LIMIT_MASK) >> N_SPI_FREG0_LIMIT; LimitAddress = (Data32 & B_SPI_FREG0_LIMIT_MASK) >> N_SPI_FREG0_LIMIT;
@ -487,6 +492,7 @@ SendSpiCmd (
} else { } else {
PermissionBit = B_SPI_FRAP_BRWA_BIOS; PermissionBit = B_SPI_FRAP_BRWA_BIOS;
} }
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG1_BIOS); Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG1_BIOS);
HardwareSpiAddr += (Data32 & B_SPI_FREG1_BASE_MASK) << N_SPI_FREG1_BASE; HardwareSpiAddr += (Data32 & B_SPI_FREG1_BASE_MASK) << N_SPI_FREG1_BASE;
LimitAddress = (Data32 & B_SPI_FREG1_LIMIT_MASK) >> N_SPI_FREG1_LIMIT; LimitAddress = (Data32 & B_SPI_FREG1_LIMIT_MASK) >> N_SPI_FREG1_LIMIT;
@ -498,6 +504,7 @@ SendSpiCmd (
} else { } else {
PermissionBit = B_SPI_FRAP_BRWA_SEC; PermissionBit = B_SPI_FRAP_BRWA_SEC;
} }
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG2_SEC); Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG2_SEC);
HardwareSpiAddr += (Data32 & B_SPI_FREG2_BASE_MASK) << N_SPI_FREG2_BASE; HardwareSpiAddr += (Data32 & B_SPI_FREG2_BASE_MASK) << N_SPI_FREG2_BASE;
LimitAddress = (Data32 & B_SPI_FREG2_LIMIT_MASK) >> N_SPI_FREG2_LIMIT; LimitAddress = (Data32 & B_SPI_FREG2_LIMIT_MASK) >> N_SPI_FREG2_LIMIT;
@ -509,6 +516,7 @@ SendSpiCmd (
} else { } else {
PermissionBit = B_SPI_FRAP_BRWA_GBE; PermissionBit = B_SPI_FRAP_BRWA_GBE;
} }
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG3_GBE); Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG3_GBE);
HardwareSpiAddr += (Data32 & B_SPI_FREG3_BASE_MASK) << N_SPI_FREG3_BASE; HardwareSpiAddr += (Data32 & B_SPI_FREG3_BASE_MASK) << N_SPI_FREG3_BASE;
LimitAddress = (Data32 & B_SPI_FREG3_LIMIT_MASK) >> N_SPI_FREG3_LIMIT; LimitAddress = (Data32 & B_SPI_FREG3_LIMIT_MASK) >> N_SPI_FREG3_LIMIT;
@ -520,6 +528,7 @@ SendSpiCmd (
} else { } else {
PermissionBit = B_SPI_FRAP_BRWA_PLATFORM; PermissionBit = B_SPI_FRAP_BRWA_PLATFORM;
} }
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG4_PLATFORM_DATA); Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG4_PLATFORM_DATA);
HardwareSpiAddr += (Data32 & B_SPI_FREG4_BASE_MASK) << N_SPI_FREG4_BASE; HardwareSpiAddr += (Data32 & B_SPI_FREG4_BASE_MASK) << N_SPI_FREG4_BASE;
LimitAddress = (Data32 & B_SPI_FREG4_LIMIT_MASK) >> N_SPI_FREG4_LIMIT; LimitAddress = (Data32 & B_SPI_FREG4_LIMIT_MASK) >> N_SPI_FREG4_LIMIT;
@ -574,6 +583,7 @@ SendSpiCmd (
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;
goto SendSpiCmdEnd; goto SendSpiCmdEnd;
} }
break; break;
case FlashCycleReadSfdp: case FlashCycleReadSfdp:
@ -615,6 +625,7 @@ SendSpiCmd (
if (HardwareSpiAddr + ByteCount > ((HardwareSpiAddr + BIT8) &~(BIT8 - 1))) { if (HardwareSpiAddr + ByteCount > ((HardwareSpiAddr + BIT8) &~(BIT8 - 1))) {
SpiDataCount = (((UINT32)(HardwareSpiAddr) + BIT8) &~(BIT8 - 1)) - (UINT32)(HardwareSpiAddr); SpiDataCount = (((UINT32)(HardwareSpiAddr) + BIT8) &~(BIT8 - 1)) - (UINT32)(HardwareSpiAddr);
} }
// //
// Calculate the number of bytes to shift in/out during the SPI data cycle. // Calculate the number of bytes to shift in/out during the SPI data cycle.
// Valid settings for the number of bytes during each data portion of the // Valid settings for the number of bytes during each data portion of the
@ -630,7 +641,8 @@ SendSpiCmd (
if (FlashCycleType == FlashCycleErase) { if (FlashCycleType == FlashCycleErase) {
if (((ByteCount / SIZE_64KB) != 0) && if (((ByteCount / SIZE_64KB) != 0) &&
((ByteCount % SIZE_64KB) == 0) && ((ByteCount % SIZE_64KB) == 0) &&
((HardwareSpiAddr % SIZE_64KB) == 0)) { ((HardwareSpiAddr % SIZE_64KB) == 0))
{
if (HardwareSpiAddr < SpiInstance->Component1StartAddr) { if (HardwareSpiAddr < SpiInstance->Component1StartAddr) {
// //
// Check whether Component0 support 64k Erase // Check whether Component0 support 64k Erase
@ -653,6 +665,7 @@ SendSpiCmd (
} else { } else {
SpiDataCount = SIZE_4KB; SpiDataCount = SIZE_4KB;
} }
if (SpiDataCount == SIZE_4KB) { if (SpiDataCount == SIZE_4KB) {
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_4K_ERASE << N_SPI_HSFS_CYCLE); FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_4K_ERASE << N_SPI_HSFS_CYCLE);
} else { } else {
@ -709,7 +722,8 @@ SendSpiCmd (
if ((FlashCycleType == FlashCycleRead) || if ((FlashCycleType == FlashCycleRead) ||
(FlashCycleType == FlashCycleReadSfdp) || (FlashCycleType == FlashCycleReadSfdp) ||
(FlashCycleType == FlashCycleReadJedecId) || (FlashCycleType == FlashCycleReadJedecId) ||
(FlashCycleType == FlashCycleReadStatus)) { (FlashCycleType == FlashCycleReadStatus))
{
if ((SpiDataCount & 0x07) != 0) { if ((SpiDataCount & 0x07) != 0) {
// //
// Use Byte read if Data Count is 0, 1, 2, 3, 4, 5, 6, 7 // Use Byte read if Data Count is 0, 1, 2, 3, 4, 5, 6, 7
@ -783,8 +797,10 @@ WaitForSpiCycleComplete (
return TRUE; return TRUE;
} }
} }
MicroSecondDelay (WAIT_PERIOD); MicroSecondDelay (WAIT_PERIOD);
} }
return FALSE; return FALSE;
} }
@ -825,9 +841,11 @@ SpiGetRegionAddress (
if (BaseAddress != NULL) { if (BaseAddress != NULL) {
*BaseAddress = 0; *BaseAddress = 0;
} }
if (RegionSize != NULL) { if (RegionSize != NULL) {
*RegionSize = SpiInstance->Component1StartAddr; *RegionSize = SpiInstance->Component1StartAddr;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -32,7 +32,6 @@ typedef struct {
UINTN EntryPoint; ///< Return the actual entry point after LoadElfImage(). UINTN EntryPoint; ///< Return the actual entry point after LoadElfImage().
} ELF_IMAGE_CONTEXT; } ELF_IMAGE_CONTEXT;
typedef struct { typedef struct {
UINT32 PtType; UINT32 PtType;
UINTN Offset; UINTN Offset;
@ -119,4 +118,5 @@ GetElfSectionPos (
OUT UINTN *Offset, OUT UINTN *Offset,
OUT UINTN *Size OUT UINTN *Size
); );
#endif /* ELF_LIB_H_ */ #endif /* ELF_LIB_H_ */

View File

@ -37,7 +37,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _SYS_ELF32_H_ #ifndef _SYS_ELF32_H_
#define _SYS_ELF32_H_ 1 #define _SYS_ELF32_H_ 1
/* /*
* ELF definitions common to all 32-bit architectures. * ELF definitions common to all 32-bit architectures.
*/ */
@ -207,8 +206,7 @@ typedef struct {
#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3) #define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3)
/* Structures used by Sun & GNU symbol versioning. */ /* Structures used by Sun & GNU symbol versioning. */
typedef struct typedef struct {
{
Elf32_Half vd_version; Elf32_Half vd_version;
Elf32_Half vd_flags; Elf32_Half vd_flags;
Elf32_Half vd_ndx; Elf32_Half vd_ndx;
@ -218,14 +216,12 @@ typedef struct
Elf32_Word vd_next; Elf32_Word vd_next;
} Elf32_Verdef; } Elf32_Verdef;
typedef struct typedef struct {
{
Elf32_Word vda_name; Elf32_Word vda_name;
Elf32_Word vda_next; Elf32_Word vda_next;
} Elf32_Verdaux; } Elf32_Verdaux;
typedef struct typedef struct {
{
Elf32_Half vn_version; Elf32_Half vn_version;
Elf32_Half vn_cnt; Elf32_Half vn_cnt;
Elf32_Word vn_file; Elf32_Word vn_file;
@ -233,8 +229,7 @@ typedef struct
Elf32_Word vn_next; Elf32_Word vn_next;
} Elf32_Verneed; } Elf32_Verneed;
typedef struct typedef struct {
{
Elf32_Word vna_hash; Elf32_Word vna_hash;
Elf32_Half vna_flags; Elf32_Half vna_flags;
Elf32_Half vna_other; Elf32_Half vna_other;

View File

@ -83,8 +83,10 @@ GetElf32SectionByRange (
if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) { if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) {
return Shdr; return Shdr;
} }
Shdr = ELF_NEXT_ENTRY (Elf32_Shdr, Shdr, Ehdr->e_shentsize); Shdr = ELF_NEXT_ENTRY (Elf32_Shdr, Shdr, Ehdr->e_shentsize);
} }
return NULL; return NULL;
} }
@ -117,7 +119,8 @@ ProcessRelocation32 (
for ( Index = 0 for ( Index = 0
; RelaEntrySize * Index < RelaSize ; RelaEntrySize * Index < RelaSize
; Index++, Rela = ELF_NEXT_ENTRY (Elf32_Rela, Rela, RelaEntrySize) ; Index++, Rela = ELF_NEXT_ENTRY (Elf32_Rela, Rela, RelaEntrySize)
) { )
{
// //
// r_offset is the virtual address of the storage unit affected by the relocation. // r_offset is the virtual address of the storage unit affected by the relocation.
// //
@ -141,6 +144,7 @@ ProcessRelocation32 (
} else { } else {
*Ptr += (UINT32)Delta; *Ptr += (UINT32)Delta;
} }
break; break;
case R_386_RELATIVE: case R_386_RELATIVE:
@ -178,12 +182,14 @@ ProcessRelocation32 (
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type)); DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
ASSERT (FALSE); ASSERT (FALSE);
} }
break; break;
default: default:
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type)); DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -239,6 +245,7 @@ RelocateElf32Dynamic (
if (DynShdr == NULL) { if (DynShdr == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
ASSERT (DynShdr->sh_type == SHT_DYNAMIC); ASSERT (DynShdr->sh_type == SHT_DYNAMIC);
ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn)); ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn));
@ -253,7 +260,8 @@ RelocateElf32Dynamic (
for ( Index = 0, Dyn = (Elf32_Dyn *)(ElfCt->FileBase + DynShdr->sh_offset) for ( Index = 0, Dyn = (Elf32_Dyn *)(ElfCt->FileBase + DynShdr->sh_offset)
; Index < DynShdr->sh_size / DynShdr->sh_entsize ; Index < DynShdr->sh_size / DynShdr->sh_entsize
; Index++, Dyn = ELF_NEXT_ENTRY (Elf32_Dyn, Dyn, DynShdr->sh_entsize) ; Index++, Dyn = ELF_NEXT_ENTRY (Elf32_Dyn, Dyn, DynShdr->sh_entsize)
) { )
{
switch (Dyn->d_tag) { switch (Dyn->d_tag) {
case DT_RELA: case DT_RELA:
case DT_REL: case DT_REL:
@ -304,12 +312,14 @@ RelocateElf32Dynamic (
if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) { if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) {
break; break;
} }
RelShdr = NULL; RelShdr = NULL;
} }
if (RelShdr == NULL) { if (RelShdr == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
ASSERT (RelShdr->sh_type == RelaType); ASSERT (RelShdr->sh_type == RelaType);
ASSERT (RelShdr->sh_entsize == RelaEntrySize); ASSERT (RelShdr->sh_entsize == RelaEntrySize);
@ -318,7 +328,9 @@ RelocateElf32Dynamic (
// //
ProcessRelocation32 ( ProcessRelocation32 (
(Elf32_Rela *)(ElfCt->FileBase + RelShdr->sh_offset), (Elf32_Rela *)(ElfCt->FileBase + RelShdr->sh_offset),
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type, RelShdr->sh_size,
RelShdr->sh_entsize,
RelShdr->sh_type,
(UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress, (UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress,
TRUE TRUE
); );
@ -376,10 +388,12 @@ RelocateElf32Sections (
for ( Index = 0, RelShdr = (Elf32_Shdr *)(ElfCt->FileBase + Ehdr->e_shoff) for ( Index = 0, RelShdr = (Elf32_Shdr *)(ElfCt->FileBase + Ehdr->e_shoff)
; Index < Ehdr->e_shnum ; Index < Ehdr->e_shnum
; Index++, RelShdr = ELF_NEXT_ENTRY (Elf32_Shdr, RelShdr, Ehdr->e_shentsize) ; Index++, RelShdr = ELF_NEXT_ENTRY (Elf32_Shdr, RelShdr, Ehdr->e_shentsize)
) { )
{
if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) { if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
continue; continue;
} }
Shdr = GetElf32SectionByIndex (ElfCt->FileBase, RelShdr->sh_info); Shdr = GetElf32SectionByIndex (ElfCt->FileBase, RelShdr->sh_info);
if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) { if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
// //
@ -387,8 +401,11 @@ RelocateElf32Sections (
// //
ProcessRelocation32 ( ProcessRelocation32 (
(Elf32_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset), (Elf32_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset),
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type, RelShdr->sh_size,
Delta, FALSE RelShdr->sh_entsize,
RelShdr->sh_type,
Delta,
FALSE
); );
} }
} }
@ -429,12 +446,14 @@ LoadElf32Image (
for ( Index = 0, Phdr = (Elf32_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff) for ( Index = 0, Phdr = (Elf32_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff)
; Index < Ehdr->e_phnum ; Index < Ehdr->e_phnum
; Index++, Phdr = ELF_NEXT_ENTRY (Elf32_Phdr, Phdr, Ehdr->e_phentsize) ; Index++, Phdr = ELF_NEXT_ENTRY (Elf32_Phdr, Phdr, Ehdr->e_phentsize)
) { )
{
// //
// Skip segments that don't require load (type tells, or size is 0) // Skip segments that don't require load (type tells, or size is 0)
// //
if ((Phdr->p_type != PT_LOAD) || if ((Phdr->p_type != PT_LOAD) ||
(Phdr->p_memsz == 0)) { (Phdr->p_memsz == 0))
{
continue; continue;
} }

View File

@ -36,7 +36,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef _SYS_ELF64_H_ #ifndef _SYS_ELF64_H_
#define _SYS_ELF64_H_ 1 #define _SYS_ELF64_H_ 1
/* /*
* ELF definitions common to all 64-bit architectures. * ELF definitions common to all 64-bit architectures.
*/ */

View File

@ -83,8 +83,10 @@ GetElf64SectionByRange (
if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) { if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) {
return Shdr; return Shdr;
} }
Shdr = ELF_NEXT_ENTRY (Elf64_Shdr, Shdr, Ehdr->e_shentsize); Shdr = ELF_NEXT_ENTRY (Elf64_Shdr, Shdr, Ehdr->e_shentsize);
} }
return NULL; return NULL;
} }
@ -117,7 +119,8 @@ ProcessRelocation64 (
for ( Index = 0 for ( Index = 0
; MultU64x64 (RelaEntrySize, Index) < RelaSize ; MultU64x64 (RelaEntrySize, Index) < RelaSize
; Index++, Rela = ELF_NEXT_ENTRY (Elf64_Rela, Rela, RelaEntrySize) ; Index++, Rela = ELF_NEXT_ENTRY (Elf64_Rela, Rela, RelaEntrySize)
) { )
{
// //
// r_offset is the virtual address of the storage unit affected by the relocation. // r_offset is the virtual address of the storage unit affected by the relocation.
// //
@ -142,6 +145,7 @@ ProcessRelocation64 (
} else { } else {
*Ptr += Delta; *Ptr += Delta;
} }
break; break;
case R_X86_64_32: case R_X86_64_32:
@ -187,12 +191,14 @@ ProcessRelocation64 (
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type)); DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
ASSERT (FALSE); ASSERT (FALSE);
} }
break; break;
default: default:
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type)); DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
} }
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -248,6 +254,7 @@ RelocateElf64Dynamic (
if (DynShdr == NULL) { if (DynShdr == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
ASSERT (DynShdr->sh_type == SHT_DYNAMIC); ASSERT (DynShdr->sh_type == SHT_DYNAMIC);
ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn)); ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn));
@ -262,7 +269,8 @@ RelocateElf64Dynamic (
for ( Index = 0, Dyn = (Elf64_Dyn *)(ElfCt->FileBase + DynShdr->sh_offset) for ( Index = 0, Dyn = (Elf64_Dyn *)(ElfCt->FileBase + DynShdr->sh_offset)
; Index < DivU64x64Remainder (DynShdr->sh_size, DynShdr->sh_entsize, NULL) ; Index < DivU64x64Remainder (DynShdr->sh_size, DynShdr->sh_entsize, NULL)
; Index++, Dyn = ELF_NEXT_ENTRY (Elf64_Dyn, Dyn, DynShdr->sh_entsize) ; Index++, Dyn = ELF_NEXT_ENTRY (Elf64_Dyn, Dyn, DynShdr->sh_entsize)
) { )
{
switch (Dyn->d_tag) { switch (Dyn->d_tag) {
case DT_RELA: case DT_RELA:
case DT_REL: case DT_REL:
@ -313,12 +321,14 @@ RelocateElf64Dynamic (
if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) { if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) {
break; break;
} }
RelShdr = NULL; RelShdr = NULL;
} }
if (RelShdr == NULL) { if (RelShdr == NULL) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
ASSERT (RelShdr->sh_type == RelaType); ASSERT (RelShdr->sh_type == RelaType);
ASSERT (RelShdr->sh_entsize == RelaEntrySize); ASSERT (RelShdr->sh_entsize == RelaEntrySize);
@ -327,7 +337,9 @@ RelocateElf64Dynamic (
// //
ProcessRelocation64 ( ProcessRelocation64 (
(Elf64_Rela *)(ElfCt->FileBase + RelShdr->sh_offset), (Elf64_Rela *)(ElfCt->FileBase + RelShdr->sh_offset),
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type, RelShdr->sh_size,
RelShdr->sh_entsize,
RelShdr->sh_type,
(UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress, (UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress,
TRUE TRUE
); );
@ -385,10 +397,12 @@ RelocateElf64Sections (
for ( Index = 0, RelShdr = (Elf64_Shdr *)(ElfCt->FileBase + Ehdr->e_shoff) for ( Index = 0, RelShdr = (Elf64_Shdr *)(ElfCt->FileBase + Ehdr->e_shoff)
; Index < Ehdr->e_shnum ; Index < Ehdr->e_shnum
; Index++, RelShdr = ELF_NEXT_ENTRY (Elf64_Shdr, RelShdr, Ehdr->e_shentsize) ; Index++, RelShdr = ELF_NEXT_ENTRY (Elf64_Shdr, RelShdr, Ehdr->e_shentsize)
) { )
{
if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) { if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
continue; continue;
} }
Shdr = GetElf64SectionByIndex (ElfCt->FileBase, RelShdr->sh_info); Shdr = GetElf64SectionByIndex (ElfCt->FileBase, RelShdr->sh_info);
if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) { if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
// //
@ -396,8 +410,11 @@ RelocateElf64Sections (
// //
ProcessRelocation64 ( ProcessRelocation64 (
(Elf64_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset), (Elf64_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset),
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type, RelShdr->sh_size,
Delta, FALSE RelShdr->sh_entsize,
RelShdr->sh_type,
Delta,
FALSE
); );
} }
} }
@ -438,12 +455,14 @@ LoadElf64Image (
for ( Index = 0, Phdr = (Elf64_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff) for ( Index = 0, Phdr = (Elf64_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff)
; Index < Ehdr->e_phnum ; Index < Ehdr->e_phnum
; Index++, Phdr = ELF_NEXT_ENTRY (Elf64_Phdr, Phdr, Ehdr->e_phentsize) ; Index++, Phdr = ELF_NEXT_ENTRY (Elf64_Phdr, Phdr, Ehdr->e_phentsize)
) { )
{
// //
// Skip segments that don't require load (type tells, or size is 0) // Skip segments that don't require load (type tells, or size is 0)
// //
if ((Phdr->p_type != PT_LOAD) || if ((Phdr->p_type != PT_LOAD) ||
(Phdr->p_memsz == 0)) { (Phdr->p_memsz == 0))
{
continue; continue;
} }

View File

@ -979,5 +979,4 @@ typedef struct {
#define R_X86_64_GOTPCRELX 41 /* Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable. */ #define R_X86_64_GOTPCRELX 41 /* Load from 32 bit signed pc relative offset to GOT entry without REX prefix, relaxable. */
#define R_X86_64_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative offset to GOT entry with REX prefix, relaxable. */ #define R_X86_64_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative offset to GOT entry with REX prefix, relaxable. */
#endif /* !_SYS_ELF_COMMON_H_ */ #endif /* !_SYS_ELF_COMMON_H_ */

View File

@ -35,7 +35,8 @@ IsElfFormat (
(Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) || (Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) ||
(Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) || (Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) ||
(Elf32Hdr->e_ident[EI_MAG2] != ELFMAG2) (Elf32Hdr->e_ident[EI_MAG2] != ELFMAG2)
) { )
{
return FALSE; return FALSE;
} }
@ -101,6 +102,7 @@ IsElfFormat (
return FALSE; return FALSE;
} }
} }
return TRUE; return TRUE;
} }
@ -137,6 +139,7 @@ CalculateElfFileSize (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
FileSize1 = Offset + Size; FileSize1 = Offset + Size;
// Use end of section header as end of file // Use end of section header as end of file
@ -241,6 +244,7 @@ ParseElfImage (
if (ElfCt == NULL) { if (ElfCt == NULL) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ZeroMem (ElfCt, sizeof (ELF_IMAGE_CONTEXT)); ZeroMem (ElfCt, sizeof (ELF_IMAGE_CONTEXT));
if (ImageBase == NULL) { if (ImageBase == NULL) {
@ -258,10 +262,12 @@ ParseElfImage (
if ((Elf32Hdr->e_type != ET_EXEC) && (Elf32Hdr->e_type != ET_DYN)) { if ((Elf32Hdr->e_type != ET_EXEC) && (Elf32Hdr->e_type != ET_DYN)) {
return (ElfCt->ParseStatus = EFI_UNSUPPORTED); return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
} }
Elf32Shdr = (Elf32_Shdr *)GetElf32SectionByIndex (ElfCt->FileBase, Elf32Hdr->e_shstrndx); Elf32Shdr = (Elf32_Shdr *)GetElf32SectionByIndex (ElfCt->FileBase, Elf32Hdr->e_shstrndx);
if (Elf32Shdr == NULL) { if (Elf32Shdr == NULL) {
return (ElfCt->ParseStatus = EFI_UNSUPPORTED); return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
} }
ElfCt->EntryPoint = (UINTN)Elf32Hdr->e_entry; ElfCt->EntryPoint = (UINTN)Elf32Hdr->e_entry;
ElfCt->ShNum = Elf32Hdr->e_shnum; ElfCt->ShNum = Elf32Hdr->e_shnum;
ElfCt->PhNum = Elf32Hdr->e_phnum; ElfCt->PhNum = Elf32Hdr->e_phnum;
@ -272,10 +278,12 @@ ParseElfImage (
if ((Elf64Hdr->e_type != ET_EXEC) && (Elf64Hdr->e_type != ET_DYN)) { if ((Elf64Hdr->e_type != ET_EXEC) && (Elf64Hdr->e_type != ET_DYN)) {
return (ElfCt->ParseStatus = EFI_UNSUPPORTED); return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
} }
Elf64Shdr = (Elf64_Shdr *)GetElf64SectionByIndex (ElfCt->FileBase, Elf64Hdr->e_shstrndx); Elf64Shdr = (Elf64_Shdr *)GetElf64SectionByIndex (ElfCt->FileBase, Elf64Hdr->e_shstrndx);
if (Elf64Shdr == NULL) { if (Elf64Shdr == NULL) {
return (ElfCt->ParseStatus = EFI_UNSUPPORTED); return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
} }
ElfCt->EntryPoint = (UINTN)Elf64Hdr->e_entry; ElfCt->EntryPoint = (UINTN)Elf64Hdr->e_entry;
ElfCt->ShNum = Elf64Hdr->e_shnum; ElfCt->ShNum = Elf64Hdr->e_shnum;
ElfCt->PhNum = Elf64Hdr->e_phnum; ElfCt->PhNum = Elf64Hdr->e_phnum;
@ -307,10 +315,12 @@ ParseElfImage (
if (Base > (SegInfo.MemAddr & ~(EFI_PAGE_SIZE - 1))) { if (Base > (SegInfo.MemAddr & ~(EFI_PAGE_SIZE - 1))) {
Base = SegInfo.MemAddr & ~(EFI_PAGE_SIZE - 1); Base = SegInfo.MemAddr & ~(EFI_PAGE_SIZE - 1);
} }
if (End < ALIGN_VALUE (SegInfo.MemAddr + SegInfo.MemLen, EFI_PAGE_SIZE) - 1) { if (End < ALIGN_VALUE (SegInfo.MemAddr + SegInfo.MemLen, EFI_PAGE_SIZE) - 1) {
End = ALIGN_VALUE (SegInfo.MemAddr + SegInfo.MemLen, EFI_PAGE_SIZE) - 1; End = ALIGN_VALUE (SegInfo.MemAddr + SegInfo.MemLen, EFI_PAGE_SIZE) - 1;
} }
} }
// //
// 0 - MAX_UINT32 + 1 equals to 0. // 0 - MAX_UINT32 + 1 equals to 0.
// //
@ -318,7 +328,7 @@ ParseElfImage (
ElfCt->PreferredImageAddress = (VOID *)Base; ElfCt->PreferredImageAddress = (VOID *)Base;
CalculateElfFileSize (ElfCt, &ElfCt->FileSize); CalculateElfFileSize (ElfCt, &ElfCt->FileSize);
return (ElfCt->ParseStatus = EFI_SUCCESS);; return (ElfCt->ParseStatus = EFI_SUCCESS);
} }
/** /**
@ -366,7 +376,6 @@ LoadElfImage (
return Status; return Status;
} }
/** /**
Get a ELF section name from its index. Get a ELF section name from its index.
@ -419,7 +428,6 @@ GetElfSectionName (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Get the offset and size of x-th ELF section. Get the offset and size of x-th ELF section.

View File

@ -20,7 +20,6 @@
#define ELF_NEXT_ENTRY(EntryType, Current, EntrySize) \ #define ELF_NEXT_ENTRY(EntryType, Current, EntrySize) \
((EntryType *) ((UINT8 *)Current + EntrySize)) ((EntryType *) ((UINT8 *)Current + EntrySize))
/** /**
Return the section header specified by Index. Return the section header specified by Index.

View File

@ -75,8 +75,11 @@ PeiLoadFileLoadPayload (
} while (EFI_ERROR (Status)); } while (EFI_ERROR (Status));
DEBUG (( DEBUG ((
DEBUG_INFO, "Payload File Size: 0x%08X, Mem Size: 0x%08x, Reload: %d\n", DEBUG_INFO,
Context.FileSize, Context.ImageSize, Context.ReloadRequired "Payload File Size: 0x%08X, Mem Size: 0x%08x, Reload: %d\n",
Context.FileSize,
Context.ImageSize,
Context.ReloadRequired
)); ));
// //
@ -89,6 +92,7 @@ PeiLoadFileLoadPayload (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
DEBUG ((DEBUG_INFO, "Payload Section[%d]: %a\n", Index, SectionName)); DEBUG ((DEBUG_INFO, "Payload Section[%d]: %a\n", Index, SectionName));
if (AsciiStrCmp (SectionName, UNIVERSAL_PAYLOAD_INFO_SEC_NAME) == 0) { if (AsciiStrCmp (SectionName, UNIVERSAL_PAYLOAD_INFO_SEC_NAME) == 0) {
Status = GetElfSectionPos (&Context, Index, &Offset, &Size); Status = GetElfSectionPos (&Context, Index, &Offset, &Size);
@ -120,6 +124,7 @@ PeiLoadFileLoadPayload (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
if (AsciiStrnCmp (SectionName, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX_LENGTH) == 0) { if (AsciiStrnCmp (SectionName, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX_LENGTH) == 0) {
Status = GetElfSectionPos (&Context, Index, &Offset, &Size); Status = GetElfSectionPos (&Context, Index, &Offset, &Size);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -137,7 +142,7 @@ PeiLoadFileLoadPayload (
} }
} }
if (Context.ReloadRequired || Context.PreferredImageAddress != Context.FileBase) { if (Context.ReloadRequired || (Context.PreferredImageAddress != Context.FileBase)) {
Context.ImageAddress = AllocatePages (EFI_SIZE_TO_PAGES (Context.ImageSize)); Context.ImageAddress = AllocatePages (EFI_SIZE_TO_PAGES (Context.ImageSize));
} else { } else {
Context.ImageAddress = Context.FileBase; Context.ImageAddress = Context.FileBase;
@ -152,20 +157,20 @@ PeiLoadFileLoadPayload (
*EntryPoint = Context.EntryPoint; *EntryPoint = Context.EntryPoint;
*ImageSizeArg = Context.ImageSize; *ImageSizeArg = Context.ImageSize;
} }
return Status; return Status;
} }
EFI_PEI_LOAD_FILE_PPI mPeiLoadFilePpi = { EFI_PEI_LOAD_FILE_PPI mPeiLoadFilePpi = {
PeiLoadFileLoadPayload PeiLoadFileLoadPayload
}; };
EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = { EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiLoadFilePpiGuid, &gEfiPeiLoadFilePpiGuid,
&mPeiLoadFilePpi &mPeiLoadFilePpi
}; };
/** /**
Install Pei Load File PPI. Install Pei Load File PPI.
@ -185,6 +190,7 @@ InitializePayloadLoaderPeim (
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = PeiServicesInstallPpi (&gPpiLoadFilePpiList); Status = PeiServicesInstallPpi (&gPpiLoadFilePpiList);
return Status; return Status;

View File

@ -44,6 +44,7 @@ FindContextBySwSmiInputValue (
return Dispatch2Context; return Dispatch2Context;
} }
} }
return NULL; return NULL;
} }
@ -69,6 +70,7 @@ FindContextByDispatchHandle (
return Dispatch2Context; return Dispatch2Context;
} }
} }
return NULL; return NULL;
} }
@ -122,6 +124,7 @@ SmmSwDispatcher (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
continue; continue;
} }
if (IoInfo.IoPort == SMM_CONTROL_PORT) { if (IoInfo.IoPort == SMM_CONTROL_PORT) {
// //
// Great! Find it. // Great! Find it.
@ -147,6 +150,7 @@ SmmSwDispatcher (
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
goto End; goto End;
} }
DEBUG ((DEBUG_VERBOSE, "Prepare to call handler for 0x%x\n", SwContext.CommandPort)); DEBUG ((DEBUG_VERBOSE, "Prepare to call handler for 0x%x\n", SwContext.CommandPort));
// //
@ -163,7 +167,6 @@ End:
// //
IoOr32 (mSmiPchReg.SmiApmStsAddr, 1 << mSmiPchReg.ApmBitOffset); IoOr32 (mSmiPchReg.SmiApmStsAddr, 1 << mSmiPchReg.ApmBitOffset);
// //
// Set EOS bit // Set EOS bit
// //
@ -172,7 +175,6 @@ End:
return Status; return Status;
} }
/** /**
Check the SwSmiInputValue is already used Check the SwSmiInputValue is already used
@ -201,7 +203,6 @@ SmiInputValueCheck (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Register a child SMI source dispatch function for the specified software SMI. Register a child SMI source dispatch function for the specified software SMI.
@ -256,6 +257,7 @@ SmmSwDispatch2Register (
break; break;
} }
} }
if (RegContext->SwSmiInputValue == (UINTN)-1) { if (RegContext->SwSmiInputValue == (UINTN)-1) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
@ -285,7 +287,6 @@ SmmSwDispatch2Register (
return Status; return Status;
} }
/** /**
Unregister a child SMI source dispatch function for the specified software SMI. Unregister a child SMI source dispatch function for the specified software SMI.
@ -320,14 +321,12 @@ SmmSwDispatch2UnRegister (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_SMM_SW_DISPATCH2_PROTOCOL gSmmSwDispatch2 = { EFI_SMM_SW_DISPATCH2_PROTOCOL gSmmSwDispatch2 = {
SmmSwDispatch2Register, SmmSwDispatch2Register,
SmmSwDispatch2UnRegister, SmmSwDispatch2UnRegister,
MAXIMUM_SWI_VALUE MAXIMUM_SWI_VALUE
}; };
/** /**
Get specified SMI register based on given register ID Get specified SMI register based on given register ID
@ -367,7 +366,8 @@ GetSmmCtrlRegById (
(PldReg->Address.Address == 0) || (PldReg->Address.Address == 0) ||
(PldReg->Address.RegisterBitWidth != 1) || (PldReg->Address.RegisterBitWidth != 1) ||
(PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) || (PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) ||
(PldReg->Value != 1)) { (PldReg->Value != 1))
{
DEBUG ((DEBUG_INFO, "Unexpected SMM register.\n")); DEBUG ((DEBUG_INFO, "Unexpected SMM register.\n"));
DEBUG ((DEBUG_INFO, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId)); DEBUG ((DEBUG_INFO, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth)); DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
@ -380,7 +380,6 @@ GetSmmCtrlRegById (
return PldReg; return PldReg;
} }
/** /**
Entry Point for this driver. Entry Point for this driver.
@ -415,6 +414,7 @@ PchSmiDispatchEntryPoint (
DEBUG ((DEBUG_ERROR, "SMI EOS reg not found.\n")); DEBUG ((DEBUG_ERROR, "SMI EOS reg not found.\n"));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
mSmiPchReg.SmiEosAddr = (UINT32)SmiEosReg->Address.Address; mSmiPchReg.SmiEosAddr = (UINT32)SmiEosReg->Address.Address;
mSmiPchReg.EosBitOffset = SmiEosReg->Address.RegisterBitOffset; mSmiPchReg.EosBitOffset = SmiEosReg->Address.RegisterBitOffset;
@ -423,6 +423,7 @@ PchSmiDispatchEntryPoint (
DEBUG ((DEBUG_ERROR, "SMI APM status reg not found.\n")); DEBUG ((DEBUG_ERROR, "SMI APM status reg not found.\n"));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
mSmiPchReg.SmiApmStsAddr = (UINT32)SmiApmStsReg->Address.Address; mSmiPchReg.SmiApmStsAddr = (UINT32)SmiApmStsReg->Address.Address;
mSmiPchReg.ApmBitOffset = SmiApmStsReg->Address.RegisterBitOffset; mSmiPchReg.ApmBitOffset = SmiApmStsReg->Address.RegisterBitOffset;
@ -452,4 +453,3 @@ PchSmiDispatchEntryPoint (
return Status; return Status;
} }

View File

@ -34,4 +34,3 @@ typedef struct {
} EFI_SMM_SW_DISPATCH2_CONTEXT; } EFI_SMM_SW_DISPATCH2_CONTEXT;
#endif #endif

View File

@ -215,20 +215,26 @@ SmmAccessEntryPoint (
DEBUG ((DEBUG_INFO, "SMRAM HOB NOT found\n")); DEBUG ((DEBUG_INFO, "SMRAM HOB NOT found\n"));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
SmramHob = (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)GET_GUID_HOB_DATA (GuidHob); SmramHob = (EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *)GET_GUID_HOB_DATA (GuidHob);
SmmRegionNum = SmramHob->NumberOfSmmReservedRegions; SmmRegionNum = SmramHob->NumberOfSmmReservedRegions;
mSmmAccess.SmramDesc = AllocateZeroPool (sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum); mSmmAccess.SmramDesc = AllocateZeroPool (sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum);
if (mSmmAccess.SmramDesc == NULL) { if (mSmmAccess.SmramDesc == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
CopyMem (mSmmAccess.SmramDesc, &SmramHob->Descriptor, sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum); CopyMem (mSmmAccess.SmramDesc, &SmramHob->Descriptor, sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum);
DEBUG ((DEBUG_INFO, "NumberOfSmmReservedRegions = 0x%x\n", SmmRegionNum)); DEBUG ((DEBUG_INFO, "NumberOfSmmReservedRegions = 0x%x\n", SmmRegionNum));
for (Index = 0; Index < SmmRegionNum; Index++) { for (Index = 0; Index < SmmRegionNum; Index++) {
DEBUG ((DEBUG_INFO, "%d: base=0x%x, size = 0x%x, State=0x%x\n",Index, DEBUG ((
DEBUG_INFO,
"%d: base=0x%x, size = 0x%x, State=0x%x\n",
Index,
SmramHob->Descriptor[Index].PhysicalStart, SmramHob->Descriptor[Index].PhysicalStart,
SmramHob->Descriptor[Index].PhysicalSize, SmramHob->Descriptor[Index].PhysicalSize,
SmramHob->Descriptor[Index].RegionState)); SmramHob->Descriptor[Index].RegionState
));
mSmmAccess.SmramDesc[Index].RegionState &= EFI_ALLOCATED; mSmmAccess.SmramDesc[Index].RegionState &= EFI_ALLOCATED;
mSmmAccess.SmramDesc[Index].RegionState |= EFI_SMRAM_CLOSED | EFI_CACHEABLE; mSmmAccess.SmramDesc[Index].RegionState |= EFI_SMRAM_CLOSED | EFI_CACHEABLE;
} }

View File

@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Guid/SmramMemoryReserve.h> #include <Guid/SmramMemoryReserve.h>
#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'M', 'M', 'A') #define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'M', 'M', 'A')
typedef struct { typedef struct {

View File

@ -150,7 +150,8 @@ GetSmmCtrlRegById (
(PldReg->Address.Address == 0) || (PldReg->Address.Address == 0) ||
(PldReg->Address.RegisterBitWidth != 1) || (PldReg->Address.RegisterBitWidth != 1) ||
(PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) || (PldReg->Address.AddressSpaceId != EFI_ACPI_3_0_SYSTEM_IO) ||
(PldReg->Value != 1)) { (PldReg->Value != 1))
{
DEBUG ((DEBUG_INFO, "Unexpected SMM register.\n")); DEBUG ((DEBUG_INFO, "Unexpected SMM register.\n"));
DEBUG ((DEBUG_INFO, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId)); DEBUG ((DEBUG_INFO, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth)); DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
@ -159,10 +160,10 @@ GetSmmCtrlRegById (
DEBUG ((DEBUG_INFO, "Address = 0x%lx\n", PldReg->Address.Address)); DEBUG ((DEBUG_INFO, "Address = 0x%lx\n", PldReg->Address.Address));
return NULL; return NULL;
} }
return PldReg; return PldReg;
} }
/** /**
Fixup data pointers so that the services can be called in virtual mode. Fixup data pointers so that the services can be called in virtual mode.
@ -181,7 +182,6 @@ SmmControlVirtualAddressChangeEvent (
EfiConvertPointer (0x0, (VOID **)&(mSmmControl2.Clear)); EfiConvertPointer (0x0, (VOID **)&(mSmmControl2.Clear));
} }
/** /**
This function installs EFI_SMM_CONTROL2_PROTOCOL. This function installs EFI_SMM_CONTROL2_PROTOCOL.
@ -217,6 +217,7 @@ SmmControlEntryPoint (
DEBUG ((DEBUG_ERROR, "SMI global enable reg not found.\n")); DEBUG ((DEBUG_ERROR, "SMI global enable reg not found.\n"));
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
mSmiCtrlReg.Address = (UINT32)SmiGblEnReg->Address.Address; mSmiCtrlReg.Address = (UINT32)SmiGblEnReg->Address.Address;
mSmiCtrlReg.GblBitOffset = SmiGblEnReg->Address.RegisterBitOffset; mSmiCtrlReg.GblBitOffset = SmiGblEnReg->Address.RegisterBitOffset;
@ -231,6 +232,7 @@ SmmControlEntryPoint (
DEBUG ((DEBUG_ERROR, "APM:0x%x, GBL:0x%x\n", SmiApmEnReg->Address.Address, mSmiCtrlReg.Address)); DEBUG ((DEBUG_ERROR, "APM:0x%x, GBL:0x%x\n", SmiApmEnReg->Address.Address, mSmiCtrlReg.Address));
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
mSmiCtrlReg.ApmBitOffset = SmiApmEnReg->Address.RegisterBitOffset; mSmiCtrlReg.ApmBitOffset = SmiApmEnReg->Address.RegisterBitOffset;
// //

View File

@ -9,7 +9,6 @@
#include "UefiPayloadEntry.h" #include "UefiPayloadEntry.h"
/** /**
Find the board related info from ACPI table Find the board related info from ACPI table
@ -116,6 +115,7 @@ Done:
AcpiBoardInfo->PcieBaseAddress = 0; AcpiBoardInfo->PcieBaseAddress = 0;
AcpiBoardInfo->PcieBaseSize = 0; AcpiBoardInfo->PcieBaseSize = 0;
} }
DEBUG ((DEBUG_INFO, "PmCtrl Reg 0x%lx\n", AcpiBoardInfo->PmCtrlRegBase)); DEBUG ((DEBUG_INFO, "PmCtrl Reg 0x%lx\n", AcpiBoardInfo->PmCtrlRegBase));
DEBUG ((DEBUG_INFO, "PmTimer Reg 0x%lx\n", AcpiBoardInfo->PmTimerRegBase)); DEBUG ((DEBUG_INFO, "PmTimer Reg 0x%lx\n", AcpiBoardInfo->PmTimerRegBase));
DEBUG ((DEBUG_INFO, "Reset Reg 0x%lx\n", AcpiBoardInfo->ResetRegAddress)); DEBUG ((DEBUG_INFO, "Reset Reg 0x%lx\n", AcpiBoardInfo->ResetRegAddress));
@ -156,21 +156,25 @@ Done:
if (!(Fadt->Flags & EFI_ACPI_5_0_HW_REDUCED_ACPI) && if (!(Fadt->Flags & EFI_ACPI_5_0_HW_REDUCED_ACPI) &&
(Fadt->SmiCmd == 0) && (Fadt->SmiCmd == 0) &&
!SciEnabled) { !SciEnabled)
{
// //
// The ACPI enabling status is inconsistent: SCI is not enabled but ACPI // The ACPI enabling status is inconsistent: SCI is not enabled but ACPI
// table does not provide a means to enable it through FADT->SmiCmd // table does not provide a means to enable it through FADT->SmiCmd
// //
DEBUG ((DEBUG_ERROR, "ERROR: The ACPI enabling status is inconsistent: SCI is not" DEBUG ((
DEBUG_ERROR,
"ERROR: The ACPI enabling status is inconsistent: SCI is not"
" enabled but the ACPI table does not provide a means to enable it through FADT->SmiCmd." " enabled but the ACPI table does not provide a means to enable it through FADT->SmiCmd."
" This may cause issues in OS.\n")); " This may cause issues in OS.\n"
));
} }
DEBUG_CODE_END (); DEBUG_CODE_END ();
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
Build ACPI board info HOB using infomation from ACPI table Build ACPI board info HOB using infomation from ACPI table
@ -196,7 +200,6 @@ BuildHobFromAcpi (
CopyMem (NewAcpiBoardInfo, &AcpiBoardInfo, sizeof (ACPI_BOARD_INFO)); CopyMem (NewAcpiBoardInfo, &AcpiBoardInfo, sizeof (ACPI_BOARD_INFO));
DEBUG ((DEBUG_INFO, "Create acpi board info guid hob\n")); DEBUG ((DEBUG_INFO, "Create acpi board info guid hob\n"));
} }
return NewAcpiBoardInfo; return NewAcpiBoardInfo;
} }

View File

@ -36,15 +36,33 @@ typedef struct _X64_IDT_TABLE {
// //
GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries[] = { GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries[] = {
/* selector { Global Segment Descriptor } */ /* selector { Global Segment Descriptor } */
/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor /* 0x00 */ {
/* 0x08 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
/* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear code segment descriptor }, // null descriptor
/* 0x18 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor /* 0x08 */ {
/* 0x20 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system code segment descriptor { 0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
/* 0x28 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor }, // linear data segment descriptor
/* 0x30 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor /* 0x10 */ {
/* 0x38 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}}, //system code segment descriptor { 0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
/* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor }, // linear code segment descriptor
/* 0x18 */ {
{ 0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
}, // system data segment descriptor
/* 0x20 */ {
{ 0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
}, // system code segment descriptor
/* 0x28 */ {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}, // spare segment descriptor
/* 0x30 */ {
{ 0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
}, // system data segment descriptor
/* 0x38 */ {
{ 0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0 }
}, // system code segment descriptor
/* 0x40 */ {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}, // spare segment descriptor
}; };
// //
@ -125,9 +143,10 @@ Create4GPageTablesIa32Pae (
PageDirectoryPointerEntry->Bits.Present = 1; PageDirectoryPointerEntry->Bits.Present = 1;
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress += SIZE_2MB) { for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress += SIZE_2MB) {
if ((IsNullDetectionEnabled () && PhysicalAddress == 0) if ( (IsNullDetectionEnabled () && (PhysicalAddress == 0))
|| ( (PhysicalAddress < StackBase + StackSize) || ( (PhysicalAddress < StackBase + StackSize)
&& ((PhysicalAddress + SIZE_2MB) > StackBase))) { && ((PhysicalAddress + SIZE_2MB) > StackBase)))
{
// //
// Need to split this 2M page that covers stack range. // Need to split this 2M page that covers stack range.
// //
@ -331,7 +350,6 @@ HandOffToDxeCore (
gLidtDescriptor.Base = (UINTN)IdtTable; gLidtDescriptor.Base = (UINTN)IdtTable;
AsmWriteIdtr (&gLidtDescriptor); AsmWriteIdtr (&gLidtDescriptor);
DEBUG (( DEBUG ((
@ -360,6 +378,4 @@ HandOffToDxeCore (
ASSERT (FALSE); ASSERT (FALSE);
CpuDeadLoop (); CpuDeadLoop ();
} }
} }

View File

@ -35,6 +35,7 @@ AllocateCodePages (
Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiBootServicesCode; Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiBootServicesCode;
return Alloc; return Alloc;
} }
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob)); Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));
} }
@ -44,7 +45,6 @@ AllocateCodePages (
return NULL; return NULL;
} }
/** /**
Loads and relocates a PE/COFF image Loads and relocates a PE/COFF image
@ -86,6 +86,7 @@ LoadPeCoffImage (
if (Buffer == NULL) { if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer; ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
// //
@ -174,7 +175,7 @@ FvFindFileByTypeGuid (
// Look for file type // Look for file type
// //
if (File->Type == FileType) { if (File->Type == FileType) {
if (Guid == NULL || CompareGuid(&File->Name, Guid)) { if ((Guid == NULL) || CompareGuid (&File->Name, Guid)) {
*FileHeader = File; *FileHeader = File;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -184,7 +185,6 @@ FvFindFileByTypeGuid (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
This function searchs a given section type within a valid FFS file. This function searchs a given section type within a valid FFS file.
@ -214,6 +214,7 @@ FileFindSection (
} else { } else {
FileSize = FFS_FILE_SIZE (FileHeader); FileSize = FFS_FILE_SIZE (FileHeader);
} }
FileSize -= sizeof (EFI_FFS_FILE_HEADER); FileSize -= sizeof (EFI_FFS_FILE_HEADER);
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1); Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
@ -225,6 +226,7 @@ FileFindSection (
} else { } else {
*SectionData = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER)); *SectionData = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER));
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -244,7 +246,6 @@ FileFindSection (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/** /**
Find DXE core from FV and build DXE core HOBs. Find DXE core from FV and build DXE core HOBs.
@ -275,6 +276,7 @@ LoadDxeCore (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = FileFindSection (FileHeader, EFI_SECTION_FIRMWARE_VOLUME_IMAGE, (VOID **)&DxeCoreFv); Status = FileFindSection (FileHeader, EFI_SECTION_FIRMWARE_VOLUME_IMAGE, (VOID **)&DxeCoreFv);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;

View File

@ -137,7 +137,6 @@ AllocateAlignedPages (
return (VOID *)(UINTN)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask); return (VOID *)(UINTN)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask);
} }
/** /**
Allocates a buffer of type EfiBootServicesData. Allocates a buffer of type EfiBootServicesData.
@ -197,5 +196,3 @@ AllocateZeroPool (
return Buffer; return Buffer;
} }

View File

@ -75,7 +75,6 @@ typedef struct{
CHAR8 *Type; CHAR8 *Type;
} PRINT_MEMORY_ALLOCCATION_HOB; } PRINT_MEMORY_ALLOCCATION_HOB;
/** /**
Print the Hex value of a given range. Print the Hex value of a given range.
@param[in] DataStart A pointer to the start of data to be printed. @param[in] DataStart A pointer to the start of data to be printed.
@ -99,6 +98,7 @@ PrintHex (
DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart)); DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart));
DataStart++; DataStart++;
} }
DEBUG ((DEBUG_VERBOSE, "\n")); DEBUG ((DEBUG_VERBOSE, "\n"));
} }
@ -119,6 +119,7 @@ PrintHandOffHob(
) )
{ {
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = (UINT8 *)HobStart; Hob.Raw = (UINT8 *)HobStart;
ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable)); ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable));
DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode)); DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode));
@ -161,6 +162,7 @@ PrintMemoryAllocationHob (
ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation)); ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation));
DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n")); DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n"));
} }
DEBUG ((DEBUG_INFO, " MemoryBaseAddress = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress)); DEBUG ((DEBUG_INFO, " MemoryBaseAddress = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress));
DEBUG ((DEBUG_INFO, " MemoryLength = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength)); DEBUG ((DEBUG_INFO, " MemoryLength = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength));
DEBUG ((DEBUG_INFO, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType])); DEBUG ((DEBUG_INFO, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType]));
@ -188,6 +190,7 @@ PrintResourceDiscriptorHob (
if (!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) { if (!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) {
DEBUG ((DEBUG_INFO, " Owner = %g\n", Hob.ResourceDescriptor->Owner)); DEBUG ((DEBUG_INFO, " Owner = %g\n", Hob.ResourceDescriptor->Owner));
} }
DEBUG ((DEBUG_INFO, " ResourceAttribute = 0x%x\n", Hob.ResourceDescriptor->ResourceAttribute)); DEBUG ((DEBUG_INFO, " ResourceAttribute = 0x%x\n", Hob.ResourceDescriptor->ResourceAttribute));
DEBUG ((DEBUG_INFO, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart)); DEBUG ((DEBUG_INFO, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart));
DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength)); DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength));
@ -209,6 +212,7 @@ PrintAcpiGuidHob (
) )
{ {
UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob; UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob;
AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (HobRaw); AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (HobRaw);
ASSERT (HobLength >= AcpiTableHob->Header.Length); ASSERT (HobLength >= AcpiTableHob->Header.Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision)); DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));
@ -231,6 +235,7 @@ PrintSerialGuidHob (
) )
{ {
UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;
SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (HobRaw); SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (HobRaw);
ASSERT (HobLength >= SerialPortInfo->Header.Length); ASSERT (HobLength >= SerialPortInfo->Header.Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision)); DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));
@ -255,6 +260,7 @@ PrintSmbios3GuidHob (
) )
{ {
UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable; UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw); SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
ASSERT (HobLength >= SmBiosTable->Header.Length); ASSERT (HobLength >= SmBiosTable->Header.Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision)); DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
@ -277,6 +283,7 @@ PrintSmbiosTablGuidHob (
) )
{ {
UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable; UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw); SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
ASSERT (HobLength >= SmBiosTable->Header.Length); ASSERT (HobLength >= SmBiosTable->Header.Length);
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision)); DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
@ -299,6 +306,7 @@ PrintAcpiBoardInfoGuidHob (
) )
{ {
ACPI_BOARD_INFO *AcpBoardInfo; ACPI_BOARD_INFO *AcpBoardInfo;
AcpBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (HobRaw); AcpBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (HobRaw);
ASSERT (HobLength >= sizeof (*AcpBoardInfo)); ASSERT (HobLength >= sizeof (*AcpBoardInfo));
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision)); DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));
@ -330,6 +338,7 @@ PrintPciRootBridgeInfoGuidHob (
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges; UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
UINTN Index; UINTN Index;
UINTN Length; UINTN Length;
Index = 0; Index = 0;
PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GET_GUID_HOB_DATA (HobRaw); PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GET_GUID_HOB_DATA (HobRaw);
Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE); Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
@ -367,6 +376,7 @@ PrintPciRootBridgeInfoGuidHob (
DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation)); DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));
Index += 1; Index += 1;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -401,6 +411,7 @@ PrintExtraDataGuidHob (
DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Size)); DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Size));
Index += 1; Index += 1;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -490,6 +501,7 @@ PrintGuidHob (
return Status; return Status;
} }
} }
DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name)); DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));
PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw)); PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));
return EFI_SUCCESS; return EFI_SUCCESS;
@ -613,6 +625,7 @@ PrintFv3Hob (
) )
{ {
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
Hob.Raw = (UINT8 *)HobStart; Hob.Raw = (UINT8 *)HobStart;
ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3)); ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));
@ -641,7 +654,6 @@ HOB_PRINT_HANDLER_TABLE mHobHandles[] = {
{ EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob } { EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob }
}; };
/** /**
Print all HOBs info from the HOB list. Print all HOBs info from the HOB list.
@param[in] HobStart A pointer to the HOB list @param[in] HobStart A pointer to the HOB list
@ -655,6 +667,7 @@ PrintHob (
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
UINTN Count; UINTN Count;
UINTN Index; UINTN Index;
ASSERT (HobStart != NULL); ASSERT (HobStart != NULL);
Hob.Raw = (UINT8 *)HobStart; Hob.Raw = (UINT8 *)HobStart;
@ -672,13 +685,16 @@ PrintHob (
break; break;
} }
} }
if (Index == ARRAY_SIZE (mHobHandles)) { if (Index == ARRAY_SIZE (mHobHandles)) {
DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %d, Offset = 0x%p, Length = 0x%x\n", Count, Hob.Header->HobType, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength)); DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %d, Offset = 0x%p, Length = 0x%x\n", Count, Hob.Header->HobType, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
DEBUG ((DEBUG_INFO, " Unkown Hob type\n")); DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));
PrintHex (Hob.Raw, Hob.Header->HobLength); PrintHex (Hob.Raw, Hob.Header->HobLength);
} }
Count++; Count++;
Hob.Raw = GET_NEXT_HOB (Hob); Hob.Raw = GET_NEXT_HOB (Hob);
} }
DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw)); DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));
} }

View File

@ -42,7 +42,7 @@ MemInfoCallbackMmio (
// //
// Skip types already handled in MemInfoCallback // Skip types already handled in MemInfoCallback
// //
if (MemoryMapEntry->Type == E820_RAM || MemoryMapEntry->Type == E820_ACPI) { if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI)) {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -79,8 +79,9 @@ MemInfoCallbackMmio (
BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, Size); BuildResourceDescriptorHob (Type, Attribue, (EFI_PHYSICAL_ADDRESS)Base, Size);
DEBUG ((DEBUG_INFO, "buildhob: base = 0x%lx, size = 0x%lx, type = 0x%x\n", Base, Size, Type)); DEBUG ((DEBUG_INFO, "buildhob: base = 0x%lx, size = 0x%lx, type = 0x%x\n", Base, Size, Type));
if (MemoryMapEntry->Type == E820_UNUSABLE || if ((MemoryMapEntry->Type == E820_UNUSABLE) ||
MemoryMapEntry->Type == E820_DISABLED) { (MemoryMapEntry->Type == E820_DISABLED))
{
BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory); BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory);
} else if (MemoryMapEntry->Type == E820_PMEM) { } else if (MemoryMapEntry->Type == E820_PMEM) {
BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory); BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory);
@ -89,7 +90,6 @@ MemInfoCallbackMmio (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Callback function to find TOLUD (Top of Lower Usable DRAM) Callback function to find TOLUD (Top of Lower Usable DRAM)
@ -120,7 +120,8 @@ FindToludCallback (
// Skip memory types not RAM or reserved // Skip memory types not RAM or reserved
// //
if ((MemoryMapEntry->Type == E820_UNUSABLE) || (MemoryMapEntry->Type == E820_DISABLED) || if ((MemoryMapEntry->Type == E820_UNUSABLE) || (MemoryMapEntry->Type == E820_DISABLED) ||
(MemoryMapEntry->Type == E820_PMEM)) { (MemoryMapEntry->Type == E820_PMEM))
{
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -132,7 +133,8 @@ FindToludCallback (
} }
if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI) || if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI) ||
(MemoryMapEntry->Type == E820_NVS)) { (MemoryMapEntry->Type == E820_NVS))
{
// //
// It's usable DRAM. Update TOLUD. // It's usable DRAM. Update TOLUD.
// //
@ -154,7 +156,6 @@ FindToludCallback (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
Callback function to build resource descriptor HOB Callback function to build resource descriptor HOB
@ -182,7 +183,8 @@ MemInfoCallback (
// It will be added later. // It will be added later.
// //
if ((MemoryMapEntry->Type != E820_RAM) && (MemoryMapEntry->Type != E820_ACPI) && if ((MemoryMapEntry->Type != E820_RAM) && (MemoryMapEntry->Type != E820_ACPI) &&
(MemoryMapEntry->Type != E820_NVS)) { (MemoryMapEntry->Type != E820_NVS))
{
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
@ -210,8 +212,6 @@ MemInfoCallback (
return RETURN_SUCCESS; return RETURN_SUCCESS;
} }
/** /**
It will build HOBs based on information from bootloaders. It will build HOBs based on information from bootloaders.
@ -240,6 +240,7 @@ BuildHobFromBl (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
DEBUG ((DEBUG_INFO, "Assuming TOLUD = 0x%x\n", mTopOfLowerUsableDram)); DEBUG ((DEBUG_INFO, "Assuming TOLUD = 0x%x\n", mTopOfLowerUsableDram));
// //
@ -262,7 +263,6 @@ BuildHobFromBl (
DEBUG ((DEBUG_INFO, "Created graphics info hob\n")); DEBUG ((DEBUG_INFO, "Created graphics info hob\n"));
} }
Status = ParseGfxDeviceInfo (&GfxDeviceInfo); Status = ParseGfxDeviceInfo (&GfxDeviceInfo);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
NewGfxDeviceInfo = BuildGuidHob (&gEfiGraphicsDeviceInfoHobGuid, sizeof (GfxDeviceInfo)); NewGfxDeviceInfo = BuildGuidHob (&gEfiGraphicsDeviceInfoHobGuid, sizeof (GfxDeviceInfo));
@ -271,7 +271,6 @@ BuildHobFromBl (
DEBUG ((DEBUG_INFO, "Created graphics device info hob\n")); DEBUG ((DEBUG_INFO, "Created graphics device info hob\n"));
} }
// //
// Creat SmBios table Hob // Creat SmBios table Hob
// //
@ -333,7 +332,6 @@ BuildHobFromBl (
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/** /**
This function will build some generic HOBs that doesn't depend on information from bootloaders. This function will build some generic HOBs that doesn't depend on information from bootloaders.
@ -374,10 +372,8 @@ BuildGenericHob (
); );
BuildResourceDescriptorHob (EFI_RESOURCE_MEMORY_MAPPED_IO, ResourceAttribute, 0xFEC80000, SIZE_512KB); BuildResourceDescriptorHob (EFI_RESOURCE_MEMORY_MAPPED_IO, ResourceAttribute, 0xFEC80000, SIZE_512KB);
BuildMemoryAllocationHob (0xFEC80000, SIZE_512KB, EfiMemoryMappedIO); BuildMemoryAllocationHob (0xFEC80000, SIZE_512KB, EfiMemoryMappedIO);
} }
/** /**
Entry point to the C language phase of UEFI payload. Entry point to the C language phase of UEFI payload.

View File

@ -42,7 +42,6 @@
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \ #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))) ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
#define E820_RAM 1 #define E820_RAM 1
#define E820_RESERVED 2 #define E820_RESERVED 2
#define E820_ACPI 3 #define E820_ACPI 3

View File

@ -67,6 +67,7 @@ FixUpPcdDatabase (
// //
return EFI_SUCCESS; return EFI_SUCCESS;
} }
PeiDatabase = (PEI_PCD_DATABASE *)GET_GUID_HOB_DATA (GuidHob); PeiDatabase = (PEI_PCD_DATABASE *)GET_GUID_HOB_DATA (GuidHob);
DEBUG ((DEBUG_INFO, "Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount)); DEBUG ((DEBUG_INFO, "Find the Pei PCD data base, the total local token number is %d\n", PeiDatabase->LocalTokenCount));
@ -75,6 +76,7 @@ FixUpPcdDatabase (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData); Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
@ -87,6 +89,7 @@ FixUpPcdDatabase (
for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) { for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount; ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
} }
DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n")); DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n"));
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -106,6 +109,7 @@ AddNewHob (
if (Hob->Raw == NULL) { if (Hob->Raw == NULL) {
return; return;
} }
NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength); NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
if (NewHob.Header != NULL) { if (NewHob.Header != NULL) {
@ -147,6 +151,7 @@ FindResourceDescriptorByRange (
if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) { if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
continue; continue;
} }
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) { if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
continue; continue;
} }
@ -157,11 +162,14 @@ FindResourceDescriptorByRange (
if (Base < ResourceHob->PhysicalStart) { if (Base < ResourceHob->PhysicalStart) {
continue; continue;
} }
if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) { if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
continue; continue;
} }
return ResourceHob; return ResourceHob;
} }
return NULL; return NULL;
} }
@ -184,6 +192,7 @@ FindAnotherHighestBelow4GResourceDescriptor (
EFI_PEI_HOB_POINTERS Hob; EFI_PEI_HOB_POINTERS Hob;
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob; EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob; EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob;
ReturnResourceHob = NULL; ReturnResourceHob = NULL;
for (Hob.Raw = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) { for (Hob.Raw = (UINT8 *)HobList; !END_OF_HOB_LIST (Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
@ -201,6 +210,7 @@ FindAnotherHighestBelow4GResourceDescriptor (
if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) { if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
continue; continue;
} }
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) { if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
continue; continue;
} }
@ -211,12 +221,14 @@ FindAnotherHighestBelow4GResourceDescriptor (
if (ResourceHob == ExceptResourceHob) { if (ResourceHob == ExceptResourceHob) {
continue; continue;
} }
// //
// Skip Resource Descriptor HOBs that are beyond 4G // Skip Resource Descriptor HOBs that are beyond 4G
// //
if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_4GB) { if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_4GB) {
continue; continue;
} }
// //
// Skip Resource Descriptor HOBs that are too small // Skip Resource Descriptor HOBs that are too small
// //
@ -235,6 +247,7 @@ FindAnotherHighestBelow4GResourceDescriptor (
} }
} }
} }
return ReturnResourceHob; return ReturnResourceHob;
} }
@ -276,7 +289,6 @@ BuildHobs (
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryBottom == Hob.HandoffInformationTable->EfiFreeMemoryBottom); ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryBottom == Hob.HandoffInformationTable->EfiFreeMemoryBottom);
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryBottom == Hob.HandoffInformationTable->EfiMemoryBottom); ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryBottom == Hob.HandoffInformationTable->EfiMemoryBottom);
// //
// Try to find Resource Descriptor HOB that contains Hob range EfiMemoryBottom..EfiMemoryTop // Try to find Resource Descriptor HOB that contains Hob range EfiMemoryBottom..EfiMemoryTop
// //
@ -325,6 +337,7 @@ BuildHobs (
FreeMemoryTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength; FreeMemoryTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength;
MemoryTop = FreeMemoryTop; MemoryTop = FreeMemoryTop;
} }
HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMemoryTop); HobConstructor ((VOID *)(UINTN)MemoryBottom, (VOID *)(UINTN)MemoryTop, (VOID *)(UINTN)FreeMemoryBottom, (VOID *)(UINTN)FreeMemoryTop);
// //
// From now on, mHobList will point to the new Hob range. // From now on, mHobList will point to the new Hob range.
@ -342,6 +355,7 @@ BuildHobs (
// Add this hob to payload HOB // Add this hob to payload HOB
AddNewHob (&Hob); AddNewHob (&Hob);
} }
Hob.Raw = GET_NEXT_HOB (Hob); Hob.Raw = GET_NEXT_HOB (Hob);
} }

View File

@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "UefiPayloadEntry.h" #include "UefiPayloadEntry.h"
#define STACK_SIZE 0x20000 #define STACK_SIZE 0x20000
/** /**
Transfers control to DxeCore. Transfers control to DxeCore.
@ -49,7 +48,6 @@ HandOffToDxeCore (
BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData); BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData);
} }
// //
// Allocate 128KB for the Stack // Allocate 128KB for the Stack
// //
@ -74,8 +72,12 @@ HandOffToDxeCore (
// //
// Create page table and save PageMapLevel4 to CR3 // Create page table and save PageMapLevel4 to CR3
// //
PageTables = CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE, PageTables = CreateIdentityMappingPageTables (
(EFI_PHYSICAL_ADDRESS) (UINTN) GhcbBase, GhcbSize); (EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack,
STACK_SIZE,
(EFI_PHYSICAL_ADDRESS)(UINTN)GhcbBase,
GhcbSize
);
} else { } else {
// //
// Set NX for stack feature also require PcdDxeIplBuildPageTables be TRUE // Set NX for stack feature also require PcdDxeIplBuildPageTables be TRUE
@ -85,7 +87,6 @@ HandOffToDxeCore (
ASSERT (PcdGetBool (PcdCpuStackGuard) == FALSE); ASSERT (PcdGetBool (PcdCpuStackGuard) == FALSE);
} }
if (FeaturePcdGet (PcdDxeIplBuildPageTables)) { if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {
AsmWriteCr3 (PageTables); AsmWriteCr3 (PageTables);
} }

View File

@ -62,25 +62,36 @@ ClearFirst4KPage (
// //
// Check if page 0 exists and free // Check if page 0 exists and free
// //
while ((RscHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, while ((RscHob.Raw = GetNextHob (
RscHob.Raw)) != NULL) { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,
if (RscHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY && RscHob.Raw
RscHob.ResourceDescriptor->PhysicalStart == 0) { )) != NULL)
{
if ((RscHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) &&
(RscHob.ResourceDescriptor->PhysicalStart == 0))
{
DoClear = TRUE; DoClear = TRUE;
// //
// Make sure memory at 0-4095 has not been allocated. // Make sure memory at 0-4095 has not been allocated.
// //
while ((MemHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, while ((MemHob.Raw = GetNextHob (
MemHob.Raw)) != NULL) { EFI_HOB_TYPE_MEMORY_ALLOCATION,
MemHob.Raw
)) != NULL)
{
if (MemHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress if (MemHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress
< EFI_PAGE_SIZE) { < EFI_PAGE_SIZE)
{
DoClear = FALSE; DoClear = FALSE;
break; break;
} }
MemHob.Raw = GET_NEXT_HOB (MemHob); MemHob.Raw = GET_NEXT_HOB (MemHob);
} }
break; break;
} }
RscHob.Raw = GET_NEXT_HOB (RscHob); RscHob.Raw = GET_NEXT_HOB (RscHob);
} }
@ -203,12 +214,12 @@ ToSplitPageTable (
IN UINTN GhcbSize IN UINTN GhcbSize
) )
{ {
if (IsNullDetectionEnabled () && Address == 0) { if (IsNullDetectionEnabled () && (Address == 0)) {
return TRUE; return TRUE;
} }
if (PcdGetBool (PcdCpuStackGuard)) { if (PcdGetBool (PcdCpuStackGuard)) {
if (StackBase >= Address && StackBase < (Address + Size)) { if ((StackBase >= Address) && (StackBase < (Address + Size))) {
return TRUE; return TRUE;
} }
} }
@ -227,6 +238,7 @@ ToSplitPageTable (
return FALSE; return FALSE;
} }
/** /**
Initialize a buffer pool for page table use only. Initialize a buffer pool for page table use only.
@ -316,8 +328,9 @@ AllocatePageTableMemory (
// //
// Renew the pool if necessary. // Renew the pool if necessary.
// //
if (mPageTablePool == NULL || if ((mPageTablePool == NULL) ||
Pages > mPageTablePool->FreePages) { (Pages > mPageTablePool->FreePages))
{
if (!InitializePageTablePool (Pages)) { if (!InitializePageTablePool (Pages)) {
return NULL; return NULL;
} }
@ -386,13 +399,16 @@ Split2MPageTo4K (
if ( (GhcbBase == 0) if ( (GhcbBase == 0)
|| (PhysicalAddress4K < GhcbBase) || (PhysicalAddress4K < GhcbBase)
|| (PhysicalAddress4K >= GhcbBase + GhcbSize) || (PhysicalAddress4K >= GhcbBase + GhcbSize)
|| (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) != 0)) { || (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) != 0))
{
PageTableEntry->Uint64 |= AddressEncMask; PageTableEntry->Uint64 |= AddressEncMask;
} }
PageTableEntry->Bits.ReadWrite = 1; PageTableEntry->Bits.ReadWrite = 1;
if ((IsNullDetectionEnabled () && PhysicalAddress4K == 0) || if ((IsNullDetectionEnabled () && (PhysicalAddress4K == 0)) ||
(PcdGetBool (PcdCpuStackGuard) && PhysicalAddress4K == StackBase)) { (PcdGetBool (PcdCpuStackGuard) && (PhysicalAddress4K == StackBase)))
{
PageTableEntry->Bits.Present = 0; PageTableEntry->Bits.Present = 0;
} else { } else {
PageTableEntry->Bits.Present = 1; PageTableEntry->Bits.Present = 1;
@ -400,7 +416,8 @@ Split2MPageTo4K (
if ( PcdGetBool (PcdSetNxForStack) if ( PcdGetBool (PcdSetNxForStack)
&& (PhysicalAddress4K >= StackBase) && (PhysicalAddress4K >= StackBase)
&& (PhysicalAddress4K < StackBase + StackSize)) { && (PhysicalAddress4K < StackBase + StackSize))
{
// //
// Set Nx bit for stack. // Set Nx bit for stack.
// //
@ -560,7 +577,6 @@ SetPageTablePoolReadOnly (
} }
break; break;
} else { } else {
// //
// The smaller granularity of page must be needed. // The smaller granularity of page must be needed.
@ -573,12 +589,14 @@ SetPageTablePoolReadOnly (
PhysicalAddress = PageAttr & LevelMask[Level]; PhysicalAddress = PageAttr & LevelMask[Level];
for (EntryIndex = 0; for (EntryIndex = 0;
EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64); EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64);
++EntryIndex) { ++EntryIndex)
{
NewPageTable[EntryIndex] = PhysicalAddress | AddressEncMask | NewPageTable[EntryIndex] = PhysicalAddress | AddressEncMask |
IA32_PG_P | IA32_PG_RW; IA32_PG_P | IA32_PG_RW;
if (Level > 2) { if (Level > 2) {
NewPageTable[EntryIndex] |= IA32_PG_PS; NewPageTable[EntryIndex] |= IA32_PG_PS;
} }
PhysicalAddress += LevelSize[Level - 1]; PhysicalAddress += LevelSize[Level - 1];
} }
@ -733,8 +751,12 @@ CreateIdentityMappingPageTables (
Page5LevelSupport = FALSE; Page5LevelSupport = FALSE;
if (PcdGetBool (PcdUse5LevelPageTable)) { if (PcdGetBool (PcdUse5LevelPageTable)) {
AsmCpuidEx ( AsmCpuidEx (
CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, NULL, CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,
&EcxFlags.Uint32, NULL, NULL CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,
NULL,
&EcxFlags.Uint32,
NULL,
NULL
); );
if (EcxFlags.Bits.FiveLevelPage != 0) { if (EcxFlags.Bits.FiveLevelPage != 0) {
Page5LevelSupport = TRUE; Page5LevelSupport = TRUE;
@ -749,7 +771,7 @@ CreateIdentityMappingPageTables (
// due to either unsupported by HW, or disabled by PCD. // due to either unsupported by HW, or disabled by PCD.
// //
ASSERT (PhysicalAddressBits <= 52); ASSERT (PhysicalAddressBits <= 52);
if (!Page5LevelSupport && PhysicalAddressBits > 48) { if (!Page5LevelSupport && (PhysicalAddressBits > 48)) {
PhysicalAddressBits = 48; PhysicalAddressBits = 48;
} }
@ -788,9 +810,14 @@ CreateIdentityMappingPageTables (
TotalPagesNum--; TotalPagesNum--;
} }
DEBUG ((DEBUG_INFO, "Pml5=%u Pml4=%u Pdp=%u TotalPage=%Lu\n", DEBUG ((
NumberOfPml5EntriesNeeded, NumberOfPml4EntriesNeeded, DEBUG_INFO,
NumberOfPdpEntriesNeeded, (UINT64)TotalPagesNum)); "Pml5=%u Pml4=%u Pdp=%u TotalPage=%Lu\n",
NumberOfPml5EntriesNeeded,
NumberOfPml4EntriesNeeded,
NumberOfPdpEntriesNeeded,
(UINT64)TotalPagesNum
));
BigPageAddress = (UINTN)AllocatePageTableMemory (TotalPagesNum); BigPageAddress = (UINTN)AllocatePageTableMemory (TotalPagesNum);
ASSERT (BigPageAddress != 0); ASSERT (BigPageAddress != 0);
@ -806,11 +833,13 @@ CreateIdentityMappingPageTables (
PageMapLevel5Entry = PageMap; PageMapLevel5Entry = PageMap;
BigPageAddress += SIZE_4KB; BigPageAddress += SIZE_4KB;
} }
PageAddress = 0; PageAddress = 0;
for ( IndexOfPml5Entries = 0 for ( IndexOfPml5Entries = 0
; IndexOfPml5Entries < NumberOfPml5EntriesNeeded ; IndexOfPml5Entries < NumberOfPml5EntriesNeeded
; IndexOfPml5Entries++) { ; IndexOfPml5Entries++)
{
// //
// Each PML5 entry points to a page of PML4 entires. // Each PML5 entry points to a page of PML4 entires.
// So lets allocate space for them and fill them in in the IndexOfPml4Entries loop. // So lets allocate space for them and fill them in in the IndexOfPml4Entries loop.
@ -831,7 +860,8 @@ CreateIdentityMappingPageTables (
for ( IndexOfPml4Entries = 0 for ( IndexOfPml4Entries = 0
; IndexOfPml4Entries < (NumberOfPml5EntriesNeeded == 1 ? NumberOfPml4EntriesNeeded : 512) ; IndexOfPml4Entries < (NumberOfPml5EntriesNeeded == 1 ? NumberOfPml4EntriesNeeded : 512)
; IndexOfPml4Entries++, PageMapLevel4Entry++) { ; IndexOfPml4Entries++, PageMapLevel4Entry++)
{
// //
// Each PML4 entry points to a page of Page Directory Pointer entires. // Each PML4 entry points to a page of Page Directory Pointer entires.
// So lets allocate space for them and fill them in in the IndexOfPdpEntries loop. // So lets allocate space for them and fill them in in the IndexOfPdpEntries loop.
@ -865,7 +895,8 @@ CreateIdentityMappingPageTables (
} else { } else {
for ( IndexOfPdpEntries = 0 for ( IndexOfPdpEntries = 0
; IndexOfPdpEntries < (NumberOfPml4EntriesNeeded == 1 ? NumberOfPdpEntriesNeeded : 512) ; IndexOfPdpEntries < (NumberOfPml4EntriesNeeded == 1 ? NumberOfPdpEntriesNeeded : 512)
; IndexOfPdpEntries++, PageDirectoryPointerEntry++) { ; IndexOfPdpEntries++, PageDirectoryPointerEntry++)
{
// //
// Each Directory Pointer entries points to a page of Page Directory entires. // Each Directory Pointer entries points to a page of Page Directory entires.
// So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop. // So allocate space for them and fill them in in the IndexOfPageDirectoryEntries loop.
@ -936,4 +967,3 @@ CreateIdentityMappingPageTables (
return (UINTN)PageMap; return (UINTN)PageMap;
} }

View File

@ -13,13 +13,12 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#ifndef _VIRTUAL_MEMORY_H_ #ifndef _VIRTUAL_MEMORY_H_
#define _VIRTUAL_MEMORY_H_ #define _VIRTUAL_MEMORY_H_
#define SYS_CODE64_SEL 0x38 #define SYS_CODE64_SEL 0x38
#pragma pack(1) #pragma pack(1)
typedef union { typedef union {
@ -235,7 +234,6 @@ CreateIdentityMappingPageTables (
IN UINTN GhcbkSize IN UINTN GhcbkSize
); );
/** /**
Fix up the vector number in the vector code. Fix up the vector number in the vector code.
@ -251,7 +249,6 @@ AsmVectorFixup (
UINT8 VectorNum UINT8 VectorNum
); );
/** /**
Get the information of vector template. Get the information of vector template.