mirror of https://github.com/acidanthera/audk.git
OvmfPkg/PlatformPei: Refactor InitializeRamRegions
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 InitializeRamRegions is refactored into 3 calls: - PlatformQemuInitializeRam - SevInitializeRam - PlatformQemuInitializeRamForS3 SevInitializeRam is not in PlatformInitLib. Because in the first stage PlatformInitLib only support the basic platform featues. PlatformQemuInitializeRamForS3 wraps the code which was previously in InitializeRamRegions (many code in 2 if-checks). Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Sebastien Boeuf <sebastien.boeuf@intel.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
parent
f3801cf26c
commit
e510326245
|
@ -161,7 +161,7 @@ PlatformQemuUc32BaseInitialization (
|
||||||
// variable MTRR suffices by truncating the size to a whole power of two,
|
// variable MTRR suffices by truncating the size to a whole power of two,
|
||||||
// while keeping the end affixed to 4GB. This will round the base up.
|
// while keeping the end affixed to 4GB. This will round the base up.
|
||||||
//
|
//
|
||||||
LowerMemorySize = GetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
||||||
PlatformInfoHob->Uc32Size = GetPowerOfTwo32 ((UINT32)(SIZE_4GB - LowerMemorySize));
|
PlatformInfoHob->Uc32Size = GetPowerOfTwo32 ((UINT32)(SIZE_4GB - LowerMemorySize));
|
||||||
PlatformInfoHob->Uc32Base = (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32Size);
|
PlatformInfoHob->Uc32Base = (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32Size);
|
||||||
//
|
//
|
||||||
|
@ -372,7 +372,8 @@ GetHighestSystemMemoryAddressFromPvhMemmap (
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
GetSystemMemorySizeBelow4gb (
|
EFIAPI
|
||||||
|
PlatformGetSystemMemorySizeBelow4gb (
|
||||||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -761,7 +762,7 @@ PublishPeiMemory (
|
||||||
UINT32 S3AcpiReservedMemoryBase;
|
UINT32 S3AcpiReservedMemoryBase;
|
||||||
UINT32 S3AcpiReservedMemorySize;
|
UINT32 S3AcpiReservedMemorySize;
|
||||||
|
|
||||||
LowerMemorySize = GetSystemMemorySizeBelow4gb (&mPlatformInfoHob);
|
LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob);
|
||||||
if (mPlatformInfoHob.SmmSmramRequire) {
|
if (mPlatformInfoHob.SmmSmramRequire) {
|
||||||
//
|
//
|
||||||
// TSEG is chipped from the end of low RAM
|
// TSEG is chipped from the end of low RAM
|
||||||
|
@ -871,7 +872,7 @@ QemuInitializeRamBelow1gb (
|
||||||
**/
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
QemuInitializeRam (
|
PlatformQemuInitializeRam (
|
||||||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -885,7 +886,7 @@ QemuInitializeRam (
|
||||||
//
|
//
|
||||||
// Determine total memory size available
|
// Determine total memory size available
|
||||||
//
|
//
|
||||||
LowerMemorySize = GetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
||||||
|
|
||||||
if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {
|
if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {
|
||||||
//
|
//
|
||||||
|
@ -995,19 +996,12 @@ QemuInitializeRam (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
STATIC
|
||||||
Publish system RAM and reserve memory regions
|
|
||||||
|
|
||||||
**/
|
|
||||||
VOID
|
VOID
|
||||||
InitializeRamRegions (
|
PlatformQemuInitializeRamForS3 (
|
||||||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
QemuInitializeRam (PlatformInfoHob);
|
|
||||||
|
|
||||||
SevInitializeRam ();
|
|
||||||
|
|
||||||
if (PlatformInfoHob->S3Supported && (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME)) {
|
if (PlatformInfoHob->S3Supported && (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME)) {
|
||||||
//
|
//
|
||||||
// This is the memory range that will be used for PEI on S3 resume
|
// This is the memory range that will be used for PEI on S3 resume
|
||||||
|
@ -1113,7 +1107,7 @@ InitializeRamRegions (
|
||||||
//
|
//
|
||||||
TsegSize = PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;
|
TsegSize = PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;
|
||||||
BuildMemoryAllocationHob (
|
BuildMemoryAllocationHob (
|
||||||
GetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize,
|
PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize,
|
||||||
TsegSize,
|
TsegSize,
|
||||||
EfiReservedMemoryType
|
EfiReservedMemoryType
|
||||||
);
|
);
|
||||||
|
@ -1152,3 +1146,19 @@ InitializeRamRegions (
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Publish system RAM and reserve memory regions
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
InitializeRamRegions (
|
||||||
|
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PlatformQemuInitializeRam (PlatformInfoHob);
|
||||||
|
|
||||||
|
SevInitializeRam ();
|
||||||
|
|
||||||
|
PlatformQemuInitializeRamForS3 (PlatformInfoHob);
|
||||||
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ MemMapInitialization (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TopOfLowRam = GetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
TopOfLowRam = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
|
||||||
PciExBarBase = 0;
|
PciExBarBase = 0;
|
||||||
if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
|
if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
|
||||||
//
|
//
|
||||||
|
|
|
@ -35,7 +35,8 @@ PublishPeiMemory (
|
||||||
);
|
);
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
GetSystemMemorySizeBelow4gb (
|
EFIAPI
|
||||||
|
PlatformGetSystemMemorySizeBelow4gb (
|
||||||
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue