OvmfPkg: Create initial version of PlatformInitLib
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 There are 3 variants of PlatformPei in OvmfPkg: - OvmfPkg/PlatformPei - OvmfPkg/XenPlatformPei - OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf These PlatformPeis can share many common codes, such as Cmos / Hob / Memory / Platform related functions. This commit (and its following several patches) are to create a PlatformInitLib which wraps the common code called in above PlatformPeis. In this initial version of PlatformInitLib, below Cmos related functions are introduced: - PlatformCmosRead8 - PlatformCmosWrite8 - PlatformDebugDumpCmos They correspond to the functions in OvmfPkg/PlatformPei: - CmosRead8 - CmosWrite8 - DebugDumpCmos Considering this PlatformInitLib will be used in SEC phase, global variables and dynamic PCDs are avoided. We use PlatformInfoHob to exchange information between functions. EFI_HOB_PLATFORM_INFO is the data struct which contains the platform information, such as HostBridgeDevId, BootMode, S3Supported, SmmSmramRequire, etc. After PlatformInitLib is created, OvmfPkg/PlatformPei is refactored with this library. 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> 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:
@@ -37,9 +37,9 @@ Module Name:
|
||||
#include <Library/MtrrLib.h>
|
||||
#include <Library/QemuFwCfgLib.h>
|
||||
#include <Library/QemuFwCfgSimpleParserLib.h>
|
||||
#include <Library/PlatformInitLib.h>
|
||||
|
||||
#include "Platform.h"
|
||||
#include "Cmos.h"
|
||||
|
||||
UINT8 mPhysMemAddressWidth;
|
||||
|
||||
@@ -412,8 +412,8 @@ GetSystemMemorySizeBelow4gb (
|
||||
// into the calculation to get the total memory size.
|
||||
//
|
||||
|
||||
Cmos0x34 = (UINT8)CmosRead8 (0x34);
|
||||
Cmos0x35 = (UINT8)CmosRead8 (0x35);
|
||||
Cmos0x34 = (UINT8)PlatformCmosRead8 (0x34);
|
||||
Cmos0x35 = (UINT8)PlatformCmosRead8 (0x35);
|
||||
|
||||
return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
|
||||
}
|
||||
@@ -436,7 +436,7 @@ GetSystemMemorySizeAbove4gb (
|
||||
|
||||
Size = 0;
|
||||
for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {
|
||||
Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex);
|
||||
Size = (UINT32)(Size << 8) + (UINT32)PlatformCmosRead8 (CmosIndex);
|
||||
}
|
||||
|
||||
return LShiftU64 (Size, 16);
|
||||
|
Reference in New Issue
Block a user