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:
committed by
mergify[bot]
parent
053e878bfb
commit
e5efcf8be8
@ -47,6 +47,7 @@ ReserveResourceInGcd (
|
||||
Length
|
||||
));
|
||||
}
|
||||
|
||||
Status = gDS->AllocateMemorySpace (
|
||||
EfiGcdAllocateAddress,
|
||||
GcdType,
|
||||
@ -70,6 +71,7 @@ ReserveResourceInGcd (
|
||||
Length
|
||||
));
|
||||
}
|
||||
|
||||
Status = gDS->AllocateIoSpace (
|
||||
EfiGcdAllocateAddress,
|
||||
GcdType,
|
||||
@ -80,10 +82,10 @@ ReserveResourceInGcd (
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Main entry for the bootloader support DXE module.
|
||||
|
||||
@ -144,4 +146,3 @@ BlDxeEntryPoint (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __DXE_BOOTLOADER_SUPPORT_H__
|
||||
#define __DXE_BOOTLOADER_SUPPORT_H__
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
PLD_S3_COMMUNICATION mPldS3Hob;
|
||||
EFI_SMRAM_HOB_DESCRIPTOR_BLOCK *mSmramHob = NULL;
|
||||
PLD_SMM_REGISTERS *mSmmRegisterHob = NULL;;
|
||||
PLD_SMM_REGISTERS *mSmmRegisterHob = NULL;
|
||||
UINT64 mSmmFeatureControl = 0;
|
||||
|
||||
/**
|
||||
@ -47,10 +47,12 @@ SaveSmmInfoForS3 (
|
||||
PldSmmInfo->Header.Header.HobLength = (UINT16)(sizeof (PLD_TO_BL_SMM_INFO) + gSmst->NumberOfCpus * sizeof (CPU_SMMBASE));
|
||||
for (Index = 0; Index < mSmramHob->NumberOfSmmReservedRegions; Index++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == mSmramHob->NumberOfSmmReservedRegions) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -76,14 +78,15 @@ SaveSmmInfoForS3 (
|
||||
// Save APIC ID and SMM base
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
PldSmmInfo->S3Info.CpuCount = (UINT32)gSmst->NumberOfCpus;
|
||||
SmmBaseInfo = &PldSmmInfo->S3Info.SmmBase[0];
|
||||
for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {
|
||||
Status = MpService->GetProcessorInfo (MpService, Index, &ProcessorInfo);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -96,7 +99,6 @@ SaveSmmInfoForS3 (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get specified SMI register based on given register ID
|
||||
|
||||
@ -118,6 +120,7 @@ GetRegisterById (
|
||||
return &mSmmRegisterHob->Registers[Index];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -147,7 +150,8 @@ LockSmiGlobalEn (
|
||||
(SmiLockReg->Address.Address != 0) &&
|
||||
(SmiLockReg->Address.RegisterBitWidth == 1) &&
|
||||
(SmiLockReg->Address.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) &&
|
||||
(SmiLockReg->Value == 1)) {
|
||||
(SmiLockReg->Value == 1))
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, "LockSmiGlobalEn ....is locked\n"));
|
||||
|
||||
MmioOr32 ((UINT32)SmiLockReg->Address.Address, 1 << SmiLockReg->Address.RegisterBitOffset);
|
||||
@ -166,23 +170,21 @@ SmmFeatureLockOnS3 (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
|
||||
if (mSmmFeatureControl != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSmmFeatureControl = AsmReadMsr64(MSR_SMM_FEATURE_CONTROL);
|
||||
mSmmFeatureControl = AsmReadMsr64 (MSR_SMM_FEATURE_CONTROL);
|
||||
if ((mSmmFeatureControl & 0x5) != 0x5) {
|
||||
//
|
||||
// Set Lock bit [BIT0] for this register and SMM code check enable bit [BIT2]
|
||||
//
|
||||
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.
|
||||
|
||||
@ -224,18 +226,19 @@ SetSmrrOnS3 (
|
||||
DEBUG ((DEBUG_ERROR, "%d SMM ranges are not supported.\n", mSmramHob->NumberOfSmmReservedRegions));
|
||||
return;
|
||||
} else if (mSmramHob->NumberOfSmmReservedRegions == 2) {
|
||||
if ((mSmramHob->Descriptor[1].PhysicalStart + mSmramHob->Descriptor[1].PhysicalSize) == SmmBase){
|
||||
if ((mSmramHob->Descriptor[1].PhysicalStart + mSmramHob->Descriptor[1].PhysicalSize) == SmmBase) {
|
||||
SmmBase = (UINT32)(UINTN)mSmramHob->Descriptor[1].PhysicalStart;
|
||||
} else if (mSmramHob->Descriptor[1].PhysicalStart != (SmmBase + SmmSize)) {
|
||||
DEBUG ((DEBUG_ERROR, "Two SMM regions are not continous.\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
SmmSize += (UINT32)(UINTN)mSmramHob->Descriptor[1].PhysicalSize;
|
||||
}
|
||||
|
||||
if ((SmmBase == 0) || (SmmSize < SIZE_4KB)) {
|
||||
DEBUG ((DEBUG_ERROR, "Invalid SMM range.\n"));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -244,7 +247,7 @@ SetSmrrOnS3 (
|
||||
//
|
||||
if ((SmmSize != GetPowerOfTwo32 (SmmSize)) || ((SmmBase & ~(SmmSize - 1)) != SmmBase)) {
|
||||
DEBUG ((DEBUG_ERROR, " Invalid SMM range.\n"));
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@ -261,18 +264,17 @@ SetSmrrOnS3 (
|
||||
//
|
||||
// Program smrr base and mask on BSP first and then on APs
|
||||
//
|
||||
SetSmrr(&Arguments);
|
||||
SetSmrr (&Arguments);
|
||||
for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {
|
||||
if (Index != gSmst->CurrentlyExecutingCpu) {
|
||||
Status = gSmst->SmmStartupThisAp (SetSmrr, Index, (VOID *)&Arguments);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Programming SMRR on AP# %d status: %r\n", Index, Status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Software SMI callback for restoring SMRR base and mask in S3 path.
|
||||
|
||||
@ -302,7 +304,6 @@ BlSwSmiHandler (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Lock SMI in this SMM ready to lock event.
|
||||
|
||||
@ -328,7 +329,6 @@ BlSupportSmmReadyToLockCallback (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The driver's entry point.
|
||||
|
||||
@ -359,8 +359,8 @@ BlSupportSmm (
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gS3CommunicationGuid);
|
||||
if (GuidHob != NULL) {
|
||||
SmmHob = (VOID *) (GET_GUID_HOB_DATA(GuidHob));
|
||||
CopyMem (&mPldS3Hob, SmmHob, GET_GUID_HOB_DATA_SIZE(GuidHob));
|
||||
SmmHob = (VOID *)(GET_GUID_HOB_DATA (GuidHob));
|
||||
CopyMem (&mPldS3Hob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob));
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -375,12 +375,13 @@ BlSupportSmm (
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gEfiSmmSmramMemoryGuid);
|
||||
if (GuidHob != NULL) {
|
||||
SmmHob = (VOID *) (GET_GUID_HOB_DATA(GuidHob));
|
||||
mSmramHob = AllocatePool (GET_GUID_HOB_DATA_SIZE(GuidHob));
|
||||
SmmHob = (VOID *)(GET_GUID_HOB_DATA (GuidHob));
|
||||
mSmramHob = AllocatePool (GET_GUID_HOB_DATA_SIZE (GuidHob));
|
||||
if (mSmramHob == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem (mSmramHob, SmmHob, GET_GUID_HOB_DATA_SIZE(GuidHob));
|
||||
|
||||
CopyMem (mSmramHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob));
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -390,12 +391,13 @@ BlSupportSmm (
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gSmmRegisterInfoGuid);
|
||||
if (GuidHob != NULL) {
|
||||
SmmHob = (VOID *) (GET_GUID_HOB_DATA(GuidHob));
|
||||
mSmmRegisterHob = AllocatePool (GET_GUID_HOB_DATA_SIZE(GuidHob));
|
||||
SmmHob = (VOID *)(GET_GUID_HOB_DATA (GuidHob));
|
||||
mSmmRegisterHob = AllocatePool (GET_GUID_HOB_DATA_SIZE (GuidHob));
|
||||
if (mSmmRegisterHob == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
CopyMem (mSmmRegisterHob, SmmHob, GET_GUID_HOB_DATA_SIZE(GuidHob));
|
||||
|
||||
CopyMem (mSmmRegisterHob, SmmHob, GET_GUID_HOB_DATA_SIZE (GuidHob));
|
||||
} else {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -403,11 +405,12 @@ BlSupportSmm (
|
||||
//
|
||||
// Get the Sw dispatch protocol and register SMI handler.
|
||||
//
|
||||
Status = gSmst->SmmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid, NULL, (VOID**)&SwDispatch);
|
||||
Status = gSmst->SmmLocateProtocol (&gEfiSmmSwDispatch2ProtocolGuid, NULL, (VOID **)&SwDispatch);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
SwContext.SwSmiInputValue = (UINTN) -1;
|
||||
|
||||
SwContext.SwSmiInputValue = (UINTN)-1;
|
||||
Status = SwDispatch->Register (SwDispatch, BlSwSmiHandler, &SwContext, &SwHandle);
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_ERROR, "Registering S3 smi handler failed: %r\n", Status));
|
||||
@ -428,4 +431,3 @@ BlSupportSmm (
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef BL_SUPPORT_SMM_H_
|
||||
#define BL_SUPPORT_SMM_H_
|
||||
|
||||
@ -38,4 +39,3 @@ typedef struct {
|
||||
} SMRR_BASE_MASK;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -28,7 +28,7 @@ typedef struct {
|
||||
//
|
||||
EFI_FVB2_MEDIA_INFO mFvbMediaInfo = {
|
||||
{
|
||||
{0,}, // ZeroVector[16]
|
||||
{ 0, }, // ZeroVector[16]
|
||||
EFI_SYSTEM_NV_DATA_FV_GUID,
|
||||
0,
|
||||
EFI_FVH_SIGNATURE,
|
||||
@ -36,7 +36,7 @@ EFI_FVB2_MEDIA_INFO mFvbMediaInfo = {
|
||||
sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
|
||||
0, // CheckSum which will be calucated dynamically.
|
||||
0, // ExtHeaderOffset
|
||||
{0,},
|
||||
{ 0, },
|
||||
EFI_FVH_REVISION,
|
||||
{
|
||||
{
|
||||
@ -81,7 +81,8 @@ InitVariableStore (
|
||||
ASSERT (FALSE);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
NvVariableInfo = (NV_VARIABLE_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
NvVariableInfo = (NV_VARIABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
//
|
||||
// Get variable region base and size.
|
||||
@ -104,27 +105,27 @@ InitVariableStore (
|
||||
if (NvVariableSize >= 0x80000000) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
Status = PcdSet32S(PcdFlashNvStorageVariableSize, NvVariableSize);
|
||||
|
||||
Status = PcdSet32S (PcdFlashNvStorageVariableSize, NvVariableSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageVariableBase, NvStorageBase);
|
||||
Status = PcdSet32S (PcdFlashNvStorageVariableBase, NvStorageBase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet64S(PcdFlashNvStorageVariableBase64, NvStorageBase);
|
||||
Status = PcdSet64S (PcdFlashNvStorageVariableBase64, NvStorageBase);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwWorkingSize, FtwWorkingSize);
|
||||
Status = PcdSet32S (PcdFlashNvStorageFtwWorkingSize, FtwWorkingSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwWorkingBase, NvStorageBase + NvVariableSize);
|
||||
Status = PcdSet32S (PcdFlashNvStorageFtwWorkingBase, NvStorageBase + NvVariableSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwSpareSize, FtwSpareSize);
|
||||
Status = PcdSet32S (PcdFlashNvStorageFtwSpareSize, FtwSpareSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
Status = PcdSet32S(PcdFlashNvStorageFtwSpareBase, NvStorageBase + FtwSpareSize);
|
||||
Status = PcdSet32S (PcdFlashNvStorageFtwSpareBase, NvStorageBase + FtwSpareSize);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get a heathy FV header used for variable store recovery
|
||||
|
||||
@ -139,13 +140,12 @@ GetFvHeaderTemplate (
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
|
||||
UINTN FvSize;
|
||||
|
||||
FvSize = PcdGet32(PcdFlashNvStorageFtwSpareSize) * 2;
|
||||
FvSize = PcdGet32 (PcdFlashNvStorageFtwSpareSize) * 2;
|
||||
FvHeader = &mFvbMediaInfo.FvInfo;
|
||||
FvHeader->FvLength = FvSize;
|
||||
FvHeader->BlockMap[0].NumBlocks = (UINT32) (FvSize / FvHeader->BlockMap[0].Length);
|
||||
FvHeader->BlockMap[0].NumBlocks = (UINT32)(FvSize / FvHeader->BlockMap[0].Length);
|
||||
FvHeader->Checksum = 0;
|
||||
FvHeader->Checksum = CalculateCheckSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength);
|
||||
FvHeader->Checksum = CalculateCheckSum16 ((UINT16 *)FvHeader, FvHeader->HeaderLength);
|
||||
|
||||
return FvHeader;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
|
||||
}
|
||||
},
|
||||
EfiMemoryMappedIO,
|
||||
(EFI_PHYSICAL_ADDRESS) 0,
|
||||
(EFI_PHYSICAL_ADDRESS) 0,
|
||||
(EFI_PHYSICAL_ADDRESS)0,
|
||||
(EFI_PHYSICAL_ADDRESS)0,
|
||||
},
|
||||
{
|
||||
END_DEVICE_PATH_TYPE,
|
||||
@ -60,7 +60,6 @@ FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
|
||||
FVB_DEVICE_SIGNATURE,
|
||||
NULL,
|
||||
@ -77,7 +76,6 @@ EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
|
||||
} // FwVolBlockInstance
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed
|
||||
by mFvbModuleGlobal.FvInstance based on a index.
|
||||
@ -106,17 +104,15 @@ GetFvbInstance (
|
||||
//
|
||||
FwhRecord = mFvbModuleGlobal.FvInstance;
|
||||
while ( Instance > 0 ) {
|
||||
FwhRecord = (EFI_FW_VOL_INSTANCE *) ((UINTN)((UINT8 *)FwhRecord) +
|
||||
FwhRecord = (EFI_FW_VOL_INSTANCE *)((UINTN)((UINT8 *)FwhRecord) +
|
||||
FwhRecord->VolumeHeader.HeaderLength +
|
||||
(sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER)));
|
||||
Instance--;
|
||||
}
|
||||
|
||||
return FwhRecord;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the EFI_FVB_ATTRIBUTES_2 of a FV.
|
||||
|
||||
@ -131,8 +127,9 @@ FvbGetVolumeAttributes (
|
||||
IN UINTN Instance
|
||||
)
|
||||
{
|
||||
EFI_FW_VOL_INSTANCE * FwInstance;
|
||||
FwInstance = GetFvbInstance(Instance);
|
||||
EFI_FW_VOL_INSTANCE *FwInstance;
|
||||
|
||||
FwInstance = GetFvbInstance (Instance);
|
||||
ASSERT (FwInstance != NULL);
|
||||
|
||||
if (FwInstance == NULL) {
|
||||
@ -142,8 +139,6 @@ FvbGetVolumeAttributes (
|
||||
return FwInstance->VolumeHeader.Attributes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the starting address of an LBA in an FV. It also
|
||||
return a few other attribut of the FV.
|
||||
@ -202,7 +197,7 @@ FvbGetLbaAddress (
|
||||
BlockLength = BlockMap->Length;
|
||||
}
|
||||
|
||||
if ( NumBlocks == 0 || BlockLength == 0) {
|
||||
if ((NumBlocks == 0) || (BlockLength == 0)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -211,8 +206,8 @@ FvbGetLbaAddress (
|
||||
//
|
||||
// The map entry found
|
||||
//
|
||||
if (Lba >= StartLba && Lba < NextLba) {
|
||||
Offset = Offset + (UINTN)MultU64x32((Lba - StartLba), BlockLength);
|
||||
if ((Lba >= StartLba) && (Lba < NextLba)) {
|
||||
Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
|
||||
if (LbaAddress != NULL) {
|
||||
*LbaAddress = FwhInstance->FvBase + Offset;
|
||||
}
|
||||
@ -224,6 +219,7 @@ FvbGetLbaAddress (
|
||||
if (NumOfBlocks != NULL) {
|
||||
*NumOfBlocks = (UINTN)(NextLba - Lba);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -233,7 +229,6 @@ FvbGetLbaAddress (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Reads specified number of bytes into a buffer from the specified block
|
||||
|
||||
@ -274,21 +269,22 @@ FvbReadBlock (
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS ReadStatus;
|
||||
|
||||
if ( (NumBytes == NULL) || (Buffer == NULL)) {
|
||||
if ((NumBytes == NULL) || (Buffer == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (*NumBytes == 0) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Attributes = FvbGetVolumeAttributes (Instance);
|
||||
|
||||
if ( (Attributes & EFI_FVB2_READ_STATUS) == 0) {
|
||||
if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {
|
||||
return (EFI_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
@ -296,20 +292,19 @@ FvbReadBlock (
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (LbaLength < ( *NumBytes + BlockOffset ) ) {
|
||||
*NumBytes = (UINT32) (LbaLength - BlockOffset);
|
||||
if (LbaLength < (*NumBytes + BlockOffset)) {
|
||||
*NumBytes = (UINT32)(LbaLength - BlockOffset);
|
||||
Status = EFI_BAD_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
ReadStatus = LibFvbFlashDeviceRead (LbaAddress + BlockOffset, NumBytes, Buffer);
|
||||
if (EFI_ERROR(ReadStatus)) {
|
||||
if (EFI_ERROR (ReadStatus)) {
|
||||
return ReadStatus;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Writes specified number of bytes from the input buffer to the block
|
||||
|
||||
@ -345,15 +340,16 @@ FvbWriteBlock (
|
||||
UINTN LbaLength;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ( (NumBytes == NULL) || (Buffer == NULL)) {
|
||||
if ((NumBytes == NULL) || (Buffer == NULL)) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
if (*NumBytes == 0) {
|
||||
return (EFI_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -361,7 +357,7 @@ FvbWriteBlock (
|
||||
// Check if the FV is write enabled
|
||||
//
|
||||
Attributes = FvbGetVolumeAttributes (Instance);
|
||||
if ( (Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
|
||||
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
|
||||
return EFI_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
@ -372,11 +368,14 @@ FvbWriteBlock (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ( LbaLength < ( *NumBytes + BlockOffset ) ) {
|
||||
DEBUG ((DEBUG_ERROR,
|
||||
if ( LbaLength < (*NumBytes + BlockOffset)) {
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"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;
|
||||
}
|
||||
|
||||
@ -384,11 +383,10 @@ FvbWriteBlock (
|
||||
Status = LibFvbFlashDeviceWrite (LbaAddress + BlockOffset, NumBytes, Buffer);
|
||||
|
||||
LibFvbFlashDeviceBlockLock (LbaAddress, LbaLength, TRUE);
|
||||
WriteBackInvalidateDataCacheRange ((VOID *) (LbaAddress + BlockOffset), *NumBytes);
|
||||
WriteBackInvalidateDataCacheRange ((VOID *)(LbaAddress + BlockOffset), *NumBytes);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Erases and initializes a firmware volume block
|
||||
|
||||
@ -409,7 +407,6 @@ FvbEraseBlock (
|
||||
IN EFI_LBA Lba
|
||||
)
|
||||
{
|
||||
|
||||
EFI_FVB_ATTRIBUTES_2 Attributes;
|
||||
UINTN LbaAddress;
|
||||
UINTN LbaLength;
|
||||
@ -420,7 +417,7 @@ FvbEraseBlock (
|
||||
//
|
||||
Attributes = FvbGetVolumeAttributes (Instance);
|
||||
|
||||
if( (Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
|
||||
if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
|
||||
return (EFI_ACCESS_DENIED);
|
||||
}
|
||||
|
||||
@ -428,7 +425,7 @@ FvbEraseBlock (
|
||||
// Get the starting address of the block for erase.
|
||||
//
|
||||
Status = FvbGetLbaAddress (Instance, Lba, &LbaAddress, &LbaLength, NULL);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -438,7 +435,7 @@ FvbEraseBlock (
|
||||
|
||||
LibFvbFlashDeviceBlockLock (LbaAddress, LbaLength, TRUE);
|
||||
|
||||
WriteBackInvalidateDataCacheRange ((VOID *) LbaAddress, LbaLength);
|
||||
WriteBackInvalidateDataCacheRange ((VOID *)LbaAddress, LbaLength);
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -484,7 +481,7 @@ FvbSetVolumeAttributes (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
AttribPtr = (EFI_FVB_ATTRIBUTES_2 *) &(FwhInstance->VolumeHeader.Attributes);
|
||||
AttribPtr = (EFI_FVB_ATTRIBUTES_2 *)&(FwhInstance->VolumeHeader.Attributes);
|
||||
ASSERT (AttribPtr != NULL);
|
||||
if ( AttribPtr == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -575,7 +572,6 @@ FvbSetVolumeAttributes (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves the physical address of the device.
|
||||
|
||||
@ -597,7 +593,7 @@ FvbProtocolGetPhysicalAddress (
|
||||
EFI_FW_VOL_INSTANCE *FwhInstance;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
FwhInstance = GetFvbInstance(FvbDevice->Instance);
|
||||
FwhInstance = GetFvbInstance (FvbDevice->Instance);
|
||||
if (FwhInstance == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
@ -606,8 +602,6 @@ FvbProtocolGetPhysicalAddress (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the size of a logical block
|
||||
|
||||
@ -638,7 +632,6 @@ FvbProtocolGetBlockSize (
|
||||
return FvbGetLbaAddress (FvbDevice->Instance, Lba, NULL, BlockSize, NumOfBlocks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves Volume attributes. No polarity translations are done.
|
||||
|
||||
@ -663,7 +656,6 @@ FvbProtocolGetAttributes (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets Volume attributes. No polarity translations are done.
|
||||
|
||||
@ -688,8 +680,6 @@ FvbProtocolSetAttributes (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function erases one or more blocks as denoted by the
|
||||
variable argument list. The entire parameter list of blocks must be verified
|
||||
@ -749,10 +739,10 @@ FvbProtocolEraseBlocks (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if ( ( StartingLba + NumOfLba ) > NumOfBlocks ) {
|
||||
if ((StartingLba + NumOfLba) > NumOfBlocks ) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
} while ( 1 );
|
||||
} while (1);
|
||||
|
||||
VA_END (args);
|
||||
|
||||
@ -767,22 +757,21 @@ FvbProtocolEraseBlocks (
|
||||
|
||||
while ( NumOfLba > 0 ) {
|
||||
Status = FvbEraseBlock (FvbDevice->Instance, StartingLba);
|
||||
if ( EFI_ERROR(Status)) {
|
||||
if ( EFI_ERROR (Status)) {
|
||||
VA_END (args);
|
||||
return Status;
|
||||
}
|
||||
|
||||
StartingLba++;
|
||||
NumOfLba--;
|
||||
}
|
||||
} while ( 1 );
|
||||
} while (1);
|
||||
|
||||
VA_END (args);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -823,14 +812,19 @@ FvbProtocolWrite (
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
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",
|
||||
Lba, Offset, *NumBytes, Buffer, Status));
|
||||
Lba,
|
||||
Offset,
|
||||
*NumBytes,
|
||||
Buffer,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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
|
||||
@ -869,15 +863,20 @@ FvbProtocolRead (
|
||||
OUT UINT8 *Buffer
|
||||
)
|
||||
{
|
||||
|
||||
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
|
||||
EFI_STATUS Status;
|
||||
|
||||
FvbDevice = FVB_DEVICE_FROM_THIS (This);
|
||||
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",
|
||||
Lba, Offset, *NumBytes, Buffer, Status));
|
||||
Lba,
|
||||
Offset,
|
||||
*NumBytes,
|
||||
Buffer,
|
||||
Status
|
||||
));
|
||||
|
||||
return Status;
|
||||
}
|
||||
@ -899,38 +898,38 @@ IsFvHeaderValid (
|
||||
UINT16 Sum;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
|
||||
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) FvBase;
|
||||
if (FvBase == PcdGet32(PcdFlashNvStorageVariableBase)) {
|
||||
if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid, sizeof(EFI_GUID)) != 0 ) {
|
||||
DEBUG((DEBUG_INFO, " --FileSystemGuid not match: %g\n", &FwVolHeader->FileSystemGuid));
|
||||
FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvBase;
|
||||
if (FvBase == PcdGet32 (PcdFlashNvStorageVariableBase)) {
|
||||
if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiSystemNvDataFvGuid, sizeof (EFI_GUID)) != 0 ) {
|
||||
DEBUG ((DEBUG_INFO, " --FileSystemGuid not match: %g\n", &FwVolHeader->FileSystemGuid));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid, sizeof(EFI_GUID)) != 0 ) {
|
||||
DEBUG((DEBUG_INFO, " --not expected guid.\n"));
|
||||
if (CompareMem (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID)) != 0 ) {
|
||||
DEBUG ((DEBUG_INFO, " --not expected guid.\n"));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (FwVolHeader->Revision != EFI_FVH_REVISION) ||
|
||||
if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
|
||||
(FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
|
||||
(FwVolHeader->FvLength == ((UINTN) -1)) ||
|
||||
((FwVolHeader->HeaderLength & 0x01 ) !=0) ) {
|
||||
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 ));
|
||||
(FwVolHeader->FvLength == ((UINTN)-1)) ||
|
||||
((FwVolHeader->HeaderLength & 0x01) != 0))
|
||||
{
|
||||
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));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Sum = CalculateSum16 ((UINT16 *) FwVolHeader, FwVolHeader->HeaderLength);
|
||||
Sum = CalculateSum16 ((UINT16 *)FwVolHeader, FwVolHeader->HeaderLength);
|
||||
if (Sum != 0) {
|
||||
DEBUG((DEBUG_INFO, "error: checksum: 0x%04X (expect 0x0)\n", Sum));
|
||||
DEBUG ((DEBUG_INFO, "error: checksum: 0x%04X (expect 0x0)\n", Sum));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get intial variable data.
|
||||
|
||||
@ -961,22 +960,23 @@ GetInitialVariableData (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = GetSectionFromAnyFv (PcdGetPtr(PcdNvsDataFile), EFI_SECTION_RAW, 0, &ImageData, &ImageSize);
|
||||
Status = GetSectionFromAnyFv (PcdGetPtr (PcdNvsDataFile), EFI_SECTION_RAW, 0, &ImageData, &ImageSize);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ImageData;
|
||||
VariableStore = (VARIABLE_STORE_HEADER *) ((UINT8 *)ImageData + FvHeader->HeaderLength);
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)ImageData;
|
||||
VariableStore = (VARIABLE_STORE_HEADER *)((UINT8 *)ImageData + FvHeader->HeaderLength);
|
||||
VarEndAddr = (UINTN)VariableStore + VariableStore->Size;
|
||||
Variable = (AUTHENTICATED_VARIABLE_HEADER *) HEADER_ALIGN (VariableStore + 1);
|
||||
Variable = (AUTHENTICATED_VARIABLE_HEADER *)HEADER_ALIGN (VariableStore + 1);
|
||||
*VarData = (VOID *)Variable;
|
||||
while (((UINTN)Variable < VarEndAddr)) {
|
||||
if (Variable->StartId != VARIABLE_DATA) {
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
*VarSize = (UINTN)Variable - HEADER_ALIGN (VariableStore + 1);
|
||||
@ -1009,8 +1009,8 @@ FvbInitialize (
|
||||
VOID *VarData;
|
||||
|
||||
InitVariableStore ();
|
||||
BaseAddress = PcdGet32(PcdFlashNvStorageVariableBase);
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) BaseAddress;
|
||||
BaseAddress = PcdGet32 (PcdFlashNvStorageVariableBase);
|
||||
FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
|
||||
|
||||
//
|
||||
// Check FV header and variable store header
|
||||
@ -1024,47 +1024,48 @@ FvbInitialize (
|
||||
LibFvbFlashDeviceBlockLock ((UINTN)BaseAddress, FvHeader->BlockMap->Length, FALSE);
|
||||
|
||||
Status = LibFvbFlashDeviceBlockErase ((UINTN)BaseAddress, FvHeader->BlockMap->Length);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Length = FvHeader->HeaderLength;
|
||||
WriteAddr = (UINTN)BaseAddress;
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &Length, (UINT8 *) FvHeader);
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &Length, (UINT8 *)FvHeader);
|
||||
WriteAddr += Length;
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Write back variable store header
|
||||
//
|
||||
VariableStore.Size = PcdGet32(PcdFlashNvStorageVariableSize) - FvHeader->HeaderLength;
|
||||
VariableStore.Size = PcdGet32 (PcdFlashNvStorageVariableSize) - FvHeader->HeaderLength;
|
||||
VariableStore.Format = VARIABLE_STORE_FORMATTED;
|
||||
VariableStore.State = VARIABLE_STORE_HEALTHY;
|
||||
CopyGuid (&VariableStore.Signature, &gEfiAuthenticatedVariableGuid);
|
||||
BufferSize = sizeof (VARIABLE_STORE_HEADER);
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &BufferSize, (UINT8 *) &VariableStore);
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &BufferSize, (UINT8 *)&VariableStore);
|
||||
WriteAddr += BufferSize;
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
// Write initial variable data if found
|
||||
//
|
||||
Status = GetInitialVariableData (&VarData, &Length);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &Length, (UINT8 *) VarData);
|
||||
ASSERT_EFI_ERROR(Status);
|
||||
Status = LibFvbFlashDeviceWrite (WriteAddr, &Length, (UINT8 *)VarData);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
LibFvbFlashDeviceBlockLock ((UINTN)BaseAddress, FvHeader->BlockMap->Length, TRUE);
|
||||
WriteBackInvalidateDataCacheRange ((VOID *) (UINTN) BaseAddress, FvHeader->BlockMap->Length);
|
||||
WriteBackInvalidateDataCacheRange ((VOID *)(UINTN)BaseAddress, FvHeader->BlockMap->Length);
|
||||
}
|
||||
|
||||
//
|
||||
// Create a new FW volume instance for NVS variable
|
||||
//
|
||||
BufferSize = FvHeader->HeaderLength + sizeof (EFI_FW_VOL_INSTANCE) - sizeof (EFI_FIRMWARE_VOLUME_HEADER);
|
||||
FwVolInstance = (EFI_FW_VOL_INSTANCE *) AllocateRuntimeZeroPool (BufferSize);
|
||||
FwVolInstance = (EFI_FW_VOL_INSTANCE *)AllocateRuntimeZeroPool (BufferSize);
|
||||
if (FwVolInstance == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
FwVolInstance->FvBase = (UINTN)BaseAddress;
|
||||
CopyMem (&FwVolInstance->VolumeHeader, FvHeader, FvHeader->HeaderLength);
|
||||
|
||||
|
@ -36,7 +36,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
// Define two helper macro to extract the Capability field or Status field in FVB
|
||||
// bit fields
|
||||
//
|
||||
#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP | \
|
||||
#define EFI_FVB2_CAPABILITIES (EFI_FVB2_READ_DISABLED_CAP |\
|
||||
EFI_FVB2_READ_ENABLED_CAP | \
|
||||
EFI_FVB2_WRITE_DISABLED_CAP | \
|
||||
EFI_FVB2_WRITE_ENABLED_CAP | \
|
||||
@ -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)
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINTN FvBase;
|
||||
UINTN NumOfBlocks;
|
||||
@ -56,7 +55,6 @@ typedef struct {
|
||||
EFI_FIRMWARE_VOLUME_HEADER VolumeHeader;
|
||||
} EFI_FW_VOL_INSTANCE;
|
||||
|
||||
|
||||
typedef struct {
|
||||
EFI_FW_VOL_INSTANCE *FvInstance;
|
||||
UINT32 NumFv;
|
||||
|
@ -37,7 +37,7 @@ InstallFvbProtocol (
|
||||
FV_MEMMAP_DEVICE_PATH *FvDevicePath;
|
||||
VOID *TempPtr;
|
||||
|
||||
FvbDevice = (EFI_FW_VOL_BLOCK_DEVICE *) AllocateRuntimeCopyPool (
|
||||
FvbDevice = (EFI_FW_VOL_BLOCK_DEVICE *)AllocateRuntimeCopyPool (
|
||||
sizeof (EFI_FW_VOL_BLOCK_DEVICE),
|
||||
&mFvbDeviceTemplate
|
||||
);
|
||||
@ -56,17 +56,18 @@ InstallFvbProtocol (
|
||||
// FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
|
||||
//
|
||||
TempPtr = AllocateRuntimeCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH), &mFvMemmapDevicePathTemplate);
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)TempPtr;
|
||||
if (FvbDevice->DevicePath == NULL) {
|
||||
ASSERT (FALSE);
|
||||
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.EndingAddress = FwhInstance->FvBase + FwVolHeader->FvLength - 1;
|
||||
} else {
|
||||
TempPtr = AllocateRuntimeCopyPool (sizeof (FV_PIWG_DEVICE_PATH), &mFvPIWGDevicePathTemplate);
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) TempPtr;
|
||||
FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)TempPtr;
|
||||
if (FvbDevice->DevicePath == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
@ -112,7 +113,6 @@ InstallFvbProtocol (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The driver entry point for SMM Firmware Volume Block Driver.
|
||||
|
||||
|
@ -25,7 +25,6 @@ typedef struct {
|
||||
UINT8 Data[1];
|
||||
} SMM_FVB_COMMUNICATE_FUNCTION_HEADER;
|
||||
|
||||
|
||||
///
|
||||
/// Size of SMM communicate header, without including the payload.
|
||||
///
|
||||
|
@ -80,7 +80,7 @@ GraphicsOutputComponentNameGetDriverName (
|
||||
This->SupportedLanguages,
|
||||
mGraphicsOutputDriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN) (This == &mGraphicsOutputComponentName)
|
||||
(BOOLEAN)(This == &mGraphicsOutputComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mGraphicsOutputCompon
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mGraphicsOutputComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GraphicsOutputComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GraphicsOutputComponentNameGetControllerName,
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)GraphicsOutputComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)GraphicsOutputComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
@ -50,7 +50,7 @@ GraphicsOutputQueryMode (
|
||||
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;
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ EFIAPI
|
||||
GraphicsOutputSetMode (
|
||||
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
||||
IN UINT32 ModeNumber
|
||||
)
|
||||
)
|
||||
{
|
||||
RETURN_STATUS Status;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
|
||||
@ -97,8 +97,10 @@ GraphicsOutputSetMode (
|
||||
Private->FrameBufferBltLibConfigure,
|
||||
&Black,
|
||||
EfiBltVideoFill,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
This->Mode->Info->HorizontalResolution,
|
||||
This->Mode->Info->VerticalResolution,
|
||||
0
|
||||
@ -159,8 +161,12 @@ GraphicsOutputBlt (
|
||||
Private->FrameBufferBltLibConfigure,
|
||||
BltBuffer,
|
||||
BltOperation,
|
||||
SourceX, SourceY,
|
||||
DestinationX, DestinationY, Width, Height,
|
||||
SourceX,
|
||||
SourceY,
|
||||
DestinationX,
|
||||
DestinationY,
|
||||
Width,
|
||||
Height,
|
||||
Delta
|
||||
);
|
||||
gBS->RestoreTPL (Tpl);
|
||||
@ -228,7 +234,7 @@ GraphicsOutputDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -236,9 +242,11 @@ GraphicsOutputDriverBindingSupported (
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
@ -252,7 +260,7 @@ GraphicsOutputDriverBindingSupported (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &DevicePath,
|
||||
(VOID **)&DevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -260,9 +268,11 @@ GraphicsOutputDriverBindingSupported (
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
gBS->CloseProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
@ -272,7 +282,8 @@ GraphicsOutputDriverBindingSupported (
|
||||
|
||||
if ((RemainingDevicePath == NULL) ||
|
||||
IsDevicePathEnd (RemainingDevicePath) ||
|
||||
CompareMem (RemainingDevicePath, &mGraphicsOutputAdrNode, sizeof (mGraphicsOutputAdrNode)) == 0) {
|
||||
(CompareMem (RemainingDevicePath, &mGraphicsOutputAdrNode, sizeof (mGraphicsOutputAdrNode)) == 0))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
} else {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -315,7 +326,7 @@ GraphicsOutputDriverBindingStart (
|
||||
|
||||
HobStart = GetFirstGuidHob (&gEfiGraphicsInfoHobGuid);
|
||||
ASSERT ((HobStart != NULL) && (GET_GUID_HOB_DATA_SIZE (HobStart) == sizeof (EFI_PEI_GRAPHICS_INFO_HOB)));
|
||||
GraphicsInfo = (EFI_PEI_GRAPHICS_INFO_HOB *) (GET_GUID_HOB_DATA (HobStart));
|
||||
GraphicsInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)(GET_GUID_HOB_DATA (HobStart));
|
||||
|
||||
HobStart = GetFirstGuidHob (&gEfiGraphicsDeviceInfoHobGuid);
|
||||
if ((HobStart == NULL) || (GET_GUID_HOB_DATA_SIZE (HobStart) < sizeof (*DeviceInfo))) {
|
||||
@ -325,15 +336,21 @@ GraphicsOutputDriverBindingStart (
|
||||
DeviceInfo = &mDefaultGraphicsDeviceInfo;
|
||||
DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB doesn't exist!\n", gEfiCallerBaseName));
|
||||
} else {
|
||||
DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) (GET_GUID_HOB_DATA (HobStart));
|
||||
DEBUG ((DEBUG_INFO, "[%a]: GraphicsDeviceInfo HOB:\n"
|
||||
DeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *)(GET_GUID_HOB_DATA (HobStart));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"[%a]: GraphicsDeviceInfo HOB:\n"
|
||||
" VendorId = %04x, DeviceId = %04x,\n"
|
||||
" RevisionId = %02x, BarIndex = %x,\n"
|
||||
" SubsystemVendorId = %04x, SubsystemId = %04x\n",
|
||||
gEfiCallerBaseName,
|
||||
DeviceInfo->VendorId, DeviceInfo->DeviceId,
|
||||
DeviceInfo->RevisionId, DeviceInfo->BarIndex,
|
||||
DeviceInfo->SubsystemVendorId, DeviceInfo->SubsystemId));
|
||||
DeviceInfo->VendorId,
|
||||
DeviceInfo->DeviceId,
|
||||
DeviceInfo->RevisionId,
|
||||
DeviceInfo->BarIndex,
|
||||
DeviceInfo->SubsystemVendorId,
|
||||
DeviceInfo->SubsystemId
|
||||
));
|
||||
}
|
||||
|
||||
//
|
||||
@ -342,7 +359,7 @@ GraphicsOutputDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &PciIo,
|
||||
(VOID **)&PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -350,12 +367,13 @@ GraphicsOutputDriverBindingStart (
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID **) &PciDevicePath,
|
||||
(VOID **)&PciDevicePath,
|
||||
This->DriverBindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@ -363,6 +381,7 @@ GraphicsOutputDriverBindingStart (
|
||||
if (Status == EFI_ALREADY_STARTED) {
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
//
|
||||
@ -377,7 +396,8 @@ GraphicsOutputDriverBindingStart (
|
||||
((DeviceInfo->SubsystemVendorId != MAX_UINT16) && (DeviceInfo->SubsystemVendorId != Pci.Device.SubsystemVendorID)) ||
|
||||
((DeviceInfo->SubsystemId != MAX_UINT16) && (DeviceInfo->SubsystemId != Pci.Device.SubsystemID))
|
||||
)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// 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)) {
|
||||
continue;
|
||||
}
|
||||
Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID**) &Resources);
|
||||
|
||||
Status = PciIo->GetBarAttributes (PciIo, Index, NULL, (VOID **)&Resources);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO, "[%a]: BAR[%d]: Base = %lx, Length = %lx\n",
|
||||
gEfiCallerBaseName, Index, Resources->AddrRangeMin, Resources->AddrLen));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"[%a]: BAR[%d]: Base = %lx, Length = %lx\n",
|
||||
gEfiCallerBaseName,
|
||||
Index,
|
||||
Resources->AddrRangeMin,
|
||||
Resources->AddrLen
|
||||
));
|
||||
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->AddrLen >= GraphicsInfo->FrameBufferSize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if (FrameBufferBase == 0) {
|
||||
FrameBufferBase = Resources->AddrRangeMin;
|
||||
}
|
||||
|
||||
if (DeviceInfo->BarIndex == MAX_UINT8) {
|
||||
if (Resources->AddrRangeMin == GraphicsInfo->FrameBufferBase) {
|
||||
FrameBufferBase = Resources->AddrRangeMin;
|
||||
@ -416,6 +445,7 @@ GraphicsOutputDriverBindingStart (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Index == MAX_PCI_BAR) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
} else {
|
||||
@ -473,7 +503,7 @@ GraphicsOutputDriverBindingStart (
|
||||
// Create the FrameBufferBltLib configuration.
|
||||
//
|
||||
ReturnStatus = FrameBufferBltConfigure (
|
||||
(VOID *) (UINTN) Private->GraphicsOutput.Mode->FrameBufferBase,
|
||||
(VOID *)(UINTN)Private->GraphicsOutput.Mode->FrameBufferBase,
|
||||
Private->GraphicsOutput.Mode->Info,
|
||||
Private->FrameBufferBltLibConfigure,
|
||||
&Private->FrameBufferBltLibConfigureSize
|
||||
@ -482,19 +512,20 @@ GraphicsOutputDriverBindingStart (
|
||||
Private->FrameBufferBltLibConfigure = AllocatePool (Private->FrameBufferBltLibConfigureSize);
|
||||
if (Private->FrameBufferBltLibConfigure != NULL) {
|
||||
ReturnStatus = FrameBufferBltConfigure (
|
||||
(VOID *) (UINTN) Private->GraphicsOutput.Mode->FrameBufferBase,
|
||||
(VOID *)(UINTN)Private->GraphicsOutput.Mode->FrameBufferBase,
|
||||
Private->GraphicsOutput.Mode->Info,
|
||||
Private->FrameBufferBltLibConfigure,
|
||||
&Private->FrameBufferBltLibConfigureSize
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_ERROR (ReturnStatus)) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto RestorePciAttributes;
|
||||
}
|
||||
|
||||
Private->DevicePath = AppendDevicePathNode (PciDevicePath, (EFI_DEVICE_PATH_PROTOCOL *) &mGraphicsOutputAdrNode);
|
||||
Private->DevicePath = AppendDevicePathNode (PciDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&mGraphicsOutputAdrNode);
|
||||
if (Private->DevicePath == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto RestorePciAttributes;
|
||||
@ -502,8 +533,10 @@ GraphicsOutputDriverBindingStart (
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Private->GraphicsOutputHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid, Private->DevicePath,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
Private->DevicePath,
|
||||
NULL
|
||||
);
|
||||
|
||||
@ -511,7 +544,7 @@ GraphicsOutputDriverBindingStart (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &Private->PciIo,
|
||||
(VOID **)&Private->PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Private->GraphicsOutputHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
@ -521,8 +554,10 @@ GraphicsOutputDriverBindingStart (
|
||||
} else {
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->GraphicsOutputHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid, Private->DevicePath,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
Private->DevicePath,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
@ -547,9 +582,11 @@ FreeMemory:
|
||||
if (Private->DevicePath != NULL) {
|
||||
FreePool (Private->DevicePath);
|
||||
}
|
||||
|
||||
if (Private->FrameBufferBltLibConfigure != NULL) {
|
||||
FreePool (Private->FrameBufferBltLibConfigure);
|
||||
}
|
||||
|
||||
FreePool (Private);
|
||||
}
|
||||
}
|
||||
@ -576,6 +613,7 @@ CloseProtocols:
|
||||
Controller
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -605,7 +643,6 @@ GraphicsOutputDriverBindingStop (
|
||||
GRAPHICS_OUTPUT_PRIVATE_DATA *Private;
|
||||
|
||||
if (NumberOfChildren == 0) {
|
||||
|
||||
//
|
||||
// Close the PCI I/O Protocol
|
||||
//
|
||||
@ -631,7 +668,7 @@ GraphicsOutputDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandleBuffer[0],
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
(VOID **) &Gop,
|
||||
(VOID **)&Gop,
|
||||
This->DriverBindingHandle,
|
||||
ChildHandleBuffer[0],
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -654,8 +691,10 @@ GraphicsOutputDriverBindingStop (
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
Private->GraphicsOutputHandle,
|
||||
&gEfiGraphicsOutputProtocolGuid, &Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid, Private->DevicePath,
|
||||
&gEfiGraphicsOutputProtocolGuid,
|
||||
&Private->GraphicsOutput,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
Private->DevicePath,
|
||||
NULL
|
||||
);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
@ -677,13 +716,14 @@ GraphicsOutputDriverBindingStop (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
&gEfiPciIoProtocolGuid,
|
||||
(VOID **) &Private->PciIo,
|
||||
(VOID **)&Private->PciIo,
|
||||
This->DriverBindingHandle,
|
||||
Private->GraphicsOutputHandle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _GRAPHICS_OUTPUT_DXE_H_
|
||||
#define _GRAPHICS_OUTPUT_DXE_H_
|
||||
#include <PiDxe.h>
|
||||
|
@ -35,12 +35,11 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _COREBOOT_PEI_H_INCLUDED_
|
||||
#define _COREBOOT_PEI_H_INCLUDED_
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4200 )
|
||||
#if defined (_MSC_VER)
|
||||
#pragma warning( disable : 4200 )
|
||||
#endif
|
||||
|
||||
#define DYN_CBMEM_ALIGN_SIZE (4096)
|
||||
@ -132,6 +131,7 @@ struct cb_mainboard {
|
||||
UINT8 part_number_idx;
|
||||
UINT8 strings[0];
|
||||
};
|
||||
|
||||
#define CB_TAG_VERSION 0x0004
|
||||
#define CB_TAG_EXTRA_VERSION 0x0005
|
||||
#define CB_TAG_BUILD 0x0006
|
||||
@ -154,8 +154,8 @@ struct cb_string {
|
||||
struct cb_serial {
|
||||
UINT32 tag;
|
||||
UINT32 size;
|
||||
#define CB_SERIAL_TYPE_IO_MAPPED 1
|
||||
#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
|
||||
#define CB_SERIAL_TYPE_IO_MAPPED 1
|
||||
#define CB_SERIAL_TYPE_MEMORY_MAPPED 2
|
||||
UINT32 type;
|
||||
UINT32 baseaddr;
|
||||
UINT32 baud;
|
||||
@ -188,7 +188,7 @@ struct cb_console {
|
||||
#define CB_TAG_CONSOLE_VGA 1 // OBSOLETE
|
||||
#define CB_TAG_CONSOLE_BTEXT 2 // OBSOLETE
|
||||
#define CB_TAG_CONSOLE_LOGBUF 3
|
||||
#define CB_TAG_CONSOLE_SROM 4 // OBSOLETE
|
||||
#define CB_TAG_CONSOLE_SROM 4// OBSOLETE
|
||||
#define CB_TAG_CONSOLE_EHCI 5
|
||||
|
||||
#define CB_TAG_FORWARD 0x00011
|
||||
|
@ -42,7 +42,6 @@ typedef struct {
|
||||
PLD_GENERIC_REGISTER Registers[0];
|
||||
} PLD_SMM_REGISTERS;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
@ -6,6 +6,7 @@
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef BOOTLOADER_PARSE_LIB_
|
||||
#define BOOTLOADER_PARSE_LIB_
|
||||
|
||||
@ -20,7 +21,10 @@
|
||||
#define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter)
|
||||
|
||||
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.
|
||||
@ -100,7 +104,6 @@ ParseSerialInfo (
|
||||
OUT SERIAL_PORT_INFO *SerialPortInfo
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Find the video frame buffer information
|
||||
|
||||
|
@ -24,4 +24,3 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
extern VOID *gHobList;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#ifndef FLASHDEVICE_LIB_H_
|
||||
#define FLASHDEVICE_LIB_H_
|
||||
|
||||
@ -31,7 +30,6 @@ LibFvbFlashDeviceRead (
|
||||
OUT UINT8 *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Write NumBytes bytes of data from Buffer to the address specified by
|
||||
PAddresss.
|
||||
@ -53,7 +51,6 @@ LibFvbFlashDeviceWrite (
|
||||
IN UINT8 *Buffer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Erase the block starting at PAddress.
|
||||
|
||||
@ -74,8 +71,7 @@ EFIAPI
|
||||
LibFvbFlashDeviceBlockErase (
|
||||
IN UINTN PAddress,
|
||||
IN UINTN LbaLength
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
/**
|
||||
Lock or unlock the block starting at PAddress.
|
||||
@ -98,11 +94,11 @@ LibFvbFlashDeviceBlockLock (
|
||||
IN UINTN PAddress,
|
||||
IN UINTN LbaLength,
|
||||
IN BOOLEAN Lock
|
||||
);
|
||||
);
|
||||
|
||||
PHYSICAL_ADDRESS
|
||||
EFIAPI
|
||||
LibFvbFlashDeviceMemoryMap (
|
||||
);
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -25,4 +25,3 @@ ParsePlatformInfo (
|
||||
);
|
||||
|
||||
#endif // __BOOTLOADER_PLATFORM_SUPPORT_LIB__
|
||||
|
||||
|
@ -117,7 +117,6 @@ SpiReadPchSoftStrap (
|
||||
OUT UINT8 *SoftStrapValue
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Read data from the flash part.
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#ifndef __PLATFORM_BOOT_MANAGER_OVERRIDE_H__
|
||||
#define __PLATFORM_BOOT_MANAGER_OVERRIDE_H__
|
||||
|
||||
|
||||
/**
|
||||
Do the platform specific action before the console is connected.
|
||||
|
||||
@ -21,7 +20,7 @@
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE) (
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_BEFORE_CONSOLE)(
|
||||
VOID
|
||||
);
|
||||
|
||||
@ -39,7 +38,7 @@ VOID
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE) (
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_AFTER_CONSOLE)(
|
||||
VOID
|
||||
);
|
||||
|
||||
@ -51,7 +50,7 @@ VOID
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK) (
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_WAIT_CALLBACK)(
|
||||
UINT16 TimeoutRemain
|
||||
);
|
||||
|
||||
@ -65,7 +64,7 @@ VOID
|
||||
**/
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT) (
|
||||
(EFIAPI *UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_UNABLE_TO_BOOT)(
|
||||
VOID
|
||||
);
|
||||
|
||||
|
@ -67,6 +67,7 @@ InternalAcpiGetTimerTick (
|
||||
if (mPmTimerReg == 0) {
|
||||
AcpiTimerLibConstructor ();
|
||||
}
|
||||
|
||||
return IoRead32 (mPmTimerReg);
|
||||
}
|
||||
|
||||
@ -261,8 +262,8 @@ GetTimeInNanoSecond (
|
||||
// i.e. highest bit set in Remainder should <= 33.
|
||||
//
|
||||
Shift = MAX (0, HighBitSet64 (Remainder) - 33);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN) Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN) Shift);
|
||||
Remainder = RShiftU64 (Remainder, (UINTN)Shift);
|
||||
Frequency = RShiftU64 (Frequency, (UINTN)Shift);
|
||||
NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL);
|
||||
|
||||
return NanoSeconds;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
#include <Coreboot.h>
|
||||
|
||||
|
||||
/**
|
||||
Convert a packed value from cbuint64 to a UINT64 value.
|
||||
|
||||
@ -34,7 +33,6 @@ cb_unpack64 (
|
||||
return LShiftU64 (val.hi, 32) | val.lo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the sum of all elements in a buffer of 16-bit values. During
|
||||
calculation, the carry bits are also been added.
|
||||
@ -58,7 +56,7 @@ CbCheckSum16 (
|
||||
|
||||
Sum = 0;
|
||||
TmpPtr = (UINT8 *)Buffer;
|
||||
for(Idx = 0; Idx < Length; Idx++) {
|
||||
for (Idx = 0; Idx < Length; Idx++) {
|
||||
TmpValue = TmpPtr[Idx];
|
||||
if (Idx % 2 == 1) {
|
||||
TmpValue <<= 8;
|
||||
@ -75,7 +73,6 @@ CbCheckSum16 (
|
||||
return (UINT16)((~Sum) & 0xFFFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the coreboot table if it is valid.
|
||||
|
||||
@ -118,7 +115,6 @@ IsValidCbTable (
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function retrieves the parameter base address from boot loader.
|
||||
|
||||
@ -184,6 +180,7 @@ GetParameterBase (
|
||||
CbTablePtr = (VOID *)(UINTN)((struct cb_forward *)(UINTN)Record)->forward;
|
||||
break;
|
||||
}
|
||||
|
||||
TmpPtr += Record->size;
|
||||
}
|
||||
|
||||
@ -200,7 +197,6 @@ GetParameterBase (
|
||||
return CbTablePtr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find coreboot record with given Tag.
|
||||
|
||||
@ -221,7 +217,7 @@ FindCbTag (
|
||||
UINT8 *TagPtr;
|
||||
UINTN Idx;
|
||||
|
||||
Header = (struct cb_header *) GetParameterBase ();
|
||||
Header = (struct cb_header *)GetParameterBase ();
|
||||
|
||||
TagPtr = NULL;
|
||||
TmpPtr = (UINT8 *)Header + Header->header_bytes;
|
||||
@ -231,13 +227,13 @@ FindCbTag (
|
||||
TagPtr = TmpPtr;
|
||||
break;
|
||||
}
|
||||
|
||||
TmpPtr += Record->size;
|
||||
}
|
||||
|
||||
return TagPtr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the given table with TableId from the given coreboot memory Root.
|
||||
|
||||
@ -266,6 +262,7 @@ FindCbMemTable (
|
||||
if ((Root == NULL) || (MemTable == NULL)) {
|
||||
return RETURN_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Check if the entry is CBMEM or IMD
|
||||
// and handle them separately
|
||||
@ -285,16 +282,22 @@ FindCbMemTable (
|
||||
for (Idx = 0; Idx < Root->num_entries; Idx++) {
|
||||
if (Entries[Idx].id == TableId) {
|
||||
if (IsImdEntry) {
|
||||
*MemTable = (VOID *) ((UINTN)Entries[Idx].start + (UINTN)Root);
|
||||
*MemTable = (VOID *)((UINTN)Entries[Idx].start + (UINTN)Root);
|
||||
} else {
|
||||
*MemTable = (VOID *) (UINTN)Entries[Idx].start;
|
||||
*MemTable = (VOID *)(UINTN)Entries[Idx].start;
|
||||
}
|
||||
|
||||
if (MemTableSize != NULL) {
|
||||
*MemTableSize = Entries[Idx].size;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Find CbMemTable Id 0x%x, base %p, size 0x%x\n",
|
||||
TableId, *MemTable, Entries[Idx].size));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"Find CbMemTable Id 0x%x, base %p, size 0x%x\n",
|
||||
TableId,
|
||||
*MemTable,
|
||||
Entries[Idx].size
|
||||
));
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
}
|
||||
@ -344,10 +347,10 @@ ParseCbMemTable (
|
||||
return Status;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < MEM_RANGE_COUNT(Rec); Index++) {
|
||||
Range = MEM_RANGE_PTR(Rec, Index);
|
||||
Start = cb_unpack64(Range->start);
|
||||
Size = cb_unpack64(Range->size);
|
||||
for (Index = 0; Index < MEM_RANGE_COUNT (Rec); Index++) {
|
||||
Range = MEM_RANGE_PTR (Rec, Index);
|
||||
Start = cb_unpack64 (Range->start);
|
||||
Size = cb_unpack64 (Range->size);
|
||||
|
||||
if ((Range->type == CB_MEM_TABLE) && (Start > 0x1000)) {
|
||||
CbMemRoot = (struct cbmem_root *)(UINTN)(Start + Size - DYN_CBMEM_ALIGN_SIZE);
|
||||
@ -361,8 +364,6 @@ ParseCbMemTable (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Acquire the memory information from the coreboot table in memory.
|
||||
|
||||
@ -393,14 +394,20 @@ ParseMemoryInfo (
|
||||
return RETURN_NOT_FOUND;
|
||||
}
|
||||
|
||||
for (Index = 0; Index < MEM_RANGE_COUNT(Rec); Index++) {
|
||||
Range = MEM_RANGE_PTR(Rec, Index);
|
||||
MemoryMap.Base = cb_unpack64(Range->start);
|
||||
MemoryMap.Size = cb_unpack64(Range->size);
|
||||
for (Index = 0; Index < MEM_RANGE_COUNT (Rec); Index++) {
|
||||
Range = MEM_RANGE_PTR (Rec, Index);
|
||||
MemoryMap.Base = cb_unpack64 (Range->start);
|
||||
MemoryMap.Size = cb_unpack64 (Range->size);
|
||||
MemoryMap.Type = (UINT8)Range->type;
|
||||
MemoryMap.Flag = 0;
|
||||
DEBUG ((DEBUG_INFO, "%d. %016lx - %016lx [%02x]\n",
|
||||
Index, MemoryMap.Base, MemoryMap.Base + MemoryMap.Size - 1, MemoryMap.Type));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"%d. %016lx - %016lx [%02x]\n",
|
||||
Index,
|
||||
MemoryMap.Base,
|
||||
MemoryMap.Base + MemoryMap.Size - 1,
|
||||
MemoryMap.Type
|
||||
));
|
||||
|
||||
MemInfoCallback (&MemoryMap, Params);
|
||||
}
|
||||
@ -408,7 +415,6 @@ ParseMemoryInfo (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Acquire SMBIOS table from coreboot.
|
||||
|
||||
@ -432,12 +438,12 @@ ParseSmbiosTable (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
SmbiosTable->SmBiosEntryPoint = (UINT64) (UINTN)MemTable;
|
||||
|
||||
SmbiosTable->SmBiosEntryPoint = (UINT64)(UINTN)MemTable;
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Acquire ACPI table from coreboot.
|
||||
|
||||
@ -461,12 +467,12 @@ ParseAcpiTableInfo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
AcpiTableHob->Rsdp = (UINT64) (UINTN)MemTable;
|
||||
|
||||
AcpiTableHob->Rsdp = (UINT64)(UINTN)MemTable;
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
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)) {
|
||||
GfxMode->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
|
||||
}
|
||||
|
||||
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.BlueMask = ((1 << CbFbRec->blue_mask_size) - 1) << CbFbRec->blue_mask_pos;
|
||||
|
@ -67,7 +67,7 @@ GetNextHob (
|
||||
|
||||
ASSERT (HobStart != NULL);
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
//
|
||||
// Parse the HOB list until end of list or matching type is found.
|
||||
//
|
||||
@ -75,8 +75,10 @@ GetNextHob (
|
||||
if (Hob.Header->HobType == Type) {
|
||||
return Hob.Raw;
|
||||
}
|
||||
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -136,13 +138,15 @@ GetNextGuidHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS GuidHob;
|
||||
|
||||
GuidHob.Raw = (UINT8 *) HobStart;
|
||||
GuidHob.Raw = (UINT8 *)HobStart;
|
||||
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
||||
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
||||
break;
|
||||
}
|
||||
|
||||
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
||||
}
|
||||
|
||||
return GuidHob.Raw;
|
||||
}
|
||||
|
||||
@ -197,7 +201,7 @@ GetBootModeHob (
|
||||
{
|
||||
EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
|
||||
|
||||
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
|
||||
HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *)GetHobList ();
|
||||
|
||||
return HandOffHob->BootMode;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
VOID *gHobList = NULL;
|
||||
@ -33,10 +32,10 @@ LocalCompareGuid (
|
||||
UINT64 *Left;
|
||||
UINT64 *Right;
|
||||
|
||||
Left = (UINT64 *) Guid1;
|
||||
Right = (UINT64 *) Guid2;
|
||||
Left = (UINT64 *)Guid1;
|
||||
Right = (UINT64 *)Guid2;
|
||||
|
||||
return (BOOLEAN) (Left[0] == Right[0] && Left[1] == Right[1]);
|
||||
return (BOOLEAN)(Left[0] == Right[0] && Left[1] == Right[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
**/
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,6 @@ LibFvbFlashDeviceInit (
|
||||
return SpiConstructor ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read NumBytes bytes of data from the address specified by
|
||||
PAddress into Buffer.
|
||||
@ -66,7 +65,6 @@ LibFvbFlashDeviceRead (
|
||||
return SpiFlashRead (FlashRegionBios, AddrOffset, ByteCount, Buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Write NumBytes bytes of data from Buffer to the address specified by
|
||||
PAddresss.
|
||||
@ -105,7 +103,6 @@ LibFvbFlashDeviceWrite (
|
||||
return SpiFlashWrite (FlashRegionBios, AddrOffset, ByteCount, Buffer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Erase the block starting at PAddress.
|
||||
|
||||
@ -140,7 +137,6 @@ LibFvbFlashDeviceBlockErase (
|
||||
return SpiFlashErase (FlashRegionBios, AddrOffset, (UINT32)LbaLength);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Lock or unlock the block starting at PAddress.
|
||||
|
||||
@ -162,4 +158,3 @@ LibFvbFlashDeviceBlockLock (
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ GetHobList (
|
||||
return mHobList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build a Handoff Information Table HOB
|
||||
|
||||
@ -51,7 +50,7 @@ GetHobList (
|
||||
@return The pointer to the handoff HOB table.
|
||||
|
||||
**/
|
||||
EFI_HOB_HANDOFF_INFO_TABLE*
|
||||
EFI_HOB_HANDOFF_INFO_TABLE *
|
||||
EFIAPI
|
||||
HobConstructor (
|
||||
IN VOID *EfiMemoryBottom,
|
||||
@ -67,21 +66,21 @@ HobConstructor (
|
||||
HobEnd = (EFI_HOB_GENERIC_HEADER *)(Hob+1);
|
||||
|
||||
Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
|
||||
Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
|
||||
Hob->Header.HobLength = sizeof (EFI_HOB_HANDOFF_INFO_TABLE);
|
||||
Hob->Header.Reserved = 0;
|
||||
|
||||
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
||||
HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
|
||||
HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
|
||||
HobEnd->Reserved = 0;
|
||||
|
||||
Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
|
||||
Hob->BootMode = BOOT_WITH_FULL_CONFIGURATION;
|
||||
|
||||
Hob->EfiMemoryTop = (EFI_PHYSICAL_ADDRESS) (UINTN) EfiMemoryTop;
|
||||
Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) EfiMemoryBottom;
|
||||
Hob->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS) (UINTN) EfiFreeMemoryTop;
|
||||
Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1);
|
||||
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
||||
Hob->EfiMemoryTop = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiMemoryTop;
|
||||
Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiMemoryBottom;
|
||||
Hob->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiFreeMemoryTop;
|
||||
Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
|
||||
Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||
|
||||
mHobList = Hob;
|
||||
return Hob;
|
||||
@ -119,19 +118,19 @@ CreateHob (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
|
||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
|
||||
((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
|
||||
((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
|
||||
Hob = (VOID *)(UINTN)HandOffHob->EfiEndOfHobList;
|
||||
((EFI_HOB_GENERIC_HEADER *)Hob)->HobType = HobType;
|
||||
((EFI_HOB_GENERIC_HEADER *)Hob)->HobLength = HobLength;
|
||||
((EFI_HOB_GENERIC_HEADER *)Hob)->Reserved = 0;
|
||||
|
||||
HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
|
||||
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
||||
HobEnd = (EFI_HOB_GENERIC_HEADER *)((UINTN)Hob + HobLength);
|
||||
HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||
|
||||
HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
|
||||
HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
|
||||
HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
|
||||
HobEnd->Reserved = 0;
|
||||
HobEnd++;
|
||||
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
|
||||
HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
|
||||
|
||||
return Hob;
|
||||
}
|
||||
@ -160,7 +159,7 @@ BuildResourceDescriptorHob (
|
||||
EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
|
||||
|
||||
Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
|
||||
ASSERT(Hob != NULL);
|
||||
ASSERT (Hob != NULL);
|
||||
|
||||
Hob->ResourceType = ResourceType;
|
||||
Hob->ResourceAttribute = ResourceAttribute;
|
||||
@ -195,7 +194,7 @@ GetNextHob (
|
||||
|
||||
ASSERT (HobStart != NULL);
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
//
|
||||
// Parse the HOB list until end of list or matching type is found.
|
||||
//
|
||||
@ -203,13 +202,13 @@ GetNextHob (
|
||||
if (Hob.Header->HobType == Type) {
|
||||
return Hob.Raw;
|
||||
}
|
||||
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns the first instance of a HOB type among the whole HOB list.
|
||||
|
||||
@ -233,7 +232,6 @@ GetFirstHob (
|
||||
return GetNextHob (Type, HobList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function searches the first instance of a HOB from the starting HOB pointer.
|
||||
Such HOB should satisfy two conditions:
|
||||
@ -262,17 +260,18 @@ GetNextGuidHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS GuidHob;
|
||||
|
||||
GuidHob.Raw = (UINT8 *) HobStart;
|
||||
GuidHob.Raw = (UINT8 *)HobStart;
|
||||
while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
|
||||
if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
|
||||
break;
|
||||
}
|
||||
|
||||
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
|
||||
}
|
||||
|
||||
return GuidHob.Raw;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function searches the first instance of a HOB among the whole HOB list.
|
||||
Such HOB should satisfy two conditions:
|
||||
@ -299,9 +298,6 @@ GetFirstGuidHob (
|
||||
return GetNextGuidHob (Guid, HobList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Builds a HOB for a loaded PE32 module.
|
||||
|
||||
@ -328,8 +324,10 @@ BuildModuleHob (
|
||||
{
|
||||
EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
|
||||
|
||||
ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||
((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
|
||||
ASSERT (
|
||||
((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));
|
||||
|
||||
@ -379,12 +377,11 @@ BuildGuidHob (
|
||||
//
|
||||
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
|
||||
|
||||
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
||||
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
|
||||
CopyGuid (&Hob->Name, Guid);
|
||||
return Hob + 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copies a data buffer to a newly-built HOB.
|
||||
|
||||
@ -422,7 +419,6 @@ BuildGuidDataHob (
|
||||
return CopyMem (HobData, Data, DataLength);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builds a Firmware Volume HOB.
|
||||
|
||||
@ -450,7 +446,6 @@ BuildFvHob (
|
||||
Hob->Length = Length;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builds a EFI_HOB_TYPE_FV2 HOB.
|
||||
|
||||
@ -529,7 +524,6 @@ BuildFv3Hob (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builds a HOB for the CPU.
|
||||
|
||||
@ -562,7 +556,6 @@ BuildCpuHob (
|
||||
ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Builds a HOB for the Stack.
|
||||
|
||||
@ -584,8 +577,10 @@ BuildStackHob (
|
||||
{
|
||||
EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
|
||||
|
||||
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||
((Length & (EFI_PAGE_SIZE - 1)) == 0));
|
||||
ASSERT (
|
||||
((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));
|
||||
|
||||
@ -600,7 +595,6 @@ BuildStackHob (
|
||||
ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update the Stack Hob if the stack has been moved
|
||||
|
||||
@ -636,12 +630,11 @@ UpdateStackHob (
|
||||
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length;
|
||||
break;
|
||||
}
|
||||
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Builds a HOB for the memory allocation.
|
||||
|
||||
@ -665,8 +658,10 @@ BuildMemoryAllocationHob (
|
||||
{
|
||||
EFI_HOB_MEMORY_ALLOCATION *Hob;
|
||||
|
||||
ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||
((Length & (EFI_PAGE_SIZE - 1)) == 0));
|
||||
ASSERT (
|
||||
((BaseAddress & (EFI_PAGE_SIZE - 1)) == 0) &&
|
||||
((Length & (EFI_PAGE_SIZE - 1)) == 0)
|
||||
);
|
||||
|
||||
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
|
||||
|
||||
|
@ -28,7 +28,7 @@ typedef struct {
|
||||
PCI_ROOT_BRIDGE *
|
||||
ScanForRootBridges (
|
||||
OUT UINTN *NumberOfRootBridges
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Scan for all root bridges from Universal Payload PciRootBridgeInfoHob
|
||||
@ -43,7 +43,7 @@ PCI_ROOT_BRIDGE *
|
||||
RetrieveRootBridgeInfoFromHob (
|
||||
IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,
|
||||
OUT UINTN *NumberOfRootBridges
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize a PCI_ROOT_BRIDGE structure.
|
||||
@ -99,7 +99,7 @@ InitRootBridge (
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,
|
||||
OUT PCI_ROOT_BRIDGE *RootBus
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize DevicePath for a PCI_ROOT_BRIDGE.
|
||||
@ -112,5 +112,6 @@ EFI_DEVICE_PATH_PROTOCOL *
|
||||
CreateRootBridgeDevicePath (
|
||||
IN UINT32 HID,
|
||||
IN UINT32 UID
|
||||
);
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -31,11 +31,11 @@ CB_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
|
||||
ACPI_DEVICE_PATH,
|
||||
ACPI_DP,
|
||||
{
|
||||
(UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
EISA_PNP_ID(0x0A03), // HID
|
||||
EISA_PNP_ID (0x0A03), // HID
|
||||
0 // UID
|
||||
},
|
||||
|
||||
@ -103,7 +103,7 @@ InitRootBridge (
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,
|
||||
OUT PCI_ROOT_BRIDGE *RootBus
|
||||
)
|
||||
)
|
||||
{
|
||||
CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
|
||||
|
||||
@ -130,18 +130,25 @@ InitRootBridge (
|
||||
|
||||
RootBus->NoExtendedConfigSpace = FALSE;
|
||||
|
||||
DevicePath = AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate),
|
||||
&mRootBridgeDevicePathTemplate);
|
||||
DevicePath = AllocateCopyPool (
|
||||
sizeof (mRootBridgeDevicePathTemplate),
|
||||
&mRootBridgeDevicePathTemplate
|
||||
);
|
||||
if (DevicePath == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DevicePath->AcpiDevicePath.UID = RootBusNumber;
|
||||
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",
|
||||
__FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber));
|
||||
__FUNCTION__,
|
||||
RootBusNumber,
|
||||
MaxSubBusNumber - RootBusNumber
|
||||
));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -156,11 +163,14 @@ EFI_DEVICE_PATH_PROTOCOL *
|
||||
CreateRootBridgeDevicePath (
|
||||
IN UINT32 HID,
|
||||
IN UINT32 UID
|
||||
)
|
||||
)
|
||||
{
|
||||
CB_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;
|
||||
DevicePath = AllocateCopyPool (sizeof (mRootBridgeDevicePathTemplate),
|
||||
&mRootBridgeDevicePathTemplate);
|
||||
|
||||
DevicePath = AllocateCopyPool (
|
||||
sizeof (mRootBridgeDevicePathTemplate),
|
||||
&mRootBridgeDevicePathTemplate
|
||||
);
|
||||
ASSERT (DevicePath != NULL);
|
||||
DevicePath->AcpiDevicePath.HID = HID;
|
||||
DevicePath->AcpiDevicePath.UID = UID;
|
||||
@ -180,29 +190,31 @@ PCI_ROOT_BRIDGE *
|
||||
EFIAPI
|
||||
PciHostBridgeGetRootBridges (
|
||||
UINTN *Count
|
||||
)
|
||||
)
|
||||
{
|
||||
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo;
|
||||
EFI_HOB_GUID_TYPE *GuidHob;
|
||||
UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
|
||||
|
||||
//
|
||||
// Find Universal Payload PCI Root Bridge Info hob
|
||||
//
|
||||
GuidHob = GetFirstGuidHob (&gUniversalPayloadPciRootBridgeInfoGuid);
|
||||
if (GuidHob != NULL) {
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
|
||||
if ((sizeof(UNIVERSAL_PAYLOAD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (GuidHob);
|
||||
if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) <= GET_GUID_HOB_DATA_SIZE (GuidHob)) && (GenericHeader->Length <= GET_GUID_HOB_DATA_SIZE (GuidHob))) {
|
||||
if ((GenericHeader->Revision == UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION) && (GenericHeader->Length >= sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES))) {
|
||||
//
|
||||
// UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES structure is used when Revision equals to UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES_REVISION
|
||||
//
|
||||
PciRootBridgeInfo = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GET_GUID_HOB_DATA (GuidHob);
|
||||
if (PciRootBridgeInfo->Count <= (GET_GUID_HOB_DATA_SIZE (GuidHob) - sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES)) / sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE)) {
|
||||
PciRootBridgeInfo = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GET_GUID_HOB_DATA (GuidHob);
|
||||
if (PciRootBridgeInfo->Count <= (GET_GUID_HOB_DATA_SIZE (GuidHob) - sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES)) / sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE)) {
|
||||
return RetrieveRootBridgeInfoFromHob (PciRootBridgeInfo, Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ScanForRootBridges (Count);
|
||||
}
|
||||
|
||||
@ -218,11 +230,12 @@ EFIAPI
|
||||
PciHostBridgeFreeRootBridges (
|
||||
PCI_ROOT_BRIDGE *Bridges,
|
||||
UINTN Count
|
||||
)
|
||||
)
|
||||
{
|
||||
if (Bridges == NULL && Count == 0) {
|
||||
if ((Bridges == NULL) && (Count == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ASSERT (Bridges != NULL && Count > 0);
|
||||
|
||||
do {
|
||||
@ -233,7 +246,6 @@ PciHostBridgeFreeRootBridges (
|
||||
FreePool (Bridges);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Inform the platform that the resource conflict happens.
|
||||
|
||||
@ -253,7 +265,7 @@ EFIAPI
|
||||
PciHostBridgeResourceConflict (
|
||||
EFI_HANDLE HostBridgeHandle,
|
||||
VOID *Configuration
|
||||
)
|
||||
)
|
||||
{
|
||||
//
|
||||
// coreboot UEFI Payload does not do PCI enumeration and should not call this
|
||||
|
@ -38,7 +38,7 @@ AdjustRootBridgeResource (
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
|
||||
)
|
||||
)
|
||||
{
|
||||
UINT64 Mask;
|
||||
|
||||
@ -63,9 +63,11 @@ AdjustRootBridgeResource (
|
||||
if (MemAbove4G->Base < Mem->Base) {
|
||||
Mem->Base = MemAbove4G->Base;
|
||||
}
|
||||
|
||||
if (MemAbove4G->Limit > Mem->Limit) {
|
||||
Mem->Limit = MemAbove4G->Limit;
|
||||
}
|
||||
|
||||
MemAbove4G->Base = MAX_UINT64;
|
||||
MemAbove4G->Limit = 0;
|
||||
}
|
||||
@ -74,9 +76,11 @@ AdjustRootBridgeResource (
|
||||
if (PMemAbove4G->Base < Mem->Base) {
|
||||
Mem->Base = PMemAbove4G->Base;
|
||||
}
|
||||
|
||||
if (PMemAbove4G->Limit > Mem->Limit) {
|
||||
Mem->Limit = PMemAbove4G->Limit;
|
||||
}
|
||||
|
||||
PMemAbove4G->Base = MAX_UINT64;
|
||||
PMemAbove4G->Limit = 0;
|
||||
}
|
||||
@ -113,7 +117,7 @@ PcatPciRootBridgeBarExisted (
|
||||
IN UINT64 Address,
|
||||
OUT UINT32 *OriginalValue,
|
||||
OUT UINT32 *Value
|
||||
)
|
||||
)
|
||||
{
|
||||
UINTN PciAddress;
|
||||
|
||||
@ -179,7 +183,7 @@ PcatPciRootBridgeParseBars (
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMem,
|
||||
IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G
|
||||
|
||||
)
|
||||
)
|
||||
{
|
||||
UINT32 OriginalValue;
|
||||
UINT32 Value;
|
||||
@ -196,11 +200,13 @@ PcatPciRootBridgeParseBars (
|
||||
for (Offset = BarOffsetBase; Offset < BarOffsetEnd; Offset += sizeof (UINT32)) {
|
||||
PcatPciRootBridgeBarExisted (
|
||||
PCI_LIB_ADDRESS (Bus, Device, Function, Offset),
|
||||
&OriginalValue, &Value
|
||||
&OriginalValue,
|
||||
&Value
|
||||
);
|
||||
if (Value == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((Value & BIT0) == BIT0) {
|
||||
//
|
||||
// IO Bar
|
||||
@ -212,12 +218,14 @@ PcatPciRootBridgeParseBars (
|
||||
if (!(Value & 0xFFFF0000)) {
|
||||
Length &= 0x0000FFFF;
|
||||
}
|
||||
|
||||
Limit = Base + Length - 1;
|
||||
|
||||
if ((Base > 0) && (Base < Limit)) {
|
||||
if (Io->Base > Base) {
|
||||
Io->Base = Base;
|
||||
}
|
||||
|
||||
if (Io->Limit < Limit) {
|
||||
Io->Limit = Limit;
|
||||
}
|
||||
@ -228,7 +236,6 @@ PcatPciRootBridgeParseBars (
|
||||
// Mem Bar
|
||||
//
|
||||
if ((Command & EFI_PCI_COMMAND_MEMORY_SPACE) != 0) {
|
||||
|
||||
Mask = 0xfffffff0;
|
||||
Base = OriginalValue & Mask;
|
||||
Length = Value & Mask;
|
||||
@ -255,8 +262,8 @@ PcatPciRootBridgeParseBars (
|
||||
&UpperValue
|
||||
);
|
||||
|
||||
Base = Base | LShiftU64 ((UINT64) OriginalUpperValue, 32);
|
||||
Length = Length | LShiftU64 ((UINT64) UpperValue, 32);
|
||||
Base = Base | LShiftU64 ((UINT64)OriginalUpperValue, 32);
|
||||
Length = Length | LShiftU64 ((UINT64)UpperValue, 32);
|
||||
if (Length != 0) {
|
||||
LowBit = LowBitSet64 (Length);
|
||||
Length = LShiftU64 (1ULL, LowBit);
|
||||
@ -274,6 +281,7 @@ PcatPciRootBridgeParseBars (
|
||||
if (MemAperture->Base > Base) {
|
||||
MemAperture->Base = Base;
|
||||
}
|
||||
|
||||
if (MemAperture->Limit < Limit) {
|
||||
MemAperture->Limit = Limit;
|
||||
}
|
||||
@ -293,7 +301,7 @@ PcatPciRootBridgeParseBars (
|
||||
PCI_ROOT_BRIDGE *
|
||||
ScanForRootBridges (
|
||||
OUT UINTN *NumberOfRootBridges
|
||||
)
|
||||
)
|
||||
{
|
||||
UINTN PrimaryBus;
|
||||
UINTN SubBus;
|
||||
@ -315,7 +323,6 @@ ScanForRootBridges (
|
||||
PCI_ROOT_BRIDGE *RootBridges;
|
||||
UINTN BarOffsetEnd;
|
||||
|
||||
|
||||
*NumberOfRootBridges = 0;
|
||||
RootBridges = NULL;
|
||||
|
||||
@ -338,9 +345,7 @@ ScanForRootBridges (
|
||||
// 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 (Function = 0; Function <= PCI_MAX_FUNC; Function++) {
|
||||
|
||||
//
|
||||
// Compute the PCI configuration address of the PCI device to probe
|
||||
//
|
||||
@ -407,16 +412,18 @@ ScanForRootBridges (
|
||||
// Get the I/O range that the PPB is decoding
|
||||
//
|
||||
Value = Pci.Bridge.IoBase & 0x0f;
|
||||
Base = ((UINT32) Pci.Bridge.IoBase & 0xf0) << 8;
|
||||
Limit = (((UINT32) Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
|
||||
Base = ((UINT32)Pci.Bridge.IoBase & 0xf0) << 8;
|
||||
Limit = (((UINT32)Pci.Bridge.IoLimit & 0xf0) << 8) | 0x0fff;
|
||||
if (Value == BIT0) {
|
||||
Base |= ((UINT32) Pci.Bridge.IoBaseUpper16 << 16);
|
||||
Limit |= ((UINT32) Pci.Bridge.IoLimitUpper16 << 16);
|
||||
Base |= ((UINT32)Pci.Bridge.IoBaseUpper16 << 16);
|
||||
Limit |= ((UINT32)Pci.Bridge.IoLimitUpper16 << 16);
|
||||
}
|
||||
|
||||
if ((Base > 0) && (Base < Limit)) {
|
||||
if (Io.Base > Base) {
|
||||
Io.Base = Base;
|
||||
}
|
||||
|
||||
if (Io.Limit < Limit) {
|
||||
Io.Limit = Limit;
|
||||
}
|
||||
@ -425,12 +432,13 @@ ScanForRootBridges (
|
||||
//
|
||||
// Get the Memory range that the PPB is decoding
|
||||
//
|
||||
Base = ((UINT32) Pci.Bridge.MemoryBase & 0xfff0) << 16;
|
||||
Limit = (((UINT32) Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
|
||||
Base = ((UINT32)Pci.Bridge.MemoryBase & 0xfff0) << 16;
|
||||
Limit = (((UINT32)Pci.Bridge.MemoryLimit & 0xfff0) << 16) | 0xfffff;
|
||||
if ((Base > 0) && (Base < Limit)) {
|
||||
if (Mem.Base > Base) {
|
||||
Mem.Base = Base;
|
||||
}
|
||||
|
||||
if (Mem.Limit < Limit) {
|
||||
Mem.Limit = Limit;
|
||||
}
|
||||
@ -440,8 +448,8 @@ ScanForRootBridges (
|
||||
// Get the Prefetchable Memory range that the PPB is decoding
|
||||
//
|
||||
Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;
|
||||
Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
|
||||
Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
|
||||
Base = ((UINT32)Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;
|
||||
Limit = (((UINT32)Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)
|
||||
<< 16) | 0xfffff;
|
||||
MemAperture = &PMem;
|
||||
if (Value == BIT0) {
|
||||
@ -449,10 +457,12 @@ ScanForRootBridges (
|
||||
Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);
|
||||
MemAperture = &PMemAbove4G;
|
||||
}
|
||||
|
||||
if ((Base > 0) && (Base < Limit)) {
|
||||
if (MemAperture->Base > Base) {
|
||||
MemAperture->Base = Base;
|
||||
}
|
||||
|
||||
if (MemAperture->Limit < Limit) {
|
||||
MemAperture->Limit = Limit;
|
||||
}
|
||||
@ -462,18 +472,22 @@ ScanForRootBridges (
|
||||
// Look at the PPB Configuration for legacy decoding attributes
|
||||
//
|
||||
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_16;
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO;
|
||||
}
|
||||
|
||||
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_MEMORY;
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_VGA_IO;
|
||||
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_IO_16;
|
||||
}
|
||||
@ -498,22 +512,30 @@ ScanForRootBridges (
|
||||
OFFSET_OF (PCI_TYPE00, Device.Bar),
|
||||
BarOffsetEnd,
|
||||
&Io,
|
||||
&Mem, &MemAbove4G,
|
||||
&PMem, &PMemAbove4G
|
||||
&Mem,
|
||||
&MemAbove4G,
|
||||
&PMem,
|
||||
&PMemAbove4G
|
||||
);
|
||||
|
||||
//
|
||||
// See if the PCI device is an IDE controller
|
||||
//
|
||||
if (IS_CLASS2 (&Pci, PCI_CLASS_MASS_STORAGE,
|
||||
PCI_CLASS_MASS_STORAGE_IDE)) {
|
||||
if (IS_CLASS2 (
|
||||
&Pci,
|
||||
PCI_CLASS_MASS_STORAGE,
|
||||
PCI_CLASS_MASS_STORAGE_IDE
|
||||
))
|
||||
{
|
||||
if (Pci.Hdr.ClassCode[0] & 0x80) {
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
|
||||
}
|
||||
|
||||
if (Pci.Hdr.ClassCode[0] & 0x01) {
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO;
|
||||
}
|
||||
|
||||
if (Pci.Hdr.ClassCode[0] & 0x04) {
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO;
|
||||
}
|
||||
@ -525,7 +547,8 @@ ScanForRootBridges (
|
||||
//
|
||||
if (IS_CLASS2 (&Pci, PCI_CLASS_OLD, PCI_CLASS_OLD_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_16;
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_VGA_MEMORY;
|
||||
@ -538,9 +561,10 @@ ScanForRootBridges (
|
||||
// or ISA_POSITIVE_DECODE Bridge device
|
||||
//
|
||||
if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {
|
||||
if (Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA ||
|
||||
Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA ||
|
||||
Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE) {
|
||||
if ((Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA) ||
|
||||
(Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_EISA) ||
|
||||
(Pci.Hdr.ClassCode[1] == PCI_CLASS_BRIDGE_ISA_PDECODE))
|
||||
{
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO;
|
||||
Attributes |= EFI_PCI_ATTRIBUTE_ISA_IO_16;
|
||||
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
|
||||
// of this PCI device
|
||||
//
|
||||
if (Function == 0 && !IS_PCI_MULTI_FUNC (&Pci)) {
|
||||
if ((Function == 0) && !IS_PCI_MULTI_FUNC (&Pci)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -572,9 +596,16 @@ ScanForRootBridges (
|
||||
AdjustRootBridgeResource (&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G);
|
||||
|
||||
InitRootBridge (
|
||||
Attributes, Attributes, 0,
|
||||
(UINT8) PrimaryBus, (UINT8) SubBus,
|
||||
&Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G,
|
||||
Attributes,
|
||||
Attributes,
|
||||
0,
|
||||
(UINT8)PrimaryBus,
|
||||
(UINT8)SubBus,
|
||||
&Io,
|
||||
&Mem,
|
||||
&MemAbove4G,
|
||||
&PMem,
|
||||
&PMemAbove4G,
|
||||
&RootBridges[*NumberOfRootBridges]
|
||||
);
|
||||
RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;
|
||||
@ -601,7 +632,7 @@ PCI_ROOT_BRIDGE *
|
||||
RetrieveRootBridgeInfoFromHob (
|
||||
IN UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridgeInfo,
|
||||
OUT UINTN *NumberOfRootBridges
|
||||
)
|
||||
)
|
||||
{
|
||||
PCI_ROOT_BRIDGE *PciRootBridges;
|
||||
UINTN Size;
|
||||
@ -612,15 +643,18 @@ RetrieveRootBridgeInfoFromHob (
|
||||
if (PciRootBridgeInfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (PciRootBridgeInfo->Count == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Size = PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE);
|
||||
PciRootBridges = (PCI_ROOT_BRIDGE *) AllocatePool (Size);
|
||||
PciRootBridges = (PCI_ROOT_BRIDGE *)AllocatePool (Size);
|
||||
ASSERT (PciRootBridges != NULL);
|
||||
if (PciRootBridges == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMem (PciRootBridges, PciRootBridgeInfo->Count * sizeof (PCI_ROOT_BRIDGE));
|
||||
|
||||
//
|
||||
@ -634,13 +668,13 @@ RetrieveRootBridgeInfoFromHob (
|
||||
PciRootBridges[Index].NoExtendedConfigSpace = PciRootBridgeInfo->RootBridge[Index].NoExtendedConfigSpace;
|
||||
PciRootBridges[Index].ResourceAssigned = PciRootBridgeInfo->ResourceAssigned;
|
||||
PciRootBridges[Index].AllocationAttributes = PciRootBridgeInfo->RootBridge[Index].AllocationAttributes;
|
||||
PciRootBridges[Index].DevicePath = CreateRootBridgeDevicePath(PciRootBridgeInfo->RootBridge[Index].HID, PciRootBridgeInfo->RootBridge[Index].UID);
|
||||
CopyMem(&PciRootBridges[Index].Bus, &PciRootBridgeInfo->RootBridge[Index].Bus, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem(&PciRootBridges[Index].Io, &PciRootBridgeInfo->RootBridge[Index].Io, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem(&PciRootBridges[Index].Mem, &PciRootBridgeInfo->RootBridge[Index].Mem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem(&PciRootBridges[Index].MemAbove4G, &PciRootBridgeInfo->RootBridge[Index].MemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem(&PciRootBridges[Index].PMem, &PciRootBridgeInfo->RootBridge[Index].PMem, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem(&PciRootBridges[Index].PMemAbove4G, &PciRootBridgeInfo->RootBridge[Index].PMemAbove4G, sizeof(UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
PciRootBridges[Index].DevicePath = CreateRootBridgeDevicePath (PciRootBridgeInfo->RootBridge[Index].HID, PciRootBridgeInfo->RootBridge[Index].UID);
|
||||
CopyMem (&PciRootBridges[Index].Bus, &PciRootBridgeInfo->RootBridge[Index].Bus, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem (&PciRootBridges[Index].Io, &PciRootBridgeInfo->RootBridge[Index].Io, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem (&PciRootBridges[Index].Mem, &PciRootBridgeInfo->RootBridge[Index].Mem, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem (&PciRootBridges[Index].MemAbove4G, &PciRootBridgeInfo->RootBridge[Index].MemAbove4G, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem (&PciRootBridges[Index].PMem, &PciRootBridgeInfo->RootBridge[Index].PMem, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
CopyMem (&PciRootBridges[Index].PMemAbove4G, &PciRootBridgeInfo->RootBridge[Index].PMemAbove4G, sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE_APERTURE));
|
||||
}
|
||||
|
||||
*NumberOfRootBridges = PciRootBridgeInfo->Count;
|
||||
|
@ -51,9 +51,10 @@ GetPciSegmentInfo (
|
||||
GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
|
||||
ASSERT (GuidHob != NULL);
|
||||
|
||||
AcpiBoardInfo = (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||
AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||
mPciSegment0.BaseAddress = AcpiBoardInfo->PcieBaseAddress;
|
||||
}
|
||||
|
||||
*Count = 1;
|
||||
return &mPciSegment0;
|
||||
}
|
||||
|
@ -28,18 +28,18 @@ InstallReadyToLock (
|
||||
EFI_HANDLE Handle;
|
||||
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
|
||||
|
||||
DEBUG((DEBUG_INFO,"InstallReadyToLock entering......\n"));
|
||||
DEBUG ((DEBUG_INFO, "InstallReadyToLock entering......\n"));
|
||||
//
|
||||
// Inform the SMM infrastructure that we're entering BDS and may run 3rd party code hereafter
|
||||
// Since PI1.2.1, we need signal EndOfDxe as ExitPmAuth
|
||||
//
|
||||
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
|
||||
DEBUG((DEBUG_INFO,"All EndOfDxe callbacks have returned successfully\n"));
|
||||
DEBUG ((DEBUG_INFO, "All EndOfDxe callbacks have returned successfully\n"));
|
||||
|
||||
//
|
||||
// Install DxeSmmReadyToLock protocol in order to lock SMM
|
||||
//
|
||||
Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **) &SmmAccess);
|
||||
Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallProtocolInterface (
|
||||
@ -51,7 +51,7 @@ InstallReadyToLock (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
DEBUG((DEBUG_INFO,"InstallReadyToLock end\n"));
|
||||
DEBUG ((DEBUG_INFO, "InstallReadyToLock end\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ PlatformFindLoadOption (
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Key,
|
||||
IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *Array,
|
||||
IN UINTN Count
|
||||
)
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
|
||||
@ -83,8 +83,9 @@ PlatformFindLoadOption (
|
||||
(StrCmp (Key->Description, Array[Index].Description) == 0) &&
|
||||
(CompareMem (Key->FilePath, Array[Index].FilePath, GetDevicePathSize (Key->FilePath)) == 0) &&
|
||||
(Key->OptionalDataSize == Array[Index].OptionalDataSize) &&
|
||||
(CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0)) {
|
||||
return (INTN) Index;
|
||||
(CompareMem (Key->OptionalData, Array[Index].OptionalData, Key->OptionalDataSize) == 0))
|
||||
{
|
||||
return (INTN)Index;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +104,7 @@ PlatformRegisterFvBootOption (
|
||||
EFI_GUID *FileGuid,
|
||||
CHAR16 *Description,
|
||||
UINT32 Attributes
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN OptionIndex;
|
||||
@ -114,13 +115,13 @@ PlatformRegisterFvBootOption (
|
||||
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
|
||||
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &LoadedImage);
|
||||
Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **)&LoadedImage);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
|
||||
DevicePath = AppendDevicePathNode (
|
||||
DevicePathFromHandle (LoadedImage->DeviceHandle),
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &FileNode
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&FileNode
|
||||
);
|
||||
|
||||
Status = EfiBootManagerInitializeLoadOption (
|
||||
@ -139,9 +140,10 @@ PlatformRegisterFvBootOption (
|
||||
OptionIndex = PlatformFindLoadOption (&NewOption, BootOptions, BootOptionCount);
|
||||
|
||||
if (OptionIndex == -1) {
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN) -1);
|
||||
Status = EfiBootManagerAddLoadOptionVariable (&NewOption, (UINTN)-1);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
EfiBootManagerFreeLoadOption (&NewOption);
|
||||
EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
|
||||
}
|
||||
@ -159,7 +161,7 @@ VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerBeforeConsole (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_INPUT_KEY Enter;
|
||||
EFI_INPUT_KEY F2;
|
||||
@ -167,12 +169,13 @@ PlatformBootManagerBeforeConsole (
|
||||
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateProtocol (&gUniversalPayloadPlatformBootManagerOverrideProtocolGuid, NULL, (VOID **) &mUniversalPayloadPlatformBootManagerOverrideInstance);
|
||||
Status = gBS->LocateProtocol (&gUniversalPayloadPlatformBootManagerOverrideProtocolGuid, NULL, (VOID **)&mUniversalPayloadPlatformBootManagerOverrideInstance);
|
||||
if (EFI_ERROR (Status)) {
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;
|
||||
}
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->BeforeConsole();
|
||||
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->BeforeConsole ();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -189,7 +192,7 @@ PlatformBootManagerBeforeConsole (
|
||||
F2.ScanCode = SCAN_F2;
|
||||
F2.UnicodeChar = CHAR_NULL;
|
||||
EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &F2, NULL);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &F2, NULL);
|
||||
|
||||
//
|
||||
// Also add Down key to Boot Manager Menu since some serial terminals don't support F2 key.
|
||||
@ -197,7 +200,7 @@ PlatformBootManagerBeforeConsole (
|
||||
Down.ScanCode = SCAN_DOWN;
|
||||
Down.UnicodeChar = CHAR_NULL;
|
||||
EfiBootManagerGetBootManagerMenu (&BootOption);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16) BootOption.OptionNumber, 0, &Down, NULL);
|
||||
EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &Down, NULL);
|
||||
|
||||
//
|
||||
// Install ready to lock.
|
||||
@ -227,15 +230,16 @@ VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerAfterConsole (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL White;
|
||||
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->AfterConsole();
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->AfterConsole ();
|
||||
return;
|
||||
}
|
||||
|
||||
Black.Blue = Black.Green = Black.Red = Black.Reserved = 0;
|
||||
White.Blue = White.Green = White.Red = White.Reserved = 0xFF;
|
||||
|
||||
@ -253,7 +257,6 @@ PlatformBootManagerAfterConsole (
|
||||
L"ENTER to boot directly.\n"
|
||||
L"\n"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,11 +268,12 @@ VOID
|
||||
EFIAPI
|
||||
PlatformBootManagerWaitCallback (
|
||||
UINT16 TimeoutRemain
|
||||
)
|
||||
)
|
||||
{
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->WaitCallback (TimeoutRemain);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -286,9 +290,10 @@ PlatformBootManagerUnableToBoot (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL){
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot();
|
||||
if (mUniversalPayloadPlatformBootManagerOverrideInstance != NULL) {
|
||||
mUniversalPayloadPlatformBootManagerOverrideInstance->UnableToBoot ();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -307,7 +312,7 @@ EFIAPI
|
||||
PlatformBootManagerLibConstructor (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Size;
|
||||
@ -324,15 +329,17 @@ PlatformBootManagerLibConstructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (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;
|
||||
}
|
||||
|
||||
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)) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
Size = sizeof (BootManagerMenuFile->FileName);
|
||||
Status = PcdSetPtrS (PcdBootManagerMenuFile, &Size, &BootManagerMenuFile->FileName);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
@ -92,7 +92,7 @@ extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
|
||||
EFI_STATUS
|
||||
PlatformBootManagerEnableQuietBoot (
|
||||
IN EFI_GUID *LogoFile
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Use SystemTable Conout to turn on video based Simple Text Out consoles. The
|
||||
@ -104,7 +104,7 @@ PlatformBootManagerEnableQuietBoot (
|
||||
EFI_STATUS
|
||||
PlatformBootManagerDisableQuietBoot (
|
||||
VOID
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Show progress bar with title above it. It only works in Graphics mode.
|
||||
@ -127,6 +127,6 @@ PlatformBootManagerShowProgress (
|
||||
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL ProgressColor,
|
||||
IN UINTN Progress,
|
||||
IN UINTN PreviousValue
|
||||
);
|
||||
);
|
||||
|
||||
#endif // _PLATFORM_BOOT_MANAGER_H
|
||||
|
@ -105,7 +105,7 @@ PLATFORM_ROOT_BRIDGE_DEVICE_PATH gPlatformRootBridge0 = {
|
||||
};
|
||||
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformRootBridges[] = {
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gPlatformRootBridge0,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gPlatformRootBridge0,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -125,7 +125,7 @@ BOOLEAN mDetectVgaOnly;
|
||||
EFI_STATUS
|
||||
PrepareLpcBridgeDevicePath (
|
||||
IN EFI_HANDLE DeviceHandle
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
@ -135,11 +135,12 @@ PrepareLpcBridgeDevicePath (
|
||||
Status = gBS->HandleProtocol (
|
||||
DeviceHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID*)&DevicePath
|
||||
(VOID *)&DevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
TempDevicePath = DevicePath;
|
||||
|
||||
//
|
||||
@ -177,7 +178,7 @@ EFI_STATUS
|
||||
GetGopDevicePath (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *PciDevicePath,
|
||||
OUT EFI_DEVICE_PATH_PROTOCOL **GopDevicePath
|
||||
)
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
@ -187,7 +188,7 @@ GetGopDevicePath (
|
||||
UINTN GopHandleCount;
|
||||
EFI_HANDLE *GopHandleBuffer;
|
||||
|
||||
if (PciDevicePath == NULL || GopDevicePath == NULL) {
|
||||
if ((PciDevicePath == NULL) || (GopDevicePath == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@ -220,15 +221,17 @@ GetGopDevicePath (
|
||||
// Add all the child handles as possible Console Device
|
||||
//
|
||||
for (Index = 0; Index < GopHandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID*)&TempDevicePath);
|
||||
Status = gBS->HandleProtocol (GopHandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID *)&TempDevicePath);
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CompareMem (
|
||||
PciDevicePath,
|
||||
TempDevicePath,
|
||||
GetDevicePathSize (PciDevicePath) - END_DEVICE_PATH_LENGTH
|
||||
) == 0) {
|
||||
) == 0)
|
||||
{
|
||||
//
|
||||
// In current implementation, we only enable one of the child handles
|
||||
// as console device, i.e. sotre one of the child handle's device
|
||||
@ -245,6 +248,7 @@ GetGopDevicePath (
|
||||
EfiBootManagerUpdateConsoleVariable (ConOut, TempDevicePath, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
gBS->FreePool (GopHandleBuffer);
|
||||
}
|
||||
|
||||
@ -263,7 +267,7 @@ GetGopDevicePath (
|
||||
EFI_STATUS
|
||||
PreparePciVgaDevicePath (
|
||||
IN EFI_HANDLE DeviceHandle
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
@ -273,7 +277,7 @@ PreparePciVgaDevicePath (
|
||||
Status = gBS->HandleProtocol (
|
||||
DeviceHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID*)&DevicePath
|
||||
(VOID *)&DevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -299,7 +303,7 @@ PreparePciVgaDevicePath (
|
||||
EFI_STATUS
|
||||
PreparePciSerialDevicePath (
|
||||
IN EFI_HANDLE DeviceHandle
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
@ -308,7 +312,7 @@ PreparePciSerialDevicePath (
|
||||
Status = gBS->HandleProtocol (
|
||||
DeviceHandle,
|
||||
&gEfiDevicePathProtocolGuid,
|
||||
(VOID*)&DevicePath
|
||||
(VOID *)&DevicePath
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -324,7 +328,6 @@ PreparePciSerialDevicePath (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
For every PCI instance execute a callback function.
|
||||
|
||||
@ -341,7 +344,7 @@ VisitAllInstancesOfProtocol (
|
||||
IN EFI_GUID *Id,
|
||||
IN PROTOCOL_INSTANCE_CALLBACK CallBackFunction,
|
||||
IN VOID *Context
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN HandleCount;
|
||||
@ -371,7 +374,7 @@ VisitAllInstancesOfProtocol (
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = (*CallBackFunction) (
|
||||
Status = (*CallBackFunction)(
|
||||
HandleBuffer[Index],
|
||||
Instance,
|
||||
Context
|
||||
@ -383,7 +386,6 @@ VisitAllInstancesOfProtocol (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
For every PCI instance execute a callback function.
|
||||
|
||||
@ -400,13 +402,13 @@ VisitingAPciInstance (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN VOID *Instance,
|
||||
IN VOID *Context
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||
PCI_TYPE00 Pci;
|
||||
|
||||
PciIo = (EFI_PCI_IO_PROTOCOL*) Instance;
|
||||
PciIo = (EFI_PCI_IO_PROTOCOL *)Instance;
|
||||
|
||||
//
|
||||
// Check for all PCI device
|
||||
@ -422,15 +424,13 @@ VisitingAPciInstance (
|
||||
return Status;
|
||||
}
|
||||
|
||||
return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN) Context) (
|
||||
return (*(VISIT_PCI_INSTANCE_CALLBACK)(UINTN)Context)(
|
||||
Handle,
|
||||
PciIo,
|
||||
&Pci
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
For every PCI instance execute a callback function.
|
||||
|
||||
@ -443,16 +443,15 @@ EFI_STATUS
|
||||
EFIAPI
|
||||
VisitAllPciInstances (
|
||||
IN VISIT_PCI_INSTANCE_CALLBACK CallBackFunction
|
||||
)
|
||||
)
|
||||
{
|
||||
return VisitAllInstancesOfProtocol (
|
||||
&gEfiPciIoProtocolGuid,
|
||||
VisitingAPciInstance,
|
||||
(VOID*)(UINTN) CallBackFunction
|
||||
(VOID *)(UINTN)CallBackFunction
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Do platform specific PCI Device check and add them to
|
||||
ConOut, ConIn, ErrOut.
|
||||
@ -471,7 +470,7 @@ DetectAndPreparePlatformPciDevicePath (
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||
IN PCI_TYPE00 *Pci
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
@ -491,7 +490,8 @@ DetectAndPreparePlatformPciDevicePath (
|
||||
((IS_PCI_ISA_PDECODE (Pci)) &&
|
||||
(Pci->Hdr.VendorId == 0x8086)
|
||||
)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Add IsaKeyboard to ConIn,
|
||||
// add IsaSerial to ConOut, ConIn, ErrOut
|
||||
@ -500,6 +500,7 @@ DetectAndPreparePlatformPciDevicePath (
|
||||
PrepareLpcBridgeDevicePath (Handle);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
//
|
||||
// Here we decide which Serial device to enable in PCI bus
|
||||
//
|
||||
@ -528,7 +529,6 @@ DetectAndPreparePlatformPciDevicePath (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
|
||||
|
||||
@ -541,20 +541,19 @@ DetectAndPreparePlatformPciDevicePath (
|
||||
EFI_STATUS
|
||||
DetectAndPreparePlatformPciDevicePaths (
|
||||
BOOLEAN DetectVgaOnly
|
||||
)
|
||||
)
|
||||
{
|
||||
mDetectVgaOnly = DetectVgaOnly;
|
||||
|
||||
EfiBootManagerUpdateConsoleVariable (
|
||||
ConIn,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gUsbClassKeyboardDevicePath,
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gUsbClassKeyboardDevicePath,
|
||||
NULL
|
||||
);
|
||||
|
||||
return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The function will connect root bridge
|
||||
|
||||
@ -564,7 +563,7 @@ DetectAndPreparePlatformPciDevicePaths (
|
||||
EFI_STATUS
|
||||
ConnectRootBridge (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE RootHandle;
|
||||
@ -598,7 +597,7 @@ VOID
|
||||
EFIAPI
|
||||
PlatformConsoleInit (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
gUartDeviceNode.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
|
||||
gUartDeviceNode.DataBits = PcdGet8 (PcdUartDefaultDataBits);
|
||||
@ -611,5 +610,4 @@ PlatformConsoleInit (
|
||||
// Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
|
||||
//
|
||||
DetectAndPreparePlatformPciDevicePaths (FALSE);
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ EFI_STATUS
|
||||
IN EFI_HANDLE Handle,
|
||||
IN VOID *Instance,
|
||||
IN VOID *Context
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
@param[in] Handle - Handle of PCI device instance
|
||||
@ -54,7 +54,7 @@ EFI_STATUS
|
||||
IN EFI_HANDLE Handle,
|
||||
IN EFI_PCI_IO_PROTOCOL *PciIo,
|
||||
IN PCI_TYPE00 *Pci
|
||||
);
|
||||
);
|
||||
|
||||
/**
|
||||
Platform console init. Include the platform firmware vendor, revision
|
||||
@ -65,6 +65,6 @@ VOID
|
||||
EFIAPI
|
||||
PlatformConsoleInit (
|
||||
VOID
|
||||
);
|
||||
);
|
||||
|
||||
#endif
|
||||
|
@ -18,15 +18,14 @@ GLOBAL_REMOVE_IF_UNREFERENCED PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath = {
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_USB_CLASS_DP,
|
||||
{
|
||||
(UINT8) (sizeof (USB_CLASS_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
|
||||
(UINT8)(sizeof (USB_CLASS_DEVICE_PATH)),
|
||||
(UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0xffff, // VendorId
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
|
||||
|
||||
/** Library Constructor
|
||||
|
||||
@retval RETURN_SUCCESS Success.
|
||||
@ -57,13 +56,13 @@ PlatformHookSerialPortInitialize (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA (GuidHob);
|
||||
GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (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;
|
||||
}
|
||||
|
||||
if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
|
||||
SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||
SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||
if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
|
||||
//
|
||||
// Return if can't find the Serial Port Info Hob with enough length
|
||||
@ -75,14 +74,17 @@ PlatformHookSerialPortInitialize (
|
||||
if (RETURN_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
|
||||
if (RETURN_ERROR (Status)) {
|
||||
return Status;
|
||||
|
@ -26,4 +26,3 @@ ParsePlatformInfo (
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ ResetShutdown (
|
||||
//
|
||||
// Clear Power Button Status
|
||||
//
|
||||
IoWrite16((UINTN) mAcpiBoardInfo.PmEvtBase, BIT8);
|
||||
IoWrite16 ((UINTN)mAcpiBoardInfo.PmEvtBase, BIT8);
|
||||
|
||||
//
|
||||
// Transform system into S5 sleep state
|
||||
//
|
||||
PmCtrlReg = (UINTN)mAcpiBoardInfo.PmCtrlRegBase;
|
||||
IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));
|
||||
IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16)(7 << 10));
|
||||
IoOr16 (PmCtrlReg, BIT13);
|
||||
CpuDeadLoop ();
|
||||
|
||||
|
@ -35,17 +35,17 @@ GetParameterBase (
|
||||
{
|
||||
EFI_HOB_HANDOFF_INFO_TABLE *HandoffTable;
|
||||
|
||||
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) &&
|
||||
(HandoffTable->Header.HobLength == sizeof (EFI_HOB_HANDOFF_INFO_TABLE)) &&
|
||||
(HandoffTable->Header.Reserved == 0)) {
|
||||
(HandoffTable->Header.Reserved == 0))
|
||||
{
|
||||
return (VOID *)HandoffTable;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function retrieves a GUIDed HOB data from Slim Bootloader.
|
||||
|
||||
@ -96,7 +96,7 @@ ParseMemoryInfo (
|
||||
MEMORY_MAP_INFO *MemoryMapInfo;
|
||||
UINTN Idx;
|
||||
|
||||
MemoryMapInfo = (MEMORY_MAP_INFO *) GetGuidHobDataFromSbl (&gLoaderMemoryMapInfoGuid);
|
||||
MemoryMapInfo = (MEMORY_MAP_INFO *)GetGuidHobDataFromSbl (&gLoaderMemoryMapInfoGuid);
|
||||
if (MemoryMapInfo == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return RETURN_NOT_FOUND;
|
||||
@ -137,7 +137,6 @@ ParseSmbiosTable (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Acquire ACPI table from slim bootloader.
|
||||
|
||||
@ -183,7 +182,7 @@ ParseSerialInfo (
|
||||
{
|
||||
SERIAL_PORT_INFO *BlSerialInfo;
|
||||
|
||||
BlSerialInfo = (SERIAL_PORT_INFO *) GetGuidHobDataFromSbl (&gUefiSerialPortInfoGuid);
|
||||
BlSerialInfo = (SERIAL_PORT_INFO *)GetGuidHobDataFromSbl (&gUefiSerialPortInfoGuid);
|
||||
if (BlSerialInfo == NULL) {
|
||||
ASSERT (FALSE);
|
||||
return RETURN_NOT_FOUND;
|
||||
@ -194,7 +193,6 @@ ParseSerialInfo (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find the video frame buffer information
|
||||
|
||||
@ -212,7 +210,7 @@ ParseGfxInfo (
|
||||
{
|
||||
EFI_PEI_GRAPHICS_INFO_HOB *BlGfxInfo;
|
||||
|
||||
BlGfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsInfoHobGuid);
|
||||
BlGfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *)GetGuidHobDataFromSbl (&gEfiGraphicsInfoHobGuid);
|
||||
if (BlGfxInfo == NULL) {
|
||||
return RETURN_NOT_FOUND;
|
||||
}
|
||||
@ -239,7 +237,7 @@ ParseGfxDeviceInfo (
|
||||
{
|
||||
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *BlGfxDeviceInfo;
|
||||
|
||||
BlGfxDeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsDeviceInfoHobGuid);
|
||||
BlGfxDeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *)GetGuidHobDataFromSbl (&gEfiGraphicsDeviceInfoHobGuid);
|
||||
if (BlGfxDeviceInfo == NULL) {
|
||||
return RETURN_NOT_FOUND;
|
||||
}
|
||||
@ -268,7 +266,7 @@ ParseMiscInfo (
|
||||
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PldRootBridgesHob;
|
||||
|
||||
Status = RETURN_NOT_FOUND;
|
||||
BlRootBridgesHob = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GetGuidHobDataFromSbl (
|
||||
BlRootBridgesHob = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GetGuidHobDataFromSbl (
|
||||
&gUniversalPayloadPciRootBridgeInfoGuid
|
||||
);
|
||||
if (BlRootBridgesHob != NULL) {
|
||||
@ -291,4 +289,3 @@ ParseMiscInfo (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,6 @@ ReleaseSpiBar0 (
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
This function is to enable/disable BIOS Write Protect in SMM phase.
|
||||
|
||||
@ -50,17 +48,17 @@ CpuSmmDisableBiosWriteProtect (
|
||||
{
|
||||
UINT32 Data32;
|
||||
|
||||
if(EnableSmmSts){
|
||||
if (EnableSmmSts) {
|
||||
//
|
||||
// Disable BIOS Write Protect in SMM phase.
|
||||
//
|
||||
Data32 = MmioRead32 ((UINTN) (0xFED30880)) | (UINT32) (BIT0);
|
||||
Data32 = MmioRead32 ((UINTN)(0xFED30880)) | (UINT32)(BIT0);
|
||||
AsmWriteMsr32 (0x000001FE, Data32);
|
||||
} else {
|
||||
//
|
||||
// Enable BIOS Write Protect in SMM phase
|
||||
//
|
||||
Data32 = MmioRead32 ((UINTN) (0xFED30880)) & (UINT32) (~BIT0);
|
||||
Data32 = MmioRead32 ((UINTN)(0xFED30880)) & (UINT32)(~BIT0);
|
||||
AsmWriteMsr32 (0x000001FE, Data32);
|
||||
}
|
||||
|
||||
@ -70,7 +68,6 @@ CpuSmmDisableBiosWriteProtect (
|
||||
Data32 = MmioRead32 (0xFED30880);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function is a hook for Spi to disable BIOS Write Protect.
|
||||
|
||||
@ -88,7 +85,6 @@ DisableBiosWriteProtect (
|
||||
IN UINT8 CpuSmmBwp
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Write clear BC_SYNC_SS prior to change WPD from 0 to 1.
|
||||
//
|
||||
@ -120,11 +116,10 @@ EnableBiosWriteProtect (
|
||||
IN UINT8 CpuSmmBwp
|
||||
)
|
||||
{
|
||||
|
||||
//
|
||||
// Disable the access to the BIOS space for write cycles
|
||||
//
|
||||
MmioAnd8 (PchSpiBase + R_SPI_BCR, (UINT8) (~B_SPI_BCR_BIOSWE));
|
||||
MmioAnd8 (PchSpiBase + R_SPI_BCR, (UINT8)(~B_SPI_BCR_BIOSWE));
|
||||
|
||||
if (CpuSmmBwp != 0) {
|
||||
CpuSmmDisableBiosWriteProtect (FALSE);
|
||||
@ -149,9 +144,11 @@ SaveAndDisableSpiPrefetchCache (
|
||||
|
||||
BiosCtlSave = MmioRead8 (PchSpiBase + R_SPI_BCR) & B_SPI_BCR_SRC;
|
||||
|
||||
MmioAndThenOr32 (PchSpiBase + R_SPI_BCR, \
|
||||
(UINT32) (~B_SPI_BCR_SRC), \
|
||||
(UINT32) (V_SPI_BCR_SRC_PREF_DIS_CACHE_DIS << B_SPI_BCR_SRC));
|
||||
MmioAndThenOr32 (
|
||||
PchSpiBase + R_SPI_BCR, \
|
||||
(UINT32)(~B_SPI_BCR_SRC), \
|
||||
(UINT32)(V_SPI_BCR_SRC_PREF_DIS_CACHE_DIS << B_SPI_BCR_SRC)
|
||||
);
|
||||
|
||||
return BiosCtlSave;
|
||||
}
|
||||
|
@ -38,16 +38,14 @@
|
||||
#define B_SPI_HSFS_FCERR BIT1 ///< Flash Cycle Error
|
||||
#define B_SPI_HSFS_FDONE BIT0 ///< Flash Cycle Done
|
||||
|
||||
|
||||
#define R_SPI_FADDR 0x08 ///< SPI Flash Address
|
||||
#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_FRAP 0x50 ///< SPI Flash Regions Access Permissions Register
|
||||
#define B_SPI_FRAP_BRWA_PLATFORM BIT12 //< Region write access for Region4 PlatformData
|
||||
#define B_SPI_FRAP_BRWA_GBE BIT11 //< Region write access for Region3 GbE
|
||||
#define B_SPI_FRAP_BRWA_PLATFORM BIT12 // < Region write access for Region4 PlatformData
|
||||
#define B_SPI_FRAP_BRWA_GBE BIT11 // < Region write access for Region3 GbE
|
||||
#define B_SPI_FRAP_BRWA_SEC BIT10 ///< Region Write Access for Region2 SEC
|
||||
#define B_SPI_FRAP_BRWA_BIOS BIT9 ///< Region Write Access for Region1 BIOS
|
||||
#define B_SPI_FRAP_BRWA_FLASHD BIT8 ///< Region Write Access for Region0 Flash Descriptor
|
||||
@ -57,7 +55,6 @@
|
||||
#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 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 N_SPI_FREG0_LIMIT 4 ///< Bit 30:16 identifies address bits [26:12]
|
||||
@ -72,15 +69,15 @@
|
||||
|
||||
#define R_SPI_FREG2_SEC 0x5C ///< Flash Region 2 (SEC) (32bits)
|
||||
#define B_SPI_FREG2_LIMIT_MASK 0x7FFF0000 ///< Size, [30:16] here represents limit[26:12]
|
||||
#define N_SPI_FREG2_LIMIT 4 //< Bit 30:16 identifies address bits [26:12]
|
||||
#define N_SPI_FREG2_LIMIT 4 // < Bit 30:16 identifies address bits [26:12]
|
||||
#define B_SPI_FREG2_BASE_MASK 0x00007FFF ///< Base, [14:0] here represents base [26:12]
|
||||
#define N_SPI_FREG2_BASE 12 //< Bit 14:0 identifies address bits [26:2]
|
||||
#define N_SPI_FREG2_BASE 12 // < Bit 14:0 identifies address bits [26:2]
|
||||
|
||||
#define R_SPI_FREG3_GBE 0x60 //< Flash Region 3(GbE)(32bits)
|
||||
#define R_SPI_FREG3_GBE 0x60 // < Flash Region 3(GbE)(32bits)
|
||||
#define B_SPI_FREG3_LIMIT_MASK 0x7FFF0000 ///< Size, [30:16] here represents limit[26:12]
|
||||
#define N_SPI_FREG3_LIMIT 4 //< Bit 30:16 identifies address bits [26:12]
|
||||
#define N_SPI_FREG3_LIMIT 4 // < Bit 30:16 identifies address bits [26:12]
|
||||
#define B_SPI_FREG3_BASE_MASK 0x00007FFF ///< Base, [14:0] here represents base [26:12]
|
||||
#define N_SPI_FREG3_BASE 12 //< Bit 14:0 identifies address bits [26:2]
|
||||
#define N_SPI_FREG3_BASE 12 // < Bit 14:0 identifies address bits [26:2]
|
||||
|
||||
#define R_SPI_FREG4_PLATFORM_DATA 0x64 ///< Flash Region 4 (Platform Data) (32bits)
|
||||
#define B_SPI_FREG4_LIMIT_MASK 0x7FFF0000 ///< Size, [30:16] here represents limit[26:12]
|
||||
@ -88,14 +85,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 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 N_SPI_FREGX_LIMIT 16 ///< Region limit bit 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 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 V_SPI_FDOC_FDSS_FSDM 0x0000 ///< Flash Signature and Descriptor Map
|
||||
@ -104,26 +99,22 @@
|
||||
|
||||
#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 B_SPI_LVSCC_EO_64K BIT29 ///<< 64k Erase valid (EO_64k_valid)
|
||||
#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 R_SPI_UVSCC 0xC8 ///< Vendor Specific Component Capabilities for Component 1 (32 bits)
|
||||
|
||||
|
||||
#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 R_SPI_FDBAR_FLASH_MAP1 0x18 ///< Flash MAP 1
|
||||
#define B_SPI_FDBAR_FPSBA 0x00FF0000 ///< Flash Strap Base Address
|
||||
|
||||
|
||||
//
|
||||
// Flash Component Base Address (FCBA) from Flash Region 0
|
||||
//
|
||||
#define R_SPI_FCBA_FLCOMP 0x00 ///< Flash Components Register
|
||||
#define B_SPI_FLCOMP_COMP1_MASK 0x0F ///< Flash Component 1 Density
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -73,7 +73,6 @@ typedef struct {
|
||||
UINT32 Component1StartAddr;
|
||||
} SPI_INSTANCE;
|
||||
|
||||
|
||||
/**
|
||||
Acquire SPI MMIO BAR
|
||||
|
||||
@ -87,7 +86,6 @@ AcquireSpiBar0 (
|
||||
IN UINTN PchSpiBase
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Release SPI MMIO BAR. Do nothing.
|
||||
|
||||
@ -101,7 +99,6 @@ ReleaseSpiBar0 (
|
||||
IN UINTN PchSpiBase
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function is a hook for Spi to disable BIOS Write Protect
|
||||
|
||||
@ -135,7 +132,6 @@ EnableBiosWriteProtect (
|
||||
IN UINT8 CpuSmmBwp
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function disables SPI Prefetching and caching,
|
||||
and returns previous BIOS Control Register value before disabling.
|
||||
@ -165,7 +161,6 @@ SetSpiBiosControlRegister (
|
||||
IN UINT8 BiosCtlValue
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
This function sends the programmed SPI command to the slave device.
|
||||
|
||||
|
@ -17,20 +17,20 @@ SPI_INSTANCE *mSpiInstance = NULL;
|
||||
SPI_INSTANCE *
|
||||
GetSpiInstance (
|
||||
VOID
|
||||
)
|
||||
)
|
||||
{
|
||||
if (mSpiInstance == NULL) {
|
||||
mSpiInstance = AllocatePool (sizeof(SPI_INSTANCE));
|
||||
mSpiInstance = AllocatePool (sizeof (SPI_INSTANCE));
|
||||
if (mSpiInstance == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
ZeroMem (mSpiInstance, sizeof(SPI_INSTANCE));
|
||||
|
||||
ZeroMem (mSpiInstance, sizeof (SPI_INSTANCE));
|
||||
}
|
||||
|
||||
return mSpiInstance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize an SPI library.
|
||||
|
||||
@ -57,7 +57,8 @@ SpiConstructor (
|
||||
ASSERT (FALSE);
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
SpiFlashInfo = (SPI_FLASH_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
SpiFlashInfo = (SPI_FLASH_INFO *)GET_GUID_HOB_DATA (GuidHob);
|
||||
|
||||
//
|
||||
// Initialize the SPI instance
|
||||
@ -66,6 +67,7 @@ SpiConstructor (
|
||||
if (SpiInstance == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "SpiInstance = %08X\n", SpiInstance));
|
||||
|
||||
SpiInstance->Signature = SC_SPI_PRIVATE_DATA_SIGNATURE;
|
||||
@ -77,9 +79,11 @@ SpiConstructor (
|
||||
if ((SpiFlashInfo->SpiAddress.AddressSpaceId != EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE) ||
|
||||
(SpiFlashInfo->SpiAddress.RegisterBitWidth != 32) ||
|
||||
(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"));
|
||||
}
|
||||
|
||||
SpiInstance->PchSpiBase = (UINT32)(UINTN)SpiFlashInfo->SpiAddress.Address;
|
||||
SpiInstance->Flags = SpiFlashInfo->Flags;
|
||||
DEBUG ((DEBUG_INFO, "PchSpiBase at 0x%x\n", SpiInstance->PchSpiBase));
|
||||
@ -106,34 +110,34 @@ SpiConstructor (
|
||||
//
|
||||
MmioAndThenOr32 (
|
||||
ScSpiBar0 + R_SPI_FDOC,
|
||||
(UINT32) (~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32) (V_SPI_FDOC_FDSS_FSDM | R_SPI_FDBAR_FLASH_MAP0)
|
||||
(UINT32)(~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32)(V_SPI_FDOC_FDSS_FSDM | R_SPI_FDBAR_FLASH_MAP0)
|
||||
);
|
||||
|
||||
//
|
||||
// Copy Zero based Number Of Components
|
||||
//
|
||||
SpiInstance->NumberOfComponents = (UINT8) ((MmioRead16 (ScSpiBar0 + R_SPI_FDOD) & B_SPI_FDBAR_NC) >> N_SPI_FDBAR_NC);
|
||||
SpiInstance->NumberOfComponents = (UINT8)((MmioRead16 (ScSpiBar0 + R_SPI_FDOD) & B_SPI_FDBAR_NC) >> N_SPI_FDBAR_NC);
|
||||
|
||||
MmioAndThenOr32 (
|
||||
ScSpiBar0 + R_SPI_FDOC,
|
||||
(UINT32) (~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32) (V_SPI_FDOC_FDSS_COMP | R_SPI_FCBA_FLCOMP)
|
||||
(UINT32)(~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32)(V_SPI_FDOC_FDSS_COMP | R_SPI_FCBA_FLCOMP)
|
||||
);
|
||||
|
||||
//
|
||||
// Copy Component 0 Density
|
||||
//
|
||||
Comp0Density = (UINT8) MmioRead32 (ScSpiBar0 + R_SPI_FDOD) & B_SPI_FLCOMP_COMP1_MASK;
|
||||
SpiInstance->Component1StartAddr = (UINT32) (SIZE_512KB << Comp0Density);
|
||||
Comp0Density = (UINT8)MmioRead32 (ScSpiBar0 + R_SPI_FDOD) & B_SPI_FLCOMP_COMP1_MASK;
|
||||
SpiInstance->Component1StartAddr = (UINT32)(SIZE_512KB << Comp0Density);
|
||||
|
||||
//
|
||||
// Select FLASH_MAP1 to get Flash SC Strap Base Address
|
||||
//
|
||||
MmioAndThenOr32 (
|
||||
(ScSpiBar0 + R_SPI_FDOC),
|
||||
(UINT32) (~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32) (V_SPI_FDOC_FDSS_FSDM | R_SPI_FDBAR_FLASH_MAP1)
|
||||
(UINT32)(~(B_SPI_FDOC_FDSS_MASK | B_SPI_FDOC_FDSI_MASK)),
|
||||
(UINT32)(V_SPI_FDOC_FDSS_FSDM | R_SPI_FDBAR_FLASH_MAP1)
|
||||
);
|
||||
|
||||
SpiInstance->StrapBaseAddress = MmioRead32 (ScSpiBar0 + R_SPI_FDOD) & B_SPI_FDBAR_FPSBA;
|
||||
@ -146,7 +150,6 @@ SpiConstructor (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Read data from the flash part.
|
||||
|
||||
@ -453,6 +456,7 @@ SendSpiCmd (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto SendSpiCmdEnd;
|
||||
}
|
||||
|
||||
BiosCtlSave = SaveAndDisableSpiPrefetchCache (SpiBaseAddress);
|
||||
}
|
||||
|
||||
@ -467,8 +471,8 @@ SendSpiCmd (
|
||||
HardwareSpiAddr = Address;
|
||||
if ((FlashCycleType == FlashCycleRead) ||
|
||||
(FlashCycleType == FlashCycleWrite) ||
|
||||
(FlashCycleType == FlashCycleErase)) {
|
||||
|
||||
(FlashCycleType == FlashCycleErase))
|
||||
{
|
||||
switch (FlashRegionType) {
|
||||
case FlashRegionDescriptor:
|
||||
if (FlashCycleType == FlashCycleRead) {
|
||||
@ -476,6 +480,7 @@ SendSpiCmd (
|
||||
} else {
|
||||
PermissionBit = B_SPI_FRAP_BRWA_FLASHD;
|
||||
}
|
||||
|
||||
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG0_FLASHD);
|
||||
HardwareSpiAddr += (Data32 & B_SPI_FREG0_BASE_MASK) << N_SPI_FREG0_BASE;
|
||||
LimitAddress = (Data32 & B_SPI_FREG0_LIMIT_MASK) >> N_SPI_FREG0_LIMIT;
|
||||
@ -487,6 +492,7 @@ SendSpiCmd (
|
||||
} else {
|
||||
PermissionBit = B_SPI_FRAP_BRWA_BIOS;
|
||||
}
|
||||
|
||||
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG1_BIOS);
|
||||
HardwareSpiAddr += (Data32 & B_SPI_FREG1_BASE_MASK) << N_SPI_FREG1_BASE;
|
||||
LimitAddress = (Data32 & B_SPI_FREG1_LIMIT_MASK) >> N_SPI_FREG1_LIMIT;
|
||||
@ -498,6 +504,7 @@ SendSpiCmd (
|
||||
} else {
|
||||
PermissionBit = B_SPI_FRAP_BRWA_SEC;
|
||||
}
|
||||
|
||||
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG2_SEC);
|
||||
HardwareSpiAddr += (Data32 & B_SPI_FREG2_BASE_MASK) << N_SPI_FREG2_BASE;
|
||||
LimitAddress = (Data32 & B_SPI_FREG2_LIMIT_MASK) >> N_SPI_FREG2_LIMIT;
|
||||
@ -509,6 +516,7 @@ SendSpiCmd (
|
||||
} else {
|
||||
PermissionBit = B_SPI_FRAP_BRWA_GBE;
|
||||
}
|
||||
|
||||
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG3_GBE);
|
||||
HardwareSpiAddr += (Data32 & B_SPI_FREG3_BASE_MASK) << N_SPI_FREG3_BASE;
|
||||
LimitAddress = (Data32 & B_SPI_FREG3_LIMIT_MASK) >> N_SPI_FREG3_LIMIT;
|
||||
@ -520,6 +528,7 @@ SendSpiCmd (
|
||||
} else {
|
||||
PermissionBit = B_SPI_FRAP_BRWA_PLATFORM;
|
||||
}
|
||||
|
||||
Data32 = MmioRead32 (ScSpiBar0 + R_SPI_FREG4_PLATFORM_DATA);
|
||||
HardwareSpiAddr += (Data32 & B_SPI_FREG4_BASE_MASK) << N_SPI_FREG4_BASE;
|
||||
LimitAddress = (Data32 & B_SPI_FREG4_LIMIT_MASK) >> N_SPI_FREG4_LIMIT;
|
||||
@ -560,11 +569,11 @@ SendSpiCmd (
|
||||
FlashCycle = 0;
|
||||
switch (FlashCycleType) {
|
||||
case FlashCycleRead:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_READ << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_READ << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
case FlashCycleWrite:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_WRITE << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_WRITE << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
case FlashCycleErase:
|
||||
@ -574,22 +583,23 @@ SendSpiCmd (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto SendSpiCmdEnd;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case FlashCycleReadSfdp:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_READ_SFDP << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_READ_SFDP << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
case FlashCycleReadJedecId:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_READ_JEDEC_ID << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_READ_JEDEC_ID << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
case FlashCycleWriteStatus:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_WRITE_STATUS << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_WRITE_STATUS << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
case FlashCycleReadStatus:
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_READ_STATUS << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_READ_STATUS << N_SPI_HSFS_CYCLE);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -613,8 +623,9 @@ SendSpiCmd (
|
||||
// per operation
|
||||
//
|
||||
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.
|
||||
// Valid settings for the number of bytes during each data portion of the
|
||||
@ -630,7 +641,8 @@ SendSpiCmd (
|
||||
if (FlashCycleType == FlashCycleErase) {
|
||||
if (((ByteCount / SIZE_64KB) != 0) &&
|
||||
((ByteCount % SIZE_64KB) == 0) &&
|
||||
((HardwareSpiAddr % SIZE_64KB) == 0)) {
|
||||
((HardwareSpiAddr % SIZE_64KB) == 0))
|
||||
{
|
||||
if (HardwareSpiAddr < SpiInstance->Component1StartAddr) {
|
||||
//
|
||||
// Check whether Component0 support 64k Erase
|
||||
@ -653,10 +665,11 @@ SendSpiCmd (
|
||||
} else {
|
||||
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 {
|
||||
FlashCycle = (UINT32) (V_SPI_HSFS_CYCLE_64K_ERASE << N_SPI_HSFS_CYCLE);
|
||||
FlashCycle = (UINT32)(V_SPI_HSFS_CYCLE_64K_ERASE << N_SPI_HSFS_CYCLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -676,7 +689,7 @@ SendSpiCmd (
|
||||
// Use Dword write if Data Count is 8, 16, 24, 32, 40, 48, 56, 64
|
||||
//
|
||||
for (Index = 0; Index < SpiDataCount; Index += sizeof (UINT32)) {
|
||||
MmioWrite32 (ScSpiBar0 + R_SPI_FDATA00 + Index, *(UINT32 *) (Buffer + Index));
|
||||
MmioWrite32 (ScSpiBar0 + R_SPI_FDATA00 + Index, *(UINT32 *)(Buffer + Index));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -684,15 +697,15 @@ SendSpiCmd (
|
||||
//
|
||||
// Set the Flash Address
|
||||
//
|
||||
MmioWrite32 (ScSpiBar0 + R_SPI_FADDR, (UINT32) (HardwareSpiAddr & B_SPI_FADDR_MASK));
|
||||
MmioWrite32 (ScSpiBar0 + R_SPI_FADDR, (UINT32)(HardwareSpiAddr & B_SPI_FADDR_MASK));
|
||||
|
||||
//
|
||||
// Set Data count, Flash cycle, and Set Go bit to start a cycle
|
||||
//
|
||||
MmioAndThenOr32 (
|
||||
ScSpiBar0 + R_SPI_HSFS,
|
||||
(UINT32) (~(B_SPI_HSFS_FDBC_MASK | B_SPI_HSFS_CYCLE_MASK)),
|
||||
(UINT32) (((SpiDataCount - 1) << N_SPI_HSFS_FDBC) | FlashCycle | B_SPI_HSFS_CYCLE_FGO)
|
||||
(UINT32)(~(B_SPI_HSFS_FDBC_MASK | B_SPI_HSFS_CYCLE_MASK)),
|
||||
(UINT32)(((SpiDataCount - 1) << N_SPI_HSFS_FDBC) | FlashCycle | B_SPI_HSFS_CYCLE_FGO)
|
||||
);
|
||||
|
||||
//
|
||||
@ -709,7 +722,8 @@ SendSpiCmd (
|
||||
if ((FlashCycleType == FlashCycleRead) ||
|
||||
(FlashCycleType == FlashCycleReadSfdp) ||
|
||||
(FlashCycleType == FlashCycleReadJedecId) ||
|
||||
(FlashCycleType == FlashCycleReadStatus)) {
|
||||
(FlashCycleType == FlashCycleReadStatus))
|
||||
{
|
||||
if ((SpiDataCount & 0x07) != 0) {
|
||||
//
|
||||
// Use Byte read if Data Count is 0, 1, 2, 3, 4, 5, 6, 7
|
||||
@ -722,7 +736,7 @@ SendSpiCmd (
|
||||
// Use Dword read if Data Count is 8, 16, 24, 32, 40, 48, 56, 64
|
||||
//
|
||||
for (Index = 0; Index < SpiDataCount; Index += sizeof (UINT32)) {
|
||||
*(UINT32 *) (Buffer + Index) = MmioRead32 (ScSpiBar0 + R_SPI_FDATA00 + Index);
|
||||
*(UINT32 *)(Buffer + Index) = MmioRead32 (ScSpiBar0 + R_SPI_FDATA00 + Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -783,8 +797,10 @@ WaitForSpiCycleComplete (
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
MicroSecondDelay ( WAIT_PERIOD);
|
||||
|
||||
MicroSecondDelay (WAIT_PERIOD);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -816,7 +832,7 @@ SpiGetRegionAddress (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
SpiInstance = GetSpiInstance();
|
||||
SpiInstance = GetSpiInstance ();
|
||||
if (SpiInstance == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -825,14 +841,16 @@ SpiGetRegionAddress (
|
||||
if (BaseAddress != NULL) {
|
||||
*BaseAddress = 0;
|
||||
}
|
||||
|
||||
if (RegionSize != NULL) {
|
||||
*RegionSize = SpiInstance->Component1StartAddr;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
ScSpiBar0 = AcquireSpiBar0 (SpiInstance->PchSpiBase);
|
||||
ReadValue = MmioRead32 (ScSpiBar0 + R_SPI_FREG0_FLASHD + S_SPI_FREGX * (UINT32) FlashRegionType);
|
||||
ReadValue = MmioRead32 (ScSpiBar0 + R_SPI_FREG0_FLASHD + S_SPI_FREGX * (UINT32)FlashRegionType);
|
||||
ReleaseSpiBar0 (SpiInstance->PchSpiBase);
|
||||
|
||||
//
|
||||
|
@ -32,7 +32,6 @@ typedef struct {
|
||||
UINTN EntryPoint; ///< Return the actual entry point after LoadElfImage().
|
||||
} ELF_IMAGE_CONTEXT;
|
||||
|
||||
|
||||
typedef struct {
|
||||
UINT32 PtType;
|
||||
UINTN Offset;
|
||||
@ -119,4 +118,5 @@ GetElfSectionPos (
|
||||
OUT UINTN *Offset,
|
||||
OUT UINTN *Size
|
||||
);
|
||||
|
||||
#endif /* ELF_LIB_H_ */
|
||||
|
@ -37,7 +37,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _SYS_ELF32_H_
|
||||
#define _SYS_ELF32_H_ 1
|
||||
|
||||
|
||||
/*
|
||||
* ELF definitions common to all 32-bit architectures.
|
||||
*/
|
||||
@ -207,8 +206,7 @@ typedef struct {
|
||||
#define ELF32_ST_VISIBILITY(oth) ((oth) & 0x3)
|
||||
|
||||
/* Structures used by Sun & GNU symbol versioning. */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
Elf32_Half vd_version;
|
||||
Elf32_Half vd_flags;
|
||||
Elf32_Half vd_ndx;
|
||||
@ -218,14 +216,12 @@ typedef struct
|
||||
Elf32_Word vd_next;
|
||||
} Elf32_Verdef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
Elf32_Word vda_name;
|
||||
Elf32_Word vda_next;
|
||||
} Elf32_Verdaux;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
Elf32_Half vn_version;
|
||||
Elf32_Half vn_cnt;
|
||||
Elf32_Word vn_file;
|
||||
@ -233,8 +229,7 @@ typedef struct
|
||||
Elf32_Word vn_next;
|
||||
} Elf32_Verneed;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
Elf32_Word vna_hash;
|
||||
Elf32_Half vna_flags;
|
||||
Elf32_Half vna_other;
|
||||
|
@ -78,13 +78,15 @@ GetElf32SectionByRange (
|
||||
|
||||
Ehdr = (Elf32_Ehdr *)ImageBase;
|
||||
|
||||
Shdr = (Elf32_Shdr *) (ImageBase + Ehdr->e_shoff);
|
||||
Shdr = (Elf32_Shdr *)(ImageBase + Ehdr->e_shoff);
|
||||
for (Index = 0; Index < Ehdr->e_shnum; Index++) {
|
||||
if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) {
|
||||
return Shdr;
|
||||
}
|
||||
|
||||
Shdr = ELF_NEXT_ENTRY (Elf32_Shdr, Shdr, Ehdr->e_shentsize);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -117,12 +119,13 @@ ProcessRelocation32 (
|
||||
for ( Index = 0
|
||||
; RelaEntrySize * Index < RelaSize
|
||||
; Index++, Rela = ELF_NEXT_ENTRY (Elf32_Rela, Rela, RelaEntrySize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// r_offset is the virtual address of the storage unit affected by the relocation.
|
||||
//
|
||||
Ptr = (UINT32 *)(UINTN)(Rela->r_offset + Delta);
|
||||
Type = ELF32_R_TYPE(Rela->r_info);
|
||||
Type = ELF32_R_TYPE (Rela->r_info);
|
||||
switch (Type) {
|
||||
case R_386_NONE:
|
||||
case R_386_PC32:
|
||||
@ -139,8 +142,9 @@ ProcessRelocation32 (
|
||||
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
|
||||
ASSERT (FALSE);
|
||||
} else {
|
||||
*Ptr += (UINT32) Delta;
|
||||
*Ptr += (UINT32)Delta;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R_386_RELATIVE:
|
||||
@ -164,12 +168,12 @@ ProcessRelocation32 (
|
||||
// Calculation: B + A
|
||||
//
|
||||
if (RelaType == SHT_RELA) {
|
||||
*Ptr = (UINT32) Delta + Rela->r_addend;
|
||||
*Ptr = (UINT32)Delta + Rela->r_addend;
|
||||
} else {
|
||||
//
|
||||
// A is stored in the field of relocation for REL type.
|
||||
//
|
||||
*Ptr = (UINT32) Delta + *Ptr;
|
||||
*Ptr = (UINT32)Delta + *Ptr;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
@ -178,12 +182,14 @@ ProcessRelocation32 (
|
||||
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -239,6 +245,7 @@ RelocateElf32Dynamic (
|
||||
if (DynShdr == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ASSERT (DynShdr->sh_type == SHT_DYNAMIC);
|
||||
ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn));
|
||||
|
||||
@ -250,10 +257,11 @@ RelocateElf32Dynamic (
|
||||
RelaCount = 0;
|
||||
RelaEntrySize = 0;
|
||||
RelaType = 0;
|
||||
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++, Dyn = ELF_NEXT_ENTRY (Elf32_Dyn, Dyn, DynShdr->sh_entsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
switch (Dyn->d_tag) {
|
||||
case DT_RELA:
|
||||
case DT_REL:
|
||||
@ -265,7 +273,7 @@ RelocateElf32Dynamic (
|
||||
// For consistency, files do not contain relocation entries to ``correct'' addresses in the dynamic structure.
|
||||
//
|
||||
RelaAddress = Dyn->d_un.d_ptr;
|
||||
RelaType = (Dyn->d_tag == DT_RELA) ? SHT_RELA: SHT_REL;
|
||||
RelaType = (Dyn->d_tag == DT_RELA) ? SHT_RELA : SHT_REL;
|
||||
break;
|
||||
case DT_RELACOUNT:
|
||||
case DT_RELCOUNT:
|
||||
@ -304,12 +312,14 @@ RelocateElf32Dynamic (
|
||||
if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) {
|
||||
break;
|
||||
}
|
||||
|
||||
RelShdr = NULL;
|
||||
}
|
||||
|
||||
if (RelShdr == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ASSERT (RelShdr->sh_type == RelaType);
|
||||
ASSERT (RelShdr->sh_entsize == RelaEntrySize);
|
||||
|
||||
@ -317,9 +327,11 @@ RelocateElf32Dynamic (
|
||||
// 3. Process the relocation section.
|
||||
//
|
||||
ProcessRelocation32 (
|
||||
(Elf32_Rela *) (ElfCt->FileBase + RelShdr->sh_offset),
|
||||
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type,
|
||||
(UINTN) ElfCt->ImageAddress - (UINTN) ElfCt->PreferredImageAddress,
|
||||
(Elf32_Rela *)(ElfCt->FileBase + RelShdr->sh_offset),
|
||||
RelShdr->sh_size,
|
||||
RelShdr->sh_entsize,
|
||||
RelShdr->sh_type,
|
||||
(UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress,
|
||||
TRUE
|
||||
);
|
||||
return EFI_SUCCESS;
|
||||
@ -350,7 +362,7 @@ RelocateElf32Sections (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Delta = (UINTN) ElfCt->ImageAddress - (UINTN) ElfCt->PreferredImageAddress;
|
||||
Delta = (UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress;
|
||||
ElfCt->EntryPoint = (UINTN)(Ehdr->e_entry + Delta);
|
||||
|
||||
//
|
||||
@ -373,22 +385,27 @@ RelocateElf32Sections (
|
||||
// The below relocation is needed in this case.
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "EXEC ELF: Fix actual/preferred base address delta ...\n"));
|
||||
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++, RelShdr = ELF_NEXT_ENTRY (Elf32_Shdr, RelShdr, Ehdr->e_shentsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Shdr = GetElf32SectionByIndex (ElfCt->FileBase, RelShdr->sh_info);
|
||||
if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
|
||||
//
|
||||
// Only fix up sections that occupy memory during process execution.
|
||||
//
|
||||
ProcessRelocation32 (
|
||||
(Elf32_Rela *)((UINT8*)Ehdr + RelShdr->sh_offset),
|
||||
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type,
|
||||
Delta, FALSE
|
||||
(Elf32_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset),
|
||||
RelShdr->sh_size,
|
||||
RelShdr->sh_entsize,
|
||||
RelShdr->sh_type,
|
||||
Delta,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -429,12 +446,14 @@ LoadElf32Image (
|
||||
for ( Index = 0, Phdr = (Elf32_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff)
|
||||
; Index < Ehdr->e_phnum
|
||||
; Index++, Phdr = ELF_NEXT_ENTRY (Elf32_Phdr, Phdr, Ehdr->e_phentsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Skip segments that don't require load (type tells, or size is 0)
|
||||
//
|
||||
if ((Phdr->p_type != PT_LOAD) ||
|
||||
(Phdr->p_memsz == 0)) {
|
||||
(Phdr->p_memsz == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -442,7 +461,7 @@ LoadElf32Image (
|
||||
// The memory offset of segment relative to the image base
|
||||
// Note: CopyMem() does nothing when the dst equals to src.
|
||||
//
|
||||
Delta = Phdr->p_paddr - (UINT32) (UINTN) ElfCt->PreferredImageAddress;
|
||||
Delta = Phdr->p_paddr - (UINT32)(UINTN)ElfCt->PreferredImageAddress;
|
||||
CopyMem (ElfCt->ImageAddress + Delta, ElfCt->FileBase + Phdr->p_offset, Phdr->p_filesz);
|
||||
ZeroMem (ElfCt->ImageAddress + Delta + Phdr->p_filesz, Phdr->p_memsz - Phdr->p_filesz);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#ifndef _SYS_ELF64_H_
|
||||
#define _SYS_ELF64_H_ 1
|
||||
|
||||
|
||||
/*
|
||||
* ELF definitions common to all 64-bit architectures.
|
||||
*/
|
||||
|
@ -78,13 +78,15 @@ GetElf64SectionByRange (
|
||||
|
||||
Ehdr = (Elf64_Ehdr *)ImageBase;
|
||||
|
||||
Shdr = (Elf64_Shdr *) (ImageBase + Ehdr->e_shoff);
|
||||
Shdr = (Elf64_Shdr *)(ImageBase + Ehdr->e_shoff);
|
||||
for (Index = 0; Index < Ehdr->e_shnum; Index++) {
|
||||
if ((Shdr->sh_offset == Offset) && (Shdr->sh_size == Size)) {
|
||||
return Shdr;
|
||||
}
|
||||
|
||||
Shdr = ELF_NEXT_ENTRY (Elf64_Shdr, Shdr, Ehdr->e_shentsize);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -117,12 +119,13 @@ ProcessRelocation64 (
|
||||
for ( Index = 0
|
||||
; MultU64x64 (RelaEntrySize, Index) < RelaSize
|
||||
; Index++, Rela = ELF_NEXT_ENTRY (Elf64_Rela, Rela, RelaEntrySize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// r_offset is the virtual address of the storage unit affected by the relocation.
|
||||
//
|
||||
Ptr = (UINT64 *)(UINTN)(Rela->r_offset + Delta);
|
||||
Type = ELF64_R_TYPE(Rela->r_info);
|
||||
Type = ELF64_R_TYPE (Rela->r_info);
|
||||
switch (Type) {
|
||||
case R_X86_64_NONE:
|
||||
case R_X86_64_PC32:
|
||||
@ -142,6 +145,7 @@ ProcessRelocation64 (
|
||||
} else {
|
||||
*Ptr += Delta;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case R_X86_64_32:
|
||||
@ -187,12 +191,14 @@ ProcessRelocation64 (
|
||||
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
|
||||
ASSERT (FALSE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
DEBUG ((DEBUG_INFO, "Unsupported relocation type %02X\n", Type));
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -248,6 +254,7 @@ RelocateElf64Dynamic (
|
||||
if (DynShdr == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ASSERT (DynShdr->sh_type == SHT_DYNAMIC);
|
||||
ASSERT (DynShdr->sh_entsize >= sizeof (*Dyn));
|
||||
|
||||
@ -259,10 +266,11 @@ RelocateElf64Dynamic (
|
||||
RelaCount = 0;
|
||||
RelaEntrySize = 0;
|
||||
RelaType = 0;
|
||||
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++, Dyn = ELF_NEXT_ENTRY (Elf64_Dyn, Dyn, DynShdr->sh_entsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
switch (Dyn->d_tag) {
|
||||
case DT_RELA:
|
||||
case DT_REL:
|
||||
@ -274,7 +282,7 @@ RelocateElf64Dynamic (
|
||||
// For consistency, files do not contain relocation entries to ``correct'' addresses in the dynamic structure.
|
||||
//
|
||||
RelaAddress = Dyn->d_un.d_ptr;
|
||||
RelaType = (Dyn->d_tag == DT_RELA) ? SHT_RELA: SHT_REL;
|
||||
RelaType = (Dyn->d_tag == DT_RELA) ? SHT_RELA : SHT_REL;
|
||||
break;
|
||||
case DT_RELACOUNT:
|
||||
case DT_RELCOUNT:
|
||||
@ -313,12 +321,14 @@ RelocateElf64Dynamic (
|
||||
if ((RelShdr->sh_addr == RelaAddress) && (RelShdr->sh_size == RelaSize)) {
|
||||
break;
|
||||
}
|
||||
|
||||
RelShdr = NULL;
|
||||
}
|
||||
|
||||
if (RelShdr == NULL) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
ASSERT (RelShdr->sh_type == RelaType);
|
||||
ASSERT (RelShdr->sh_entsize == RelaEntrySize);
|
||||
|
||||
@ -326,9 +336,11 @@ RelocateElf64Dynamic (
|
||||
// 3. Process the relocation section.
|
||||
//
|
||||
ProcessRelocation64 (
|
||||
(Elf64_Rela *) (ElfCt->FileBase + RelShdr->sh_offset),
|
||||
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type,
|
||||
(UINTN) ElfCt->ImageAddress - (UINTN) ElfCt->PreferredImageAddress,
|
||||
(Elf64_Rela *)(ElfCt->FileBase + RelShdr->sh_offset),
|
||||
RelShdr->sh_size,
|
||||
RelShdr->sh_entsize,
|
||||
RelShdr->sh_type,
|
||||
(UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress,
|
||||
TRUE
|
||||
);
|
||||
return EFI_SUCCESS;
|
||||
@ -359,7 +371,7 @@ RelocateElf64Sections (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Delta = (UINTN) ElfCt->ImageAddress - (UINTN) ElfCt->PreferredImageAddress;
|
||||
Delta = (UINTN)ElfCt->ImageAddress - (UINTN)ElfCt->PreferredImageAddress;
|
||||
ElfCt->EntryPoint = (UINTN)(Ehdr->e_entry + Delta);
|
||||
|
||||
//
|
||||
@ -382,22 +394,27 @@ RelocateElf64Sections (
|
||||
// The below relocation is needed in this case.
|
||||
//
|
||||
DEBUG ((DEBUG_INFO, "EXEC ELF: Fix actual/preferred base address delta ...\n"));
|
||||
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++, RelShdr = ELF_NEXT_ENTRY (Elf64_Shdr, RelShdr, Ehdr->e_shentsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
if ((RelShdr->sh_type != SHT_REL) && (RelShdr->sh_type != SHT_RELA)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Shdr = GetElf64SectionByIndex (ElfCt->FileBase, RelShdr->sh_info);
|
||||
if ((Shdr->sh_flags & SHF_ALLOC) == SHF_ALLOC) {
|
||||
//
|
||||
// Only fix up sections that occupy memory during process execution.
|
||||
//
|
||||
ProcessRelocation64 (
|
||||
(Elf64_Rela *)((UINT8*)Ehdr + RelShdr->sh_offset),
|
||||
RelShdr->sh_size, RelShdr->sh_entsize, RelShdr->sh_type,
|
||||
Delta, FALSE
|
||||
(Elf64_Rela *)((UINT8 *)Ehdr + RelShdr->sh_offset),
|
||||
RelShdr->sh_size,
|
||||
RelShdr->sh_entsize,
|
||||
RelShdr->sh_type,
|
||||
Delta,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -438,12 +455,14 @@ LoadElf64Image (
|
||||
for ( Index = 0, Phdr = (Elf64_Phdr *)(ElfCt->FileBase + Ehdr->e_phoff)
|
||||
; Index < Ehdr->e_phnum
|
||||
; Index++, Phdr = ELF_NEXT_ENTRY (Elf64_Phdr, Phdr, Ehdr->e_phentsize)
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Skip segments that don't require load (type tells, or size is 0)
|
||||
//
|
||||
if ((Phdr->p_type != PT_LOAD) ||
|
||||
(Phdr->p_memsz == 0)) {
|
||||
(Phdr->p_memsz == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -451,9 +470,9 @@ LoadElf64Image (
|
||||
// The memory offset of segment relative to the image base
|
||||
// Note: CopyMem() does nothing when the dst equals to src.
|
||||
//
|
||||
Delta = (UINTN) Phdr->p_paddr - (UINTN) ElfCt->PreferredImageAddress;
|
||||
CopyMem (ElfCt->ImageAddress + Delta, ElfCt->FileBase + (UINTN) Phdr->p_offset, (UINTN) Phdr->p_filesz);
|
||||
ZeroMem (ElfCt->ImageAddress + Delta + (UINTN) Phdr->p_filesz, (UINTN) (Phdr->p_memsz - Phdr->p_filesz));
|
||||
Delta = (UINTN)Phdr->p_paddr - (UINTN)ElfCt->PreferredImageAddress;
|
||||
CopyMem (ElfCt->ImageAddress + Delta, ElfCt->FileBase + (UINTN)Phdr->p_offset, (UINTN)Phdr->p_filesz);
|
||||
ZeroMem (ElfCt->ImageAddress + Delta + (UINTN)Phdr->p_filesz, (UINTN)(Phdr->p_memsz - Phdr->p_filesz));
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -227,11 +227,11 @@ typedef struct {
|
||||
#define SHT_SUNW_COMDAT 0x6ffffffb
|
||||
#define SHT_SUNW_syminfo 0x6ffffffc
|
||||
#define SHT_SUNW_verdef 0x6ffffffd
|
||||
#define SHT_GNU_verdef 0x6ffffffd /* Symbol versions provided */
|
||||
#define SHT_GNU_verdef 0x6ffffffd/* Symbol versions provided */
|
||||
#define SHT_SUNW_verneed 0x6ffffffe
|
||||
#define SHT_GNU_verneed 0x6ffffffe /* Symbol versions required */
|
||||
#define SHT_SUNW_versym 0x6fffffff
|
||||
#define SHT_GNU_versym 0x6fffffff /* Symbol version table */
|
||||
#define SHT_GNU_versym 0x6fffffff/* Symbol version table */
|
||||
#define SHT_HISUNW 0x6fffffff
|
||||
#define SHT_HIOS 0x6fffffff /* Last of OS specific semantics */
|
||||
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
|
||||
@ -354,8 +354,8 @@ typedef struct {
|
||||
#define DT_MOVESZ 0x6ffffdfb /* move table size */
|
||||
#define DT_FEATURE_1 0x6ffffdfc /* feature holder */
|
||||
#define DT_POSFLAG_1 0x6ffffdfd /* flags for DT_* entries, effecting */
|
||||
/* the following DT_* entry. */
|
||||
/* See DF_P1_* definitions */
|
||||
/* the following DT_* entry. */
|
||||
/* See DF_P1_* definitions */
|
||||
#define DT_SYMINSZ 0x6ffffdfe /* syminfo table size (in bytes) */
|
||||
#define DT_SYMINENT 0x6ffffdff /* syminfo entry size (in bytes) */
|
||||
#define DT_VALRNGHI 0x6ffffdff
|
||||
@ -385,7 +385,7 @@ typedef struct {
|
||||
#define DT_VERNEED 0x6ffffffe /* Address of verneed section. */
|
||||
#define DT_VERNEEDNUM 0x6fffffff /* Number of elems in verneed section */
|
||||
|
||||
#define DT_LOPROC 0x70000000 /* First processor-specific type. */
|
||||
#define DT_LOPROC 0x70000000/* First processor-specific type. */
|
||||
#define DT_DEPRECATED_SPARC_REGISTER 0x7000001
|
||||
#define DT_AUXILIARY 0x7ffffffd /* shared library auxiliary name */
|
||||
#define DT_USED 0x7ffffffe /* ignored - same as needed */
|
||||
@ -471,15 +471,15 @@ typedef struct {
|
||||
* Syminfo flag values
|
||||
*/
|
||||
#define SYMINFO_FLG_DIRECT 0x0001 /* symbol ref has direct association */
|
||||
/* to object containing defn. */
|
||||
/* to object containing defn. */
|
||||
#define SYMINFO_FLG_PASSTHRU 0x0002 /* ignored - see SYMINFO_FLG_FILTER */
|
||||
#define SYMINFO_FLG_COPY 0x0004 /* symbol is a copy-reloc */
|
||||
#define SYMINFO_FLG_LAZYLOAD 0x0008 /* object containing defn should be */
|
||||
/* lazily-loaded */
|
||||
/* lazily-loaded */
|
||||
#define SYMINFO_FLG_DIRECTBIND 0x0010 /* ref should be bound directly to */
|
||||
/* object containing defn. */
|
||||
/* object containing defn. */
|
||||
#define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference */
|
||||
/* directly bind to this symbol */
|
||||
/* directly bind to this symbol */
|
||||
#define SYMINFO_FLG_FILTER 0x0002 /* symbol ref is associated to a */
|
||||
#define SYMINFO_FLG_AUXILIARY 0x0040 /* standard or auxiliary filter */
|
||||
|
||||
@ -541,14 +541,14 @@ typedef struct {
|
||||
/* Null relocation */
|
||||
#define R_AARCH64_NONE 256 /* No relocation */
|
||||
/* Static AArch64 relocations */
|
||||
/* Static data relocations */
|
||||
/* Static data relocations */
|
||||
#define R_AARCH64_ABS64 257 /* S + A */
|
||||
#define R_AARCH64_ABS32 258 /* S + A */
|
||||
#define R_AARCH64_ABS16 259 /* S + A */
|
||||
#define R_AARCH64_PREL64 260 /* S + A - P */
|
||||
#define R_AARCH64_PREL32 261 /* S + A - P */
|
||||
#define R_AARCH64_PREL16 262 /* S + A - P */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit unsigned data value or address inline */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit unsigned data value or address inline */
|
||||
#define R_AARCH64_MOVW_UABS_G0 263 /* S + A */
|
||||
#define R_AARCH64_MOVW_UABS_G0_NC 264 /* S + A */
|
||||
#define R_AARCH64_MOVW_UABS_G1 265 /* S + A */
|
||||
@ -556,11 +556,11 @@ typedef struct {
|
||||
#define R_AARCH64_MOVW_UABS_G2 267 /* S + A */
|
||||
#define R_AARCH64_MOVW_UABS_G2_NC 268 /* S + A */
|
||||
#define R_AARCH64_MOVW_UABS_G3 269 /* S + A */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit signed data or offset value inline */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit signed data or offset value inline */
|
||||
#define R_AARCH64_MOVW_SABS_G0 270 /* S + A */
|
||||
#define R_AARCH64_MOVW_SABS_G1 271 /* S + A */
|
||||
#define R_AARCH64_MOVW_SABS_G2 272 /* S + A */
|
||||
/* Relocations to generate 19, 21 and 33 bit PC-relative addresses */
|
||||
/* Relocations to generate 19, 21 and 33 bit PC-relative addresses */
|
||||
#define R_AARCH64_LD_PREL_LO19 273 /* S + A - P */
|
||||
#define R_AARCH64_ADR_PREL_LO21 274 /* S + A - P */
|
||||
#define R_AARCH64_ADR_PREL_PG_HI21 275 /* Page(S+A) - Page(P) */
|
||||
@ -571,12 +571,12 @@ typedef struct {
|
||||
#define R_AARCH64_LDST32_ABS_LO12_NC 285 /* S + A */
|
||||
#define R_AARCH64_LDST64_ABS_LO12_NC 286 /* S + A */
|
||||
#define R_AARCH64_LDST128_ABS_LO12_NC 299 /* S + A */
|
||||
/* Relocations for control-flow instructions - all offsets are a multiple of 4 */
|
||||
/* Relocations for control-flow instructions - all offsets are a multiple of 4 */
|
||||
#define R_AARCH64_TSTBR14 279 /* S+A-P */
|
||||
#define R_AARCH64_CONDBR19 280 /* S+A-P */
|
||||
#define R_AARCH64_JUMP26 282 /* S+A-P */
|
||||
#define R_AARCH64_CALL26 283 /* S+A-P */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit PC-relative offset inline */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit PC-relative offset inline */
|
||||
#define R_AARCH64_MOVW_PREL_G0 287 /* S+A-P */
|
||||
#define R_AARCH64_MOVW_PREL_G0_NC 288 /* S+A-P */
|
||||
#define R_AARCH64_MOVW_PREL_G1 289 /* S+A-P */
|
||||
@ -584,7 +584,7 @@ typedef struct {
|
||||
#define R_AARCH64_MOVW_PREL_G2 291 /* S+A-P */
|
||||
#define R_AARCH64_MOVW_PREL_G2_NC 292 /* S+A-P */
|
||||
#define R_AARCH64_MOVW_PREL_G3 293 /* S+A-P */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit GOT-relative offsets inline */
|
||||
/* Group relocations to create a 16, 32, 48, or 64 bit GOT-relative offsets inline */
|
||||
#define R_AARCH64_MOVW_GOTOFF_G0 300 /* G(S)-GOT */
|
||||
#define R_AARCH64_MOVW_GOTOFF_G0_NC 301 /* G(S)-GOT */
|
||||
#define R_AARCH64_MOVW_GOTOFF_G1 302 /* G(S)-GOT */
|
||||
@ -592,23 +592,23 @@ typedef struct {
|
||||
#define R_AARCH64_MOVW_GOTOFF_G2 304 /* G(S)-GOT */
|
||||
#define R_AARCH64_MOVW_GOTOFF_G2_NC 305 /* G(S)-GOT */
|
||||
#define R_AARCH64_MOVW_GOTOFF_G3 306 /* G(S)-GOT */
|
||||
/* GOT-relative data relocations */
|
||||
/* GOT-relative data relocations */
|
||||
#define R_AARCH64_GOTREL64 307 /* S+A-GOT */
|
||||
#define R_AARCH64_GOTREL32 308 /* S+A-GOT */
|
||||
/* GOT-relative instruction relocations */
|
||||
/* GOT-relative instruction relocations */
|
||||
#define R_AARCH64_GOT_LD_PREL19 309 /* G(S)-P */
|
||||
#define R_AARCH64_LD64_GOTOFF_LO15 310 /* G(S)-GOT */
|
||||
#define R_AARCH64_ADR_GOT_PAGE 311 /* Page(G(S))-Page(P) */
|
||||
#define R_AARCH64_LD64_GOT_LO12_NC 312 /* G(S) */
|
||||
#define R_AARCH64_LD64_GOTPAGE_LO15 313 /* G(S)-Page(GOT) */
|
||||
/* Relocations for thread-local storage */
|
||||
/* General Dynamic TLS relocations */
|
||||
/* General Dynamic TLS relocations */
|
||||
#define R_AARCH64_TLSGD_ADR_PREL21 512 /* G(TLSIDX(S+A)) - P */
|
||||
#define R_AARCH64_TLSGD_ADR_PAGE21 513 /* Page(G(TLSIDX(S+A))) - Page(P) */
|
||||
#define R_AARCH64_TLSGD_ADD_LO12_NC 514 /* G(TLSIDX(S+A)) */
|
||||
#define R_AARCH64_TLSGD_MOVW_G1 515 /* G(TLSIDX(S+A)) - GOT */
|
||||
#define R_AARCH64_TLSGD_MOVW_G0_NC 516 /* G(TLSIDX(S+A)) - GOT */
|
||||
/* Local Dynamic TLS relocations */
|
||||
/* Local Dynamic TLS relocations */
|
||||
#define R_AARCH64_TLSLD_ADR_PREL21 517 /* G(LDM(S))) - P */
|
||||
#define R_AARCH64_TLSLD_ADR_PAGE21 518 /* Page(G(LDM(S)))-Page(P) */
|
||||
#define R_AARCH64_TLSLD_ADD_LO12_NC 519 /* G(LDM(S)) */
|
||||
@ -631,13 +631,13 @@ typedef struct {
|
||||
#define R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC 536 /* DTPREL(S+A) */
|
||||
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12 537 /* DTPREL(S+A) */
|
||||
#define R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC 538 /* DTPREL(S+A) */
|
||||
/* Initial Exec TLS relocations */
|
||||
/* Initial Exec TLS relocations */
|
||||
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 539 /* G(TPREL(S+A)) - GOT */
|
||||
#define R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC 540 /* G(TPREL(S+A)) - GOT */
|
||||
#define R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 541 /* Page(G(TPREL(S+A))) - Page(P) */
|
||||
#define R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC 542 /* G(TPREL(S+A)) */
|
||||
#define R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 543 /* G(TPREL(S+A)) - P */
|
||||
/* Local Exec TLS relocations */
|
||||
/* Local Exec TLS relocations */
|
||||
#define R_AARCH64_TLSLE_MOVW_TPREL_G2 544 /* TPREL(S+A) */
|
||||
#define R_AARCH64_TLSLE_MOVW_TPREL_G1 545 /* TPREL(S+A) */
|
||||
#define R_AARCH64_TLSLE_MOVW_TPREL_G1_NC 546 /* TPREL(S+A) */
|
||||
@ -655,7 +655,7 @@ typedef struct {
|
||||
#define R_AARCH64_TLSLE_LDST64_TPREL_LO12 558 /* TPREL(S+A) */
|
||||
#define R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC 559 /* TPREL(S+A) */
|
||||
/* Dynamic relocations */
|
||||
/* Dynamic relocations */
|
||||
/* Dynamic relocations */
|
||||
#define R_AARCH64_COPY 1024
|
||||
#define R_AARCH64_GLOB_DAT 1025 /* S + A */
|
||||
#define R_AARCH64_JUMP_SLOT 1026 /* S + A */
|
||||
@ -696,7 +696,7 @@ typedef struct {
|
||||
#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
|
||||
#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
|
||||
|
||||
#define R_ARM_NONE 0 /* No relocation. */
|
||||
#define R_ARM_NONE 0/* No relocation. */
|
||||
#define R_ARM_PC24 1
|
||||
#define R_ARM_ABS32 2
|
||||
#define R_ARM_REL32 3
|
||||
@ -768,7 +768,7 @@ typedef struct {
|
||||
#define R_ARM_RPC24 254
|
||||
#define R_ARM_RBASE 255
|
||||
|
||||
#define R_PPC_NONE 0 /* No relocation. */
|
||||
#define R_PPC_NONE 0/* No relocation. */
|
||||
#define R_PPC_ADDR32 1
|
||||
#define R_PPC_ADDR24 2
|
||||
#define R_PPC_ADDR16 3
|
||||
@ -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_REX_GOTPCRELX 42 /* Load from 32 bit signed pc relative offset to GOT entry with REX prefix, relaxable. */
|
||||
|
||||
|
||||
#endif /* !_SYS_ELF_COMMON_H_ */
|
||||
|
@ -35,7 +35,8 @@ IsElfFormat (
|
||||
(Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) ||
|
||||
(Elf32Hdr->e_ident[EI_MAG1] != ELFMAG1) ||
|
||||
(Elf32Hdr->e_ident[EI_MAG2] != ELFMAG2)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -101,6 +102,7 @@ IsElfFormat (
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -134,9 +136,10 @@ CalculateElfFileSize (
|
||||
|
||||
// Use last section as end of file
|
||||
Status = GetElfSectionPos (ElfCt, ElfCt->ShNum - 1, &Offset, &Size);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
FileSize1 = Offset + Size;
|
||||
|
||||
// Use end of section header as end of file
|
||||
@ -149,7 +152,7 @@ CalculateElfFileSize (
|
||||
FileSize2 = (UINTN)(Elf64Hdr->e_shoff + Elf64Hdr->e_shentsize * Elf64Hdr->e_shnum);
|
||||
}
|
||||
|
||||
*FileSize = MAX(FileSize1, FileSize2);
|
||||
*FileSize = MAX (FileSize1, FileSize2);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -241,7 +244,8 @@ ParseElfImage (
|
||||
if (ElfCt == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
ZeroMem (ElfCt, sizeof(ELF_IMAGE_CONTEXT));
|
||||
|
||||
ZeroMem (ElfCt, sizeof (ELF_IMAGE_CONTEXT));
|
||||
|
||||
if (ImageBase == NULL) {
|
||||
return (ElfCt->ParseStatus = EFI_INVALID_PARAMETER);
|
||||
@ -258,10 +262,12 @@ ParseElfImage (
|
||||
if ((Elf32Hdr->e_type != ET_EXEC) && (Elf32Hdr->e_type != ET_DYN)) {
|
||||
return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
Elf32Shdr = (Elf32_Shdr *)GetElf32SectionByIndex (ElfCt->FileBase, Elf32Hdr->e_shstrndx);
|
||||
if (Elf32Shdr == NULL) {
|
||||
return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
ElfCt->EntryPoint = (UINTN)Elf32Hdr->e_entry;
|
||||
ElfCt->ShNum = Elf32Hdr->e_shnum;
|
||||
ElfCt->PhNum = Elf32Hdr->e_phnum;
|
||||
@ -272,10 +278,12 @@ ParseElfImage (
|
||||
if ((Elf64Hdr->e_type != ET_EXEC) && (Elf64Hdr->e_type != ET_DYN)) {
|
||||
return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
Elf64Shdr = (Elf64_Shdr *)GetElf64SectionByIndex (ElfCt->FileBase, Elf64Hdr->e_shstrndx);
|
||||
if (Elf64Shdr == NULL) {
|
||||
return (ElfCt->ParseStatus = EFI_UNSUPPORTED);
|
||||
}
|
||||
|
||||
ElfCt->EntryPoint = (UINTN)Elf64Hdr->e_entry;
|
||||
ElfCt->ShNum = Elf64Hdr->e_shnum;
|
||||
ElfCt->PhNum = Elf64Hdr->e_phnum;
|
||||
@ -307,18 +315,20 @@ ParseElfImage (
|
||||
if (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) {
|
||||
End = ALIGN_VALUE (SegInfo.MemAddr + SegInfo.MemLen, EFI_PAGE_SIZE) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// 0 - MAX_UINT32 + 1 equals to 0.
|
||||
//
|
||||
ElfCt->ImageSize = End - Base + 1;
|
||||
ElfCt->PreferredImageAddress = (VOID *) Base;
|
||||
ElfCt->PreferredImageAddress = (VOID *)Base;
|
||||
|
||||
CalculateElfFileSize (ElfCt, &ElfCt->FileSize);
|
||||
return (ElfCt->ParseStatus = EFI_SUCCESS);;
|
||||
return (ElfCt->ParseStatus = EFI_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,7 +376,6 @@ LoadElfImage (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get a ELF section name from its index.
|
||||
|
||||
@ -419,7 +428,6 @@ GetElfSectionName (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the offset and size of x-th ELF section.
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#define ELF_NEXT_ENTRY(EntryType, Current, EntrySize) \
|
||||
((EntryType *) ((UINT8 *)Current + EntrySize))
|
||||
|
||||
|
||||
/**
|
||||
Return the section header specified by Index.
|
||||
|
||||
|
@ -75,8 +75,11 @@ PeiLoadFileLoadPayload (
|
||||
} while (EFI_ERROR (Status));
|
||||
|
||||
DEBUG ((
|
||||
DEBUG_INFO, "Payload File Size: 0x%08X, Mem Size: 0x%08x, Reload: %d\n",
|
||||
Context.FileSize, Context.ImageSize, Context.ReloadRequired
|
||||
DEBUG_INFO,
|
||||
"Payload File Size: 0x%08X, Mem Size: 0x%08x, Reload: %d\n",
|
||||
Context.FileSize,
|
||||
Context.ImageSize,
|
||||
Context.ReloadRequired
|
||||
));
|
||||
|
||||
//
|
||||
@ -86,16 +89,17 @@ PeiLoadFileLoadPayload (
|
||||
ExtraDataCount = 0;
|
||||
for (Index = 0; Index < Context.ShNum; Index++) {
|
||||
Status = GetElfSectionName (&Context, Index, &SectionName);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
if (!EFI_ERROR (Status)) {
|
||||
PldInfo = (UNIVERSAL_PAYLOAD_INFO_HEADER *)(Context.FileBase + Offset);
|
||||
}
|
||||
} else if (AsciiStrnCmp(SectionName, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX_LENGTH) == 0) {
|
||||
} else if (AsciiStrnCmp (SectionName, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX, UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX_LENGTH) == 0) {
|
||||
Status = GetElfSectionPos (&Context, Index, &Offset, &Size);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ExtraDataCount++;
|
||||
@ -113,20 +117,21 @@ PeiLoadFileLoadPayload (
|
||||
);
|
||||
ExtraData->Count = ExtraDataCount;
|
||||
ExtraData->Header.Revision = UNIVERSAL_PAYLOAD_EXTRA_DATA_REVISION;
|
||||
ExtraData->Header.Length = (UINT16) Length;
|
||||
ExtraData->Header.Length = (UINT16)Length;
|
||||
if (ExtraDataCount != 0) {
|
||||
for (ExtraDataIndex = 0, Index = 0; Index < Context.ShNum; Index++) {
|
||||
Status = GetElfSectionName (&Context, Index, &SectionName);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
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);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
ASSERT (ExtraDataIndex < ExtraDataCount);
|
||||
AsciiStrCpyS (
|
||||
ExtraData->Entry[ExtraDataIndex].Identifier,
|
||||
sizeof(ExtraData->Entry[ExtraDataIndex].Identifier),
|
||||
sizeof (ExtraData->Entry[ExtraDataIndex].Identifier),
|
||||
SectionName + UNIVERSAL_PAYLOAD_EXTRA_SEC_NAME_PREFIX_LENGTH
|
||||
);
|
||||
ExtraData->Entry[ExtraDataIndex].Base = (UINTN)(Context.FileBase + Offset);
|
||||
@ -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));
|
||||
} else {
|
||||
Context.ImageAddress = Context.FileBase;
|
||||
@ -147,25 +152,25 @@ PeiLoadFileLoadPayload (
|
||||
// Load ELF into the required base
|
||||
//
|
||||
Status = LoadElfImage (&Context);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
*ImageAddressArg = (UINTN) Context.ImageAddress;
|
||||
if (!EFI_ERROR (Status)) {
|
||||
*ImageAddressArg = (UINTN)Context.ImageAddress;
|
||||
*EntryPoint = Context.EntryPoint;
|
||||
*ImageSizeArg = Context.ImageSize;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
EFI_PEI_LOAD_FILE_PPI mPeiLoadFilePpi = {
|
||||
PeiLoadFileLoadPayload
|
||||
};
|
||||
|
||||
|
||||
EFI_PEI_PPI_DESCRIPTOR gPpiLoadFilePpiList = {
|
||||
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
|
||||
&gEfiPeiLoadFilePpiGuid,
|
||||
&mPeiLoadFilePpi
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Install Pei Load File PPI.
|
||||
@ -185,6 +190,7 @@ InitializePayloadLoaderPeim (
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = PeiServicesInstallPpi (&gPpiLoadFilePpiList);
|
||||
|
||||
return Status;
|
||||
|
@ -38,12 +38,13 @@ FindContextBySwSmiInputValue (
|
||||
EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;
|
||||
|
||||
Node = mSmmSwDispatch2Queue.ForwardLink;
|
||||
for (; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
Dispatch2Context = BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link);
|
||||
if (Dispatch2Context->SwSmiInputValue == SwSmiInputValue) {
|
||||
return Dispatch2Context;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -63,12 +64,13 @@ FindContextByDispatchHandle (
|
||||
EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;
|
||||
|
||||
Node = mSmmSwDispatch2Queue.ForwardLink;
|
||||
for (; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
Dispatch2Context = BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link);
|
||||
if (Dispatch2Context->DispatchHandle == DispatchHandle) {
|
||||
return Dispatch2Context;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -114,7 +116,7 @@ SmmSwDispatcher (
|
||||
for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {
|
||||
Status = mSmmCpuProtocol->ReadSaveState (
|
||||
mSmmCpuProtocol,
|
||||
sizeof(IoInfo),
|
||||
sizeof (IoInfo),
|
||||
EFI_SMM_SAVE_STATE_REGISTER_IO,
|
||||
Index,
|
||||
&IoInfo
|
||||
@ -122,6 +124,7 @@ SmmSwDispatcher (
|
||||
if (EFI_ERROR (Status)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IoInfo.IoPort == SMM_CONTROL_PORT) {
|
||||
//
|
||||
// Great! Find it.
|
||||
@ -147,13 +150,14 @@ SmmSwDispatcher (
|
||||
Status = EFI_SUCCESS;
|
||||
goto End;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "Prepare to call handler for 0x%x\n", SwContext.CommandPort));
|
||||
|
||||
//
|
||||
// Dispatch
|
||||
//
|
||||
DispatchContext.SwSmiInputValue = SwContext.CommandPort;
|
||||
Size = sizeof(SwContext);
|
||||
Size = sizeof (SwContext);
|
||||
DispatchFunction = (EFI_SMM_HANDLER_ENTRY_POINT2)Context->DispatchFunction;
|
||||
Status = DispatchFunction (DispatchHandle, &DispatchContext, &SwContext, &Size);
|
||||
|
||||
@ -163,7 +167,6 @@ End:
|
||||
//
|
||||
IoOr32 (mSmiPchReg.SmiApmStsAddr, 1 << mSmiPchReg.ApmBitOffset);
|
||||
|
||||
|
||||
//
|
||||
// Set EOS bit
|
||||
//
|
||||
@ -172,7 +175,6 @@ End:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Check the SwSmiInputValue is already used
|
||||
|
||||
@ -191,7 +193,7 @@ SmiInputValueCheck (
|
||||
EFI_SMM_SW_DISPATCH2_CONTEXT *Dispatch2Context;
|
||||
|
||||
Node = mSmmSwDispatch2Queue.ForwardLink;
|
||||
for (; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
for ( ; Node != &mSmmSwDispatch2Queue; Node = Node->ForwardLink) {
|
||||
Dispatch2Context = BASE_CR (Node, EFI_SMM_SW_DISPATCH2_CONTEXT, Link);
|
||||
if (Dispatch2Context->SwSmiInputValue == SwSmiInputValue) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@ -201,7 +203,6 @@ SmiInputValueCheck (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Register a child SMI source dispatch function for the specified software SMI.
|
||||
|
||||
@ -256,6 +257,7 @@ SmmSwDispatch2Register (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (RegContext->SwSmiInputValue == (UINTN)-1) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -269,13 +271,13 @@ SmmSwDispatch2Register (
|
||||
//
|
||||
// Register
|
||||
//
|
||||
Status = gSmst->SmmAllocatePool (EfiRuntimeServicesData, sizeof(*Context), (VOID **)&Context);
|
||||
Status = gSmst->SmmAllocatePool (EfiRuntimeServicesData, sizeof (*Context), (VOID **)&Context);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
*DispatchHandle = (EFI_HANDLE )Context;
|
||||
*DispatchHandle = (EFI_HANDLE)Context;
|
||||
Context->Signature = SMI_SW_HANDLER_SIGNATURE;
|
||||
Context->SwSmiInputValue = RegContext->SwSmiInputValue;
|
||||
Context->DispatchFunction = (UINTN)DispatchFunction;
|
||||
@ -285,7 +287,6 @@ SmmSwDispatch2Register (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Unregister a child SMI source dispatch function for the specified software SMI.
|
||||
|
||||
@ -320,14 +321,12 @@ SmmSwDispatch2UnRegister (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
EFI_SMM_SW_DISPATCH2_PROTOCOL gSmmSwDispatch2 = {
|
||||
SmmSwDispatch2Register,
|
||||
SmmSwDispatch2UnRegister,
|
||||
MAXIMUM_SWI_VALUE
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Get specified SMI register based on given register ID
|
||||
|
||||
@ -367,20 +366,20 @@ GetSmmCtrlRegById (
|
||||
(PldReg->Address.Address == 0) ||
|
||||
(PldReg->Address.RegisterBitWidth != 1) ||
|
||||
(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, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
|
||||
DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
|
||||
DEBUG ((DEBUG_INFO, "RegBitOffset = 0x%x\n", PldReg->Address.RegisterBitOffset));
|
||||
DEBUG ((DEBUG_INFO, "AccessSize = 0x%x\n", PldReg->Address.AccessSize));
|
||||
DEBUG ((DEBUG_INFO, "Address = 0x%lx\n",PldReg->Address.Address ));
|
||||
DEBUG ((DEBUG_INFO, "Address = 0x%lx\n", PldReg->Address.Address));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PldReg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Entry Point for this driver.
|
||||
|
||||
@ -409,12 +408,13 @@ PchSmiDispatchEntryPoint (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
SmmRegister = (PLD_SMM_REGISTERS *) GET_GUID_HOB_DATA(GuidHob);
|
||||
SmmRegister = (PLD_SMM_REGISTERS *)GET_GUID_HOB_DATA (GuidHob);
|
||||
SmiEosReg = GetSmmCtrlRegById (SmmRegister, REGISTER_ID_SMI_EOS);
|
||||
if (SmiEosReg == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "SMI EOS reg not found.\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
mSmiPchReg.SmiEosAddr = (UINT32)SmiEosReg->Address.Address;
|
||||
mSmiPchReg.EosBitOffset = SmiEosReg->Address.RegisterBitOffset;
|
||||
|
||||
@ -423,6 +423,7 @@ PchSmiDispatchEntryPoint (
|
||||
DEBUG ((DEBUG_ERROR, "SMI APM status reg not found.\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
mSmiPchReg.SmiApmStsAddr = (UINT32)SmiApmStsReg->Address.Address;
|
||||
mSmiPchReg.ApmBitOffset = SmiApmStsReg->Address.RegisterBitOffset;
|
||||
|
||||
@ -452,4 +453,3 @@ PchSmiDispatchEntryPoint (
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -34,4 +34,3 @@ typedef struct {
|
||||
} EFI_SMM_SW_DISPATCH2_CONTEXT;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -18,7 +18,7 @@ SMM_ACCESS_PRIVATE_DATA mSmmAccess;
|
||||
|
||||
**/
|
||||
VOID
|
||||
SyncRegionState2SmramDesc(
|
||||
SyncRegionState2SmramDesc (
|
||||
IN BOOLEAN OrLogic,
|
||||
IN UINT64 Value
|
||||
)
|
||||
@ -62,10 +62,10 @@ Open (
|
||||
}
|
||||
|
||||
mSmmAccess.SmmRegionState &= ~(EFI_SMRAM_CLOSED | EFI_ALLOCATED);
|
||||
SyncRegionState2SmramDesc(FALSE, (UINT64)(UINTN)(~(EFI_SMRAM_CLOSED | EFI_ALLOCATED)));
|
||||
SyncRegionState2SmramDesc (FALSE, (UINT64)(UINTN)(~(EFI_SMRAM_CLOSED | EFI_ALLOCATED)));
|
||||
|
||||
mSmmAccess.SmmRegionState |= EFI_SMRAM_OPEN;
|
||||
SyncRegionState2SmramDesc(TRUE, EFI_SMRAM_OPEN);
|
||||
SyncRegionState2SmramDesc (TRUE, EFI_SMRAM_OPEN);
|
||||
mSmmAccess.SmmAccess.OpenState = TRUE;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@ -104,10 +104,10 @@ Close (
|
||||
}
|
||||
|
||||
mSmmAccess.SmmRegionState &= ~EFI_SMRAM_OPEN;
|
||||
SyncRegionState2SmramDesc(FALSE, (UINT64)(UINTN)(~EFI_SMRAM_OPEN));
|
||||
SyncRegionState2SmramDesc (FALSE, (UINT64)(UINTN)(~EFI_SMRAM_OPEN));
|
||||
|
||||
mSmmAccess.SmmRegionState |= (EFI_SMRAM_CLOSED | EFI_ALLOCATED);
|
||||
SyncRegionState2SmramDesc(TRUE, EFI_SMRAM_CLOSED | EFI_ALLOCATED);
|
||||
SyncRegionState2SmramDesc (TRUE, EFI_SMRAM_CLOSED | EFI_ALLOCATED);
|
||||
|
||||
mSmmAccess.SmmAccess.OpenState = FALSE;
|
||||
|
||||
@ -140,7 +140,7 @@ Lock (
|
||||
}
|
||||
|
||||
mSmmAccess.SmmRegionState |= EFI_SMRAM_LOCKED;
|
||||
SyncRegionState2SmramDesc(TRUE, EFI_SMRAM_LOCKED);
|
||||
SyncRegionState2SmramDesc (TRUE, EFI_SMRAM_LOCKED);
|
||||
mSmmAccess.SmmAccess.LockState = TRUE;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -172,11 +172,11 @@ GetCapabilities (
|
||||
EFI_STATUS Status;
|
||||
UINTN NecessaryBufferSize;
|
||||
|
||||
NecessaryBufferSize = mSmmAccess.NumberRegions * sizeof(EFI_SMRAM_DESCRIPTOR);
|
||||
NecessaryBufferSize = mSmmAccess.NumberRegions * sizeof (EFI_SMRAM_DESCRIPTOR);
|
||||
if (*SmramMapSize < NecessaryBufferSize) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
CopyMem(SmramMap, mSmmAccess.SmramDesc, NecessaryBufferSize);
|
||||
CopyMem (SmramMap, mSmmAccess.SmramDesc, NecessaryBufferSize);
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -215,20 +215,26 @@ SmmAccessEntryPoint (
|
||||
DEBUG ((DEBUG_INFO, "SMRAM HOB NOT found\n"));
|
||||
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;
|
||||
mSmmAccess.SmramDesc = AllocateZeroPool (sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum);
|
||||
if (mSmmAccess.SmramDesc == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (mSmmAccess.SmramDesc, &SmramHob->Descriptor, sizeof (EFI_SMRAM_DESCRIPTOR) * SmmRegionNum);
|
||||
|
||||
DEBUG ((DEBUG_INFO, "NumberOfSmmReservedRegions = 0x%x\n", SmmRegionNum));
|
||||
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].PhysicalSize,
|
||||
SmramHob->Descriptor[Index].RegionState));
|
||||
SmramHob->Descriptor[Index].RegionState
|
||||
));
|
||||
mSmmAccess.SmramDesc[Index].RegionState &= EFI_ALLOCATED;
|
||||
mSmmAccess.SmramDesc[Index].RegionState |= EFI_SMRAM_CLOSED | EFI_CACHEABLE;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Guid/SmramMemoryReserve.h>
|
||||
|
||||
|
||||
#define SMM_ACCESS_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('S', 'M', 'M', 'A')
|
||||
|
||||
typedef struct {
|
||||
|
@ -150,19 +150,20 @@ GetSmmCtrlRegById (
|
||||
(PldReg->Address.Address == 0) ||
|
||||
(PldReg->Address.RegisterBitWidth != 1) ||
|
||||
(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, "AddressSpaceId= 0x%x\n", PldReg->Address.AddressSpaceId));
|
||||
DEBUG ((DEBUG_INFO, "RegBitWidth = 0x%x\n", PldReg->Address.RegisterBitWidth));
|
||||
DEBUG ((DEBUG_INFO, "RegBitOffset = 0x%x\n", PldReg->Address.RegisterBitOffset));
|
||||
DEBUG ((DEBUG_INFO, "AccessSize = 0x%x\n", PldReg->Address.AccessSize));
|
||||
DEBUG ((DEBUG_INFO, "Address = 0x%lx\n",PldReg->Address.Address ));
|
||||
DEBUG ((DEBUG_INFO, "Address = 0x%lx\n", PldReg->Address.Address));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return PldReg;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fixup data pointers so that the services can be called in virtual mode.
|
||||
|
||||
@ -177,11 +178,10 @@ SmmControlVirtualAddressChangeEvent (
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EfiConvertPointer (0x0, (VOID **) &(mSmmControl2.Trigger));
|
||||
EfiConvertPointer (0x0, (VOID **) &(mSmmControl2.Clear));
|
||||
EfiConvertPointer (0x0, (VOID **)&(mSmmControl2.Trigger));
|
||||
EfiConvertPointer (0x0, (VOID **)&(mSmmControl2.Clear));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function installs EFI_SMM_CONTROL2_PROTOCOL.
|
||||
|
||||
@ -211,12 +211,13 @@ SmmControlEntryPoint (
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
SmmRegister = (PLD_SMM_REGISTERS *) (GET_GUID_HOB_DATA(GuidHob));
|
||||
SmmRegister = (PLD_SMM_REGISTERS *)(GET_GUID_HOB_DATA (GuidHob));
|
||||
SmiGblEnReg = GetSmmCtrlRegById (SmmRegister, REGISTER_ID_SMI_GBL_EN);
|
||||
if (SmiGblEnReg == NULL) {
|
||||
DEBUG ((DEBUG_ERROR, "SMI global enable reg not found.\n"));
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
mSmiCtrlReg.Address = (UINT32)SmiGblEnReg->Address.Address;
|
||||
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));
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
mSmiCtrlReg.ApmBitOffset = SmiApmEnReg->Address.RegisterBitOffset;
|
||||
|
||||
//
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "UefiPayloadEntry.h"
|
||||
|
||||
|
||||
/**
|
||||
Find the board related info from ACPI table
|
||||
|
||||
@ -51,7 +50,7 @@ ParseAcpiInfo (
|
||||
Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->RsdtAddress);
|
||||
if (Rsdt != NULL) {
|
||||
Entry32 = (UINT32 *)(Rsdt + 1);
|
||||
Entry32Num = (Rsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 2;
|
||||
Entry32Num = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) >> 2;
|
||||
for (Idx = 0; Idx < Entry32Num; Idx++) {
|
||||
Signature = (UINT32 *)(UINTN)Entry32[Idx];
|
||||
if (*Signature == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
|
||||
@ -76,7 +75,7 @@ ParseAcpiInfo (
|
||||
Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)(Rsdp->XsdtAddress);
|
||||
if (Xsdt != NULL) {
|
||||
Entry64 = (UINT64 *)(Xsdt + 1);
|
||||
Entry64Num = (Xsdt->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER)) >> 3;
|
||||
Entry64Num = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) >> 3;
|
||||
for (Idx = 0; Idx < Entry64Num; Idx++) {
|
||||
Signature = (UINT32 *)(UINTN)Entry64[Idx];
|
||||
if (*Signature == EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
|
||||
@ -109,13 +108,14 @@ Done:
|
||||
AcpiBoardInfo->PmGpeEnBase = Fadt->Gpe0Blk + Fadt->Gpe0BlkLen / 2;
|
||||
|
||||
if (MmCfgHdr != NULL) {
|
||||
MmCfgBase = (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *)((UINT8*) MmCfgHdr + sizeof (*MmCfgHdr));
|
||||
MmCfgBase = (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE *)((UINT8 *)MmCfgHdr + sizeof (*MmCfgHdr));
|
||||
AcpiBoardInfo->PcieBaseAddress = MmCfgBase->BaseAddress;
|
||||
AcpiBoardInfo->PcieBaseSize = (MmCfgBase->EndBusNumber + 1 - MmCfgBase->StartBusNumber) * 4096 * 32 * 8;
|
||||
} else {
|
||||
AcpiBoardInfo->PcieBaseAddress = 0;
|
||||
AcpiBoardInfo->PcieBaseSize = 0;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "PmCtrl Reg 0x%lx\n", AcpiBoardInfo->PmCtrlRegBase));
|
||||
DEBUG ((DEBUG_INFO, "PmTimer Reg 0x%lx\n", AcpiBoardInfo->PmTimerRegBase));
|
||||
DEBUG ((DEBUG_INFO, "Reset Reg 0x%lx\n", AcpiBoardInfo->ResetRegAddress));
|
||||
@ -128,11 +128,11 @@ Done:
|
||||
//
|
||||
// Verify values for proper operation
|
||||
//
|
||||
ASSERT(Fadt->Pm1aCntBlk != 0);
|
||||
ASSERT(Fadt->PmTmrBlk != 0);
|
||||
ASSERT(Fadt->ResetReg.Address != 0);
|
||||
ASSERT(Fadt->Pm1aEvtBlk != 0);
|
||||
ASSERT(Fadt->Gpe0Blk != 0);
|
||||
ASSERT (Fadt->Pm1aCntBlk != 0);
|
||||
ASSERT (Fadt->PmTmrBlk != 0);
|
||||
ASSERT (Fadt->ResetReg.Address != 0);
|
||||
ASSERT (Fadt->Pm1aEvtBlk != 0);
|
||||
ASSERT (Fadt->Gpe0Blk != 0);
|
||||
|
||||
DEBUG_CODE_BEGIN ();
|
||||
BOOLEAN SciEnabled;
|
||||
@ -145,32 +145,36 @@ Done:
|
||||
// Get SCI_EN value
|
||||
//
|
||||
if (Fadt->Pm1CntLen == 4) {
|
||||
SciEnabled = (IoRead32 (Fadt->Pm1aCntBlk) & BIT0)? TRUE : FALSE;
|
||||
SciEnabled = (IoRead32 (Fadt->Pm1aCntBlk) & BIT0) ? TRUE : FALSE;
|
||||
} else {
|
||||
//
|
||||
// if (Pm1CntLen == 2), use 16 bit IO read;
|
||||
// if (Pm1CntLen != 2 && Pm1CntLen != 4), use 16 bit IO read as a fallback
|
||||
//
|
||||
SciEnabled = (IoRead16 (Fadt->Pm1aCntBlk) & BIT0)? TRUE : FALSE;
|
||||
SciEnabled = (IoRead16 (Fadt->Pm1aCntBlk) & BIT0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
if (!(Fadt->Flags & EFI_ACPI_5_0_HW_REDUCED_ACPI) &&
|
||||
(Fadt->SmiCmd == 0) &&
|
||||
!SciEnabled) {
|
||||
!SciEnabled)
|
||||
{
|
||||
//
|
||||
// The ACPI enabling status is inconsistent: SCI is not enabled but ACPI
|
||||
// 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."
|
||||
" This may cause issues in OS.\n"));
|
||||
" This may cause issues in OS.\n"
|
||||
));
|
||||
}
|
||||
|
||||
DEBUG_CODE_END ();
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build ACPI board info HOB using infomation from ACPI table
|
||||
|
||||
@ -196,7 +200,6 @@ BuildHobFromAcpi (
|
||||
CopyMem (NewAcpiBoardInfo, &AcpiBoardInfo, sizeof (ACPI_BOARD_INFO));
|
||||
DEBUG ((DEBUG_INFO, "Create acpi board info guid hob\n"));
|
||||
}
|
||||
|
||||
return NewAcpiBoardInfo;
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,16 +35,34 @@ typedef struct _X64_IDT_TABLE {
|
||||
// Global Descriptor Table (GDT)
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries[] = {
|
||||
/* selector { Global Segment Descriptor } */
|
||||
/* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor
|
||||
/* 0x08 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor
|
||||
/* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //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
|
||||
/* selector { Global Segment Descriptor } */
|
||||
/* 0x00 */ {
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
}, // null descriptor
|
||||
/* 0x08 */ {
|
||||
{ 0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
|
||||
}, // linear data segment descriptor
|
||||
/* 0x10 */ {
|
||||
{ 0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0 }
|
||||
}, // 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
|
||||
};
|
||||
|
||||
//
|
||||
@ -52,8 +70,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT gGdtEntries[] = {
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR gGdt = {
|
||||
sizeof (gGdtEntries) - 1,
|
||||
(UINTN) gGdtEntries
|
||||
};
|
||||
(UINTN)gGdtEntries
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR gLidtDescriptor = {
|
||||
sizeof (X64_IDT_GATE_DESCRIPTOR) * IDT_ENTRY_COUNT - 1,
|
||||
@ -98,13 +116,13 @@ Create4GPageTablesIa32Pae (
|
||||
//
|
||||
// Calculate the table entries needed.
|
||||
//
|
||||
NumberOfPdpEntriesNeeded = (UINT32) LShiftU64 (1, (PhysicalAddressBits - 30));
|
||||
NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30));
|
||||
|
||||
TotalPagesNum = NumberOfPdpEntriesNeeded + 1;
|
||||
PageAddress = (UINTN) AllocatePageTableMemory (TotalPagesNum);
|
||||
PageAddress = (UINTN)AllocatePageTableMemory (TotalPagesNum);
|
||||
ASSERT (PageAddress != 0);
|
||||
|
||||
PageMap = (VOID *) PageAddress;
|
||||
PageMap = (VOID *)PageAddress;
|
||||
PageAddress += SIZE_4KB;
|
||||
|
||||
PageDirectoryPointerEntry = PageMap;
|
||||
@ -115,28 +133,29 @@ Create4GPageTablesIa32Pae (
|
||||
// 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.
|
||||
//
|
||||
PageDirectoryEntry = (VOID *) PageAddress;
|
||||
PageDirectoryEntry = (VOID *)PageAddress;
|
||||
PageAddress += SIZE_4KB;
|
||||
|
||||
//
|
||||
// Fill in a Page Directory Pointer Entries
|
||||
//
|
||||
PageDirectoryPointerEntry->Uint64 = (UINT64) (UINTN) PageDirectoryEntry | AddressEncMask;
|
||||
PageDirectoryPointerEntry->Uint64 = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask;
|
||||
PageDirectoryPointerEntry->Bits.Present = 1;
|
||||
|
||||
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress += SIZE_2MB) {
|
||||
if ((IsNullDetectionEnabled () && PhysicalAddress == 0)
|
||||
|| ((PhysicalAddress < StackBase + StackSize)
|
||||
&& ((PhysicalAddress + SIZE_2MB) > StackBase))) {
|
||||
if ( (IsNullDetectionEnabled () && (PhysicalAddress == 0))
|
||||
|| ( (PhysicalAddress < StackBase + StackSize)
|
||||
&& ((PhysicalAddress + SIZE_2MB) > StackBase)))
|
||||
{
|
||||
//
|
||||
// Need to split this 2M page that covers stack range.
|
||||
//
|
||||
Split2MPageTo4K (PhysicalAddress, (UINT64 *) PageDirectoryEntry, StackBase, StackSize, 0, 0);
|
||||
Split2MPageTo4K (PhysicalAddress, (UINT64 *)PageDirectoryEntry, StackBase, StackSize, 0, 0);
|
||||
} else {
|
||||
//
|
||||
// Fill in the Page Directory entries
|
||||
//
|
||||
PageDirectoryEntry->Uint64 = (UINT64) PhysicalAddress | AddressEncMask;
|
||||
PageDirectoryEntry->Uint64 = (UINT64)PhysicalAddress | AddressEncMask;
|
||||
PageDirectoryEntry->Bits.ReadWrite = 1;
|
||||
PageDirectoryEntry->Bits.Present = 1;
|
||||
PageDirectoryEntry->Bits.MustBe1 = 1;
|
||||
@ -144,7 +163,7 @@ Create4GPageTablesIa32Pae (
|
||||
}
|
||||
}
|
||||
|
||||
for (; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
|
||||
for ( ; IndexOfPdpEntries < 512; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
|
||||
ZeroMem (
|
||||
PageDirectoryPointerEntry,
|
||||
sizeof (PAGE_MAP_AND_DIRECTORY_POINTER)
|
||||
@ -157,7 +176,7 @@ Create4GPageTablesIa32Pae (
|
||||
//
|
||||
EnablePageTableProtection ((UINTN)PageMap, FALSE);
|
||||
|
||||
return (UINTN) PageMap;
|
||||
return (UINTN)PageMap;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,10 +276,10 @@ HandOffToDxeCore (
|
||||
BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData);
|
||||
}
|
||||
|
||||
BaseOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
|
||||
BaseOfStack = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
|
||||
ASSERT (BaseOfStack != 0);
|
||||
|
||||
if (FeaturePcdGet(PcdDxeIplSwitchToLongMode)) {
|
||||
if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
|
||||
//
|
||||
// Compute the top of the stack we were allocated, which is used to load X64 dxe core.
|
||||
// Pre-allocate a 32 bytes which confroms to x64 calling convention.
|
||||
@ -275,7 +294,7 @@ HandOffToDxeCore (
|
||||
//
|
||||
// x64 Calling Conventions requires that the stack must be aligned to 16 bytes
|
||||
//
|
||||
TopOfStack = (EFI_PHYSICAL_ADDRESS) (UINTN) ALIGN_POINTER (TopOfStack, 16);
|
||||
TopOfStack = (EFI_PHYSICAL_ADDRESS)(UINTN)ALIGN_POINTER (TopOfStack, 16);
|
||||
|
||||
//
|
||||
// Load the GDT of Go64. Since the GDT of 32-bit Tiano locates in the BS_DATA
|
||||
@ -301,36 +320,35 @@ HandOffToDxeCore (
|
||||
|
||||
SizeOfTemplate = AsmGetVectorTemplatInfo (&TemplateBase);
|
||||
|
||||
VectorAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) AllocatePages (EFI_SIZE_TO_PAGES(sizeof (X64_IDT_TABLE) + SizeOfTemplate * IDT_ENTRY_COUNT));
|
||||
VectorAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocatePages (EFI_SIZE_TO_PAGES (sizeof (X64_IDT_TABLE) + SizeOfTemplate * IDT_ENTRY_COUNT));
|
||||
ASSERT (VectorAddress != 0);
|
||||
|
||||
//
|
||||
// Store EFI_PEI_SERVICES** in the 4 bytes immediately preceding IDT to avoid that
|
||||
// it may not be gotten correctly after IDT register is re-written.
|
||||
//
|
||||
IdtTableForX64 = (X64_IDT_TABLE *) (UINTN) VectorAddress;
|
||||
IdtTableForX64 = (X64_IDT_TABLE *)(UINTN)VectorAddress;
|
||||
IdtTableForX64->PeiService = NULL;
|
||||
|
||||
VectorAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) (IdtTableForX64 + 1);
|
||||
VectorAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)(IdtTableForX64 + 1);
|
||||
IdtTable = IdtTableForX64->IdtTable;
|
||||
for (Index = 0; Index < IDT_ENTRY_COUNT; Index++) {
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.GateType = 0x8e;
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.Reserved_0 = 0;
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.Selector = SYS_CODE64_SEL;
|
||||
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.OffsetLow = (UINT16) VectorAddress;
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.OffsetHigh = (UINT16) (RShiftU64 (VectorAddress, 16));
|
||||
IdtTable[Index].Offset32To63 = (UINT32) (RShiftU64 (VectorAddress, 32));
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.OffsetLow = (UINT16)VectorAddress;
|
||||
IdtTable[Index].Ia32IdtEntry.Bits.OffsetHigh = (UINT16)(RShiftU64 (VectorAddress, 16));
|
||||
IdtTable[Index].Offset32To63 = (UINT32)(RShiftU64 (VectorAddress, 32));
|
||||
IdtTable[Index].Reserved = 0;
|
||||
|
||||
CopyMem ((VOID *) (UINTN) VectorAddress, TemplateBase, SizeOfTemplate);
|
||||
AsmVectorFixup ((VOID *) (UINTN) VectorAddress, (UINT8) Index);
|
||||
CopyMem ((VOID *)(UINTN)VectorAddress, TemplateBase, SizeOfTemplate);
|
||||
AsmVectorFixup ((VOID *)(UINTN)VectorAddress, (UINT8)Index);
|
||||
|
||||
VectorAddress += SizeOfTemplate;
|
||||
}
|
||||
|
||||
gLidtDescriptor.Base = (UINTN) IdtTable;
|
||||
|
||||
gLidtDescriptor.Base = (UINTN)IdtTable;
|
||||
|
||||
AsmWriteIdtr (&gLidtDescriptor);
|
||||
|
||||
@ -358,8 +376,6 @@ HandOffToDxeCore (
|
||||
// 32bit UEFI payload could be supported if required later.
|
||||
DEBUG ((DEBUG_ERROR, "NOT support 32bit UEFI payload\n"));
|
||||
ASSERT (FALSE);
|
||||
CpuDeadLoop();
|
||||
CpuDeadLoop ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
@return Allocated memory.
|
||||
**/
|
||||
VOID*
|
||||
VOID *
|
||||
AllocateCodePages (
|
||||
IN UINTN Pages
|
||||
)
|
||||
@ -35,6 +35,7 @@ AllocateCodePages (
|
||||
Hob.MemoryAllocation->AllocDescriptor.MemoryType = EfiBootServicesCode;
|
||||
return Alloc;
|
||||
}
|
||||
|
||||
Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (Hob));
|
||||
}
|
||||
|
||||
@ -44,7 +45,6 @@ AllocateCodePages (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Loads and relocates a PE/COFF image
|
||||
|
||||
@ -82,10 +82,11 @@ LoadPeCoffImage (
|
||||
//
|
||||
// Allocate Memory for the image
|
||||
//
|
||||
Buffer = AllocateCodePages (EFI_SIZE_TO_PAGES((UINT32)ImageContext.ImageSize));
|
||||
Buffer = AllocateCodePages (EFI_SIZE_TO_PAGES ((UINT32)ImageContext.ImageSize));
|
||||
if (Buffer == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
|
||||
|
||||
//
|
||||
@ -140,7 +141,7 @@ FvFindFileByTypeGuid (
|
||||
UINT32 Size;
|
||||
EFI_PHYSICAL_ADDRESS EndOfFile;
|
||||
|
||||
CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN) FvHeader;
|
||||
CurrentAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)FvHeader;
|
||||
EndOfFirmwareVolume = CurrentAddress + FvHeader->FvLength;
|
||||
|
||||
//
|
||||
@ -152,7 +153,7 @@ FvFindFileByTypeGuid (
|
||||
break;
|
||||
}
|
||||
|
||||
File = (EFI_FFS_FILE_HEADER*)(UINTN) CurrentAddress;
|
||||
File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
|
||||
if (IS_FFS_FILE2 (File)) {
|
||||
Size = FFS_FILE2_SIZE (File);
|
||||
if (Size <= 0x00FFFFFF) {
|
||||
@ -174,7 +175,7 @@ FvFindFileByTypeGuid (
|
||||
// Look for file type
|
||||
//
|
||||
if (File->Type == FileType) {
|
||||
if (Guid == NULL || CompareGuid(&File->Name, Guid)) {
|
||||
if ((Guid == NULL) || CompareGuid (&File->Name, Guid)) {
|
||||
*FileHeader = File;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -184,7 +185,6 @@ FvFindFileByTypeGuid (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function searchs a given section type within a valid FFS file.
|
||||
|
||||
@ -214,6 +214,7 @@ FileFindSection (
|
||||
} else {
|
||||
FileSize = FFS_FILE_SIZE (FileHeader);
|
||||
}
|
||||
|
||||
FileSize -= sizeof (EFI_FFS_FILE_HEADER);
|
||||
|
||||
Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
|
||||
@ -221,10 +222,11 @@ FileFindSection (
|
||||
while (Index < FileSize) {
|
||||
if (Section->Type == SectionType) {
|
||||
if (IS_SECTION2 (Section)) {
|
||||
*SectionData = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER2));
|
||||
*SectionData = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER2));
|
||||
} else {
|
||||
*SectionData = (VOID *)((UINT8 *) Section + sizeof (EFI_COMMON_SECTION_HEADER));
|
||||
*SectionData = (VOID *)((UINT8 *)Section + sizeof (EFI_COMMON_SECTION_HEADER));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -244,7 +246,6 @@ FileFindSection (
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find DXE core from FV and build DXE core HOBs.
|
||||
|
||||
@ -275,6 +276,7 @@ LoadDxeCore (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = FileFindSection (FileHeader, EFI_SECTION_FIRMWARE_VOLUME_IMAGE, (VOID **)&DxeCoreFv);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
@ -283,7 +285,7 @@ LoadDxeCore (
|
||||
//
|
||||
// Report DXE FV to DXE core
|
||||
//
|
||||
BuildFvHob ((EFI_PHYSICAL_ADDRESS) (UINTN) DxeCoreFv, DxeCoreFv->FvLength);
|
||||
BuildFvHob ((EFI_PHYSICAL_ADDRESS)(UINTN)DxeCoreFv, DxeCoreFv->FvLength);
|
||||
|
||||
//
|
||||
// Find DXE core file from DXE FV
|
||||
@ -306,7 +308,7 @@ LoadDxeCore (
|
||||
return Status;
|
||||
}
|
||||
|
||||
BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
|
||||
BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32)ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -353,7 +355,7 @@ UniversalLoadDxeCore (
|
||||
return Status;
|
||||
}
|
||||
|
||||
BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
|
||||
BuildModuleHob (&FileHeader->Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32)ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -134,10 +134,9 @@ AllocateAlignedPages (
|
||||
AlignmentMask = Alignment - 1;
|
||||
}
|
||||
|
||||
return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);
|
||||
return (VOID *)(UINTN)(((UINTN)Memory + AlignmentMask) & ~AlignmentMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Allocates a buffer of type EfiBootServicesData.
|
||||
|
||||
@ -197,5 +196,3 @@ AllocateZeroPool (
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,15 +19,15 @@ EFI_STATUS
|
||||
(*HOB_PRINT_HANDLER) (
|
||||
IN VOID *Hob,
|
||||
IN UINT16 HobLength
|
||||
);
|
||||
);
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
UINT16 Type;
|
||||
CHAR8 *Name;
|
||||
HOB_PRINT_HANDLER PrintHandler;
|
||||
} HOB_PRINT_HANDLER_TABLE;
|
||||
|
||||
CHAR8 * mMemoryTypeStr[] = {
|
||||
CHAR8 *mMemoryTypeStr[] = {
|
||||
"EfiReservedMemoryType",
|
||||
"EfiLoaderCode",
|
||||
"EfiLoaderData",
|
||||
@ -46,15 +46,15 @@ CHAR8 * mMemoryTypeStr[] = {
|
||||
"EfiMaxMemoryType"
|
||||
};
|
||||
|
||||
CHAR8 * mResource_Type_List[] = {
|
||||
"EFI_RESOURCE_SYSTEM_MEMORY ", //0x00000000
|
||||
"EFI_RESOURCE_MEMORY_MAPPED_IO ", //0x00000001
|
||||
"EFI_RESOURCE_IO ", //0x00000002
|
||||
"EFI_RESOURCE_FIRMWARE_DEVICE ", //0x00000003
|
||||
"EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", //0x00000004
|
||||
"EFI_RESOURCE_MEMORY_RESERVED ", //0x00000005
|
||||
"EFI_RESOURCE_IO_RESERVED ", //0x00000006
|
||||
"EFI_RESOURCE_MAX_MEMORY_TYPE " //0x00000007
|
||||
CHAR8 *mResource_Type_List[] = {
|
||||
"EFI_RESOURCE_SYSTEM_MEMORY ", // 0x00000000
|
||||
"EFI_RESOURCE_MEMORY_MAPPED_IO ", // 0x00000001
|
||||
"EFI_RESOURCE_IO ", // 0x00000002
|
||||
"EFI_RESOURCE_FIRMWARE_DEVICE ", // 0x00000003
|
||||
"EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", // 0x00000004
|
||||
"EFI_RESOURCE_MEMORY_RESERVED ", // 0x00000005
|
||||
"EFI_RESOURCE_IO_RESERVED ", // 0x00000006
|
||||
"EFI_RESOURCE_MAX_MEMORY_TYPE " // 0x00000007
|
||||
};
|
||||
|
||||
typedef
|
||||
@ -62,7 +62,7 @@ EFI_STATUS
|
||||
(*GUID_HOB_PRINT) (
|
||||
IN UINT8 *HobRaw,
|
||||
IN UINT16 HobLength
|
||||
);
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
EFI_GUID *Guid;
|
||||
@ -70,12 +70,11 @@ typedef struct {
|
||||
CHAR8 *GuidName;
|
||||
} GUID_HOB_PRINT_HANDLE;
|
||||
|
||||
typedef struct{
|
||||
typedef struct {
|
||||
EFI_GUID *Guid;
|
||||
CHAR8 *Type;
|
||||
} PRINT_MEMORY_ALLOCCATION_HOB;
|
||||
|
||||
|
||||
/**
|
||||
Print the Hex value of a given range.
|
||||
@param[in] DataStart A pointer to the start of data to be printed.
|
||||
@ -95,10 +94,11 @@ PrintHex (
|
||||
StartAddr = DataStart;
|
||||
for (Index1 = 0; Index1 * ROW_LIMITER < DataSize; Index1++) {
|
||||
DEBUG ((DEBUG_VERBOSE, " 0x%04p:", (DataStart - StartAddr)));
|
||||
for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++){
|
||||
for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++) {
|
||||
DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart));
|
||||
DataStart++;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_VERBOSE, "\n"));
|
||||
}
|
||||
|
||||
@ -113,13 +113,14 @@ PrintHex (
|
||||
@retval EFI_SUCCESS If it completed successfully.
|
||||
**/
|
||||
EFI_STATUS
|
||||
PrintHandOffHob(
|
||||
PrintHandOffHob (
|
||||
IN VOID *HobStart,
|
||||
IN UINT16 HobLength
|
||||
)
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable));
|
||||
DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode));
|
||||
DEBUG ((DEBUG_INFO, " EfiMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryTop));
|
||||
@ -144,9 +145,9 @@ PrintMemoryAllocationHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
|
||||
if(CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocStackGuid)) {
|
||||
if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocStackGuid)) {
|
||||
ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationStack));
|
||||
DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_STACK\n"));
|
||||
} else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocBspStoreGuid)) {
|
||||
@ -161,6 +162,7 @@ PrintMemoryAllocationHob (
|
||||
ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation));
|
||||
DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n"));
|
||||
}
|
||||
|
||||
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, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType]));
|
||||
@ -181,13 +183,14 @@ PrintResourceDiscriptorHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.ResourceDescriptor));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " ResourceType = %a\n", mResource_Type_List[Hob.ResourceDescriptor->ResourceType]));
|
||||
if(!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) {
|
||||
if (!IsZeroGuid (&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, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart));
|
||||
DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength));
|
||||
@ -209,11 +212,12 @@ PrintAcpiGuidHob (
|
||||
)
|
||||
{
|
||||
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);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));
|
||||
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", AcpiTableHob->Header.Length));
|
||||
DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64) AcpiTableHob->Rsdp));
|
||||
DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64)AcpiTableHob->Rsdp));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -231,7 +235,8 @@ PrintSerialGuidHob (
|
||||
)
|
||||
{
|
||||
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);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));
|
||||
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SerialPortInfo->Header.Length));
|
||||
@ -255,11 +260,12 @@ PrintSmbios3GuidHob (
|
||||
)
|
||||
{
|
||||
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);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
|
||||
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
|
||||
DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));
|
||||
DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -277,11 +283,12 @@ PrintSmbiosTablGuidHob (
|
||||
)
|
||||
{
|
||||
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);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
|
||||
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
|
||||
DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64) SmBiosTable->SmBiosEntryPoint));
|
||||
DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -299,7 +306,8 @@ PrintAcpiBoardInfoGuidHob (
|
||||
)
|
||||
{
|
||||
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));
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));
|
||||
DEBUG ((DEBUG_INFO, " Reserved0 = 0x%x\n", AcpBoardInfo->Reserved0));
|
||||
@ -330,8 +338,9 @@ PrintPciRootBridgeInfoGuidHob (
|
||||
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
|
||||
UINTN Index;
|
||||
UINTN Length;
|
||||
|
||||
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);
|
||||
ASSERT (HobLength >= Length);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
|
||||
@ -339,7 +348,7 @@ PrintPciRootBridgeInfoGuidHob (
|
||||
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
|
||||
DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));
|
||||
|
||||
while(Index < PciRootBridges->Count) {
|
||||
while (Index < PciRootBridges->Count) {
|
||||
DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));
|
||||
DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));
|
||||
DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));
|
||||
@ -365,8 +374,9 @@ PrintPciRootBridgeInfoGuidHob (
|
||||
DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));
|
||||
DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));
|
||||
DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));
|
||||
Index+=1;
|
||||
Index += 1;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -388,7 +398,7 @@ PrintExtraDataGuidHob (
|
||||
UINTN Length;
|
||||
|
||||
Index = 0;
|
||||
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (HobRaw);
|
||||
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *)GET_GUID_HOB_DATA (HobRaw);
|
||||
Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
|
||||
ASSERT (HobLength >= Length);
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
|
||||
@ -396,11 +406,12 @@ PrintExtraDataGuidHob (
|
||||
DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
|
||||
|
||||
while (Index < ExtraData->Count) {
|
||||
DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index,ExtraData->Entry[Index].Identifier));
|
||||
DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Base));
|
||||
DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index,ExtraData->Entry[Index].Size));
|
||||
Index+=1;
|
||||
DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index, ExtraData->Entry[Index].Identifier));
|
||||
DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Base));
|
||||
DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Size));
|
||||
Index += 1;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -419,7 +430,7 @@ PrintMemoryTypeInfoGuidHob (
|
||||
{
|
||||
EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;
|
||||
|
||||
MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *) GET_GUID_HOB_DATA (HobRaw);
|
||||
MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *)GET_GUID_HOB_DATA (HobRaw);
|
||||
ASSERT (HobLength >= sizeof (*MemoryTypeInfo));
|
||||
DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));
|
||||
DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));
|
||||
@ -440,7 +451,7 @@ PrintBootManagerMenuGuidHob (
|
||||
{
|
||||
UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *BootManagerMenuFile;
|
||||
|
||||
BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) GET_GUID_HOB_DATA (HobRaw);
|
||||
BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *)GET_GUID_HOB_DATA (HobRaw);
|
||||
ASSERT (HobLength >= sizeof (*BootManagerMenuFile));
|
||||
DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", BootManagerMenuFile->Header.Revision));
|
||||
DEBUG ((DEBUG_INFO, " Length = 0x%x\n", BootManagerMenuFile->Header.Length));
|
||||
@ -453,15 +464,15 @@ PrintBootManagerMenuGuidHob (
|
||||
// This table can be easily extented.
|
||||
//
|
||||
GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {
|
||||
{&gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)"},
|
||||
{&gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)"},
|
||||
{&gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)"},
|
||||
{&gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)"},
|
||||
{&gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)"},
|
||||
{&gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)"},
|
||||
{&gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)"},
|
||||
{&gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)"},
|
||||
{&gEdkiiBootManagerMenuFileGuid, PrintBootManagerMenuGuidHob, "gEdkiiBootManagerMenuFileGuid(Boot Manager Menu File Guid)"}
|
||||
{ &gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)" },
|
||||
{ &gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)" },
|
||||
{ &gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)" },
|
||||
{ &gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)" },
|
||||
{ &gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)" },
|
||||
{ &gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)" },
|
||||
{ &gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)" },
|
||||
{ &gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)" },
|
||||
{ &gEdkiiBootManagerMenuFileGuid, PrintBootManagerMenuGuidHob, "gEdkiiBootManagerMenuFileGuid(Boot Manager Menu File Guid)" }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -480,7 +491,7 @@ PrintGuidHob (
|
||||
UINTN Index;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (Hob.Guid));
|
||||
|
||||
for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
|
||||
@ -490,6 +501,7 @@ PrintGuidHob (
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));
|
||||
PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));
|
||||
return EFI_SUCCESS;
|
||||
@ -509,7 +521,7 @@ PrintFvHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));
|
||||
@ -531,7 +543,7 @@ PrintCpuHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.Cpu));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));
|
||||
@ -568,7 +580,7 @@ PrintFv2Hob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume2));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));
|
||||
@ -592,7 +604,7 @@ PrintCapsuleHob (
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.Capsule));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));
|
||||
@ -613,7 +625,8 @@ PrintFv3Hob (
|
||||
)
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));
|
||||
|
||||
DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));
|
||||
@ -629,19 +642,18 @@ PrintFv3Hob (
|
||||
// Mappint table from Hob type to Hob print function.
|
||||
//
|
||||
HOB_PRINT_HANDLER_TABLE mHobHandles[] = {
|
||||
{EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob},
|
||||
{EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob},
|
||||
{EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob},
|
||||
{EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob},
|
||||
{EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob},
|
||||
{EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob},
|
||||
{EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob},
|
||||
{EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob},
|
||||
{EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob},
|
||||
{EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob}
|
||||
{ EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob },
|
||||
{ EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob },
|
||||
{ EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob },
|
||||
{ EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob },
|
||||
{ EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob },
|
||||
{ EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob },
|
||||
{ EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob },
|
||||
{ EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob },
|
||||
{ EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob },
|
||||
{ EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Print all HOBs info from the HOB list.
|
||||
@param[in] HobStart A pointer to the HOB list
|
||||
@ -655,9 +667,10 @@ PrintHob (
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
UINTN Count;
|
||||
UINTN Index;
|
||||
|
||||
ASSERT (HobStart != NULL);
|
||||
|
||||
Hob.Raw = (UINT8 *) HobStart;
|
||||
Hob.Raw = (UINT8 *)HobStart;
|
||||
DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));
|
||||
|
||||
Count = 0;
|
||||
@ -667,18 +680,21 @@ PrintHob (
|
||||
while (!END_OF_HOB_LIST (Hob)) {
|
||||
for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {
|
||||
if (Hob.Header->HobType == mHobHandles[Index].Type) {
|
||||
DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %a, Offset = 0x%p, Length = 0x%x\n", Count, mHobHandles[Index].Name, (Hob.Raw - (UINT8 *) HobStart), Hob.Header->HobLength));
|
||||
DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %a, Offset = 0x%p, Length = 0x%x\n", Count, mHobHandles[Index].Name, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
|
||||
mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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, " Unkown Hob type\n"));
|
||||
PrintHex (Hob.Raw, Hob.Header->HobLength);
|
||||
}
|
||||
|
||||
Count++;
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ MemInfoCallbackMmio (
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -77,10 +77,11 @@ MemInfoCallbackMmio (
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;
|
||||
|
||||
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 ||
|
||||
MemoryMapEntry->Type == E820_DISABLED) {
|
||||
if ((MemoryMapEntry->Type == E820_UNUSABLE) ||
|
||||
(MemoryMapEntry->Type == E820_DISABLED))
|
||||
{
|
||||
BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory);
|
||||
} else if (MemoryMapEntry->Type == E820_PMEM) {
|
||||
BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory);
|
||||
@ -89,7 +90,6 @@ MemInfoCallbackMmio (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback function to find TOLUD (Top of Lower Usable DRAM)
|
||||
|
||||
@ -120,7 +120,8 @@ FindToludCallback (
|
||||
// Skip memory types not RAM or reserved
|
||||
//
|
||||
if ((MemoryMapEntry->Type == E820_UNUSABLE) || (MemoryMapEntry->Type == E820_DISABLED) ||
|
||||
(MemoryMapEntry->Type == E820_PMEM)) {
|
||||
(MemoryMapEntry->Type == E820_PMEM))
|
||||
{
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -132,7 +133,8 @@ FindToludCallback (
|
||||
}
|
||||
|
||||
if ((MemoryMapEntry->Type == E820_RAM) || (MemoryMapEntry->Type == E820_ACPI) ||
|
||||
(MemoryMapEntry->Type == E820_NVS)) {
|
||||
(MemoryMapEntry->Type == E820_NVS))
|
||||
{
|
||||
//
|
||||
// It's usable DRAM. Update TOLUD.
|
||||
//
|
||||
@ -154,7 +156,6 @@ FindToludCallback (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Callback function to build resource descriptor HOB
|
||||
|
||||
@ -182,7 +183,8 @@ MemInfoCallback (
|
||||
// It will be added later.
|
||||
//
|
||||
if ((MemoryMapEntry->Type != E820_RAM) && (MemoryMapEntry->Type != E820_ACPI) &&
|
||||
(MemoryMapEntry->Type != E820_NVS)) {
|
||||
(MemoryMapEntry->Type != E820_NVS))
|
||||
{
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
@ -199,7 +201,7 @@ MemInfoCallback (
|
||||
EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;
|
||||
|
||||
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_ACPI) {
|
||||
BuildMemoryAllocationHob (Base, Size, EfiACPIReclaimMemory);
|
||||
@ -210,8 +212,6 @@ MemInfoCallback (
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
It will build HOBs based on information from bootloaders.
|
||||
|
||||
@ -235,19 +235,20 @@ BuildHobFromBl (
|
||||
//
|
||||
// First find TOLUD
|
||||
//
|
||||
DEBUG ((DEBUG_INFO , "Guessing Top of Lower Usable DRAM:\n"));
|
||||
DEBUG ((DEBUG_INFO, "Guessing Top of Lower Usable DRAM:\n"));
|
||||
Status = ParseMemoryInfo (FindToludCallback, NULL);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
DEBUG ((DEBUG_INFO , "Assuming TOLUD = 0x%x\n", mTopOfLowerUsableDram));
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Assuming TOLUD = 0x%x\n", mTopOfLowerUsableDram));
|
||||
|
||||
//
|
||||
// Parse memory info and build memory HOBs for Usable RAM
|
||||
//
|
||||
DEBUG ((DEBUG_INFO , "Building ResourceDescriptorHobs for usable memory:\n"));
|
||||
DEBUG ((DEBUG_INFO, "Building ResourceDescriptorHobs for usable memory:\n"));
|
||||
Status = ParseMemoryInfo (MemInfoCallback, NULL);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -262,7 +263,6 @@ BuildHobFromBl (
|
||||
DEBUG ((DEBUG_INFO, "Created graphics info hob\n"));
|
||||
}
|
||||
|
||||
|
||||
Status = ParseGfxDeviceInfo (&GfxDeviceInfo);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NewGfxDeviceInfo = BuildGuidHob (&gEfiGraphicsDeviceInfoHobGuid, sizeof (GfxDeviceInfo));
|
||||
@ -271,7 +271,6 @@ BuildHobFromBl (
|
||||
DEBUG ((DEBUG_INFO, "Created graphics device info hob\n"));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Creat SmBios table Hob
|
||||
//
|
||||
@ -280,7 +279,7 @@ BuildHobFromBl (
|
||||
SmBiosTableHob->Header.Revision = UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION;
|
||||
SmBiosTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE);
|
||||
DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGuid guid hob\n"));
|
||||
Status = ParseSmbiosTable(SmBiosTableHob);
|
||||
Status = ParseSmbiosTable (SmBiosTableHob);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx\n", SmBiosTableHob->SmBiosEntryPoint));
|
||||
}
|
||||
@ -293,7 +292,7 @@ BuildHobFromBl (
|
||||
AcpiTableHob->Header.Revision = UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION;
|
||||
AcpiTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE);
|
||||
DEBUG ((DEBUG_INFO, "Create ACPI table gUniversalPayloadAcpiTableGuid guid hob\n"));
|
||||
Status = ParseAcpiTableInfo(AcpiTableHob);
|
||||
Status = ParseAcpiTableInfo (AcpiTableHob);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
DEBUG ((DEBUG_INFO, "Detected ACPI Table at 0x%lx\n", AcpiTableHob->Rsdp));
|
||||
}
|
||||
@ -307,9 +306,9 @@ BuildHobFromBl (
|
||||
//
|
||||
// Parse memory info and build memory HOBs for reserved DRAM and MMIO
|
||||
//
|
||||
DEBUG ((DEBUG_INFO , "Building ResourceDescriptorHobs for reserved memory:\n"));
|
||||
DEBUG ((DEBUG_INFO, "Building ResourceDescriptorHobs for reserved memory:\n"));
|
||||
Status = ParseMemoryInfo (MemInfoCallbackMmio, AcpiBoardInfo);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
@ -333,7 +332,6 @@ BuildHobFromBl (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This function will build some generic HOBs that doesn't depend on information from bootloaders.
|
||||
|
||||
@ -356,7 +354,7 @@ BuildGenericHob (
|
||||
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
||||
if (RegEax >= 0x80000008) {
|
||||
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
|
||||
PhysicalAddressBits = (UINT8) RegEax;
|
||||
PhysicalAddressBits = (UINT8)RegEax;
|
||||
} else {
|
||||
PhysicalAddressBits = 36;
|
||||
}
|
||||
@ -373,11 +371,9 @@ BuildGenericHob (
|
||||
EFI_RESOURCE_ATTRIBUTE_TESTED
|
||||
);
|
||||
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.
|
||||
|
||||
@ -422,7 +418,7 @@ _ModuleEntryPoint (
|
||||
ASSERT (UniversalSerialPort != NULL);
|
||||
UniversalSerialPort->Header.Revision = UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION;
|
||||
UniversalSerialPort->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO);
|
||||
UniversalSerialPort->UseMmio = (SerialPortInfo.Type == 1)?FALSE:TRUE;
|
||||
UniversalSerialPort->UseMmio = (SerialPortInfo.Type == 1) ? FALSE : TRUE;
|
||||
UniversalSerialPort->RegisterBase = SerialPortInfo.BaseAddr;
|
||||
UniversalSerialPort->BaudRate = SerialPortInfo.Baud;
|
||||
UniversalSerialPort->RegisterStride = (UINT8)SerialPortInfo.RegWidth;
|
||||
@ -430,7 +426,7 @@ _ModuleEntryPoint (
|
||||
|
||||
// The library constructors might depend on serial port, so call it after serial port hob
|
||||
ProcessLibraryConstructorList ();
|
||||
DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof(UINTN)));
|
||||
DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof (UINTN)));
|
||||
|
||||
// Build HOB based on information from Bootloader
|
||||
Status = BuildHobFromBl ();
|
||||
@ -454,7 +450,7 @@ _ModuleEntryPoint (
|
||||
IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
|
||||
IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
|
||||
|
||||
Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *) GetFirstHob(EFI_HOB_TYPE_HANDOFF);
|
||||
Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHob (EFI_HOB_TYPE_HANDOFF);
|
||||
HandOffToDxeCore (DxeCoreEntryPoint, Hob);
|
||||
|
||||
// Should not get here
|
||||
|
@ -42,7 +42,6 @@
|
||||
#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
|
||||
((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
|
||||
|
||||
|
||||
#define E820_RAM 1
|
||||
#define E820_RESERVED 2
|
||||
#define E820_ACPI 3
|
||||
@ -108,7 +107,7 @@ UpdateStackHob (
|
||||
@return The pointer to the handoff HOB table.
|
||||
|
||||
**/
|
||||
EFI_HOB_HANDOFF_INFO_TABLE*
|
||||
EFI_HOB_HANDOFF_INFO_TABLE *
|
||||
EFIAPI
|
||||
HobConstructor (
|
||||
IN VOID *EfiMemoryBottom,
|
||||
|
@ -67,7 +67,8 @@ FixUpPcdDatabase (
|
||||
//
|
||||
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));
|
||||
|
||||
Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DRIVER, PcdGetPtr (PcdPcdDriverFile), &FileHeader);
|
||||
@ -75,18 +76,20 @@ FixUpPcdDatabase (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = FileFindSection (FileHeader, EFI_SECTION_RAW, &PcdRawData);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
UplDatabase = (PEI_PCD_DATABASE *) PcdRawData;
|
||||
ExMapTable = (DYNAMICEX_MAPPING *) (UINTN) ((UINTN) PcdRawData + UplDatabase->ExMapTableOffset);
|
||||
UplDatabase = (PEI_PCD_DATABASE *)PcdRawData;
|
||||
ExMapTable = (DYNAMICEX_MAPPING *)(UINTN)((UINTN)PcdRawData + UplDatabase->ExMapTableOffset);
|
||||
|
||||
for (Index = 0; Index < UplDatabase->ExTokenCount; Index++) {
|
||||
ExMapTable[Index].TokenNumber += PeiDatabase->LocalTokenCount;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Fix up UPL PCD database successfully\n"));
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -106,6 +109,7 @@ AddNewHob (
|
||||
if (Hob->Raw == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
|
||||
|
||||
if (NewHob.Header != NULL) {
|
||||
@ -132,7 +136,7 @@ FindResourceDescriptorByRange (
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
|
||||
|
||||
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)) {
|
||||
//
|
||||
// Skip all HOBs except Resource Descriptor HOBs
|
||||
//
|
||||
@ -147,6 +151,7 @@ FindResourceDescriptorByRange (
|
||||
if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
|
||||
continue;
|
||||
}
|
||||
@ -157,11 +162,14 @@ FindResourceDescriptorByRange (
|
||||
if (Base < ResourceHob->PhysicalStart) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return ResourceHob;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -184,9 +192,10 @@ FindAnotherHighestBelow4GResourceDescriptor (
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
|
||||
EFI_HOB_RESOURCE_DESCRIPTOR *ReturnResourceHob;
|
||||
|
||||
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)) {
|
||||
//
|
||||
// Skip all HOBs except Resource Descriptor HOBs
|
||||
//
|
||||
@ -201,6 +210,7 @@ FindAnotherHighestBelow4GResourceDescriptor (
|
||||
if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != TESTED_MEMORY_ATTRIBUTES) {
|
||||
continue;
|
||||
}
|
||||
@ -211,12 +221,14 @@ FindAnotherHighestBelow4GResourceDescriptor (
|
||||
if (ResourceHob == ExceptResourceHob) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip Resource Descriptor HOBs that are beyond 4G
|
||||
//
|
||||
if ((ResourceHob->PhysicalStart + ResourceHob->ResourceLength) > BASE_4GB) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Skip Resource Descriptor HOBs that are too small
|
||||
//
|
||||
@ -235,6 +247,7 @@ FindAnotherHighestBelow4GResourceDescriptor (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ReturnResourceHob;
|
||||
}
|
||||
|
||||
@ -267,25 +280,24 @@ BuildHobs (
|
||||
UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTable;
|
||||
ACPI_BOARD_INFO *AcpiBoardInfo;
|
||||
|
||||
Hob.Raw = (UINT8 *) BootloaderParameter;
|
||||
Hob.Raw = (UINT8 *)BootloaderParameter;
|
||||
MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
|
||||
|
||||
ASSERT (Hob.Raw != NULL);
|
||||
ASSERT ((UINTN) Hob.HandoffInformationTable->EfiFreeMemoryTop == Hob.HandoffInformationTable->EfiFreeMemoryTop);
|
||||
ASSERT ((UINTN) Hob.HandoffInformationTable->EfiMemoryTop == Hob.HandoffInformationTable->EfiMemoryTop);
|
||||
ASSERT ((UINTN) Hob.HandoffInformationTable->EfiFreeMemoryBottom == Hob.HandoffInformationTable->EfiFreeMemoryBottom);
|
||||
ASSERT ((UINTN) Hob.HandoffInformationTable->EfiMemoryBottom == Hob.HandoffInformationTable->EfiMemoryBottom);
|
||||
|
||||
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop == Hob.HandoffInformationTable->EfiFreeMemoryTop);
|
||||
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryTop == Hob.HandoffInformationTable->EfiMemoryTop);
|
||||
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiFreeMemoryBottom == Hob.HandoffInformationTable->EfiFreeMemoryBottom);
|
||||
ASSERT ((UINTN)Hob.HandoffInformationTable->EfiMemoryBottom == Hob.HandoffInformationTable->EfiMemoryBottom);
|
||||
|
||||
//
|
||||
// Try to find Resource Descriptor HOB that contains Hob range EfiMemoryBottom..EfiMemoryTop
|
||||
//
|
||||
PhitResourceHob = FindResourceDescriptorByRange(Hob.Raw, Hob.HandoffInformationTable->EfiMemoryBottom, Hob.HandoffInformationTable->EfiMemoryTop);
|
||||
PhitResourceHob = FindResourceDescriptorByRange (Hob.Raw, Hob.HandoffInformationTable->EfiMemoryBottom, Hob.HandoffInformationTable->EfiMemoryTop);
|
||||
if (PhitResourceHob == NULL) {
|
||||
//
|
||||
// Boot loader's Phit Hob is not in an available Resource Descriptor, find another Resource Descriptor for new Phit Hob
|
||||
//
|
||||
ResourceHob = FindAnotherHighestBelow4GResourceDescriptor(Hob.Raw, MinimalNeededSize, NULL);
|
||||
ResourceHob = FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, MinimalNeededSize, NULL);
|
||||
if (ResourceHob == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -315,7 +327,7 @@ BuildHobs (
|
||||
// In the Resource Descriptor HOB contains boot loader Hob, there is no enough free memory size for payload hob
|
||||
// Find another Resource Descriptor Hob
|
||||
//
|
||||
ResourceHob = FindAnotherHighestBelow4GResourceDescriptor(Hob.Raw, MinimalNeededSize, PhitResourceHob);
|
||||
ResourceHob = FindAnotherHighestBelow4GResourceDescriptor (Hob.Raw, MinimalNeededSize, PhitResourceHob);
|
||||
if (ResourceHob == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@ -325,7 +337,8 @@ BuildHobs (
|
||||
FreeMemoryTop = ResourceHob->PhysicalStart + ResourceHob->ResourceLength;
|
||||
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.
|
||||
//
|
||||
@ -333,7 +346,7 @@ BuildHobs (
|
||||
//
|
||||
// Create an empty FvHob for the DXE FV that contains DXE core.
|
||||
//
|
||||
BuildFvHob ((EFI_PHYSICAL_ADDRESS) 0, 0);
|
||||
BuildFvHob ((EFI_PHYSICAL_ADDRESS)0, 0);
|
||||
//
|
||||
// Since payload created new Hob, move all hobs except PHIT from boot loader hob list.
|
||||
//
|
||||
@ -342,27 +355,28 @@ BuildHobs (
|
||||
// Add this hob to payload HOB
|
||||
AddNewHob (&Hob);
|
||||
}
|
||||
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
|
||||
//
|
||||
// Get DXE FV location
|
||||
//
|
||||
GuidHob = GetFirstGuidHob(&gUniversalPayloadExtraDataGuid);
|
||||
GuidHob = GetFirstGuidHob (&gUniversalPayloadExtraDataGuid);
|
||||
ASSERT (GuidHob != NULL);
|
||||
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *) GET_GUID_HOB_DATA (GuidHob);
|
||||
ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *)GET_GUID_HOB_DATA (GuidHob);
|
||||
ASSERT (ExtraData->Count == 1);
|
||||
ASSERT (AsciiStrCmp (ExtraData->Entry[0].Identifier, "uefi_fv") == 0);
|
||||
|
||||
*DxeFv = (EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) ExtraData->Entry[0].Base;
|
||||
*DxeFv = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)ExtraData->Entry[0].Base;
|
||||
ASSERT ((*DxeFv)->FvLength == ExtraData->Entry[0].Size);
|
||||
|
||||
//
|
||||
// Create guid hob for acpi board information
|
||||
//
|
||||
GuidHob = GetFirstGuidHob(&gUniversalPayloadAcpiTableGuid);
|
||||
GuidHob = GetFirstGuidHob (&gUniversalPayloadAcpiTableGuid);
|
||||
if (GuidHob != NULL) {
|
||||
AcpiTable = (UNIVERSAL_PAYLOAD_ACPI_TABLE *) GET_GUID_HOB_DATA (GuidHob);
|
||||
AcpiTable = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (GuidHob);
|
||||
AcpiBoardInfo = BuildHobFromAcpi ((UINT64)AcpiTable->Rsdp);
|
||||
ASSERT (AcpiBoardInfo != NULL);
|
||||
}
|
||||
@ -372,7 +386,7 @@ BuildHobs (
|
||||
// is the empty FvHob created before.
|
||||
//
|
||||
FvHob = GetFirstHob (EFI_HOB_TYPE_FV);
|
||||
FvHob->BaseAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) *DxeFv;
|
||||
FvHob->BaseAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)*DxeFv;
|
||||
FvHob->Length = (*DxeFv)->FvLength;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -395,13 +409,13 @@ _ModuleEntryPoint (
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
EFI_FIRMWARE_VOLUME_HEADER *DxeFv;
|
||||
|
||||
mHobList = (VOID *) BootloaderParameter;
|
||||
mHobList = (VOID *)BootloaderParameter;
|
||||
DxeFv = NULL;
|
||||
// Call constructor for all libraries
|
||||
ProcessLibraryConstructorList ();
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Entering Universal Payload...\n"));
|
||||
DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof(UINTN)));
|
||||
DEBUG ((DEBUG_INFO, "sizeof(UINTN) = 0x%x\n", sizeof (UINTN)));
|
||||
|
||||
DEBUG_CODE (
|
||||
//
|
||||
@ -427,7 +441,7 @@ _ModuleEntryPoint (
|
||||
IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
|
||||
IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
|
||||
|
||||
Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *) GetFirstHob(EFI_HOB_TYPE_HANDOFF);
|
||||
Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHob (EFI_HOB_TYPE_HANDOFF);
|
||||
HandOffToDxeCore (DxeCoreEntryPoint, Hob);
|
||||
|
||||
// Should not get here
|
||||
|
@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include "UefiPayloadEntry.h"
|
||||
#define STACK_SIZE 0x20000
|
||||
|
||||
|
||||
/**
|
||||
Transfers control to DxeCore.
|
||||
|
||||
@ -49,7 +48,6 @@ HandOffToDxeCore (
|
||||
BuildMemoryAllocationHob (0, EFI_PAGES_TO_SIZE (1), EfiBootServicesData);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Allocate 128KB for the Stack
|
||||
//
|
||||
@ -60,7 +58,7 @@ HandOffToDxeCore (
|
||||
// Compute the top of the stack we were allocated. Pre-allocate a UINTN
|
||||
// for safety.
|
||||
//
|
||||
TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
|
||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||
|
||||
//
|
||||
@ -74,8 +72,12 @@ HandOffToDxeCore (
|
||||
//
|
||||
// Create page table and save PageMapLevel4 to CR3
|
||||
//
|
||||
PageTables = CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE,
|
||||
(EFI_PHYSICAL_ADDRESS) (UINTN) GhcbBase, GhcbSize);
|
||||
PageTables = CreateIdentityMappingPageTables (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack,
|
||||
STACK_SIZE,
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)GhcbBase,
|
||||
GhcbSize
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// Set NX for stack feature also require PcdDxeIplBuildPageTables be TRUE
|
||||
@ -85,7 +87,6 @@ HandOffToDxeCore (
|
||||
ASSERT (PcdGetBool (PcdCpuStackGuard) == FALSE);
|
||||
}
|
||||
|
||||
|
||||
if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {
|
||||
AsmWriteCr3 (PageTables);
|
||||
}
|
||||
@ -93,7 +94,7 @@ HandOffToDxeCore (
|
||||
//
|
||||
// Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.
|
||||
//
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, STACK_SIZE);
|
||||
UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
|
||||
|
||||
//
|
||||
// Transfer the control to the entry point of DxeCore.
|
||||
|
@ -62,25 +62,36 @@ ClearFirst4KPage (
|
||||
//
|
||||
// Check if page 0 exists and free
|
||||
//
|
||||
while ((RscHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,
|
||||
RscHob.Raw)) != NULL) {
|
||||
if (RscHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
|
||||
RscHob.ResourceDescriptor->PhysicalStart == 0) {
|
||||
while ((RscHob.Raw = GetNextHob (
|
||||
EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,
|
||||
RscHob.Raw
|
||||
)) != NULL)
|
||||
{
|
||||
if ((RscHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) &&
|
||||
(RscHob.ResourceDescriptor->PhysicalStart == 0))
|
||||
{
|
||||
DoClear = TRUE;
|
||||
//
|
||||
// Make sure memory at 0-4095 has not been allocated.
|
||||
//
|
||||
while ((MemHob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION,
|
||||
MemHob.Raw)) != NULL) {
|
||||
while ((MemHob.Raw = GetNextHob (
|
||||
EFI_HOB_TYPE_MEMORY_ALLOCATION,
|
||||
MemHob.Raw
|
||||
)) != NULL)
|
||||
{
|
||||
if (MemHob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress
|
||||
< EFI_PAGE_SIZE) {
|
||||
< EFI_PAGE_SIZE)
|
||||
{
|
||||
DoClear = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
MemHob.Raw = GET_NEXT_HOB (MemHob);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
RscHob.Raw = GET_NEXT_HOB (RscHob);
|
||||
}
|
||||
|
||||
@ -203,12 +214,12 @@ ToSplitPageTable (
|
||||
IN UINTN GhcbSize
|
||||
)
|
||||
{
|
||||
if (IsNullDetectionEnabled () && Address == 0) {
|
||||
if (IsNullDetectionEnabled () && (Address == 0)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (PcdGetBool (PcdCpuStackGuard)) {
|
||||
if (StackBase >= Address && StackBase < (Address + Size)) {
|
||||
if ((StackBase >= Address) && (StackBase < (Address + Size))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -227,6 +238,7 @@ ToSplitPageTable (
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize a buffer pool for page table use only.
|
||||
|
||||
@ -316,8 +328,9 @@ AllocatePageTableMemory (
|
||||
//
|
||||
// Renew the pool if necessary.
|
||||
//
|
||||
if (mPageTablePool == NULL ||
|
||||
Pages > mPageTablePool->FreePages) {
|
||||
if ((mPageTablePool == NULL) ||
|
||||
(Pages > mPageTablePool->FreePages))
|
||||
{
|
||||
if (!InitializePageTablePool (Pages)) {
|
||||
return NULL;
|
||||
}
|
||||
@ -368,14 +381,14 @@ Split2MPageTo4K (
|
||||
//
|
||||
// Fill in 2M page entry.
|
||||
//
|
||||
*PageEntry2M = (UINT64) (UINTN) PageTableEntry | AddressEncMask | IA32_PG_P | IA32_PG_RW;
|
||||
*PageEntry2M = (UINT64)(UINTN)PageTableEntry | AddressEncMask | IA32_PG_P | IA32_PG_RW;
|
||||
|
||||
PhysicalAddress4K = PhysicalAddress;
|
||||
for (IndexOfPageTableEntries = 0; IndexOfPageTableEntries < 512; IndexOfPageTableEntries++, PageTableEntry++, PhysicalAddress4K += SIZE_4KB) {
|
||||
//
|
||||
// Fill in the Page Table entries
|
||||
//
|
||||
PageTableEntry->Uint64 = (UINT64) PhysicalAddress4K;
|
||||
PageTableEntry->Uint64 = (UINT64)PhysicalAddress4K;
|
||||
|
||||
//
|
||||
// The GHCB range consists of two pages per CPU, the GHCB and a
|
||||
@ -383,24 +396,28 @@ Split2MPageTo4K (
|
||||
// unencrypted page while the per-CPU variable page needs to be
|
||||
// mapped encrypted. These pages alternate in assignment.
|
||||
//
|
||||
if ((GhcbBase == 0)
|
||||
if ( (GhcbBase == 0)
|
||||
|| (PhysicalAddress4K < GhcbBase)
|
||||
|| (PhysicalAddress4K >= GhcbBase + GhcbSize)
|
||||
|| (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) != 0)) {
|
||||
|| (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) != 0))
|
||||
{
|
||||
PageTableEntry->Uint64 |= AddressEncMask;
|
||||
}
|
||||
|
||||
PageTableEntry->Bits.ReadWrite = 1;
|
||||
|
||||
if ((IsNullDetectionEnabled () && PhysicalAddress4K == 0) ||
|
||||
(PcdGetBool (PcdCpuStackGuard) && PhysicalAddress4K == StackBase)) {
|
||||
if ((IsNullDetectionEnabled () && (PhysicalAddress4K == 0)) ||
|
||||
(PcdGetBool (PcdCpuStackGuard) && (PhysicalAddress4K == StackBase)))
|
||||
{
|
||||
PageTableEntry->Bits.Present = 0;
|
||||
} else {
|
||||
PageTableEntry->Bits.Present = 1;
|
||||
}
|
||||
|
||||
if (PcdGetBool (PcdSetNxForStack)
|
||||
if ( PcdGetBool (PcdSetNxForStack)
|
||||
&& (PhysicalAddress4K >= StackBase)
|
||||
&& (PhysicalAddress4K < StackBase + StackSize)) {
|
||||
&& (PhysicalAddress4K < StackBase + StackSize))
|
||||
{
|
||||
//
|
||||
// Set Nx bit for stack.
|
||||
//
|
||||
@ -446,7 +463,7 @@ Split1GPageTo2M (
|
||||
//
|
||||
// Fill in 1G page entry.
|
||||
//
|
||||
*PageEntry1G = (UINT64) (UINTN) PageDirectoryEntry | AddressEncMask | IA32_PG_P | IA32_PG_RW;
|
||||
*PageEntry1G = (UINT64)(UINTN)PageDirectoryEntry | AddressEncMask | IA32_PG_P | IA32_PG_RW;
|
||||
|
||||
PhysicalAddress2M = PhysicalAddress;
|
||||
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress2M += SIZE_2MB) {
|
||||
@ -454,12 +471,12 @@ Split1GPageTo2M (
|
||||
//
|
||||
// Need to split this 2M page that covers NULL or stack range.
|
||||
//
|
||||
Split2MPageTo4K (PhysicalAddress2M, (UINT64 *) PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
Split2MPageTo4K (PhysicalAddress2M, (UINT64 *)PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
} else {
|
||||
//
|
||||
// Fill in the Page Directory entries
|
||||
//
|
||||
PageDirectoryEntry->Uint64 = (UINT64) PhysicalAddress2M | AddressEncMask;
|
||||
PageDirectoryEntry->Uint64 = (UINT64)PhysicalAddress2M | AddressEncMask;
|
||||
PageDirectoryEntry->Bits.ReadWrite = 1;
|
||||
PageDirectoryEntry->Bits.Present = 1;
|
||||
PageDirectoryEntry->Bits.MustBe1 = 1;
|
||||
@ -560,7 +577,6 @@ SetPageTablePoolReadOnly (
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
} else {
|
||||
//
|
||||
// The smaller granularity of page must be needed.
|
||||
@ -573,12 +589,14 @@ SetPageTablePoolReadOnly (
|
||||
PhysicalAddress = PageAttr & LevelMask[Level];
|
||||
for (EntryIndex = 0;
|
||||
EntryIndex < EFI_PAGE_SIZE/sizeof (UINT64);
|
||||
++EntryIndex) {
|
||||
++EntryIndex)
|
||||
{
|
||||
NewPageTable[EntryIndex] = PhysicalAddress | AddressEncMask |
|
||||
IA32_PG_P | IA32_PG_RW;
|
||||
if (Level > 2) {
|
||||
NewPageTable[EntryIndex] |= IA32_PG_PS;
|
||||
}
|
||||
|
||||
PhysicalAddress += LevelSize[Level - 1];
|
||||
}
|
||||
|
||||
@ -615,7 +633,7 @@ EnablePageTableProtection (
|
||||
// Disable write protection, because we need to mark page table to be write
|
||||
// protected.
|
||||
//
|
||||
AsmWriteCr0 (AsmReadCr0() & ~CR0_WP);
|
||||
AsmWriteCr0 (AsmReadCr0 () & ~CR0_WP);
|
||||
|
||||
//
|
||||
// SetPageTablePoolReadOnly might update mPageTablePool. It's safer to
|
||||
@ -633,7 +651,7 @@ EnablePageTableProtection (
|
||||
// protection to them one by one.
|
||||
//
|
||||
while (PoolSize > 0) {
|
||||
SetPageTablePoolReadOnly(PageTableBase, Address, Level4Paging);
|
||||
SetPageTablePoolReadOnly (PageTableBase, Address, Level4Paging);
|
||||
Address += PAGE_TABLE_POOL_UNIT_SIZE;
|
||||
PoolSize -= PAGE_TABLE_POOL_UNIT_SIZE;
|
||||
}
|
||||
@ -644,7 +662,7 @@ EnablePageTableProtection (
|
||||
//
|
||||
// Enable write protection, after page table attribute updated.
|
||||
//
|
||||
AsmWriteCr0 (AsmReadCr0() | CR0_WP);
|
||||
AsmWriteCr0 (AsmReadCr0 () | CR0_WP);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -704,7 +722,7 @@ CreateIdentityMappingPageTables (
|
||||
AddressEncMask = PcdGet64 (PcdPteMemoryEncryptionAddressOrMask) & PAGING_1G_ADDRESS_MASK_64;
|
||||
|
||||
Page1GSupport = FALSE;
|
||||
if (PcdGetBool(PcdUse1GPageTable)) {
|
||||
if (PcdGetBool (PcdUse1GPageTable)) {
|
||||
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
||||
if (RegEax >= 0x80000001) {
|
||||
AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx);
|
||||
@ -719,12 +737,12 @@ CreateIdentityMappingPageTables (
|
||||
//
|
||||
Hob = GetFirstHob (EFI_HOB_TYPE_CPU);
|
||||
if (Hob != NULL) {
|
||||
PhysicalAddressBits = ((EFI_HOB_CPU *) Hob)->SizeOfMemorySpace;
|
||||
PhysicalAddressBits = ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace;
|
||||
} else {
|
||||
AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);
|
||||
if (RegEax >= 0x80000008) {
|
||||
AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);
|
||||
PhysicalAddressBits = (UINT8) RegEax;
|
||||
PhysicalAddressBits = (UINT8)RegEax;
|
||||
} else {
|
||||
PhysicalAddressBits = 36;
|
||||
}
|
||||
@ -733,8 +751,12 @@ CreateIdentityMappingPageTables (
|
||||
Page5LevelSupport = FALSE;
|
||||
if (PcdGetBool (PcdUse5LevelPageTable)) {
|
||||
AsmCpuidEx (
|
||||
CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO, NULL,
|
||||
&EcxFlags.Uint32, NULL, NULL
|
||||
CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,
|
||||
CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,
|
||||
NULL,
|
||||
&EcxFlags.Uint32,
|
||||
NULL,
|
||||
NULL
|
||||
);
|
||||
if (EcxFlags.Bits.FiveLevelPage != 0) {
|
||||
Page5LevelSupport = TRUE;
|
||||
@ -749,7 +771,7 @@ CreateIdentityMappingPageTables (
|
||||
// due to either unsupported by HW, or disabled by PCD.
|
||||
//
|
||||
ASSERT (PhysicalAddressBits <= 52);
|
||||
if (!Page5LevelSupport && PhysicalAddressBits > 48) {
|
||||
if (!Page5LevelSupport && (PhysicalAddressBits > 48)) {
|
||||
PhysicalAddressBits = 48;
|
||||
}
|
||||
|
||||
@ -758,19 +780,19 @@ CreateIdentityMappingPageTables (
|
||||
//
|
||||
NumberOfPml5EntriesNeeded = 1;
|
||||
if (PhysicalAddressBits > 48) {
|
||||
NumberOfPml5EntriesNeeded = (UINT32) LShiftU64 (1, PhysicalAddressBits - 48);
|
||||
NumberOfPml5EntriesNeeded = (UINT32)LShiftU64 (1, PhysicalAddressBits - 48);
|
||||
PhysicalAddressBits = 48;
|
||||
}
|
||||
|
||||
NumberOfPml4EntriesNeeded = 1;
|
||||
if (PhysicalAddressBits > 39) {
|
||||
NumberOfPml4EntriesNeeded = (UINT32) LShiftU64 (1, PhysicalAddressBits - 39);
|
||||
NumberOfPml4EntriesNeeded = (UINT32)LShiftU64 (1, PhysicalAddressBits - 39);
|
||||
PhysicalAddressBits = 39;
|
||||
}
|
||||
|
||||
NumberOfPdpEntriesNeeded = 1;
|
||||
ASSERT (PhysicalAddressBits > 30);
|
||||
NumberOfPdpEntriesNeeded = (UINT32) LShiftU64 (1, PhysicalAddressBits - 30);
|
||||
NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, PhysicalAddressBits - 30);
|
||||
|
||||
//
|
||||
// Pre-allocate big pages to avoid later allocations.
|
||||
@ -788,17 +810,22 @@ CreateIdentityMappingPageTables (
|
||||
TotalPagesNum--;
|
||||
}
|
||||
|
||||
DEBUG ((DEBUG_INFO, "Pml5=%u Pml4=%u Pdp=%u TotalPage=%Lu\n",
|
||||
NumberOfPml5EntriesNeeded, NumberOfPml4EntriesNeeded,
|
||||
NumberOfPdpEntriesNeeded, (UINT64)TotalPagesNum));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"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);
|
||||
|
||||
//
|
||||
// By architecture only one PageMapLevel4 exists - so lets allocate storage for it.
|
||||
//
|
||||
PageMap = (VOID *) BigPageAddress;
|
||||
PageMap = (VOID *)BigPageAddress;
|
||||
if (Page5LevelSupport) {
|
||||
//
|
||||
// By architecture only one PageMapLevel5 exists - so lets allocate storage for it.
|
||||
@ -806,24 +833,26 @@ CreateIdentityMappingPageTables (
|
||||
PageMapLevel5Entry = PageMap;
|
||||
BigPageAddress += SIZE_4KB;
|
||||
}
|
||||
|
||||
PageAddress = 0;
|
||||
|
||||
for ( IndexOfPml5Entries = 0
|
||||
; IndexOfPml5Entries < NumberOfPml5EntriesNeeded
|
||||
; IndexOfPml5Entries++) {
|
||||
; IndexOfPml5Entries++)
|
||||
{
|
||||
//
|
||||
// Each PML5 entry points to a page of PML4 entires.
|
||||
// So lets allocate space for them and fill them in in the IndexOfPml4Entries loop.
|
||||
// When 5-Level Paging is disabled, below allocation happens only once.
|
||||
//
|
||||
PageMapLevel4Entry = (VOID *) BigPageAddress;
|
||||
PageMapLevel4Entry = (VOID *)BigPageAddress;
|
||||
BigPageAddress += SIZE_4KB;
|
||||
|
||||
if (Page5LevelSupport) {
|
||||
//
|
||||
// Make a PML5 Entry
|
||||
//
|
||||
PageMapLevel5Entry->Uint64 = (UINT64) (UINTN) PageMapLevel4Entry | AddressEncMask;
|
||||
PageMapLevel5Entry->Uint64 = (UINT64)(UINTN)PageMapLevel4Entry | AddressEncMask;
|
||||
PageMapLevel5Entry->Bits.ReadWrite = 1;
|
||||
PageMapLevel5Entry->Bits.Present = 1;
|
||||
PageMapLevel5Entry++;
|
||||
@ -831,12 +860,13 @@ CreateIdentityMappingPageTables (
|
||||
|
||||
for ( IndexOfPml4Entries = 0
|
||||
; IndexOfPml4Entries < (NumberOfPml5EntriesNeeded == 1 ? NumberOfPml4EntriesNeeded : 512)
|
||||
; IndexOfPml4Entries++, PageMapLevel4Entry++) {
|
||||
; IndexOfPml4Entries++, PageMapLevel4Entry++)
|
||||
{
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
PageDirectoryPointerEntry = (VOID *) BigPageAddress;
|
||||
PageDirectoryPointerEntry = (VOID *)BigPageAddress;
|
||||
BigPageAddress += SIZE_4KB;
|
||||
|
||||
//
|
||||
@ -847,11 +877,11 @@ CreateIdentityMappingPageTables (
|
||||
PageMapLevel4Entry->Bits.Present = 1;
|
||||
|
||||
if (Page1GSupport) {
|
||||
PageDirectory1GEntry = (VOID *) PageDirectoryPointerEntry;
|
||||
PageDirectory1GEntry = (VOID *)PageDirectoryPointerEntry;
|
||||
|
||||
for (IndexOfPageDirectoryEntries = 0; IndexOfPageDirectoryEntries < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress += SIZE_1GB) {
|
||||
if (ToSplitPageTable (PageAddress, SIZE_1GB, StackBase, StackSize, GhcbBase, GhcbSize)) {
|
||||
Split1GPageTo2M (PageAddress, (UINT64 *) PageDirectory1GEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
Split1GPageTo2M (PageAddress, (UINT64 *)PageDirectory1GEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
} else {
|
||||
//
|
||||
// Fill in the Page Directory entries
|
||||
@ -865,12 +895,13 @@ CreateIdentityMappingPageTables (
|
||||
} else {
|
||||
for ( IndexOfPdpEntries = 0
|
||||
; IndexOfPdpEntries < (NumberOfPml4EntriesNeeded == 1 ? NumberOfPdpEntriesNeeded : 512)
|
||||
; IndexOfPdpEntries++, PageDirectoryPointerEntry++) {
|
||||
; IndexOfPdpEntries++, PageDirectoryPointerEntry++)
|
||||
{
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
PageDirectoryEntry = (VOID *) BigPageAddress;
|
||||
PageDirectoryEntry = (VOID *)BigPageAddress;
|
||||
BigPageAddress += SIZE_4KB;
|
||||
|
||||
//
|
||||
@ -885,7 +916,7 @@ CreateIdentityMappingPageTables (
|
||||
//
|
||||
// Need to split this 2M page that covers NULL or stack range.
|
||||
//
|
||||
Split2MPageTo4K (PageAddress, (UINT64 *) PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
Split2MPageTo4K (PageAddress, (UINT64 *)PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize);
|
||||
} else {
|
||||
//
|
||||
// Fill in the Page Directory entries
|
||||
@ -901,7 +932,7 @@ CreateIdentityMappingPageTables (
|
||||
//
|
||||
// Fill with null entry for unused PDPTE
|
||||
//
|
||||
ZeroMem (PageDirectoryPointerEntry, (512 - IndexOfPdpEntries) * sizeof(PAGE_MAP_AND_DIRECTORY_POINTER));
|
||||
ZeroMem (PageDirectoryPointerEntry, (512 - IndexOfPdpEntries) * sizeof (PAGE_MAP_AND_DIRECTORY_POINTER));
|
||||
}
|
||||
}
|
||||
|
||||
@ -936,4 +967,3 @@ CreateIdentityMappingPageTables (
|
||||
|
||||
return (UINTN)PageMap;
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,12 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _VIRTUAL_MEMORY_H_
|
||||
#define _VIRTUAL_MEMORY_H_
|
||||
|
||||
|
||||
#define SYS_CODE64_SEL 0x38
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef union {
|
||||
@ -54,18 +53,18 @@ typedef struct {
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Reserved:1; // Reserved
|
||||
UINT64 MustBeZero:2; // Must Be Zero
|
||||
UINT64 Available:3; // Available for use by system software
|
||||
UINT64 PageTableBaseAddress:40; // Page Table Base Address
|
||||
UINT64 AvabilableHigh:11; // Available for use by system software
|
||||
UINT64 Nx:1; // No Execute bit
|
||||
UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Reserved : 1; // Reserved
|
||||
UINT64 MustBeZero : 2; // Must Be Zero
|
||||
UINT64 Available : 3; // Available for use by system software
|
||||
UINT64 PageTableBaseAddress : 40; // Page Table Base Address
|
||||
UINT64 AvabilableHigh : 11; // Available for use by system software
|
||||
UINT64 Nx : 1; // No Execute bit
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
} PAGE_MAP_AND_DIRECTORY_POINTER;
|
||||
@ -75,19 +74,19 @@ typedef union {
|
||||
//
|
||||
typedef union {
|
||||
struct {
|
||||
UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 PAT:1; //
|
||||
UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available:3; // Available for use by system software
|
||||
UINT64 PageTableBaseAddress:40; // Page Table Base Address
|
||||
UINT64 AvabilableHigh:11; // Available for use by system software
|
||||
UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
|
||||
UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 PAT : 1; //
|
||||
UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available : 3; // Available for use by system software
|
||||
UINT64 PageTableBaseAddress : 40; // Page Table Base Address
|
||||
UINT64 AvabilableHigh : 11; // Available for use by system software
|
||||
UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
} PAGE_TABLE_4K_ENTRY;
|
||||
@ -97,21 +96,21 @@ typedef union {
|
||||
//
|
||||
typedef union {
|
||||
struct {
|
||||
UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 MustBe1:1; // Must be 1
|
||||
UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available:3; // Available for use by system software
|
||||
UINT64 PAT:1; //
|
||||
UINT64 MustBeZero:8; // Must be zero;
|
||||
UINT64 PageTableBaseAddress:31; // Page Table Base Address
|
||||
UINT64 AvabilableHigh:11; // Available for use by system software
|
||||
UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
|
||||
UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 MustBe1 : 1; // Must be 1
|
||||
UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available : 3; // Available for use by system software
|
||||
UINT64 PAT : 1; //
|
||||
UINT64 MustBeZero : 8; // Must be zero;
|
||||
UINT64 PageTableBaseAddress : 31; // Page Table Base Address
|
||||
UINT64 AvabilableHigh : 11; // Available for use by system software
|
||||
UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
} PAGE_TABLE_ENTRY;
|
||||
@ -121,21 +120,21 @@ typedef union {
|
||||
//
|
||||
typedef union {
|
||||
struct {
|
||||
UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 MustBe1:1; // Must be 1
|
||||
UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available:3; // Available for use by system software
|
||||
UINT64 PAT:1; //
|
||||
UINT64 MustBeZero:17; // Must be zero;
|
||||
UINT64 PageTableBaseAddress:22; // Page Table Base Address
|
||||
UINT64 AvabilableHigh:11; // Available for use by system software
|
||||
UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
|
||||
UINT64 Present : 1; // 0 = Not present in memory, 1 = Present in memory
|
||||
UINT64 ReadWrite : 1; // 0 = Read-Only, 1= Read/Write
|
||||
UINT64 UserSupervisor : 1; // 0 = Supervisor, 1=User
|
||||
UINT64 WriteThrough : 1; // 0 = Write-Back caching, 1=Write-Through caching
|
||||
UINT64 CacheDisabled : 1; // 0 = Cached, 1=Non-Cached
|
||||
UINT64 Accessed : 1; // 0 = Not accessed, 1 = Accessed (set by CPU)
|
||||
UINT64 Dirty : 1; // 0 = Not Dirty, 1 = written by processor on access to page
|
||||
UINT64 MustBe1 : 1; // Must be 1
|
||||
UINT64 Global : 1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
|
||||
UINT64 Available : 3; // Available for use by system software
|
||||
UINT64 PAT : 1; //
|
||||
UINT64 MustBeZero : 17; // Must be zero;
|
||||
UINT64 PageTableBaseAddress : 22; // Page Table Base Address
|
||||
UINT64 AvabilableHigh : 11; // Available for use by system software
|
||||
UINT64 Nx : 1; // 0 = Execute Code, 1 = No Code Execution
|
||||
} Bits;
|
||||
UINT64 Uint64;
|
||||
} PAGE_TABLE_1G_ENTRY;
|
||||
@ -235,7 +234,6 @@ CreateIdentityMappingPageTables (
|
||||
IN UINTN GhcbkSize
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Fix up the vector number in the vector code.
|
||||
@ -251,7 +249,6 @@ AsmVectorFixup (
|
||||
UINT8 VectorNum
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Get the information of vector template.
|
||||
|
Reference in New Issue
Block a user