Skip to content

Commit

Permalink
OvmfPkg/PlatformInitLib: Add memory functions
Browse files Browse the repository at this point in the history
Below functions are introduced in PlatformInitLib:
 - PlatformGetFirstNonAddress
 - PlatformAddressWidthInitialization
 - PlatformGetSystemMemorySizeBelow4gb
 - PlatformQemuUc32BaseInitialization
 - PlatformInitializeRamRegions

They correspond to the below functions in OvmfPkg/PlatformPei:
 - GetFirstNonAddress
 - AddressWidthInitialization
 - GetSystemMemorySizeBelow4gb
 - QemuUc32BaseInitialization
 - InitializeRamRegions

Note: PlatformInitLib will not determine whether SMM or S3 is supported
or not. Instead the caller of these functions should input SMM / S3
support as the IN parameter by themselves. This is to reduce the
complexity of PlatformInitLib. Another reason is that some PCDs cannot
be declared as FixedAtBuild while PlatformInitLib is designed to be used
in both SEC and PEI phase.

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>
Signed-off-by: Min Xu <min.m.xu@intel.com>
  • Loading branch information
mxu9 committed Feb 19, 2022
1 parent c42ff9c commit ef0615c
Show file tree
Hide file tree
Showing 3 changed files with 788 additions and 0 deletions.
78 changes: 78 additions & 0 deletions OvmfPkg/Include/Library/PlatformInitLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,84 @@ PlatformDebugDumpCmos (
VOID
);

/**
* Return the highest address that DXE could possibly use, plus one.
*
* @param Pci64Base The 64-bit PCI host aperture base address.
* @param Pci64Size The 64-bit PCI host aperture size.
* @param DefaultPciMmio64Size The default 64-bit PCI host aperture size.
*
* @return The highest address that DXE could possibly use, plus one.
*/
UINT64
EFIAPI
PlatformGetFirstNonAddress (
OUT UINT64 *Pci64Base,
OUT UINT64 *Pci64Size,
IN UINT64 DefaultPciMmio64Size
);

/**
* Initialize the PhysMemAddressWidth variable, based on guest RAM size.
*
* @param FirstNonAddress The highest address that DXE could possibly use, plus one.
*
* @return The physical memory address width based on the guest RAM size.
*/
UINT8
EFIAPI
PlatformAddressWidthInitialization (
IN UINT64 FirstNonAddress
);

/**
* Get the memory size below 4GB.
*
* @return UINT32 The lower memory size.
*/
UINT32
EFIAPI
PlatformGetSystemMemorySizeBelow4gb (
VOID
);

/**
* Initializatoin of Qemu UC32Base.
*
* @param HostBridgeDevId The host bridge Dev Id.
* @param LowerMemorySize The lower memory size (under 4G).
* @return UINT32 The Qemu UC32 base address.
*/
UINT32
EFIAPI
PlatformQemuUc32BaseInitialization (
IN UINT16 HostBridgeDevId,
IN UINT32 LowerMemorySize
);

/**
Publish system RAM and reserve memory regions.
@param Uc32Base
@param HostBridgeDevId
@param SmmSmramRequire
@param BootMode
@param S3Supported
@param LowerMemorySize
@param Q35TsegMbytes
**/
VOID
EFIAPI
PlatformInitializeRamRegions (
IN UINT32 Uc32Base,
IN UINT16 HostBridgeDevId,
IN BOOLEAN SmmSmramRequire,
IN EFI_BOOT_MODE BootMode,
IN BOOLEAN S3Supported,
IN UINT32 LowerMemorySize,
IN UINT16 Q35TsegMbytes
);

VOID
EFIAPI
PlatformAddIoMemoryBaseSizeHob (
Expand Down

0 comments on commit ef0615c

Please sign in to comment.