!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc\r
\r
MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
[LibraryClasses.common.DXE_CORE]\r
HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc\r
\r
MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
[LibraryClasses.common.DXE_CORE]\r
HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
--- /dev/null
+/** @file\r
+ PlatformInitLib header file.\r
+\r
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef PLATFORM_INIT_LIB_H_\r
+#define PLATFORM_INIT_LIB_H_\r
+\r
+#include <PiPei.h>\r
+\r
+#pragma pack(1)\r
+typedef struct {\r
+ EFI_HOB_GUID_TYPE GuidHeader;\r
+ UINT16 HostBridgeDevId;\r
+\r
+ UINT64 PcdConfidentialComputingGuestAttr;\r
+ BOOLEAN SevEsIsEnabled;\r
+\r
+ UINT32 BootMode;\r
+ BOOLEAN S3Supported;\r
+\r
+ BOOLEAN SmmSmramRequire;\r
+ BOOLEAN Q35SmramAtDefaultSmbase;\r
+ UINT16 Q35TsegMbytes;\r
+\r
+ UINT64 FirstNonAddress;\r
+ UINT8 PhysMemAddressWidth;\r
+ UINT32 Uc32Base;\r
+ UINT32 Uc32Size;\r
+\r
+ BOOLEAN PcdSetNxForStack;\r
+ UINT64 PcdTdxSharedBitMask;\r
+\r
+ UINT64 PcdPciMmio64Base;\r
+ UINT64 PcdPciMmio64Size;\r
+ UINT32 PcdPciMmio32Base;\r
+ UINT32 PcdPciMmio32Size;\r
+ UINT64 PcdPciIoBase;\r
+ UINT64 PcdPciIoSize;\r
+\r
+ UINT64 PcdEmuVariableNvStoreReserved;\r
+ UINT32 PcdCpuBootLogicalProcessorNumber;\r
+ UINT32 PcdCpuMaxLogicalProcessorNumber;\r
+ UINT32 DefaultMaxCpuNumber;\r
+\r
+ UINT32 S3AcpiReservedMemoryBase;\r
+ UINT32 S3AcpiReservedMemorySize;\r
+} EFI_HOB_PLATFORM_INFO;\r
+#pragma pack()\r
+\r
+/**\r
+ Reads 8-bits of CMOS data.\r
+\r
+ Reads the 8-bits of CMOS data at the location specified by Index.\r
+ The 8-bit read value is returned.\r
+\r
+ @param Index The CMOS location to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PlatformCmosRead8 (\r
+ IN UINTN Index\r
+ );\r
+\r
+/**\r
+ Writes 8-bits of CMOS data.\r
+\r
+ Writes 8-bits of CMOS data to the location specified by Index\r
+ with the value specified by Value and returns Value.\r
+\r
+ @param Index The CMOS location to write.\r
+ @param Value The value to write to CMOS.\r
+\r
+ @return The value written to CMOS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PlatformCmosWrite8 (\r
+ IN UINTN Index,\r
+ IN UINT8 Value\r
+ );\r
+\r
+/**\r
+ Dump the CMOS content\r
+ */\r
+VOID\r
+EFIAPI\r
+PlatformDebugDumpCmos (\r
+ VOID\r
+ );\r
+\r
+#endif // PLATFORM_INIT_LIB_H_\r
--- /dev/null
+/** @file\r
+ PC/AT CMOS access routines\r
+\r
+ Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/PlatformInitLib.h>\r
+#include <Library/DebugLib.h>\r
+#include "Library/IoLib.h"\r
+\r
+/**\r
+ Reads 8-bits of CMOS data.\r
+\r
+ Reads the 8-bits of CMOS data at the location specified by Index.\r
+ The 8-bit read value is returned.\r
+\r
+ @param Index The CMOS location to read.\r
+\r
+ @return The value read.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PlatformCmosRead8 (\r
+ IN UINTN Index\r
+ )\r
+{\r
+ IoWrite8 (0x70, (UINT8)Index);\r
+ return IoRead8 (0x71);\r
+}\r
+\r
+/**\r
+ Writes 8-bits of CMOS data.\r
+\r
+ Writes 8-bits of CMOS data to the location specified by Index\r
+ with the value specified by Value and returns Value.\r
+\r
+ @param Index The CMOS location to write.\r
+ @param Value The value to write to CMOS.\r
+\r
+ @return The value written to CMOS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+PlatformCmosWrite8 (\r
+ IN UINTN Index,\r
+ IN UINT8 Value\r
+ )\r
+{\r
+ IoWrite8 (0x70, (UINT8)Index);\r
+ IoWrite8 (0x71, Value);\r
+ return Value;\r
+}\r
+\r
+/**\r
+ Dump the CMOS content\r
+ */\r
+VOID\r
+EFIAPI\r
+PlatformDebugDumpCmos (\r
+ VOID\r
+ )\r
+{\r
+ UINT32 Loop;\r
+\r
+ DEBUG ((DEBUG_INFO, "CMOS:\n"));\r
+\r
+ for (Loop = 0; Loop < 0x80; Loop++) {\r
+ if ((Loop % 0x10) == 0) {\r
+ DEBUG ((DEBUG_INFO, "%02x:", Loop));\r
+ }\r
+\r
+ DEBUG ((DEBUG_INFO, " %02x", PlatformCmosRead8 (Loop)));\r
+ if ((Loop % 0x10) == 0xf) {\r
+ DEBUG ((DEBUG_INFO, "\n"));\r
+ }\r
+ }\r
+}\r
--- /dev/null
+## @file\r
+# Platform Initialization Lib\r
+#\r
+# This module provides platform specific function to detect boot mode.\r
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = PlatformInitLib\r
+ FILE_GUID = 89f886b0-7109-46e1-9d28-503ad4ab6ee0\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PlatformInitLib|PEIM\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 EBC\r
+#\r
+\r
+[Sources]\r
+ Cmos.c\r
+\r
+[Packages]\r
+ MdeModulePkg/MdeModulePkg.dec\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ IoLib\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf\r
\r
MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
[LibraryClasses.common.DXE_CORE]\r
HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf\r
#\r
TdxMailboxLib|Include/Library/TdxMailboxLib.h\r
\r
+ ## @libraryclass PlatformInitLib\r
+ #\r
+ PlatformInitLib|Include/Library/PlatformInitLib.h\r
+\r
[Guids]\r
gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}\r
gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}\r
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf\r
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc\r
\r
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf\r
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc\r
\r
QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf\r
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf\r
+ PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf\r
\r
!include OvmfPkg/OvmfTpmLibsPeim.dsc.inc\r
\r
+++ /dev/null
-/** @file\r
- PC/AT CMOS access routines\r
-\r
- Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "Cmos.h"\r
-#include "Library/IoLib.h"\r
-\r
-/**\r
- Reads 8-bits of CMOS data.\r
-\r
- Reads the 8-bits of CMOS data at the location specified by Index.\r
- The 8-bit read value is returned.\r
-\r
- @param Index The CMOS location to read.\r
-\r
- @return The value read.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-CmosRead8 (\r
- IN UINTN Index\r
- )\r
-{\r
- IoWrite8 (0x70, (UINT8)Index);\r
- return IoRead8 (0x71);\r
-}\r
-\r
-/**\r
- Writes 8-bits of CMOS data.\r
-\r
- Writes 8-bits of CMOS data to the location specified by Index\r
- with the value specified by Value and returns Value.\r
-\r
- @param Index The CMOS location to write.\r
- @param Value The value to write to CMOS.\r
-\r
- @return The value written to CMOS.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-CmosWrite8 (\r
- IN UINTN Index,\r
- IN UINT8 Value\r
- )\r
-{\r
- IoWrite8 (0x70, (UINT8)Index);\r
- IoWrite8 (0x71, Value);\r
- return Value;\r
-}\r
+++ /dev/null
-/** @file\r
- PC/AT CMOS access routines\r
-\r
- Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __CMOS_H__\r
-#define __CMOS_H__\r
-\r
-/**\r
- Reads 8-bits of CMOS data.\r
-\r
- Reads the 8-bits of CMOS data at the location specified by Index.\r
- The 8-bit read value is returned.\r
-\r
- @param Index The CMOS location to read.\r
-\r
- @return The value read.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-CmosRead8 (\r
- IN UINTN Index\r
- );\r
-\r
-/**\r
- Writes 8-bits of CMOS data.\r
-\r
- Writes 8-bits of CMOS data to the location specified by Index\r
- with the value specified by Value and returns Value.\r
-\r
- @param Index The CMOS location to write.\r
- @param Value The value to write to CMOS.\r
-\r
- @return The value written to CMOS.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-CmosWrite8 (\r
- IN UINTN Index,\r
- IN UINT8 Value\r
- );\r
-\r
-#endif\r
#include <Library/MtrrLib.h>\r
#include <Library/QemuFwCfgLib.h>\r
#include <Library/QemuFwCfgSimpleParserLib.h>\r
+#include <Library/PlatformInitLib.h>\r
\r
#include "Platform.h"\r
-#include "Cmos.h"\r
\r
UINT8 mPhysMemAddressWidth;\r
\r
// into the calculation to get the total memory size.\r
//\r
\r
- Cmos0x34 = (UINT8)CmosRead8 (0x34);\r
- Cmos0x35 = (UINT8)CmosRead8 (0x35);\r
+ Cmos0x34 = (UINT8)PlatformCmosRead8 (0x34);\r
+ Cmos0x35 = (UINT8)PlatformCmosRead8 (0x35);\r
\r
return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);\r
}\r
\r
Size = 0;\r
for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {\r
- Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex);\r
+ Size = (UINT32)(Size << 8) + (UINT32)PlatformCmosRead8 (CmosIndex);\r
}\r
\r
return LShiftU64 (Size, 16);\r
#include <IndustryStandard/Pci22.h>\r
#include <IndustryStandard/Q35MchIch9.h>\r
#include <IndustryStandard/QemuCpuHotplug.h>\r
+#include <Library/PlatformInitLib.h>\r
#include <OvmfPlatforms.h>\r
\r
#include "Platform.h"\r
-#include "Cmos.h"\r
\r
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {\r
{\r
{\r
EFI_STATUS Status;\r
\r
- if (CmosRead8 (0xF) == 0xFE) {\r
+ if (PlatformCmosRead8 (0xF) == 0xFE) {\r
mBootMode = BOOT_ON_S3_RESUME;\r
}\r
\r
- CmosWrite8 (0xF, 0x00);\r
+ PlatformCmosWrite8 (0xF, 0x00);\r
\r
Status = PeiServicesSetBootMode (mBootMode);\r
ASSERT_EFI_ERROR (Status);\r
ASSERT_RETURN_ERROR (PcdStatus);\r
}\r
\r
-VOID\r
-DebugDumpCmos (\r
- VOID\r
- )\r
-{\r
- UINT32 Loop;\r
-\r
- DEBUG ((DEBUG_INFO, "CMOS:\n"));\r
-\r
- for (Loop = 0; Loop < 0x80; Loop++) {\r
- if ((Loop % 0x10) == 0) {\r
- DEBUG ((DEBUG_INFO, "%02x:", Loop));\r
- }\r
-\r
- DEBUG ((DEBUG_INFO, " %02x", CmosRead8 (Loop)));\r
- if ((Loop % 0x10) == 0xf) {\r
- DEBUG ((DEBUG_INFO, "\n"));\r
- }\r
- }\r
-}\r
-\r
VOID\r
S3Verification (\r
VOID\r
\r
DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));\r
\r
- DebugDumpCmos ();\r
+ PlatformDebugDumpCmos ();\r
\r
if (QemuFwCfgS3Enabled ()) {\r
DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));\r
[Sources]\r
AmdSev.c\r
ClearCache.c\r
- Cmos.c\r
- Cmos.h\r
FeatureControl.c\r
Fv.c\r
MemDetect.c\r
MemEncryptSevLib\r
PcdLib\r
VmgExitLib\r
+ PlatformInitLib\r
\r
[Pcd]\r
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase\r