diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
index d35a1f27b4a54a6c079d7d1c68909b06e977bba1..d97aefa62aeb53f14d07071dd78468e741659a85 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) Common Module Package DEC
-# file.
-# This file provides the minimum AMD SoC/Mircoporcessor definitions for building
-# AMD edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
index 16370684325a2801af93e9b5bcaf36b29dc97244..256940132a9957f23731e187c0368d22e1d7be74 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -14,5 +14,3 @@
[Includes]
Include/AmdEdk2
-
-
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
index 37b8d15cb17cc2e14bae89e8bff074639daef578..bf01a8e4709d045429c9ac55455325a30ca17651 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
@@ -2,8 +2,8 @@
#
# The DSC include file for edk2 package to pull in the necessary AGESA modules
# into build process.
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
index b84fe5b7383b7a855690538f95bf535feaae8b9c..9c9fd3be643a84c57e71631a4b26e02d5c4d508a 100755
--- a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) FCH Module Package DEC
-# file.
-# This file provides the minimum AMD Core Complex package definitions for building AMD
-# edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
index 57db15e663ce6c1b95f92154d1a9a02e03896048..8f6d88e20120f288839dce944dd926d9c0b5b715 100755
--- a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) FCH Module Package DEC
-# file.
-# This file provides the minimum AMD Data Fabric package definitions for building AMD
-# edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
index 521957e809a392c1b7901fa88c7da8a2f7b8563f..71027fd9b4da631dfe27fb9edc5583264b49aa8d 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) FCH Module Package DEC
-# file.
-# This file provides the minimum AMD Fusion Control Hub package definitions for building AMD
-# edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
index 721d3ea73b9e89263cef481e5ffefad1ac6626c3..40dbe76ab17981e97916ba00b2806235d4bfd99d 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) NBIO Module Package DEC
-# file.
-# This file provides the minimum AMD Memory package definitions for building AMD
-# edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -21,6 +17,3 @@
[PcdsFixedAtBuild]
gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries|64|UINT32|0x00029001
-
-
-
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
index 0501774c9b0c8a144ef2e0c4ca656eaba733c3d0..9536b0b41e0bec3df31300ac240df5357e08abc9 100755
--- a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) NBIO Module Package DEC
-# file.
-# This file provides the minimum AMD North Bridge I/O package definitions for building AMD
-# edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
index 41cf320c76797a746ed7349b1c997154519bf6b2..3efc87fb0eed180e0eab9c97406157f44f38f7b4 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
+++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
@@ -1,10 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) NBIO Module Package DEC
-# file.
-# This file provides the minimum AMD Platform Security Processor package definitions
-# for building AMD edk2 modules.
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleRasPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleRasPkg.dec
new file mode 100644
index 0000000000000000000000000000000000000000..8d79f533af83e1278a8b4d9e5716bbe35f99c874
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleRasPkg.dec
@@ -0,0 +1,20 @@
+## @file
+#
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaRasPkg
+ PACKAGE_GUID = B517CFC7-446E-A818-5FB9-C985575EA47B
+ PACKAGE_VERSION = 0.2
+
+[Includes]
+ Include/
+ Include/Library/
+
+[Protocols]
+ gAmdRasInitDataProtocolGuid = {0x3C6ED57C, 0x4F6A, 0x8A58, {0x85, 0xDF, 0xDC, 0xA5, 0xAD, 0xF0, 0xF1, 0x6B}}
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.dxe.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..7c94de85906ae8dfc61a94ca45a6e7d0db919216
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.dxe.inc.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.inc.dsc
new file mode 100644
index 0000000000000000000000000000000000000000..2e4910831622f85f825df5c48355e77ab2691101
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.inc.dsc
@@ -0,0 +1,48 @@
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[LibraryClasses.common.SEC]
+
+[LibraryClasses.Common.PEIM]
+ ## APCB
+ ApcbLibV3Pei|AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
+
+[LibraryClasses.Common.DXE_DRIVER]
+ AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
+ ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
+
+[LibraryClasses.Common.DXE_SMM_DRIVER]
+ AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
+ ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
+
+[LibraryClasses]
+ #
+ # Agesa specific common libraries
+ #
+
+ ## PSP Libs
+ AmdPspBaseLibV2|AgesaModulePkg/Library/AmdPspBaseLibV2/AmdPspBaseLibV2.inf
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+
+ ## DF Lib
+ BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.inf
+
+ ## Fch Lib
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+ SmnAccessLib|AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
+ NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+
+[Components.IA32]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+
+[Components.X64]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.pei.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..f68e8a27d885d0f4d4552c8a3834687fce2f3002
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5BrhModulePkg.pei.inc.fdf
@@ -0,0 +1,9 @@
+## @file
+#
+# Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
index 9303d1fac4418333c46d2c627bc2275e35ee7e8a..476a21f662b3730ab7fedcc178174002b4bcf527 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
@@ -1,7 +1,7 @@
## @file
# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
#
-# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
index e7e05fd2d80624586252ee6f728d708ebc937e38..a5cf26b03f9cbd57ca313f0467c67de4b3a1d9ed 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
@@ -1,7 +1,7 @@
## @file
# The AGESA DSC file for building AMD SP5 Genoa boards.
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
index 0ef5a2a8062edcc94fe57193a674d4ab50599194..72aa5c5754cb7c943efec93bff94d8aa5669535a 100644
--- a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
@@ -1,7 +1,7 @@
## @file
# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
#
-# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Kunlun/FchKunlunCore/Kunlun/FchBreithorn.asi b/Platform/AMD/AgesaModulePkg/Fch/Kunlun/FchKunlunCore/Kunlun/FchBreithorn.asi
new file mode 100644
index 0000000000000000000000000000000000000000..35ebc4322c8c789424fceb71086474a8d9777230
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Fch/Kunlun/FchKunlunCore/Kunlun/FchBreithorn.asi
@@ -0,0 +1,1115 @@
+/** @file
+
+ Fch Return I2C I3C Interrupt
+
+ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+Scope(\_SB) {
+
+Name (TSOS, 0x75)
+
+If(CondRefOf(\_OSI))
+{
+ If(\_OSI("Windows 2009"))
+ {
+ Store(0x50, TSOS)
+ }
+ If(\_OSI("Windows 2015"))
+ {
+ Store(0x70, TSOS)
+ }
+}
+
+OperationRegion(ECMC, SystemIo, 0x72, 0x02)
+Field(ECMC, AnyAcc, NoLock, Preserve)
+{
+ ECMI, 8,
+ ECMD, 8,
+}
+IndexField(ECMI, ECMD, ByteAcc, NoLock, Preserve) {
+ Offset (0x08),
+ FRTB, 32,
+}
+OperationRegion(FRTP, SystemMemory, FRTB, 0x100)
+Field(FRTP, AnyAcc, NoLock, Preserve)
+{
+ PEBA, 64,
+ Offset (0x08),
+ , 4,
+ LPCE, 1, //LPC , 4
+ IC0E, 1, //I2C0, 5
+ IC1E, 1, //I2C1, 6
+ IC2E, 1, //I2C2, 7
+ IC3E, 1, //I2C3, 8
+ IC4E, 1, //I2C3, 9
+ IC5E, 1, //I2C3, 10
+ UT0E, 1, //UART0, 11
+ UT1E, 1, //UART1, 12
+ I31E, 1, //I3C1 13
+ I32E, 1, //I3C2, 14
+ I33E, 1, //I3C3, 15
+ UT2E, 1, //UART2, 16
+ , 1,
+ EMMD, 2, //18-19, EMMC Driver type, 0:AMD eMMC Driver (AMDI0040) 1:MS SD Driver (PNP0D40) 2:0:MS eMMC Driver (AMDI0040)
+ , 1, //UART4, 20
+ I30E, 1, //I3C0, 21
+ , 1,
+ XHCE, 1, //XCHI, 23
+ , 1, //24
+ , 1,
+ UT3E, 1, //UART3, 26
+ ESPI, 1, //ESPI 27
+ EMME, 1, //EMMC 28
+ Offset (0x0C),
+ PCEF, 1, // Post Code Enable Flag
+ , 4,
+ IC0D, 1, //I2C0, 5
+ IC1D, 1,
+ IC2D, 1,
+ IC3D, 1, //I2C3, 8
+ IC4D, 1, //I2C3, 9
+ IC5D, 1, //I2C3, 10
+ UT0D, 1, //UART0, 11
+ UT1D, 1, //UART1, 12
+ , 1, //, 13
+ , 1, //, 14
+ ST_D, 1, //SATA, 15
+ UT2D, 1, //UART2, 16
+ , 1,
+ EHCD, 1, //EHCI, 18
+ , 4,
+ XHCD, 1, //XCHI, 23
+ SD_D, 1, //SD, 24
+ , 1,
+ UT3D, 1, //UART1, 26
+ , 1,
+ EMD3, 1, //EMMC D3 28
+ , 2,
+ S03D, 1, //S0I3 flag, 31
+ Offset (0x10),
+ FW00, 16,
+ FW01, 32,
+ FW02, 16,
+ FW03, 32,
+ SDS0, 8, //SataDevSlpPort0S5Pin
+ SDS1, 8, //SataDevSlpPort1S5Pin
+ Offset (0x2A),
+ I30M, 1, //I3C 0 Mode
+ I31M, 1, //I3C 1 Mode
+ I32M, 1, //I3C 2 Mode
+ I33M, 1, //I3C 3 Mode
+ Offset (0x2E),
+ UT0I, 1, // UART0 Invisible 0
+ UT1I, 1, // UART1 Invisible 1
+ UT2I, 1, // UART2 Invisible 2
+ UT3I, 1, // UART3 Invisible 3
+ UT4I, 1, // UART4 Invisible 4
+ , 3,
+ UL0I, 1, // UART0 Legacy IO Invisible 8
+ UL1I, 1, // UART1 Legacy IO Invisible 9
+ UL2I, 1, // UART2 Legacy IO Invisible 10
+ UL3I, 1, // UART3 Legacy IO Invisible 11
+ Offset (0x30),
+ I20I, 1, // I2C0 Invisidble 0
+ I21I, 1, // I2C1 Invisidble 1
+ I22I, 1, // I2C2 Invisidble 2
+ I23I, 1, // I2C3 Invisidble 3
+ I24I, 1, // I2C4 Invisidble 4
+ I25I, 1, // I2C5 Invisidble 5
+ I30I, 1, // I3C0 Invisidble 6
+ I31I, 1, // I3C1 Invisidble 7
+ I32I, 1, // I3C2 Invisidble 8
+ I33I, 1, // I3C3 Invisidble 9
+ Offset (0x32),
+ IDPC, 8, // Identify Dimms per channel - Offset (0x32)
+}
+OperationRegion(FCFG, SystemMemory, PEBA, 0x01000000)
+Field(FCFG, DwordAcc, NoLock, Preserve)
+{
+ Offset(0x000A3044),
+ IPDE, 32, //IO Port Decode Enable
+ Offset(0x000A3048),
+ IMPE, 32, //IO Memory Port decode Enable
+ Offset(0x000A3078),
+ , 2,
+ LDQ0, 1, //
+ Offset(0x000A30CB),
+ , 7,
+ AUSS, 1, //AutoSizeStart
+}
+OperationRegion(IOMX, SystemMemory, 0xFED80D00, 0x100)
+Field(IOMX, AnyAcc, NoLock, Preserve)
+{
+ Offset (0x15),
+ IM15, 8, //
+ Offset (0x16),
+ IM16, 8, //
+ Offset (0x1F),
+ IM1F, 8, //
+ Offset (0x20),
+ IM20, 8, //
+ Offset (0x44),
+ IM44, 8, //
+ Offset (0x46),
+ IM46, 8, //
+ Offset (0x4A),
+ IM4A, 8, //
+ Offset (0x4B),
+ IM4B, 8, //
+ Offset (0x57),
+ IM57, 8, //
+ Offset (0x58),
+ IM58, 8, //
+ Offset (0x68),
+ IM68, 8, //
+ Offset (0x69),
+ IM69, 8, //
+ Offset (0x6A),
+ IM6A, 8, //
+ Offset (0x6B),
+ IM6B, 8, //
+ Offset (0x6D),
+ IM6D, 8, //
+}
+OperationRegion(FACR, SystemMemory, 0xFED81E00, 0x100) //Fch AoaC Register
+Field(FACR, AnyAcc, NoLock, Preserve)
+{
+ Offset (0x80),
+ ,28,
+ RD28, 1, //Request of Device 28, MAP
+ , 1,
+ RQTY, 1, //ReQuestTYpe
+ Offset (0x84),
+ ,28,
+ SD28, 1, //Status of Device 28, MAP
+ , 1,
+ Offset (0xA0), //AOACx0000A0 [PwrGood Control] (PwrGoodCtl)
+ PG1A, 1,
+}
+
+
+OperationRegion(LUIE, SystemMemory, 0xFEDC0020, 0x4) //Legacy Uart Io Enable
+Field(LUIE, AnyAcc, NoLock, Preserve)
+{
+ IER0, 1, //2E8
+ IER1, 1, //2F8
+ IER2, 1, //3E8
+ IER3, 1, //3F8
+ RESV, 4, //Reserved
+ WUR0, 2, // 0=Uart0, 1=Uart1, 2=Uart2, 3=Uart3
+ WUR1, 2, //
+ WUR2, 2, //
+ WUR3, 2, //
+}
+
+// Fch Return I2C/I3C Interrupt
+Method (FRII, 1, Serialized) {
+ if (LEqual (Arg0, 0)) {
+ return (IIC0)
+ } elseif (LEqual (Arg0, 1)) {
+ return (IIC1)
+ } elseif (LEqual (Arg0, 2)) {
+ return (IIC2)
+ } elseif (LEqual (Arg0, 3)) {
+ return (IIC3)
+ } elseif (LEqual (Arg0, 4)) {
+ return (IIC4)
+ } elseif (LEqual (Arg0, 5)) {
+ return (IIC5)
+ } else {
+ // Return IRQ10 should never be run, it avoids ASL compiler warning.
+ return (10)
+ }
+} // End of Method (FRII, 1, Serialized)
+
+// Fch Return Uart Interrupt
+Method (FRUI, 1, Serialized) {
+ if (LEqual (Arg0, 0)) {
+ return (IUA0)
+ } elseif (LEqual (Arg0, 1)) {
+ return (IUA1)
+ } elseif (LEqual (Arg0, 2)) {
+ return (IUA2)
+ } elseif (LEqual (Arg0, 3)) {
+ return (IUA3)
+ } else {
+ // Return IRQ3 should never be run, it avoids ASL compiler warning.
+ return (3)
+ }
+} // End of Method (FRUI
+
+Method(SRAD,2, Serialized) //SoftResetAoacDevice, Arg0:Device ID, Arg1:reset period in micro seconds
+{
+ ShiftLeft(Arg0, 1, Local0)
+ Add (Local0, 0xfed81e40, Local0)
+ OperationRegion( ADCR, SystemMemory, Local0, 0x02)
+ Field( ADCR, ByteAcc, NoLock, Preserve) { //AoacD3ControlRegister
+ ADTD, 2,
+ ADPS, 1,
+ ADPD, 1,
+ ADSO, 1,
+ ADSC, 1,
+ ADSR, 1,
+ ADIS, 1,
+ ADDS, 3,
+ }
+ store (one, ADIS) // IsSwControl = 1
+ store (zero, ADSR) // SwRstB = 0
+ stall (Arg1)
+ store (one, ADSR) // SwRstB = 1
+ store (zero, ADIS) // IsSwControl = 0
+ stall (Arg1)
+}
+Method(DSAD,2, Serialized) //DxSequenceAoacDevice, Arg0:Device ID, Arg1:3=D3, 0=D0
+{
+ ShiftLeft(Arg0, 1, Local0)
+ Add (Local0, 0xfed81e40, Local0)
+ OperationRegion( ADCR, SystemMemory, Local0, 0x02)
+ Field( ADCR, ByteAcc, NoLock, Preserve) { //AoacD3ControlRegister
+ ADTD, 2,
+ ADPS, 1,
+ ADPD, 1,
+ ADSO, 1,
+ ADSC, 1,
+ ADSR, 1,
+ ADIS, 1,
+ ADDS, 3,
+ }
+ if (LNotEqual(Arg0, ADTD)) {
+ if (LEqual(Arg1, 0)) {
+ //D0
+ store(0x00, ADTD)
+ store(one, ADPD)
+ store(ADDS, Local0)
+ while (LNotEqual(Local0,0x7)) {store(ADDS, Local0)}
+ }
+ if (LEqual(Arg1, 3)) {
+ //D3
+ store(zero, ADPD)
+ store(ADDS, Local0)
+ while (LNotEqual(Local0,0x0)) {store(ADDS, Local0)}
+ store(0x03, ADTD)
+ }
+ }
+}
+Method(HSAD,2, Serialized) //Hardware dx Sequence Aoac Device, Arg0:Device ID, Arg1:3=D3, 0=D0
+{
+ //ShiftLeft(1, Arg0, Local3) //caculate bit map location
+ ShiftLeft(Arg0, 1, Local0) //Caculate device register location
+ Add (Local0, 0xfed81e40, Local0)
+ OperationRegion( ADCR, SystemMemory, Local0, 0x02)
+ Field( ADCR, ByteAcc, NoLock, Preserve) { //AoacD3ControlRegister
+ ADTD, 2,
+ ADPS, 1,
+ ADPD, 1,
+ ADSO, 1,
+ ADSC, 1,
+ ADSR, 1,
+ ADIS, 1,
+ ADDS, 3,
+ }
+ if (LNotEqual(Arg1, ADTD)) {
+ if (LEqual(Arg1, 0)) {
+ store (One, PG1A) //power up
+ //D0
+ store(0x00, ADTD)
+ store(one, ADPD)
+ store(ADDS, Local0)
+ while (LNotEqual(Local0,0x7)) {store(ADDS, Local0)}
+ //Do hareware restore now
+ // Set RequestType to restore
+ store (one, RQTY)
+ store (one, RD28)
+ // Wait for restore complete
+ store (SD28, Local0)
+ while (LNot(Local0)) {store (SD28, Local0)}
+ }
+ if (LEqual(Arg1, 3)) {
+ //Do hareware save first
+ store (zero, RQTY)
+ store (one, RD28)
+ store (SD28, Local0)
+ while (Local0) {store (SD28, Local0)}
+ //D3
+ store(zero, ADPD)
+ store(ADDS, Local0)
+ while (LNotEqual(Local0,0x0)) {store(ADDS, Local0)}
+ store(0x03, ADTD)
+ store (Zero, PG1A) //power down
+ }
+ }
+}
+OperationRegion(FPIC, SystemIo, 0xc00, 0x02)//Fch Pci Interrupt Connector
+Field(FPIC, AnyAcc, NoLock, Preserve)
+{
+ FPII, 8,
+ FPID, 8,
+}
+IndexField(FPII, FPID, ByteAcc, NoLock, Preserve) {
+ Offset (0xF0), //Interrupt for I2C/I3C/UART
+ IIC0, 8,
+ IIC1, 8,
+ IIC2, 8,
+ IIC3, 8,
+ IUA0, 8,
+ IUA1, 8,
+ IIC4, 8,
+ IIC5, 8,
+ IUA2, 8,
+ IUA3, 8,
+}
+
+Method(CKUL,1, Serialized)
+{
+ //Check if legacy UART is enabled. Return 1: enabled, 0:no legacy UART enabled.
+ if (LAnd (LEqual (IER0, 1), LEqual (WUR0, Arg0))) {Return (1)}
+ elseif (LAnd (LEqual (IER1, 1), LEqual (WUR1, Arg0))) {Return (1)}
+ elseif (LAnd (LEqual (IER2, 1), LEqual (WUR2, Arg0))) {Return (1)}
+ elseif (LAnd (LEqual (IER3, 1), LEqual (WUR3, Arg0))) {Return (1)}
+ else {Return (0)}
+}
+
+ Device(GPIO) {
+ Name (_HID, "AMDI0030")
+ Name (_CID, "AMDI0030")
+ Name(_UID, 0)
+
+ Method (_CRS, 0x0, NotSerialized) {
+ Name (RBUF, ResourceTemplate () {
+ //
+ // Interrupt resource. In this example, banks 0 & 1 share the same
+ // interrupt to the parent controller and similarly banks 2 & 3.
+ //
+ // N.B. The definition below is chosen for an arbitrary
+ // test platform. It needs to be changed to reflect the hardware
+ // configuration of the actual platform
+ //
+ Interrupt(ResourceConsumer, Level, ActiveLow, Shared, , , ) {7}
+
+ //
+ // Memory resource. The definition below is chosen for an arbitrary
+ // test platform. It needs to be changed to reflect the hardware
+ // configuration of the actual platform.
+ //
+ Memory32Fixed(ReadWrite, 0xFED81500, 0x400)
+ //for 11 remote GPIO ( GPIO256~GPIO266)
+ Memory32Fixed(ReadWrite, 0xFED81200, 0x2C)
+ })
+
+ Return (RBUF)
+ }
+
+ Method(_STA, 0, NotSerialized) {
+ If (LGreaterEqual(TSOS, 0x70)) {
+ Return (0x0F)
+ } Else {
+ Return (0x00)
+ }
+ }
+ } // End Device GPIO
+
+
+ Device(FUR0) {
+ Name(_HID,"AMDI0020") // UART Hardware Device ID
+ Name(_UID,"ID00")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {3}
+ Memory32Fixed(ReadWrite, 0xFEDC9000, 0x1000)
+ Memory32Fixed(ReadWrite, 0xFEDC7000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IUA0, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ If (LGreaterEqual(TSOS, 0x70)) {
+ if (LEqual(UT0E, one)) {
+ if (LEqual(CKUL(0), one) ) {Return (0)} //if legacy uart enabled ,hide it.
+ if (LEqual(UT0I, one) ) {Return (0)}
+ Return (0x0F)
+ }
+ Return (0x00)
+ } Else {
+ Return (0x00)
+ }
+ }
+ } // End Device FUR0
+
+ Device(FUR1) {
+ Name(_HID,"AMDI0020") // UART Hardware Device ID
+ Name(_UID,"ID01")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {14}
+ Memory32Fixed(ReadWrite, 0xFEDCA000, 0x1000)
+ Memory32Fixed(ReadWrite, 0xFEDC8000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IUA1, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ If (LGreaterEqual(TSOS, 0x70)) {
+ if (LEqual(UT1E, one)) {
+ if (LEqual(CKUL(1), one) ) {Return (0)} //if legacy uart enabled ,hide it.
+ if (LEqual(UT1I, one) ) {Return (0)}
+ Return (0x0F)
+ }
+ Return (0x00)
+ } Else {
+ Return (0x00)
+ }
+ }
+ } // End Device FUR1
+
+ Device(FUR2) {
+ Name(_HID,"AMDI0020") // UART Hardware Device ID
+ Name(_UID,"ID02")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {5}
+ Memory32Fixed(ReadWrite, 0xFEDCE000, 0x1000)
+ Memory32Fixed(ReadWrite, 0xFEDCC000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IUA2, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ If (LGreaterEqual(TSOS, 0x70)) {
+ if (LEqual(UT2E, one)) {
+ if (LEqual(CKUL(2), one) ) {Return (0)} //if legacy uart enabled ,hide it.
+ if (LEqual(UT2I, one) ) {Return (0)}
+ Return (0x0F)
+ }
+ Return (0x00)
+ } Else {
+ Return (0x00)
+ }
+ }
+ } // End Device FUR2
+
+ Device(FUR3) {
+ Name(_HID,"AMDI0020") // UART Hardware Device ID
+ Name(_UID,"ID03")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {15}
+ Memory32Fixed(ReadWrite, 0xFEDCF000, 0x1000)
+ Memory32Fixed(ReadWrite, 0xFEDCD000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IUA3, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ If (LGreaterEqual(TSOS, 0x70)) {
+ if (LEqual(UT3E, one)) {
+ if (LEqual(CKUL(3), one) ) {Return (0)} //if legacy uart enabled ,hide it.
+ if (LEqual(UT3I, one) ) {Return (0)}
+ Return (0x0F)
+ }
+ Return (0x00)
+ } Else {
+ Return (0x00)
+ }
+ }
+ } // End Device FUR3
+
+ Device(I2CA) {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x0)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {10}
+ Memory32Fixed(ReadWrite, 0xFEDC2000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC0, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC0E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I20I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (5, 200)}
+
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ if (LEqual(IDPC, one) || LEqual(IDPC, 2)) {
+ Return(Buffer(One){0x01})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CA
+
+ Device(I2CB)
+ {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x1)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {11}
+ Memory32Fixed(ReadWrite, 0xFEDC3000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC1, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC1E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I21I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (6, 200)}
+
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ if (LEqual(IDPC, one) || LEqual(IDPC, 2)) {
+ Return(Buffer(One){0x01})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CB
+
+ Device(I2CC) {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x2)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {4}
+ Memory32Fixed(ReadWrite, 0xFEDC4000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC2, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC2E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I22I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (7, 200)}
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ if (LEqual(IDPC, 2)) {
+ Return(Buffer(One){0x01})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CC
+
+ Device(I2CD) {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x3)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {6}
+ Memory32Fixed(ReadWrite, 0xFEDC5000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC3, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC3E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I23I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+ Method(RSET,0) { SRAD (8, 200)}
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ if (LEqual(IDPC, 2)) {
+ Return(Buffer(One){0x01})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CD
+
+ Device(I2CE) {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x4)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {22}
+ Memory32Fixed(ReadWrite, 0xFEDC6000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC4, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC4E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I24I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (9, 200)}
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ Return(Buffer(One){0x00})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CE
+
+ Device(I2CF) {
+ Name(_HID,"AMDI0010") // Hardware Device ID
+ Name(_UID,0x5)
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {23}
+ Memory32Fixed(ReadWrite, 0xFEDCB000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC5, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(IC5E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I25I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (10, 200)}
+ Method(_DSM, 0x4, NotSerialized)
+ {
+ If(LEqual(Arg0, ToUUID("48DFFC9D-B5A5-48B0-8BA8-28D4E674B25A")))
+ {
+ Return(Buffer(One){0x00})
+ } Else {
+ Return(Buffer(One){0x00})
+ }
+ }
+ } // End Device I2CF
+
+
+ Device(I3CA) {
+ Name(_UID,0x0)
+ // I3C DisCo Definition
+ Name(_HID, "AMDI0015")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {10}
+ Memory32Fixed(ReadWrite, 0xFEDD2000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC0, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(I30E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I30I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (21, 200)}
+
+} // End Device I3C0
+
+
+ Device(I3CB) {
+ Name(_UID,0x1)
+ // I3C DisCo Definition
+ Name(_HID, "AMDI0015")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {11}
+ Memory32Fixed(ReadWrite, 0xFEDD3000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC1, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(I31E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I31I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (13, 200)}
+
+} // End Device I3C1
+
+
+ Device(I3CC) {
+ Name(_UID,0x2)
+ // I3C DisCo Definition
+ Name(_HID, "AMDI0015")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {4}
+ Memory32Fixed(ReadWrite, 0xFEDD4000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC2, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(I32E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I32I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (14, 200)}
+
+} // End Device I3C2
+
+
+ Device(I3CD) {
+ Name(_UID,0x3)
+ // I3C DisCo Definition
+ Name(_HID, "AMDI0015")
+ Method(_CRS, 0, Serialized) {
+ Name(BUF0, ResourceTemplate(){
+ Interrupt(ResourceConsumer, Edge, ActiveHigh, Exclusive) {6}
+ Memory32Fixed(ReadWrite, 0xFEDD6000, 0x1000)
+ })
+ // Create pointers to the specific byte
+ CreateWordField (BUF0, 0x05, IRQW)
+ //Modify the IRQ
+ Store (IIC3, IRQW)
+ Return(BUF0) // return the result
+ }// end _CRS method
+
+ Method(_STA, 0, NotSerialized) {
+ Store (0x0, Local0)
+ If (LGreaterEqual(TSOS, 0x70)) {
+ If (LEqual(I33E, one)) {
+ Store (0x0F, Local0)
+ }
+ }
+ If (LEqual (I33I, One)) {
+ Store (0x0, Local0)
+ }
+ Return (Local0)
+ }
+
+ Method(RSET,0) { SRAD (15, 200)}
+
+} // End Device I3C3
+
+
+
+Device(UAR4) { // UART COM Port 0x2E8
+ Name(_HID, EISAID("PNP0501"))
+ Name(_DDN, "COM4")
+ Name(_UID, 0x4)
+ //*****************************************************
+ // Method _STA: Return Status
+ //*****************************************************
+ Method (_STA, 0, NotSerialized) { // Return Status of the UART
+ if (IER0) {Return (0x0f)}
+ Return (0x00)
+ } // end of Method _STA
+ //*****************************************************
+ // Method _CRS: Return Current Resource Settings
+ //*****************************************************
+ Method (_CRS, 0, NotSerialized) {
+ Name (BUF0, ResourceTemplate() {
+ IO (Decode16, 0x2E8, 0x2E8, 0x01, 0x08)
+ IRQNoFlags() {3}
+ })
+ //
+ // Create some ByteFields in the Buffer in order to
+ // permit saving values into the data portions of
+ // each of the descriptors above.
+ //
+ // CreateByteField (BUF0, 0x02, IOLO) // IO Port Low
+ // CreateByteField (BUF0, 0x03, IOHI) // IO Port Hi
+ // CreateByteField (BUF0, 0x04, IORL) // IO Port Low
+ // CreateByteField (BUF0, 0x05, IORH) // IO Port High
+ CreateWordField (BUF0, 0x09, IRQL) // IRQ
+ //
+ // Get the IO setting from the chip, and copy it
+ // to both the min & max for the IO descriptor.
+ //
+ // Low Bytes:
+ //Store (CR61, IOLO) // min.
+ //Store (CR61, IORL) // max.
+ // High Bytes:
+ //Store (CR60, IOHI) // min.
+ //Store (CR60, IORH) // max.
+ //
+ // Get the IRQ setting from the chip, and shift
+ // it into the IRQ descriptor word (bitwise).
+ //
+ ShiftLeft (One, And (FRUI (WUR0), 0x0F), IRQL)
+ Return(BUF0) // return the result
+ } // end _CRS Method
+} // end of Device UART1
+
+Device(UAR2) { // COM Port 0x2F8
+ Name(_HID, EISAID("PNP0501"))
+ Name(_DDN, "COM2")
+ Name(_UID, 0x2)
+ //*****************************************************
+ // Method _STA: Return Status
+ //*****************************************************
+ Method (_STA, 0, NotSerialized) { // Return Status of the UART
+ if (IER1) {Return (0x0f)}
+ Return (0x00)
+ } // end of Method _STA
+ //*****************************************************
+ // Method _CRS: Return Current Resource Settings
+ //*****************************************************
+ Method (_CRS, 0, NotSerialized) {
+ Name (BUF0, ResourceTemplate() {
+ IO (Decode16, 0x2F8, 0x2F8, 0x01, 0x08)
+ IRQNoFlags() {4}
+ })
+ //
+ // Create some ByteFields in the Buffer in order to
+ // permit saving values into the data portions of
+ // each of the descriptors above.
+ //
+ // CreateByteField (BUF0, 0x02, IOLO) // IO Port Low
+ // CreateByteField (BUF0, 0x03, IOHI) // IO Port Hi
+ // CreateByteField (BUF0, 0x04, IORL) // IO Port Low
+ // CreateByteField (BUF0, 0x05, IORH) // IO Port High
+ CreateWordField (BUF0, 0x09, IRQL) // IRQ
+ //
+ // Get the IO setting from the chip, and copy it
+ // to both the min & max for the IO descriptor.
+ //
+ // Low Bytes:
+ //Store (CR61, IOLO) // min.
+ //Store (CR61, IORL) // max.
+ // High Bytes:
+ //Store (CR60, IOHI) // min.
+ //Store (CR60, IORH) // max.
+ //
+ // Get the IRQ setting from the chip, and shift
+ // it into the IRQ descriptor word (bitwise).
+ //
+ ShiftLeft (One, And (FRUI (WUR1), 0x0F), IRQL)
+ Return(BUF0) // return the result
+ } // end _CRS Method
+} // end of Device UART2
+
+Device(UAR3) { // COM Port 0x3E8
+ Name(_HID, EISAID("PNP0501"))
+ Name(_DDN, "COM3")
+ Name(_UID, 0x3)
+ //*****************************************************
+ // Method _STA: Return Status
+ //*****************************************************
+ Method (_STA, 0, NotSerialized) { // Return Status of the UART
+ if (IER2) {Return (0x0f)}
+ Return (0x00)
+ } // end of Method _STA
+ //*****************************************************
+ // Method _CRS: Return Current Resource Settings
+ //*****************************************************
+ Method (_CRS, 0, NotSerialized) {
+ Name (BUF0, ResourceTemplate() {
+ IO (Decode16, 0x3E8, 0x3E8, 0x01, 0x08)
+ IRQNoFlags() {3}
+ })
+ //
+ // Create some ByteFields in the Buffer in order to
+ // permit saving values into the data portions of
+ // each of the descriptors above.
+ //
+ // CreateByteField (BUF0, 0x02, IOLO) // IO Port Low
+ // CreateByteField (BUF0, 0x03, IOHI) // IO Port Hi
+ // CreateByteField (BUF0, 0x04, IORL) // IO Port Low
+ // CreateByteField (BUF0, 0x05, IORH) // IO Port High
+ CreateWordField (BUF0, 0x09, IRQL) // IRQ
+ //
+ // Get the IO setting from the chip, and copy it
+ // to both the min & max for the IO descriptor.
+ //
+ // Low Bytes:
+ //Store (CR61, IOLO) // min.
+ //Store (CR61, IORL) // max.
+ // High Bytes:
+ //Store (CR60, IOHI) // min.
+ //Store (CR60, IORH) // max.
+ //
+ // Get the IRQ setting from the chip, and shift
+ // it into the IRQ descriptor word (bitwise).
+ //
+ ShiftLeft (One, And (FRUI (WUR2), 0x0F), IRQL)
+ Return(BUF0) // return the result
+ } // end _CRS Method
+} // end of Device UART3
+
+Device(UAR1) { // COM Port 0x3F8
+ Name(_HID, EISAID("PNP0501"))
+ Name(_DDN, "COM1")
+ Name(_UID, 0x1)
+ //*****************************************************
+ // Method _STA: Return Status
+ //*****************************************************
+ Method (_STA, 0, NotSerialized) { // Return Status of the UART
+ if (IER3) {Return (0x0f)}
+ Return (0x00)
+ } // end of Method _STA
+ //*****************************************************
+ // Method _CRS: Return Current Resource Settings
+ //*****************************************************
+ Method (_CRS, 0, NotSerialized) {
+ Name (BUF0, ResourceTemplate() {
+ IO (Decode16, 0x3F8, 0x3F8, 0x01, 0x08)
+ IRQNoFlags() {4}
+ })
+ //
+ // Create some ByteFields in the Buffer in order to
+ // permit saving values into the data portions of
+ // each of the descriptors above.
+ //
+ // CreateByteField (BUF0, 0x02, IOLO) // IO Port Low
+ // CreateByteField (BUF0, 0x03, IOHI) // IO Port Hi
+ // CreateByteField (BUF0, 0x04, IORL) // IO Port Low
+ // CreateByteField (BUF0, 0x05, IORH) // IO Port High
+ CreateWordField (BUF0, 0x09, IRQL) // IRQ
+ //
+ // Get the IO setting from the chip, and copy it
+ // to both the min & max for the IO descriptor.
+ //
+ // Low Bytes:
+ //Store (CR61, IOLO) // min.
+ //Store (CR61, IORL) // max.
+ // High Bytes:
+ //Store (CR60, IOHI) // min.
+ //Store (CR60, IORH) // max.
+ //
+ // Get the IRQ setting from the chip, and shift
+ // it into the IRQ descriptor word (bitwise).
+ //
+ ShiftLeft (One, And (FRUI (WUR3), 0x0F), IRQL)
+ Return(BUF0) // return the result
+ } // end _CRS Method
+} // end of Device UART4
+
+} // End of Scope(\_SB)
+
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
index 72b9a876393e0fffa0d6b5566c211c463a89ade4..719e47d4a24a1013872d4dcfe13a5351bcacf6c9 100644
--- a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
+++ b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
@@ -1,9 +1,9 @@
-/** @file
-
- Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
+/** @file
+
+ Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
index 3ec03aafd39cbe0b8736f9f4c815ec7cc9ee2edf..3ed500ffc2a2863843b75cac6d7f1d72a52d6fb9 100644
--- a/Platform/AMD/AgesaModulePkg/Include/AGESA.h
+++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/AgesaModulePkg/Include/AMD.h
index 062d9e1e1aabed305ccd77a9ff666010306b5773..1caa4a6be4de69f97c2714c55aea623f213982a6 100755
--- a/Platform/AMD/AgesaModulePkg/Include/AMD.h
+++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
index 534b03d4a755a9f32776bb6ef83489a0cae09448..6c8f3eac514067a456a3101bb28796fcd5ead92b 100755
--- a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPU Register Table Related Functions.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
index e086a4c9b184a8707244ea5f1c3327132464da30..1328cf45ee9c98b2fea7d033960a5836d4dae83d 100644
--- a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
@@ -1,7 +1,7 @@
/** @file
AMD Psp Directory header file
- Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
index faa8d35b1b1210fa993a1be046db992f83706e37..dd7052004a23f382edf98a76862018a6cc183569 100755
--- a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
+++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPU Register Table Related Definitions.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
index 8ede1be83881453a4b866579ac0296a93806fa98..5b65f48a1edb6aaa297735e7810e2ab4604df9f2 100644
--- a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
+++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -75,7 +75,7 @@
#define FCH_SPI_R2MSK25 0x00000008l //
#define FCH_SPI_MMIO_REG45_CMDCODE 0x45 //
#define FCH_SPI_MMIO_REG47_CMDTRIGGER 0x47 //
-#define FCH_SPI_MMIO_REG48_TXBYTECOUNT 0x48 //
+#define FCH_SPI_MMIO_REG48_TX_BYTECOUNT 0x48 //
#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 0x4B //
#define FCH_SPI_MMIO_REG4C_SPISTATUS 0x4C //
#define FCH_SPI_MMIO_REG5C_Addr32_Ctrl3 0x5C //
diff --git a/Platform/AMD/AgesaModulePkg/Include/Filecode.h b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
index 726479d79f5104f8fa7f9604b82121f4c1c11178..74ee5f3d190f5d06ca6e2b77a03546b4c3d70387 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Filecode.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -23,9 +23,9 @@
* @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800 (Mon, 09 Feb 2015) $
*/
-#ifndef _FILECODE_H_
-#define _FILECODE_H_
+#ifndef FILECODE_H_
+#define FILECODE_H_
#define UNASSIGNED_FILE_FILECODE (0xFFFF)
-#endif // _FILECODE_H_
+#endif // FILECODE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
index ddc9309d3d395153171c14615d3aa3338c3aa7d0..b330b3c359e4446d03c1bff8b98533d2316dc2ac 100755
--- a/Platform/AMD/AgesaModulePkg/Include/Gnb.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
index 192e0d6a8bfc6d95d5d6df0129c96d009bb1197a..8928347ddad11cf2bb85b6e552b0bc5a5620398d 100644
--- a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -34,6 +34,8 @@
#define DESCRIPTOR_ALL_TYPES (DESCRIPTOR_ALL_WRAPPERS | DESCRIPTOR_ALL_ENGINES | DESCRIPTOR_SILICON | DESCRIPTOR_PLATFORM)
#define PcieLibGetNextDescriptor(Descriptor) ((Descriptor == NULL) ? NULL : ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
+#define SILICON_CXL_CAPABLE 0x00008000ull
+
typedef UINT16 PCIE_ENGINE_INIT_STATUS;
///
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH.h
new file mode 100644
index 0000000000000000000000000000000000000000..e34f24a7a8d879f888f659180d40b6180f91cf9d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH.h
@@ -0,0 +1,18 @@
+/** @file
+
+ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBREGISTERSBRH_H_
+#define GNBREGISTERSBRH_H_
+
+#include "GnbRegistersBRH/IOHC.h"
+
+#ifndef NBIO_SPACE
+#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + ((HANDLE->RBIndex & 0x3) << 20))
+#endif
+
+#endif /* GNBREGISTERSBRH_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH/IOHC.h
new file mode 100644
index 0000000000000000000000000000000000000000..d2368be9bda5d2911b2d2c59c219c82b9915670d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersBRH/IOHC.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef IOHC_H_
+#define IOHC_H_
+
+#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
+
+#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
+
+#define SMN_IOHUB0NBIO0_IOAPIC_BASE_ADDR_LO_ADDRESS 0x13b102f0UL
+
+#define SMN_IOHUB0NBIO0_IOAPIC_BASE_ADDR_LO_ADDRESS 0x13b102f0UL
+#define IOAPIC_BASE_ADDR_LO_IOAPIC_BASE_ADDR_LO_MASK 0xffffff00
+#define SMN_IOHUB1NBIO0_IOAPIC_BASE_ADDR_LO_ADDRESS 0x1d4102f0UL
+
+#endif /* IOHC_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
index 90f52cca7bc96317f47ebb603a0af7410f2fc02c..4c2a0bdc44d052eca212995bb2ea4315b2cb245f 100644
--- a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
index b1a95237decdf69dce68c7b7b05905d1d0831e3a..8dbed5769fc22a9779f31542756634baf47d5919 100644
--- a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
index f5cc5e2228dcd4c3ebbdc166fff5bc37a10c8c18..6d8f6cb5a0eae9bff5c4bafb8ce08a689b61bd68 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
index dc773737b9d306e9b85b29f1a0465d686e6ffc88..a25ac9c5bad0dc9762e67a594612ee65edc1df25 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
@@ -1,7 +1,6 @@
/** @file
- Contains interface to the AMD AGESA library.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
index 9d9892aa30425fb2ced7bf3763df091fa78c3519..0158108f1ab59ce0f006f82b37dfafefcc6c4ed5 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -19,8 +19,8 @@
* @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue, 03 Feb 2015) $
*/
-#ifndef _PSP_MBOX_H_
-#define _PSP_MBOX_H_
+#ifndef PSP_MBOX_H_
+#define PSP_MBOX_H_
/**
* @brief Bios send these commands to PSP to grant dTPM status and event log
@@ -40,4 +40,4 @@ PspMboxGetDTPMData (
OUT VOID *LogData
);
-#endif //_PSP_MBOX_H_
+#endif // PSP_MBOX_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
index 51935f413aa25990e32d85636ef045fe49141167..ab321988b0b6a24145d9d81a2c8e1b1f3c11c97a 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -19,4 +19,18 @@ FabricTopologyGetNumberOfRootBridgesOnSocket (
IN UINTN Socket
);
+UINTN
+FabricTopologyGetHostBridgeBusBase (
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Index
+ );
+
+UINTN
+FabricTopologyGetHostBridgeBusLimit (
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Index
+ );
+
#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
index cae3aff9b39834e93c66537368d72297c529e12f..897c225df7f34f5f66419d0e00e21c6d6db9be62 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _FCH_BASE_LIB_H_
-#define _FCH_BASE_LIB_H_
+#ifndef FCH_BASE_LIB_H_
+#define FCH_BASE_LIB_H_
#include
#include
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
index 345e39adce3b97fd810be43d59c98726a901857b..cd0b85e90df78d296e12feed89cb1778ec14f764 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _FCH_ESPI_CMD_LIB_H_
-#define _FCH_ESPI_CMD_LIB_H_
+#ifndef FCH_ESPI_CMD_LIB_H_
+#define FCH_ESPI_CMD_LIB_H_
#include
@@ -410,4 +410,4 @@ FchEspiCmd_SafsRpmcOp2 (
OUT UINT8 *Buffer
);
-#endif
+#endif // FCH_ESPI_CMD_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
index 19688e25483ee3f8d8ad5a616ca26f42d6edeecd..3abe9f8a4f6479c14e4d0fef3c1e59fda8d6e0b1 100755
--- a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
@@ -1,7 +1,6 @@
/** @file
- GNB PCIe Library definition.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
index df882745303e60be6be928129f2ac218d5d1a60a..14d3596cebfd8698da237e77c9bfd0150b483b8e 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
@@ -1,7 +1,6 @@
/** @file
- Header file of AMD NBIO Common DXE library.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
index 4fec578a9f186b675b6cd5e70775f589c5a838f8..6b3aada1f3062b87141658d1e6324623ec246bcc 100755
--- a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
@@ -1,8 +1,6 @@
/** @file
- GNB function to GetHostPciAddress and GetHandle.
- Contain code that create/locate and rebase configuration data area.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
index 9f5374681440840f4db3daa4737e054c34e78e6b..1ee27e7e949465a959a0a165cf734bdeff990cee 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
@@ -1,7 +1,6 @@
/** @file
- Helper functions to access PCIe configuration data area.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
index f0c6d1ccbb2c553e76f53ef7577a7f7787122b53..a58d0f663abb52bd353e6ea98574f9af9a09d461 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
@@ -1,15 +1,16 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _SMNACCESSLIB_H_
-#define _SMNACCESSLIB_H_
+#ifndef SMNACCESSLIB_H_
+#define SMNACCESSLIB_H_
VOID
+EFIAPI
SmnRegisterReadS (
IN UINT32 SegmentNumber,
IN UINT32 BusNumber,
@@ -18,6 +19,7 @@ SmnRegisterReadS (
);
VOID
+EFIAPI
SmnRegisterRMWS (
IN UINT32 SegmentNumber,
IN UINT32 BusNumber,
@@ -27,4 +29,4 @@ SmnRegisterRMWS (
IN UINT32 Flags
);
-#endif
+#endif // SMNACCESSLIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
index 0e08e64b248865e4f7cd62ed9258db6b52a34efb..57e98931eeb84e284fbea89a1506a2352e5467d4 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
index 10d3b730a6f13822ada658fe1353fb6ba8d0edd1..610f89b54608d63b49f05670879ab99d78ba0739 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
@@ -1,14 +1,14 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
-#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
+#ifndef AMD_OEM_OOB_PPR_PROTOCOL_H_
+#define AMD_OEM_OOB_PPR_PROTOCOL_H_
extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
-#endif
+#endif // AMD_OEM_OOB_PPR_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
index a15995188b4698e98103ce22f0b29cebbe89a184..a16f4084e43405cada8e97fd8504e4cba4b62793 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2018-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
index 485240c0fb0330c3f6eff58e6a122108d50da89e..8c08cc60f4966b2f476d0bf9079022c4d84256b7 100644
--- a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
index 44093e40970c5cebb933509f57d1104f5596061c..a81c3edb5389badd7fde9a7840d3bb3e6746522b 100755
--- a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
+++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
@@ -1,7 +1,6 @@
/** @file
- SoC Logical ID Definitions.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
index 8d3357bf56c3c1f92e1a7134849fe4eaa072f327..43606ad20bae91c7bbe398995bce09a711bca23a 100755
--- a/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -23,7 +23,3 @@
[LibraryClasses]
BaseLib
PcdLib
-
-
-
-
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspBaseLibV2/AmdPspBaseLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspBaseLibV2/AmdPspBaseLibV2.inf
new file mode 100644
index 0000000000000000000000000000000000000000..21da77402287768f9908f3071de9dee3e078c289
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspBaseLibV2/AmdPspBaseLibV2.inf
@@ -0,0 +1,18 @@
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspBaseLibV2
+ FILE_GUID = 3463D317-7619-4350-A7BB-64DA224D7DFD
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspBaseLibV2
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
index fa83888e95bee3d525b5a408a0911a33bd92c84f..ba53ff15da75ed5b1d6100a8c9abf6f5b09bbb21 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
@@ -1,7 +1,6 @@
/** @file
- PSP Mailbox related functions
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
index 1594a99265a84bde4061c6cecf916b810a5b7678..ccb9fb2aacd3b7fda3befe659bbcc5130d9dd8cb 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
@@ -1,30 +1,27 @@
-## @file
-#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = AmdPspMboxLibV2
- FILE_GUID = B9E57A31-CAB0-4CEE-9D50-9D43E2EEAA44
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = AmdPspMboxLibV2
-
-[Sources.common]
- AmdPspMboxLibV2.c
-
-[Packages]
- MdePkg/MdePkg.dec
- AgesaPkg/AgesaPkg.dec
- AgesaModulePkg/AgesaCommonModulePkg.dec
- AgesaModulePkg/AgesaModulePspPkg.dec
-
-[LibraryClasses]
- PciLib
- SmnAccessLib
-
-
-
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspMboxLibV2
+ FILE_GUID = B9E57A31-CAB0-4CEE-9D50-9D43E2EEAA44
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspMboxLibV2
+
+[Sources.common]
+ AmdPspMboxLibV2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ PciLib
+ SmnAccessLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
index 0e9baad955691b8f2f898044864593fa6b48ca40..65dde2e3d5865b392761f7b2db68310047f1eac9 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
index c685a26604fc0be7679cf951d0c44cf0f14faf86..509c462459f0978200133722e4eed93ddafd0104 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -22,6 +22,3 @@
AgesaPkg/AgesaPkg.dec
AgesaModulePkg/AgesaCommonModulePkg.dec
AgesaModulePkg/AgesaModulePspPkg.dec
-
-
-
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
index a04bc1f9928ad8f73a4ade7307e9cd2ac0cda4ff..343e3794e89b1c1e4f535e38fb98f25873d049d0 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
index a3906dc13e8c98642d795ef4bbd1279fe5fbafca..e715c32c4d1c336b6eedcf1e95071dd127019863 100644
--- a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -22,5 +22,3 @@
AgesaPkg/AgesaPkg.dec
AgesaModulePkg/AgesaCommonModulePkg.dec
AgesaModulePkg/AgesaModulePspPkg.dec
-
-
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
index fce82d75b00f2c45c91c2ccba4aff1210ab3f0cc..81b47bd2523138bd9ff6f70f3abfb1ca0adb1911 100644
--- a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
index 09d5bd38ac1c17583d5a4b2d8c967175bd8c68eb..e7b78e76655eaa47ae7dfa8de858da37a39d5675 100644
--- a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -12,7 +12,7 @@
FILE_GUID = C7932467-DF16-4C7A-A32A-3E6F50213E68
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = ApcbLibV3 | DXE_DRIVER DXE_SMM_DRIVER DXE_RUNTIME_DRIVER DXE_CORE SMM_CORE UEFI_DRIVER
+ LIBRARY_CLASS = ApcbLibV3 | DXE_DRIVER DXE_SMM_DRIVER DXE_RUNTIME_DRIVER DXE_CORE SMM_CORE UEFI_DRIVER
[Sources.common]
ApcbLibV3.c
@@ -31,7 +31,3 @@
[Pcd]
gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries
-
-
-
-
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
index f8b9eb0bcfd3aa069b47413779ded6fb0767f777..235189aebfac80462b25d210f51ca1a1aa339daf 100644
--- a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
index c031d00d79227a907c42ad4876dbfd0c65d2347f..3a242a38eaa1ddcfbb5ddb34a01ad4c28d61f7ce 100644
--- a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.c
new file mode 100644
index 0000000000000000000000000000000000000000..1b15b82a93857bd63ba9c36e61fa8790ae631b36
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.c
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include
+#include
+#include
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetHostBridgeBusBase (
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Index
+ )
+{
+ return (UINTN)-1;
+}
+
+UINTN
+FabricTopologyGetHostBridgeBusLimit (
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Index
+ )
+{
+ return 0;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..92281562707e1670eb324e31116180945761c5f2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyBrhLib/BaseFabricTopologyBrhLib.inf
@@ -0,0 +1,31 @@
+## @file
+#
+# For EDKII use Only
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseFabricTopologyBrhLib
+ FILE_GUID = 92CA2E3D-A8C5-47E0-879D-9D56BDBD8B13
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseFabricTopologyLib
+
+[Sources]
+ BaseFabricTopologyBrhLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
index cff678d76b2d12387540663e58cd0ad2d8b3cfc7..6aaa72050eb9967777fd3be7f80d3b0be2397591 100644
--- a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
@@ -1,7 +1,7 @@
** @file
Fabric Topology Base Lib implementation
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
index 38a72e26b76385d5b7e55f975becd33c66296046..718c22ca78dea8512181f4689eac1c575e8bb028 100644
--- a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
@@ -2,7 +2,7 @@
#
# For EDKII use Only
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
index f72cbe7dffb656d838cb42831e97115e5180d540..970290c52b4eb229443ac808cdd74214f553cec4 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
@@ -1,7 +1,6 @@
/** @file
- A Base Timer Library implementation which uses the Time Stamp Counter in the processor.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
index d15d8169febbb2287eefc4b72570fb110628391e..d8a1e00dfe4c3b056d33d37c2ee3453c31e1226c 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
@@ -1,7 +1,6 @@
## @file
-# Base Timer Library which uses the Time Stamp Counter in the processor.
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
index a155978a5d1595eba41299bfb6317389edbb2f2e..d08551a25d84aa3e89c557e7c4cb937e4fa6ba4c 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
@@ -1,7 +1,6 @@
/** @file
- A Dxe Timer Library implementation which uses the Time Stamp Counter in the processor.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
index 1e52768a01ec0b6fd495220e1edb3878391fbc09..c0b240bcfeb2de2725e1838b9d9f1666a9d11a22 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
@@ -1,7 +1,6 @@
## @file
-# Dxe Timer Library which uses the Time Stamp Counter in the processor.
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
index f70aa3de0ece521df385c9090995fd8f664c2626..cf5932481f959185309fd43afeeef1ac4b052cf1 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
@@ -1,7 +1,6 @@
/** @file
- A Pei Timer Library implementation which uses the Time Stamp Counter in the processor.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
index b1eaefd2824c20b812c59a3c1bf839f74643eba8..23c5c67ed768fd32265f2ebc09b30f1564ba3378 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
@@ -1,7 +1,6 @@
## @file
-# Pei Timer Library which uses the Time Stamp Counter in the processor.
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
index 7d14d62e60d75bcc58725170bec84edab07b8e54..054365347ccc5329d1dd4453b8073e39284c5075 100644
--- a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
@@ -1,7 +1,6 @@
/** @file
- The Timer Library implementation which uses the Time Stamp Counter in the processor.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
index 44e23df62f93b9cde6946d9f7562d3828b86080e..91d87216c2dc352b49d0ccf1f8202110f64b7d4e 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
@@ -1,7 +1,6 @@
/** @file
- AMD instance of the PCI Host Bridge Library.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
index f60f97905a7ca607a9c35e232e54e430ceb0faa3..6ff6aa68602d17114d8d81e323eede822faa3ba5 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
@@ -1,7 +1,6 @@
## @file
-# Library instance of PciHostBridgeLib library class for coreboot.
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
index 318f8e5ad7ee5d900ce13589bd3f0d9956b26a11..edb8cd971c5d16e4bc5531257d62b8dd8ca65967 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
index 371537c9aac5435944317d2cb26a23aeb947235f..ddf7b859e5c5e385c08ea5f324854ba3cb3969fd 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
index b7d4f4c9d74e673776f5b4885af6da2cccfd5921..b5cf796da16a1175f3813c25f6279e8fa6bbb7ce 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
index e8ea9d8e84d5f83bb8cab6f9600e2da1a3278a47..52b3ec13eb738a2430669412a3d1ec1f818cc3d3 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
index 2a72fa8117c03ee8a4b61ced452f20715b2e74b5..052d0a4d0336931f64f886a45a03e9f145c241c8 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -1,47 +1,47 @@
-## @file
-#
-# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = AmlGenerationLib
- FILE_GUID = 8F62C8D1-B67F-4AFB-9179-54384F1A6163
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = AmlGenerationLib | DXE_DRIVER UEFI_DRIVER HOST_APPLICATION
-
-[Sources.common]
- LocalAmlObjects.h
- LocalAmlObjects.c
- LocalAmlLib.h
- AmlAssistFunctions.c
- AmlObjectsDebug.c
- AmlNameString.c
- AmlDataObjects.c
- AmlNamespaceModifierObjects.c
- AmlPkgLength.c
- AmlNamedObject.c
- AmlTable.c
- AmlStatementOpcodes.c
- AmlResourceDescriptor.c
- AmlExpressionOpcodes.c
- AmlArgObjects.c
- AmlLocalObjects.c
-
-[Packages]
- MdePkg/MdePkg.dec
- AgesaPkg/AgesaPkg.dec
- AgesaModulePkg/AgesaCommonModulePkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- BaseMemoryLib
- MemoryAllocationLib
-
-[Depex]
- TRUE
-
+## @file
+#
+# Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmlGenerationLib
+ FILE_GUID = 8F62C8D1-B67F-4AFB-9179-54384F1A6163
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmlGenerationLib | DXE_DRIVER UEFI_DRIVER HOST_APPLICATION
+
+[Sources.common]
+ LocalAmlObjects.h
+ LocalAmlObjects.c
+ LocalAmlLib.h
+ AmlAssistFunctions.c
+ AmlObjectsDebug.c
+ AmlNameString.c
+ AmlDataObjects.c
+ AmlNamespaceModifierObjects.c
+ AmlPkgLength.c
+ AmlNamedObject.c
+ AmlTable.c
+ AmlStatementOpcodes.c
+ AmlResourceDescriptor.c
+ AmlExpressionOpcodes.c
+ AmlArgObjects.c
+ AmlLocalObjects.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+
+[Depex]
+ TRUE
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
index 21deb200e327732c4df25ddb0dc39f9e3c7cb298..0f639ba3f71937e9c4441c044e0a0d39faf61929 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
index 0502547a013db3dffffa49e5a4666c2f3048c552..46d04534db0340b51e5d32aaf921de0bb80ce1e8 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
index 37ae9319beadd78fb82d9b2366ecf2eb9c7393d1..eeeff6a8482370594db47f67d53076b65a156c86 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
index afe51cdcf24bf6086e4d65b55cf81bb88dfa7914..33bdd57df0219a38c36f2c9fad25af2b4b0415c6 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
index 279bfc782d76efc5797a2206269f3fba222409f3..1cda39236ff61390f4df5536b8d2f04540276feb 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
index 85d184b759f920a682d344e3487e6233642df01e..d161fca586d95e34995338851de706688a1871a7 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
index 4ef746327bebaebffc9634d3489d825cc6ffface..7c34375ae124d900eff7e502b075c13d07c62f02 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
index 03201d01096658bae83788825baa9198f95ea318..86040fff3c49bc9a6d60b6c9a34feae526528bf2 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
index c9a43997649d32cb2bf65a2c92f2209799519b21..cd7780cf6b2e563162d7a2720e84acabf6939156 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
index a60ae20d334ee7f2e210223663f88a0bbfadd388..a4759b5cc9d18343d5970393c64c285209add2c2 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _INTERNAL_AML_LIB_H_
-#define _INTERNAL_AML_LIB_H_
+#ifndef INTERNAL_AML_LIB_H_
+#define INTERNAL_AML_LIB_H_
#include
#include
@@ -97,4 +97,4 @@ InternalAmlNameSeg (
IN OUT LIST_ENTRY *ListHead
);
-#endif
+#endif // INTERNAL_AML_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
index b1ad9b70372c9e8718d987a4e93a0ad7c5d2a87c..6325cacec5984b9edbc94a093a503371fd41b5c6 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
index b19b6fe867609e6046880732fb4fb2922c176c33..4e8ca98a259cae4840301609e3f0046383c694e5 100644
--- a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2020-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _INTERNAL_AML_OBJECTS_H_
-#define _INTERNAL_AML_OBJECTS_H_
+#ifndef INTERNAL_AML_OBJECTS_H_
+#define INTERNAL_AML_OBJECTS_H_
// #include "LocalAmlLib.h"
@@ -147,4 +147,4 @@ InternalAmlCollapseAndReleaseChildren (
IN OUT LIST_ENTRY *ListHead
);
-#endif // _INTERNAL_AML_OBJECTS_H_
+#endif // INTERNAL_AML_OBJECTS_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
index e63a70e8490b3e40a8cd1fde310128d087852df0..eba5efd2fd587698a561b38546cb09c379ec1857 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
@@ -1,26 +1,26 @@
-## @file
-#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = FchBaseLib
- FILE_GUID = 4108287a-c864-4427-b2c3-bd0e91a83abd
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = FchBaseLib
-
-[Sources.common]
- FchStallLib.c
-
-[Packages]
- AgesaModulePkg/AgesaModuleFchPkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- PciSegmentLib
-
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = FchBaseLib
+ FILE_GUID = 4108287a-c864-4427-b2c3-bd0e91a83abd
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = FchBaseLib
+
+[Sources.common]
+ FchStallLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ PciSegmentLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
index 2f4f676adb106ff8b179bbd66d6bbe2a26c3809c..0a030e056db7209b46ede0708c69ebc0b2985e9a 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
index 60305ee4a6a7d4f14bcf7e7e3326176675fa852b..dc9d08389b51cd5453d5691f98c56d4590c726da 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
@@ -1,7 +1,6 @@
/** @file
- Library to support reset library, inheritted from Agesa Cf9Reset module.
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
index e422cb69a47be58db4d58f361f1a4b1558b50967..a7f4a96fae53bcc713389f858c6fa6b425d263d3 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
index d10e676668da50cb213ae6f7989325fa31e96b06..72681e16c97da73a0d94036dace69e07ba33c2b5 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
index d7f49c40de3f00774eee6d7da5e9c6de03349f83..cd8d497539aa23ab4e5831331ee7008fc1160826 100644
--- a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
@@ -1,33 +1,26 @@
-## @file
-#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010006
- BASE_NAME = FchEspiCmdLib
- FILE_GUID = 89671327-a620-43e9-93b1-d1da79a50392
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = FchEspiCmdLib
-
-[Sources.common]
- FchEspiCmdLib.c
-
-[Packages]
- AgesaModulePkg/AgesaModuleFchPkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- IoLib
- FchBaseLib
-
-
-
-
-
-
-
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = FchEspiCmdLib
+ FILE_GUID = 89671327-a620-43e9-93b1-d1da79a50392
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = FchEspiCmdLib
+
+[Sources.common]
+ FchEspiCmdLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ IoLib
+ FchBaseLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
index 9044d3d497304c47d57014b548e5e2c01d66edc5..352ae3f3c0e3c6b23582640d1d9dd6bd2f2d038a 100755
--- a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
@@ -1,8 +1,6 @@
/** @file
- GNB function to create/locate PCIe configuration data area, Contain code
- that create/locate/manages GNB/PCIe configuration
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
index f32bbc9ff2173a8090b40838c86a3448ddaaea81..7b7355ea87b65ca9777c22a3a71407a35f756ae5 100755
--- a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
index d5fbe98d2265502aba8d36e62483a0c66862b6ca..9d9b27ac43414dcfcd18c2577957ed7902ccb930 100755
--- a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
@@ -1,7 +1,6 @@
/** @file
- GNB function to create/locate PCIe configuration data area
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
index 0d6ba605f5d2cc28b58c9f32645d100361989da7..efa6394a9a0dda4a2a6f0ffd87920c122d7f2dea 100755
--- a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
index 5c6be22ee460fed8437907d9f956089a1a6fbd99..fa0249aca02de2be725c7b6a1a24de12f1f9072e 100755
--- a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
@@ -1,7 +1,6 @@
/** @file
- Procedure to parse PCIe input configuration data
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
index e6be32b071c2226dab47c32f77b95bde4efe0c79..7f401b83b1125807404b5b732130cfa9478d14ea 100644
--- a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
@@ -1,10 +1,30 @@
/** @file
- SMN Register Access Methods
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include
+
+/*
+ Routine to read all register spaces.
+
+ @param[in] SegmentNumber Segment number of D0F0 of the target die
+ @param[in] BusNumber Bus number of D0F0 of the target die
+ @param[in] Address Register offset, but PortDevice
+ @param[out] Value Return value
+ @retval VOID
+ */
+VOID
+EFIAPI
+SmnRegisterReadS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ OUT VOID *Value
+ )
+{
+ return;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
index ae1dd6cd8377f5a0fa8e17120bf7cf10bd53655a..d437916327e13227f2e42d16346d0045080a5ad7 100644
--- a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
index 1dc13900c7d15a3974516a19569ccbafcf7e45a6..e924254bdd191f9a7e656e4c995ef876bf95a249 100644
--- a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
index da7f5c185d54e68653fab3778dcd824035780957..da1bd461985abfbe21b8986560cd7cad57f3e445 100644
--- a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
index fbd3ddcf3742b1c7940abd8d212efd7c78fd69e0..a8db3ef5c75ac1dd489e17080c9756689abd7a6d 100644
--- a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
@@ -1,7 +1,6 @@
/** @file
- APCB DXE Driver
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
index 54c3514020dc283dedce3de134dfbc144bb3e632..4af1447848ca39027c821747ad745abe40ba3f59 100644
--- a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
index 23d1a8fee01d8b1458a348a5f707c6cdf7c44e23..5e81ab8dddcd023e57168ae246075759086a84ac 100644
--- a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
index 7f90aa6ea0a11e9442b93cdc354c0432b5eab14a..9bedce23f00b8b20621f0d41acf624fa1aae75ad 100644
--- a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.c b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe179889445c828728d529c6df4626e57070ef8a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.c
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/**
+ Entry point of Act Dynamic Command.
+
+ Produce the DynamicCommand protocol to handle "act" command.
+
+ @param ImageHandle The image handle of the process.
+ @param SystemTable The EFI System Table pointer.
+
+ @retval EFI_SUCCESS Act command is executed sucessfully.
+ @retval EFI_ABORTED HII package was failed to initialize.
+ @retval others Other errors when executing act command.
+**/
+EFI_STATUS
+EFIAPI
+ActCommandInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/**
+ Destructor for the library. free any resources.
+
+ @param ImageHandle The image handle of the process.
+ @param SystemTable The EFI System Table pointer.
+**/
+EFI_STATUS
+EFIAPI
+ActLibraryUnregisterActCommand (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.inf b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.inf
new file mode 100644
index 0000000000000000000000000000000000000000..47000b346a7af31492f9240e8539726f04550172
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoDynamicCommand.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdAutoDynamicCommand
+ FILE_GUID = CCD8FEC8-1E30-45BD-8632-DB83A255FAC3
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.1
+ ENTRY_POINT = ActCommandInitialize
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+ AutoConfigOptions.c
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[Depex]
+ TRUE
\ No newline at end of file
diff --git a/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoToolApp.inf b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoToolApp.inf
new file mode 100644
index 0000000000000000000000000000000000000000..7af256233a8d6ca840f600a929bfccc0b9c10544
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AmdAutoToolApp.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdAutoToolApp
+ FILE_GUID = 470E1741-2DFE-43EF-861E-505CB3226DC0
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ActCommandInitialize
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+ AutoConfigOptions.c
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ UefiApplicationEntryPoint
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AutoConfigOptions.c b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AutoConfigOptions.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e496a8a80dc20a7385bf276ddf85dcbcb4bf853
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Universal/AmdAutoDynamicCommand/BRH/AutoConfigOptions.c
@@ -0,0 +1,7 @@
+/** @file
+
+ Copyright (C) 2021-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
index 74b129931b0bdb47a643a7d570396900f90252ea..fd116812be70b5d266deafa6ce939eb4e1fa26bf 100644
--- a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
@@ -1,7 +1,6 @@
/** @file
- Required OEM hooks for CCX initialization
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
index 0f115c362e71543c470eb85c12a56fd339fafec8..6438546e35d3a33ea45a78ed0478d29e90a78248 100755
--- a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
index 54ce202cb1a3a0ab241d0d0a5255b647e4408873..1915c1691da32ee508c81572fe661357206f9f0e 100644
--- a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2018-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
index ba551e5c142ab7d78acfd4ab0939e822b4a21134..d1dfff95457611692cda1e6aad95c1ab6db66c9c 100644
--- a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2018-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
index e712a808862897c1700c5f52314e37b73b4b1297..b629ab8b248b79a67646c59b3104d99a63f1b13c 100644
--- a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2018-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
index 643174d7b9e80df1cf7f996efce5ac4140a369b1..082ba89b0661dfd55f3d1f522858b8899cd054ed 100644
--- a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2018-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb188fa0b3926d78fe2ad885a9659271619ac505
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.c
@@ -0,0 +1,16 @@
+/** @file
+
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+EFI_STATUS
+EFIAPI
+AmdPspDpeDxeEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.inf
new file mode 100644
index 0000000000000000000000000000000000000000..07e257e4cf2f96dc2c7450a7398f5eec623144d7
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspDpeDxe/AmdPspDpeDxe.inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdPspDpeDxe
+ FILE_GUID = 3d86af84-10ca-4139-b253-f1b88e6fc279
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdPspDpeDxeEntry
+
+[Sources]
+ AmdPspDpeDxe.c
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[Depex]
+ TRUE
\ No newline at end of file
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
index d83bb6c2d88db06ecaccbd773baded591b041532..cfbe255bfce2c465ee5acb9d99426c95e5a1369d 100644
--- a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
index f4b9d0d7891370d658f62e0301a93d7daea0e88d..4e3cd9622cf2f7ce81bb477a2b147819e50cdc7d 100644
--- a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
index a264eb929425bccf113fa7d090e9183ef360f673..74c0e90b2ba7a8df3be3d21abc4accafd4bcfc91 100644
--- a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
@@ -1,12 +1,29 @@
/** @file
- Platform ROM Armor Whitelist table
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include
+#include
+#include
#include
#include
-#include
+
+/*
+ Return allocated and filled AMD PSP ROM Armor White list Table
+
+ @param[in] PlatformSpiWhitelist Pointer to white list table
+
+ @return EFI_SUCCESS
+ @return EFI_OUT_OF_RESOURCES Buffer to return could not be allocated
+ */
+EFI_STATUS
+EFIAPI
+GetPspRomArmorWhitelist (
+ IN SPI_WHITE_LIST **PlatformSpiWhitelist
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
index 57bb0d9e25745f14f1d99a86fe18c4efd1f0fc96..2e72f4e39c5c20c28ef020443399d171dcb4fd00 100644
--- a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/AgesaPkg.dec
index 9377c64cc348f14d8b5c8a9104ab736c03e37c4d..c9f6070ad7efd8736c8913c56cc7290e1ab4d916 100644
--- a/Platform/AMD/AgesaPkg/AgesaPkg.dec
+++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
@@ -1,8 +1,6 @@
## @file
-# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
-# file.
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -341,7 +339,6 @@
gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x00030004
gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BOOLEAN|0x00030005
gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BOOLEAN|0x00030006
-[PcdsDynamicEx]
[PcdsFixedAtBuild, PcdsDynamic]
#----------------------------------------------------------------------------
@@ -408,6 +405,14 @@
#----------------------------------------------------------------------------
### PSP PCDs
+ ### @brief Switch to control if S3/Capsule start
+ ### @details Switch to control if S3/Capsule start from SMM or
+ ### the address provided by PspPlatfromProtocol->RsmHandOffInfo->RsmEntryPoint.
+ ### @li TRUE: S3/Capsule start from BspSmmResumeVector.
+ ### @li FALSE: S3/Capsule start from PspPlatfromProtocol->RsmHandOffInfo->RsmEntryPoint.
+ ### NOTE, Processor will be set to 32bits protect mode with pagging disabled.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspS3WakeFromSmm|TRUE|BOOLEAN|0x95940F00
+
### @brief Rom Armor selection
### @details Rom Armor selection
### @li 0: Rom Armor is disabled
@@ -416,8 +421,6 @@
### @li 3: Rom Armor 3 is enabled (CGL, RMB and later)
gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspRomArmorSelection|0|UINT8|0x95940054
-
-
### @brief System TPM config Value
### @details System TPM config Value, SBIOS needs to set the value in PEI phase.
### @li 0x0: dTPM
diff --git a/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
index 3a628ed0b29ca3f70dd58af91fd6d41033006198..f546b245cc02512eff54e197cea919d2a2fa4fc0 100755
--- a/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
+++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -48,6 +48,17 @@ typedef struct {
IN UINT32 Ovrd; ///< Ancillary data table address point to ANC_DATA_PARAM[]
} ANC_DATA;
+/**
+ * @brief Port parameter override enumerator.
+ * @details This enumerator provides a parmeter type for platform topology override values.
+ * If unused all ports will default to platform configurations.
+ */
+typedef enum {
+ PP_SLOT_NUM, /**< (__UINT16__) Specify a SLOT NUMBER value.
+ * @li Valid Values: __0-0xFFFF__
+ */
+} DXIO_PORT_PARAM_TYPE;
+
typedef struct {
UINT16 ParamType; ///< This identifies a specific PHY parameter
UINT16 ParamValue; ///< This specifies the value to be assigned to indicated PHY parameter
@@ -429,4 +440,14 @@ typedef enum {
DxioGen5, ///< Gen5
MaxDxioGen ///< Max Gen for boundary check
} DXIO_LINK_SPEEDS;
+
+/**
+ * @brief PCIe link initialization
+ * @details NOTE: UBM HFC hotplug types are identified during auto-discovery
+ */
+typedef enum {
+ DxioPortDisabled, ///< Disable
+ DxioPortEnabled ///< Enable
+} DXIO_PORT_ENABLE;
+
#endif // AMD_PCIE_COMPLEX_H_
diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
index d62f26023582722783ab4f5cc5dffe9cb487f11f..32978a16a81646f1c7f71a94a67e74c9301a1e24 100644
--- a/Platform/AMD/AgesaPkg/Include/AmdSoc.h
+++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _AMD_SOC_H_
-#define _AMD_SOC_H_
+#ifndef AMD_SOC_H_
+#define AMD_SOC_H_
#define F1A_BRH_A0_RAW_ID 0x00B00F00ul
#define F1A_BRH_B0_RAW_ID 0x00B00F10ul
diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
index 2dfb3190d4388e437b2ed0782a73bdead3b8b5b4..7508b7822fbd7a961d48269e9d56f4f105c0083a 100644
--- a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
+++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
@@ -1,10 +1,12 @@
; @file
;
; AMD Generic Encapsulated Software Architecture
-; Code to setup temporary memory access for stack usage. This code
-; is to be used on memory present systems that do not need CAR.
-;
-; Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+; Workfile: AmdUefiStackNasm.inc
+; $Revision$ $Date$
+; Description: Code to setup temporary memory access for stack usage. This code
+; is to be used on memory present systems that do not need CAR
+;
+; Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
;
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
index 2291f7dc83c1455a27717989cdef6ac7ef25a132..d39153b2da40fbf9ca3fe9952ef71ffb16070ffa 100644
--- a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
+++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
@@ -1,7 +1,6 @@
/** @file
- Fabric resource manager common definition
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -11,7 +10,7 @@
#define FABRIC_RESOURCE_MANAGER_CMN_H_
#pragma pack (push, 1)
-#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets in system.
+#define MAX_SOCKETS_SUPPORTED 4 ///< Max number of sockets in system.
#define MAX_RBS_PER_SOCKET 20 ///< Max number of root bridges per socket.
/**
diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
index 9e58f299b49a6baee96acdd55d2e524a04764f54..47d08de1e726d96765eea8fe2ce08ecfd603759a 100644
--- a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
+++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
@@ -1,7 +1,7 @@
/** @file
- AMD Memory Info Hob Definition
- Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
index d144a4ad2052396792bc87839a1f60563426e09b..790ffdd6b337fe680a8e8416d777fc891e5b5113 100644
--- a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
@@ -1,6 +1,8 @@
/** @file
AMD Psp Base Lib
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
index 23c90b65c2b47780c480bab90587f09f23f2f50b..ba88f40836f25f894f246f4e1c80fccb0c2fe354 100644
--- a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
@@ -1,7 +1,8 @@
/** @file
AMD Psp Ftpm Library header file
- Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
index 4ad4020f958904fe0feaee7c2c7ce1d6490bfcc9..5c1047f9a7dbca864e0566d5d7815ec72279a116 100644
--- a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
@@ -1,13 +1,13 @@
/** @file
- Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef _PSP_ROM_ARMOR_LIB_H_
-#define _PSP_ROM_ARMOR_LIB_H_
+#ifndef PSP_ROM_ARMOR_LIB_H_
+#define PSP_ROM_ARMOR_LIB_H_
#include "Uefi.h"
@@ -228,4 +228,4 @@ PspSwitchChipSelect (
IN UINT8 ChipSelect
);
-#endif //_PSP_ROM_ARMOR_LIB_H_
+#endif // PSP_ROM_ARMOR_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
index 0189910bd12c424012522b3dc68ed887b67771d6..a28181cc12302d0f7043185acc61c6b69708c018 100644
--- a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2019-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
index d48ca1a90a3a4f3f45e56b5584e2937aca6297a8..fb1e75951866090c492c77d5ea91a94e96880259 100644
--- a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
+++ b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
@@ -1,12 +1,14 @@
/** @file
- Platform ROM Armor Whitelist table
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+#ifndef PLATFORM_PSP_ROM_ARMOR_WHILE_LIST_
+#define PLATFORM_PSP_ROM_ARMOR_WHILE_LIST_
+
#include
/*
@@ -23,3 +25,5 @@ EFIAPI
GetPspRomArmorWhitelist (
IN SPI_WHITE_LIST **PlatformSpiWhitelist
);
+
+#endif // PLATFORM_PSP_ROM_ARMOR_WHILE_LIST_
diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
index 6c854651ccd9301de673c034e6a6dae13e0f7e87..80c0acfc83affcab790b343fd3914fb499341782 100644
--- a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
+++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
@@ -1,7 +1,8 @@
/** @file
AMD Psp Ftpm Ppi Header
- Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
index 715cbbcf78179b111944c4c4f7d0af8ced017519..e3cf692d3bb003f5fa49d2a06421a279e7f95d5d 100644
--- a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
@@ -1,7 +1,6 @@
/** @file
- CXL Configuration Services Protocol prototype definition
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
index 7bcff65dc998f5645aae9655c46d18a004788eae..c5fd167fc775bea06494fb23bfbb961a0543752c 100644
--- a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
index ebc7812b18e510a5d9b68901fa17659f9a90c4fd..706250f5f16dde33a771fc198eef3127f9164fec 100644
--- a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
@@ -1,7 +1,8 @@
/** @file
AMD Psp Ftpm Protocol Header
- Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
index 7f57facf8850816e1c19ec76b53210c5bf3a8f16..127ab819fa49b44082ea298e6fdf8ed463a94949 100644
--- a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
@@ -1,7 +1,6 @@
/** @file
- Fabric MMIO map manager Protocol prototype definition
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
new file mode 100644
index 0000000000000000000000000000000000000000..fe91cb4f4a7f46d138febd254812706e8658b51a
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -0,0 +1,151 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/*
+ Fill the DataBuffer with correct Arg Opcode based on provided argument number
+ Valid Argument numbers are 0, 1, 2, 3, 4, 5 and 6.
+ AML supports max 7 argument, i.e., Arg1, Arg2 ... Arg6.
+
+ @param[in] ArgN - Argument Number
+ @param[out] ReturnData - Allocated DataBuffer with encoded integer
+ @param[out] ReturnDataSize - Size of ReturnData
+
+ @return EFI_SUCCESS - Successful completion
+ @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffer
+ @return EFI_INVALID_PARAMETER - Invalid ArgN provided.
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlArgBuffer (
+ IN OUT UINT8 ArgN,
+ OUT VOID **ReturnData,
+ OUT UINTN *ReturnDataSize
+ )
+{
+ UINT8 *Data;
+ UINTN DataSize;
+
+ Data = AllocateZeroPool (sizeof (UINT8));
+ if (Data == NULL) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Failed to create Data Buffer.\n",
+ __FUNCTION__
+ ));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ DataSize = 1;
+ switch (ArgN) {
+ case 0:
+ Data[0] = AML_ARG0;
+ break;
+ case 1:
+ Data[0] = AML_ARG1;
+ break;
+ case 2:
+ Data[0] = AML_ARG2;
+ break;
+ case 3:
+ Data[0] = AML_ARG3;
+ break;
+ case 4:
+ Data[0] = AML_ARG4;
+ break;
+ case 5:
+ Data[0] = AML_ARG5;
+ break;
+ case 6:
+ Data[0] = AML_ARG6;
+ break;
+ default:
+ FreePool (Data);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ReturnData = (VOID *)Data;
+ *ReturnDataSize = DataSize;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Creates an ArgN Opcode object
+
+ Arg Objects Encoding
+ ArgObj := Arg0Op | Arg1Op | Arg2Op | Arg3Op | Arg4Op | Arg5Op | Arg6Op
+ Arg0Op := 0x68
+ Arg1Op := 0x69
+ Arg2Op := 0x6A
+ Arg3Op := 0x6B
+ Arg4Op := 0x6C
+ Arg5Op := 0x6D
+ Arg6Op := 0x6E
+
+ @param[in] ArgN - Argument Number to be encoded
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOpArgN (
+ IN UINT8 ArgN,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Start %a object\n",
+ __FUNCTION__,
+ "ARGN_OPCODE"
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlArgBuffer (
+ ArgN,
+ (VOID **)&(Object->Data),
+ &(Object->DataSize)
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: ACPI Argument 0x%X object\n",
+ __FUNCTION__,
+ ArgN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
new file mode 100644
index 0000000000000000000000000000000000000000..6991e2b6ed5e8fe72f2b5cf0b2a79497ccd7a1a0
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -0,0 +1,148 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ Free all the children AML_OBJECT_INSTANCE(s) of ListHead.
+ Will not free ListHead nor an Object containing ListHead.
+
+ @param[in,out] ListHead - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+AmlFreeObjectList (
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+
+ Node = GetNextNode (ListHead, ListHead);
+ while (Node != ListHead) {
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ // Get next node before freeing current Object
+ Node = GetNextNode (ListHead, Node);
+ // Free Object
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Validate that ACPI table is completed and return Table and Size
+
+ @param[in,out] ListHead - Head of linked list of Objects
+ @param[out] Table - Completed ACPI Table
+ @param[out] TableSize - Completed ACPI Table size
+
+ @retval EFI_SUCCESS
+ EFI_INVALID_PARAMETER
+ EFI_DEVICE_ERROR
+**/
+EFI_STATUS
+EFIAPI
+AmlGetCompletedTable (
+ IN OUT LIST_ENTRY *ListHead,
+ OUT VOID **Table,
+ OUT UINTN *TableSize
+ )
+{
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ListHead cannot be NULL\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Table = NULL;
+ *TableSize = 0;
+ Node = GetFirstNode (ListHead);
+ if (!IsNodeAtEnd (ListHead, Node)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Multiple nodes remain, Likely missed an 'AmlClose' call\n", __FUNCTION__));
+ return EFI_DEVICE_ERROR;
+ } else {
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ if (!Object->Completed) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Final node not completed: Likely missed an 'AmlCLose' call\n", __FUNCTION__));
+ return EFI_DEVICE_ERROR;
+ }
+
+ *Table = Object->Data;
+ *TableSize = Object->DataSize;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Initialize Table List to work with AmlGenerationLib
+
+ Allocates a LIST_ENTRY linked list item and initializes it. Use
+ AmlReleaseTableList to free resulting table and LIST_ENTRY.
+
+ @param[in,out] ListHead - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ EFI_INVALID_PARAMETER
+ EFI_OUT_OF_RESOURCES
+**/
+EFI_STATUS
+EFIAPI
+AmlInitializeTableList (
+ IN OUT LIST_ENTRY **ListHead
+ )
+{
+ if (ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ListHead = NULL\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ListHead = AllocatePool (sizeof (LIST_ENTRY));
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ InitializeListHead (*ListHead);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Release table List
+
+ Releases all elements. Use to free built table and LIST_ENTRY allocated by
+ AmlInitializeTableList.
+
+ @param[in,out] ListHead - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ EFI_INVALID_PARAMETER
+**/
+EFI_STATUS
+EFIAPI
+AmlReleaseTableList (
+ IN OUT LIST_ENTRY **ListHead
+ )
+{
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NULL ListHead passed in\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlFreeObjectList (*ListHead);
+ FreePool (*ListHead);
+ *ListHead = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
new file mode 100644
index 0000000000000000000000000000000000000000..9fd1c0a430d63dc2d70791007550980ea135e7ae
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -0,0 +1,637 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/*
+ Creates an allocated buffer with sized data and no Op Code
+
+ ByteData := 0x00 - 0xFF
+ WordData := ByteData[0:7] ByteData[8:15] // 0x0000-0xFFFF
+ DWordData := WordData[0:15] WordData[16:31] // 0x00000000-0xFFFFFFFF
+ QWordData := DWordData[0:31] DWordData[32:63] // 0x0000000000000000- 0xFFFFFFFFFFFFFFFF
+
+ Forces max integer size UINT64
+
+ Caller is responsible for freeing returned buffer.
+
+ @param[in] Integer - Integer value to encode
+ @param[in] IntegerSize - Size of integer in bytes
+ @param[out] ReturnData - Allocated DataBuffer with encoded integer
+ @param[out] ReturnDataSize - Size of ReturnData
+
+ @return EFI_SUCCESS - Successful completion
+ @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffer
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlSizedDataBuffer (
+ IN UINT64 Integer,
+ IN UINTN IntegerSize,
+ OUT VOID **ReturnData
+ )
+{
+ UINT8 *Data;
+
+ if ((IntegerSize != sizeof (UINT8)) &&
+ (IntegerSize != sizeof (UINT16)) &&
+ (IntegerSize != sizeof (UINT32)) &&
+ (IntegerSize != sizeof (UINT64)))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Incorrect integer size=%d requested.\n", __FUNCTION__, IntegerSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IntegerSize < sizeof (UINT64)) && (Integer >= LShiftU64 (1, IntegerSize * 8))) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Integer is larger than requestd size.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Max Data Size is 64 bit. Plus one Opcode byte
+ Data = AllocateZeroPool (sizeof (UINT64));
+ if (Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Integer Space Alloc Failed\n", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // Already established we only have supported sizes above
+ switch (IntegerSize) {
+ case sizeof (UINT8):
+ *(UINT8 *)Data = (UINT8)Integer;
+ break;
+ case sizeof (UINT16):
+ *(UINT16 *)Data = (UINT16)Integer;
+ break;
+ case sizeof (UINT32):
+ *(UINT32 *)Data = (UINT32)Integer;
+ break;
+ case sizeof (UINT64):
+ *(UINT64 *)Data = (UINT64)Integer;
+ break;
+ }
+
+ *ReturnData = (VOID *)Data;
+ return EFI_SUCCESS;
+}
+
+/*
+ Calculates the optimized integer value used by AmlOPDataInteger and others
+
+ Forces max integer size UINT64
+
+ @param[in] Integer - Integer value to encode
+ @param[out] ReturnData - Allocated DataBuffer with encoded integer
+ @param[out] ReturnDataSize - Size of ReturnData
+
+ @return EFI_SUCCESS - Successful completion
+ @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffer
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlDataIntegerBuffer (
+ IN UINT64 Integer,
+ OUT VOID **ReturnData,
+ OUT UINTN *ReturnDataSize
+ )
+{
+ UINT8 *IntegerData;
+ UINTN IntegerDataSize;
+ UINT8 *Data = NULL;
+ UINTN DataSize;
+
+ // Max Data Size is 64 bit. Plus one Opcode byte
+ IntegerData = AllocateZeroPool (sizeof (UINT64) + 1);
+ if (IntegerData == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Integer Space Alloc Failed\n", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (Integer == 0) {
+ // ZeroOp
+ IntegerDataSize = 1;
+ IntegerData[0] = AML_ZERO_OP;
+ } else if (Integer == 1) {
+ // OneOp
+ IntegerDataSize = 1;
+ IntegerData[0] = AML_ONE_OP;
+ } else if (Integer == (UINT64) ~0x0) {
+ // OnesOp
+ IntegerDataSize = 1;
+ IntegerData[0] = AML_ONES_OP;
+ } else {
+ if (Integer >= 0x100000000) {
+ // QWordConst
+ IntegerDataSize = sizeof (UINT64) + 1;
+ IntegerData[0] = AML_QWORD_PREFIX;
+ } else if (Integer >= 0x10000) {
+ // DWordConst
+ IntegerDataSize = sizeof (UINT32) + 1;
+ IntegerData[0] = AML_DWORD_PREFIX;
+ } else if (Integer >= 0x100) {
+ // WordConst
+ IntegerDataSize = sizeof (UINT16) + 1;
+ IntegerData[0] = AML_WORD_PREFIX;
+ } else {
+ // ByteConst
+ IntegerDataSize = sizeof (UINT8) + 1;
+ IntegerData[0] = AML_BYTE_PREFIX;
+ }
+
+ DataSize = IntegerDataSize - 1;
+ InternalAmlSizedDataBuffer (Integer, DataSize, (VOID **)&Data);
+ if (Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Integer Data Space Alloc Failed\n", __FUNCTION__));
+ FreePool (IntegerData);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (&IntegerData[1], Data, DataSize);
+ FreePool (Data);
+ }
+
+ // Reallocate the pool so size is exact
+ *ReturnData = (VOID *)IntegerData;
+ *ReturnDataSize = IntegerDataSize;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Creates an optimized integer object
+
+ Forces max integer size UINT64
+
+ ComputationalData := ByteConst | WordConst | DWordConst | QWordConst | String |
+ ConstObj | RevisionOp | DefBuffer
+ DataObject := ComputationalData | DefPackage | DefVarPackage
+ DataRefObject := DataObject | ObjectReference | DDBHandle
+ ByteConst := BytePrefix ByteData
+ BytePrefix := 0x0A
+ WordConst := WordPrefix WordData
+ WordPrefix := 0x0B
+ DWordConst := DWordPrefix DWordData
+ DWordPrefix := 0x0C
+ QWordConst := QWordPrefix QWordData
+ QWordPrefix := 0x0E
+ ConstObj := ZeroOp | OneOp | OnesOp
+ ByteData := 0x00 - 0xFF
+ WordData := ByteData[0:7] ByteData[8:15]
+ // 0x0000-0xFFFF
+ DWordData := WordData[0:15] WordData[16:31]
+ // 0x00000000-0xFFFFFFFF
+ QWordData := DWordData[0:31] DWordData[32:63]
+ // 0x0000000000000000-0xFFFFFFFFFFFFFFFF
+ ZeroOp := 0x00
+ OneOp := 0x01
+ OnesOp := 0xFF
+
+ @param[in] Integer - Number to be optimized and encoded
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDataInteger (
+ IN UINT64 Integer,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "DATA_INTEGER"));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ Integer,
+ (VOID **)&(Object->Data),
+ &(Object->DataSize)
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ACPI Integer 0x%X object\n", __FUNCTION__, Integer));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an Sized Data integer object for use in Buffer objects. Does not
+ include opcode.
+
+ ByteData := 0x00 - 0xFF
+ WordData := ByteData[0:7] ByteData[8:15]
+ // 0x0000-0xFFFF
+ DWordData := WordData[0:15] WordData[16:31]
+ // 0x00000000-0xFFFFFFFF
+ QWordData := DWordData[0:31] DWordData[32:63]
+ // 0x0000000000000000-0xFFFFFFFFFFFFFFFF
+
+ @param[in] Integer - Number to be optimized and encoded
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlOPSizedData (
+ IN UINT64 Integer,
+ IN UINTN IntegerSize,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "SIZED_DATA_INTEGER"));
+ goto Done;
+ }
+
+ Object->DataSize = IntegerSize;
+ Status = InternalAmlSizedDataBuffer (
+ Integer,
+ Object->DataSize,
+ (VOID **)&(Object->Data)
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ACPI Integer 0x%X object\n", __FUNCTION__, Integer));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a ByteData integer object for use in Buffer objects. Does not
+ include opcode.
+
+ ByteData := 0x00 - 0xFF
+
+ @param[in] Integer - Number to be placed in object
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPByteData (
+ IN UINT8 Integer,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ return InternalAmlOPSizedData (Integer, sizeof (UINT8), ListHead);
+}
+
+/**
+ Creates a WordData integer object for use in Buffer objects. Does not
+ include opcode.
+
+ WordData := 0x0000 - 0xFFFF
+
+ @param[in] Integer - Number to be placed in object
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPWordData (
+ IN UINT16 Integer,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ return InternalAmlOPSizedData (Integer, sizeof (UINT16), ListHead);
+}
+
+/**
+ Creates a DWordData integer object for use in Buffer objects. Does not
+ include opcode.
+
+ DWordData := 0x00000000 - 0xFFFFFFFF
+
+ @param[in] Integer - Number to be placed in object
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDWordData (
+ IN UINT32 Integer,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ return InternalAmlOPSizedData (Integer, sizeof (UINT32), ListHead);
+}
+
+/**
+ Creates a QWordData integer object for use in Buffer objects. Does not
+ include opcode.
+
+ QWordData := 0x00000000_00000000 - 0xFFFFFFFF_FFFFFFFF
+
+ @param[in] Integer - Number to be placed in object
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPQWordData (
+ IN UINT64 Integer,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ return InternalAmlOPSizedData (Integer, sizeof (UINT64), ListHead);
+}
+
+/**
+ Creates a data string object
+
+ ComputationalData := String
+
+ String := StringPrefix AsciiCharList NullChar
+ StringPrefix := 0x0D
+ AsciiCharList := Nothing |
+ AsciiChar := 0x01 - 0x7F
+ NullChar := 0x00
+
+ @param[in] String - String to be encoded
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDataString (
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ UINT8 *Data;
+ UINTN DataSize;
+ UINTN Index;
+
+ if ((String == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ // Validate all characters
+ DataSize = AsciiStrLen (String);
+ for (Index = 0; Index < DataSize; Index++) {
+ if (String[Index] < 0x01) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Invalid character String[%d] : %a\n",
+ __FUNCTION__,
+ Index,
+ String
+ ));
+ return Status;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // AML_STRING_PREFIX + String + NULL Terminator
+ DataSize += 2;
+ Data = AllocatePool (DataSize);
+ if (Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: String Space Allocation %a\n",
+ __FUNCTION__,
+ String
+ ));
+ goto Done;
+ }
+
+ Data[0] = AML_STRING_PREFIX;
+ CopyMem (&Data[1], String, DataSize - 1);
+
+ // DataString Complete, Put into Object
+ Object->Data = Data;
+ Object->DataSize = DataSize;
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a data buffer AML object from an array
+
+ This will take the passed in buffer and generate an AML Object from that
+ buffer
+
+ @param[in] Buffer - Buffer to be placed in AML Object
+ @param[in] BufferSize - Size of Buffer to be copied into Object
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDataBufferFromArray (
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if ((Buffer == NULL) || (BufferSize == 0) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Data Buffer object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocatePool (BufferSize);
+ Object->DataSize = BufferSize;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Data Buffer allocate failed\n", __FUNCTION__));
+ goto Done;
+ }
+
+ CopyMem (Object->Data, Buffer, BufferSize);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.36 EISAID (EISA ID String To Integer Conversion Macro)
+
+ Syntax:
+ EISAID (EisaIdString) => DWordConst
+
+ Arguments:
+ The EisaIdString must be a String object of the form "UUUNNNN", where "U"
+ is an uppercase letter and "N" is a hexadecimal digit. No asterisks or other
+ characters are allowed in the string.
+
+ Description:
+ Converts EisaIdString, a 7-character text string argument, into its
+ corresponding 4-byte numeric EISA ID encoding. It can be used when declaring
+ IDs for devices that have EISA IDs.
+
+ Encoded EISA ID Definition - 32-bits
+ bits[15:0] - three character compressed ASCII EISA ID. *
+ bits[31:16] - binary number
+ * Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
+
+
+ Example:
+ EISAID ("PNP0C09") // This is a valid invocation of the macro.
+
+ @param[in] String - EISA ID string.
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+**/
+EFI_STATUS
+EFIAPI
+AmlOPEisaId (
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ UINT32 EncodedEisaId;
+ UINT8 i;
+
+ EncodedEisaId = 0;
+
+ if ((String == NULL) || (ListHead == NULL)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, inputs cannot == NULL.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AsciiStrLen (String) != 0x7) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String' parameter.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Verify String is formatted as "UUUNNNN".
+ //
+ for (i = 0; i <= 0x6; i++) {
+ //
+ // If first 3 characters are not uppercase alpha or last 4 characters are not hexadecimal
+ //
+ if (((i <= 0x2) && (!IS_ASCII_UPPER_ALPHA (String[i]))) ||
+ ((i >= 0x3) && (!IS_ASCII_HEX_DIGIT (String[i]))))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid EISA ID string format!\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, " Input String must be formatted as 'UUUNNNN'.\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // Convert string to 4-byte EISA ID encoding.
+ // Ex: 'PNP0A03' encodes to '0x30AD041'
+ //
+ EncodedEisaId = ((((String[0] - AML_NAME_CHAR_A + 1) & 0x1f) << 10)
+ + (((String[1] - AML_NAME_CHAR_A + 1) & 0x1f) << 5)
+ + (((String[2] - AML_NAME_CHAR_A + 1) & 0x1f) << 0)
+ + (UINT32)(AsciiStrHexToUint64 (&String[3]) << 16));
+
+ //
+ // Swap bytes of upper and lower WORD to format EISA ID with proper endian-ness.
+ //
+ EncodedEisaId = Swap4Bytes (EncodedEisaId);
+
+ //
+ // Insert DWordPrefix into list.
+ // Note: EncodedEisaId will always be 32-bits, resulting in DWordConst.
+ //
+ Status = AmlOPDataInteger (EncodedEisaId, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to create ACPI DWordConst from Encoded EISA ID.\n", __FUNCTION__));
+ return Status;
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
new file mode 100644
index 0000000000000000000000000000000000000000..d9ba614597f90fe307b0b09af10e59a32a341da3
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -0,0 +1,1291 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+// ----------------------------------------------------------------------------
+// Expression Opcodes Encoding
+// ----------------------------------------------------------------------------
+// ExpressionOpcode := DefAcquire | DefAdd | DefAnd | DefBuffer | DefConcat |
+// DefConcatRes | DefCondRefOf | DefCopyObject | DefDecrement |
+// DefDerefOf | DefDivide | DefFindSetLeftBit | DefFindSetRightBit |
+// DefFromBCD | DefIncrement | DefIndex | DefLAnd | DefLEqual |
+// DefLGreater | DefLGreaterEqual | DefLLess | DefLLessEqual | DefMid |
+// DefLNot | DefLNotEqual | DefLoadTable | DefLOr | DefMatch | DefMod |
+// DefMultiply | DefNAnd | DefNOr | DefNot | DefObjectType | DefOr |
+// DefPackage | DefVarPackage | DefRefOf | DefShiftLeft | DefShiftRight |
+// DefSizeOf | DefStore | DefSubtract | DefTimer | DefToBCD | DefToBuffer |
+// DefToDecimalString | DefToHexString | DefToInteger | DefToString |
+// DefWait | DefXOr | MethodInvocation
+// ----------------------------------------------------------------------------
+
+/**
+ Creates a Buffer (BufferSize) {Initializer} => Buffer Object
+
+ Initializers must be created between AmlStart and AmlClose Phase
+
+ DefBuffer := BufferOp PkgLength BufferSize ByteList
+ BufferOp := 0x11
+ BufferSize := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] BufferSize - Requested BufferSize, Encoded value will be
+ MAX (BufferSize OR Child->DataSize)
+ @param[in,out] ListHead - Linked list has completed Buffer Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlBuffer (
+ IN AML_FUNCTION_PHASE Phase,
+ IN UINTN BufferSize,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+ UINTN InternalBufferSize;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // iASL compiler 20200110 only keeps lower 32 bits of size. We'll error if
+ // someone requests something >= 4GB size. Have a message with this to be
+ // very specific
+ if (BufferSize >= SIZE_4GB) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BufferSize=0x%X >= 4GB\n", __FUNCTION__, BufferSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start the Buffer Object
+ Status = InternalAppendNewAmlObject (&Object, "BUFFER", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFER object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Start BufferSize
+ Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // ByteList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // ByteList items should be closed already
+
+ // Close BufferSize
+ Status = InternalAmlLocateObjectByIdentifier (
+ &Object,
+ "BUFFERSIZE",
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Fail locate BufferSize object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collect BufferSize children\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Set BufferSize Object to correct value and size.
+ // BufferSize should be from zero (no Child Data) to MAX of requested
+ // BufferSize or size required for ChildObject->Data.
+ InternalBufferSize = MAX (BufferSize, ChildObject->DataSize);
+ // iASL compiler 20200110 only keeps lower 32 bits of size. We'll error if
+ // someone requests something >= 4GB size.
+ if (InternalBufferSize >= SIZE_4GB) {
+ Status = EFI_BAD_BUFFER_SIZE;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: BufferSize 0x%X >= 4GB\n",
+ __FUNCTION__,
+ InternalBufferSize
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ InternalBufferSize,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __FUNCTION__));
+ goto Done;
+ }
+
+ if ((ChildObject->DataSize != 0) && (ChildObject->Data != NULL)) {
+ // Make room for ChildObject->Data
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize +
+ ChildObject->DataSize,
+ Object->Data
+ );
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: to reallocate BufferSize\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ CopyMem (
+ &Object->Data[Object->DataSize],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ Object->DataSize += ChildObject->DataSize;
+ }
+
+ // Free Child Object since it has been consumed
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: close PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Complete Buffer object with all data
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "BUFFER", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Buffer object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+
+ // Buffer must have at least PkgLength BufferSize
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: No Buffer Data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // BufferOp is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer allocate failed\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Object->Data[0] = AML_BUFFER_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ // Free Child Object since it has been consumed
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a LEqual (Source1, Source2) => Boolean
+
+ Source1 and Source2 operands must be created between AmlStart and AmlClose Phase
+
+ DefLEqual := LequalOp Operand Operand
+ LequalOp := 0x93
+ Operand := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed LEqual Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlLEqual (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start the LEqual Object
+ Status = InternalAppendNewAmlObject (&Object, "LEQUAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start LEQUAL object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Operands are too complicated and must be added outside
+ break;
+
+ case AmlClose:
+
+ // Close LEqual
+ Status = InternalAmlLocateObjectByIdentifier (
+ &Object,
+ "LEQUAL",
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Fail locate LEqual object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+
+ // LEqual must have at least two operands
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: No LEqual Args\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // LequalOp is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer allocate failed\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Object->Data[0] = AML_LEQUAL_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ // Free Child Object since it has been consumed
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/*
+ Creates (NumElements) section of a Package: {PackageList} => Package
+
+ Initializers must be created between AmlStart and AmlClose Phase
+ Internal only function no public reference or documentation needed.
+
+ NumElements := ByteData
+ VarNumElements := TermArg => Integer
+ PackageElementList := Nothing |
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] NumElements - Number of elements in the package. If 0, size
+ is calculated from the PackageList.
+ @param[in,out] ListHead - Linked list has completed Package Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlNumElements (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT UINTN *NumElements,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+ ChildCount = 0;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start Number of Elements Object
+ Status = InternalAppendNewAmlObject (&Object, "NUM_ELEMENTS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NUM_ELEMENTS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // PackageList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // PackageList items should be closed already
+
+ // Close Number of Elements Object
+ Status = InternalAmlLocateObjectByIdentifier (
+ &Object,
+ "NUM_ELEMENTS",
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Fail locate NUM_ELEMENTS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collect NUM_ELEMENTS children\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // We do not have to change anything for NumElements >= Child Count
+ if (*NumElements == 0) {
+ *NumElements = ChildCount;
+ } else if (*NumElements < ChildCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumElements < ChildCount.\n", __FUNCTION__));
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ if (*NumElements <= MAX_UINT8) {
+ Object->DataSize = 1;
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumElements allocate failed\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Object->Data[0] = (UINT8)*NumElements;
+ } else {
+ Status = InternalAmlDataIntegerBuffer (
+ *NumElements,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc NumElements\n", __FUNCTION__));
+ goto Done;
+ }
+ }
+
+ if ((ChildObject->DataSize != 0) && (ChildObject->Data != NULL)) {
+ // Make room for ChildObject->Data
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize +
+ ChildObject->DataSize,
+ Object->Data
+ );
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: to reallocate NumElements\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ CopyMem (
+ &Object->Data[Object->DataSize],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ Object->DataSize += ChildObject->DataSize;
+ }
+
+ // Free Child Object since it has been consumed
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Package (NumElements) {PackageList} => Package
+
+ Initializers must be created between AmlStart and AmlClose Phase
+
+ DefPackage := PackageOp PkgLength NumElements PackageElementList
+ PackageOp := 0x12
+ DefVarPackage := VarPackageOp PkgLength VarNumElements PackageElementList
+ VarPackageOp := 0x13
+ NumElements := ByteData
+ VarNumElements := TermArg => Integer
+ PackageElementList := Nothing |
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] NumElements - Number of elements in the package. If 0, size
+ is calculated from the PackageList.
+ @param[in,out] ListHead - Linked list has completed Package Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlPackage (
+ IN AML_FUNCTION_PHASE Phase,
+ IN UINTN NumElements,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+ UINT8 OpCode;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start the Package Object
+ Status = InternalAppendNewAmlObject (&Object, "PACKAGE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PACKAGE object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Start Number of Elements Object
+ Status = InternalAmlNumElements (AmlStart, &NumElements, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NUM_ELEMENTS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // PackageList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // PackageList items should be closed already
+
+ // Close Number of Elements Object
+ Status = InternalAmlNumElements (AmlClose, &NumElements, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close NUM_ELEMENTS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ if (NumElements <= MAX_UINT8) {
+ OpCode = AML_PACKAGE_OP;
+ } else {
+ OpCode = AML_VAR_PACKAGE_OP;
+ }
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: close PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Complete Package object with all data
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "PACKAGE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate PACKAGE object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ // Package must have at least PkgLength NumElements
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: No Package Data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // PackageOp and VarPackageOp are both one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package allocate failed\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Object->Data[0] = OpCode;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ // Free Child Object since it has been consumed
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Store expression
+
+ Syntax:
+ Store (Source, Destination) => DataRefObject Destination = Source => DataRefObject
+
+ Store expression must be created between AmlStart and AmlClose Phase.
+
+ DefStore := StoreOp TermArg SuperName
+ StoreOp := 0x70
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlStore (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ // Start Store expression
+ Status = InternalAppendNewAmlObject (&Object, "STORE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot append STORE object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // TermArg and SuperName are outside the scope of this object. They must be
+ // defined as part of a multi-tier call - in between AmlStore(AmlStart,..) and
+ // AmlStore(AmlClose,...) - when creating the Store expression.
+ break;
+
+ case AmlClose:
+ // TermArg and SuperName must have been created and closed by now.
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "STORE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating STORE Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 1);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Store()\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Store Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+
+ // Fill out Store object
+ Object->Data[0] = AML_STORE_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Shift Left or Right expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Reult) => Integer
+ Result = Source << ShiftCount => Integer
+ Result <<= ShiftCount => Integer
+
+ ShiftRight (Source, ShiftCount, Reult) => Integer
+ Result = Source >> ShiftCount => Integer
+ Result >>= ShiftCount => Integer
+
+ Shift expression must be created between AmlStart and AmlClose Phase.
+
+ DefShiftLeft := ShiftOp Operand ShiftCount Target
+ ShiftOp := 0x79 or 0x7A
+ ShiftCount := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] ShiftOp - Specifies whether to shift left or shift
+ right.
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlShift (
+ IN AML_FUNCTION_PHASE Phase,
+ IN UINT8 ShiftOp,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start Store expression
+ Status = InternalAppendNewAmlObject (&Object, "SHIFT", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot append SHIFT object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Operand, ShiftCount, and Target are outside the scope of this object. They must be
+ // defined as part of a multi-tier call - in between AmlShift(AmlStart,..) and
+ // AmlShift(AmlClose,...) - when creating the Shift expression.
+
+ break;
+
+ case AmlClose:
+ // Operand, ShiftCount, and Target must have been created and closed by now.
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "SHIFT", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating SHIFT Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 1);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Store()\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Store Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+
+ // Fill out Store object
+ Object->Data[0] = ShiftOp;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Shift Left expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Result) => Integer
+ Result = Source << ShiftCount => Integer
+ Result <<= ShiftCount => Integer
+
+ Shift expression must be created between AmlStart and AmlClose Phase.
+
+ DefShiftLeft := ShiftLeftOp Operand ShiftCount Target
+ ShiftLeftOp := 0x79
+ ShiftCount := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlShiftLeft (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlShift (Phase, AML_SHIFT_LEFT_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a Shift Right expression
+
+ Syntax:
+ ShiftRight (Source, ShiftCount, Reult) => Integer
+ Result = Source >> ShiftCount => Integer
+ Result >>= ShiftCount => Integer
+
+ Shift expression must be created between AmlStart and AmlClose Phase.
+
+ DefShiftRight := ShiftRightOp Operand ShiftCount Target
+ ShiftRightOp := 0x7A
+ ShiftCount := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlShiftRight (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlShift (Phase, AML_SHIFT_RIGHT_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a Find First Set Bit AML object for
+ both right and left searches.
+
+ Syntax:
+ FindSetLeftBit (Source, Result) => Integer
+
+ FindSetRightBit (Source, Result) => Integer
+
+ Bit Fields must be created between AmlStart and AmlClose Phase.
+
+ DefFindSetLeftBit := FindSetLeftBitOp Operand Target
+ FindSetLeftBitOp := 0x81
+
+ DefFindSetRightBit := FindSetRightBitOp Operand Target
+ FindSetRightBitOp := 0x82
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] FindSetOp - Specifies whether to search left or search
+ right.
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlFindSetBit (
+ IN AML_FUNCTION_PHASE Phase,
+ IN UINT8 FindSetOp,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start Store expression
+ Status = InternalAppendNewAmlObject (&Object, "FINDSET", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot append FIND_SET object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Source and Result are outside the scope of this object. They must be
+ // defined as part of a multi-tier call - in between AmlFindSet(AmlStart,..) and
+ // AmlFindSet(AmlClose,...) - when creating the FindSetBit expression.
+
+ break;
+
+ case AmlClose:
+ // Source and Result must have been created and closed by now.
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "FINDSET", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating FIND_SET Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 1);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Store()\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Store Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+
+ // Fill out Store object
+ Object->Data[0] = FindSetOp;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a FindSetLeftBit AML Object
+
+ Syntax:
+ FindSetLeftBit (Source, Result) => Integer
+
+ FindSetLeftBit expression must be created between
+ AmlStart and AmlClose Phase.
+
+ DefFindSetLeftBit := FindSetLeftBitOp Operand Target
+ FindSetLeftBitOp := 0x81
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlFindSetLeftBit (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlFindSetBit (Phase, AML_FIND_SET_LEFT_BIT_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a FindSetRightBit AML Object
+
+ Syntax:
+ FindSetRightBit (Source, Result) => Integer
+
+ FindSetRightBit expression must be created between
+ AmlStart and AmlClose Phase.
+
+ DefFindSetRightBit := FindSetRightBit Operand Target
+ FindSetRightBit := 0x82
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlFindSetRightBit (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlFindSetBit (Phase, AML_FIND_SET_RIGHT_BIT_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a Decrement expression
+
+ Syntax:
+ Decrement (Minuend) => Integer
+ Minuend-- => Integer
+
+ Creates object to decrement Minuend.
+
+ DefDecrement := DecrementOp SuperName
+ DecrementOp := 0x76
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDecrement (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ switch (Phase) {
+ case AmlStart:
+ // Start decrement expression
+ Status = InternalAppendNewAmlObject (&Object, "DECREMENT", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot append DECREMENT object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Minuend is outside the scope of this object. It must be
+ // defined as part of a multi-tier call - in between AmlDecrement(AmlStart,..) and
+ // AmlDecrement(AmlClose,...) - when creating the Decrement expression.
+
+ break;
+
+ case AmlClose:
+ // Minuend must created and closed by now.
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "DECREMENT", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating DECREMENT Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 1);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Store()\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Decrement Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+
+ // Fill out Decrement object
+ Object->Data[0] = AML_DECREMENT_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..a0db35628ab436fc30c27404826ef66ac6d11072
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -0,0 +1,50 @@
+## @file
+#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmlGenerationLib
+ FILE_GUID = 8F62C8D1-B67F-4AFB-9179-54384F1A6163
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DXE_DRIVER UEFI_DRIVER HOST_APPLICATION
+
+[Sources.common]
+ LocalAmlObjects.h
+ LocalAmlObjects.c
+ LocalAmlLib.h
+ AmlAssistFunctions.c
+ AmlObjectsDebug.c
+ AmlNameString.c
+ AmlDataObjects.c
+ AmlNamespaceModifierObjects.c
+ AmlPkgLength.c
+ AmlNamedObject.c
+ AmlTable.c
+ AmlStatementOpcodes.c
+ AmlResourceDescriptor.c
+ AmlExpressionOpcodes.c
+ AmlArgObjects.c
+ AmlLocalObjects.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+
+[Protocols]
+
+[Pcd]
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
new file mode 100644
index 0000000000000000000000000000000000000000..0a0e2d2c64a71289d05e7e7703fdb0ae00dce54c
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -0,0 +1,155 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ Fill the DataBuffer with correct Local Opcode based on provided argument number
+ Valid Argument numbers are 0, 1, 2, 3, 4, 5 and 6.
+ AML supports max 7 Local variables, i.e., Local1, Local2 ... Local6.
+
+ @param[in] LocalN - Local variable Number
+ @param[out] ReturnData - Allocated DataBuffer with encoded integer
+ @param[out] ReturnDataSize - Size of ReturnData
+
+ @return EFI_SUCCESS - Successful completion
+ @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffer
+ @return EFI_INVALID_PARAMETER - Invalid LocalN provided.
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlLocalBuffer (
+ IN OUT UINT8 LocalN,
+ OUT VOID **ReturnData,
+ OUT UINTN *ReturnDataSize
+ )
+{
+ UINT8 *Data;
+ UINTN DataSize;
+
+ Data = AllocateZeroPool (sizeof (UINT8));
+ if (Data == NULL) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Failed to create Data Buffer.\n",
+ __FUNCTION__
+ ));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ DataSize = 1;
+ switch (LocalN) {
+ case 0:
+ Data[0] = AML_LOCAL0;
+ break;
+ case 1:
+ Data[0] = AML_LOCAL1;
+ break;
+ case 2:
+ Data[0] = AML_LOCAL2;
+ break;
+ case 3:
+ Data[0] = AML_LOCAL3;
+ break;
+ case 4:
+ Data[0] = AML_LOCAL4;
+ break;
+ case 5:
+ Data[0] = AML_LOCAL5;
+ break;
+ case 6:
+ Data[0] = AML_LOCAL6;
+ break;
+ case 7:
+ Data[0] = AML_LOCAL7;
+ break;
+ default:
+ FreePool (Data);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ReturnData = (VOID *)Data;
+ *ReturnDataSize = DataSize;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Creates an LocalN Opcode object
+
+ Local Objects Encoding
+ LocalObj := Local0Op | Local1Op | Local2Op | Local3Op | Local4Op | Local5Op | Local6Op | Local7Op
+ Local0Op := 0x60
+ Local1Op := 0x61
+ Local2Op := 0x62
+ Local3Op := 0x63
+ Local4Op := 0x64
+ Local5Op := 0x65
+ Local6Op := 0x66
+ Local7Op := 0x67
+
+ @param[in] LocalN - Argument Number to be encoded
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+**/
+EFI_STATUS
+EFIAPI
+AmlOPLocalN (
+ IN UINT8 LocalN,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Start %a object\n",
+ __FUNCTION__,
+ "LOCALN_OPCODE"
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlLocalBuffer (
+ LocalN,
+ (VOID **)&(Object->Data),
+ &(Object->DataSize)
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: ACPI Argument 0x%X object\n",
+ __FUNCTION__,
+ LocalN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNameString.c
new file mode 100644
index 0000000000000000000000000000000000000000..620a2211598678b50c3de020001623e66d1e1bb9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -0,0 +1,573 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+#define MAX_NAME_SEG_COUNT 255
+
+/*
+ Is character a RootChar
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a RootChar
+ @return FALSE - Character is not a RootChar
+ */
+BOOLEAN
+InternalIsRootChar (
+ IN CHAR8 TestChar
+ )
+{
+ if (TestChar == AML_ROOT_CHAR) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ Is character a ParentPrefixChar
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a ParentPrefixChar
+ @return FALSE - Character is not a ParentPrefixChar
+ */
+BOOLEAN
+InternalIsParentPrefixChar (
+ IN CHAR8 TestChar
+ )
+{
+ if (TestChar == AML_PARENT_PREFIX_CHAR) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ Is character a LeadNameChar = '_', 'A' - 'Z'
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a LeadNameChar
+ @return FALSE - Character is not a LeadNameChar
+ */
+BOOLEAN
+InternalIsLeadNameChar (
+ IN CHAR8 TestChar
+ )
+{
+ if ( // Allowed LeadNameChars '_', 'A'-'Z'
+ (TestChar == AML_NAME_CHAR__) ||
+ ((TestChar >= AML_NAME_CHAR_A) &&
+ (TestChar <= AML_NAME_CHAR_Z))
+ )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ Is character a DigitChar = '0' - '9'
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a DigitChar
+ @return FALSE - Character is not a DigitChar
+ */
+BOOLEAN
+InternalIsDigitChar (
+ IN CHAR8 TestChar
+ )
+{
+ if ( // Allowed DigitChars '0'-'9'
+ (TestChar >= AML_DIGIT_CHAR_0) &&
+ (TestChar <= AML_DIGIT_CHAR_9)
+ )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ Is character a NameChar = LeadNameChar | DigitChar
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a NameChar
+ @return FALSE - Character is not a NameChar
+ */
+BOOLEAN
+InternalIsNameChar (
+ IN CHAR8 TestChar
+ )
+{
+ if ( // Allowed LeadNameChar and DigitChars
+ InternalIsDigitChar (TestChar) ||
+ InternalIsLeadNameChar (TestChar)
+ )
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ Is character a NameSeg separator
+
+ @param[in] TestChar - Character to check
+
+ @return TRUE - Character is a NameChar
+ @return FALSE - Character is not a NameChar
+ */
+BOOLEAN
+InternalIsNameSegSeparator (
+ IN CHAR8 TestChar
+ )
+{
+ if (TestChar == '.') {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Creates a NameSeg AML object and inserts it into the List
+
+ NameSeg :=
+
+ NameSegs shorter than 4 characters are filled with trailing underscores
+
+ @param[in] Name - NameSeg
+ @param[in,out] ListHead - Linked list has NameSeg after call
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlNameSeg (
+ IN CHAR8 *Name,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+ UINT8 *NameSeg;
+ UINTN NameLen;
+ EFI_STATUS Status;
+
+ if (Name == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ NameLen = AsciiStrLen (Name);
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ NameSeg = NULL;
+ // parameter validation
+ if ((NameLen == 0) || (NameLen > 4)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!InternalIsLeadNameChar (Name[0])) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (UINT8 i = 1; NameLen > 1 && i < NameLen; i++) {
+ if (!InternalIsNameChar (Name[i])) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ NameSeg = AllocateZeroPool (4);
+ if (NameSeg == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (NameSeg, Name, NameLen);
+
+ if (NameLen < 4) {
+ SetMem (&NameSeg[NameLen], 4 - NameLen, '_');
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (Object != NULL) {
+ if (!EFI_ERROR (Status)) {
+ Object->Data = NameSeg;
+ Object->DataSize = 4;
+ Object->Completed = TRUE;
+ } else {
+ InternalFreeAmlObject (&Object, ListHead);
+ FreePool (NameSeg);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Namestring AML Object and inserts it into the linked list
+
+ LeadNameChar := 'A'-'Z' | '_'
+ DigitChar := '0'-'9'
+ NameChar := DigitChar | LeadNameChar
+ RootChar := '\'
+ ParentPrefixChar := '^'
+
+ 'A'-'Z' := 0x41 - 0x5A
+ '_' := 0x5F
+ '0'-'9' := 0x30 - 0x39
+ '\' := 0x5C
+ '^' := 0x5E
+
+ NameSeg :=
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := |
+ PrefixPath := Nothing | <'^' PrefixPath>
+ NamePath := NameSeg | DualNamePath | MultiNamePath | NullName
+
+ DualNamePath := DualNamePrefix NameSeg NameSeg
+ DualNamePrefix := 0x2E
+ MultiNamePath := MultiNamePrefix SegCount NameSeg(SegCount)
+ MultiNamePrefix := 0x2F
+
+ SegCount := ByteData
+
+ Note:SegCount can be from 1 to 255. For example: MultiNamePrefix(35) is
+ encoded as 0x2f 0x23 and followed by 35 NameSegs. So, the total encoding
+ length will be 1 + 1 + 35*4 = 142. Notice that: DualNamePrefix NameSeg
+ NameSeg has a smaller encoding than the encoding of: MultiNamePrefix(2)
+ NameSeg NameSeg
+
+ SimpleName := NameString | ArgObj | LocalObj
+ SuperName := SimpleName | DebugObj | Type6Opcode
+ NullName := 0x00
+ Target := SuperName | NullName
+
+ @param[in] String - Null Terminated NameString Representation
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+ **/
+EFI_STATUS
+EFIAPI
+AmlOPNameString (
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ CHAR8 *NameString;
+ CHAR8 *NameStringPrefix;
+ UINTN NameStringBufferSize;
+ UINTN NameStringSize;
+ UINTN NameStringPrefixSize;
+ UINTN NameSegCount;
+ UINTN StringIndex;
+ UINTN StringLength;
+ UINTN NameSegIndex;
+ BOOLEAN FoundRootChar;
+ BOOLEAN FoundParentPrefixChar;
+ BOOLEAN FoundParenthesisOpenChar;
+ BOOLEAN FoundParenthesisCloseChar;
+
+ if ((String == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ NameString = NULL;
+ FoundRootChar = FALSE;
+ FoundParentPrefixChar = FALSE;
+ NameStringBufferSize = 0;
+ FoundParenthesisOpenChar = FALSE;
+ FoundParenthesisCloseChar = FALSE;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Create a buffer to fit NameSeg [4] * max NameSegCount [255]
+ NameStringBufferSize = 4 * MAX_NAME_SEG_COUNT;
+ NameString = AllocateZeroPool (NameStringBufferSize);
+ // Create arbitrarily large RootChar\ParentPrefixChar buffer
+ NameStringPrefix = AllocateZeroPool (NameStringBufferSize);
+
+ // Calculate length of required space
+ StringLength = AsciiStrLen (String);
+ NameStringSize = 0;
+ NameStringPrefixSize = 0;
+ NameSegIndex = 0;
+ NameSegCount = 0;
+ for (StringIndex = 0; StringIndex < StringLength; StringIndex++) {
+ if (NameStringPrefixSize >= NameStringBufferSize) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Exceeded ParentPrefixChar support at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+
+ if (InternalIsRootChar (String[StringIndex])) {
+ if (NameSegCount != 0) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: RootChar at offset=%d of String=%a\n", __FUNCTION__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more than 1 RootChar.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ if (FoundParentPrefixChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // RootChar; increment NameStringSize
+ NameStringPrefix[NameStringPrefixSize] = String[StringIndex];
+ NameStringPrefixSize++;
+ FoundRootChar = TRUE;
+ } else if (InternalIsParentPrefixChar (String[StringIndex])) {
+ if (NameSegCount != 0) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ParentPrefixChar at offset=%d of String=%a\n", __FUNCTION__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // ParentPrefixChar; increment NameStringSize
+ NameStringPrefix[NameStringPrefixSize] = String[StringIndex];
+ NameStringPrefixSize++;
+ FoundParentPrefixChar = TRUE;
+ } else if (!InternalIsNameChar (String[StringIndex])) {
+ if (InternalIsNameSegSeparator (String[StringIndex])) {
+ if (NameSegIndex == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Invalid NameSeg separator at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ } else {
+ NameSegIndex = 0;
+ }
+ } else if (String[StringIndex] == '(') {
+ if (FoundParenthesisOpenChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Invalid Parenthesis at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+
+ FoundParenthesisOpenChar = TRUE;
+ } else if (String[StringIndex] == ')') {
+ if (FoundParenthesisCloseChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Invalid Parenthesis at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ } else if (!FoundParenthesisOpenChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: No Open Parenthesis before offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+
+ FoundParenthesisCloseChar = TRUE;
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Unsupported character at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+ } else {
+ // Must be NameChar
+ if (FoundParenthesisOpenChar || FoundParenthesisCloseChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: NameChar after Parenthesis at offset=%d of String=%a\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ } else if ((NameSegIndex == 0) && InternalIsDigitChar (String[StringIndex])) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: must be LeadNameChar at offset=%d of String=%a'\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+
+ if (NameSegIndex >= 4) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: NameSeg > 4 characters at offset=%d of String=%a'\n",
+ __FUNCTION__,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ } else {
+ if (NameSegIndex == 0) {
+ NameSegCount++;
+ if (NameSegCount > MAX_NAME_SEG_COUNT) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: Max NameSegCount=%d reached at offset=%d of String=%a'\n",
+ __FUNCTION__,
+ MAX_NAME_SEG_COUNT,
+ StringIndex,
+ String
+ ));
+ goto Done;
+ }
+ }
+
+ NameString[NameStringSize] = String[StringIndex];
+ NameStringSize++;
+ NameSegIndex++;
+ if ((StringIndex + 1 >= StringLength) ||
+ !InternalIsNameChar (String[StringIndex + 1]))
+ {
+ // Extend in progress NameSeg with '_'s
+ if (NameSegIndex < 4) {
+ SetMem (&NameString[NameStringSize], 4 - NameSegIndex, '_');
+ NameStringSize += 4 - NameSegIndex;
+ }
+ }
+ }
+ }
+ }
+
+ // Create AML Record with NameString contents from above
+ // Copy in RootChar or ParentPrefixChar(s)
+ if (NameStringPrefixSize != 0) {
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ NameStringPrefixSize,
+ Object->Data
+ );
+ CopyMem (
+ &Object->Data[Object->DataSize],
+ NameStringPrefix,
+ NameStringPrefixSize
+ );
+ Object->DataSize += NameStringPrefixSize;
+ FreePool (NameStringPrefix);
+ }
+
+ // Set up for Dual/MultiName Prefix
+ if (NameSegCount > MAX_NAME_SEG_COUNT) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Exceeded MaxNameSegCount in NameString=%a\n", __FUNCTION__, String));
+ goto Done;
+ } else if (NameSegCount == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Must be at least one NameSeg in NameString=%a\n", __FUNCTION__, String));
+ goto Done;
+ } else if (NameSegCount == 1) {
+ // Single NameSeg
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + NameStringSize,
+ Object->Data
+ );
+ } else if (NameSegCount == 2) {
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + NameStringSize + 1,
+ Object->Data
+ );
+ Object->Data[Object->DataSize] = AML_DUAL_NAME_PREFIX;
+ Object->DataSize += 1;
+ } else {
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + NameStringSize + 2,
+ Object->Data
+ );
+ Object->Data[Object->DataSize] = AML_MULTI_NAME_PREFIX;
+ Object->Data[Object->DataSize + 1] = NameSegCount & 0xFF;
+ Object->DataSize += 2;
+ }
+
+ // Copy NameString data over. From above must be at least one NameSeg
+ CopyMem (&Object->Data[Object->DataSize], NameString, NameStringSize);
+ Object->DataSize += NameStringSize;
+ FreePool (NameString);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ if (NameString != NULL) {
+ FreePool (NameString);
+ }
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
new file mode 100644
index 0000000000000000000000000000000000000000..2880adb117cc4c9ec974e7a218869afcfd023d9b
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -0,0 +1,2135 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+#define METHOD_ARGS_MAX 7
+#define MAX_SYNC_LEVEL 0x0F
+#define GENERIC_FIELD_IDENTIFIER "FIELD"
+
+/**
+ Creates a Device (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := DeviceOp PkgLength NameString TermList
+ NameOp := ExtOpPrefix 0x82
+ ExtOpPrefix := 0x5B
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] String - Object name
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDevice (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (String == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Device for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Insert NameString for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // TermList should be closed already
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Device Op is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_DEVICE_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an AccessField
+
+ AccessField := 0x01 AccessType AccessAttrib
+
+ @param[in] AccessType - Access type for field member
+ @param[in] AccessAttribute - Access attribute for field member
+ @param[in,out] ListHead - Linked list containing AML objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlAccessField (
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS AccessAttribute,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ // Start new AML object
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start ACCESSFIELD object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (3);
+ // AML_ACCESSFIELD_OP + AccessType + AccessAttrib
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for ACCESSFIELD\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_FIELD_ACCESS_OP;
+ Object->Data[1] = (UINT8)AccessType;
+ Object->Data[2] = (UINT8)AccessAttribute;
+ Object->DataSize = 3;
+
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an ExtendedAccessField
+
+ ExtendedAccessField := 0x03 AccessType ExtendedAccessAttrib AccessLength
+
+ @param[in] AccessType - Access type for field member
+ @param[in] AccessAttribute - Access attribute for field member
+ @param[in] AccessLength - Specifies the access length for the field member
+ @param[in,out] ListHead - Linked list containing AML objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlExtendedAccessField (
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS AccessAttribute,
+ IN UINT8 AccessLength,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+
+ // Start new AML object
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start EXTENDEDACCESSFIELD object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (4);
+ // AML_EXTACCESSFIELD_OP + AccessType + AccessAttrib + AccessLength
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for EXTENDEDACCESSFIELD\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_FIELD_EXT_ACCESS_OP;
+ Object->Data[1] = (UINT8)AccessType;
+ Object->Data[2] = (UINT8)AccessAttribute;
+ Object->Data[3] = AccessLength;
+ Object->DataSize = 4;
+
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an AccessAs Field Unit
+
+ AccessAs (AccessType, AccessAttribute)
+ AccessAs (AccessType, AccessAttribute (AccessLength))
+
+ AccessField := 0x01 AccessType AccessAttrib
+ AccessType := ByteData // Bits 0:3 - Same as AccessType bits of FieldFlags.
+ // Bits 4:5 - Reserved
+ // Bits 7:6 - 0 = AccessAttrib = Normal Access Attributes
+ // 1 = AccessAttrib = AttribBytes (x)
+ // 2 = AccessAttrib = AttribRawBytes (x)
+ // 3 = AccessAttrib = AttribRawProcessBytes (x)
+
+ // x' is encoded as bits 0:7 of the AccessAttrib byte.
+ The description of bits 7:6 is incorrect and if AttribBytes,
+ AttribRawBytes, or AttribRawProcessBytes are used here, an
+ ExtendedAccessField is used with the following definitions
+ ExtendedAccessField := 0x03 AccessType ExtendedAccessAttrib AccessLength
+ ExtendedAccessAttrib := ByteData // 0x0B AttribBytes
+ // 0x0E AttribRawBytes
+ // 0x0F AttribRawProcess
+
+ AccessAttrib := ByteData // If AccessType is BufferAcc for the SMB or
+ // GPIO OpRegions, AccessAttrib can be one of
+ // the following values:
+ // 0x02 AttribQuick
+ // 0x04 AttribSendReceive
+ // 0x06 AttribByte
+ // 0x08 AttribWord
+ // 0x0A AttribBlock
+ // 0x0C AttribProcessCall
+ // 0x0D AttribBlockProcessCall
+
+ @param[in] AccessType - Access type for field member
+ @param[in] AccessAttribute - Access attribute for field member
+ @param[in] AccessLength - Only used if AccessAttribute is AttribBytes,
+ AttribRawBytes, or AttribRawProcessBytes.
+ Specifies the access length for the field member
+ Otherwise, ignored.
+ @param[in,out] ListHead - Linked list containing AML objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPAccessAs (
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS AccessAttribute,
+ IN UINT8 AccessLength,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // AcessType parameter check
+ if (AccessType > BufferAcc) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // AccessAttrib parameter checking
+ if ((AccessAttribute >= AttribNormal) && (AccessAttribute <= AttribBlock)) {
+ if ((AccessAttribute & 1) == 1) {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else if (AccessAttribute > AttribRawProcessBytes) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // if AccessAttrib requires a length parameter, then an ExtendedAccessField is used
+ switch (AccessAttribute) {
+ case AttribBytes:
+ case AttribRawBytes:
+ case AttribRawProcessBytes:
+ Status = InternalAmlExtendedAccessField (AccessType, AccessAttribute, AccessLength, ListHead);
+ break;
+ default:
+ Status = InternalAmlAccessField (AccessType, AccessAttribute, ListHead);
+ break;
+ }
+
+ return Status;
+}
+
+/**
+ Creates an External Object
+
+ External (ObjectName, ObjectType, ReturnType, ParameterTypes)
+
+ Note: ReturnType is not used for AML encoding and is therefore not passed in
+ to this function.
+ ParameterTypes is only used if the ObjectType is a MethodObj. It
+ specifies MethodObj's argument types in a list. For the purposes of
+ this library, we are passing in the the number of input parameters for
+ that MethodObj.
+
+ DefExternal := ExternalOp NameString ObjectType ArgumentCount
+ ExternalOp := 0x15
+ ObjectType := ByteData
+ ArgumentCount := ByteData (0 - 7)
+
+ @param[in] Name - Object name
+ @param[in] ObjectType - Type of object declared
+ @param[in] NumArgs - Only used if ObjectType is MethodObj.
+ Specifies the number of input parameters for
+ that MethodObj.
+ Otherwise, ignored.
+ @param[in,out] ListHead - Linked list that has completed External Object
+ after AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPExternal (
+ IN CHAR8 *Name,
+ IN UINT8 ObjectType,
+ IN UINT8 NumArgs,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Name == NULL) ||
+ (NumArgs > METHOD_ARGS_MAX) ||
+ (ObjectType >= InvalidObj) ||
+ (ListHead == NULL))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ // Start EXTERNAL object
+ Status = InternalAppendNewAmlObject (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 3);
+ // AML_EXTERNAL_OP + Name + ObjectType + ArgumentCount
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Object->DataSize = 0;
+ Object->Data[0] = AML_EXTERNAL_OP;
+ Object->DataSize++;
+ CopyMem (
+ &Object->Data[Object->DataSize],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ Object->DataSize += ChildObject->DataSize;
+ Object->Data[Object->DataSize] = ObjectType;
+ Object->DataSize++;
+ Object->Data[Object->DataSize] = NumArgs;
+ Object->DataSize++;
+
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Locates the AML object that holds the cumulative offset term.
+ This is the node directly after the node designated by
+ GENERIC_FIELD_IDENTIFIER in Object->Data.
+
+ @param[out] ReturnObject - Object that contains the offset term
+ @param[in,out] ListHead - Linked list that contains the GENERIC_FIELD_IDENTIFIER
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlLocateOffsetTerm (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+ UINTN IdentifierSize;
+ CHAR8 *Identifier;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = NULL;
+ *ReturnObject = NULL;
+ Identifier = GENERIC_FIELD_IDENTIFIER;
+ IdentifierSize = AsciiStrLen (Identifier) + 1;
+ // Look Backwards and find Node for this Object
+ Node = ListHead;
+ do {
+ Node = GetPreviousNode (ListHead, Node);
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ if ((Object->DataSize != 0) &&
+ (Object->DataSize == IdentifierSize) &&
+ (CompareMem (
+ Object->Data,
+ Identifier,
+ MAX (Object->DataSize, IdentifierSize)
+ ) == 0))
+ {
+ break;
+ }
+ } while (Node != ListHead);
+
+ // Check to make sure FIELD is found, otherwise error
+ if ((Object->DataSize == 0) ||
+ (Object->DataSize != IdentifierSize) ||
+ CompareMem (
+ Object->Data,
+ Identifier,
+ (MAX (Object->DataSize, IdentifierSize) != 0)
+ ))
+ {
+ return EFI_DEVICE_ERROR;
+ }
+
+ // Have found FIELD
+ Node = GetNextNode (ListHead, Node);
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ *ReturnObject = Object;
+ return EFI_SUCCESS;
+}
+
+/**
+ Offset (ByteOffset)
+
+ Creates a ReservedField if the passed ByteOffset is larger than
+ the previous bit length value optionally specified by an AmlOPFieldListItem,
+ or another Offset call. All offsets are defined starting from zero, based at
+ the starting address of the parent Operation Region.
+
+ ReservedField := 0x00 PkgLength
+
+ @param[in] ByteLength -Byte offset of the next defined field within
+ the parent Operation Region
+ @param[in,out] ListHead - Linked list has completed Offset object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPOffset (
+ IN UINT32 ByteOffset,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *OffsetObject;
+ UINT8 *PkgLength;
+ UINTN DataLength;
+ EFI_STATUS Status;
+ UINT64 InternalOffsetData;
+ UINT64 BitCount;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ InternalOffsetData = 0;
+ BitCount = LShiftU64 (ByteOffset, 3);
+ Object = NULL;
+ OffsetObject = NULL;
+ PkgLength = NULL;
+
+ // Find and read internal offset data
+ Status = InternalAmlLocateOffsetTerm (&OffsetObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term\n", __FUNCTION__));
+ goto Done;
+ }
+
+ InternalOffsetData = *(UINT64 *)OffsetObject->Data;
+
+ if (InternalOffsetData > BitCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __FUNCTION__));
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ } else if (InternalOffsetData == BitCount) {
+ // Do not need to append any reserved fields
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+
+ // update internal offset value to new offset
+ *(UINT64 *)OffsetObject->Data = BitCount;
+
+ // take difference to find how many bits to reserve
+ BitCount = BitCount - InternalOffsetData;
+
+ // Create new object for the offset data, add pkglength encoding
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: appending new AML object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataLength);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->DataSize = DataLength + 1; // add one for Reserved Field Indicator
+ Object->Data = AllocateZeroPool (Object->DataSize);
+
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Offset\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data[0] = 0;
+ CopyMem (&Object->Data[1], PkgLength, DataLength); // read internal offset data
+ Object->Completed = TRUE;
+ FreePool (PkgLength);
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&OffsetObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a NamedField or a ReservedField, depending on the
+ parameters.
+
+ To create a NamedField item pass in the NameSeg and Bitlength
+ as in ASL. To create a ReservedField pass "" as the Name.
+ Must be used inside a Field or IndexField TermList.
+
+ NamedField := NameSeg PkgLength
+ ReservedField := 0x00 PkgLength
+
+ @param[in] Name - Field NameSeg
+ @param[in] BitLength - Length of field item in bits
+ @param[in,out] ListHead - Linked list has completed FieldUnitItem
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPFieldUnit (
+ IN CHAR8 *Name,
+ IN UINT32 BitLength,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *OffsetObject;
+ EFI_STATUS Status;
+
+ if ((ListHead == NULL) || (Name == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ OffsetObject = NULL;
+
+ if (AsciiStrLen (Name) == 0) {
+ if (BitLength > 0) {
+ // Prepend a 0 to the list
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to append AML object.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (1);
+ Object->DataSize = 1;
+ Object->Completed = TRUE;
+ } else {
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+ } else {
+ // add NameSeg to List
+ Status = InternalAmlNameSeg (Name, ListHead);
+ }
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ // Locate and update internal Offset term
+ Status = InternalAmlLocateOffsetTerm (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating offset term for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ *(UINT64 *)Object->Data += BitLength; // write
+
+ // Add BitLength as a PkgLength term
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Appending BitLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength (BitLength, &Object->Data, &Object->DataSize);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Appending BitLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&OffsetObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Field
+
+ Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be added between AmlStart and AmlClose phase
+
+ DefField := FieldOp PkgLength NameString FieldFlags FieldList
+ FieldOp := ExtOpPrefix 0x81
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Field NameString
+ @param[in] AccessType - Access Type for field
+ @param[in] LockRule - Lock rule for field
+ @param[in] UpdateRule - Update rule for field
+ @param[in,out] ListHead - Linked list has completed Field Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlField (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *Name,
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS LockRule,
+ IN EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS UpdateRule,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINT8 FieldFlags;
+ UINTN ChildCount;
+
+ if ((ListHead == NULL) || (Name == NULL) || (AsciiStrLen (Name) == 0)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // parameter validation
+ if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) || (UpdateRule > WriteAsZeros)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Field for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Insert internal offset counter
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to append AML object.\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (UINT64);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ Object->Completed = TRUE;
+ if (EFI_ERROR (Status) || (Object->Data == NULL)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Field internal offset %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Add Field Flags
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start FIELD_FLAGS for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Field Flags is one byte
+ Object->DataSize = 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ FieldFlags = (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessType);
+
+ Object->Data[0] = FieldFlags;
+ Object->Completed = TRUE;
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+
+ // Required NameString completed in one phase call
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Remove internal offset counter
+ Status = InternalAmlLocateOffsetTerm (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // remove original field identifier data
+ Status = InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Field Op is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_FIELD_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a BankField
+
+ BankField (RegionName, BankName, BankValue, AccessType, LockRule, UpdateRule) {FieldUnitList}
+ FieldUnitList must be added between AmlStart and AmlClose phase
+
+ DefBankField := BankFieldOp PkgLength NameString NameString BankValue FieldFlags FieldList
+ BankFieldOp := ExtOpPrefix 0x87
+ BankValue := TermArg => Integer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] RegionName - Name of host Operation Region
+ @param[in] BankName - Name of bank selection register
+ @param[in] BankValue - Bank Selection ID
+ @param[in] AccessType - Access Type as in Field
+ @param[in] LockRule - Lock rule as in Field
+ @param[in] UpdateRule - Update rule as in Field
+ @param[in,out] ListHead - Linked list has completed BankField Object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlBankField (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *RegionName,
+ IN CHAR8 *BankName,
+ IN UINT64 BankValue,
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS LockRule,
+ IN EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS UpdateRule,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINT8 FieldFlags;
+ UINTN ChildCount;
+
+ if ((ListHead == NULL) || (RegionName == NULL) || (AsciiStrLen (RegionName) == 0) ||
+ (BankName == NULL) || (AsciiStrLen (BankName) == 0))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // parameter validation
+ if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) || (UpdateRule > WriteAsZeros)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BankField for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Insert internal offset counter
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ Object->DataSize = sizeof (UINT64);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ Object->Completed = TRUE;
+ if (EFI_ERROR (Status) || (Object->Data == NULL)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BankField internal offset %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Insert required Region NameString
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ // Insert required Bank NameString
+ Status = AmlOPNameString (BankName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Insert required BankValue integer
+ Status = AmlOPDataInteger (BankValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Adding BankValue Integer for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Add Field Flags
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start FIELD_FLAGS for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Field Flags is one byte
+ Object->DataSize = 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ FieldFlags = (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessType);
+
+ Object->Data[0] = FieldFlags;
+ Object->Completed = TRUE;
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+
+ // Required NameStrings completed in one phase call
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Remove internal offset counter
+ Status = InternalAmlLocateOffsetTerm (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // remove original field identifier data
+ Status = InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ // Field Op is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, BankName));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_BANK_FIELD_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an IndexField
+
+ IndexField (IndexName, DataName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be added between AmlStart and AmlClose phase
+
+ DefIndexField := IndexFieldOp PkgLength NameString NameString FieldFlags FieldList
+ IndexFieldOp := ExtOpPrefix 0x86
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] IndexName - Name of Index FieldUnit
+ @param[in] DataName - Name of Data FieldUnit
+ @param[in] AccessType - Access Type for the FieldUnit
+ @param[in] LockRule - Lock rule for the FieldUnit
+ @param[in] UpdateRule - Update rule for the FieldUnit
+ @param[in,out] ListHead - Linked list has completed IndexField Object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlIndexField (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *IndexName,
+ IN CHAR8 *DataName,
+ IN EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS AccessType,
+ IN EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS LockRule,
+ IN EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS UpdateRule,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINT8 FieldFlags;
+ UINTN ChildCount;
+
+ if ((ListHead == NULL) || (IndexName == NULL) || (AsciiStrLen (IndexName) == 0) ||
+ (DataName == NULL) || (AsciiStrLen (DataName) == 0))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // parameter validation
+ if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) || (UpdateRule > WriteAsZeros)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start IndexField for %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Insert internal offset counter
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ Object->DataSize = sizeof (UINT64);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ Object->Completed = TRUE;
+ if (EFI_ERROR (Status) || (Object->Data == NULL)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start IndexField internal offset %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Insert required Index NameString
+ Status = AmlOPNameString (IndexName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Insert required Data NameString
+ Status = AmlOPNameString (DataName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, DataName));
+ goto Done;
+ }
+
+ // Add Field Flags
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start FIELD_FLAGS for %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Field Flags is one byte
+ Object->DataSize = 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ FieldFlags = (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessType);
+
+ Object->Data[0] = FieldFlags;
+ Object->Completed = TRUE;
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+
+ // Required NameString completed in one phase call
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Remove internal offset counter
+ Status = InternalAmlLocateOffsetTerm (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // remove original field identifier data
+ Status = InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIELD_IDENTIFIER, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ // Field Op is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, IndexName));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_INDEX_FIELD_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ OperationRegion (RegionName, RegionSpace, Offset, Length)
+
+ DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen
+ OpRegionOp := ExtOpPrefix 0x80
+ RegionSpace :=
+ ByteData // 0x00 SystemMemory
+ // 0x01 SystemIO
+ // 0x02 PCI_Config
+ // 0x03 EmbeddedControl
+ // 0x04 SMBus
+ // 0x05 System CMOS
+ // 0x06 PciBarTarget
+ // 0x07 IPMI
+ // 0x08 GeneralPurposeIO
+ // 0x09 GenericSerialBus
+ // 0x0A PCC
+ // 0x80-0xFF: OEM Defined
+ RegionOffset := TermArg => Integer
+ RegionLen := TermArg => Integer
+
+ @param[in] RegionName - Name for the Operation Region
+ @param[in] RegionSpace - Region Space type
+ @param[in] Offset - Offset within the selected RegionSpace at which the
+ region starts (byte-granular)
+ @param[in] Length - Length of the region in bytes.
+ @param[in,out] ListHead - Linked list head
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPOperationRegion (
+ IN CHAR8 *RegionName,
+ IN GENERIC_ADDRESS_SPACE_ID RegionSpace,
+ IN UINT64 Offset,
+ IN UINT64 Length,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+ EFI_STATUS Status;
+
+ // Input parameter validation
+ if ((RegionName == NULL) || (AsciiStrLen (RegionName) == 0) || (ListHead == NULL) ||
+ ((RegionSpace > PCC) && (RegionSpace < 0x80)) || (RegionSpace > 0xFF))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = NULL;
+ ChildObject = NULL;
+ Status = EFI_DEVICE_ERROR;
+
+ Status = InternalAppendNewAmlObject (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start OpRegion for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPByteData ((UINT8)RegionSpace, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Region space byte data for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Offset, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Length, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ // OpRegion Opcode is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, RegionName));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_REGION_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a CreateField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateField ( SourceBuffer, BitIndex, NumBits, FieldName )
+
+ DefCreateField := CreateFieldOp SourceBuff BitIndex NumBits NameString
+ CreateFieldOp := ExtOpPrefix 0x13
+ ExtOpPrefix := 0x5B
+ SourceBuff := TermArg => Buffer
+ BitIndex := TermArg => Integer
+ NumBits := TermArg -> Integer
+
+ @param[in] SourceBuffer, - Buffer to house the new buffer field object
+ @param[in] BitIndex, - Starting bit index place the new buffer
+ @param[in] NumBits, - Number of bits to reserve
+ @param[in] FieldName, - The new buffer field object to be created in SourceBuffer
+ @param[in,out] ListHead - Linked list has completed CreateField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 BitIndex,
+ IN UINT64 NumBits,
+ IN CHAR8 *FieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ ChildObject = NULL;
+ Object = NULL;
+
+ if ((SourceBuffer == NULL) || (FieldName == NULL) || (ListHead == NULL) ||
+ (AsciiStrLen (SourceBuffer) == 0) || (AsciiStrLen (FieldName) == 0))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ChildObject = NULL;
+ Status = InternalAppendNewAmlObject (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: CreateField for %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (BitIndex, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NumBits, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ // CreateFieldOp is two bytes
+ Object->DataSize = ChildObject->DataSize + 2;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, FieldName));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_EXT_OP;
+ Object->Data[1] = AML_EXT_CREATE_FIELD_OP;
+ CopyMem (
+ &Object->Data[2],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Internal function used to create a CreateBit|Byte|Word|DWord|QWordField objects
+ and insert them into the linked list
+
+ @param[in] SourceBuffer, - Buffer to insert the new buffer fixed field object
+ @param[in] Index, - Starting index to place the new buffer
+ @param[in] FixedFieldName, - Name of the FixedField
+ @param[in] OpCode, - AML opcode for the Create_Field encoding
+ @param[in,out] ListHead - Linked list has completed CreateFixedField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlCreateFixedField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 Index,
+ IN CHAR8 *FixedFieldName,
+ IN UINT8 OpCode,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ ChildObject = NULL;
+
+ if ((SourceBuffer == NULL) || (FixedFieldName == NULL) || (ListHead == NULL) ||
+ (AsciiStrLen (SourceBuffer) == 0) || (AsciiStrLen (FixedFieldName) == 0))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObject (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: CreateField for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ // Check if Localx Buffer
+ if (AsciiStrnCmp (SourceBuffer, "Local", 5) == 0) {
+ if ((SourceBuffer[5] >= '0') && (SourceBuffer[5] <= '9')) {
+ Status = AmlOPLocalN ((UINT8)AsciiStrDecimalToUintn (&SourceBuffer[5]), ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: LocalN for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ // Check if Argx Buffer
+ } else if (AsciiStrnCmp (SourceBuffer, "Arg", 3) == 0) {
+ if ((SourceBuffer[3] >= '0') && (SourceBuffer[3] <= '9')) {
+ Status = AmlOpArgN ((UINT8)AsciiStrDecimalToUintn (&SourceBuffer[3]), ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ArgN for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+ }
+ } else {
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ Status = AmlOPDataInteger (Index, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FixedFieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ // CreateWordFieldOp is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, FixedFieldName));
+ goto Done;
+ }
+
+ Object->Data[0] = OpCode;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a CreateBitField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateBitField (SourceBuffer, BitIndex, BitFieldName)
+
+ DefCreateBitField := CreateBitFieldOp SourceBuff BitIndex NameString
+ CreateBitFieldOp := 0x8D
+ SourceBuff := TermArg => Buffer
+ BitIndex := TermArg => Integer
+
+ @param[in] SourceBuffer, - Buffer to insert the new buffer bit field object
+ @param[in] BitIndex, - Starting bit index to place the new buffer
+ @param[in] BitFieldName, - Name of the BitField
+ @param[in,out] ListHead - Linked list has completed CreateBitField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateBitField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 BitIndex,
+ IN CHAR8 *BitFieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlCreateFixedField (SourceBuffer, BitIndex, BitFieldName, AML_CREATE_BIT_FIELD_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a CreateByteField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateByteField ( SourceBuffer, ByteIndex, ByteFieldName )
+
+ DefCreateByteField := CreateByteFieldOp SourceBuff ByteIndex NameString
+ CreateByteFieldOp := 0x8C
+ SourceBuff := TermArg => Buffer
+ ByteIndex := TermArg => Integer
+
+ @param[in] SourceBuffer, - Buffer to insert the new buffer byte field object
+ @param[in] ByteIndex, - Starting byte index to place the new buffer
+ @param[in] ByteFieldName, - Name of the ByteField
+ @param[in,out] ListHead - Linked list has completed CreateByteField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateByteField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 ByteIndex,
+ IN CHAR8 *ByteFieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlCreateFixedField (SourceBuffer, ByteIndex, ByteFieldName, AML_CREATE_BYTE_FIELD_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a CreateDWordField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateDWordField ( SourceBuffer, ByteIndex, DWordFieldName )
+
+ DefCreateDWordField := CreateDWordFieldOp SourceBuff ByteIndex NameString
+ CreateDWordFieldOp := 0x8A
+ SourceBuff := TermArg => Buffer
+ ByteIndex := TermArg => Integer
+
+ @param[in] SourceBuffer, - Buffer to insert the new buffer DWord field object
+ @param[in] ByteIndex, - Starting byte index to place the new buffer
+ @param[in] DWordFieldName, - Name of the DWordField
+ @param[in,out] ListHead - Linked list has completed CreateDWordField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateDWordField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 ByteIndex,
+ IN CHAR8 *DWordFieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlCreateFixedField (SourceBuffer, ByteIndex, DWordFieldName, AML_CREATE_DWORD_FIELD_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a CreateQWordField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateQWordField ( SourceBuffer, ByteIndex, QWordFieldName )
+
+ DefCreateQWordField := CreateQWordFieldOp SourceBuff ByteIndex NameString
+ CreateQWordFieldOp := 0x8F
+ SourceBuff := TermArg => Buffer
+ ByteIndex := TermArg => Integer
+
+ @param[in] SourceBuffer, - Buffer to insert the new buffer QWord field object
+ @param[in] ByteIndex, - Starting byte index to place the new buffer
+ @param[in] QWordFieldName, - Name of the QWordField
+ @param[in,out] ListHead - Linked list has completed CreateQWordField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateQWordField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 ByteIndex,
+ IN CHAR8 *QWordFieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlCreateFixedField (SourceBuffer, ByteIndex, QWordFieldName, AML_CREATE_QWORD_FIELD_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a CreateWordField AML Object and inserts it into the linked list
+
+ Syntax:
+ CreateWordField ( SourceBuffer, ByteIndex, WordFieldName )
+
+ DefCreateWordField := CreateWordFieldOp SourceBuff ByteIndex NameString
+ CreateWordFieldOp := 0x8B
+ SourceBuff := TermArg => Buffer
+ ByteIndex := TermArg => Integer
+
+ @param[in] SourceBuffer, - Buffer to house the new buffer word field object
+ @param[in] ByteIndex, - Starting byte index to place the new buffer
+ @param[in] WordFieldName, - Name of the WordField
+ @param[in,out] ListHead - Linked list has completed CreateWordField object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPCreateWordField (
+ IN CHAR8 *SourceBuffer,
+ IN UINT64 ByteIndex,
+ IN CHAR8 *WordFieldName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlCreateFixedField (SourceBuffer, ByteIndex, WordFieldName, AML_CREATE_WORD_FIELD_OP, ListHead);
+ return Status;
+}
+
+/**
+ Creates a Method
+
+ Method (MethodName, NumArgs, SerializeRule, SyncLevel, ReturnType,
+ ParameterTypes) {TermList}
+
+ TermList must be created between AmlStart and AmlClose Phase
+
+ Note: ReturnType and ParameterTypes are not used for AML encoding
+ and are therefore not passed in to this function.
+
+ DefMethod := MethodOp PkgLength NameString MethodFlags TermList
+ MethodOp := 0x14
+ MethodFlags := ByteData // bit 0-2: ArgCount (0-7)
+ // bit 3: SerializeFlag
+ // 0 NotSerialized
+ // 1 Serialized
+ // bit 4-7: SyncLevel (0x00-0x0f)
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Method name
+ @param[in] NumArgs - Number of arguments passed in to method
+ @param[in] SerializeRule - Flag indicating whether method is serialized
+ or not
+ @param[in] SyncLevel - synchronization level for the method (0 - 15),
+ use zero for default sync level.
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlMethod (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *Name,
+ IN UINT8 NumArgs,
+ IN METHOD_SERIALIZE_FLAG SerializeRule,
+ IN UINT8 SyncLevel,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINT8 MethodFlags;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) ||
+ (Name == NULL) ||
+ (NumArgs > METHOD_ARGS_MAX) ||
+ (SyncLevel > MAX_SYNC_LEVEL) ||
+ (SerializeRule >= FlagInvalid) ||
+ (ListHead == NULL))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Method for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Add Method Flags
+ Status = InternalAppendNewAmlObject (&Object, "METHOD_FLAGS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start METHOD_FLAGS for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // TermList should be closed already
+ // Add Method Flags
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "METHOD_FLAGS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate METHOD_FLAGS for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a METHOD_FLAGS child data collection.\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Method Flags is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ MethodFlags = NumArgs & 0x07;
+ if (SerializeRule) {
+ MethodFlags |= BIT3;
+ }
+
+ MethodFlags |= (SyncLevel & 0x0F) << 4;
+ Object->Data[0] = MethodFlags;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ // Required NameString completed in one phase call
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ // Method Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, Name));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_METHOD_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
new file mode 100644
index 0000000000000000000000000000000000000000..c1b66f4f84421f61d15e7371bdcbca68d6d7b75c
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -0,0 +1,357 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ Creates a Scope (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefScope := ScopeOp PkgLength NameString TermList
+ ScopeOp := 0x10
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] String - Location
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlScope (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (String == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PkgLength for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Insert NameString for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // TermList should be closed already
+
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Scope Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_SCOPE_OP;
+ CopyMem (&Object->Data[1], ChildObject->Data, ChildObject->DataSize);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Name (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := NameOp NameString ChildObjectData
+ NameOp := 0x08
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] String - Object name
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlName (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *String,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (String == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NameString for %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ // DataRefObject should be closed already
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Object->Data = AllocatePool (ChildObject->DataSize + 1);
+ // Name Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, String));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_NAME_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates an Alias (SourceObject, AliasObject)
+
+ DefAlias := AliasOp NameString NameString
+ AliasOp := 0x06
+
+ @param[in] SourceName - Any named Source Object NameString
+ @param[in] AliasName - Alias Object NameString
+ @param[in,out] ListHead - Linked list has completed the Alias Object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPAlias (
+ IN CHAR8 *SourceName,
+ IN CHAR8 *AliasName,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((SourceName == NULL) || (AliasName == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ // Start ALIAS object
+ Status = InternalAppendNewAmlObject (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot append ALIAS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Insert required Object (to be aliased) NameString
+ Status = AmlOPNameString (SourceName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create NameString: %a \n", __FUNCTION__, SourceName));
+ goto Done;
+ }
+
+ // Insert required Alias NameString
+ Status = AmlOPNameString (AliasName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create NameString: %a \n", __FUNCTION__, AliasName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, SourceName));
+ goto Done;
+ }
+
+ Object->Data = AllocateZeroPool (ChildObject->DataSize + 1);
+ // Alias Op is one byte
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, SourceName));
+ goto Done;
+ }
+
+ Object->Data[0] = AML_ALIAS_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
new file mode 100644
index 0000000000000000000000000000000000000000..f97f1741cf1ea914111001913da0ade4bd034b76
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -0,0 +1,141 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ DEBUG print a (VOID *)buffer in an array of HEX bytes
+
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 0000 54 48 49 53 20 49 53 20 41 20 53 41 4D 50 4C 45 THIS IS A SAMPLE
+ 0010 5F 42 55 46 46 45 52 01 02 5E 5C 30 31 _BUFFER..^\01
+
+ @param[in] Buffer - Buffer containing buffer
+ @param[in] BufferSize - Number of bytes to print
+
+ @retval EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintBuffer (
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ )
+{
+ UINTN Column;
+ UINTN Index;
+ UINTN NumberOfColumns;
+ UINT8 *Data;
+
+ Data = Buffer;
+ NumberOfColumns = 16;
+ // Header
+ DEBUG ((DEBUG_VERBOSE, " 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n"));
+ for (Index = 0; Index < BufferSize;) {
+ // Row Counter
+ DEBUG ((DEBUG_VERBOSE, "%4X ", Index));
+
+ // Hex ouput
+ for (Column = 0; Column < NumberOfColumns; Column++) {
+ if (Index + Column < BufferSize) {
+ DEBUG ((DEBUG_VERBOSE, " %02X", Data[Index + Column]));
+ } else {
+ DEBUG ((DEBUG_VERBOSE, " "));
+ }
+ }
+
+ DEBUG ((DEBUG_VERBOSE, " "));
+ // Ascii ouput
+ for (Column = 0; Column < NumberOfColumns; Column++) {
+ if (Index + Column < BufferSize) {
+ // Only print ACPI acceptable characters
+ if (((Data[Index + Column] >= 0x30) && // '0' - '9'
+ (Data[Index + Column] <= 0x39)) ||
+ ((Data[Index + Column] >= 0x41) && // 'A' - 'Z'
+ (Data[Index + Column] <= 0x5A)) ||
+ (Data[Index + Column] == 0x5C) || // '\'
+ (Data[Index + Column] == 0x5F) || // '_'
+ (Data[Index + Column] == 0x5E) // '^'
+ )
+ {
+ DEBUG ((DEBUG_VERBOSE, "%c", Data[Index + Column]));
+ } else {
+ DEBUG ((DEBUG_VERBOSE, "."));
+ }
+ }
+ }
+
+ Index += NumberOfColumns;
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ DEBUG print an AML Object including an array of HEX bytes for the data
+
+ 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+ 0000 54 48 49 53 20 49 53 20 41 20 53 41 4D 50 4C 45 THIS IS A SAMPLE
+ 0010 5F 42 55 46 46 45 52 01 02 5E 5C 30 31 _BUFFER..^\01
+ Completed=(TRUE|FALSE)
+
+ @param[in] Object - AML_OBJECT_INSTANCE
+
+ @retval EFI_SUCCESS, EFI_INVALID_PARAMETER
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintObject (
+ IN AML_OBJECT_INSTANCE *Object
+ )
+{
+ if ((Object == NULL) || (Object->Signature != AML_OBJECT_INSTANCE_SIGNATURE)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "Object=0x%X, Size=0x%d\n",
+ (UINTN)Object,
+ Object->DataSize
+ ));
+ AmlDebugPrintBuffer (Object->Data, Object->DataSize);
+ DEBUG ((DEBUG_VERBOSE, "Completed=%a\n", Object->Completed ? "TRUE" : "FALSE"));
+ DEBUG ((DEBUG_VERBOSE, "\n"));
+ return EFI_SUCCESS;
+}
+
+/**
+ DEBUG print a linked list of AML buffer Objects in an array of HEX bytes
+
+ @param[in] ListHead - Head of AML_OBJECT_INSTANCE Linked List
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintLinkedObjects (
+ IN LIST_ENTRY *ListHead
+ )
+{
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ListHead == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ DEBUG ((DEBUG_VERBOSE, "Printing AML_OBJECT_INSTANCE Linked List\n"));
+ Node = GetNextNode (ListHead, ListHead);
+ while (Node != ListHead) {
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ AmlDebugPrintObject (Object);
+ Node = GetNextNode (ListHead, Node);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
new file mode 100644
index 0000000000000000000000000000000000000000..85efd9a835d1d3bd6e8654812d3b4cc6e9622623
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -0,0 +1,264 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+#define MAX_ONE_BYTE_PKG_LENGTH 63
+#define ONE_BYTE_PKG_LENGTH_ENCODING 0x00
+#define ONE_BYTE_NIBBLE_MASK 0x3F
+
+#define MAX_TWO_BYTE_PKG_LENGTH 4095
+#define TWO_BYTE_PKG_LENGTH_ENCODING 0x40
+#define PKG_LENGTH_NIBBLE_MASK 0x0F
+
+#define MAX_THREE_BYTE_PKG_LENGTH 1048575
+#define THREE_BYTE_PKG_LENGTH_ENCODING 0x80
+
+#define MAX_FOUR_BYTE_PKG_LENGTH 268435455
+#define FOUR_BYTE_PKG_LENGTH_ENCODING 0xC0
+
+/**
+ Creates a Package Length encoding and places it in the return buffer,
+ PkgLengthEncoding. Similar to AmlPkgLength but the PkgLength does not
+ include the length of its own encoding.
+
+ @param[in] DataSize - The size of data to be encoded as a pkglength
+ @param[out] PkgLengthEncoding - Return buffer containing the AML encoding
+ @param[out] ReturnDataLength - Size of the return buffer
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+ **/
+EFI_STATUS
+EFIAPI
+InternalAmlBitPkgLength (
+ IN UINT32 DataSize,
+ OUT UINT8 **PkgLengthEncoding,
+ OUT UINTN *ReturnDataLength
+ )
+{
+ UINTN DataLength;
+ UINT8 PkgLeadByte;
+ UINTN PkgLengthRemainder;
+ EFI_STATUS Status;
+
+ Status = EFI_INVALID_PARAMETER;
+ DataLength = 0;
+ // Calculate Length of PkgLength Data and fill out least
+ // significant nibble
+ if ((DataSize + 1) <= MAX_ONE_BYTE_PKG_LENGTH) {
+ DataLength = 1;
+ PkgLeadByte = ONE_BYTE_PKG_LENGTH_ENCODING;
+ PkgLeadByte |= ((DataSize) & ONE_BYTE_NIBBLE_MASK);
+ } else {
+ if ((DataSize + 2) <= MAX_TWO_BYTE_PKG_LENGTH) {
+ DataLength = 2;
+ PkgLeadByte = TWO_BYTE_PKG_LENGTH_ENCODING;
+ } else if ((DataSize + 3) <= MAX_THREE_BYTE_PKG_LENGTH) {
+ DataLength = 3;
+ PkgLeadByte = THREE_BYTE_PKG_LENGTH_ENCODING;
+ } else if ((DataSize + 4) <= MAX_FOUR_BYTE_PKG_LENGTH) {
+ DataLength = 4;
+ PkgLeadByte = FOUR_BYTE_PKG_LENGTH_ENCODING;
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: PkgLength data size > 0x%X\n",
+ __FUNCTION__,
+ MAX_FOUR_BYTE_PKG_LENGTH - 4
+ ));
+ goto Done;
+ }
+
+ PkgLeadByte |= ((DataSize) & PKG_LENGTH_NIBBLE_MASK);
+ }
+
+ // Allocate new data buffer
+ // DataSize = DataLength + DataSize;
+ *PkgLengthEncoding = AllocatePool (DataLength);
+ if (*PkgLengthEncoding == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocation failed Object=PkgLength\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Populate PkgLeadByte
+ *PkgLengthEncoding[0] = PkgLeadByte;
+
+ // Populate remainder of PkgLength bytes
+ PkgLengthRemainder = (DataSize) >> 4;
+ if (PkgLengthRemainder != 0) {
+ CopyMem (&PkgLengthEncoding[0][1], &PkgLengthRemainder, DataLength - 1);
+ }
+
+ *ReturnDataLength = DataLength;
+
+Done:
+ return Status;
+}
+
+/**
+ Creates a Package Length AML Object and inserts it into the linked list
+
+ PkgLength := PkgLeadByte |
+ |
+ |
+
+
+ PkgLeadByte :=
+
+
+
+ Note: The high 2 bits of the first byte reveal how many follow bytes are in
+ the PkgLength. If the PkgLength has only one byte, bit 0 through 5 are used
+ to encode the package length (in other words, values 0-63). If the package
+ length value is more than 63, more than one byte must be used for the encoding
+ in which case bit 4 and 5 of the PkgLeadByte are reserved and must be zero.
+
+ If the multiple bytes encoding is used, bits 0-3 of the PkgLeadByte become
+ the least significant 4 bits of the resulting package length value. The next
+ ByteData will become the next least significant 8 bits of the resulting value
+ and so on, up to 3 ByteData bytes. Thus, the maximum package length is 2**28.
+
+ @param[in] Phase - Example: AmlStart, AmlClose
+ @param[in,out] ListHead - Head of Linked List of all AML Objects
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+ **/
+EFI_STATUS
+EFIAPI
+AmlPkgLength (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+ UINTN DataLength;
+ UINT8 PkgLeadByte;
+ UINTN PkgLengthRemainder;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Length object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, "Length"));
+ goto Done;
+ }
+
+ DataLength = 0;
+ // Calculate Length of PkgLength Data and fill out least
+ // significant nibble
+ if ((ChildObject->DataSize + 1) <= MAX_ONE_BYTE_PKG_LENGTH) {
+ DataLength = 1;
+ PkgLeadByte = ONE_BYTE_PKG_LENGTH_ENCODING;
+ PkgLeadByte |= ((ChildObject->DataSize + DataLength) & ONE_BYTE_NIBBLE_MASK);
+ } else {
+ if ((ChildObject->DataSize + 2) <= MAX_TWO_BYTE_PKG_LENGTH) {
+ DataLength = 2;
+ PkgLeadByte = TWO_BYTE_PKG_LENGTH_ENCODING;
+ } else if ((ChildObject->DataSize + 3) <= MAX_THREE_BYTE_PKG_LENGTH) {
+ DataLength = 3;
+ PkgLeadByte = THREE_BYTE_PKG_LENGTH_ENCODING;
+ } else if ((ChildObject->DataSize + 4) <= MAX_FOUR_BYTE_PKG_LENGTH) {
+ DataLength = 4;
+ PkgLeadByte = FOUR_BYTE_PKG_LENGTH_ENCODING;
+ } else {
+ Status = EFI_DEVICE_ERROR;
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: PkgLength data size > 0x%X\n",
+ __FUNCTION__,
+ MAX_FOUR_BYTE_PKG_LENGTH - 4
+ ));
+ goto Done;
+ }
+
+ PkgLeadByte |= ((ChildObject->DataSize + DataLength) & PKG_LENGTH_NIBBLE_MASK);
+ }
+
+ // Allocate new data buffer
+ Object->DataSize = DataLength + ChildObject->DataSize;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocation failed Object=PkgLength\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Populate PkgLeadByte
+ Object->Data[0] = PkgLeadByte;
+
+ // Populate remainder of PkgLength bytes
+ PkgLengthRemainder = (ChildObject->DataSize + DataLength) >> 4;
+ if (PkgLengthRemainder != 0) {
+ CopyMem (&Object->Data[1], &PkgLengthRemainder, DataLength - 1);
+ }
+
+ CopyMem (
+ &Object->Data[DataLength],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
new file mode 100644
index 0000000000000000000000000000000000000000..d2b326e846908d2533a9da759bc5faf6da1c36ab
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -0,0 +1,1986 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ ResourceTemplate (Resource To Buffer Conversion Macro)
+
+ Syntax:
+ ResourceTemplate () {ResourceMacroList} => Buffer
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed ResourceTemplate Object
+ after AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlResourceTemplate (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+ EFI_ACPI_END_TAG_DESCRIPTOR *EndTag;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = AmlBuffer (AmlStart, 0, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "ResourceTemplate"));
+ goto Done;
+ }
+
+ // Start EndTag object to be completed in Close
+ // ACPI 6.3: 6.4.2.9 End Tag: ...The End Tag is automatically generated by
+ // the ASL compiler at the end of the ResourceTemplate statement.
+ Status = InternalAppendNewAmlObject (&Object, "END_TAG", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "END_TAG"));
+ goto Done;
+ }
+
+ // ResourceMacroList is too complicated and must be added outside
+ break;
+ case AmlClose:
+ // ResourceMacroList should be closed already
+
+ // Locate and complete End Tag
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "END_TAG", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __FUNCTION__, "END_TAG"));
+ goto Done;
+ }
+
+ // Release Object->Data Identifier
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Object->DataSize = ChildObject->DataSize + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: EndTag Alloc Failed\n", __FUNCTION__));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ // ChildObject Data goes before End Tag
+ if ((ChildObject->Data != NULL) && (ChildObject->DataSize > 0)) {
+ CopyMem (Object->Data, ChildObject->Data, ChildObject->DataSize);
+ }
+
+ EndTag = (EFI_ACPI_END_TAG_DESCRIPTOR *)&Object->Data[ChildObject->DataSize];
+ EndTag->Desc = ACPI_END_TAG_DESCRIPTOR;
+ // Spec says the byte is a checksum, but I have never seen a value other
+ // than zero in the field compiled from ASL.
+ // EndTag->Checksum already = 0;
+
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+
+ Status = AmlBuffer (AmlClose, 0, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Close %a object\n", __FUNCTION__, "ResourceTemplate"));
+ goto Done;
+ }
+
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ InternalAmlAddressSpaceCheck
+
+ Checks Address space parameters for Word, DWord, or QWord size Address space
+ Descriptor. Size will be constrained by the Resource Descriptor input
+ parameters being of the correct size.
+
+ @param[in] IsMinFixed
+ @param[in] IsMaxFixed
+ @param[in] AddressGranularity
+ @param[in] AddressMinimum
+ @param[in] AddressMaximum
+ @param[in] RangeLength
+
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlAddressSpaceCheck (
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT64 AddressGranularity,
+ IN UINT64 AddressMinimum,
+ IN UINT64 AddressMaximum,
+ IN UINT64 RangeLength
+ )
+{
+ // Max must be greater than Min
+ if (AddressMaximum < AddressMinimum) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMinimum greater than AddressMaximum\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Address Granularity must be (2^n)-1
+ if (((AddressGranularity + 1) & AddressGranularity) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressGranularity must be (a power of 2)-1\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (RangeLength == 0) {
+ // LEN _MIF _MAF Definition
+ // 0 0 0
+ // 0 0 1
+ // 0 1 0
+ // Variable size, variable location resource descriptor for _PRS.
+ // If _MIF is set, _MIN must be a multiple of (_GRA+1). If _MAF
+ // is set, _MAX must be (a multiple of (_GRA+1))-1.
+ // OS can pick the resource range that satisfies following conditions:
+ // If _MIF is not set, start address is a multiple of (_GRA+1)
+ // and greater or equal to _MIN. Otherwise, start address is _MIN.
+ // If _MAF is not set, end address is (a multiple of (_GRA+1))-1
+ // and less or equal to _MAX. Otherwise, end address is _MAX.
+ // 0 1 1 (Invalid combination)
+ if ((IsMinFixed == EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) &&
+ (IsMaxFixed == EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED))
+ {
+ // 0 1 1 (Invalid combination)
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: IsMinFixed and IsMaxFixed cannot both be set\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n", __FUNCTION__, RangeLength));
+ return EFI_INVALID_PARAMETER;
+ } else if (IsMaxFixed == EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED) {
+ // 0 0 1
+ if ((AddressMaximum & AddressGranularity) != AddressGranularity) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMaximum=0x%lX + 1) is not a multiple of\n", __FUNCTION__, AddressMaximum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __FUNCTION__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressMaximum == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else if (IsMinFixed == EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) {
+ // 0 1 0
+ if ((AddressMinimum & AddressGranularity) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMinimum=0x%lX is not a multiple of\n", __FUNCTION__, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __FUNCTION__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else if ((IsMinFixed == EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED) &&
+ (IsMaxFixed == EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED) &&
+ (AddressMinimum == 0) &&
+ (AddressMaximum == 0) &&
+ (AddressGranularity == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Maximum, Minimum, Granularity all 0\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ // LEN _MIF _MAF Definition
+ // >0 0 0 Fixed size, variable location resource descriptor for _PRS.
+ // _LEN must be a multiple of (_GRA+1).
+ // OS can pick the resource range that satisfies following conditions:
+ // Start address is a multiple of (_GRA+1) and greater or equal to _MIN.
+ // End address is (start address+_LEN-1) and less or equal to _MAX.
+ // >0 0 1 (Invalid combination)
+ // >0 1 0 (Invalid combination)
+ // >0 1 1 Fixed size, fixed location resource descriptor.
+ // _GRA must be 0 and _LEN must be (_MAX - _MIN +1).
+ if ((IsMinFixed == EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED) &&
+ (IsMaxFixed == EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED))
+ {
+ // >0 0 0
+ if ((RangeLength & AddressGranularity) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=0x%lX is not a multiple of\n", __FUNCTION__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __FUNCTION__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed = 0\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ } else if (RangeLength > (AddressMaximum - AddressMinimum + 1)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=0x%lX > (AddrRangeMax=0x%lX - AddrRangeMin=0x%lX + 1)\n", __FUNCTION__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n", __FUNCTION__, RangeLength));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else if ((IsMinFixed == EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) &&
+ (IsMaxFixed == EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED))
+ {
+ // >0 1 1
+ if (AddressGranularity != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressGranularity=0x%lX != 0\n", __FUNCTION__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0, IsMinFixed = 1, and IsMaxFixed = 1\n", __FUNCTION__, RangeLength));
+ return EFI_INVALID_PARAMETER;
+ } else if (RangeLength != (AddressMaximum - AddressMinimum + 1)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=0x%lX != (AddrRangeMax=0x%lX - AddrRangeMin=0x%lX + 1)\n", __FUNCTION__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n", __FUNCTION__, RangeLength));
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ // >0 0 1 (Invalid combination)
+ // >0 1 0 (Invalid combination)
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: When RangeLength=0x%lX > 0,\n", __FUNCTION__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both be either 1 or 0\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/*
+ Internal function to create DWord Address Space Descriptors
+
+ This function only requires a single call and therefore no Phases
+ Generates:
+ 6.4.3.5.2 DWord Address Space Descriptor
+ Type 1, Large Item Value 0x7
+ The DWORD address space descriptor is used to report resource usage in a
+ 32-bit address space (like memory and I/O).
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed DWordSpace buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlOPDWordAddressSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT32 AddressGranularity,
+ IN UINT32 AddressMinimum,
+ IN UINT32 AddressMaximum,
+ IN UINT32 AddressTranslation,
+ IN UINT32 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+
+ // Vaidate General Flags Input
+ if ((ResourceUsage & ~EFI_ACPI_GENERAL_FLAG_MASK_USAGE) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid ResourceUsage Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlAddressSpaceCheck (
+ IsMinFixed,
+ IsMaxFixed,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ RangeLength
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: DWord Address Space Check FAILED\n", __FUNCTION__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "DWORD_ADDRESS"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "DWORD_ADDRESS"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Header.Byte = ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR;
+ Descriptor->Header.Length = sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR) -
+ sizeof (ACPI_LARGE_RESOURCE_HEADER);
+ Descriptor->ResType = ResourceType;
+ Descriptor->GenFlag = IsMinFixed | IsMaxFixed | Decode;
+ Descriptor->SpecificFlag = TypeSpecificFlags;
+ Descriptor->AddrSpaceGranularity = AddressGranularity;
+ Descriptor->AddrRangeMin = AddressMinimum;
+ Descriptor->AddrRangeMax = AddressMaximum;
+ Descriptor->AddrTranslationOffset = AddressTranslation;
+ Descriptor->AddrLen = RangeLength;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.32 DMA (DMA Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ DMA (DmaType, IsBusMaster, DmaTransferSize, DescriptorName) {DmaChannelList} => Buffer (BitMask)
+
+ Generates: 6.4.2.2 DMA Descriptor
+
+ @param[in] DmaType - DMA channel speed supported
+ @param[in] IsBusMaster - Logical device bus master status
+ @param[in] DmaTransferSize - DMA transfer type preference (8-bit, 16-bit, both)
+ @param[in] DmaChannelList - DMA channel mask bits [7:0] (channels 0 - 7), _DMA
+ Bit [0] is channel 0, etc.
+ // DescriptorName - Optional - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed DWordIO buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDma (
+ IN EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS DmaType,
+ IN EFI_ACPI_DMA_BUS_MASTER_KEYWORDS IsBusMaster,
+ IN EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS DmaTransferSize,
+ IN UINT8 DmaChannelList,
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_DMA_DESCRIPTOR *Descriptor;
+
+ if ((DmaType & (UINT8) ~EFI_ACPI_DMA_SPEED_TYPE_MASK) != 0) {
+ // Invalid DmaType value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: DmaType '%x' is not valid.\n", __FUNCTION__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsBusMaster & ~EFI_ACPI_DMA_BUS_MASTER_MASK) != 0) {
+ // Invalid IsBusMaster value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: IsBusMaster '%x' is not valid.\n", __FUNCTION__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (((DmaTransferSize & ~EFI_ACPI_DMA_TRANSFER_TYPE_MASK) != 0) ||
+ (DmaTransferSize == 0x3))
+ {
+ // Invalid DmaTransferSize value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: DmaTransferSize '%x' is not valid.\n", __FUNCTION__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __FUNCTION__, "DMA_RESOURCE"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_DMA_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "DMA_RESOURCE"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_DMA_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Byte = ACPI_DMA_DESCRIPTOR;
+ Descriptor->ChannelMask = DmaChannelList;
+ //
+ // Descriptor->Information bit mask:
+ // Bit [7] Reserved (must be 0)
+ // Bits [6:5] DMA channel speed supported, _TYP
+ // 00 Indicates compatibility mode
+ // 01 Indicates Type A DMA as described in the EISA
+ // 10 Indicates Type B DMA
+ // 11 Indicates Type F
+ // Bits [4:3] Ignored
+ // Bit [2] Logical device bus master status, _BM
+ // 0 Logical device is not a bus master
+ // 1 Logical device is a bus master
+ // Bits [1:0] DMA transfer type preference, _SIZ
+ // 00 8-bit only
+ // 01 8- and 16-bit
+ // 10 16-bit only
+ Descriptor->Information = (UINT8)(DmaType +
+ IsBusMaster +
+ DmaTransferSize);
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.35 DWordSpace (DWord Space Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ DWordSpace (ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed,
+ TypeSpecificFlags, AddressGranularity, AddressMinimum,
+ AddressMaximum, AddressTranslation, RangeLength,
+ ResourceSourceIndex, ResourceSource, DescriptorName)
+
+ Generates:
+ 6.4.3.5.2 DWord Address Space Descriptor
+ Type 1, Large Item Value 0x7
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed DWordSpace buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDWordSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT32 AddressGranularity,
+ IN UINT32 AddressMinimum,
+ IN UINT32 AddressMaximum,
+ IN UINT32 AddressTranslation,
+ IN UINT32 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // UINT8 ResourceType cannot be > 0xFF, so no need to check top end.
+ if (ResourceType < EFI_ACPI_SPACE_RESOURCE_TYPE_MIN) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ResourceType\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPDWordAddressSpace (
+ ResourceType,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ TypeSpecificFlags,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.33 DWordIO (DWord IO Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ DWordIO (ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges,
+ AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName, TranslationType,
+ TranslationDensity)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Decode,
+ @param[in] ISARanges,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ TranslationType - NOT IMPLEMENTED
+ TranslationDensity - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed DWordIO buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDWordIO (
+ IN UINT8 ResourceUsage,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Decode,
+ IN UINT8 ISARanges,
+ IN UINT32 AddressGranularity,
+ IN UINT32 AddressMinimum,
+ IN UINT32 AddressMaximum,
+ IN UINT32 AddressTranslation,
+ IN UINT32 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ // TranslationType - NOT IMPLEMENTED
+ // TranslationDensity - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ if (ISARanges == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges = 0 = Reserved\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPDWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_IO,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ (ISARanges),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.34 DWordMemory (DWord Memory Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ DWordMemory (ResourceUsage, Decode, IsMinFixed, IsMaxFixed, Cacheable,
+ ReadAndWrite, AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName, MemoryRangeType, TranslationType)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Cacheable,
+ @param[in] ReadAndWrite,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ MemoryRangeType - NOT IMPLEMENTED
+ TranslationType - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed DWordMemory buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPDWordMemory (
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Cacheable,
+ IN UINT8 ReadAndWrite,
+ IN UINT32 AddressGranularity,
+ IN UINT32 AddressMinimum,
+ IN UINT32 AddressMaximum,
+ IN UINT32 AddressTranslation,
+ IN UINT32 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ // MemoryRangeType - NOT IMPLEMENTED
+ // TranslationType - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // Validate Type Specific Parameters
+ if ((Cacheable & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid Cacheable Parameter 0x%X\n", __FUNCTION__, (Cacheable & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM)));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((ReadAndWrite & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ReadAndWrite Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPDWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_MEM,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ (Cacheable | ReadAndWrite),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/*
+ Internal function to create QWord Address Space Descriptors
+
+ This function only requires a single call and therefore no Phases
+ Generates:
+ 6.4.3.5.1 QWord Address Space Descriptor
+ Type 1, Large Item Value 0xA
+ The QWORD address space descriptor is used to report resource usage in a
+ 64-bit address space (like memory and I/O).
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed QWordSpace buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlOPQWordAddressSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT64 AddressGranularity,
+ IN UINT64 AddressMinimum,
+ IN UINT64 AddressMaximum,
+ IN UINT64 AddressTranslation,
+ IN UINT64 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+
+ // Vaidate General Flags Input
+ if ((ResourceUsage & ~EFI_ACPI_GENERAL_FLAG_MASK_USAGE) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid ResourceUsage Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlAddressSpaceCheck (
+ IsMinFixed,
+ IsMaxFixed,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ RangeLength
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: QWord Address Space Check FAILED\n", __FUNCTION__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "QWORD_ADDRESS"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "QWORD_ADDRESS"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Header.Byte = ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR;
+ Descriptor->Header.Length = sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) -
+ sizeof (ACPI_LARGE_RESOURCE_HEADER);
+ Descriptor->ResType = ResourceType;
+ Descriptor->GenFlag = IsMinFixed | IsMaxFixed | Decode;
+ Descriptor->SpecificFlag = TypeSpecificFlags;
+ Descriptor->AddrSpaceGranularity = AddressGranularity;
+ Descriptor->AddrRangeMin = AddressMinimum;
+ Descriptor->AddrRangeMax = AddressMaximum;
+ Descriptor->AddrTranslationOffset = AddressTranslation;
+ Descriptor->AddrLen = RangeLength;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.65 IRQ (Interrupt Resource Descriptor Macro)
+
+ Syntax:
+ IRQ (EdgeLevel, ActiveLevel, Shared, DescriptorName) {InterruptList} => Buffer
+
+ Arguments:
+ EdgeLevel:
+ Describes whether the interrupt is edge triggered (Edge) or level triggered
+ (Level). The field DescriptorName. _HE is automatically created to refer to
+ this portion of the resource descriptor, where '1' is Edge and ActiveHigh
+ and '0' is Level and ActiveLow.
+
+ ActiveLevel:
+ Describes whether the interrupt is active-high (ActiveHigh) or active-low
+ (ActiveLow). The field DescriptorName. _LL is automatically created to refer
+ to this portion of the resource descriptor, where '1' is Edge and ActiveHigh
+ and '0' is Level and ActiveLow.
+
+ Shared:
+ Describes whether the interrupt can be shared with other devices (Shared) or
+ not (Exclusive), and whether it is capable of waking the system from a
+ low-power idle or system sleep state (SharedAndWake or ExclusiveAndWake).
+ The field DescriptorName. _SHR is automatically created to refer to this portion
+ of the resource descriptor, where '1' is Shared and '0' is Exclusive. If nothing
+ is specified, then Exclusive is assumed.
+
+ InterruptList:
+ IRQ mask bits [15:0]
+ Bit[0] represents IRQ0, bit[1] is IRQ1, etc.
+
+ DescriptorName:
+ Is an optional argument that specifies a name for an integer constant that
+ will be created in the current scope that contains the offset of this resource
+ descriptor within the current resource template buffer. The predefined
+ descriptor field names may be appended to this name to access individual
+ fields within the descriptor via the Buffer Field operators.
+
+ Description:
+ The IRQ macro evaluates to a buffer that contains an IRQ resource descriptor.
+ The format of the IRQ descriptor can be found in "IRQ Descriptor". The macro
+ produces the three-byte form of the descriptor. The macro is designed to be
+ used inside of a ResourceTemplate.
+
+ Generates: 6.4.2.1 IRQ Descriptor
+
+ @param[in] EdgeLevel - trigger level supported
+ @param[in] ActiveLevel - interrupt polarity
+ @param[in] Shared - interrupt exclusivity
+ @param[in] InterruptList - IRQ mask bits[7:0], _INT
+ Bit [0] represents IRQ0,
+ bit[1] is IRQ1, and so on.
+ IRQ mask bits[15:8], _INT
+ Bit [0] represents IRQ8,
+ bit[1] is IRQ9, and so on.
+ // DescriptorName - Optional - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed IRQ buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+
+**/
+EFI_STATUS
+EFIAPI
+AmlOPIRQ (
+ IN EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS EdgeLevel,
+ IN EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS ActiveLevel,
+ IN EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS Shared,
+ IN UINT16 InterruptList,
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_IRQ_DESCRIPTOR *Descriptor;
+
+ if ((EdgeLevel & (UINT8) ~EFI_ACPI_IRQ_MODE_MASK) != 0) {
+ // Invalid Decode value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: EdgeLevel '%x' is not valid.\n", __FUNCTION__, EdgeLevel));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((ActiveLevel & (UINT8) ~EFI_ACPI_IRQ_POLARITY_MASK) != 0) {
+ // Invalid Decode value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ActiveLevel '%x' is not valid.\n", __FUNCTION__, ActiveLevel));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Shared & (UINT8) ~(EFI_ACPI_IRQ_WAKE_CAPABLE_MASK | EFI_ACPI_IRQ_SHARABLE_MASK)) != 0) {
+ // Invalid Decode value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Shared '%x' is not valid.\n", __FUNCTION__, Shared));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __FUNCTION__, "IRQ_RESOURCE"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_IRQ_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Alloc for %a failed\n", __FUNCTION__, "IRQ_RESOURCE"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_IRQ_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Byte = ACPI_IRQ_DESCRIPTOR;
+ Descriptor->Mask = InterruptList;
+ //
+ // Ref 6.4.2.1 IRQ Descriptor - IRQ Information
+ // Descriptor->Information bit mask:
+ // IRQ Information. Each bit, when set, indicates this device is capable of
+ // driving a certain type of interrupt. (Optional-if not included then assume
+ // edge sensitive, high true interrupts.) These bits can be used both for
+ // reporting and setting IRQ resources.
+ // Note: This descriptor is meant for describing interrupts that are connected
+ // to PIC-compatible interrupt controllers, which can only be programmed
+ // for Active-High-Edge-Triggered or Active-Low-LevelTriggered interrupts.
+ // Any other combination is invalid. The Extended Interrupt Descriptor can
+ // be used to describe other combinations.
+ //
+ // Bit [7:6] Reserved (must be 0)
+ // Bit [5] Wake Capability, _WKC
+ // 0x0 = Not Wake Capable: This interrupt is not capable of waking the system.
+ // 0x1 = Wake Capable: This interrupt is capable of waking the system from a
+ // low-power idle state or a system sleep state.
+ // Bit [4] Interrupt Sharing, _SHR
+ // 0x0 = Exclusive: This interrupt is not shared with other devices.
+ // 0x1 = Shared: This interrupt is shared with other devices.
+ // Bit [3] Interrupt Polarity, _LL
+ // 0 Active-High - This interrupt is sampled when the signal is high, or true
+ // 1 Active-Low - This interrupt is sampled when the signal is low, or false.
+ // Bit [2:1] Ignored
+ // Bit [0] Interrupt Mode, _HE
+ // 0 Level-Triggered - Interrupt is triggered in response to signal in a low state.
+ // 1 Edge-Triggered - Interrupt is triggered in response to a change in signal state from
+ // low to high.
+ //
+ Descriptor->Information = (UINT8)((EFI_ACPI_IRQ_WAKE_CAPABLE_MASK |
+ EFI_ACPI_IRQ_SHARABLE_MASK |
+ EFI_ACPI_IRQ_POLARITY_MASK |
+ EFI_ACPI_IRQ_MODE_MASK) &
+ (Shared |
+ ActiveLevel |
+ EdgeLevel));
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.64 IO (IO Resource Descriptor Macro)
+
+ Syntax:
+ IO (Decode, AddressMin, AddressMax, AddressAlignment, RangeLength, DescriptorName) => Buffer
+
+ Arguments:
+ Decode:
+ Describes whether the I/O range uses 10-bit decode (Decode10) or 16-bit
+ decode (Decode16). The field DescriptorName. _DEC is automatically created
+ to refer to this portion of the resource descriptor, where '1' is Decode16
+ and '0' is Decode10.
+
+ AddressMin:
+ Evaluates to a 16-bit integer that specifies the minimum acceptable starting
+ address for the I/O range. It must be an even multiple of AddressAlignment.
+ The field DescriptorName._MIN is automatically created to refer to this
+ portion of the resource descriptor.
+
+ AddressMax:
+ Evaluates to a 16-bit integer that specifies the maximum acceptable starting
+ address for the I/O range. It must be an even multiple of AddressAlignment.
+ The field DescriptorName._MAX is automatically created to refer to this
+ portion of the resource descriptor.
+
+ AddressAlignment:
+ Evaluates to an 8-bit integer that specifies the alignment granularity
+ for the I/O address assigned. The field DescriptorName. _ALN is automatically
+ created to refer to this portion of the resource descriptor.
+
+ RangeLength:
+ Evaluates to an 8-bit integer that specifies the number of bytes in the
+ I/O range. The field DescriptorName. _LEN is automatically created to refer
+ to this portion of the resource descriptor.
+
+ DescriptorName:
+ An optional argument that specifies a name for an integer constant that
+ will be created in the current scope that contains the offset of this
+ resource descriptor within the current resource template buffer. The
+ predefined descriptor field names may be appended to this name to access
+ individual fields within the descriptor via the Buffer Field operators.
+
+ Description:
+ The IO macro evaluates to a buffer which contains an IO resource descriptor.
+ The format of the IO descriptor can be found in the ACPI Specification section
+ "I/O Port Descriptor". The macro is designed to be used inside of a ResourceTemplate.
+
+ Generates:
+ 6.4.2.5 I/O Port Descriptor
+ Type 0, Small Item Name 0x8, Length = 7
+
+ @param[in] Decode,
+ @param[in] AddressMin,
+ @param[in] AddressMax,
+ @param[in] AddressAlignment,
+ @param[in] RangeLength,
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed IO buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPIO (
+ IN EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION Decode,
+ IN UINT16 AddressMin,
+ IN UINT16 AddressMax,
+ IN UINT8 AddressAlignment,
+ IN UINT8 RangeLength,
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_IO_PORT_DESCRIPTOR *Descriptor;
+ UINT64 Remainder;
+
+ if ((Decode & (UINT8) ~EFI_ACPI_IO_DECODE_MASK) != 0) {
+ // Invalid Decode value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Decode '%x' is not valid.\n", __FUNCTION__, Decode));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressAlignment != 0) {
+ DivU64x64Remainder (AddressMin, AddressAlignment, &Remainder);
+ if (Remainder != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMin=0x%X) is not a multiple of\n", __FUNCTION__, AddressMin));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __FUNCTION__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ DivU64x64Remainder (AddressMax, AddressAlignment, &Remainder);
+ if (Remainder != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMax=0x%X) is not a multiple of\n", __FUNCTION__, AddressMax));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __FUNCTION__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __FUNCTION__, "IO_RESOURCE"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_IO_PORT_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "IO_RESOURCE"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_IO_PORT_DESCRIPTOR *)Object->Data;
+
+ /*
+ * According to ACPI spec for
+ * ACPI_IO_PORT_DESCRIPTOR = 0x47 contains the informaion about
+ * Name, Type and Length, hence no need to calculate the length.
+ * Below is description from ACPI spec
+ * Byte 0 I/O Port Descriptor Value = 0x47 (01000111B) - Type = 0, Small item name =
+ * 0x8, Length = 7
+ */
+ Descriptor->Header.Byte = ACPI_IO_PORT_DESCRIPTOR;
+ //
+ // Descriptor->Information bit mask:
+ // Bit [7:1] Reserved, must be 0
+ // Bit [0] (_DEC)
+ // 1 The logical device decodes 16-bit addresses
+ // 0 The logical device decodes 10-bit addresses
+ Descriptor->Information = (UINT8)(EFI_ACPI_IO_DECODE_MASK & Decode);
+ Descriptor->BaseAddressMin = AddressMin;
+ Descriptor->BaseAddressMax = AddressMax;
+ Descriptor->Alignment = AddressAlignment;
+ Descriptor->Length = RangeLength;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/*
+ 19.6.114 Register (Generic Register Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ Register (AddressSpaceKeyword, RegisterBitWidth, RegisterBitOffset,
+ RegisterAddress, AccessSize, DescriptorName)
+
+ Generates:
+ 6.4.3.7 Generic Register Descriptor
+ Type 1, Large Item Value 0x2
+ The generic register descriptor describes the location of a fixed width
+ register within any of the ACPI-defined address spaces. See Generic Register
+ Descriptor for details.
+
+
+ @param[in] AddressSpaceKeyword,
+ @param[in] RegisterBitWidth,
+ @param[in] RegisterBitOffset,
+ @param[in] RegisterAddress,
+ @param[in] AccessSize,
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed QWordSpace buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+AmlOPRegister (
+ IN GENERIC_ADDRESS_SPACE_ID AddressSpaceKeyword,
+ IN UINT8 RegisterBitWidth,
+ IN UINT8 RegisterBitOffset,
+ IN UINT64 RegisterAddress,
+ IN UINT8 AccessSize,
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR *Descriptor;
+
+ if ((AddressSpaceKeyword < EFI_ACPI_6_4_SYSTEM_MEMORY) ||
+ (AddressSpaceKeyword > EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AddressSpaceKeyword=0x%02X\n", __FUNCTION__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((AddressSpaceKeyword > EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL) &&
+ (AddressSpaceKeyword < EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AddressSpaceKeyword=0x%02X\n", __FUNCTION__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AccessSize > EFI_ACPI_6_4_QWORD) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n", __FUNCTION__, AccessSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __FUNCTION__, "IO_RESOURCE"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "IO_RESOURCE"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR *)Object->Data;
+
+ Descriptor->Header.Header.Byte = ACPI_GENERIC_REGISTER_DESCRIPTOR;
+ Descriptor->Header.Length = sizeof (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR) -
+ sizeof (ACPI_LARGE_RESOURCE_HEADER);
+ Descriptor->AddressSpaceId = AddressSpaceKeyword;
+ Descriptor->RegisterBitWidth = RegisterBitWidth;
+ Descriptor->RegisterBitOffset = RegisterBitOffset;
+ Descriptor->AddressSize = AccessSize;
+ Descriptor->RegisterAddress = RegisterAddress;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/*
+ 19.6.111 QWordSpace (QWord Space Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ QWordSpace (ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed,
+ TypeSpecificFlags, AddressGranularity, AddressMinimum,
+ AddressMaximum, AddressTranslation, RangeLength,
+ ResourceSourceIndex, ResourceSource, DescriptorName)
+
+ Generates:
+ 6.4.3.5.1 QWord Address Space Descriptor
+ Type 1, Large Item Value 0xA
+ The QWORD address space descriptor is used to report resource usage in a
+ 64-bit address space (like memory and I/O).
+
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed QWordSpace buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+AmlOPQWordSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT64 AddressGranularity,
+ IN UINT64 AddressMinimum,
+ IN UINT64 AddressMaximum,
+ IN UINT64 AddressTranslation,
+ IN UINT64 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // UINT8 ResourceType cannot be > 0xFF, so no need to check top end.
+ if (ResourceType < EFI_ACPI_SPACE_RESOURCE_TYPE_MIN) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ResourceType\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPQWordAddressSpace (
+ ResourceType,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ TypeSpecificFlags,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.82 Memory32Fixed (Memory Resource Descriptor Macro)
+
+ Syntax:
+ Memory32Fixed (ReadAndWrite, AddressBase, RangeLength, DescriptorName)
+
+ Arguments:
+ ReadAndWrite: Specifies whether or not the memory region is read-only (ReadOnly)
+ or read/write (ReadWrite). If nothing is specified, then ReadWrite is assumed.
+ The 1-bit field DescriptorName._RW is automatically created to refer to this
+ portion of the resource descriptor, where '1' is ReadWrite and '0' is ReadOnly.
+
+ AddressBase: Evaluates to a 32-bit integer that specifies the base address
+ of the memory range. The 32-bit field DescriptorName. _BAS is automatically
+ created to refer to this portion of the resource descriptor.
+
+ RangeLength: Evaluates to a 32-bit integer that specifies the total number of
+ bytes decoded in the memory range. The 32-bit field DescriptorName. _LEN is
+ automatically created to refer to this portion of the resource descriptor.
+
+ DescriptorName: Is an optional argument that specifies a name for an integer
+ constant that will be created in the current scope that contains the offset
+ of this resource descriptor within the current resource template buffer. The
+ predefined descriptor field names may be appended to this name to access
+ individual fields within the descriptor via the Buffer Field operators.
+
+ Description:
+ The Memory32Fixed macro evaluates to a buffer which contains a 32-bit memory
+ descriptor, which describes a fixed range of memory addresses. The format of
+ the fixed 32-bit memory descriptor can be found in 32-Bit Fixed Memory Range
+ Descriptor. The macro is designed to be used inside of a ResourceTemplate.
+
+ Generates:
+ 6.4.3.4 32-Bit Fixed Memory Range Descriptor
+ Type 1, Large Item Value 0x6
+ This memory range descriptor describes a device's memory resources within a
+ 32-bit address space.
+
+ @param[in] ReadAndWrite,
+ @param[in] AddressBase,
+ @param[in] RangeLength,
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed memory resource descriptor
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPMemory32Fixed (
+ IN READ_WRITE_FLAG ReadAndWrite,
+ IN UINT32 AddressBase,
+ IN UINT32 RangeLength,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *Descriptor;
+
+ if ((ReadAndWrite & (UINT8) ~EFI_ACPI_MEMORY_WRITE_STATUS_MASK) != 0) {
+ // Invalid ReadAndWrite value
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ReadAndWrite '%x' is not valid.\n", __FUNCTION__, ReadAndWrite));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __FUNCTION__, "MEMORY_32_FIXED_RESOURCE"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "MEMORY_32_FIXED_RESOURCE"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Header.Byte = ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR;
+ Descriptor->Header.Length = sizeof (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPTOR) -
+ sizeof (ACPI_LARGE_RESOURCE_HEADER);
+ Descriptor->Information = ReadAndWrite;
+ Descriptor->BaseAddress = AddressBase;
+ Descriptor->Length = RangeLength;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.109 QWordIO (QWord IO Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ QWordIO (ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges,
+ AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName, TranslationType,
+ TranslationDensity)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Decode,
+ @param[in] ISARanges,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ TranslationType - NOT IMPLEMENTED
+ TranslationDensity - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed QWordIO buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPQWordIO (
+ IN UINT8 ResourceUsage,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Decode,
+ IN UINT8 ISARanges,
+ IN UINT64 AddressGranularity,
+ IN UINT64 AddressMinimum,
+ IN UINT64 AddressMaximum,
+ IN UINT64 AddressTranslation,
+ IN UINT64 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ // TranslationType - NOT IMPLEMENTED
+ // TranslationDensity - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ if (ISARanges == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges = 0 = Reserved\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPQWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_IO,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ (ISARanges),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.110 QWordMemory (QWord Memory Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ QWordMemory (ResourceUsage, Decode, IsMinFixed, IsMaxFixed, Cacheable,
+ ReadAndWrite, AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName, MemoryRangeType, TranslationType)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Cacheable,
+ @param[in] ReadAndWrite,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ MemoryRangeType - NOT IMPLEMENTED
+ TranslationType - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed QWordMemory buffer
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPQWordMemory (
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Cacheable,
+ IN UINT8 ReadAndWrite,
+ IN UINT64 AddressGranularity,
+ IN UINT64 AddressMinimum,
+ IN UINT64 AddressMaximum,
+ IN UINT64 AddressTranslation,
+ IN UINT64 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ // MemoryRangeType - NOT IMPLEMENTED
+ // TranslationType - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // Validate Type Specific Parameters
+ if ((Cacheable & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid Cacheable Parameter 0x%X\n", __FUNCTION__, (Cacheable & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM)));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((ReadAndWrite & ~EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ReadAndWrite Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPQWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_MEM,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ (Cacheable | ReadAndWrite),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/*
+ Internal function to create DWord Address Space Descriptors
+
+ This function only requires a single call and therefore no Phases
+ Generates:
+ 6.4.3.5.3 Word Address Space Descriptor
+ Type 1, Large Item Value 0x8
+ The WORD address space descriptor is used to report resource usage in a
+ 16-bit address space (like memory and I/O, Bus Number).
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed WordSpace Descriptor
+
+ @retval EFI_SUCCESS
+ @retval Error status
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlOPWordAddressSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
+
+ // Vaidate General Flags Input
+ if ((ResourceUsage & ~EFI_ACPI_GENERAL_FLAG_MASK_USAGE) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid ResourceUsage Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlAddressSpaceCheck (
+ IsMinFixed,
+ IsMaxFixed,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ RangeLength
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Address Space Check FAILED\n", __FUNCTION__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __FUNCTION__, "WORD_ADDRESS"));
+ goto Done;
+ }
+
+ Object->DataSize = sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __FUNCTION__, "DWORD_ADDRESS"));
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Descriptor = (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR *)Object->Data;
+ Descriptor->Header.Header.Byte = ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR;
+ Descriptor->Header.Length = sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR) -
+ sizeof (ACPI_LARGE_RESOURCE_HEADER);
+ Descriptor->ResType = ResourceType;
+ Descriptor->GenFlag = IsMinFixed | IsMaxFixed | Decode;
+ Descriptor->SpecificFlag = TypeSpecificFlags;
+ Descriptor->AddrSpaceGranularity = AddressGranularity;
+ Descriptor->AddrRangeMin = AddressMinimum;
+ Descriptor->AddrRangeMax = AddressMaximum;
+ Descriptor->AddrTranslationOffset = AddressTranslation;
+ Descriptor->AddrLen = RangeLength;
+ Object->Completed = TRUE;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ WordSpace (ResourceType, ResourceUsage, Decode, IsMinFixed, IsMaxFixed,
+ TypeSpecificFlags, AddressGranularity, AddressMinimum,
+ AddressMaximum, AddressTranslation, RangeLength,
+ ResourceSourceIndex, ResourceSource, DescriptorName)
+
+ Generates:
+ 6.4.3.5.3 Word Address Space Descriptor
+ Type 1, Large Item Value 0x8
+
+ @param[in] ResourceType
+ @param[in] ResourceUsage,
+ @param[in] Decode,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] TypeSpecificFlags,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed WordSpace Descriptor
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPWordSpace (
+ IN UINT8 ResourceType,
+ IN UINT8 ResourceUsage,
+ IN UINT8 Decode,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 TypeSpecificFlags,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ // UINT8 ResourceType cannot be > 0xFF, so no need to check top end.
+ if (ResourceType < EFI_ACPI_SPACE_RESOURCE_TYPE_MIN) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ResourceType\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPWordAddressSpace (
+ ResourceType,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ TypeSpecificFlags,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.150 WordBusNumber (Word Bus Number Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ WordBusNumber (ResourceUsage, IsMinFixed, IsMaxFixed, Decode,
+ AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Decode,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed WordBusNumber
+ Descriptor
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPWordBusNumber (
+ IN UINT8 ResourceUsage,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Decode,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalAmlOPWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_BUS,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ 0,
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
+
+/**
+ 19.6.151 WordIO (Word IO Resource Descriptor Macro)
+
+ This function only requires a single call and therefore no Phases
+ Syntax
+ WordIO (ResourceUsage, IsMinFixed, IsMaxFixed, Decode, ISARanges,
+ AddressGranularity, AddressMinimum, AddressMaximum,
+ AddressTranslation, RangeLength, ResourceSourceIndex,
+ ResourceSource, DescriptorName, TranslationType, TranslationDensity)
+
+ defines for pass in parameters can be found in:
+ MdePkg/Include/IndustryStandard/Acpi10.h
+
+ @param[in] ResourceUsage,
+ @param[in] IsMinFixed,
+ @param[in] IsMaxFixed,
+ @param[in] Decode,
+ @param[in] ISARanges,
+ @param[in] AddressGranularity,
+ @param[in] AddressMinimum,
+ @param[in] AddressMaximum,
+ @param[in] AddressTranslation,
+ @param[in] RangeLength,
+ ResourceSourceIndex - NOT IMPLEMENTED
+ ResourceSource - NOT IMPLEMENTED
+ DescriptorName - NOT IMPLEMENTED
+ TranslationType - NOT IMPLEMENTED
+ TranslationDensity - NOT IMPLEMENTED
+ @param[in,out] ListHead - Linked list has completed WordIO Descriptor
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPWordIO (
+ IN UINT8 ResourceUsage,
+ IN UINT8 IsMinFixed,
+ IN UINT8 IsMaxFixed,
+ IN UINT8 Decode,
+ IN UINT8 ISARanges,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ // ResourceSourceIndex - NOT IMPLEMENTED
+ // ResourceSource - NOT IMPLEMENTED
+ // DescriptorName - NOT IMPLEMENTED
+ // TranslationType - NOT IMPLEMENTED
+ // TranslationDensity - NOT IMPLEMENTED
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+
+ if (ISARanges == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges = 0 = Reserved\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __FUNCTION__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAmlOPWordAddressSpace (
+ ACPI_ADDRESS_SPACE_TYPE_IO,
+ ResourceUsage,
+ Decode,
+ IsMinFixed,
+ IsMaxFixed,
+ (ISARanges),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ListHead
+ );
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
new file mode 100644
index 0000000000000000000000000000000000000000..64066e13317969b2d78f0f158d20a2b49f032d95
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -0,0 +1,512 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ Creates an Else object
+
+ TermList must be created between AmlStart and AmlClose Phase
+
+ Since ElseIf (...) is created with Else {( If (){})}. ElseIf will not be
+ supported and must be created with Else and If.
+
+ DefElse := Nothing |
+ ElseOp := 0xA1
+
+ EXAMPLE:
+ AmlIf (AmlStart, ListHead);
+ {
+ { // Predicate
+ AmlOpDataInteger (1, ListHead);
+ } // Predicate
+ { // TermList
+ ...
+ } // TermList
+ }
+ AmlIf (AmlClose, ListHead);
+ AmlElse (AmlStart, ListHead);
+ {
+ AmlIf (AmlStart, ListHead);
+ {
+ {} // Predicate
+ {} // Termlist
+ }
+ AmlIf (AmlClose, ListHead);
+ AmlElse (AmlStart, ListHead);
+ {} // TermList
+ AmlElse (AmlClose, ListHead);
+ }
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed AmlElse Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlElse (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, "Else", ListHead);
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: If PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // DataRefObject is outside the scope of this object
+ break;
+ case AmlClose:
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: close PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // DataRefObject should be closed already
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Else", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Handle Return with no arguments
+ if ((ChildObject->Data == NULL) || (ChildObject->DataSize == 0)) {
+ Status = EFI_DEVICE_ERROR;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: If must have at least a Predicate\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Allocate buffer for Return object
+ Object->Data = AllocatePool (ChildObject->DataSize + 1);
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=Return\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Fill out Return object
+ Object->Data[0] = AML_ELSE_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a If object
+
+ Predicate and TermList must be created between AmlStart and AmlClose Phase
+
+ Since ElseIf (...) is created with Else {( If (){})}. ElseIf will not be
+ supported and must be created with Else and If.
+
+ DefIfElse := IfOp PkgLength Predicate TermList DefElse
+ IfOp := 0xA0
+ Predicate := TermArg => Integer
+
+ EXAMPLE:
+ AmlIf (AmlStart, ListHead);
+ {
+ { // Predicate
+ AmlOpDataInteger (1, ListHead);
+ } // Predicate
+ { // TermList
+ ...
+ } // TermList
+ }
+ AmlIf (AmlClose, ListHead);
+ AmlElse (AmlStart, ListHead);
+ {
+ AmlIf (AmlStart, ListHead);
+ {
+ {} // Predicate
+ {} // Termlist
+ }
+ AmlIf (AmlClose, ListHead);
+ AmlElse (AmlStart, ListHead);
+ {} // TermList
+ AmlElse (AmlClose, ListHead);
+ }
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed AmlIf Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlIf (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, "If", ListHead);
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: If PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // DataRefObject is outside the scope of this object
+ break;
+ case AmlClose:
+ // Close required PkgLength before finishing Object
+ Status = AmlPkgLength (AmlClose, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: close PkgLength object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // DataRefObject should be closed already
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "If", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Handle Return with no arguments
+ if ((ChildObject->Data == NULL) || (ChildObject->DataSize == 0)) {
+ Status = EFI_DEVICE_ERROR;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: If must have at least a Predicate\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Allocate buffer for Return object
+ Object->Data = AllocatePool (ChildObject->DataSize + 1);
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=Return\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Fill out Return object
+ Object->Data[0] = AML_IF_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Notify object
+
+ DefNotify := NotifyOp NotifyObject NotifyValue
+ NotifyOp := 0x86
+ NotifyObject := SuperName => ThermalZone | Processor | Device
+ NotifyValue := TermArg => Integer
+
+ @param[in] NotifyObject - String of Namestring to a device
+ @param[in] NotifyValue - Integer Notify value
+ @param[in,out] ListHead - Linked list updated with Notify object
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlOPNotify (
+ IN CHAR8 *NotifyObject,
+ IN UINT64 NotifyValue,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ Status = InternalAppendNewAmlObject (&Object, NotifyObject, ListHead);
+ Status = AmlOPNameString (NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyObject NameString\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NotifyValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n", __FUNCTION__));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Allocate buffer for Return object
+ Object->Data = AllocatePool (ChildObject->DataSize + 1);
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=Return\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Fill out Return object
+ Object->Data[0] = AML_NOTIFY_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
+
+/**
+ Creates a Return object
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefReturn := ReturnOp ArgObject
+ ReturnOp := 0xA4
+ ArgObject := TermArg => DataRefObject
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlReturn (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, "Return", ListHead);
+ // DataRefObject is outside the scope of this object
+ break;
+ case AmlClose:
+ // DataRefObject should be closed already
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Return", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Handle Return with no arguments
+ if ((ChildObject->Data == NULL) || (ChildObject->DataSize == 0)) {
+ // Return without arguments is treated like Return(0)
+ // Zeroed byte = ZeroOp
+ ChildObject->Data = AllocateZeroPool (sizeof (UINT8));
+ if (ChildObject->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Zero Child for Return\n", __FUNCTION__));
+ goto Done;
+ }
+
+ ChildObject->DataSize = 1;
+ }
+
+ // Allocate buffer for Return object
+ Object->Data = AllocatePool (ChildObject->DataSize + 1);
+ Object->DataSize = ChildObject->DataSize + 1;
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=Return\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Fill out Return object
+ Object->Data[0] = AML_RETURN_OP;
+ CopyMem (
+ &Object->Data[1],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlTable.c
new file mode 100644
index 0000000000000000000000000000000000000000..1d965572cf14946f78b06d102bf2b3f11eec2189
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -0,0 +1,210 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+// String Length Constants
+#define OEM_ID_LENGTH 6
+#define OEM_TABLE_ID_LENGTH 8
+#define SIGNATURE_LENGTH 4
+#define CREATOR_ID_LENGTH 4
+
+/**
+ Creates an AML Encoded Table
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefBlockHeader := TableSignature TableLength SpecCompliance CheckSum OemID
+ OemTableID OemRevision CreatorID CreatorRevision
+
+ TableSignature := DWordData // As defined in section 5.2.3.
+ TableLength := DWordData // Length of the table in bytes including the
+ // block header
+ SpecCompliance := ByteData // The revision of the structure.
+ CheckSum := ByteData // Byte checksum of the entire table.
+ OemID := ByteData(6) // OEM ID of up to 6 characters.
+ // If the OEM ID is shorter than 6
+ // characters, it can be terminated with a
+ // NULL character.
+ OemTableID := ByteData(8) // OEM Table ID of up to 8 characters.
+ // If the OEM Table ID is shorter than
+ // 8 characters, it can be terminated with
+ // a NULL character.
+ OemRevision := DWordData // OEM Table Revision.
+ CreatorID := DWordData // Vendor ID of the ASL compiler.
+ CreatorRevision := DWordData // Revision of the ASL compiler.
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] TableNameString - Table Name
+ @param[in] ComplianceRev - Compliance Revision
+ @param[in] OemId - OEM ID
+ @param[in] OemTableId - OEM ID of table
+ @param[in] OemRevision - OEM Revision number
+ @param[in] CreatorId - Vendor ID of the ASL compiler
+ @param[in] CreatorRevision - Vendor Revision of the ASL compiler
+ @param[in,out] ListHead - Linked list has completed String Object after
+ AmlClose.
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDefinitionBlock (
+ IN AML_FUNCTION_PHASE Phase,
+ IN CHAR8 *TableNameString,
+ IN UINT8 ComplianceRev,
+ IN CHAR8 *OemId,
+ IN CHAR8 *OemTableId,
+ IN UINT32 OemRevision,
+ IN CHAR8 *CreatorId,
+ IN UINT32 CreatorRevision,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+ UINTN ChildCount;
+
+ if ((Phase >= AmlInvalid) ||
+ (ListHead == NULL) ||
+ (TableNameString == NULL) ||
+ (OemId == NULL) ||
+ (OemTableId == NULL) ||
+ (CreatorId == NULL) ||
+ (AsciiStrLen (TableNameString) != SIGNATURE_LENGTH) ||
+ (AsciiStrLen (OemId) > OEM_ID_LENGTH) ||
+ (AsciiStrLen (OemTableId) > OEM_TABLE_ID_LENGTH) ||
+ (AsciiStrLen (CreatorId) != CREATOR_ID_LENGTH))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_DEVICE_ERROR;
+ Object = NULL;
+ ChildObject = NULL;
+
+ switch (Phase) {
+ case AmlStart:
+ Status = InternalAppendNewAmlObject (&Object, TableNameString, ListHead);
+ // TermList is too complicated and must be added outside
+ break;
+
+ case AmlClose:
+ // TermList should be closed already
+ Status = InternalAmlLocateObjectByIdentifier (&Object, TableNameString, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate %a object\n", __FUNCTION__, TableNameString));
+ goto Done;
+ }
+
+ // Get rid of original Identifier data
+ InternalFreeAmlObjectData (Object);
+
+ // Collect child data and delete children
+ Status = InternalAmlCollapseAndReleaseChildren (
+ &ChildObject,
+ &ChildCount,
+ &Object->Link,
+ ListHead
+ );
+ if (EFI_ERROR (Status) ||
+ (ChildObject->Data == NULL) ||
+ (ChildObject->DataSize == 0))
+ {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __FUNCTION__, TableNameString));
+ goto Done;
+ }
+
+ Object->DataSize = ChildObject->DataSize + sizeof (EFI_ACPI_DESCRIPTION_HEADER);
+ Object->Data = AllocateZeroPool (Object->DataSize);
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __FUNCTION__, TableNameString));
+ goto Done;
+ }
+
+ // Fill table header with data
+ // Signature
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Signature)],
+ TableNameString,
+ AsciiStrLen (TableNameString)
+ );
+
+ // Table Length
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Length)],
+ (UINT32 *)&Object->DataSize,
+ sizeof (UINT32)
+ );
+
+ // ACPI Table Version
+ Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Revision)] = ComplianceRev;
+
+ // OEM ID
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, OemId)],
+ OemId,
+ AsciiStrLen (OemId)
+ );
+
+ // OEM Table ID
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, OemTableId)],
+ OemTableId,
+ AsciiStrLen (OemTableId)
+ );
+
+ // OEM Table Version
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, OemRevision)],
+ (UINT8 *)&OemRevision,
+ sizeof (UINT32)
+ );
+
+ // Creator ID
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, CreatorId)],
+ CreatorId,
+ AsciiStrLen (CreatorId)
+ );
+
+ // Creator Version
+ CopyMem (
+ &Object->Data[OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, CreatorRevision)],
+ (UINT8 *)&CreatorRevision,
+ sizeof (UINT32)
+ );
+
+ // Copy rest of data into Object
+ CopyMem (
+ &Object->Data[sizeof (EFI_ACPI_DESCRIPTION_HEADER)],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+
+ // Checksum Set on Table Install
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ Object->Completed = TRUE;
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ Status = EFI_DEVICE_ERROR;
+ break;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
new file mode 100644
index 0000000000000000000000000000000000000000..37cc81ec7c945f78c833f9e29cbe0f0e87892afb
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef INTERNAL_AML_LIB_H_
+#define INTERNAL_AML_LIB_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "LocalAmlObjects.h"
+
+// EDK2 open source MdePkg/Include/IndustryStandard/AcpiAml.h does not have
+// these and should.
+#define AML_DIGIT_CHAR_0 0x30
+#define AML_DIGIT_CHAR_9 0x39
+
+// The max string size for a QWord is 8 bytes = 16 characters plus NULL Terminator
+#define MAX_AML_DATA_INTEGER_SIZE 17
+
+// Defines similar to ctype.h functions isalpha() and isdigit()
+#define IS_ASCII_UPPER_ALPHA(c) ( ((c) >= AML_NAME_CHAR_A) && ((c) <= AML_NAME_CHAR_Z) )
+#define IS_ASCII_HEX_DIGIT(c) ( (((c) >= AML_DIGIT_CHAR_0) && ((c) <= AML_DIGIT_CHAR_9)) ||\
+ (((c) >= AML_NAME_CHAR_A) && ((c) <= AML_NAME_CHAR_F)) )
+
+// Swap bytes of upper and lower WORDs within a DWORD
+#define Swap4Bytes(val) \
+ ( (((val) >> 8) & 0x000000FF) | (((val) << 8) & 0x0000FF00) | \
+ (((val) >> 8) & 0x00FF0000) | (((val) << 8) & 0xFF000000) )
+
+/*
+ Calculates the optimized integer value used by AmlDataInteger and others
+
+ Not a public function so no doxygen comment identifiers.
+
+ @param[in] Integer - Integer value to encode
+ @param[out] ReturnData - Allocated DataBuffer with encoded integer
+ @param[out] ReturnDataSize - Size of ReturnData
+
+ @return EFI_SUCCESS - Successful completion
+ @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffer
+*/
+EFI_STATUS
+EFIAPI
+InternalAmlDataIntegerBuffer (
+ IN UINT64 Integer,
+ OUT VOID **ReturnData,
+ OUT UINTN *ReturnDataSize
+ );
+
+/**
+ Creates a Package Length encoding and places it in the return buffer,
+ PkgLengthEncoding. Similar to AmlPkgLength but the PkgLength does not
+ include the length of its own encoding.
+
+ @param[in] DataSize - The size of data to be encoded as a pkglength
+ @param[out] PkgLengthEncoding - Return buffer containing the AML encoding
+ @param[out] ReturnDataLength - Size of the return buffer
+
+ @return EFI_SUCCESS - Success
+ @return all others - Fail
+ **/
+EFI_STATUS
+EFIAPI
+InternalAmlBitPkgLength (
+ IN UINT32 DataSize,
+ OUT UINT8 **PkgLengthEncoding,
+ OUT UINTN *ReturnDataLength
+ );
+
+/**
+ Creates a NameSeg AML object and inserts it into the List
+
+ NameSeg :=
+
+ NameSegs shorter than 4 characters are filled with trailing underscores
+
+ @param[in] Name - Field NameSeg
+ @param[in,out] ListHead - Linked list has NameSeg after call
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlNameSeg (
+ IN CHAR8 *Name,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+#endif // INTERNAL_AML_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
new file mode 100644
index 0000000000000000000000000000000000000000..b9d9bc5485ede69149ea347a5c7251b7e80f26b9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -0,0 +1,357 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+
+/**
+ Free Object->Data
+
+ Frees Object->Data, Nulls pointer, zeros size and marks
+ Object->Completed = FALSE
+
+ @param [in] Object - Pointer to Object to have Data freed
+
+ @return EFI_SUCCESS - Object Freed
+ @return - Object free failed
+**/
+EFI_STATUS
+EFIAPI
+InternalFreeAmlObjectData (
+ IN AML_OBJECT_INSTANCE *Object
+ )
+{
+ if (Object == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Object->Data != NULL) {
+ FreePool (Object->Data);
+ Object->Data = NULL;
+ Object->DataSize = 0;
+ Object->Completed = FALSE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Free an Object
+
+ Removes Object from it's linked list.
+ Frees Object->Data
+ Frees Object
+
+ @param [in] Object - Pointer to Object to be freed
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object Freed
+ @return - Object free failed
+**/
+EFI_STATUS
+EFIAPI
+InternalFreeAmlObject (
+ IN AML_OBJECT_INSTANCE **FreeObject,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+
+ if ((FreeObject == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = *FreeObject;
+ if (Object != NULL) {
+ InternalFreeAmlObjectData (Object);
+ if (IsNodeInList (ListHead, &Object->Link)) {
+ RemoveEntryList (&Object->Link);
+ }
+
+ FreePool (Object);
+ }
+
+ *FreeObject = NULL;
+ return EFI_SUCCESS;
+}
+
+/**
+ Creates a new AML_OBJECT_INSTANCE. Object->Data will be NULL and
+ Object->DataSize will be 0
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalNewAmlObjectNoData (
+ OUT AML_OBJECT_INSTANCE **ReturnObject
+ )
+{
+ AML_OBJECT_INSTANCE *Object;
+
+ if (ReturnObject == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ReturnObject = NULL;
+
+ // Allocate AML Object
+ Object = AllocateZeroPool (sizeof (AML_OBJECT_INSTANCE));
+ if (Object == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Allocate Object Failed\n", __FUNCTION__));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Object->DataSize = 0;
+ Object->Data = NULL;
+ Object->Signature = AML_OBJECT_INSTANCE_SIGNATURE;
+
+ *ReturnObject = Object;
+ return EFI_SUCCESS;
+}
+
+/**
+ Inserts a new AML_OBJECT_INSTANCE at the end of the linked list. Object->Data
+ will be NULL and Object->DataSize will be 0
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAppendNewAmlObjectNoData (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if ((ListHead == NULL) || (ReturnObject == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalNewAmlObjectNoData (&Object);
+ if (!EFI_ERROR (Status)) {
+ InsertTailList (ListHead, &Object->Link);
+ *ReturnObject = Object;
+ }
+
+ return Status;
+}
+
+/**
+ Inserts a new AML_OBJECT_INSTANCE at the end of the linked list. Using a
+ string Identifier for comparison purposes
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in] Identifier - String Identifier to create object with
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAppendNewAmlObject (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN CHAR8 *Identifier,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_INSTANCE *Object;
+
+ if ((Identifier == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = NULL;
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // Allocate Identifier Data + NULL termination
+ Object->DataSize = AsciiStrLen (Identifier) + 1;
+ Object->Data = AllocatePool (Object->DataSize);
+ if (Object->Data == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Allocate Data Identifier=%a\n", __FUNCTION__, Identifier));
+ InternalFreeAmlObject (&Object, ListHead);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CopyMem (Object->Data, Identifier, Object->DataSize);
+
+ *ReturnObject = Object;
+ return EFI_SUCCESS;
+}
+
+/**
+ Finds AML_OBJECT_INSTANCE given a string Identifier looking backwards in the
+ AML_OBJECT_INSTANCE linked list
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in] Identifier - String Identifier to create object with
+ @param [in] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object located and returned
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlLocateObjectByIdentifier (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN CHAR8 *Identifier,
+ IN LIST_ENTRY *ListHead
+ )
+{
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+ UINTN IdentifierSize;
+
+ if ((Identifier == NULL) || (ListHead == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Object = NULL;
+ *ReturnObject = NULL;
+
+ IdentifierSize = AsciiStrLen (Identifier) + 1;
+ // Look Backwards and find Node for this Object
+ Node = ListHead;
+ do {
+ Node = GetPreviousNode (ListHead, Node);
+ Object = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+
+ if (Object->Completed) {
+ // Object to be found cannot be completed yet
+ continue;
+ } else {
+ if ((Object->DataSize != 0) &&
+ (Object->DataSize == IdentifierSize) &&
+ (CompareMem (
+ Object->Data,
+ Identifier,
+ MAX (Object->DataSize, IdentifierSize)
+ ) == 0))
+ {
+ *ReturnObject = Object;
+ return EFI_SUCCESS;
+ } else {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: ERROR: First incomplete Object is not %a.\n",
+ __FUNCTION__,
+ Identifier
+ ));
+ // Object looking for should be the first uncompleted Object.
+ return EFI_NOT_FOUND;
+ }
+ }
+ } while (Node != ListHead);
+
+ *ReturnObject = NULL;
+ return EFI_NOT_FOUND;
+}
+
+/**
+ Finds all children of the Link and appends them into a single ObjectData
+ buffer of ObjectDataSize
+
+ Allocates AML_OBJECT_INSTANCE and Data which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object pointer
+ @param [out] ChildCount - Count of Child Objects collapsed
+ @param [in] Link - Linked List Object entry to collect children
+ @param [in,out] ListHead - Head of Object Linked List
+
+ @return EFI_SUCCESS - ChildObject created and returned
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlCollapseAndReleaseChildren (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ OUT UINTN *ChildCount,
+ IN LIST_ENTRY *Link,
+ IN OUT LIST_ENTRY *ListHead
+ )
+{
+ EFI_STATUS Status;
+ LIST_ENTRY *Node;
+ AML_OBJECT_INSTANCE *Object;
+ AML_OBJECT_INSTANCE *ChildObject;
+
+ Status = EFI_SUCCESS;
+ if ((ReturnObject == NULL) ||
+ (ChildCount == NULL) ||
+ (Link == NULL) ||
+ (ListHead == NULL))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ChildCount = 0;
+
+ Status = InternalNewAmlObjectNoData (&Object);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: allocating Object Data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Get first Child Node
+ Node = GetNextNode (ListHead, Link);
+ while (Node != ListHead) {
+ ChildObject = AML_OBJECT_INSTANCE_FROM_LINK (Node);
+ // Expand data buffer to fit existing data + new data
+ Object->Data = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + ChildObject->DataSize,
+ Object->Data
+ );
+ if (Object->Data == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __FUNCTION__));
+ goto Done;
+ }
+
+ // Copy new data at end of buffer
+ CopyMem (
+ &Object->Data[Object->DataSize],
+ ChildObject->Data,
+ ChildObject->DataSize
+ );
+ Object->DataSize += ChildObject->DataSize;
+ // Get Next ChildObject Node, then free ChildObject from list
+ Node = GetNextNode (ListHead, Node);
+ InternalFreeAmlObject (&ChildObject, ListHead);
+ *ChildCount = *ChildCount + 1;
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ Object = NULL;
+ }
+
+ *ReturnObject = Object;
+ return Status;
+}
diff --git a/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
new file mode 100644
index 0000000000000000000000000000000000000000..453420307fee84cfa2a2f924bf687448071cb0ba
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -0,0 +1,150 @@
+/** @file
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef INTERNAL_AML_OBJECTS_H_
+#define INTERNAL_AML_OBJECTS_H_
+
+// #include "LocalAmlLib.h"
+
+/**
+ Free Object->Data
+
+ Frees Object->Data, Nulls pointer, zeros size and marks
+ Object->Completed = FALSE
+
+ @param [in] Object - Pointer to Object to have Data freed
+
+ @return EFI_SUCCESS - Object Freed
+ @return - Object free failed
+**/
+EFI_STATUS
+EFIAPI
+InternalFreeAmlObjectData (
+ IN AML_OBJECT_INSTANCE *Object
+ );
+
+/**
+ Free an Object
+
+ Removes Object from it's linked list.
+ Frees Object->Data
+ Frees Object
+
+ @param [in] Object - Pointer to Object to be freed
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object Freed
+ @return - Object free failed
+**/
+EFI_STATUS
+EFIAPI
+InternalFreeAmlObject (
+ IN AML_OBJECT_INSTANCE **Object,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+/**
+ Creates a new AML_OBJECT_INSTANCE. Object->Data will be NULL and
+ Object->DataSize will be 0
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalNewAmlObjectNoData (
+ OUT AML_OBJECT_INSTANCE **ReturnObject
+ );
+
+/**
+ Inserts a new AML_OBJECT_INSTANCE at the end of the linked list. Object->Data
+ will be NULL and Object->DataSize will be 0
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAppendNewAmlObjectNoData (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+/**
+ Inserts a new AML_OBJECT_INSTANCE at the end of the linked list. Using a
+ string Identifier for comparison purposes
+
+ Allocates AML_OBJECT_INSTANCE which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in] Identifier - String Identifier to create object with
+ @param [in,out] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object created and appended to linked list
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAppendNewAmlObject (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN CHAR8 *Identifier,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+/**
+ Finds AML_OBJECT_INSTANCE given a string Identifier looking backwards in the
+ AML_OBJECT_INSTANCE linked list
+
+ @param [out] ReturnObject - Pointer to an Object
+ @param [in] Identifier - String Identifier to create object with
+ @param [in] ListHead - Head of AML Object linked list
+
+ @return EFI_SUCCESS - Object located and returned
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlLocateObjectByIdentifier (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ IN CHAR8 *Identifier,
+ IN LIST_ENTRY *ListHead
+ );
+
+/**
+ Finds all children of the Link and appends them into a single ObjectData
+ buffer of ObjectDataSize
+
+ Allocates AML_OBJECT_INSTANCE and Data which must be freed by caller
+
+ @param [out] ReturnObject - Pointer to an Object pointer
+ @param [out] ChildCount - Count of Child Objects collapsed
+ @param [in] Link - Linked List Object entry to collect children
+ @param [in,out] ListHead - Head of Object Linked List
+
+ @return EFI_SUCCESS - ChildObject created and returned
+ @return - Object creation failed, Object = NULL
+**/
+EFI_STATUS
+EFIAPI
+InternalAmlCollapseAndReleaseChildren (
+ OUT AML_OBJECT_INSTANCE **ReturnObject,
+ OUT UINTN *ChildCount,
+ IN LIST_ENTRY *Link,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+#endif // INTERNAL_AML_OBJECTS_H_
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
index 4766ad0447357c5e83d0763b16c95a976c528772..3f61cbbdc754a05a094be9f021a478e62d7e693f 100644
--- a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
@@ -1,7 +1,8 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
+##
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
index 1f1e04c414b6517b91e5c599a2933b1984f8f2a1..5c05759883c6a4ee4247b696caeb6f2e02cd9a77 100644
--- a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
index 4766ad0447357c5e83d0763b16c95a976c528772..3f61cbbdc754a05a094be9f021a478e62d7e693f 100644
--- a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
@@ -1,7 +1,8 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
+##
diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
index da3afe6e59c1889f3bd2caed293199101c09b1d4..6a1494c2dbdea5f12c401f261dae471bd2c8bcd1 100644
--- a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
index da3afe6e59c1889f3bd2caed293199101c09b1d4..6a1494c2dbdea5f12c401f261dae471bd2c8bcd1 100644
--- a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.dxe.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..3f61cbbdc754a05a094be9f021a478e62d7e693f
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+##
diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.pei.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.pei.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..3f61cbbdc754a05a094be9f021a478e62d7e693f
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x1A/BRH/External/CbsBreithorn.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+##
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatform.inf
new file mode 100644
index 0000000000000000000000000000000000000000..87b4ec1aea7627b84f4054a8f97bde3f5293215a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PspPlatform
+ FILE_GUID = 28374747-76FF-41B3-9740-381EFAEF13BC
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PspPlatformEntryPoint
+
+[Sources]
+ PspPlatformDriver.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatformDriver.c
new file mode 100644
index 0000000000000000000000000000000000000000..5ba586059b066a0a7bdc4ce66d45762a9de41fa2
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -0,0 +1,21 @@
+/** @file
+
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include
+#include
+
+#include
+
+EFI_STATUS
+EFIAPI
+PspPlatformEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
new file mode 100644
index 0000000000000000000000000000000000000000..d38258f0479ea14cf3abf5562d62801906682d2f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include
+#include
+#include
+#include
+#include
+
+EFI_STATUS
+EFIAPI
+HotplugDescEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
new file mode 100644
index 0000000000000000000000000000000000000000..672e5168587b596ac6a61eeab89504f0c2dbc073
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = ServerHotplugDxe
+ FILE_GUID = FAFF8CA9-E515-44ed-B5F9-E2F6E5D902E3
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = HotplugDescEntry
+
+[Sources]
+ ServerHotplugDxe.c
+
+[Packages]
+ AgesaPkg/AgesaPkg.dec
+ MdePkg/MdePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.dxe.inc.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.dxe.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..3f61cbbdc754a05a094be9f021a478e62d7e693f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+##
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..980934c3ac3450c645784764a385510777dff4e5
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Platform Package Flash Description File
+#
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.inc.dsc b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.inc.dsc
new file mode 100644
index 0000000000000000000000000000000000000000..e6b5d185f18f68abc2ffd0134cf6279515d4cdc6
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.inc.dsc
@@ -0,0 +1,12 @@
+## @file
+#
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEFINE AGESA_PKG_PATH = AgesaModulePkg
+ DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.pei.inc.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.pei.inc.fdf
new file mode 100644
index 0000000000000000000000000000000000000000..6a1494c2dbdea5f12c401f261dae471bd2c8bcd1
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Chalupa/Processor/Turin/AmdCpmTurinChalupaPkg.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
index e379538e3ab61117e684bb837dbac38fcf9f79ae..3898790a2b6592ad085125a83cd0c6ad4c838a2f 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
@@ -1,7 +1,6 @@
/** @file
- OEM OOB PPR DXE Driver.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
index 64fd2913ad80b54a726cc94dd5aa8e661f3a5332..4c0cee4bbe567c040e7f58f40baa27dc19359e0b 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
@@ -1,42 +1,39 @@
-## @file
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = OobPprDxe
- FILE_GUID = F91DCAB4-3639-11EE-BE56-0242AC120002
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = OobPprEntry
-
-[Sources]
- OobPprDxe.c
-
-[Packages]
- AgesaPkg/AgesaPkg.dec
- AgesaModulePkg/AgesaCommonModulePkg.dec
- MdePkg/MdePkg.dec
- AmdCpmPkg/AmdCpmPkg.dec
-
-[LibraryClasses]
- UefiDriverEntryPoint
- DebugLib
- PcdLib
- BaseMemoryLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- MemoryAllocationLib
- TimerLib
-
-[Protocols]
- gEfiPciIoProtocolGuid #CONSUMES
-
-[Depex]
- TRUE
-
-
-
+## @file
+#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = OobPprDxe
+ FILE_GUID = F91DCAB4-3639-11EE-BE56-0242AC120002
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = OobPprEntry
+
+[Sources]
+ OobPprDxe.c
+
+[Packages]
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ MdePkg/MdePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ DebugLib
+ PcdLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ MemoryAllocationLib
+ TimerLib
+
+[Protocols]
+ gEfiPciIoProtocolGuid #CONSUMES
+
+[Depex]
+ TRUE
\ No newline at end of file
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
index f4d7638c1a6bed2f5ae3ec6d96ae385d152e1bde..5c9857f921d6891032de4b71384de14602192cff 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
index 5242e6261a91cc359d8bb3e494f6c51ee7241a8f..6b532d7185ec3a58543752e57b77401f29908945 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
index 530bd9d4b699204acf43285a88672c83fbc8141a..d38258f0479ea14cf3abf5562d62801906682d2f 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
index 973ace863236fe481edfcac2181e9396620d89b2..c97f8dbc7c44155998141fdd9132bdb90945ade9 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2008-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
index 4766ad0447357c5e83d0763b16c95a976c528772..421a0cba662fc7be9bd99fe68b6b84edeb01b405 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
index b790e4ead57d5d60b05fba25f571fb70ba45b351..1dfdb6800276b2ca88bf97f34501093a0a28bdc7 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
@@ -2,7 +2,7 @@
#
# Platform Package Flash Description File
#
-# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
index 2916fecb2625e80e0b3e16866f9fb3d0184558f2..1bc71dab3b584c7c33569aca1785af79184574a0 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
index 4766ad0447357c5e83d0763b16c95a976c528772..421a0cba662fc7be9bd99fe68b6b84edeb01b405 100644
--- a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
index c8c474637f8ac3e5d1a8b3553f9422e19726e792..0b7422c420fa7bcc1bcd68f074ac2dfdc1719607 100755
--- a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
+++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
@@ -1,7 +1,6 @@
## @file
-# AMD Common Platform Module (CPM) Module Package DEC.
#
-# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
index a7fef5a35c26d0f84cbc01b990437af21322f35e..059e32588847e4c0cf52a5848240914485cdbefa 100644
--- a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPM Base Definitions.
- Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2014-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
index af192fcf035c30b77ea1f0f541f4ca04efe22fa6..54e64cc8430f84a737dffb743e3a41f6510d3f82 100644
--- a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPM Common Definitions.
- Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
index 4fc3f97a80facc118e177c90f2f3ecd6d00802a4..b5b250702a16876cb8bd224ebb0ff81ba78155ce 100644
--- a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPM Common Definitions.
- Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
index 7dce2381356ac19015dea20f5ecd3350d5d4aad2..cede8ad198b50587a1cfb2d50e5f5734cdbeca98 100644
--- a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPM Common Functions.
- Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
index fbc372586b5d6793c54da12ce6a5735452de8da7..fe179889445c828728d529c6df4626e57070ef8a 100644
--- a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
index 2d9dbeb715f0eb82242c129bf1969e590bf34337..a38229af65e678757d3e00aaf09f3c22bdf2d75a 100644
--- a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
index 0a5f4a7e817a60df9d718e844cbf7bc75d5fcd3b..f157218d2f77c88068fc654537591e3ce40cb092 100644
--- a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
@@ -1,13 +1,6 @@
/** @file
- String token ID of help message text.
- Shell supports to find help message in the resource section of an
- application image if * .MAN file is not found.
- This global variable is added to make build tool recognizes
- that the help string is consumed by user and then build tool will
- add the string into the resource section.
- Thus the application can use '-?' option to show help message in Shell.
- Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
index 98c8755ab8d24ee7edde6c7879d72d1cd3ccff26..d56603a9378ae9448d5bbb0ba1a79a16e582d5e6 100644
--- a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
index 47eb700f8fc25d0bf1b441225df3a70c122f9e1a..0ac33a2bc1404161b98b35440cb683f9bb88819e 100644
--- a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
index 9c3c0dd0a9b492f6efae7eae6628666581f627a0..f690274a35ee58215591367e65c9339765163b54 100644
--- a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2016-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -30,4 +30,3 @@
PlatformHookLib
-
diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
index 4a90aa3d8bcf53fcc8cbf1f82ff656d9a8c7bada..735a55668f289353db75f0cfd448d4dff869cce5 100644
--- a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
+++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
@@ -1,7 +1,6 @@
/** @file
- AMD CPM Table Protocol.
- Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2012-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec
index 58700988c845001bf02786e0dfc87c3b18a83a96..8e488f1aea1eb6e2cb38f81289a4c4c123a7ac12 100644
--- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec
+++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec
@@ -4,7 +4,7 @@
# This package supports AMD processor family based board as per the MinPlatform
# Arch specification.
#
-# Copyright (c) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (c) 2023 - 2025, Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
# @par Specification Reference:
@@ -26,11 +26,9 @@
[Ppis]
gAmdMemoryInfoHobPpiGuid = { 0xba16e587, 0x1d66, 0x41b7, { 0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
- gAmdTopOfTemporaryRamPpiGuid = { 0x1e1ad6ed, 0xa13d, 0x4fdc, { 0xa5, 0xb8, 0x58, 0x23, 0xef, 0x17, 0xd9, 0x08}}
-[LibraryClasses]
- ## @libraryclass Provide services to platform BDS hook.
- BoardBdsHookLib|Include/Library/AmdBoardBdsHookLib.h
+[Ppis]
+ gTopOfTemporaryRamPpiGuid = { 0x2f3962b2, 0x57c5, 0x44ec, { 0x9e, 0xfc, 0xa6, 0x9f, 0xd3, 0x02, 0x03, 0x2b}}
[Protocols]
gAmdBoardBdsBootOptionPriorityProtocolGuid = { 0x5806db97, 0x5303, 0x409f, { 0x8f, 0x09, 0xab, 0x29, 0xd8, 0x07, 0xa3, 0xf1}}
@@ -56,14 +54,21 @@
gAmdMinBoardPkgTokenSpaceGuid.PcdAmdFlashFvAdvancedSecuritySize |0x00000000|UINT32|0x10000008
gAmdMinBoardPkgTokenSpaceGuid.PcdAmdFlashFvAdvancedSecurityOffset |0x00000000|UINT32|0x10000009
- # SMRAM size
- # Holds the SMRAM area size, which is reserved for SMRAM operation
- # default value 128MB
- gAmdMinBoardPkgTokenSpaceGuid.PcdAmdSmramAreaSize |0x08000000|UINT64|0x20000100
-
# PCDs of temp memory address
gAmdMinBoardPkgTokenSpaceGuid.PcdTempRamBase |0x00030000|UINT32|0x1000000A
gAmdMinBoardPkgTokenSpaceGuid.PcdTempRamSize |0x00020000|UINT32|0x1000000B
# PCD of boot FV base address
gAmdMinBoardPkgTokenSpaceGuid.PcdBootFvBase |0x09B00000|UINT32|0x1000000C
+
+ #
+ # PCIe Config Space
+ #
+ gAmdMinBoardPkgTokenSpaceGuid.PcdMmioCfgBusRange |0x00000008|UINT32|0x1000000D # 8 = 256MB, 7 = 128MB, and 6 = 64MB
+ gAmdMinBoardPkgTokenSpaceGuid.PcdPciExpressBaseAddressLow |0xE0000000|UINT32|0x1000000E # Lower 32 bit address of PCIe config base.
+ gAmdMinBoardPkgTokenSpaceGuid.PcdPciExpressBaseAddressHi |0x00000000|UINT32|0x1000000F # Upper 32 bit address of PCIe config base.
+
+ # SMRAM size
+ # Holds the SMRAM area size, which is reserved for SMRAM operation
+ # default value 128MB
+ gAmdMinBoardPkgTokenSpaceGuid.PcdAmdSmramAreaSize |0x08000000|UINT64|0x20000100
diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
index 1dbefbb7ec61a2cf50d97d48f80996e7e3abb91b..f9fb49ac8b6cc5dc17e02a988d95b583e33fa264 100644
--- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
+++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc
@@ -22,12 +22,10 @@
MinPlatformPkg/MinPlatformPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
-[PcdsDynamicDefault]
- gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0x10000000
-
[LibraryClasses]
- ReportFvLib|AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
SpcrDeviceLib|AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
+ ReportFvLib|AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
+ PlatformSecLib|AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
[LibraryClasses.common]
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
@@ -36,31 +34,45 @@
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
- StackCheckLib|MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
+ BoardAcpiTableLib|MinPlatformPkg/Acpi/Library/BoardAcpiTableLibNull/BoardAcpiTableLibNull.inf
-[LibraryClasses.common.SEC]
- PlatformSecLib|AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
-
[LibraryClasses.common.PEIM]
- BoardInitLib|AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
+ BoardInitLib|AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
[LibraryClasses.common.DXE_DRIVER]
- BoardBdsHookLib|AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
BoardInitLib|AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
[Components]
AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
-[Components.IA32]
- AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
- AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
+[Components.IA32, Components.X64]
AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
+
+[Components.IA32]
AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
+ AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
+ AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
[Components.X64]
- AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
- AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf
+ AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
+
+# to make PcdSet64S working
+[PcdsDynamicDefault]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize|0x10000000
+
+[BuildOptions]
+ GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+ INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+ MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+
+ GCC:*_*_*_CC_FLAGS = -D USE_EDKII_HEADER_FILE
+
+ # Turn off DEBUG messages for Release Builds
+ GCC:RELEASE_*_*_CC_FLAGS = -D MDEPKG_NDEBUG
+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
+
diff --git a/Platform/AMD/AmdMinBoardPkg/Include/Library/AmdBoardBdsHookLib.h b/Platform/AMD/AmdMinBoardPkg/Include/Library/AmdBoardBdsHookLib.h
index 6bfa4747e061951106e3b466fac6366260311bfc..70683c2641aa32d82a1081ef190ac4e7277983bd 100644
--- a/Platform/AMD/AmdMinBoardPkg/Include/Library/AmdBoardBdsHookLib.h
+++ b/Platform/AMD/AmdMinBoardPkg/Include/Library/AmdBoardBdsHookLib.h
@@ -2,7 +2,7 @@
Header file for BDS Hook Library
Copyright (c) 2020, Intel Corporation. All rights reserved.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/Include/Ppi/TopOfTemporaryRam.h b/Platform/AMD/AmdMinBoardPkg/Include/Ppi/TopOfTemporaryRam.h
new file mode 100644
index 0000000000000000000000000000000000000000..5805bc184f62664481c71f978677c155a900259b
--- /dev/null
+++ b/Platform/AMD/AmdMinBoardPkg/Include/Ppi/TopOfTemporaryRam.h
@@ -0,0 +1,15 @@
+/** @file
+ Provides the pointer to top of temporary ram.
+
+ Copyright (c) 2014, Intel Corporation. All rights reserved.
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef TOP_OF_TEMPORARY_RAM_H_
+#define TOP_OF_TEMPORARY_RAM_H_
+
+extern EFI_GUID gTopOfTemporaryRamPpiGuid;
+
+#endif
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
index 5c950c4866d64d51b85920c0627cb7f79467d135..bddf1426b2c70bed671078432f58f409c6d28ed5 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
+++ b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHook.h
@@ -2,7 +2,7 @@
Header file for BDS Hook Library
Copyright (c) 2020, Intel Corporation. All rights reserved.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -68,14 +68,29 @@
#define STD_ERROR 0x00000002
#define CONSOLE_IN 0x00000004
#define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
-#define END_ENTIRE_DEVICE_PATH \
- { \
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
- }
extern EFI_GUID gUefiShellFileGuid;
extern EFI_BOOT_MODE gBootMode;
+#define gPciRootBridge \
+ { \
+ { \
+ ACPI_DEVICE_PATH, \
+ ACPI_DP, \
+ { \
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+ }, \
+ }, \
+ EISA_PNP_ID (0x0A03), \
+ 0 \
+ }
+
+#define gEndEntire \
+ { \
+ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
+ }
+
typedef struct {
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN ConnectType;
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index 3d7c0c2bf790f2cf37e2e34a786d5ce8d00d35a2..9739a40391582c2e6fcbf9388eb90bd46de20e90 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -3,7 +3,7 @@
implementation instance of the BDS hook library
Copyright (c) 2019, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -26,7 +26,6 @@
#include
#endif
-CHAR16 *mConsoleVar[] = { L"ConIn", L"ConOut" };
GLOBAL_REMOVE_IF_UNREFERENCED EFI_BOOT_MODE gBootMode;
BOOLEAN gPPRequireUIConfirm;
extern UINTN mBootMenuOptionNumber;
@@ -47,7 +46,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDev
SUBCLASS_BOOT, // DeviceSubClass
PROTOCOL_KEYBOARD // DeviceProtocol
},
- END_ENTIRE_DEVICE_PATH
+ gEndEntire
};
#ifdef INTERNAL_IDS
@@ -638,6 +637,7 @@ ConnectTrustedConsole (
UINTN Index;
EFI_HANDLE Handle;
EFI_STATUS Status;
+ CHAR16 *ConsoleVar[] = { L"ConIn", L"ConOut" };
VOID *TrustedConsoleDevicepath;
TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);
@@ -645,8 +645,8 @@ ConnectTrustedConsole (
TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);
DumpDevicePath (L"TrustedConsoleOut", TrustedConsoleDevicepath);
- for (Index = 0; Index < sizeof (mConsoleVar) / sizeof (mConsoleVar[0]); Index++) {
- GetEfiGlobalVariable2 (mConsoleVar[Index], (VOID **)&Consoles, NULL);
+ for (Index = 0; Index < sizeof (ConsoleVar) / sizeof (ConsoleVar[0]); Index++) {
+ GetEfiGlobalVariable2 (ConsoleVar[Index], (VOID **)&Consoles, NULL);
TempDevicePath = Consoles;
do {
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
index 23e834e332bee5bb06d86f6b97a4b96856e41a17..6f573b41bf8490afc0d19d34bf7ffef90ea804c1 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
@@ -18,85 +18,83 @@
[LibraryClasses]
BaseLib
+ MemoryAllocationLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
BaseMemoryLib
DebugLib
+ PcdLib
+ PrintLib
DevicePathLib
+ UefiLib
+ HobLib
DxeServicesLib
DxeServicesTableLib
HiiLib
- HobLib
- IpmiCommandLib
- IpmiLib
- MemoryAllocationLib
- PcdLib
+ UefiBootManagerLib
PerformanceLib
- PrintLib
- SortLib
- Tcg2PhysicalPresenceLib
TimerLib
- UefiBootManagerLib
- UefiBootServicesTableLib
- UefiLib
- UefiRuntimeServicesTableLib
+ Tcg2PhysicalPresenceLib
+ IpmiLib
+ IpmiCommandLib
+ SortLib
[Packages]
- AmdMinBoardPkg/AmdMinBoardPkg.dec
- BoardModulePkg/BoardModulePkg.dec
- IpmiFeaturePkg/IpmiFeaturePkg.dec
- ManageabilityPkg/ManageabilityPkg.dec
- MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
- MinPlatformPkg/MinPlatformPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
SecurityPkg/SecurityPkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+ BoardModulePkg/BoardModulePkg.dec
+ ManageabilityPkg/ManageabilityPkg.dec
+ AmdMinBoardPkg/AmdMinBoardPkg.dec
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
+ gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## PRODUCES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## PRODUCES
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut ## PRODUCES
- gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand ## PRODUCES
gMinPlatformPkgTokenSpaceGuid.PcdPlatformMemoryCheckLevel ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdShellFile ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdShellFileDesc ## CONSUMES
- gMinPlatformPkgTokenSpaceGuid.PcdTpm2Enable ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath ## CONSUMES
gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath ## CONSUMES
gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdShellFile ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdShellFileDesc ## CONSUMES
[Sources]
BoardBdsHook.h
BoardBdsHookLib.c
- BoardBootOption.c
BoardMemoryTest.c
+ BoardBootOption.c
[Protocols]
- gAmdBoardBdsBootOptionPriorityProtocolGuid ## CONSUMES
+ gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
+ gEfiPciIoProtocolGuid ## CONSUMES
gEfiCpuIo2ProtocolGuid ## CONSUMES
- gEfiDevicePathToTextProtocolGuid ## CONSUMES
- gEfiDiskInfoProtocolGuid ## CONSUMES
- gEfiDxeSmmReadyToLockProtocolGuid
gEfiDxeSmmReadyToLockProtocolGuid ## PRODUCES
+ gEfiGenericMemTestProtocolGuid ## CONSUMES
+ gEfiDiskInfoProtocolGuid ## CONSUMES
+ gEfiDevicePathToTextProtocolGuid ## CONSUMES
+ gEfiSimpleTextInputExProtocolGuid ## CONSUMES
gEfiFirmwareVolume2ProtocolGuid ## CONSUMES
gEfiFormBrowser2ProtocolGuid ## CONSUMES
gEfiGenericMemTestProtocolGuid ## CONSUMES
- gEfiGenericMemTestProtocolGuid ## CONSUMES
- gEfiPciIoProtocolGuid ## CONSUMES
- gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
- gEfiSimpleTextInputExProtocolGuid ## CONSUMES
-
+ gAmdBoardBdsBootOptionPriorityProtocolGuid ## CONSUMES
+ gEfiDxeSmmReadyToLockProtocolGuid
[Guids]
- gBdsEventAfterConsoleReadyBeforeBootOptionGuid
- gBdsEventBeforeConsoleAfterTrustedConsoleGuid
- gBdsEventBeforeConsoleBeforeEndOfDxeGuid
- gEfiEndOfDxeEventGroupGuid ## CONSUMES
gEfiGlobalVariableGuid ## PRODUCES
gEfiMemoryOverwriteControlDataGuid ## PRODUCES
+ gEfiEndOfDxeEventGroupGuid ## CONSUMES
+ gBdsEventBeforeConsoleAfterTrustedConsoleGuid
+ gBdsEventBeforeConsoleBeforeEndOfDxeGuid
+ gBdsEventAfterConsoleReadyBeforeBootOptionGuid
[Depex.common.DXE_DRIVER]
gEfiVariableArchProtocolGuid
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBootOption.c b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBootOption.c
index 16a47c2f8239bda6e43d81b86a1f7f2adfdfaf6d..837c2775ac28beea659034cb2f955e94b0373961 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBootOption.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardBootOption.c
@@ -2,7 +2,7 @@
Driver for Platform Boot Options support.
Copyright (c) 2019, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardMemoryTest.c b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardMemoryTest.c
index fff0ef299348e9b606314928b01bf988d79dc695..1969940c7be54d57c5919169921d9183c7580161 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardMemoryTest.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/BoardBdsHookLib/BoardMemoryTest.c
@@ -1,7 +1,7 @@
/** @file
Perform the platform memory test
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
Copyright (c) 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.c b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.c
index 7f3bf1b9fca0f93c6bc053cd0974b889a3d8d72d..69f2f58c9d82a8536fe8078cb1cf84dc9409ba51 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.c
@@ -1,7 +1,7 @@
/** @file
BoardInitLib library implementation for DXE phase.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -187,6 +187,30 @@ BoardInitReadyToBoot (
VOID
)
{
+ EFI_STATUS Status;
+
+ Status = UpdateReinstallAcpiTable (
+ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
+ (PATCH_ACPITABLE)FadtAcpiTablePatch
+ );
+ DEBUG ((DEBUG_INFO, "Patching FADT ACPI Table ... Status = %r.\n", Status));
+
+ Status = UpdateReinstallAcpiTable (
+ EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
+ (PATCH_ACPITABLE)MadtAcpiTablePatch
+ );
+ DEBUG ((DEBUG_INFO, "Patching MADT ACPI Table ... Status = %r.\n", Status));
+
+ UpdateReinstallAcpiTable (
+ EFI_ACPI_6_5_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ (PATCH_ACPITABLE)AcpiTableAmlUpdate
+ );
+
+ UpdateReinstallAcpiTable (
+ EFI_ACPI_6_5_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ (PATCH_ACPITABLE)AcpiTableAmlUpdate
+ );
+
return EFI_SUCCESS;
}
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
index 919777d0164e25ccfcfcf415ab5f1c786539520a..c526d09a9a2f4a62e559fa5fbaf2cf8fb3fb94b1 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLib.inf
@@ -1,7 +1,7 @@
## @file
# Implements BoardInitLib Library Class in DXE phase.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
@@ -29,14 +29,13 @@
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
MinPlatformPkg/MinPlatformPkg.dec
- PcAtChipsetPkg/PcAtChipsetPkg.dec
UefiCpuPkg/UefiCpuPkg.dec
[Sources]
DxeBoardInitLib.c
DxeBoardInitLibInternal.c
- DxeBoardInitLibInternal.h
MadtAcpiTablePatch.c
+ DxeBoardInitLibInternal.h
[Protocols]
gEfiAcpiSdtProtocolGuid
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.c b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.c
index 17bb46254585a3ad96276aeab43399ed97605234..a4c39125575b232b651d7fefd78c25d59b3f91a2 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.c
@@ -1,14 +1,181 @@
/** @file
BoardInitLib library internal implementation for DXE phase.
-Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "DxeBoardInitLibInternal.h"
/**
- Reserve Legacy VGA IO space.
+ A helper function to uninstall or update the ACPI table.
+ It searches for ACPI table for provided table signature,
+ if found then creates a copy of the table and calls the callbackfunction.
+
+ @param[in] Signature ACPI table signature
+ @param[in] CallbackFunction The function to call to patch the searching ACPI table.
+ If NULL then uninstalls the table.
+
+ @return EFI_SUCCESS Successfully Re-install the ACPI Table
+ @return EFI_NOT_FOUND Table not found
+ @return EFI_STATUS returns non-EFI_SUCCESS value in case of failure
+
+**/
+EFI_STATUS
+EFIAPI
+UpdateReinstallAcpiTable (
+ IN UINT32 Signature,
+ IN PATCH_ACPITABLE CallbackFunction
+ )
+{
+ EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol;
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_ACPI_SDT_HEADER *Table;
+ EFI_ACPI_TABLE_VERSION Version;
+ UINTN OriginalTableKey;
+ EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
+ EFI_ACPI_SDT_HEADER *NewTable;
+ UINTN NewTableKey;
+ BOOLEAN Found;
+
+ Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Error(%r): Unable to locate ACPI Table protocol.\n", Status));
+ return Status;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **)&AcpiSdtProtocol);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Error(%r): Unable to locate ACPI SDT protocol.\n", Status));
+ return Status;
+ }
+
+ Found = FALSE;
+ Index = 0;
+ do {
+ Status = AcpiSdtProtocol->GetAcpiTable (Index, &Table, &Version, &OriginalTableKey);
+ if (EFI_ERROR (Status)) {
+ goto END_OF_SEARCH;
+ }
+
+ // Look for given table
+ if (Table->Signature == Signature) {
+ if (CallbackFunction == NULL) {
+ Status = AcpiTableProtocol->UninstallAcpiTable (AcpiTableProtocol, OriginalTableKey);
+ return Status;
+ }
+
+ NewTable = AllocateCopyPool (Table->Length, Table);
+ if (NULL == NewTable) {
+ Status = EFI_OUT_OF_RESOURCES;
+ DEBUG ((DEBUG_ERROR, "Error(%r): Not enough resource to allocate table.\n", Status));
+ return Status;
+ }
+
+ Status = CallbackFunction (NewTable);
+ if (!EFI_ERROR (Status)) {
+ // Uninstall the old table
+ Status = AcpiTableProtocol->UninstallAcpiTable (AcpiTableProtocol, OriginalTableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Error(%r): Uninstall old table error.\n", Status));
+ FreePool (NewTable);
+ return Status;
+ }
+
+ // Install the new table
+ Status = AcpiTableProtocol->InstallAcpiTable (AcpiTableProtocol, NewTable, NewTable->Length, &NewTableKey);
+ FreePool (NewTable);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Error(%r): Failed to install new table.\n", Status));
+ return Status;
+ }
+
+ // If non SSDT table, then return status
+ if (Table->Signature != EFI_ACPI_6_5_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
+ return Status;
+ }
+
+ // Atleast one SSDT table update is success
+ Found = TRUE;
+ }
+
+ // continue to search next SSDT table.
+ Status = EFI_SUCCESS;
+ }
+
+ Index++;
+ } while (!EFI_ERROR (Status));
+
+END_OF_SEARCH:
+ if (!Found) {
+ DEBUG ((DEBUG_ERROR, "Error(%r): Unable to locate ACPI Table.\n", Status));
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ A Callback function to patch the ACPI FADT table.
+ Updates FADT table with AMD specific values, which
+ are different than MinPlatformPkg.
+
+ @param[in, out] NewTable Pointer to ACPI FADT table
+
+ @return EFI_SUCCESS Always return EFI_SUCCESSe
+
+**/
+EFI_STATUS
+EFIAPI
+FadtAcpiTablePatch (
+ IN OUT EFI_ACPI_SDT_HEADER *NewTable
+ )
+{
+ EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *NewFadt;
+
+ NewFadt = (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *)NewTable;
+ // Patch the Table
+ NewFadt->PLvl2Lat = 0x64;
+ NewFadt->Pm2CntLen = 0;
+ NewFadt->XGpe0Blk.RegisterBitWidth = 0x40;
+ NewFadt->FlushSize = 0x400;
+ NewFadt->FlushStride = 0x10;
+ NewFadt->XGpe1Blk.AccessSize = 0x01;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ A Callback function to patch the ACPI DSDT/SSDT table.
+ Which has ASL code that needs to be updated.
+
+ @param[in, out] NewTable Pointer to ACPI FADT table
+
+ @return EFI_SUCCESS If table is modified.
+ EFI_NOT_FOUND If table is not modified.
+
+**/
+EFI_STATUS
+EFIAPI
+AcpiTableAmlUpdate (
+ IN OUT EFI_ACPI_SDT_HEADER *NewTable
+ )
+{
+ UINT64 OemTableId;
+
+ if ((AsciiStrnCmp (NewTable->OemTableId, "AmdTable", 8) == 0)) {
+ DEBUG ((DEBUG_INFO, "Found (D/S)SDT table for patching OemTableId.\n"));
+ OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
+ CopyMem (NewTable->OemTableId, &OemTableId, 8);
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ Reserve Legay VGA IO space.
@retval EFI_SUCCESS MMIO at Legacy VGA region has been allocated.
@retval !EFI_SUCCESS Error allocating the legacy VGA region.
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.h b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.h
index f61619677a6930c878ad5b46fe7e9e5359851b09..fa6aca513f867348e5788b2add661b9f9f86f3e7 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.h
+++ b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/DxeBoardInitLibInternal.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -20,7 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include
#include
#include
-#include
+#include
#include
#include
@@ -86,7 +86,64 @@ EFI_STATUS
);
/**
- Reserve Legacy VGA IO space.
+ A helper function to update and re-install ACPI table.
+ It searh for ACPI table for provided table signature,
+ if found then creates a copy of the table and calls the callbackfunction.
+
+ @param[in] Signature ACPI table signature
+ @param[in] CallbackFunction The function to call to patch the searching ACPI table.
+
+ @return EFI_SUCCESS Successfully Re-install the ACPI Table
+ @return EFI_NOT_FOUND Table not found
+ @return EFI_STATUS returns non-EFI_SUCCESS value in case of failure
+
+**/
+EFI_STATUS
+EFIAPI
+UpdateReinstallAcpiTable (
+ IN UINT32 Signature,
+ IN PATCH_ACPITABLE CallbackFunction
+ );
+
+/**
+ A Callback function to patch the ACPI FADT table.
+ Updates FADT table with AMD specific values, which
+ are different than MinPlatformPkg.
+
+ @param[in, out] NewTable Pointer to ACPI FADT table
+
+ @return EFI_SUCCESS Always return EFI_SUCCESSe
+
+**/
+EFI_STATUS
+EFIAPI
+FadtAcpiTablePatch (
+ IN OUT EFI_ACPI_SDT_HEADER *NewTable
+ );
+
+EFI_STATUS
+EFIAPI
+MadtAcpiTablePatch (
+ IN OUT EFI_ACPI_SDT_HEADER *NewTable
+ );
+
+/**
+ A Callback function to patch the ACPI DSDT/SSDT table.
+ Which has ASL code that needs to be updated.
+
+ @param[in, out] NewTable Pointer to ACPI FADT table
+
+ @return EFI_SUCCESS Always return EFI_SUCCESSe
+
+**/
+EFI_STATUS
+EFIAPI
+AcpiTableAmlUpdate (
+ IN OUT EFI_ACPI_SDT_HEADER *NewTable
+ );
+
+/**
+ Reserve Legay VGA IO space.
@retval EFI_SUCCESS MMIO at Legacy VGA region has been allocated.
@retval !EFI_SUCCESS Error allocating the legacy VGA region.
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/MadtAcpiTablePatch.c b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/MadtAcpiTablePatch.c
index 555aab39889371b6b81c3573a634855e061d29be..dc4aaa79306a348b4f3de3af765bcc409ac80c7e 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/MadtAcpiTablePatch.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/DxeBoardInitLib/MadtAcpiTablePatch.c
@@ -1,7 +1,7 @@
/** @file
This file patches the ACPI MADT table for AMD specific values.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -94,6 +94,23 @@ SortByCcd (
return 0;
}
+/**
+ Function that determines whether SMT is enabled or disabled
+ based on CPU register values
+
+ @retval TRUE SMT Enabled
+ @retval FALSE SMT Disabled
+
+**/
+BOOLEAN
+IsSmtEnabled (VOID) {
+ UINT32 RegEbx = 0;
+
+ // Get SMT enable/disable info from CPUIDx8000001E_EBX[15:8]: 0 SMT off, 1 SMT on
+ AsmCpuid (0x8000001E, NULL, &RegEbx, NULL, NULL);
+ return ((BOOLEAN) (((RegEbx >> 8) & 0xFF) != 0));
+}
+
/**
A Callback function to patch the ACPI MADT table.
Updates MADT table with AMD specific values, which
@@ -232,10 +249,11 @@ MadtAcpiTablePatch (
} else {
Src++;
}
+
+ CopyMem (LocalX2ApicPtr, SortedItem, sizeof (EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC_STRUCTURE) * LapicCount);
+ FreePool (SortedItem);
}
- CopyMem (LocalX2ApicPtr, SortedItem, sizeof (EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC_STRUCTURE) * LapicCount);
- FreePool (SortedItem);
}
}
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/AmdMemoryInfoHob.h b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/AmdMemoryInfoHob.h
index b596b3bdf3feb4137b115b2d187d70950d907c4e..3aa1fe7d08b39b23c9f79636428280a0fdb7c7ff 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/AmdMemoryInfoHob.h
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/AmdMemoryInfoHob.h
@@ -1,7 +1,7 @@
/** @file
Defines AMD memory info hob.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.c b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.c
index af96969471ed42956a59534af8dcd2802b8c451e..f2f95b00da61c3a5f4fde39269b56e351ee7ccb7 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.c
@@ -1,7 +1,7 @@
/** @file
BoardInitLib library implementation for pre-mem PEI phase.
-Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
index 9f3cfd47c4fef480636955bafc00a5b1985b5377..737cdd55be1b7684dfc78f8bed2ff97a90afcb48 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiBoardInitPreMemLib.inf
@@ -1,7 +1,7 @@
## @file
# Board Init Library for AMD Platforms.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+# Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.c b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.c
index 74da0f3c8705accf7535487ae39d2bbbcf8fa34d..bdd135ac638691aa22995040e369bb2f06983c82 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -112,7 +112,7 @@ EndofAmdMemoryInfoHobPpiGuidCallBack (
break;
}
- if (AmdMemoryInfoRange->Size > 0) {
+ if (AmdMemoryInfoRange->Size) {
BuildResourceDescriptorHob (
EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_ATTRIBUTES,
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.h b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.h
index 726db2554314f75e218eeccf392be5ba0a066839..375c6adb13598e3ca3e75b90a1421802f19bc445 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.h
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiBoardInitPreMemLib/PeiMemoryInit.h
@@ -1,7 +1,7 @@
/** @file
This file contains definitions required for memory initialization in PEI phase.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c b/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c
index b19f33663d3012cc799a2bd0a5fb8c6d1f14bc9b..3abd7582bbb691ac171e7f8bfd60b2cb81e2c182 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.c
@@ -1,13 +1,17 @@
+/**
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved
+**/
+
/** @file
Source code file for Report Firmware Volume (FV) library for AMD platforms.
@par Note:
This source has the reference of MinPlatformPkgs's PeriReportFvLib.c module.
+**/
+/**
Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
-
**/
#include
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
index 23ee503c42bed0e6dbe2810bd6e991a8ea92a63a..7c6875386f46bc08669598c3b73407edbd8e66a3 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PeiReportFvLib/PeiReportFvLib.inf
@@ -1,8 +1,11 @@
+###
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+###
+
### @file
# Component information file for the Report Firmware Volume (FV) library.
#
# Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
-# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/AmdWrapperPlatformSecLib.c b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/AmdWrapperPlatformSecLib.c
index 32455fb0c51516d96d91d5d400cdc46b3f082fea..b18c945e86c98fe15944497c94a49b38d094b7f8 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/AmdWrapperPlatformSecLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/AmdWrapperPlatformSecLib.c
@@ -2,7 +2,7 @@
Sample to provide FSP wrapper platform sec related function.
Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -44,7 +44,7 @@ PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = {
EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI,
- &gAmdTopOfTemporaryRamPpiGuid,
+ &gTopOfTemporaryRamPpiGuid,
NULL // To be patched later.
},
{
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/AmdUefiStackNasm.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/AmdUefiStackNasm.inc
deleted file mode 100644
index 71e653f3ceeb2585ab730a386eab1b26a562bbe9..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/AmdUefiStackNasm.inc
+++ /dev/null
@@ -1,549 +0,0 @@
-;*****************************************************************************
-; AMD Generic Encapsulated Software Architecture
-;
-; Copyright (C) 2008 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Workfile: AmdUefiStackNasm.inc
-; $Revision$ $Date$
-;
-; Description: Code to setup temporary memory access for stack usage. This code
-; is to be used on memory present systems that do not need CAR
-;
-
-;============================================================================
-;
-; Define a macro that allow the OEM to specify supported solutions in the
-; cache-as-ram code. This will reduce the size of the assembled file.
-; The macro will convert solutions into supported families.
-;
-;============================================================================
-
-%include "CpStackNasm.inc"
-
-;======================================================================
-; Reference: UEFI PI v1.2 definition:
-;
-; typedef struct _UEFI_SEC_PEI_HAND_OFF {
-; UINT16 DataSize;
-; VOID *BootFirmwareVolumeBase;
-; UINTN BootFirmwareVolumeSize;
-; VOID *TemporaryRamBase;
-; UINTN TemporaryRamSize;
-; VOID *PeiTemporaryRamBase;
-; UINTN PeiTemporaryRamSize;
-; VOID *StackBase;
-; UINTN StackSize;
-; } UEFI_SEC_PEI_HAND_OFF;
-;
-struc UEFI_SEC_PEI_HAND_OFF
- .DATA_SIZE resw 1
- .ALIGNMENT_PAD resw 1
- .BOOT_FIRMWARE_VOLUME_BASE resd 1
- .BOOT_FIRMWARE_VOLUME_SIZE resd 1
- .TEMPORARY_RAM_BASE resd 1
- .TEMPORARY_RAM_SIZE resd 1
- .PEI_TEMPORARY_RAM_BASE resd 1
- .PEI_TEMPORARY_RAM_SIZE resd 1
- .STACK_BASE resd 1
- .STACK_SIZE resd 1
-endstruc
-
-; Assure build option is defined, default is BIST only storage
-%ifndef AMD_STACK_FRAME_PAD
-%define AMD_STACK_FRAME_PAD 0
-%endif
-
-
-;======================================================================
-;======================================================================
-; AMD_ENABLE_UEFI_STACK2: Setup a stack, heap & UEFI stack frame
-;
-; Input condition requirements:
-; 32bit protected 'flat addressing' mode
-; SS, DS, ES = segment descriptor defining 0x00000000 as the base.
-;
-; Build time options:
-; AMD_STACK_FRAME_PAD EQU 00h
-; used to create a Host Env stack frame for pseudo
-; global variables - a build time option. Incremented
-; by 4 to cover the BIST storage.
-;
-; Input Parameter:
-; StackLocation
-; STACK_AT_TOP
-; Indicate stack is on the top of cache as RAM.
-; STACK_AT_BOTTOM (default)
-; Indicate stack is at the bottom of cache as RAM.
-; BspStackSize = Stack size for BSP
-; BspStackAddr = Stack base address for BSP
-;
-; In:
-; EAX = BIST value collected after reset by host env
-; EBX = Return address (preserved)
-; ECX = size, in bytes, of the region to cache for execution.
-; EDX = base address of region to cache, or zero for (4GB - size).
-;
-; Out:
-; SS:ESP - Our new private stack location
-;
-; EAX = AGESA_STATUS
-; EDX = Return status code if EAX contains a return code of higher
-; severity than AGESA_SUCCESS
-; ECX = Stack size in bytes
-; EDI = pointer to stack frame location. Points to the
-; beginning of the UEFI structure defined by the
-; PI v1.2 spec. The Host Env stack frame follows
-; this structure.
-; [EDI]UEFI_SEC_PEI_HAND_OFF.BOOT_FIRMWARE_VOLUME_BASE = OEM_BFV_BASE
-; [EDI]UEFI_SEC_PEI_HAND_OFF.BOOT_FIRMWARE_VOLUME_SIZE = OEM_BFV_SIZE
-; [EDI+sizeof(UEFI_SEC_PEI_HAND_OFF)].OEM_DATA_DWORD[0] = BIST
-;
-; Preserved:
-; EBX, EBP, DS, ES, SS
-;
-; Destroyed:
-; EAX, ECX, EDX, EDI, ESI, ESP
-; MMX0, MMX1, MMX2, MMX3, MMX4, MMX5 ... MMX[0..7] are used as save/restore storage
-;
-; Known Limitations:
-; *!* This routine presently is limited to a max of 64 processor cores
-;
-; Description:
-; This procedure will do the following:
-; - allocate pre-defined address space for use as a stack for C code
-; - allocate pre-defined address space for use as a UEFI heap
-; - enable execution cache for a specified region
-; - create an instance of the UEFI structure UEFI_SEC_PEI_HAND_OFF on the
-; stack and populate it with values.
-;
-; Stack Allocation:
-; Note: At present, the stack allocation is the same as described above in AMD_ENABLE_STACK_PRIVATE.
-; In fact, this macro uses that macro to perform the allocation.
-; The same 64 core limit applies to this implementation.
-; Future versions of this macro will expand support to 80+ cores.
-; Stack allocation will be 64k for the BSP, 16K for all APs.
-; ESP is set to point below the HostEnv stack frame.
-;
-; Heap Allocation:
-; Note: At present, only the BSP will be allocated space for a UEFI heap.
-; Future versions of this macro will allcate 48K for each AP and the
-; allocation for the BSP will vary for the size of the L2 present and
-; the number of cores sharing the L2; maximizing the BSP allocation.
-;
-; Execution cache:
-; The code will use Variable MTRRs 6 and 7 to define an area of memory
-; enabled for execution cache. This is presumed to include the PEI core
-; code area. The allocation is presummed to be at top-of-4G address range
-; so the smaller block, if one exists, will be allocated at the base
-; parameter (edx) and the larger block just after (edx+sizeof(smaller block))
-;
-; HostEnv UEFI stack frame:
-; The code will create a stack data frame containing:
-; * a Host Env specific area for pseudo global variables.
-; o This area is at 'bottom (defalult)' so as to be retained if the PEI core decides
-; to reset the stack.
-; o The first entry in this area is the BIST value.
-; * an SEC-PEI hand-off structure (PI v1.2)
-; o populated with the stack and Temporary RAM entries.
-; o A processor's stack and heap are contiguous, with stack on 'top'.
-;
-;======================================================================
-%macro AMD_ENABLE_UEFI_STACK2 2-3
-
- movd mm1, ebp ; Save user requested register
- movd mm0, ebx ; Logically 'push' the input parameters ( return address )
- movd mm2, eax ; ( BIST )
- movd mm3, ecx ; ( cache zone size )
- movd mm4, edx ; ( cache zone base )
-
- ; Short term method - need to accommodate existance of UEFI heap AND the AGESA heap.
- ; So, use the old stack allocation process for stack, then mimick current UEFI (~v0.9)
- ; operation to fill in the data stack frame.
- %if (%0 = 3)
- AMD_ENABLE_STACK_PRIVATE %1, %2, %3
- %else
- AMD_ENABLE_STACK_PRIVATE STACK_AT_BOTTOM, %1, %2
- %endif
- cmp eax, AGESA_SUCCESS ; Abort if not first entry; future versions will not allow multi-entry
- jne %%AmdEnableUefiStackAbort
-
- ; review:
- ; EAX = AGESA_STATUS
- ; EDX = Return status code if EAX contains a return code of higher
- ; severity than AGESA_SUCCESS
- ; ECX = Stack size in bytes
- ; ebx - return address parameter
- ; ebp - user preserved register
- ; ss:esp - stack pointer
- ;
- ; esi - address of start of stack block
- ; [esp] - stack base address
- ; [esp+4] - size of stack
- ; [esp+8] - Marker for top-of-stack
- ; mm0 - user return address
- ; mm1 - user saved EBP register content
- ; mm2 - BIST value
- ; mm3 - cache zone size
- ; mm5 - 32b pointer to family info struc. Set by GET_NODE_ID_CORE_ID_Fxx macros
-
- ; calculate stack frame pointer
-
- mov ebp, [esp]
- mov edx, ebp ; save stack base to edx
-
- ; for BSC, we divide the memory allocation zone in half and allocate 1/2 to each of stack & UEFI heap
- ; for APs, we allocate whole allocation to stack
- IS_BSC
- _if carry
- %if (%0 = 3)
- %if (%1 = STACK_AT_BOTTOM)
- shr ecx, 1
- add ebp, ecx
- shl ecx, 1
- %else
- add ebp, ecx
- %endif
- %else
- shr ecx, 1
- add ebp, ecx
- shl ecx, 1
- %endif
- _else
- add ebp, ecx
- _endif
- sub ebp, (4 + AMD_STACK_FRAME_PAD) ; space for BIST and additional OEM data
- movd eax, mm2 ; retrieve BIST data OEM acquired after reset
- mov [ebp], eax ; place BIST data into first OEM data DWORD
- sub ebp, UEFI_SEC_PEI_HAND_OFF_size ; space for UEFI structure storage
- mov eax, edx ; retrieve memory base address for passing on
- mov esp, ebp ; now can update the esp
- ; fill the UEFI stack frame
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.TEMPORARY_RAM_BASE], eax
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.TEMPORARY_RAM_SIZE], ecx
- mov word [ebp + UEFI_SEC_PEI_HAND_OFF.DATA_SIZE], UEFI_SEC_PEI_HAND_OFF_size
-
- ; for BSC, we divide the memory zone in half and allocate 1/2 to each of stack & UEFI heap
- IS_BSC
- _if carry
- push ecx
- shr ecx, 1 ; divide the memory zone in half and allocate 1/2 to each of stack & UEFI heap
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_SIZE], ecx
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_SIZE], ecx
-
- %if (%0 = 3)
- %if (%1 = STACK_AT_BOTTOM)
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_BASE], eax
- add eax, ecx ; put PEI temporary RAM base in upper half
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_BASE], eax
- %else
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_BASE], eax
- add eax, ecx ; put stack base in upper half
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_BASE], eax
- %endif
- %else
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_BASE], eax
- add eax, ecx ; put PEI temporary RAM base in upper half
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_BASE], eax
- %endif
- pop ecx
- _else
- ; for APs, we allocate whole memory to stack
- mov dword [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_BASE], 0
- mov dword [ebp + UEFI_SEC_PEI_HAND_OFF.PEI_TEMPORARY_RAM_SIZE], 0
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_SIZE], ecx
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.STACK_BASE], eax
- _endif
-
- ; we will use the cache zone as implied BFV,
- ; The OEM is free to override this from their code that follows
- movd eax, mm3 ; cache zone size
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.BOOT_FIRMWARE_VOLUME_SIZE], eax
-
- ; calculate the base from size
- movd ebx, mm4
- _if ebx, e, 0
- sub ebx, eax
- movd mm4, ebx
- _endif
- mov [ebp + UEFI_SEC_PEI_HAND_OFF.BOOT_FIRMWARE_VOLUME_BASE], ebx
-
- ; Round up the size if there are more than 2 bits set in the given cache zone size
- push edx
- push ecx
- push eax
-
- bsr ecx, eax
- _if nzero
- btr eax, ecx ; there is one bit set in the given cache zone size
- bsr ecx, eax
- _if nzero
- push ecx
- btr eax, ecx ; there are two bits set in the given cache zone size
- bsr ecx, eax
- _if nzero
- pop ecx ; ecx is the index of second bit set from most-significant
- pop eax ; eax is the given cache zone size
-
- xor edx, edx
- bts edx, ecx
- add eax, edx ; round up the size
- dec edx
- bts edx, ecx ; former 2nd bit spot should now be =0, clear it also
- not edx
- and eax, edx ; now, eax has two bits set at most, could have only one
-
- push eax
- _else
- pop ecx ; balance the stack
- _endif
- _endif
- _endif
-
- pop eax
- pop ecx
- pop edx
- movd mm3, eax ; update cache zone size
-
- ; Check for and apply any family size limits.
- movd edi, mm5
- mov bx, [edi + CPU_FAMILY_INFO.L2_ALLOC_EXE]
-
- _if bx, a, 0 ; if there is a family limit
- ; CPUID will destroyed EAX, EBX, ECX, EDX
- ; but we only want to preserve EAX, ECX, EDX
- push eax
- push ecx
- push edx
-
- ; get L2 allocate execution cache = CPU_FAMILY_INFO.L2_ALLOC_EXE + (L2 cache size - CPU_FAMILY_INFO.L2_MIN_SIZE)
- AMD_CPUID AMD_CPUID_L2Cache
- shr ecx, 16 ; CX = L2 cache size
- sub cx, [edi + CPU_FAMILY_INFO.L2_MIN_SIZE] ; CX = additional L2 size to the family limit
- mov bx, [edi + CPU_FAMILY_INFO.L2_ALLOC_EXE] ; use the additional L2 for exe cache
- add bx, cx
-
- ; restore EAX, ECX, EDX
- pop edx
- pop ecx
- pop eax
-
- movzx ebx, bx ; convert the limit from K to Bytes
- shl ebx, 10
- _if eax, a, ebx ; enforce the family limit
- ; note: SEC-PEI data is NOT updated on purpose, to allow the PEI
- ; to see the full intended zone as the BFV
-
-
- mov eax, ebx ; set size to family limit
- movd mm3, eax ; update cache zone size
- _endif
- _endif
-
- ; base = 4G - size
-; push edx
-; xor edx, edx
-; sub edx, eax
-; movd mm4, edx
-; pop edx
- ; review:
- ; eax - Cache zone size
- ; ebx -
- ; ecx - Stack size in bytes
- ; edx - Return status code if EAX contains a return code of higher
- ; severity than AGESA_SUCCESS
- ; ebp - Stack Frame pointer
- ;
- ; esi - address of start of stack block
- ; mm0 - user return address
- ; mm1 - user saved EBP register content
- ; mm3 - cache zone size
- ; mm4 - cache zone base
- ; mm5 - 32b pointer to family info struc. Set by GET_NODE_ID_CORE_ID_Fxx macros
-
- ; Cross check the cache zone for proper base/length values,
- push edx
- push ecx
-
- and eax, 0FFFF8000h ; size must be >= 32K
-
- ; Size a Power of Two? We can pull the two largest blocks from the size
- ; then set first avaible vMTRR to cover those blocks of the zone. The zone is presumed
- ; to be at the top of 4G memory space, so the blocks are allocated in a
- ; 'top down' manner, smaller first at base address then the larger.
- bsr ecx, eax
- _if nzero ; Is parameter non-zero?
- push ecx ; save size of larger block
- btr eax, ecx ; reduce zone size by 1st 2**N
- push eax
-
- ; skip vMTRR setting if it's not a primary thread
- pushad
- AMD_CPUID CPUID_MODEL
- shr ebx, LOCAL_APIC_ID
- and ebx, 0FFh ; ebx - initial local APIC physical ID
- push ebx
-
- AMD_CPUID AMD_CPUID_EXT_APIC
-
- pop eax ; eax - initial local APIC physical ID
- shr ebx, 8
- and ebx, 0FFh
- inc bl ; bl - ThreadsPerCore
- div bl
- cmp ah, 0
- popad
- jnz %%AmdSkipvMtrrSetting
-
- ; calculate upper mask value - needs to match the CPU address bus size
- movzx ax, [edi + CPU_FAMILY_INFO.SIZE_ADDRESS_BUS]
- movzx eax, ax
- xor edx, edx
-
- ; find out the first vMTRR which is available
- push eax
- push ecx
- push edx
- mov ecx, AMD_MTRR_VARIABLE_MASK0
- _while ecx, be, AMD_MTRR_VARIABLE_MASK7
- rdmsr
- _if eax, e, 0
- mov edi, ecx
- dec edi ; now edi points to AMD_MTRR_VARIABLE_BASEx
- jmp %%AmdvMtrrFound
- _endif
- add ecx, 2
- _endw
-%%AmdvMtrrFound:
- pop edx
- pop ecx
- pop eax
- _if edi, a, AMD_MTRR_VARIABLE_BASE7
- jmp %%AmdSkipvMtrrSetting ; There's no enough vMTRR register pairs for ROM cache
- _endif
-
-
- _if al, be, 64
- bts edx, eax
- _endif
- dec edx ; edx = upper mask (e.g. 0x000FFFFF)
- pop eax ; retrieve zone size (minus large block)
- bsr ecx, eax
- _if nzero
- push edx ; save upper mask, make room to calc new base
- ; set vMTRR[x] for Smaller block, if it exists
- xor ebx, ebx
- dec ebx ; ebx = all ones
- btr ebx, ecx
- inc ebx ; ebx = MTRR mask ( e.g 0xFFF80000)
- movd eax, mm4 ; cache zone base
- and eax, ebx ; use mask to align base
- xor edx, edx
- bts edx, ecx ; edx = block size
- add edx, eax ; add block size to base - for next block's base
- movd mm4, edx ; update stored base value
- mov al, MTRR_TYPE_WP
- mov ecx, edi ; use vMTRR pair # which is found above
- add edi, 2 ; point to the next vMTRR
- xor edx, edx ; clear upper base
- wrmsr ; set the vMTRR[6] Base
- mov eax, ebx ; now build the mask
- pop edx ; retrieve upper mask value
- bts eax, VMTRR_VALID
- inc ecx
- wrmsr ; set the vMTRR[6] Mask + Valid
- _endif ; Any remaining size is abandoned. We can only use 2 vMTRRs
- pop ecx ; retrieve size of larger block
- push edx ; save upper mask value
- ; set vMTRR[x + 1] for Larger block, if it exists
- _if edi, a, AMD_MTRR_VARIABLE_BASE7
- jmp %%AmdSkipvMtrrSetting ; There's no enough vMTRR register pairs for ROM cache
- _endif
-
- xor ebx, ebx
- dec ebx ; ebx=all ones
- btr ebx, ecx
- inc ebx ; ebx = MTRR mask ( e.g 0xFFF00000)
- movd eax, mm4 ; cache zone base
- and eax, ebx ; use mask to align base
- xor edx, edx ; clear upper base
- mov al, MTRR_TYPE_WP
- mov ecx, edi
- wrmsr ; set the vMTRR[7] Base
- mov eax, ebx ; now build the mask
- bts eax, VMTRR_VALID
- pop edx ; retrieve upper mask value
- inc ecx
- wrmsr ; set the vMTRR[7] Mask + Valid
- _endif
-
- ; prepare to exit
-%%AmdSkipvMtrrSetting:
- mov edi, ebp ; place stack frame pointer for return
- movd ebp, mm1 ; Restore saved user requested register
- movd ebx, mm0 ; and the return address
-
- pop ecx
- pop edx
- mov eax, AGESA_SUCCESS
-%%AmdEnableUefiStackAbort:
-%endmacro
-
-
-;======================================================================
-; AMD_DISABLE_UEFI_STACK2: Dismantle the pre-memory cache-as-RAM mode.
-;
-; In:
-; EBX = Return address (preserved)
-;
-; Out:
-; EAX = AGESA_SUCCESS
-;
-; Description:
-; It is expected that the UEFI PEI core has relocated the stack to main
-; RAM by this time and the MTRR map has been sync'd. Therefore, this
-; routine will not modify the MTRR settings; but rather, just disable
-; the CAR mode. Cache tags will be invalidated.
-;
-; Preserved:
-; ebx, esp
-; Destroyed:
-; eax, ebx, ecx, edx, esi, ebp
-;======================================================================
-%macro AMD_DISABLE_UEFI_STACK2 0
-
- mov ebp, ebx ; Save return address
-
- ; get node/core/flags of current executing core
- GET_NODE_ID_CORE_ID ; Sets ESI[15,8]= Node#; ESI[7,0]= core# (relative to node); flags
-
- AMD_DISABLE_STACK_FAMILY_HOOK ; Re-Enable 'normal' cache operations
-
- mov ebx, ebp ; restore return address (ebx)
- xor eax, AGESA_SUCCESS
-
-%endmacro
-
-;======================================================================
-; IS_BSC: Determine if this is Boot Strap Core
-;
-; In:
-; NULL
-;
-; Out:
-; CF = 1, it's BSC
-; CF = 0, it's AP
-;
-; Destroyed:
-; CF
-;======================================================================
-%macro IS_BSC 0
- pushad
- mov ecx, APIC_BASE_ADDRESS ; MSR:0000_001B
- rdmsr
- bt eax, APIC_BSC ; Is this the BSC?
- popad
-
-%endmacro
-
-
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackHooksNasm.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackHooksNasm.inc
deleted file mode 100644
index 024939189c5c7f9eb0ae1fb83ea41a0324d0c44f..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackHooksNasm.inc
+++ /dev/null
@@ -1,452 +0,0 @@
-;*****************************************************************************
-; AMD Generic Encapsulated Software Architecture
-;
-; Copyright (C) 2008 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; $Workfile:: CpStackHooksNasm.inc
-; $Revision$ $Date$
-;
-; Description: CpStackHooksNasm.inc - AGESA stack setup family hooks
-;
-
-%include "NasmBase.inc"
-
-%define STACK_SIZE_4M 400000h ; 4MB
-%define STACK_SIZE_2M 200000h ; 2MB
-%define STACK_SIZE_1M 100000h ; 1MB
-%define STACK_SIZE_256K 40000h ; 256KB
-%define STACK_SIZE_192K 30000h ; 192KB
-%define STACK_SIZE_128K 20000h ; 128KB
-%define STACK_SIZE_64K 10000h ; 64KB
-%define STACK_SIZE_32K 8000h ; 32KB
-%define STACK_SIZE_16K 4000h ; 16KB
-%define STACK_SIZE_4K 1000h ; 4KB
-
-%define CORE0_STACK_SIZE STACK_SIZE_16K ; 16KB for primary cores
-%define CORE1_STACK_SIZE STACK_SIZE_4K ; 4KB for each AP cores
-
-%define BSP_STACK_BASE_ADDR 30000h ; Base address for core 0 stack
-%define BSP_STACK_BASE_ADDR_4M 400000h ; Base address at 4MB
-%define CORE0_STACK_BASE_ADDR 80000h ; Base address for primary cores stack
-;
-;CORE1_STACK_BASE_ADDR = BSP_STACK_BASE_ADDR + BSP_STACK_SIZE
-;
-%define BSP_CACHE_TYPE_POSITION 3
-
-;============================================================================
-;
-; Define a macro that allow the exclusion of processor families from
-; the cache-as-ram code. This will reduce the size of the assembled file.
-;
-;============================================================================
-
-;---------------------------------------------------
-;
-; AMD_ENABLE_STACK_FAMILY_HOOK Macro - Stackless
-;
-; Set any family specific controls needed to enable the use of
-; cache as general storage before main memory is available.
-;
-; Inputs:
-; ESI - node#, core#, flags from GET_NODE_ID_CORE_ID
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;---------------------------------------------------
-%macro AMD_ENABLE_STACK_FAMILY_HOOK 0
-
- AMD_ENABLE_STACK_FAMILY_HOOK_F19
- AMD_ENABLE_STACK_FAMILY_HOOK_F1A
-
-%endmacro
-
-;----------------------------------------------
-;
-; AMD_DISABLE_STACK_FAMILY_HOOK Macro - Stackless
-;
-; Return any family specific controls to their 'standard'
-; settings for using cache with main memory.
-;
-; Inputs:
-; ESI - node#, core#, flags from GET_NODE_ID_CORE_ID
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;----------------------------------------------
-%macro AMD_DISABLE_STACK_FAMILY_HOOK 0
-
- AMD_DISABLE_STACK_FAMILY_HOOK_F19
- AMD_DISABLE_STACK_FAMILY_HOOK_F1A
-
-%endmacro
-
-;---------------------------------------------------
-;
-; GET_NODE_ID_CORE_ID Macro - Stackless
-;
-; Read family specific values to determine the node and core
-; numbers for the core executing this code.
-;
-; Inputs:
-; none
-; Outputs:
-; SI[7:0] = Core# (0..N, relative to node)
-; SI[15:8]= Node# (0..N)
-; SI[23:16]= reserved
-; SI[24]= flag: 1=Family Unrecognized
-; SI[25]= flag: 1=Interface re-entry call
-; SI[26]= flag: 1=Core is primary of compute unit
-; SI[31:27]= reserved, =0
-;
-; Destroyed:
-; eax, ebx, ecx, edx, esi
-;---------------------------------------------------
-%macro GET_NODE_ID_CORE_ID 0
-
- mov si, -1
- GET_NODE_ID_CORE_ID_F19
- GET_NODE_ID_CORE_ID_F1A
-
- ;
- ; Check for unrecognized Family
- ;
- _if si, e, -1 ; Has family (node/core) been discovered?
- mov esi, ( (1 << FLAG_UNKNOWN_FAMILY)+(1 << FLAG_IS_PRIMARY) ) ; No, Set error code, Only let BSP continue
- mov ecx, APIC_BASE_ADDRESS ; MSR:0000_001B
- rdmsr
- bt eax, APIC_BSC ; Is this the BSC?
- _if ncarry
- ;
- ; No, this is an AP
- ;
- hlt ; Kill APs
- _endif
- _endif
-%endmacro
-
-;;***************************************************************************
-;; Family 19h MACROS
-;;***************************************************************************
-;---------------------------------------------------
-;
-; AMD_ENABLE_STACK_FAMILY_HOOK_F19 Macro - Stackless
-;
-; Set any family specific controls needed to enable the use of
-; cache as general storage before main memory is available.
-;
-; Inputs:
-; ESI - node#, core#, flags from GET_NODE_ID_CORE_ID
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;---------------------------------------------------
-%macro AMD_ENABLE_STACK_FAMILY_HOOK_F19 0
-
- AMD_CPUID CPUID_MODEL
- mov ebx, eax ; Save revision info to EBX
- shr eax, 20 ; AL = cpu extended family
- cmp al, 0Ah ; Is this family 19h?
- jnz %%fam19_enable_stack_hook_exit ; Br if no
-
- ;
- ; Set TOP_MEM (C001_001A) for non-shared cores to 16M. This will be increased at heap init.
- ; - not strictly needed since the FixedMTRRs take presedence.
- ;
- mov ecx, TOP_MEM ; MSR:C001_001A
- rdmsr
- test eax, eax
- _if zero
- dec eax
- wrmsr
- _endif
-
-%%fam19_enable_stack_hook_exit:
-%endmacro
-
-;----------------------------------------------
-;
-; AMD_DISABLE_STACK_FAMILY_HOOK_F19 Macro - Stackless
-;
-; Return any family specific controls to their 'standard'
-; settings for using cache with main memory.
-;
-; Inputs:
-; ESI - [31:24] flags; [15:8]= Node#; [7:0]= core#
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;---------------------------------------------------
-%macro AMD_DISABLE_STACK_FAMILY_HOOK_F19 0
-
- AMD_CPUID CPUID_MODEL
- mov ebx, eax ; Save revision info to EBX
- shr eax, 20 ; AL = cpu extended family
- cmp al, 0Ah ; Is this family 19h?
- jnz %%fam19_disable_stack_hook_exit ; Br if no
-
-%%fam19_disable_stack_hook_exit:
-%endmacro
-
-;---------------------------------------------------
-;
-; GET_NODE_ID_CORE_ID_F19 Macro - Stackless
-;
-; Read family specific values to determine the node and core
-; numbers for the core executing this code.
-;
-; Inputs:
-; none
-; Outputs:
-; ESI = core#, node# & flags (see GET_NODE_ID_CORE_ID macro above)
-; MM5 = 32b pointer to family info structure
-; Destroyed:
-; eax, ebx, ecx, edx, esi, mm5
-;---------------------------------------------------
-%macro GET_NODE_ID_CORE_ID_F19 0
-
- jmp %%end_of_f19h_data
- ; Family 19h Info Structure: L2Size, #SharedCores, AllocMem, AllocExe, SzAddrBus, pad
- %%FAM19H_INFO_STRUCT istruc CPU_FAMILY_INFO
- at CPU_FAMILY_INFO.L2_MIN_SIZE, dw 2048
- at CPU_FAMILY_INFO.NUM_SHARED_CORES, db 2
- at CPU_FAMILY_INFO.L2_ALLOC_MEM, db 0
- at CPU_FAMILY_INFO.L2_ALLOC_EXE, dw 0
- at CPU_FAMILY_INFO.SIZE_ADDRESS_BUS, db 48
- at CPU_FAMILY_INFO.FAMILY_RESERVED, db 0
- iend
-%%end_of_f19h_data:
- jmp %%end_of_f19h_zen4_data
- ; Family 19h Info Structure: L2Size, #SharedCores, AllocMem, AllocExe, SzAddrBus, pad
- %%FAM19H_ZEN4_INFO_STRUCT istruc CPU_FAMILY_INFO
- at CPU_FAMILY_INFO.L2_MIN_SIZE, dw 2048
- at CPU_FAMILY_INFO.NUM_SHARED_CORES, db 2
- at CPU_FAMILY_INFO.L2_ALLOC_MEM, db 0
- at CPU_FAMILY_INFO.L2_ALLOC_EXE, dw 0
- at CPU_FAMILY_INFO.SIZE_ADDRESS_BUS, db 52
- at CPU_FAMILY_INFO.FAMILY_RESERVED, db 0
- iend
-%%end_of_f19h_zen4_data:
-
- cmp si, -1 ; Has node/core already been discovered?
- jnz %%node_core_f19_exit ; Br if yes
-
- AMD_CPUID CPUID_MODEL
- shr ebx, 16 ; BH = LocalApicId
- mov bl, al
- shr bl, 4 ; BL = cpu basic model
- shr eax, 12 ; AH = cpu extended family
- cmp ah, 0Ah ; Is this family 19h?
- jnz %%node_core_f19_exit ; Br if no
- or bl, al ; BL = cpu model
-
- cmp bl, 010h ; Is this RS
- jz %%load_family_19_zen4_info ; Br if yes
- cmp bl, 011h ; Is this RS B0
- jz %%load_family_19_zen4_info ; Br if yes
- cmp bl, 018h ; Is this STP
- jz %%load_family_19_zen4_info ; Br if yes
- cmp bl, 0A0h ; Is this Bergamo
- jz %%load_family_19_zen4_info ; Br if yes
- jmp %%load_family_19_info
-
-%%load_family_19_zen4_info:
- ; TODO, Need to check whether 52 bus is enabled or not
- ; Assuming its enabled
- LoadTableAddress %%FAM19H_ZEN4_INFO_STRUCT
- jmp %%load_family_19_end
-%%load_family_19_info:
- LoadTableAddress %%FAM19H_INFO_STRUCT
-%%load_family_19_end:
- movd mm5, eax ; load pointer to Family Info Struc
-
- xor esi, esi ; Assume BSC, clear local flags
- mov ecx, APIC_BASE_ADDRESS ; MSR:0000_001B
- rdmsr
- bt eax, APIC_BSC ; Is this the BSC?
- _if ncarry
- shr bx, 4
- shr bl, 4
- mov si, bx ; SI = [15:8]= Node# = 0; [7:0]= core#
- _endif ; end
-
- ;
- ; determine if this core shares MTRRs
- ;
-
- AMD_CPUID AMD_CPUID_EXT_APIC
- _if bh, ne, 0
- bt si, 0
- _if ncarry
- bts esi, FLAG_IS_PRIMARY ; Set shared flag into return value
- _endif
- _else
- bts esi, FLAG_IS_PRIMARY ; Set shared flag into return value
- _endif
-
- bts esi, FLAG_DRAM_AVAILABLE
-%%node_core_f19_exit:
-%endmacro
-
-;;***************************************************************************
-;; Family 1Ah MACROS
-;;***************************************************************************
-;---------------------------------------------------
-;
-; AMD_ENABLE_STACK_FAMILY_HOOK_F1A Macro - Stackless
-;
-; Set any family specific controls needed to enable the use of
-; cache as general storage before main memory is available.
-;
-; Inputs:
-; ESI - node#, core#, flags from GET_NODE_ID_CORE_ID
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;
-;---------------------------------------------------
-%macro AMD_ENABLE_STACK_FAMILY_HOOK_F1A 0
-
- AMD_CPUID CPUID_MODEL
- mov ebx, eax ; Save revision info to EBX
- shr eax, EXT_FAMILY ; AL = cpu extended family
- cmp al, 0bh ; Is this family 1Ah?
- jnz %%fam1A_enable_stack_hook_exit ; Br if no
-
- ;
- ; Set TOP_MEM (C001_001A) for non-shared cores to 16M. This will be increased at heap init.
- ; - not strictly needed since the FixedMTRRs take presedence.
- ;
- mov ecx, TOP_MEM ; MSR:C001_001A
- rdmsr
- test eax, eax
-
- _if zero
- dec eax
- wrmsr
- _endif
-
-%%fam1A_enable_stack_hook_exit:
-%endmacro
-
-;----------------------------------------------
-;
-; AMD_DISABLE_STACK_FAMILY_HOOK_F1A Macro - Stackless
-;
-; Return any family specific controls to their 'standard'
-; settings for using cache with main memory.
-;
-; Inputs:
-; ESI - [31:24] flags; [15:8]= Node#; [7:0]= core#
-; Outputs:
-; none
-; Destroyed:
-; eax, ebx, ecx, edx
-;
-;---------------------------------------------------
-%macro AMD_DISABLE_STACK_FAMILY_HOOK_F1A 0
-
- AMD_CPUID CPUID_MODEL
- mov ebx, eax ; Save revision info to EBX
- shr eax, EXT_FAMILY ; AL = cpu extended family
- cmp al, 0bh ; Is this family 1ah?
- jnz %%fam1A_disable_stack_hook_exit ; Br if no
-
-%%fam1A_disable_stack_hook_exit:
-%endmacro
-
-;---------------------------------------------------
-;
-; GET_NODE_ID_CORE_ID_F1A Macro - Stackless
-;
-; Read family specific values to determine the node and core
-; numbers for the core executing this code.
-;
-; Inputs:
-; none
-; Outputs:
-; ESI = core#, node# & flags (see GET_NODE_ID_CORE_ID macro above)
-; MM5 = 32b pointer to family info structure
-;
-; Destroyed:
-; eax, ebx, ecx, edx, esi, mm5
-;---------------------------------------------------
-%macro GET_NODE_ID_CORE_ID_F1A 0
-
- jmp %%end_of_f1ah_48bit_data
-
- ; Family 1Ah Info Structure for 48 bits bus: L2Size, #SharedCores, AllocMem, AllocExe, SzAddrBus, pad
- %%FAM1AH_48BIT_INFO_STRUCT istruc CPU_FAMILY_INFO
- at CPU_FAMILY_INFO.L2_MIN_SIZE, dw 2048
- at CPU_FAMILY_INFO.NUM_SHARED_CORES, db 2
- at CPU_FAMILY_INFO.L2_ALLOC_MEM, db 0
- at CPU_FAMILY_INFO.L2_ALLOC_EXE, dw 0
- at CPU_FAMILY_INFO.SIZE_ADDRESS_BUS, db 48
- at CPU_FAMILY_INFO.FAMILY_RESERVED, db 0
-%%end_of_f1ah_48bit_data:
- jmp %%end_of_f1ah_52bit_data
-
- ; Family 1Ah Info Structure for 52 bits bus: L2Size, #SharedCores, AllocMem, AllocExe, SzAddrBus, pad
- %%FAM1AH_52BIT_INFO_STRUCT istruc CPU_FAMILY_INFO
- at CPU_FAMILY_INFO.L2_MIN_SIZE, dw 2048
- at CPU_FAMILY_INFO.NUM_SHARED_CORES, db 2
- at CPU_FAMILY_INFO.L2_ALLOC_MEM, db 0
- at CPU_FAMILY_INFO.L2_ALLOC_EXE, dw 0
- at CPU_FAMILY_INFO.SIZE_ADDRESS_BUS, db 52
- at CPU_FAMILY_INFO.FAMILY_RESERVED, db 0
-%%end_of_f1ah_52bit_data:
-
- cmp si, -1 ; Has node/core already been discovered?
- jnz %%node_core_f1A_exit ; Br if yes
-
- AMD_CPUID AMD_CPUID_CAP_EXT ; CPUID function 8000_0008h
- and eax, PHYSICAL_ADDR_MASK ;
- cmp al, 52 ; If the maximum physical address is 52 bits.
- je %%load_family_1a_52bit_info ; Load 52-bit table if PAE is set
-
- ; Load 48-bit table.
- LoadTableAddress %%FAM1AH_48BIT_INFO_STRUCT
- jmp %%load_family_1a_info_end
-
-%%load_family_1a_52bit_info:
- ; Load 52-bit table.
- LoadTableAddress %%FAM1AH_52BIT_INFO_STRUCT
-
-%%load_family_1a_info_end:
- movd mm5, eax ; load pointer to Family Info Struc
-
- AMD_CPUID CPUID_MODEL
- shr eax, EXT_FAMILY ; AL = cpu extended family
- cmp al, 0bh ; Is this family 1ah?
- jnz %%node_core_f1A_exit ; Br if no
- shr ebx, PROCESSOR_COUNT ; BH = LocalApicId (Node #), BL = Logical processor count (Core #)
- xor esi, esi ; Assume BSC, clear local flags
- mov ecx, APIC_BASE_ADDRESS ; MSR:0000_001B
- rdmsr
- bt eax, APIC_BSC ; Is this the BSC?
- _if ncarry
- mov si, bx ; SI = [15:8]= Node# = 0; [7:0]= core#
- _endif ; end
-
- ;
- ; determine if this core shares MTRRs
- ;
- AMD_CPUID AMD_CPUID_EXT_APIC
- _if bh, ne, 0
- bt si, 0
- _if ncarry
- bts esi, FLAG_IS_PRIMARY ; Set shared flag into return value
- _endif
- _else
- bts esi, FLAG_IS_PRIMARY ; Set shared flag into return value
- _endif
-
- bts esi, FLAG_DRAM_AVAILABLE
-%%node_core_f1A_exit:
-%endmacro
-
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackNasm.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackNasm.inc
deleted file mode 100644
index 5fb79afaed03646e890af8a04712206595a4b616..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/CpStackNasm.inc
+++ /dev/null
@@ -1,855 +0,0 @@
-;*****************************************************************************
-; AMD Generic Encapsulated Software Architecture
-;
-; Copyright (C) 2008 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; Workfile: CpStackNasm.inc $Revision$ $Date$
-;
-; Description: Code to setup and break down stack
-;
-
-;============================================================================
-;
-; Define a macro that allow the OEM to specify supported solutions in the
-; cache-as-ram code. This will reduce the size of the assembled file.
-; The macro will convert solutions into supported families.
-;
-;============================================================================
-
- %include "EarlyCpuSupportNasm.inc"
- %include "CpStackHooksNasm.inc"
-
-;======================================================================
-; AMD_ENABLE_STACK_PRIVATE: Setup a stack
-;
-; In:
-; EBX = Return address (preserved)
-;
-; Out:
-; SS:ESP - Our new private stack location
-;
-; EAX = AGESA_STATUS
-; EDX = Return status code if EAX contains a return code of higher
-; severity than AGESA_SUCCESS
-; ECX = Stack size in bytes
-;
-; Requirements:
-; * This routine presently is limited to a max of 64 processor cores
-; Preserved:
-; ebx ebp
-; Destroyed:
-; eax, ecx, edx, edi, esi, ds, es, ss, esp
-; mmx0, mmx1, mmx5
-; Input Parameter:
-; STACK_AT_TOP
-; Indicate stack is on the top of cache as RAM.
-; STACK_AT_BOTTOM (default)
-; Indicate stack is at the bottom of cache as RAM.
-;
-; BspStackSize (default: STACK_SIZE_64K)
-; could be STACK_SIZE_64K, STACK_SIZE_128K, STACK_SIZE_192K, STACK_SIZE_256K
-; N O T E: BspStackSize must be the same as the one in PspPlatformDriver.c (RESUME_BSP_STACK_SIZE)
-;
-; Description:
-; Fixed MTRR address allocation to cores:
-; The BSP gets 64K of stack, Core0 of each node gets 16K of stack, all other cores get 4K.
-; There is a max of 1 BSP, 7 core0s and 56 other cores.
-; Although each core has it's own cache storage, they share the address space. Each core must
-; be assigned a private and unique address space for its stack. To support legacy systems,
-; the stack needs to be within the legacy address space (1st 1Meg). Room must also be reserved
-; for the other legacy elements (Interrupt vectors, BIOS ROM, video buffer, etc.)
-;
-; 80000h 40000h 00000h
-; +----------+----------+----------+----------+----------+----------+----------+----------+
-; 64K | | | | | | | | | 64K ea
-; ea +----------+----------+----------+----------+----------+----------+----------+----------+
-; | MTRR 0000_0250 MTRRfix64K_00000 |
-; +----------+----------+----------+----------+----------+----------+----------+----------+
-; | 3 | 2 | 1 | 0 | 0 | | | | <-node
-; | 15..1 | 15..1 | 15..1 | 15..1 | 0 | | | | <-core
-; +----------+----------+----------+----------+----------+----------+----------+----------+
-;
-; C0000h B0000h A0000h 90000h 80000h
-; +------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
-;16K | | | | | | | | | | | | | | | | |
-; ea +------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
-; | MTRR 0259 MTRRFIX16K_A0000 | MTRR 0258 MTRRFIX16K_80000 |
-; +------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
-; | > Dis|play B|uffer | < | | | | | | | | | | 3 | 2 | 1 | <-node
-; | > T| e m |p o r |a r y | B u |f f e |r A |r e a<| | | | | | 0 | 0 | 0 | <-core
-; +------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+
-;
-; E0000h D0000h C0000h
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; 4K | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4K ea
-; ea +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; | 026B MTRRFIX4K_D8000 | 026A MTRRFIX4K_D0000 | 0269 MTRRFIX4K_C8000 | 0268 MTRRFIX4K_C0000 |
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; | | | | | | | | | | | | | | | | | >| V| I| D| E| O| |B |I |O |S | |A |r |e |a<|
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-;
-; 100000h F0000h E0000h
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4K ea
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; | 026F MTRRFIX4K_F8000 | 026E MTRRFIX4K_F0000 | 026D MTRRFIX4K_E8000 | 026C MTRRFIX4K_E0000 |
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-; | >|MA|IN| B|IO|S |RA|NG|E | | | | | | |< | >|EX|TE|ND|ED| B|IO|S |ZO|NE| | | | | |< |
-; +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
-;======================================================================
-%macro AMD_ENABLE_STACK_PRIVATE 3
-
- %if (%2 < STACK_SIZE_1M)
- %if ((%2 != STACK_SIZE_64K) && (%2 != STACK_SIZE_128K) && (%2 != STACK_SIZE_192K) && (%2 != STACK_SIZE_256K))
- jmp $ ; We only support 64K, 128K, 192K, 256K, please check input parameter
- %endif
- %else
- %if ((%2 % 100000h) != 0)
- jmp $ ; For BspStackSize >= 1MB, BspStackSize needs to be aligned with 1MB
- %endif
- %endif
-
- ; Note that SS:ESP will be default stack. Note that this stack
- ; routine will not be used after memory has been initialized. Because
- ; of its limited lifetime, it will not conflict with typical PCI devices.
- movd mm0, ebx ; Put return address in a safe place
- movd mm1, ebp ; Save some other user registers
-
- ; get node id and core id of current executing core
- GET_NODE_ID_CORE_ID ; Sets ESI[15,8]= Node#; ESI[7,0]= core# (relative to node)
- ; Note: ESI[31:24] are used for flags: Unrecognized Family, Is_Primary core, Stack already established
-
- ; If Stack Base is located under 1M, limit it to the first 640K
- mov ebp, %3
- _if ebp, b, 0100000h
- _if ebp, ae, 0A0000h
- mov edx, CPU_EVENT_STACK_BASE_OUT_OF_BOUNDS
- mov eax, AGESA_FATAL
- jmp %%AmdEnableStackExit
- _endif
- _endif
-
- ; If BspStackSize is >= 1MB, then BspStackAddr should also >= 1MB
- %if (%2 >= STACK_SIZE_1M)
- %if (%3 < 0100000h)
- mov edx, CPU_EVENT_STACK_BASE_OUT_OF_BOUNDS
- mov eax, AGESA_FATAL
- jmp %%AmdEnableStackExit
- %endif
- %endif
-
- ; STACK_SIZE_1M or greater is not valid for systems where DRAM is not yet available at this timepoint.
- bt esi, FLAG_DRAM_AVAILABLE
- _if ncarry
- %if (%2 >= STACK_SIZE_1M)
- mov edx, CPU_EVENT_STACK_SIZE_INVALID
- mov eax, AGESA_FATAL
- jmp %%AmdEnableStackExit
- %endif
- _endif
-
- ; If we detected an unknown processor family or core combination, return AGESA_FATAL.
- test esi, (1 << FLAG_UNKNOWN_FAMILY)
- _if ne
- mov edx, CPU_EVENT_UNKNOWN_PROCESSOR_FAMILY
- mov eax, AGESA_FATAL
- jmp %%AmdEnableStackExit
- _else
- test esi, (1 << FLAG_CORE_NOT_IDENTIFIED)
- _if ne
- mov edx, CPU_EVENT_CORE_NOT_IDENTIFIED
- mov eax, AGESA_FATAL
- jmp %%AmdEnableStackExit
- _endif
- _endif
-
- ; determine if stack is already enabled. We are using the DefType MSR for this determination.
- ; It is =0 after reset; CAR setup sets it to enable the MTRRs
- mov eax, cr0 ; Is cache enabled? (CD or NW bit set)
- %define CR0_MASK ((1 << CR0_CD) | (1 << CR0_NW))
- test eax, CR0_MASK
- _if e
- mov ecx, AMD_MTRR_DEFTYPE ; MSR:0000_02FF
- rdmsr ; Are either of the default types enabled? (MTRR_DEF_TYPE_EN + MTRR_DEF_TYPE_FIX_EN)
- %define MSR_MASK ((1 << MTRR_DEF_TYPE_EN)+(1 << MTRR_DEF_TYPE_FIX_EN))
- test eax, MSR_MASK
- _if ne
- bts esi, FLAG_STACK_REENTRY ; indicate stack has already been initialized
- _endif
- _endif
-
- AMD_ENABLE_STACK_FAMILY_HOOK
-
- ; Init CPU MSRs for our init routines
- mov ecx, MTRR_SYS_CFG ; SYS_CFG
- rdmsr
- bts eax, MTRR_FIX_DRAM_MOD_EN ; Turn on modification enable bit
- wrmsr
-
- mov eax, esi
- bt eax, FLAG_STACK_REENTRY ; Is this a 2nd entry?
- _if ncarry ; On a re-entry, do not clear MTRRs or reset TOM; just reset the stack SS:ESP
- bt eax, FLAG_IS_PRIMARY ; Is this core the primary in a compute unit?
- _if carry ; Families using shared groups do not need to clear the MTRRs since that is done at power-on reset
- ; Note: Relying on MSRs to be cleared to 0's at reset for families w/shared cores
- ; Clear all variable and Fixed MTRRs for non-shared cores
- mov ecx, AMD_MTRR_VARIABLE_BASE0
- xor eax, eax
- xor edx, edx
- _while cl, ne, 10h ; Variable MTRRphysBase[n] and MTRRphysMask[n]
- wrmsr
- inc cl
- _endw
- mov cx, AMD_MTRR_FIX64k_00000 ; MSR:0000_0250
- wrmsr
- mov cx, AMD_MTRR_FIX16K_80000 ; MSR:0000_0258
- wrmsr
- mov cx, AMD_MTRR_FIX16K_A0000 ; MSR:0000_0259
- wrmsr
- mov cx, AMD_MTRR_FIX4K_C0000 ; Fixed 4Ks: MTRRFIX4K_C0000 to MTRRFIX4K_F8000
- _while cl, ne, 70h
- wrmsr
- inc cl
- _endw
-
- _endif ; End Is_Primary
- _endif ; End Stack_ReEntry
-
- ; Clear IORRs (C001_0016-19) and TOM2(C001_001D) for all cores
- xor eax, eax
- xor edx, edx
- mov ecx, IORR_BASE ; MSR:C001_0016 - 0019
- _while cl, ne, 1Ah
- wrmsr
- inc cl
- _endw
-
- ; setup MTTRs for stacks
- ; A speculative read can be generated by a speculative fetch mis-aligned in a code zone
- ; or due to a data zone being interpreted as code. When a speculative read occurs outside a
- ; controlled region (intentionally used by software), it could cause an unwanted cache eviction.
- ; To prevent speculative reads from causing an eviction, the unused cache ranges are set
- ; to UC type. Only the actively used regions (stack, heap) are reflected in the MTRRs.
- ; Note: some core stack regions will share an MTRR since the control granularity is much
- ; larger than the allocated stack zone. The allocation algorithm must account for this 'extra'
- ; space covered by the MTRR when parseling out cache space for the various uses. In some cases
- ; this could reduce the amount of EXE cache available to a core. see cpuCacheInit.c
- ;
- ; Outcome of this block is that: (Note the MTRR map at the top of the file)
- ; ebp - start address of stack block
- ; ebx - [31:16] - MTRR MSR address
- ; - [15:8] - slot# in MTRR register
- ; - [7:0] - block size in #4K blocks
- ; review: ESI[31:24]=Flags; SI[15,8]= Node#; SI[7,0]= core# (relative to node)
- ;
- mov eax, esi ; Load Flags, node, core
- _if al, e, 0 ; Is a core 0?
- _if ah, e, 0 ; Is Node 0? (BSP)
- bt esi, FLAG_DRAM_AVAILABLE
- _if carry
- ; a) For stack located under 1M, use Fixed MTRRs
- _if ebp, b, 0100000h
- ; a.i) Use Fixed 0250h and possibly 0258h
- _if ebp, b, 080000h
- ; Calculate starting block #
- mov ecx, ebp
- and ecx, 0F0000h
- shr ecx, 16
-
- ; Calculate # of 64K blocks to fill
- mov bl, (%2 / 10000h)
- mov ch, bl
-
- ; Calculate end block #
- add ch, cl
-
- ; bl = Number of 64K blocks
- ; cl = Start block #
- ; ch = End block #
- _if cl, b, 4
- _if ch, be, 4
- ;
- ; a.i.i) if Start Block and End Block are within the lower 32 bits of MTRR
- ;
- mov edi, WB_DRAM_TYPE
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
- shl cl, 3
- shl edi, cl
-
- mov ecx, AMD_MTRR_FIX64k_00000
- rdmsr
- or eax, edi
- wrmsr
- _else
- ;
- ; a.i.ii) if Start Block and End Block spans upper and lower bits of MTRR
- ;
- ; bh = number of blocks that needs to be set in the lower 32 bits
- mov bh, 4
- sub bh, cl
-
- ; Store number of remaining blocks to be set in upper 32 bits in ecx [24:16]
- ror ecx, 16
- mov cl, bl
- sub cl, bh
- rol ecx, 16
-
- mov edi, WB_DRAM_TYPE
- _while bh, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bh
- _endw
-
- ; transfer number of blocks to bs set in the upper 32 bits to ebx
- mov ebx, ecx
-
- ; move to the correct Start block position
- shl cl, 3
- shl edi, cl
-
- mov ecx, AMD_MTRR_FIX64k_00000
- rdmsr
- or eax, edi
-
- mov edi, WB_DRAM_TYPE
- ; Retrieve number of remaining blocks to be set in the upper 32 bits of MTRR
- ror ebx, 16
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
- or edx, edi
- wrmsr
- _endif
- _else
- _if ch, be, 8
- ;
- ; a.i.iii) if Start Block and End Block are within the upper 32 bits of MTRR
- ;
- sub cl, 4
-
- mov edi, WB_DRAM_TYPE
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
-
- shl cl, 3
- shl edi, cl
-
- mov ecx, AMD_MTRR_FIX64k_00000
- rdmsr
- or edx, edi
- wrmsr
- _else
- ;
- ; a.i.iv) if Start Block and End Block spans multiple MTRRs
- ;
- ; bh = Number of blocks that need to be set in MSR0000_0250
- mov bh, 8
- sub bh, cl
-
- ; Store number of remaining blocks to be set in MSR0000_0258 in ebx[24:16]
- mov al, bl
- sub al, bh
- ror ebx, 16
- mov bx, ax
- rol ebx, 16
-
- mov edi, WB_DRAM_TYPE
- _while bh, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bh
- _endw
-
- shl cl, 3
- shl edi, cl
-
- ; Since the max size for stack under 1M is 256K, if the start block and end block
- ; spans multiple MTRRs, then only upper bits of MSR250 needs to be set
- mov ecx, AMD_MTRR_FIX64k_00000
- rdmsr
- or edx, edi
- wrmsr
-
- ; Retrieve number of blocks to be set in MSR0000_0258
- ror ebx, 16
- ; bl = Number of 16K blocks to be set in the lower 32 bits of MSR0000_0258
- shl bl, 2
- mov bh, bl
- ; bh = Number of 16K blocks to be set in the upper 32 bits of MSR0000_0258
- sub bh, 4
-
- mov edi, WB_DRAM_TYPE
- _if bl, a, 4
- mov bl, 4
- _endif
-
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
-
- mov ecx, AMD_MTRR_FIX16K_80000
- rdmsr
- or eax, edi
-
- _if bh, e, 0
- xor edi, edi
- _else
- mov edi, WB_DRAM_TYPE
- ; If number of slots exceeds 4, ignore the remaining since we are limiting stack within 640K
- _if bh, a, 4
- mov bh, 4
- _endif
- _endif
- _while bh, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bh
- _endw
-
- or edx, edi
- wrmsr
-
- _endif
- _endif
- _else
- ; a.ii) Use Fixed 258h
-
- ; Calculate start block #
- mov ecx, ebp
- and ecx, 01F000h
- shr ecx, 14
-
- ; Calculate # of 16K blocks to fill
- mov bl, (%2 / 4000h)
- mov ch, bl
-
- ; Calculate end block #
- add ch, cl
-
- ; bl = Number of 16K blocks
- ; cl = Start block #
- ; ch = End block #
- _if cl, b, 4
- _if ch, be, 4
- ;
- ; a.ii.i) if Start Block and End Block are within the lower 32 bits of MTRR
- ;
- mov edi, WB_DRAM_TYPE
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
-
- mov ecx, AMD_MTRR_FIX16K_80000
- rdmsr
- or eax, edi
- wrmsr
- _else
- ;
- ; a.ii.ii) if Start Block and End Block spans both the upper and lower 32 bits of the MTRR
- ;
- ; bh = number of blocks to be set in the lower 32 bits
- mov bh, 4
- sub bh, cl
-
- ; store number of remaining blocks to be set in the upper 32 bits in ecx[26:16]
- ror ecx, 16
- mov cl, bl
- sub cl, bh
- rol ecx, 16
-
- mov edi, WB_DRAM_TYPE
- _while bh, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bh
- _endw
-
- shl cl, 3
- shl edi, cl
-
- ; transfer number of blocks to bs set in the upper 32 bits to ebx
- mov ebx, ecx
-
- mov ecx, AMD_MTRR_FIX16K_80000
- rdmsr
- or eax, edi
-
- mov edi, WB_DRAM_TYPE
- ; Retrieve number of remaning blocks to be set in the upper 32 bits
- ror ebx, 16
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
-
- or edx, edi
- wrmsr
-
- _endif
- _else
- ;
- ; a.ii.iii) if Start Block and End Block are within the upper 32 bits of the MTRR
- ;
- mov edi, WB_DRAM_TYPE
- _while bl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec bl
- _endw
-
- mov ecx, AMD_MTRR_FIX16K_80000
- rdmsr
- or edx, edi
- wrmsr
- _endif
- _endif
-
- ; Set ebx with the correct value for later use
- mov ebx, (%2 / 1000h)
- jmp %%GoToVarMtrr
- _else
- ; b. If stack is located above 1M, use variable MTRRs
- mov ebx, (%2 / 1000h)
- jmp %%GoToVarMtrr
- _endif
- _else
- ; Is BSP, assigning stack as specified by %2
- mov ebx, ((AMD_MTRR_FIX64k_00000 << 16) + (BSP_CACHE_TYPE_POSITION << 8) + (%2 / 1000h))
- mov ebp, BSP_STACK_BASE_ADDR
- _endif
- _else ; node 1 to 7, core0
- ; Is a Core0 of secondary node, assign 16K stacks
- mov bx, AMD_MTRR_FIX16K_80000
- shl ebx, 16 ;
- dec ah ; index from 0
- mov bh, ah ; Node# is used as slot#
- mov bl, (CORE0_STACK_SIZE / 1000h)
- mov al, ah ; Base = (Node# * Size);
- mul bl ;
- movzx eax, ax ;
- shl eax, 12 ; Expand back to full byte count (* 4K)
- add eax, CORE0_STACK_BASE_ADDR
- mov ebp, eax
- _endif
- _else ;core 1 thru core 15
- ; Is core 1-15 of any node, assign 4K stacks
- mov al, 16 ; CoreIndex = ( (Node# * 16) ...
- mul ah ;
- mov bx, si ;
- dec bl ; account for core 0 on P1, etc
- add al, bl ; ... + Core#);
-
- mov bx, AMD_MTRR_FIX64k_00000
- shl ebx, 16 ;
- mov bh, al ; Slot# = (CoreIndex / 16) + 4;
- shr bh, 4 ;
- add bh, (%2 / 10000h + BSP_CACHE_TYPE_POSITION)
- mov bl, (CORE1_STACK_SIZE / 1000h)
-
- mul bl ; Base = ( (CoreIndex * Size) ...
- movzx eax, ax ;
- shl eax, 12 ; Expand back to full byte count (* 4K)
- add eax, (BSP_STACK_BASE_ADDR + %2) ; ... + Base_Addr);
- mov ebp, eax
- _endif
-
- ; Now set the MTRR. Add this to already existing settings (do not clear any MTRR)
- ; Set lower 32 bits of MTRR
- mov edi, WB_DRAM_TYPE ; Load Cache type in 1st slot
- mov cl, bl ; block size in #64K blocks
- shr cl, 4
- _if cl, a, 4
- jmp $ ; We do NOT support size larger than 256K
- _endif
- _while cl, a, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec cl
- _endw
- mov cl, bh ; ShiftCount = ((slot# ...
- _if cl, a, 3
- mov edi, 0
- _else
- shl cl, 3 ; ... * 8);
- shl edi, cl ; Cache type is now in correct position
- _endif
- ror ebx, 16 ; Get the MTRR address
- movzx ecx, bx ;
- rol ebx, 16 ; Put slot# & size back in BX
- rdmsr ; Read-modify-write the MSR
- or eax, edi ;
-
- ; Set upper 32 bits of MTRR
- mov cl, bl
- add cl, 0Fh
- shr cl, 4
- dec cl
- add cl, bh
- mov ch, cl
- _if cl, ae, 4
- _if bh, ae, 4
- mov cl, bh
- _else
- mov cl, 4
- _endif
- sub ch, cl
- sub cl, 4
- mov edi, WB_DRAM_TYPE
- _while ch, ae, 1
- shl edi, 8
- or edi, WB_DRAM_TYPE
- dec ch
- _endw
- shl cl, 3
- shl edi, cl
- _else
- mov edi, 0
- _endif
- ror ebx, 16 ; Get the MTRR address
- movzx ecx, bx ;
- rol ebx, 16 ; Put slot# & size back in BX
- or edx, edi ;
- wrmsr ;
-
-%%GoToVarMtrr:
- bt esi, FLAG_IS_PRIMARY ; Is this a primary core?
- _if carry
- bt esi, FLAG_DRAM_AVAILABLE ; Is system DRAM initialized?
- _if carry
- mov ecx, TOP_MEM ; Read the top of memory below 4GB
- rdmsr
- mov edi, eax ; EDI = top of memory below 4GB
- xor esp, esp ; Initialize DRAM base address to 0
- mov ecx, AMD_MTRR_VARIABLE_BASE0 ; Start with VarMtrr0
- jmp %%WhileCheck
- %%WhileStart: ; Loop until all set bits are accounted for or we run out of mtrrs
- mov eax, esp ; EAX = region base
- mov al, MTRR_TYPE_WB ; WB type
- xor edx, edx ; Only describing below 4GB
- wrmsr ; Apply var mtrr base
- inc cx ; Set ECX to var mtrr limit register
- bsr edx, edi ; Find MSb
- btr edi, edx ; Mark it as accounted for
- xor eax, eax ; EAX = 0
- bts eax, edx ; EAX = region size
- mov edx, esp ; EDX = current region base
- add edx, eax ; EDX = next region base
- mov esp, edx ; ESP = next region base
- neg eax ; EAX = lower 32 bits of the mask required for this region's size
- bts eax, VMTRR_VALID ; Set the valid bit
- mov edx, edi ; Save EDI to EDX
- movd edi, mm5 ; Load pointer to Family Info Struc
- bswap ecx ; Save MTRR address to ECX[31:16]
- mov cl, [edi + CPU_FAMILY_INFO.SIZE_ADDRESS_BUS] ; CL = number of address bits for this family
- mov edi, edx ; Restore EDI
- xor edx, edx ; EDX = 0
- _if cl, b, 64
- sub cl, 32 ; CL = number of valid address bits between [63:32]
- inc dx ; EDX = 1
- shl edx, cl ;
- _endif
- dec edx ; EDX = Upper half of the address mask for this family
- xor cl, cl ; Restore CL
- bswap ecx ; Restore ECX
- wrmsr ; Enable the var mtrr
- inc cx ; Point to next var mtrr base
- %%WhileCheck:
- cmp edi, 0
- je %%WhileEnd
- cmp ecx, AMD_MTRR_VARIABLE_BASE6
- jb %%WhileStart
- %%WhileEnd:
- _endif
- _endif
-
- ; Enable MTRR defaults as UC type
- mov ecx, AMD_MTRR_DEFTYPE ; MSR:0000_02FF
- rdmsr ; Read-modify-write the MSR
- bts eax, MTRR_DEF_TYPE_EN ; MtrrDefTypeEn
- bts eax, MTRR_DEF_TYPE_FIX_EN ; MtrrDefTypeFixEn
- wrmsr
-
- ; Close the modification window on the Fixed MTRRs
- mov ecx, MTRR_SYS_CFG ; MSR:0C001_0010
- rdmsr
- bts eax, MTRR_FIX_DRAM_EN ; MtrrFixDramEn
- bts eax, MTRR_VAR_DRAM_EN ; variable MTRR enable bit
- btr eax, MTRR_FIX_DRAM_MOD_EN ; Turn off modification enable bit
- wrmsr
-
- ; Enable caching in CR0
- mov eax, CR0 ; Enable WT/WB cache
- btr eax, CR0_PG ; Make sure paging is disabled
- btr eax, CR0_CD ; Clear CR0 NW and CD
- btr eax, CR0_NW
- mov CR0, eax
-
- ; Use the Stack Base & size to calculate SS and ESP values
- ; review:
- ; esi[31:24]=Flags; esi[15,8]= Node#; esi[7,0]= core# (relative to node)
- ; ebp - start address of stack block
- ; ebx - [31:16] - MTRR MSR address
- ; - [15:8] - slot# in MTRR register
- ; - [7:0] - block size in #4K blocks
- ;
- mov esp, ebp ; Initialize the stack pointer
- mov edi, esp ; Copy the stack start to edi
- bt esi, FLAG_DRAM_AVAILABLE
-
- _if ncarry
- movzx bx, bl
- movzx ebx, bx ; Clear upper ebx, do not need MSR addr anymore
- _endif
- shl ebx, 12 ; Make size full byte count (* 4K)
- %if (%1 = STACK_AT_BOTTOM)
- mov ax, si
- _if al, e, 0 ; Only BSC needs to cut its CAR in half for PEI RAM
- shr ebx, 1 ; If stack is at the bottom of CAR, divide size by 2
- _endif
- %endif
- add esp, ebx ; Set the Stack Pointer as full linear address
- sub esp, 4
- ;
- ; review:
- ; esi[31:24]=Flags; esi[15,8]= Node#; esi[7,0]= core# (relative to node)
- ; edi - 32b start address of stack block
- ; ebx - size of stack block
- ; esp - 32b linear stack pointer
- ;
-
- ; Determine mode for SS base;
- mov ecx, CR0 ; Check for 32-bit protect mode
- bt ecx, CR0_PE ;
- _if ncarry ; PE=0 means real mode
- mov cx, cs ;
- _if cx, ae, 0D000h ; If CS >= D000, it's a real mode segment. PM selector would be 08-> 1000
- ; alter SS:ESP for 16b Real Mode:
- mov eax, edi ;
- shr eax, 4 ; Create a Real Mode segment for ss, ds, es
- mov ss, ax ;
- mov ds, ax ;
- mov es, ax ;
- shl eax, 4 ;
- sub edi, eax ; Adjust the clearing pointer for Seg:Offset mode
- mov esp, ebx ; Make SP an offset from SS
- sub esp, 4 ;
- _endif ; endif
- ; else
- ; Default is to use Protected 32b Mode
- _endif
- %if (%1 = STACK_AT_BOTTOM)
- mov ax, si
- _if al, e, 0
- shl ebx, 1 ; restore the size of CAR
- _endif
- %endif
- ;
- ; Clear The Stack
- ; Now that we have set the location and the MTRRs, initialize the cache by
- ; reading then writing to zero all of the stack area.
- ; review:
- ; ss - Stack base
- ; esp - stack pointer
- ; ebx - size of stack block
- ; esi[31:24]=Flags; esi[15,8]= Node#; esi[7,0]= core# (relative to node)
- ; edi - address of start of stack block
- ;
- shr ebx, 2 ;
- mov ecx, ebx ; set cx for size count of DWORDS
-
- ; Check our flags - Do not clear an existing stack
- test esi, (1 << FLAG_STACK_REENTRY)
- _if zero
- cld
- mov esi, edi
- rep lodsd ; Pre-load the range
- xor eax, eax
- mov ecx, ebx
- mov esi, edi ; Preserve base for push on stack
- rep stosd ; Clear the range
- mov dword [esp], 0ABCDDCBAh ; Put marker in top stack dword
- shl ebx, 2 ; Put stack size and base
- push ebx ; in top of stack
- push esi
-
- mov ecx, ebx ; Return size of stack in bytes
- mov eax, AGESA_SUCCESS ; eax = AGESA_SUCCESS : no error return code
- _else
- movzx ecx, cx
- shl ecx, 2 ; Return size of stack, in bytes
- mov edx, CPU_EVENT_STACK_REENTRY
- mov eax, AGESA_WARNING ; eax = AGESA_WARNING (Stack has already been set up)
- _endif
-
-%%AmdEnableStackExit:
- movd ebx, mm0 ; Restore return address
- movd ebp, mm1
-%endmacro
-
-;======================================================================
-; AMD_DISABLE_STACK_PRIVATE: Destroy the stack inside the cache. This routine
-; should only be executed on the BSP
-;
-; In:
-; none
-;
-; Out:
-; EAX = AGESA_SUCCESS
-;
-; Preserved:
-; ebx
-; Destroyed:
-; eax, ecx, edx, esp, mmx5
-;======================================================================
-%macro AMD_DISABLE_STACK_PRIVATE 0
-
- mov esp, ebx ; Save return address
-
- ; get node/core/flags of current executing core
- GET_NODE_ID_CORE_ID ; Sets ESI[15,8]= Node#; ESI[7,0]= core# (relative to node)
-
- ; Turn on modification enable bit
- mov ecx, MTRR_SYS_CFG ; MSR:C001_0010
- rdmsr
- bts eax, MTRR_FIX_DRAM_MOD_EN ; Enable modifications
- wrmsr
-
- ; Set lower 640K MTRRs for Write-Back memory caching
- mov ecx, AMD_MTRR_FIX64k_00000
- mov eax, 1E1E1E1Eh
- mov edx, eax
- wrmsr ; 0 - 512K = WB Mem
- mov ecx, AMD_MTRR_FIX16K_80000
- wrmsr ; 512K - 640K = WB Mem
-
- ; Turn off modification enable bit
- mov ecx, MTRR_SYS_CFG ; MSR:C001_0010
- rdmsr
- btr eax, MTRR_FIX_DRAM_MOD_EN ; Disable modification
- wrmsr
-
- AMD_DISABLE_STACK_FAMILY_HOOK ; Re-Enable 'normal' cache operations
-
- mov ebx, esp ; restore return address (ebx)
- xor eax, eax
-
-%endmacro
-
-
-
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/EarlyCpuSupportNasm.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/EarlyCpuSupportNasm.inc
deleted file mode 100644
index 78a3b63ec45ce1ec336b12a1da1ff6940369a3c7..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/EarlyCpuSupportNasm.inc
+++ /dev/null
@@ -1,208 +0,0 @@
-;*****************************************************************************
-; AMD Generic Encapsulated Software Architecture
-;
-; Copyright (C) 2008 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; $Workfile:: EarlyCpuSupportNasm.inc
-;
-; $Revision$ $Date$
-;
-; Description:
-;
-
-%define STACK_AT_TOP 0 ; Stack is at the top of CAR
-%define STACK_AT_BOTTOM 1 ; Stack is at the bottom of CAR
-
-%define APIC_BASE_ADDRESS 0000001Bh
-%define APIC_BSC 8 ; Boot Strap Core
-
-%define APIC_MSG_REG 380h ; Location of BSC message
-%define APIC_MSG 00DE00ADh ; Message data
-%define APIC_INVD_ALL_DONE_MSG 00AD00DEh ; Indicate all cores have invalidated
-%define APIC_CMD_LO_REG 300h ; APIC command low
-%define APIC_CMD_HI_REG 310h ; APIC command high
-%define CMD_REG_TO_READ_DATA 00000338h ; APIC command for remote read of APIC_MSG_REG
-%define REMOTE_READ_STS 00030000h ; Remote read status mask
-%define REMOTE_DELIVERY_PEND 00010000h ; Remote read is pending
-%define REMOTE_DELIVERY_DONE 00020000h ; Remote read is complete
-%define DELIVERY_STS_BIT 12 ; Delivery status valid bit
-%define APIC_ID_REG 0020h ; Local APIC ID offset
-%define APIC20_APICID 24
-%define APIC_REMOTE_READ_REG 00C0h ; Remote read offset
-
-%define AMD_MTRR_VARIABLE_BASE0 0200h
-%define AMD_MTRR_VARIABLE_BASE6 020Ch
-%define AMD_MTRR_VARIABLE_BASE7 020Eh
-%define VMTRR_VALID 11
-%define MTRR_TYPE_WB 06h
-%define MTRR_TYPE_WP 05h
-%define MTRR_TYPE_WT 04h
-%define MTRR_TYPE_UC 00h
-%define AMD_MTRR_VARIABLE_MASK0 0201h
-%define AMD_MTRR_VARIABLE_MASK7 020Fh
-%define AMD_MTRR_FIX64k_00000 0250h
-%define AMD_MTRR_FIX16K_80000 0258h
-%define AMD_MTRR_FIX16K_A0000 0259h
-%define AMD_MTRR_FIX4K_C0000 0268h
-%define AMD_MTRR_FIX4K_C8000 0269h
-%define AMD_MTRR_FIX4K_D0000 026Ah
-%define AMD_MTRR_FIX4K_D8000 026Bh
-%define AMD_MTRR_FIX4K_E0000 026Ch
-%define AMD_MTRR_FIX4K_E8000 026Dh
-%define AMD_MTRR_FIX4K_F0000 026Eh
-%define AMD_MTRR_FIX4K_F8000 026Fh
-%define CPU_LIST_TERMINAL 0FFFFFFFFh
-
-%define AMD_MTRR_DEFTYPE 02FFh
-%define WB_DRAM_TYPE 1Eh ; MemType - memory type
-%define MTRR_DEF_TYPE_EN 11 ; MtrrDefTypeEn - variable and fixed MTRRs default enabled
-%define MTRR_DEF_TYPE_FIX_EN 10 ; MtrrDefTypeEn - fixed MTRRs default enabled
-
-%define INVD_WBINVD 4 ; INVD to WBINVD conversion
-
-%define IORR_BASE 0C0010016h ; IO Range Regusters Base/Mask, 2 pairs
- ; uses 16h - 19h
-%define TOP_MEM 0C001001Ah ; Top of Memory
-%define TOP_MEM2 0C001001Dh ; Top of Memory2
-
-%define CR0_PE 0 ; Protection Enable
-%define CR0_NW 29 ; Not Write-through
-%define CR0_CD 30 ; Cache Disable
-%define CR0_PG 31 ; Paging Enable
-
-; CPUID Functions
-
-%define CPUID_MODEL 1
- ; In EAX
-%define EXT_MODEL 16 ; Extended model
-%define EXT_FAMILY 20 ; Extended family
- ; In EBX
-%define PROCESSOR_COUNT 16 ; Logical processor count
-%define LOCAL_APIC_ID 24 ; LocalApicId - initial local APIC physical ID
- ; In EDX
-%define PYSYCAL_ADDRESS_EXT 6 ; Physical addresss extensions.
-
-
-%define AMD_CPUID_L2Cache 80000006h ; L2/L3 cache info
-%define AMD_CPUID_APIC 80000008h ; Long Mode and APIC info., core count
-%define APIC_ID_CORE_ID_SIZE 12 ; ApicIdCoreIdSize bit position
-%define AMD_CPUID_EXT_APIC 8000001Eh ; Extended APICID information
-
-%define AMD_CPUID_CAP_EXT 80000008h ; Processor capability parameter and
- ; Extended feature identification.
-%define PHYSICAL_ADDR_MASK 0FFh ;
-
-%define MTRR_SYS_CFG 0C0010010h ; System Configuration Register
-%define SYS_UC_LOCK_EN 17 ; SysUcLockEn System lock command enable
-%define MTRR_FIX_DRAM_EN 18 ; MtrrFixDramEn MTRR fixed RdDram and WrDram attributes enable
-%define MTRR_FIX_DRAM_MOD_EN 19 ; MtrrFixDramModEn MTRR fixed RdDram and WrDram modification enable
-%define MTRR_VAR_DRAM_EN 20 ; MtrrVarDramEn MTRR variable DRAM enable
-
-; Local use flags, in upper most byte of ESI
-%define FLAG_UNKNOWN_FAMILY 24 ; Signals that the family# of the installed processor is not recognized
-%define FLAG_STACK_REENTRY 25 ; Signals that the environment has made a re-entry (2nd) call to set up the stack
-%define FLAG_IS_PRIMARY 26 ; Signals that this core is the primary within the compute unit
-%define FLAG_CORE_NOT_IDENTIFIED 27 ; Signals that the cores/compute units of the installed processor is not recognized
-%define FLAG_FORCE_32K_STACK 28 ; Signals to force 32KB stack size for BSP core
-%define FLAG_DRAM_AVAILABLE 29 ; Signals that DRAM is present
-
-; Error code returned in EDX by AMD_ENABLE_STACK_PRIVATE
-%ifndef CPU_EVENT_UNKNOWN_PROCESSOR_FAMILY
-%define CPU_EVENT_UNKNOWN_PROCESSOR_FAMILY 008010500h
-%endif
-%ifndef CPU_EVENT_STACK_REENTRY
-%define CPU_EVENT_STACK_REENTRY 008020500h
-%endif
-%ifndef CPU_EVENT_CORE_NOT_IDENTIFIED
-%define CPU_EVENT_CORE_NOT_IDENTIFIED 008030500h
-%endif
-%ifndef CPU_EVENT_STACK_BASE_OUT_OF_BOUNDS
-%define CPU_EVENT_STACK_BASE_OUT_OF_BOUNDS 008040500h
-%endif
-%ifndef CPU_EVENT_STACK_SIZE_INVALID
-%define CPU_EVENT_STACK_SIZE_INVALID 008050500h
-%endif
-
-; AGESA_STATUS values
-%ifndef AGESA_SUCCESS
-%define AGESA_SUCCESS 0
-%endif
-%ifndef AGESA_WARNING
-%define AGESA_WARNING 4
-%endif
-%ifndef AGESA_FATAL
-%define AGESA_FATAL 7
-%endif
-;;***************************************************************************
-;;
-;; CPU MACROS - PUBLIC
-;;
-;;***************************************************************************
-
-%macro AMD_CPUID 0-1
- %if (%0 = 0)
- mov eax, 1
- db 0Fh, 0A2h ; Execute instruction
- bswap eax
- xchg al, ah ; Ext model in al now
- rol eax, 8 ; Ext model in ah, model in al
- and ax, 0FFCFh ; Keep 23:16, 7:6, 3:0
- %else
- mov eax, %1
- db 0Fh, 0A2h
- %endif
-%endmacro
-
-%macro MAKE_SBDFO 5
- mov eax, ((%1 << 28) | (%2 << 20) | (%3 << 15) | (%4 << 12) | (%5))
-%endmacro
-
-%macro MAKE_EXT_PCI_ADDR 5
- mov eax, ((1 << 31) | (%1 << 28) | (((%5 & 0F00h) >> 8) << 24) | (%2 << 16) | (%3 << 11) | (%4 << 8) | (%5 & 0FCh))
-%endmacro
-
-;---------------------------------------------------
-; LoadTableAddress
-; Due to the various assembly methodologies used by BIOS vendors, this macro is needed to abstract the
-; loading of the address of a table. The default is the standard LEA instruction with table address.
-; The IBV that needs to use an alternative method can define their version of the macro prior to including
-; this file into their source.
-; An alternative example:
-; LoadTableAddress MACRO MyTable
-; LEA eax, -(LAST_ADDRESS - MyTable)
-;---------------------------------------------------
-%ifnmacro LoadTableAddress 1
-%macro LoadTableAddress 1
- lea eax, [%1]
-%endmacro
-%endif
-
-
-;;***************************************************************************
-;;
-;; CPU STRUCTURES - PUBLIC
-;;
-;;***************************************************************************
-struc CPU_FAMILY_INFO
- .L2_MIN_SIZE resw 1 ; Minimum size of the L2 cache for this family, in K
- .NUM_SHARED_CORES resb 1 ; Number of cores sharing an L2 cache
- .L2_ALLOC_MEM resb 1 ; L2 space reserved for memory training, in K
- .L2_ALLOC_EXE resw 1 ; L2 space reserved for EXE CACHE, in K. 0 means unlimited.
- .SIZE_ADDRESS_BUS resb 1 ; Number of address bits supported by this family
- .FAMILY_RESERVED resb 1 ; reserved, pad to DWORD size
-endstruc
-
-
-%macro CPU_DEADLOOP 0
-
-%%DeadLoop:
- out 84h, al
- jmp %%DeadLoop
-
-%endmacro
-
-
-
-
-
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Flat32.nasm b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Flat32.nasm
index dbf18413daa89b62283e19a3db71a704dccbeb28..cdccb423e0456dc5e81320aa6b9219f9b5047542 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Flat32.nasm
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Flat32.nasm
@@ -9,7 +9,7 @@
; It consumes the reset vector, and configures the stack.
;
; Copyright (c) 2013-2015 Intel Corporation
-; Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+; Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
;
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
@@ -51,6 +51,11 @@ extern ASM_PFX(BoardBeforeTempRamInit)
extern ASM_PFX(BoardAfterTempRamInitWrapper)
+; Following are fixed PCDs
+
+extern ASM_PFX(PcdGet32 (PcdPciExpressBaseAddressHi))
+extern ASM_PFX(PcdGet32 (PcdPciExpressBaseAddressLow))
+
%define BSP_HEAP_STACK_BASE FixedPcdGet32 (PcdTempRamBase)
%define BSP_HEAP_STACK_SIZE FixedPcdGet32 (PcdTempRamSize)
%define FLASH_IMAGE_SIZE FixedPcdGet32 (PcdFlashAreaSize)
@@ -177,6 +182,19 @@ ProtectedModeEntryPoint:
; Early board hooks
;
JMP32 ASM_PFX(BoardBeforeTempRamInit)
+ ;
+ ; Configure MMIO Base Address
+ ;
+ mov ecx, 0x0C0010058
+ rdmsr
+ mov ebx, eax
+ mov eax, DWORD [ASM_PFX(PcdGet32 (PcdPciExpressBaseAddressLow))]
+ or eax, ebx
+ or eax, MMIO_CFG_ENABLE
+ mov edx, DWORD [ASM_PFX(PcdGet32 (PcdPciExpressBaseAddressHi))]
+ mov ecx, 0x0C0010058
+ wrmsr
+
;
; Set UEFI stack
;
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/NasmBase.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/NasmBase.inc
deleted file mode 100644
index 8b56a38ae8f7c75c29f3a9c5b31010abfbcfa6ac..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/NasmBase.inc
+++ /dev/null
@@ -1,141 +0,0 @@
-;*****************************************************************************
-; AMD Generic Encapsulated Software Architecture
-;
-; Copyright (C) 2008 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-; $Workfile:: NasmBase.inc
-;
-; $Revision$ $Date$
-;
-; Description:
-;
-
-%ifnmacro _if 1-3
-%macro _if 1-3
-
- nop ;WA for nasm to avoid label incorrect issue
-
- %push _if
-
- %if %0 = 1
-
- %ifidn %1, carry
- jae %$ifnot
- %elifidn %1, ncarry
- jb %$ifnot
- %elifidn %1, zero
- jne %$ifnot
- %elifidn %1, nzero
- je %$ifnot
- %else
- j%-1 %$ifnot
- %endif
-
- %endif
-
- %if %0 = 2
- %error "2 parameters is not allowed"
- %endif
-
- %if %0 = 3
- cmp %1, %3
- j%-2 %$ifnot
- %endif
-
-%endmacro
-%endif
-
-
-%ifnmacro _else 0
-%macro _else 0
-
- %ifctx _if
- %repl _else
- jmp %$ifend
- %$ifnot:
- %else
- %error "expected '_if' before '_else'"
- %endif
-
-%endmacro
-%endif
-
-
-%ifnmacro _endif 0
-%macro _endif 0
-
- %ifctx _if
- %$ifnot:
- %elifctx _else
- %$ifend:
- %else
- %error "expected '_if' or '_else' before '_endif'"
- %endif
-
- %pop
-
-%endmacro
-%endif
-
-
-%ifnmacro _while 1-3
-%macro _while 1-3
-
- nop ;WA for nasm to avoid label incorrect issue
-
- %push _while
-
-
- %if %0 = 1
- %define %$arg1 %1
- %define %$arg2 one_parameter
- %define %$arg3 one_parameter
- %endif
-
- %if %0 = 2
- %error "2 parameters is not allowed"
- %endif
-
- %if %0 = 3
- %define %$arg1 %1
- %define %$arg2 %2
- %define %$arg3 %3
- %endif
-
- jmp %$whilecheck
- %$whilestart:
-%endmacro
-%endif
-
-
-%ifnmacro _endw 0
-%macro _endw 0
-
- %ifctx _while
- %$whilecheck:
- %ifidn %$arg2, one_parameter
- %ifidn %$arg1, carry
- jb %$whilestart
- %elifidn %$arg1, ncarry
- jae %$whilestart
- %elifidn %$arg1, zero
- je %$whilestart
- %elifidn %$arg1, nzero
- jne %$whilestart
- %else
- j%1 %$whilestart
- %endif
- %else
- cmp %$arg1, %$arg3
- j%$arg2 %$whilestart
- %endif
- %else
- %error "expected '_while' before '_endw'"
- %endif
-
- %pop
-
-%endmacro
-%endif
-
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Platform.inc b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Platform.inc
index e2fd7e254a1c594b7f69414b35592368d5810905..60710c1af32065a345c5a1d49f7bc5d129eb9231 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Platform.inc
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/Ia32/Platform.inc
@@ -7,7 +7,7 @@
; Platform Specific Definitions
;
; Copyright (c) 2013-2015 Intel Corporation
-; Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+; Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
;
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.c b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.c
index 5fee7f8d42403b26f39da66d795c8f034d6ee826..8d820d3ee2419e1ebfa55be6e2af380569d53a80 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.c
@@ -2,7 +2,7 @@
Platform SEC Library.
Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -19,24 +19,7 @@ Platform SEC Library.
#include
#include
-#define SYS_CFG 0xC0010010ul
-#define TOP_MEM 0xC001001Aul
-#define TOP_MEM2 0xC001001Dul
-
-// CPU Build Configuration structures and definitions
-
-#define AMD_AP_MTRR_FIX64K_00000 0x00000250ul
-#define AMD_AP_MTRR_FIX16K_80000 0x00000258ul
-#define AMD_AP_MTRR_FIX16K_A0000 0x00000259ul
-#define AMD_AP_MTRR_FIX4K_C0000 0x00000268ul
-#define AMD_AP_MTRR_FIX4K_C8000 0x00000269ul
-#define AMD_AP_MTRR_FIX4K_D0000 0x0000026Aul
-#define AMD_AP_MTRR_FIX4K_D8000 0x0000026Bul
-#define AMD_AP_MTRR_FIX4K_E0000 0x0000026Cul
-#define AMD_AP_MTRR_FIX4K_E8000 0x0000026Dul
-#define AMD_AP_MTRR_FIX4K_F0000 0x0000026Eul
-#define AMD_AP_MTRR_FIX4K_F8000 0x0000026Ful
-#define CPU_LIST_TERMINAL 0xFFFFFFFFul
+#include
//
// Bitfield Description : Not shared between threads.
@@ -113,17 +96,17 @@ PlatformSecLibStartup (
SYS_CFG_MTRR_FIX_DRAM_MOD_EN_OFFSET,
0x1
);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX64K_00000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX16K_80000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX16K_A0000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_C0000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_C8000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_D0000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_D8000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_E0000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_E8000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_F0000, 0x1E1E1E1E1E1E1E1E);
- AsmWriteMsr64 (AMD_AP_MTRR_FIX4K_F8000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX64k_00000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX16k_80000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX16k_A0000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_C0000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_C8000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_D0000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_D8000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_E0000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_E8000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_F0000, 0x1E1E1E1E1E1E1E1E);
+ AsmWriteMsr64 (AMD_AP_MTRR_FIX4k_F8000, 0x1E1E1E1E1E1E1E1E);
AsmMsrBitFieldAnd64 (
SYS_CFG,
SYS_CFG_MTRR_FIX_DRAM_MOD_EN_OFFSET,
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
index 3b6e4b33f299a5305440e52bf9610f41deff7523..35c9a0dbf859c3e77bc01af028084f41d9e1f710 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLib.inf
@@ -2,7 +2,7 @@
# Platform SEC Library.
#
# Copyright (c) 2013-2015 Intel Corporation.
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -31,6 +31,8 @@
Ia32/Flat32.nasm
[Packages]
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
AmdMinBoardPkg/AmdMinBoardPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -53,7 +55,9 @@
gAmdMinBoardPkgTokenSpaceGuid.PcdBootFvBase ## CONSUMES
gAmdMinBoardPkgTokenSpaceGuid.PcdTempRamBase ## CONSUMES
gAmdMinBoardPkgTokenSpaceGuid.PcdTempRamSize ## CONSUMES
+ gAmdMinBoardPkgTokenSpaceGuid.PcdPciExpressBaseAddressLow ## CONSUMES
+ gAmdMinBoardPkgTokenSpaceGuid.PcdPciExpressBaseAddressHi ## CONSUMES
[Ppis]
gEfiSecPlatformInformationPpiGuid ## UNDEFINED # it is used as GUIDED HOB
- gAmdTopOfTemporaryRamPpiGuid
+ gTopOfTemporaryRamPpiGuid
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLibModStrs.uni b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLibModStrs.uni
index 6c68ed4f8b76fe8a42e761965646ce4450450b74..f18f6384ead45ea16d666a2d1ca0c2a65475a340 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLibModStrs.uni
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/PlatformSecLibModStrs.uni
@@ -3,7 +3,7 @@
// PlatformSecLib Localized Abstract and Description Content
//
// Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.
-// Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+// Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/SecGetPerformance.c b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/SecGetPerformance.c
index 09e9b5002b72117c565a311df62e2bc31e96b7ce..594653b3c065fa8696f20bfc323adb52544016b5 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/SecGetPerformance.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/PlatformSecLib/SecGetPerformance.c
@@ -2,13 +2,14 @@
Sample to provide SecGetPerformance function.
Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include
#include
+#include
#include
#include
#include
@@ -49,7 +50,7 @@ SecGetPerformance (
Status = (*PeiServices)->LocatePpi (
PeiServices,
- &gAmdTopOfTemporaryRamPpiGuid,
+ &gTopOfTemporaryRamPpiGuid,
0,
NULL,
(VOID **)&TopOfTemporaryRamPpi
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.c b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.c
index e7a503f6cff0ba059cfd870a5a23ca76d83df0d3..d1e3e5410e77aeb6247402f4a6fcbd23bbee89a2 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.c
@@ -3,7 +3,7 @@
SetCacheMtrr library functions.
This library implementation is for AMD processor based platforms.
-Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
index b4c4b3e7de1406e3ece95093fd5a5d4cb661a887..79895865460aa10a5e7c37533bd5bdeada0324e3 100644
--- a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf
@@ -2,7 +2,7 @@
# Component information file for Platform SetCacheMtrr Library.
# This library implementation is for AMD processor based platforms.
#
-# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
index 0762f16fb360f3202936c1a32247574d41d570f3..20074612f646569caa1c1828fdf721db8782b781 100755
--- a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.c
@@ -3,7 +3,7 @@
Implements SpcrDeviceLib library functions.
This library implementation is for AMD processor based platforms.
-Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
index d9b77e586aa8af5e81f9a97a483d1f00f16d0e80..302bb8f219ce5b3b046b2aad8461cf2c494bd1d1 100755
--- a/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
+++ b/Platform/AMD/AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf
@@ -2,7 +2,7 @@
# Implementation for SpcrDeviceLib Library.
# SpcrDeviceLib is usd for Serial Port Console Redirection Table (SPCR) device.
#
-# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c
index 9a7b509b5518c48e76f2ca5f15e24a17c0d8e2d4..f4a5ec957d4b2127cbec27698ddecade1ae24446 100755
--- a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c
+++ b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c
@@ -44,7 +44,7 @@
Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
Copyright (C) 2016, Red Hat, Inc.
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf
index 861fc120d9737821dd16ebc95463919d792b90d6..4cfafceb085f4175b0a06ef8ed57855bf3032d2f 100755
--- a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf
+++ b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf
@@ -2,7 +2,7 @@
# This driver implements EFI_PCI_HOT_PLUG_INIT_PROTOCOL.
# Adds resource padding information, for PCIe hotplug purposes.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved
+# Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.ci.yaml b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.ci.yaml
deleted file mode 100644
index b6b25dc18500f40e48d4e6846f8f54835f8f37b2..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.ci.yaml
+++ /dev/null
@@ -1,139 +0,0 @@
-## @file
-# CI configuration for AmdPlatformPkg
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-{
- "PrEval": {
- "DscPath": "AmdPlatformPkg.dsc",
- },
- ## options defined .pytool/Plugin/LicenseCheck
- "LicenseCheck": {
- "IgnoreFiles": []
- },
- "EccCheck": {
- ## Exception sample looks like below:
- ## "ExceptionList": [
- ## "", ""
- ## ]
- "ExceptionList": [
- ],
- ## Both file path and directory path are accepted.
- "IgnoreFiles": [
- ]
- },
- ## options defined ci/Plugin/CompilerPlugin
- "CompilerPlugin": {
- "DscPath": "AmdPlatformPkg.dsc"
- },
- ## options defined ci/Plugin/HostUnitTestCompilerPlugin
- "HostUnitTestCompilerPlugin": {
- "DscPath": ""
- },
-
- ## options defined ci/Plugin/CharEncodingCheck
- "CharEncodingCheck": {
- "IgnoreFiles": []
- },
-
- ## options defined ci/Plugin/DependencyCheck
- "DependencyCheck": {
- "AcceptableDependencies": [
- "AgesaModulePkg/AgesaCommonModulePkg.dec",
- "AgesaModulePkg/AgesaEdk2Pkg.dec",
- "AgesaModulePkg/AgesaModuleFchPkg.dec",
- "AgesaModulePkg/AgesaModuleNbioPkg.dec",
- "AgesaModulePkg/AgesaModulePspPkg.dec",
- "AgesaPkg/AgesaPkg.dec",
- "AmdCpmPkg/AmdCpmPkg.dec",
- "AmdMinBoardPkg/AmdMinBoardPkg.dec",
- "AmdPlatformPkg/AmdPlatformPkg.dec",
- "BoardModulePkg/BoardModulePkg.dec",
- "DynamicTablesPkg/DynamicTablesPkg.dec",
- "IpmiFeaturePkg/IpmiFeaturePkg.dec",
- "MdeModulePkg/MdeModulePkg.dec",
- "MdePkg/MdePkg.dec",
- "MinPlatformPkg/MinPlatformPkg.dec",
- "PcAtChipsetPkg/PcAtChipsetPkg.dec",
- "SignedCapsulePkg/SignedCapsulePkg.dec",
- "SecurityPkg/SecurityPkg.dec",
- "UefiCpuPkg/UefiCpuPkg.dec",
- "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
- ],
- # For host based unit tests
- "AcceptableDependencies-HOST_APPLICATION":[
- "UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec"
- ],
- # For UEFI shell based apps
- "AcceptableDependencies-UEFI_APPLICATION":[],
- "IgnoreInf": []
- },
-
- ## options defined ci/Plugin/DscCompleteCheck
- "DscCompleteCheck": {
- "IgnoreInf": [
- ],
- "DscPath": "AmdPlatformPkg.dsc"
- },
- ## options defined ci/Plugin/HostUnitTestDscCompleteCheck
- "HostUnitTestDscCompleteCheck": {
- "IgnoreInf": [""],
- ## "DscPath": "Test/AmdPlatformPkgHostTest.dsc"
- },
-
- ## options defined ci/Plugin/GuidCheck
- "GuidCheck": {
- "IgnoreGuidName": [],
- "IgnoreGuidValue": [],
- "IgnoreFoldersAndFiles": [],
- "IgnoreDuplicates": []
- },
-
- ## options defined ci/Plugin/LibraryClassCheck
- "LibraryClassCheck": {
- "IgnoreHeaderFile": []
- },
-
- ## options defined ci/Plugin/SpellCheck
- "SpellCheck": {
- "AuditOnly": False, # If True, only audit the files, do not fail the build
- "IgnoreStandardPaths": [ # Standard Plugin defined paths that should be ignore
- ## "*.c", "*.asm", "*.h", "*.nasm", "*.s", "*.asl", "*.inf"
- ],
- "IgnoreFiles": [ # use gitignore syntax to ignore errors in matching files
- ],
- "ExtendWords": [ # words to extend to the dictionary for this package
- "agesa",
- "defaultdb",
- "defaultdbx",
- "deviceid",
- "eisaid",
- "flashid",
- "iomux",
- "jedec",
- "oemid",
- "pmioa",
- "ppread",
- "rdsfdp",
- "smdbg",
- "ssdtproc",
- "eeprom",
- "gpiox",
- "agpio",
- "sgpio",
- "acpimmio",
- "glink",
- "ehci's",
- "uhci's"
- ],
- "AdditionalIncludePaths": [] # Additional paths to spell check relative to package root (wildcards supported)
- },
- "DebugMacroCheck": {
- "StringSubstitutions": {
- # Reason: Expansion of macro that contains a print specifier.
- # AMD can write its own print specifier.
- # "AMD_PRINT": "0x%lx"
- }
- }
-}
diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec
index 6be301fd77d3801e481ab5e992ff5132f5c7cdb7..9355e009280d15028f49a96ba4a0da251f0e559f 100644
--- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec
+++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec
@@ -3,7 +3,7 @@
# This is the package provides the AMD edk2 common platform drivers
# and libraries for AMD Server, Client and Gaming console platforms.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -31,9 +31,9 @@
[Protocols]
gAmdSpiHcStateProtocolGuid = { 0x189566ab, 0x245, 0x43ae, {0x9d, 0x1, 0xd2, 0x21, 0x1c, 0xb9, 0x1a, 0xda }}
- gFakeDeviceIoProtocolGuid = { 0x7fecf70, 0xd7ae, 0x4274, {0x9f, 0x70, 0x78, 0xc8, 0x36, 0x91, 0xd4, 0xfb }}
- gEdk2EspiSmmDriverProtocolGuid = { 0x0ecc91df, 0xe165, 0x42ee, {0x82, 0xa7, 0x8d, 0x63, 0x98, 0x53, 0x6a, 0x31 }}
- gAmdEspiSmmNorFlashProtocolGuid = { 0x6ef7b652, 0x84b7, 0x4d43, {0x9d, 0x88, 0x04, 0xb3, 0x0c, 0x49, 0xde, 0xd5 }}
+ gFakeDeviceIoProtocolGuid = {0x7fecf70, 0xd7ae, 0x4274, {0x9f, 0x70, 0x78, 0xc8, 0x36, 0x91, 0xd4, 0xfb}}
+ gEdk2EspiSmmDriverProtocolGuid = {0x0ecc91df, 0xe165, 0x42ee, {0x82, 0xa7, 0x8d, 0x63, 0x98, 0x53, 0x6a, 0x31}}
+ gAmdEspiSmmNorFlashProtocolGuid = {0x6ef7b652, 0x84b7, 0x4d43, {0x9d, 0x88, 0x04, 0xb3, 0x0c, 0x49, 0xde, 0xd5}}
[PcdsDynamic]
## Event GUID to trigger logo displaying
@@ -80,6 +80,22 @@
MdeModulePkg/MdeModulePkg.dec
}
+ #
+ # SPI PCDs
+ #
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdSpiRetryCount|0xFFFFFFFF|UINT32|0x00020006
+
+ #
+ # eSPI PCDs
+ #
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdEspiOffset|0x10000|UINT32|0x00040003
+
+ #
+ # ROM selection PCDs
+ #
+ gAmdPlatformPkgTokenSpaceGuid.PcdRom3FlashAreaBase|0x00000000|UINT64|0x00020007
+ gAmdPlatformPkgTokenSpaceGuid.PcdRom3FlashAreaSize|0x00000000|UINT64|0x00020008
+
#
# These PCDs are mapped to AMD SMBIOS type 9 record structure
#
@@ -95,6 +111,7 @@
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.CardBusSupported|0
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.ZoomVideoSupported|0
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics1.ModemRingResumeSupported|0
+
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2|{0x0}|MISC_SLOT_CHARACTERISTICS2|0x0002000A {
IndustryStandard/SmBios.h
@@ -106,18 +123,23 @@
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.AsyncSurpriseRemoval|0
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.FlexbusSlotCxl10Capable|0
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.FlexbusSlotCxl20Capable|0
- gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.FlexbusSlotCxl30Capable|0
-
- #
- # SPI PCDs
- #
- gAmdPlatformPkgTokenSpaceGuid.PcdAmdSpiRetryCount|0xFFFFFFFF|UINT32|0x00020006
- gAmdPlatformPkgTokenSpaceGuid.PcdFlashNvStorageBlockSize|0x1000|UINT32|0x0002000B
- gAmdPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress|0xFF000000|UINT32|0x10000001
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType9SlotCharacteristics2.Reserved|0
[PcdsDynamic, PcdsDynamicEx]
+
# SMBIOS
gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStringsCount|0|UINT8|0x00030001
gAmdPlatformPkgTokenSpaceGuid.PcdType11OemStrings|NULL|VOID*|0x00030002
gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptionsCount|0|UINT8|0x00030003
gAmdPlatformPkgTokenSpaceGuid.PcdType12SystemCfgOptions|NULL|VOID*|0x00030004
+
+[PcdsFeatureFlag]
+ ## ROM Armor PCDs
+ # Used to specify if the Rom Armor is enabled or not
+ gAmdPlatformPkgTokenSpaceGuid.PcdRomArmorEnable|FALSE|BOOLEAN|0x00040000
+ # pecify whether to enable ROM Armor white list for the SPI device.
+ gAmdPlatformPkgTokenSpaceGuid.PcdRomArmorWhitelistEnable|FALSE|BOOLEAN|0x00040001
+
+ # Used to specify if the driver should disable SPI Write Enable command
+ # outside of SMM.
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdSpiWriteDisable|TRUE|BOOLEAN|0x00040002
diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc
index 60d77ec22ee0bb340b3b048918acbc965096c473..90b5d636cebe146cbbfebbf46ed78a433b6bc80f 100644
--- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc
+++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc
@@ -3,7 +3,7 @@
# This is the package provides the AMD edk2 common platform drivers
# and libraries for AMD Server, Client and Gaming console platforms.
#
-# Copyright (C) 2023 - 2025 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -23,10 +23,11 @@
!include MdePkg/MdeLibs.dsc.inc
+# Include AGESA module for edk2-platforms
+!include AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
+
[LibraryClasses.Common]
- AcpiHelperLib|DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
AlwaysFalseDepexLib|AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf
- AmlLib|DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
@@ -35,21 +36,15 @@
DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
- IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
- LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
- PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
- PciSegmentInfoLib|MdePkg/Library/BasePciSegmentInfoLibNull/BasePciSegmentInfoLibNull.inf
PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf
+ PlatformSocLib|AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
- StackCheckLib|MdePkg/Library/StackCheckLibNull/StackCheckLibNull.inf
SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -62,42 +57,113 @@
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
!endif
-[LibraryClasses.common.DXE_DRIVER]
+ AmlLib|DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
+ AcpiHelperLib|DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+ AmdPspBaseLibV2|AgesaModulePkg/Library/AmdPspBaseLibV2/AmdPspBaseLibV2.inf
+ AmdPspMmioLib|AgesaModulePkg/Library/AmdPspMmioLib/AmdPspMmioLib.inf
+ AmdPspRegBaseLib|AgesaModulePkg/Library/AmdPspRegBaseLib/AmdPspRegBaseLib.inf
+ AmdSocBaseLib|AgesaModulePkg/Library/AmdSocBaseLib/AmdSocBaseLib.inf
+ AmdHeapLib|AgesaModulePkg/Library/AmdHeapLibNull/AmdHeapLibNull.inf
+ AmdPspRegMuxLibV2|AgesaModulePkg/Library/AmdPspRegMuxLibV2Null/AmdPspRegMuxLibV2.inf
+ AmdDirectoryBaseLib|AgesaModulePkg/Library/AmdDirectoryBaseLib/AmdDirectoryBaseLib.inf
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+ FchSpiAccessLib|AgesaModulePkg/Library/FchSpiAccessLib/FchSpiAccessRom2Lib.inf
+
+ IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+ AmlGenerationLib|AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
+ SmnAccessLib|AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
+ SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
+
+ BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
+ SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+ BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf
+ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
+ UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
+ DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
+ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
+ UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
+ PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
+
+ # Simulator serial port 80
+ SerialPortLib|AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf
+
+ # Boot logo
+
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
+[LibraryClasses.common.DXE_CORE, LibraryClasses.common.DXE_SMM_DRIVER, LibraryClasses.common.SMM_CORE, LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION]
+ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
+ ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
+
+[LibraryClasses.common.DXE_SMM_DRIVER]
+ SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
+ AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
+ PlatformPspRomArmorWhitelistLib|AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
+
+[LibraryClasses.Common.DXE_DRIVER]
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
- PlatformSocLib|AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
- SpiHcPlatformLib|AmdPlatformPkg/Universal/Spi/SpiFvb/SpiFvbDxe.inf
- TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
-[LibraryClasses.common.SMM_CORE]
- SmmCoreAmdSpiHcHookLib|AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
+ AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
+
+[LibraryClasses.Common.SMM_CORE]
SmmCorePlatformHookLib|AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
+ SmmCoreAmdSpiHcHookHookLib|AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
-[LibraryClasses.common.DXE_SMM_DRIVER]
- MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
- SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
- SpiHcPlatformLib|AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
+[Components.common.DXE_DRIVER]
+ AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonDxe.inf # AMD SMBIOS common DXE driver
[Components]
- AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
- AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.inf
- AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.inf
- AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.inf
- AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SamplecmPlatOverrideLib.inf
AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf
AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf
- AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
- AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
- AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf
- AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
+ AmdPlatformPkg/Universal/SecureBoot/SecureBootDefaultKeysInit/SecureBootDefaultKeysInit.inf
AmdPlatformPkg/Universal/HiiConfigRouting/AmdConfigRouting.inf
AmdPlatformPkg/Universal/LogoDxe/JpegLogoDxe.inf # Server platform JPEG logo driver
AmdPlatformPkg/Universal/LogoDxe/LogoDxe.inf # Server platfrom Bitmap logo driver
AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf
- AmdPlatformPkg/Universal/SecureBoot/SecureBootDefaultKeysInit/SecureBootDefaultKeysInit.inf
- AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonDxe.inf
+
+ AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
+ AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
+ AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+ AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
+[Components.X64]
+ AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.inf
+ AmdPlatformPkg/Universal/Spi/AmdSpiFvb/AmdSpiFvbSmm.inf
+ AmdPlatformPkg/Universal/Spi/AmdSpiFvb/AmdSpiFvbDxe.inf
+ AmdPlatformPkg/Universal/Spi/AmdSpiHc/AmdSpiHcSmm.inf
+ AmdPlatformPkg/Universal/Spi/AmdSpiHc/AmdSpiHcDxe.inf
+ AmdPlatformPkg/Universal/Spi/BoardSpiBus/BoardSpiBusDxe.inf
+ AmdPlatformPkg/Universal/Spi/BoardSpiBus/BoardSpiBusSmm.inf
AmdPlatformPkg/Universal/Spi/BoardSpiConfig/BoardSpiConfigDxe.inf
AmdPlatformPkg/Universal/Spi/BoardSpiConfig/BoardSpiConfigSmm.inf
- AmdPlatformPkg/Universal/Spi/SpiFvb/SpiFvbDxe.inf
- AmdPlatformPkg/Universal/Spi/SpiFvb/SpiFvbSmm.inf
+
+[BuildOptions]
+ GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+ INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+ MSFT:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
+
+ GCC:*_*_*_CC_FLAGS = -D USE_EDKII_HEADER_FILE
+
+ # Turn off DEBUG messages for Release Builds
+ GCC:RELEASE_*_*_CC_FLAGS = -D MDEPKG_NDEBUG
+ INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
+ MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
+
+ !ifdef $(INTERNAL_IDS)
+ GCC:*_*_*_CC_FLAGS = -DINTERNAL_IDS
+ INTEL:*_*_*_CC_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_CC_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_VFRPP_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_ASLCC_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_ASLPP_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_PP_FLAGS = /D INTERNAL_IDS
+ MSFT:*_*_*_APP_FLAGS = /D INTERNAL_IDS
+ !endif
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Hpet.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Hpet.c
deleted file mode 100644
index f583094d4899b808f0ae83a90c8f12972b04d796..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Hpet.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file
- This file implements the ACPI table updates for the Configuration Manager DXE driver.
-
- It includes functions to update the HPET table information in the Platform Repository.
-
- Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-#include "../ConfigurationManager.h"
-#include
-#include
-
-/**
- Update HPET table information in Platform Repository.
-
- @param[in] PlatformRepo The pointer to the Platform Repository.
-
- @retval EFI_SUCCESS The HPET table information is updated successfully.
- @retval EFI_INVALID_PARAMETER The input parameter is NULL.
-**/
-EFI_STATUS
-EFIAPI
-UpdateHpetTableInfo (
- IN EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- )
-{
- UINT64 HpetCapabilities;
- UINTN Index;
- UINTN TableIndex;
-
- if (PlatformRepo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- HpetCapabilities = MmioRead64 (PlatformRepo->HpetInfo.BaseAddressLower32Bit);
- if ((HpetCapabilities == 0) || (HpetCapabilities == MAX_UINT64)) {
- for (Index = 0; Index < PlatformRepo->CurrentAcpiTableCount; Index++) {
- if (PlatformRepo->CmAcpiTableList[Index].TableGeneratorId == CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdHpet)) {
- for (TableIndex = Index; TableIndex < PlatformRepo->CurrentAcpiTableCount - 1; TableIndex++) {
- CopyMem (&PlatformRepo->CmAcpiTableList[TableIndex], &PlatformRepo->CmAcpiTableList[TableIndex + 1], sizeof (CM_STD_OBJ_ACPI_TABLE_INFO));
- }
-
- ZeroMem (&PlatformRepo->CmAcpiTableList[PlatformRepo->CurrentAcpiTableCount - 1], sizeof (CM_STD_OBJ_ACPI_TABLE_INFO));
- PlatformRepo->CurrentAcpiTableCount--;
- break;
- }
- }
-
- for (Index = 0; Index < PlatformRepo->CurrentAcpiTableCount; Index++) {
- if (PlatformRepo->CmAcpiTableList[Index].TableGeneratorId == CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdtHpet)) {
- for (TableIndex = Index; TableIndex < PlatformRepo->CurrentAcpiTableCount - 1; TableIndex++) {
- CopyMem (&PlatformRepo->CmAcpiTableList[TableIndex], &PlatformRepo->CmAcpiTableList[TableIndex + 1], sizeof (CM_STD_OBJ_ACPI_TABLE_INFO));
- }
-
- ZeroMem (&PlatformRepo->CmAcpiTableList[PlatformRepo->CurrentAcpiTableCount - 1], sizeof (CM_STD_OBJ_ACPI_TABLE_INFO));
- PlatformRepo->CurrentAcpiTableCount--;
- break;
- }
- }
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Madt.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Madt.c
deleted file mode 100755
index 7ffc2c8330c925ac4f45ce26aaa82df15e164da9..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Madt.c
+++ /dev/null
@@ -1,372 +0,0 @@
-/** @file
- Collects the information required to update the MADT table.
-
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "ConfigurationManager.h"
-
-UINT32 mMadtCcdOrder[16] = { 0, 4, 8, 12, 2, 6, 10, 14, 3, 7, 11, 15, 1, 5, 9, 13 };
-
-/**
- Callback compare function.
- Compares CCD number of provided arguments.
-
- @param[in] ProcessorInfoLeft Pointer to Left Buffer.
- @param[in] ProcessorInfoRight Pointer to Right Buffer.
- @return 0 If both are same
- -1 If left value is less than righ value.
- 1 If left value is greater than righ value.
-
-**/
-INTN
-EFIAPI
-MadtSortByCcd (
- CONST VOID *ProcessorInfoLeft,
- CONST VOID *ProcessorInfoRight
- )
-{
- CONST EFI_PROCESSOR_INFORMATION *Left;
- CONST EFI_PROCESSOR_INFORMATION *Right;
- UINT32 Index;
- UINT32 LeftCcdIndex;
- UINT32 RightCcdIndex;
-
- Left = (EFI_PROCESSOR_INFORMATION *)ProcessorInfoLeft;
- Right = (EFI_PROCESSOR_INFORMATION *)ProcessorInfoRight;
-
- // Get the CCD Index number
- LeftCcdIndex = MAX_UINT32;
- for (Index = 0; Index < ARRAY_SIZE (mMadtCcdOrder); Index++) {
- if (Left->ExtendedInformation.Location2.Die == mMadtCcdOrder[Index]) {
- LeftCcdIndex = Index;
- break;
- }
- }
-
- RightCcdIndex = MAX_UINT32;
- for (Index = 0; Index < ARRAY_SIZE (mMadtCcdOrder); Index++) {
- if (Right->ExtendedInformation.Location2.Die == mMadtCcdOrder[Index]) {
- RightCcdIndex = Index;
- break;
- }
- }
-
- // Now compare for quick sort
- if (LeftCcdIndex < RightCcdIndex) {
- return -1;
- }
-
- if (LeftCcdIndex > RightCcdIndex) {
- return 1;
- }
-
- return 0;
-}
-
-/** The UpdateMadtTable function updates the MADT table.
-
- @param [in, out] PlatformRepo Pointer to the platform repository information.
-
- @retval EFI_SUCCESS The MADT table is updated successfully.
- @retval EFI_INVALID_PARAMETER The input parameter is invalid.
-**/
-EFI_STATUS
-EFIAPI
-UpdateMadtTable (
- IN OUT EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- )
-{
- EFI_STATUS Status;
- EFI_MP_SERVICES_PROTOCOL *MpService;
- UINTN NumberOfProcessors;
- UINTN NumberOfEnabledProcessors;
- UINT32 Index;
- EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer;
- UINTN NumSocket;
- UINTN ThreadsPerCore;
- UINTN Socket;
- CM_X64_LOCAL_APIC_X2APIC_INFO *LocalApicInfo;
- CM_X64_LOCAL_APIC_X2APIC_INFO *TempLocalApicInfo;
- CM_X64_LOCAL_APIC_X2APIC_INFO *SrcLocalApicInfo;
- CM_X64_LOCAL_APIC_X2APIC_INFO *DstLocalApicInfo;
- UINT8 ApicMode;
- CM_X64_IO_APIC_INFO *CmIoApicInfo;
- EFI_ACPI_6_5_IO_APIC_STRUCTURE *IoApicInfo;
- UINTN IoApicCount;
- CM_X64_INTR_SOURCE_OVERRIDE_INFO *IntrSourceOverrideInfo;
- UINTN IntrSourceOverrideCount;
- CM_X64_LOCAL_APIC_X2APIC_NMI_INFO *LocalApicNmiInfo;
- UINTN LocalApicNmiCount;
-
- if (PlatformRepo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ApicMode = (UINT8)GetApicMode ();
- PlatformRepo->MadtInfo.LocalApicAddress = PcdGet32 (PcdCpuLocalApicBaseAddress);
- PlatformRepo->MadtInfo.Flags = EFI_ACPI_6_5_PCAT_COMPAT;
- PlatformRepo->MadtInfo.ApicMode = ApicMode;
-
- Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService);
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d Failed to locate MP Services Protocol. Status(%r)\n",
- __func__,
- __LINE__,
- Status
- ));
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- Status = MpService->GetNumberOfProcessors (
- MpService,
- &NumberOfProcessors,
- &NumberOfEnabledProcessors
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d Failed to get number of processors. Status(%r)\n",
- __func__,
- __LINE__,
- Status
- ));
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- ProcessorInfoBuffer = AllocateZeroPool (NumberOfProcessors * sizeof (EFI_PROCESSOR_INFORMATION));
- if (ProcessorInfoBuffer == NULL) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d Failed to allocate memory for Processor Information Buffer. Status(%r)\n",
- __func__,
- __LINE__,
- Status
- ));
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- /// Get ProcessorInfoBuffer
- NumSocket = 0;
- ThreadsPerCore = 0;
- for (Index = 0; Index < NumberOfProcessors; Index++) {
- Status = MpService->GetProcessorInfo (
- MpService,
- Index|CPU_V2_EXTENDED_TOPOLOGY,
- &ProcessorInfoBuffer[Index]
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d Failed to get Processor Information. Status(%r)\n",
- __func__,
- __LINE__,
- Status
- ));
- ASSERT_EFI_ERROR (Status);
- FreePool (ProcessorInfoBuffer);
- return Status;
- }
-
- if (ProcessorInfoBuffer[Index].ExtendedInformation.Location2.Package > NumSocket) {
- NumSocket = ProcessorInfoBuffer[Index].ExtendedInformation.Location2.Package;
- }
-
- if (ProcessorInfoBuffer[Index].ExtendedInformation.Location2.Thread > ThreadsPerCore) {
- ThreadsPerCore = ProcessorInfoBuffer[Index].ExtendedInformation.Location2.Thread;
- }
- }
-
- /// Increment the NumSocket and ThreadsPerCore by 1, as it is 0 based
- NumSocket++;
- ThreadsPerCore++;
-
- /// Sort by CCD location
- if (NumSocket > 1) {
- PerformQuickSort (
- ProcessorInfoBuffer,
- NumberOfProcessors/2,
- sizeof (EFI_PROCESSOR_INFORMATION),
- MadtSortByCcd
- );
- PerformQuickSort (
- ProcessorInfoBuffer+(NumberOfProcessors/2),
- NumberOfProcessors/2,
- sizeof (EFI_PROCESSOR_INFORMATION),
- MadtSortByCcd
- );
- } else {
- PerformQuickSort (
- ProcessorInfoBuffer,
- NumberOfProcessors,
- sizeof (EFI_PROCESSOR_INFORMATION),
- MadtSortByCcd
- );
- }
-
- LocalApicInfo = AllocateZeroPool (sizeof (CM_X64_LOCAL_APIC_X2APIC_INFO) * NumberOfProcessors);
- if (LocalApicInfo == NULL) {
- FreePool (ProcessorInfoBuffer);
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Socket = 0; Socket < NumSocket; Socket++) {
- for (Index = 0; Index < NumberOfProcessors; Index++) {
- if (ProcessorInfoBuffer[Index].ProcessorId > MAX_UINT32) {
- DEBUG ((DEBUG_ERROR, "%a:%d ProcessorId is greater than MAX_UINT32\n", __func__, __LINE__));
- FreePool (ProcessorInfoBuffer);
- ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
- return EFI_INVALID_PARAMETER;
- }
-
- LocalApicInfo[Index].ApicId = (UINT32)ProcessorInfoBuffer[Index].ProcessorId;
- if ((ProcessorInfoBuffer[Index].StatusFlag & PROCESSOR_ENABLED_BIT) != 0) {
- LocalApicInfo[Index].Flags = 1;
- }
-
- LocalApicInfo[Index].AcpiProcessorUid = Index;
- }
- }
-
- FreePool (ProcessorInfoBuffer);
-
- /// Now separate the first thread list
- TempLocalApicInfo = NULL;
- if (ThreadsPerCore > 1) {
- TempLocalApicInfo = AllocateCopyPool ((sizeof (CM_X64_LOCAL_APIC_X2APIC_INFO) * NumberOfProcessors), (const void *)LocalApicInfo);
- if (TempLocalApicInfo == NULL) {
- FreePool (LocalApicInfo);
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- SrcLocalApicInfo = TempLocalApicInfo;
- DstLocalApicInfo = LocalApicInfo;
- for (Index = 0; Index < NumberOfProcessors; Index++) {
- if ((SrcLocalApicInfo->ApicId & 0x1) == 0) {
- CopyMem (DstLocalApicInfo, SrcLocalApicInfo, sizeof (CM_X64_LOCAL_APIC_X2APIC_INFO));
- SrcLocalApicInfo++;
- DstLocalApicInfo++;
- } else {
- SrcLocalApicInfo++;
- }
- }
-
- SrcLocalApicInfo = TempLocalApicInfo;
- for (Index = 0; Index < NumberOfProcessors; Index++) {
- if ((SrcLocalApicInfo->ApicId & 0x1) == 1) {
- CopyMem (DstLocalApicInfo, SrcLocalApicInfo, sizeof (CM_X64_LOCAL_APIC_X2APIC_INFO));
- SrcLocalApicInfo++;
- DstLocalApicInfo++;
- } else {
- SrcLocalApicInfo++;
- }
- }
- }
-
- if (TempLocalApicInfo != NULL) {
- FreePool (TempLocalApicInfo);
- }
-
- /// Now copy the LocalApicInfo to PlatformRepo
- PlatformRepo->LocalApicX2ApicInfoCount = NumberOfProcessors;
- PlatformRepo->LocalApicX2ApicInfo = LocalApicInfo;
-
- /// Get the IO APIC Information
-
- IoApicInfo = NULL;
- IoApicCount = 0;
- Status = GetIoApicInfo (&IoApicInfo, (UINT8 *)&IoApicCount);
- if ((EFI_ERROR (Status) || (IoApicInfo == NULL) || (IoApicCount == 0))) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d GetIoApicInfo() failed. Status (%r).\n",
- __func__,
- __LINE__,
- Status
- ));
- return Status;
- }
-
- CmIoApicInfo = NULL;
- CmIoApicInfo = AllocateZeroPool (sizeof (CM_X64_IO_APIC_INFO) * IoApicCount);
- if (CmIoApicInfo == NULL) {
- FreePool (IoApicInfo);
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- /// Copy the IO APIC Information
- for (Index = 0; Index < IoApicCount; Index++) {
- CmIoApicInfo[Index].IoApicId = IoApicInfo[Index].IoApicId;
- CmIoApicInfo[Index].IoApicAddress = IoApicInfo[Index].IoApicAddress;
- CmIoApicInfo[Index].GlobalSystemInterruptBase = IoApicInfo[Index].GlobalSystemInterruptBase;
- }
-
- FreePool (IoApicInfo);
-
- PlatformRepo->IoApicInfoCount = IoApicCount;
- PlatformRepo->IoApicInfo = CmIoApicInfo;
-
- /// Get the Interrupt Source Override Information
- IntrSourceOverrideCount = 2;
- IntrSourceOverrideInfo = AllocateZeroPool (sizeof (CM_X64_INTR_SOURCE_OVERRIDE_INFO) * IntrSourceOverrideCount);
- if (IntrSourceOverrideInfo == NULL) {
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- IntrSourceOverrideInfo[0].Bus = 0x0;
- IntrSourceOverrideInfo[0].Source = 0x0;
- IntrSourceOverrideInfo[0].GlobalSystemInterrupt = 0x2;
- IntrSourceOverrideInfo[0].Flags = 0xF;
-
- IntrSourceOverrideInfo[1].Bus = 0x0;
- IntrSourceOverrideInfo[1].Source = 0x9;
- IntrSourceOverrideInfo[1].GlobalSystemInterrupt = 0x9;
- IntrSourceOverrideInfo[1].Flags = 0xF;
-
- PlatformRepo->IntrSourceOverrideInfoCount = IntrSourceOverrideCount;
- PlatformRepo->IntrSourceOverrideInfo = IntrSourceOverrideInfo;
-
- /// Get the Local APIC NMI Information
- LocalApicNmiCount = 1;
- LocalApicNmiInfo = AllocateZeroPool (sizeof (CM_X64_LOCAL_APIC_X2APIC_NMI_INFO) * LocalApicNmiCount);
- if (LocalApicNmiInfo == NULL) {
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- return EFI_OUT_OF_RESOURCES;
- }
-
- LocalApicNmiInfo[0].Flags = 0x5;
- if (ApicMode == LOCAL_APIC_MODE_X2APIC) {
- LocalApicNmiInfo[0].AcpiProcessorUid = MAX_UINT32;
- } else {
- LocalApicNmiInfo[0].AcpiProcessorUid = MAX_UINT8;
- }
-
- LocalApicNmiInfo[0].LocalApicLint = 0x1;
-
- /// update the PlatformRepo
- PlatformRepo->LocalApicX2ApicNmiInfoCount = LocalApicNmiCount;
- PlatformRepo->LocalApicX2ApicNmiInfo = LocalApicNmiInfo;
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Mcfg.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Mcfg.c
deleted file mode 100644
index 572dc7b12347247b39b51cf5c988d55669b0c1bd..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/Acpi/Mcfg.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/** @file
- This file contains the implementation of the MCFG table initialization for the
- Configuration Manager DXE driver.
-
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include "../ConfigurationManager.h"
-
-/** Updates ACPI MCFG table information in the platform repository.
-
- @param [in] PlatformRepo Pointer to the platform repository.
-
- @retval EFI_SUCCESS The ACPI MCFG table information is updated.
- @retval EFI_INVALID_PARAMETER The input parameter is invalid.
- @retval EFI_NOT_FOUND The PCI segment information is not found.
-**/
-EFI_STATUS
-EFIAPI
-UpdateMcfgTableInfo (
- IN EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- )
-{
- PCI_SEGMENT_INFO *PciSegmentInfo;
- CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciConfigSpaceInfo;
- UINTN PciSegmentCount;
- UINTN Index;
-
- if (PlatformRepo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- PciSegmentInfo = NULL;
- PciSegmentCount = 0;
- PciSegmentInfo = GetPciSegmentInfo (&PciSegmentCount);
- if ((PciSegmentInfo == NULL) || (PciSegmentCount == 0)) {
- return EFI_NOT_FOUND;
- }
-
- PciConfigSpaceInfo = AllocateZeroPool (sizeof (CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO) * PciSegmentCount);
- if (PciConfigSpaceInfo == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- for (Index = 0; Index < PciSegmentCount; Index++) {
- PciConfigSpaceInfo[Index].BaseAddress = PciSegmentInfo[Index].BaseAddress;
- PciConfigSpaceInfo[Index].PciSegmentGroupNumber = PciSegmentInfo[Index].SegmentNumber;
- PciConfigSpaceInfo[Index].StartBusNumber = PciSegmentInfo[Index].StartBusNumber;
- PciConfigSpaceInfo[Index].EndBusNumber = PciSegmentInfo[Index].EndBusNumber;
- }
-
- PlatformRepo->PciConfigSpaceInfoCount = PciSegmentCount;
- PlatformRepo->PciConfigSpaceInfo = PciConfigSpaceInfo;
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c
deleted file mode 100755
index 724645bb0af6f3699c1cffad0e1f35a387db2386..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/** @file
- Configuration Manager Protocol implementation for AMD platform.
- This file implements the Configuration Manager Protocol for the AMD platform.
- The Configuration Manager Protocol is used to provide the Configuration
- Objects to the Configuration Manager.
-
- Copyright (C) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "ConfigurationManager.h"
-
-/** The platform configuration repository information.
-*/
-STATIC
-EDKII_PLATFORM_REPOSITORY_INFO mAmdPlatformRepositoryInfo = {
- /// Configuration Manager Information
- {
- CONFIGURATION_MANAGER_REVISION,
- CFG_MGR_OEM_ID
- },
- /// ACPI Table List
- {
- /// FACS Table
- {
- EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE,
- EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFacs),
- NULL
- },
- /// FADT Table
- {
- EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt),
- NULL
- },
- /// HPET Table
- {
- EFI_ACPI_6_3_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE,
- EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdHpet),
- NULL
- },
- /// HPET Ssdt Table
- {
- EFI_ACPI_6_5_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
- 0, // Unused
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdtHpet),
- NULL
- },
- /// WSMT Table
- {
- EFI_ACPI_6_3_WINDOWS_SMM_SECURITY_MITIGATION_TABLE_SIGNATURE,
- EFI_WSMT_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdWsmt),
- NULL
- },
- /// SPMI Table
- {
- EFI_ACPI_6_5_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE,
- EFI_ACPI_SERVICE_PROCESSOR_MANAGEMENT_INTERFACE_5_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSpmi),
- NULL
- },
- /// MCFG Table
- {
- EFI_ACPI_6_5_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMcfg),
- NULL
- },
- /// MADT Table
- {
- EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE,
- EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMadt),
- NULL
- },
- /// SRAT Table
- {
- EFI_ACPI_6_5_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE,
- EFI_ACPI_6_5_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION,
- CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSrat),
- NULL
- }
- },
- /// Current ACPI Table Count
- PLAT_ACPI_TABLE_COUNT,
- /// FACS info
- {
- 0,
- 0,
- 0,
- 0
- },
- /// PmProfile
- {
- EFI_ACPI_6_5_PM_PROFILE_ENTERPRISE_SERVER
- },
- /// HypervisorVendorId
- {
- 0x00000000
- },
- /// FixedFeatureFlags
- {
- EFI_ACPI_6_5_WBINVD | \
- EFI_ACPI_6_5_PROC_C1 | \
- EFI_ACPI_6_5_P_LVL2_UP | \
- EFI_ACPI_6_5_SLP_BUTTON | \
- EFI_ACPI_6_5_TMR_VAL_EXT | \
- EFI_ACPI_6_5_RESET_REG_SUP | \
- EFI_ACPI_6_5_REMOTE_POWER_ON_CAPABLE
- },
- /// SciInterrupt
- {
- 0x0009
- },
- /// SciCmdinfo
- {
- 0x000000B2,
- 0xA0,
- 0xA1,
- 0x00,
- 0x00,
- 0x00
- },
- /// PmBlockInfo
- {
- 0x00000800,
- 0x00000000,
- 0x00000804,
- 0x00000000,
- 0x00000000,
- 0x00000808,
- 0x04,
- 0x02,
- 0x00,
- 0x04
- },
- /// GPE block
- {
- 0x00000820,
- 0x00000000,
- 0x08,
- 0x00,
- 0x00
- },
- /// X PM Event
- {
- { EFI_ACPI_6_5_SYSTEM_IO, 0x20, 0x0, EFI_ACPI_6_5_WORD, 0x0000000000000800 },
- { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 },
- { EFI_ACPI_6_5_SYSTEM_IO, 0x10, 0x0, EFI_ACPI_6_5_WORD, 0x0000000000000804 },
- { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 },
- { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 },
- { EFI_ACPI_6_5_SYSTEM_IO, 0x20, 0x0, EFI_ACPI_6_5_DWORD, 0x0000000000000808 }
- },
- /// X GPE Event
- {
- { EFI_ACPI_6_5_SYSTEM_IO, 0x40, 0x0, EFI_ACPI_6_5_BYTE, 0x0000000000000820 },
- { 0x0, 0x0, 0x0, 0x0, 0x0000000000000000 }
- },
- /// Sleep Event
- {
- { 0x0, 0x0, 0x0, 0x0, 0x0 },
- { 0x0, 0x0, 0x0, 0x0, 0x0 }
- },
- /// Reset Event
- {
- { EFI_ACPI_6_5_SYSTEM_IO, 0x8, 0x0, EFI_ACPI_6_5_UNDEFINED, 0x0000000000000CF9 },
- 0x06
- },
- /// FadtMiscInfo
- {
- 0x0064,
- 0x03E9,
- 0x0400,
- 0x0010,
- 0x01,
- 0x03,
- 0x0D,
- 0x00,
- 0x32
- },
- /// HpetInfo
- {
- FixedPcdGet64 (PcdHpetBaseAddress),
- 0x37EE,
- 0x0
- },
- /// Wsmt flags info
- {
- EFI_WSMT_PROTECTION_FLAGS_FIXED_COMM_BUFFERS | \
- EFI_WSMT_PROTECTION_FLAGS_COMM_BUFFER_NESTED_PTR_PROTECTION | \
- EFI_WSMT_PROTECTION_FLAGS_SYSTEM_RESOURCE_PROTECTION
- },
- /// SpmiInterruptInfo
- {
- 0x01,
- { EFI_ACPI_6_5_SYSTEM_IO, 0x8, 0, 0, 0x0000000000000CA2 }
- }
-};
-
-/** A structure describing the configuration manager protocol interface.
-*/
-STATIC
-EDKII_CONFIGURATION_MANAGER_PROTOCOL mAmdPlatformConfigManagerProtocol = {
- CREATE_REVISION (1, 0),
- AmdPlatformGetObject,
- AmdPlatformSetObject,
- &mAmdPlatformRepositoryInfo
-};
-
-/**
- Entrypoint of Configuration Manager Dxe.
-
- @param [in] ImageHandle
- @param [in] SystemTable
-
- @return EFI_SUCCESS
- @return EFI_LOAD_ERROR
- @return EFI_OUT_OF_RESOURCES
-**/
-EFI_STATUS
-EFIAPI
-ConfigurationManagerDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- UINTN Index;
-
- Status = UpdateMcfgTableInfo (&mAmdPlatformRepositoryInfo);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "ERROR: Failed to update MCFG table info. Status = %r\n", Status));
- return Status;
- }
-
- /// set the OemTableId and OemRevision for the CmACpiTableList
- for (Index = 0; Index < mAmdPlatformRepositoryInfo.CurrentAcpiTableCount; Index++) {
- mAmdPlatformRepositoryInfo.CmAcpiTableList[Index].OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId);
- mAmdPlatformRepositoryInfo.CmAcpiTableList[Index].OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision);
- }
-
- UpdateMadtTable (&mAmdPlatformRepositoryInfo);
- Status = UpdateHpetTableInfo (&mAmdPlatformRepositoryInfo);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "ERROR: Failed to update HPET table info. Status = %r\n", Status));
- return Status;
- }
-
- Status = gBS->InstallProtocolInterface (
- &ImageHandle,
- &gEdkiiConfigurationManagerProtocolGuid,
- EFI_NATIVE_INTERFACE,
- (VOID *)&mAmdPlatformConfigManagerProtocol
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Failed to get Install Configuration Manager Protocol." \
- " Status = %r\n",
- Status
- ));
- }
-
- return Status;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h
deleted file mode 100755
index cb86efa5b900235fa33bcfc11b3e0abba7376c89..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManager.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file
-
- Copyright (C) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
- @par Glossary:
- - Cm or CM - Configuration Manager
- - Obj or OBJ - Object
-**/
-
-#ifndef CONFIGURATION_MANAGER_H_
-#define CONFIGURATION_MANAGER_H_
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-/** The SetObject function defines the interface implemented by the
- Configuration Manager Protocol for updating the Configuration
- Manager Objects.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in] CmObject Pointer to the Configuration Manager Object
- descriptor describing the Object.
-
- @retval EFI_UNSUPPORTED This operation is not supported.
-**/
-EFI_STATUS
-EFIAPI
-AmdPlatformSetObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN CM_OBJ_DESCRIPTOR *CONST CmObject
- );
-
-/** The GetObject function defines the interface implemented by the
- Configuration Manager Protocol for returning the Configuration
- Manager Objects.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in, out] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-AmdPlatformGetObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
- );
-
-/** Updates ACPI MCFG table information in the platform repository.
-
- @param [in] PlatformRepo Pointer to the platform repository.
-
- @retval EFI_SUCCESS The ACPI MCFG table information is updated.
- @retval EFI_INVALID_PARAMETER The input parameter is invalid.
- @retval EFI_UNSUPPORTED The operation is not supported.
-**/
-EFI_STATUS
-EFIAPI
-UpdateMcfgTableInfo (
- IN EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- );
-
-/** The UpdateMadtTable function updates the MADT table.
-
- @param [in, out] PlatformRepo Pointer to the platform repository information.
-
- @retval EFI_SUCCESS The MADT table is updated successfully.
- @retval EFI_INVALID_PARAMETER The input parameter is invalid.
-**/
-EFI_STATUS
-EFIAPI
-UpdateMadtTable (
- IN OUT EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- );
-
-/**
- Update HPET table information in Platform Repository.
-
- @param[in] PlatformRepo The pointer to the Platform Repository.
-
- @retval EFI_SUCCESS The HPET table information is updated successfully.
- @retval EFI_INVALID_PARAMETER The input parameter is NULL.
-**/
-EFI_STATUS
-EFIAPI
-UpdateHpetTableInfo (
- IN EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo
- );
-
-#endif // CONFIGURATION_MANAGER_H_
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
deleted file mode 100755
index 341c460ef6cf396877efd2ae3f7cf150fcc74209..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/ConfigurationManagerDxe.inf
+++ /dev/null
@@ -1,65 +0,0 @@
-## @file
-# AMD platform configuration manager Dxe driver.
-#
-# Copyright (C) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = ConfigurationManagerDxe
- FILE_GUID = C0400631-702B-4E7D-9CC1-38F0BD021F5D
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = ConfigurationManagerDxeInitialize
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = X64
-#
-
-[Sources]
- Acpi/Hpet.c
- Acpi/Madt.c
- Acpi/Mcfg.c
- ConfigurationManager.c
- ConfigurationManager.h
- NameSpaceObject.c
-
-[Packages]
- AmdPlatformPkg/AmdPlatformPkg.dec
- DynamicTablesPkg/DynamicTablesPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
- PcAtChipsetPkg/PcAtChipsetPkg.dec
-
-[LibraryClasses]
- BaseMemoryLib
- DebugLib
- LocalApicLib
- MemoryAllocationLib
- IoLib
- PciSegmentInfoLib
- PlatformSocLib
- PrintLib
- SortLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiRuntimeServicesTableLib
-
-[Protocols]
- gEdkiiConfigurationManagerProtocolGuid
- gEfiMpServiceProtocolGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId
- gPcAtChipsetPkgTokenSpaceGuid.PcdHpetBaseAddress
- gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
-
-[Depex]
- TRUE
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c
deleted file mode 100644
index 2efdc24f4e113872ca73ee8d7e274044e9986ad0..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/ConfigurationManagerDxe/NameSpaceObject.c
+++ /dev/null
@@ -1,1028 +0,0 @@
-/** @file
- This file implements the Get/Set function for the Configuration Manager.
-
- Copyright (C) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-#include
-#include
-#include
-#include
-#include
-#include "ConfigurationManager.h"
-
-/** A helper function for returning the Configuration Manager Objects.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Object Pointer to the Object(s).
- @param [in] ObjectSize Total size of the Object(s).
- @param [in] ObjectCount Number of Objects.
- @param [in, out] CmObjectDesc Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
- @retval EFI_SUCCESS Success.
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-HandleCmObject (
- IN CONST CM_OBJECT_ID CmObjectId,
- IN VOID *Object,
- IN CONST UINTN ObjectSize,
- IN CONST UINTN ObjectCount,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObjectDesc
- )
-{
- if ((ObjectSize > MAX_UINT32) || (ObjectCount > MAX_UINT32)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Object == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- CmObjectDesc->ObjectId = CmObjectId;
- CmObjectDesc->Size = (UINT32)ObjectSize;
- CmObjectDesc->Data = (VOID *)Object;
- CmObjectDesc->Count = (UINT32)ObjectCount;
- DEBUG ((
- DEBUG_INFO,
- "INFO: CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n",
- CmObjectId,
- CmObjectDesc->Data,
- CmObjectDesc->Size,
- CmObjectDesc->Count
- ));
- return EFI_SUCCESS;
-}
-
-/** A helper function for setting the Configuration Manager Objects.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [out] Object Pointer to the Object(s).
- @param [in] ObjectSize Total size of the Object(s).
- @param [in] ObjectCount Number of Objects.
- @param [in] CmObjectDesc Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
- @retval EFI_SUCCESS Success.
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-SetHandleCmObject (
- IN CONST CM_OBJECT_ID CmObjectId,
- OUT VOID *Object,
- IN CONST UINTN ObjectSize,
- IN CONST UINTN ObjectCount,
- IN CM_OBJ_DESCRIPTOR *CONST CmObjectDesc
- )
-{
- DEBUG ((
- DEBUG_INFO,
- "INFO: Received CmObjectId = %x, Ptr = 0x%p, Size = %d, Count = %d\n",
- CmObjectId,
- CmObjectDesc->Data,
- CmObjectDesc->Size,
- CmObjectDesc->Count
- ));
- if ((CmObjectDesc->Size != ObjectSize) || (CmObjectDesc->Count != ObjectCount)) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- CopyMem (Object, CmObjectDesc->Data, (ObjectSize * ObjectCount));
-
- return EFI_SUCCESS;
-}
-
-/** A helper function for setting the Configuration Manager Objects.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [out] Object Pointer to the Object(s).
- @param [in] ObjectSize Total size of the Object(s).
- @param [in] ObjectCount Number of Objects.
- @param [in] CmObjectDesc Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_BAD_BUFFER_SIZE The buffer size is invalid.
- @retval EFI_OUT_OF_RESOURCES The buffer allocation failed.
- @retval EFI_BUFFER_TOO_SMALL The buffer is too small.
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-SetHandleCmObjectBuffer (
- IN CM_OBJECT_ID CmObjectId,
- OUT VOID **Object,
- IN CONST UINTN ObjectSize,
- IN UINTN *ObjectCount,
- IN CM_OBJ_DESCRIPTOR *CONST CmObjectDesc
- )
-{
- EFI_STATUS Status;
- VOID *Buffer;
-
- if ((Object == NULL) ||
- (*Object == NULL) ||
- (ObjectCount == NULL) ||
- (CmObjectDesc == NULL)
- )
- {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*ObjectCount == 0) {
- return EFI_BUFFER_TOO_SMALL;
- }
-
- if (CmObjectDesc->Count != *ObjectCount) {
- Buffer = AllocateZeroPool (CmObjectDesc->Size * CmObjectDesc->Count);
- if (Buffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- *ObjectCount = CmObjectDesc->Count;
- } else {
- Buffer = *Object;
- }
-
- Status = SetHandleCmObject (CmObjectId, Buffer, CmObjectDesc->Size, *ObjectCount, CmObjectDesc);
- if ((!EFI_ERROR (Status)) && (Buffer != *Object)) {
- FreePool (*Object);
- *Object = Buffer;
- }
-
- return Status;
-}
-
-/** Return a standard namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in, out] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-GetStandardNameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EStdObjCfgMgrInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->CmInfo,
- sizeof (PlatformRepo->CmInfo),
- 1,
- CmObject
- );
- break;
- case EStdObjAcpiTableList:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->CmAcpiTableList,
- sizeof (CM_STD_OBJ_ACPI_TABLE_INFO) * PlatformRepo->CurrentAcpiTableCount,
- PlatformRepo->CurrentAcpiTableCount,
- CmObject
- );
- break;
- default:
- {
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/** Return an architecture namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in, out] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-GetArchNameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EArchCommonObjPowerManagementProfileInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->PowerManagementProfile,
- sizeof (PlatformRepo->PowerManagementProfile),
- 1,
- CmObject
- );
- break;
-
- case EArchCommonObjHypervisorVendorIdentity:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->HypervisorVendorId,
- sizeof (PlatformRepo->HypervisorVendorId),
- 1,
- CmObject
- );
- break;
-
- case EArchCommonObjFixedFeatureFlags:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->FixedFeatureFlags,
- sizeof (PlatformRepo->FixedFeatureFlags),
- 1,
- CmObject
- );
- break;
-
- case EArchCommonObjSpmiInterfaceInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->SpmiInterfaceInfo,
- sizeof (PlatformRepo->SpmiInterfaceInfo),
- 1,
- CmObject
- );
- break;
- case EArchCommonObjPciConfigSpaceInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->PciConfigSpaceInfo,
- sizeof (*(PlatformRepo->PciConfigSpaceInfo)) * PlatformRepo->PciConfigSpaceInfoCount,
- PlatformRepo->PciConfigSpaceInfoCount,
- CmObject
- );
- break;
- case EArchCommonObjMemoryAffinityInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->MemoryAffinityInfo,
- sizeof (*(PlatformRepo->MemoryAffinityInfo)) * PlatformRepo->MemoryAffinityInfoCount,
- PlatformRepo->MemoryAffinityInfoCount,
- CmObject
- );
- break;
- default:
- {
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/** Set the data for standard namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-SetStandardNameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EStdObjAcpiTableList:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->CmAcpiTableList,
- sizeof (CM_STD_OBJ_ACPI_TABLE_INFO) * PlatformRepo->CurrentAcpiTableCount,
- PlatformRepo->CurrentAcpiTableCount,
- CmObject
- );
- break;
- default:
- {
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/** Set the data for an architecture namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-SetArchNameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EArchCommonObjPowerManagementProfileInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->PowerManagementProfile,
- sizeof (PlatformRepo->PowerManagementProfile),
- 1,
- CmObject
- );
- break;
-
- case EArchCommonObjHypervisorVendorIdentity:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->HypervisorVendorId,
- sizeof (PlatformRepo->HypervisorVendorId),
- 1,
- CmObject
- );
- break;
-
- case EArchCommonObjFixedFeatureFlags:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->FixedFeatureFlags,
- sizeof (PlatformRepo->FixedFeatureFlags),
- 1,
- CmObject
- );
- break;
- case EArchCommonObjPciConfigSpaceInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->PciConfigSpaceInfo,
- sizeof (*(PlatformRepo->PciConfigSpaceInfo)) * PlatformRepo->PciConfigSpaceInfoCount,
- (VOID *)&PlatformRepo->PciConfigSpaceInfoCount,
- CmObject
- );
- break;
- case EArchCommonObjMemoryAffinityInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->MemoryAffinityInfo,
- sizeof (*(PlatformRepo->MemoryAffinityInfo)) * PlatformRepo->MemoryAffinityInfoCount,
- (VOID *)&PlatformRepo->MemoryAffinityInfoCount,
- CmObject
- );
- break;
- default:
- {
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/** Return an architecture namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in, out] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-GetX64NameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EX64ObjFadtSciInterrupt:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->SciInterrupt,
- sizeof (PlatformRepo->SciInterrupt),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtSciCmdInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->SciCmdinfo,
- sizeof (PlatformRepo->SciCmdinfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtPmBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->PmBlockInfo,
- sizeof (PlatformRepo->PmBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtGpeBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->GpeBlockInfo,
- sizeof (PlatformRepo->GpeBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtXpmBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->XpmBlockInfo,
- sizeof (PlatformRepo->XpmBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtXgpeBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->XgpeBlockInfo,
- sizeof (PlatformRepo->XgpeBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtSleepBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->SleepBlockInfo,
- sizeof (PlatformRepo->SleepBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtResetBlockInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->ResetBlockInfo,
- sizeof (PlatformRepo->ResetBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtMiscInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->FadtMiscInfo,
- sizeof (PlatformRepo->FadtMiscInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjHpetInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->HpetInfo,
- sizeof (PlatformRepo->HpetInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjWsmtFlagsInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->WsmtFlagsInfo,
- sizeof (PlatformRepo->WsmtFlagsInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjMadtInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->MadtInfo,
- sizeof (PlatformRepo->MadtInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->LocalApicX2ApicInfo,
- sizeof (*(PlatformRepo->LocalApicX2ApicInfo)) * PlatformRepo->LocalApicX2ApicInfoCount,
- PlatformRepo->LocalApicX2ApicInfoCount,
- CmObject
- );
- break;
- case EX64ObjIoApicInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->IoApicInfo,
- sizeof (*(PlatformRepo->IoApicInfo)) * PlatformRepo->IoApicInfoCount,
- PlatformRepo->IoApicInfoCount,
- CmObject
- );
- break;
- case EX64ObjIntrSourceOverrideInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->IntrSourceOverrideInfo,
- sizeof (*(PlatformRepo->IntrSourceOverrideInfo)) * PlatformRepo->IntrSourceOverrideInfoCount,
- PlatformRepo->IntrSourceOverrideInfoCount,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicNmiInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->LocalApicX2ApicNmiInfo,
- sizeof (*(PlatformRepo->LocalApicX2ApicNmiInfo)) * PlatformRepo->LocalApicX2ApicNmiInfoCount,
- PlatformRepo->LocalApicX2ApicNmiInfoCount,
- CmObject
- );
- break;
- case EX64ObjFacsInfo:
- Status = HandleCmObject (
- CmObjectId,
- &PlatformRepo->FacsInfo,
- sizeof (PlatformRepo->FacsInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicAffinityInfo:
- Status = HandleCmObject (
- CmObjectId,
- PlatformRepo->LocalApicX2ApicAffinityInfo,
- sizeof (*PlatformRepo->LocalApicX2ApicAffinityInfo) * PlatformRepo->LocalApicX2ApicAffinityInfoCount,
- PlatformRepo->LocalApicX2ApicAffinityInfoCount,
- CmObject
- );
- break;
- default:
- {
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/**
- Set the data for X64 namespace object.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object.
- If unused this must be CM_NULL_TOKEN.
- @param [in] CmObject Pointer to the Configuration Manager Object.
-**/
-EFI_STATUS
-EFIAPI
-SetX64NameSpaceObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
- EDKII_PLATFORM_REPOSITORY_INFO *PlatformRepo;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- Status = EFI_NOT_FOUND;
- PlatformRepo = This->PlatRepoInfo;
-
- switch (GET_CM_OBJECT_ID (CmObjectId)) {
- case EX64ObjFacsInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->FacsInfo,
- sizeof (PlatformRepo->FacsInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtSciInterrupt:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->SciInterrupt,
- sizeof (PlatformRepo->SciInterrupt),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtSciCmdInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->SciCmdinfo,
- sizeof (PlatformRepo->SciCmdinfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtPmBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->PmBlockInfo,
- sizeof (PlatformRepo->PmBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtGpeBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->GpeBlockInfo,
- sizeof (PlatformRepo->GpeBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtXpmBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->XpmBlockInfo,
- sizeof (PlatformRepo->XpmBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtXgpeBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->XgpeBlockInfo,
- sizeof (PlatformRepo->XgpeBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtSleepBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->SleepBlockInfo,
- sizeof (PlatformRepo->SleepBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtResetBlockInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->ResetBlockInfo,
- sizeof (PlatformRepo->ResetBlockInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjFadtMiscInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->FadtMiscInfo,
- sizeof (PlatformRepo->FadtMiscInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjHpetInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->HpetInfo,
- sizeof (PlatformRepo->HpetInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjWsmtFlagsInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->WsmtFlagsInfo,
- sizeof (PlatformRepo->WsmtFlagsInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjMadtInfo:
- Status = SetHandleCmObject (
- CmObjectId,
- &PlatformRepo->MadtInfo,
- sizeof (PlatformRepo->MadtInfo),
- 1,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->LocalApicX2ApicInfo,
- sizeof (*(PlatformRepo->LocalApicX2ApicInfo)) * PlatformRepo->LocalApicX2ApicInfoCount,
- (VOID *)&PlatformRepo->LocalApicX2ApicInfoCount,
- CmObject
- );
- break;
- case EX64ObjIoApicInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->IoApicInfo,
- sizeof (*(PlatformRepo->IoApicInfo)) * PlatformRepo->IoApicInfoCount,
- (VOID *)&PlatformRepo->IoApicInfoCount,
- CmObject
- );
- break;
- case EX64ObjIntrSourceOverrideInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->IntrSourceOverrideInfo,
- sizeof (*(PlatformRepo->IntrSourceOverrideInfo)) * PlatformRepo->IntrSourceOverrideInfoCount,
- (VOID *)&PlatformRepo->IntrSourceOverrideInfoCount,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicNmiInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->LocalApicX2ApicNmiInfo,
- sizeof (*(PlatformRepo->LocalApicX2ApicNmiInfo)) * PlatformRepo->LocalApicX2ApicNmiInfoCount,
- (VOID *)&PlatformRepo->LocalApicX2ApicNmiInfoCount,
- CmObject
- );
- break;
- case EX64ObjLocalApicX2ApicAffinityInfo:
- Status = SetHandleCmObjectBuffer (
- CmObjectId,
- (VOID **)&PlatformRepo->LocalApicX2ApicAffinityInfo,
- sizeof (*PlatformRepo->LocalApicX2ApicAffinityInfo) * PlatformRepo->LocalApicX2ApicAffinityInfoCount,
- (VOID *)&PlatformRepo->LocalApicX2ApicAffinityInfoCount,
- CmObject
- );
- break;
- default:
- Status = EFI_NOT_FOUND;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Object 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
-
- return Status;
-}
-
-/** The GetObject function defines the interface implemented by the
- Configuration Manager Protocol for returning the Configuration
- Manager Objects.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in, out] CmObject Pointer to the Configuration Manager Object
- descriptor describing the requested Object.
-
- @retval EFI_SUCCESS Success.
- @retval EFI_INVALID_PARAMETER A parameter is invalid.
- @retval EFI_NOT_FOUND The required object information is not found.
-**/
-EFI_STATUS
-EFIAPI
-AmdPlatformGetObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN OUT CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- switch (GET_CM_NAMESPACE_ID (CmObjectId)) {
- case EObjNameSpaceStandard:
- Status = GetStandardNameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- case EObjNameSpaceArchCommon:
- Status = GetArchNameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- case EObjNameSpaceX64:
- Status = GetX64NameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- default:
- {
- Status = EFI_INVALID_PARAMETER;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Unknown Namespace Object = 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
-
-/** The SetObject function defines the interface implemented by the
- Configuration Manager Protocol for updating the Configuration
- Manager Objects.
-
- @param [in] This Pointer to the Configuration Manager Protocol.
- @param [in] CmObjectId The Configuration Manager Object ID.
- @param [in] Token An optional token identifying the object. If
- unused this must be CM_NULL_TOKEN.
- @param [in] CmObject Pointer to the Configuration Manager Object
- descriptor describing the Object.
-
- @retval EFI_UNSUPPORTED This operation is not supported.
-**/
-EFI_STATUS
-EFIAPI
-AmdPlatformSetObject (
- IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST This,
- IN CONST CM_OBJECT_ID CmObjectId,
- IN CONST CM_OBJECT_TOKEN Token OPTIONAL,
- IN CM_OBJ_DESCRIPTOR *CONST CmObject
- )
-{
- EFI_STATUS Status;
-
- if ((This == NULL) || (CmObject == NULL)) {
- ASSERT (This != NULL);
- ASSERT (CmObject != NULL);
- return EFI_INVALID_PARAMETER;
- }
-
- switch (GET_CM_NAMESPACE_ID (CmObjectId)) {
- case EObjNameSpaceStandard:
- Status = SetStandardNameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- case EObjNameSpaceArchCommon:
- Status = SetArchNameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- case EObjNameSpaceX64:
- Status = SetX64NameSpaceObject (This, CmObjectId, Token, CmObject);
- break;
-
- default:
- {
- Status = EFI_INVALID_PARAMETER;
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Unknown Namespace Object = 0x%x. Status = %r\n",
- CmObjectId,
- Status
- ));
- break;
- }
- }
-
- return Status;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.c
deleted file mode 100644
index 700dec37631ebff8613c7f249ffd84ccaa0b1e3f..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/** @file
-
- Generate ACPI FACS table for AMD platforms.
-
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-STATIC
-EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE mAcpiFacs = {
- EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE,
- sizeof (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE),
- /// Hardware Signature
- 0x00000000,
- /// Firmware Waking Vector
- 0x00000000,
- /// Global Lock
- 0x00000000,
- /// Flags
- 0x00000000,
- /// XFirmware Waking Vector
- 0x0000000000000000,
- /// Version
- EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION,
- /// Reserved0
- { 0, 0, 0 },
- /// OspmFlags
- 0x00000000,
- /// Reserved1
- { 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0}
-};
-
-/**
- Update the hardware signature in the FACS table.
-**/
-VOID
-AcpiFacsTableUpdate (
- VOID
- )
-{
- EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE *Facs;
- EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
- EFI_ACPI_DESCRIPTION_HEADER *Rsdt;
- EFI_ACPI_DESCRIPTION_HEADER *Table;
- EFI_ACPI_DESCRIPTION_HEADER *Xsdt;
- EFI_STATUS Status;
- UINT32 *RsdtPtr32;
- UINT32 CollectedCrc[2];
- UINT32 ComputedCrc;
- UINT32 TableCount;
- UINT64 XsdtTablePtr;
- UINTN Index;
- UINTN XsdtPtr;
-
- DEBUG ((DEBUG_INFO, "Updating hardware signature in FACS Table.\n"));
-
- Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **)&Rsdp);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to get RSDP. Status(%r)\n", Status));
- ASSERT_EFI_ERROR (Status);
- return;
- }
-
- CollectedCrc[0] = Rsdp->Checksum;
- CollectedCrc[1] = Rsdp->ExtendedChecksum;
- gBS->CalculateCrc32 ((UINT8 *)CollectedCrc, ARRAY_SIZE (CollectedCrc), &ComputedCrc);
- CollectedCrc[0] = ComputedCrc;
-
- Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress;
- Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress;
- if (Xsdt != NULL) {
- CollectedCrc[1] = Xsdt->Checksum;
- gBS->CalculateCrc32 ((UINT8 *)CollectedCrc, ARRAY_SIZE (CollectedCrc), &ComputedCrc);
- CollectedCrc[0] = ComputedCrc;
-
- TableCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof (UINT64);
- XsdtPtr = (UINTN)(Xsdt + 1);
- for (Index = 0; Index < TableCount; Index++) {
- CopyMem (&XsdtTablePtr, (VOID *)(XsdtPtr + Index * sizeof (UINT64)), sizeof (UINT64));
- Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(XsdtTablePtr));
- CollectedCrc[1] = Table->Checksum;
- gBS->CalculateCrc32 ((UINT8 *)CollectedCrc, ARRAY_SIZE (CollectedCrc), &ComputedCrc);
- CollectedCrc[0] = ComputedCrc;
- }
- } else if (Rsdt != NULL) {
- /// compute the CRC
- CollectedCrc[1] = Rsdt->Checksum;
- gBS->CalculateCrc32 ((UINT8 *)Rsdt, Rsdt->Length, &ComputedCrc);
- CollectedCrc[0] = ComputedCrc;
-
- TableCount = (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof (UINT32);
- RsdtPtr32 = (UINT32 *)(Rsdt + 1);
- for (Index = 0; Index < TableCount; Index++, RsdtPtr32++) {
- Table = (EFI_ACPI_DESCRIPTION_HEADER *)((UINTN)(*RsdtPtr32));
- CollectedCrc[1] = Table->Checksum;
- gBS->CalculateCrc32 ((UINT8 *)CollectedCrc, ARRAY_SIZE (CollectedCrc), &ComputedCrc);
- CollectedCrc[0] = ComputedCrc;
- }
- }
-
- Facs = (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE *)EfiLocateFirstAcpiTable (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE);
- if (Facs != NULL) {
- /// Update FACS signature
- Facs->HardwareSignature = ComputedCrc;
- }
-
- return;
-}
-
-/**
- Event notification function for AcpiFacsLib.
-
- @param[in] Event Event whose notification function is being invoked.
- @param[in] Context Pointer to the notification function's context, which is
- implementation-dependent.
-**/
-STATIC
-VOID
-EFIAPI
-AcpiFacsLibEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- /// Close the Event
- gBS->CloseEvent (Event);
-
- /// Update the FACS Table
- AcpiFacsTableUpdate ();
-}
-
-/**
- Implementation of AcpiFacsLibConstructor for AMD platforms.
- This is library constructor for AcpiFacsLib.
-
- @param[in] ImageHandle Image handle of the loaded driver.
- @param[in] SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS Successfully generated ACPI FACS Table.
- @retval Others Failed to generate ACPI FACS Table.
-**/
-EFI_STATUS
-EFIAPI
-AcpiFacsLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol;
- EFI_EVENT Event;
- EFI_STATUS Status;
- UINTN NewTableKey;
-
- // FACS Table Generation code goes here
- DEBUG ((DEBUG_INFO, "Generating ACPI FACS Table.\n"));
-
- /// Locate ACPI Table Protocol
- Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to locate ACPI Table Protocol. Status(%r)\n", Status));
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- /// Install FACS Table
- Status = AcpiProtocol->InstallAcpiTable (
- AcpiProtocol,
- &mAcpiFacs,
- sizeof (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE),
- &NewTableKey
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to install FACS Table. Status(%r)\n", Status));
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- //
- // Register notify function
- //
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- AcpiFacsLibEvent,
- NULL,
- &gEfiEventReadyToBootGuid,
- &Event
- );
- ASSERT_EFI_ERROR (Status);
- return Status;
-}
-
-/**
- Implementation of AcpiFacsLibDestructor for AMD platforms.
- This is library destructor for AcpiFacsLib.
-
- @param[in] ImageHandle Image handle of the loaded driver.
- @param[in] SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The destructor always returns EFI_SUCCESS.
-**/
-EFI_STATUS
-EFIAPI
-AcpiFacsLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.inf
deleted file mode 100644
index bb4745af79f815b2bed757a3ef272c8bc40d04a3..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiFacsLib/AcpiFacsLib.inf
+++ /dev/null
@@ -1,35 +0,0 @@
-## @file
-# Creates ACPI FACS tables for AMD platforms.
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = AcpiFacsLib
- FILE_GUID = 9EB7C0C6-61B4-4C7A-8481-76E935C7957A
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|DXE_DRIVER
- CONSTRUCTOR = AcpiFacsLibConstructor
- DESTRUCTOR = AcpiFacsLibDestructor
-
-[Sources]
- AcpiFacsLib.c
-
-[Packages]
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- UefiBootServicesTableLib
- UefiLib
-
-[Guids]
- gEfiEventReadyToBootGuid
- gEfiAcpiTableGuid
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.c
deleted file mode 100644
index b5ccb99eb57d9ac2bab0af874f0496bc8bc75139..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.c
+++ /dev/null
@@ -1,613 +0,0 @@
-/** @file
-
- Generate ACPI SSDT CPU table for AMD platforms.
-
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include // for CPUID_EXTENDED_TOPOLOGY
-#include
-
-#define DEVICE_ENABLED_BIT 0x0002
-#define DEVICE_HEALTH_BIT 0x0008
-#define DEVICE_IN_UI_BIT 0x0004
-#define DEVICE_PRESENT_BIT 0x0001
-#define MAX_TEST_CPU_STRING_SIZE 20
-
-EFI_PROCESSOR_INFORMATION *mApicIdtoUidMap = NULL;
-UINT32 mCcdOrder[16] = { 0, 4, 8, 12, 2, 6, 10, 14, 3, 7, 11, 15, 1, 5, 9, 13 };
-
-/**
- Callback compare function.
- Compares CCD number of provided arguments.
-
- @param[in] LocalX2ApicLeft Pointer to Left Buffer.
- @param[in] LocalX2ApicRight Pointer to Right Buffer.
- @return 0 If both are same
- -1 If left value is less than righ value.
- 1 If left value is greater than righ value.
-
-**/
-INTN
-EFIAPI
-SortByCcd (
- IN CONST VOID *LocalX2ApicLeft,
- IN CONST VOID *LocalX2ApicRight
- )
-{
- EFI_PROCESSOR_INFORMATION *Left;
- EFI_PROCESSOR_INFORMATION *Right;
- UINT32 Index;
- UINT32 LeftCcdIndex;
- UINT32 RightCcdIndex;
-
- Left = (EFI_PROCESSOR_INFORMATION *)LocalX2ApicLeft;
- Right = (EFI_PROCESSOR_INFORMATION *)LocalX2ApicRight;
-
- // Get the CCD Index number
- LeftCcdIndex = MAX_UINT32;
- for (Index = 0; Index < ARRAY_SIZE (mCcdOrder); Index++) {
- if (Left->ExtendedInformation.Location2.Die == mCcdOrder[Index]) {
- LeftCcdIndex = Index;
- break;
- }
- }
-
- RightCcdIndex = MAX_UINT32;
- for (Index = 0; Index < ARRAY_SIZE (mCcdOrder); Index++) {
- if (Right->ExtendedInformation.Location2.Die == mCcdOrder[Index]) {
- RightCcdIndex = Index;
- break;
- }
- }
-
- // Now compare for quick sort
- if (LeftCcdIndex < RightCcdIndex) {
- return -1;
- }
-
- if (LeftCcdIndex > RightCcdIndex) {
- return 1;
- }
-
- return 0;
-}
-
-/**
- Generate ApicId to Processor UID map.
-
- @retval EFI_SUCCESS - ApicId to Processor UID map generated successfully.
- @retval EFI_NOT_FOUND - MP Service Protocol not found.
- @retval EFI_OUT_OF_RESOURCES - Memory allocation failed.
-**/
-EFI_STATUS
-GenerateApicIdToUidMap (
- VOID
- )
-{
- EFI_MP_SERVICES_PROTOCOL *MpService;
- EFI_STATUS Status;
- UINTN Index;
- UINTN NumberOfCpus;
- UINTN NumberOfEnabledCPUs;
- UINTN SocketCount;
-
- // Get MP service
- Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService);
- if (EFI_ERROR (Status) || (MpService == NULL)) {
- return EFI_NOT_FOUND;
- }
-
- // Load MpServices
- Status = MpService->GetNumberOfProcessors (MpService, &NumberOfCpus, &NumberOfEnabledCPUs);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- DEBUG ((DEBUG_ERROR, "%a: NumberOfCpus = %d NumberOfEnabledCPUs = %d\n", __func__, NumberOfCpus, NumberOfEnabledCPUs));
-
- mApicIdtoUidMap = AllocateZeroPool (NumberOfCpus * sizeof (EFI_PROCESSOR_INFORMATION));
- if (mApicIdtoUidMap == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- SocketCount = 0;
- for (Index = 0; Index < NumberOfCpus; Index++) {
- Status = MpService->GetProcessorInfo (
- MpService,
- Index | CPU_V2_EXTENDED_TOPOLOGY,
- &mApicIdtoUidMap[Index]
- );
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- FreePool (mApicIdtoUidMap);
- mApicIdtoUidMap = NULL;
- return Status;
- }
-
- if (mApicIdtoUidMap[Index].ExtendedInformation.Location2.Package > SocketCount) {
- SocketCount = mApicIdtoUidMap[Index].ExtendedInformation.Location2.Package;
- }
- }
-
- // increment the SocketCount by 1 because socket numbering starts from 0
- SocketCount++;
-
- if (SocketCount > 1) {
- /// Sort by CCD location
- PerformQuickSort (
- mApicIdtoUidMap,
- NumberOfCpus/2,
- sizeof (EFI_PROCESSOR_INFORMATION),
- SortByCcd
- );
- PerformQuickSort (
- mApicIdtoUidMap+(NumberOfCpus/2),
- NumberOfCpus/2,
- sizeof (EFI_PROCESSOR_INFORMATION),
- SortByCcd
- );
- } else {
- /// Sort by CCD location
- PerformQuickSort (
- mApicIdtoUidMap,
- NumberOfCpus,
- sizeof (EFI_PROCESSOR_INFORMATION),
- SortByCcd
- );
- }
-
- // Now allocate the Uid
- for (Index = 0; Index < NumberOfCpus; Index++) {
- // Now make Processor as Uid
- mApicIdtoUidMap[Index].ProcessorId = Index;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Install CPU devices scoped under \_SB into DSDT
-
- Determine all the CPU threads and create ACPI Device nodes for each thread.
-
- @retval EFI_SUCCESS, various EFI FAILUREs.
-**/
-EFI_STATUS
-GenerateAcpiSsdtCpuTable (
- VOID
- )
-{
- AML_OBJECT_NODE_HANDLE CpuInstanceNode;
- AML_OBJECT_NODE_HANDLE CpuNode;
- AML_OBJECT_NODE_HANDLE ScopeNode;
- AML_ROOT_NODE_HANDLE RootNode;
- CHAR8 *String;
- CHAR8 Identifier[MAX_TEST_CPU_STRING_SIZE];
- EFI_ACPI_DESCRIPTION_HEADER *Table;
- EFI_ACPI_SDT_HEADER *DsdtTable;
- EFI_ACPI_SDT_HEADER *ReplacementAcpiTable;
- EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol;
- EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol;
- EFI_ACPI_TABLE_VERSION DsdtVersion;
- EFI_MP_SERVICES_PROTOCOL *MpServices;
- EFI_STATUS Status;
- EFI_STATUS Status1;
- UINT32 ReplacementAcpiTableLength;
- UINTN DeviceStatus;
- UINTN DsdtTableKey;
- UINTN Index;
- UINTN NumberOfEnabledProcessors;
- UINTN NumberOfLogicProcessors;
- UINTN TableHandle;
-
- DEBUG ((DEBUG_INFO, "Generating ACPI CPU SSDT Table. \n"));
-
- // Get Acpi Table Protocol
- Status = gBS->LocateProtocol (
- &gEfiAcpiTableProtocolGuid,
- NULL,
- (VOID **)&AcpiTableProtocol
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- /// Locate ACPI SDT protocol
- Status = gBS->LocateProtocol (
- &gEfiAcpiSdtProtocolGuid,
- NULL,
- (VOID **)&AcpiSdtProtocol
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Failed to locate ACPI SDT Protocol. Status = %r\n",
- Status
- ));
- return Status;
- }
-
- // Find the DSDT table and append to it
- for (Index = 0; ; Index++) {
- Status = AcpiSdtProtocol->GetAcpiTable (
- Index,
- &DsdtTable,
- &DsdtVersion,
- &DsdtTableKey
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: ACPI DSDT table not found. Status(%r)\n",
- Status
- ));
- return Status;
- }
-
- if (DsdtTable->Signature == EFI_ACPI_6_5_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
- break;
- }
- }
-
- String = &Identifier[0];
-
- // Get MP service
- MpServices = NULL;
- Status = gBS->LocateProtocol (
- &gEfiMpServiceProtocolGuid,
- NULL,
- (VOID **)&MpServices
- );
- if (EFI_ERROR (Status) || (MpServices == NULL)) {
- return EFI_NOT_FOUND;
- }
-
- // Load MpServices
- Status = MpServices->GetNumberOfProcessors (
- MpServices,
- &NumberOfLogicProcessors,
- &NumberOfEnabledProcessors
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Generate ACPI UID Map
- Status = GenerateApicIdToUidMap ();
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a: Could not generate ApicId to ProcessorUid map.\n",
- __func__
- ));
- return EFI_NOT_FOUND;
- }
-
- Status = AmlCodeGenDefinitionBlock (
- "SSDT",
- "AMD ",
- "CPU TOPO",
- 0x00,
- &RootNode
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- FreePool (mApicIdtoUidMap);
- return Status;
- }
-
- Status = AmlCodeGenScope ("\\_SB_", RootNode, &ScopeNode);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- CpuNode = ScopeNode;
-
- for (Index = 0; Index < NumberOfLogicProcessors; Index++) {
- // Check for valid Processor under the current socket
- if (!mApicIdtoUidMap[Index].StatusFlag) {
- continue;
- }
-
- AsciiSPrint (String, MAX_TEST_CPU_STRING_SIZE, "C%03X", Index);
- Status = AmlCodeGenDevice (String, CpuNode, &CpuInstanceNode);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // _HID
- Status = AmlCodeGenNameString ("_HID", "ACPI0007", CpuInstanceNode, NULL);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- DeviceStatus = DEVICE_PRESENT_BIT | DEVICE_IN_UI_BIT;
- if (mApicIdtoUidMap[Index].StatusFlag & PROCESSOR_ENABLED_BIT) {
- DeviceStatus |= DEVICE_ENABLED_BIT;
- }
-
- if (mApicIdtoUidMap[Index].StatusFlag & PROCESSOR_HEALTH_STATUS_BIT) {
- DeviceStatus |= DEVICE_HEALTH_BIT;
- }
-
- // _UID - Must match ACPI Processor UID in MADT
- Status = AmlCodeGenNameInteger (
- "_UID",
- mApicIdtoUidMap[Index].ProcessorId,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // _STA - As defined by 6.3.7
- Status = AmlCodeGenMethodRetInteger (
- "_STA",
- DeviceStatus,
- 0,
- FALSE,
- 0,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // PACK -> Package
- Status = AmlCodeGenNameInteger (
- "PACK",
- mApicIdtoUidMap[Index].ExtendedInformation.Location2.Package,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // CCD_ -> Ccd
- Status = AmlCodeGenNameInteger (
- "CCD_",
- mApicIdtoUidMap[Index].ExtendedInformation.Location2.Die,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // CCX_ -> Ccx
- Status = AmlCodeGenNameInteger (
- "CCX_",
- mApicIdtoUidMap[Index].ExtendedInformation.Location2.Module,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // CORE -> Core Number
- Status = AmlCodeGenNameInteger (
- "CORE",
- mApicIdtoUidMap[Index].ExtendedInformation.Location2.Core,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
-
- // THRD -> Thread
- Status = AmlCodeGenNameInteger (
- "THRD",
- mApicIdtoUidMap[Index].ExtendedInformation.Location2.Thread,
- CpuInstanceNode,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
- }
-
- Table = NULL;
- // Serialize the tree.
- Status = AmlSerializeDefinitionBlock (
- RootNode,
- &Table
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SSDT-PCI: Failed to Serialize SSDT Table Data."
- " Status = %r\n",
- Status
- ));
- goto exit_handler;
- }
-
- // Cleanup
- Status1 = AmlDeleteTree (RootNode);
- if (EFI_ERROR (Status1)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: SSDT-PCI: Failed to cleanup AML tree."
- " Status = %r\n",
- Status1
- ));
- // If Status was success but we failed to delete the AML Tree
- // return Status1 else return the original error code, i.e. Status.
- if (!EFI_ERROR (Status)) {
- FreePool (mApicIdtoUidMap);
- return Status1;
- }
- }
-
- // Update the Table header
- Table->CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId);
- Table->CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision);
- CopyMem (&Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId));
-
- // Calculate new DSDT Length and allocate space
- ReplacementAcpiTableLength = DsdtTable->Length + (UINT32)(Table->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER));
- ReplacementAcpiTable = AllocatePool (ReplacementAcpiTableLength);
- if (ReplacementAcpiTable == NULL) {
- ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
- DEBUG ((DEBUG_ERROR, "ERROR: Unable to allocate Replacement Table space.\n"));
- FreePool (mApicIdtoUidMap);
- return EFI_OUT_OF_RESOURCES;
- }
-
- // Copy the old DSDT to the new buffer
- CopyMem (ReplacementAcpiTable, DsdtTable, DsdtTable->Length);
-
- // Append new data to DSDT
- CopyMem (
- (UINT8 *)ReplacementAcpiTable + DsdtTable->Length,
- (UINT8 *)Table + sizeof (EFI_ACPI_DESCRIPTION_HEADER),
- Table->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)
- );
-
- ReplacementAcpiTable->Length = ReplacementAcpiTableLength;
-
- // Uninstall the original DSDT
- Status = AcpiTableProtocol->UninstallAcpiTable (
- AcpiTableProtocol,
- DsdtTableKey
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Unable to uninstall original DSDT table. Status(%r)\n",
- Status
- ));
- } else {
- // Install ACPI table
- Status = AcpiTableProtocol->InstallAcpiTable (
- AcpiTableProtocol,
- ReplacementAcpiTable,
- ReplacementAcpiTableLength,
- &TableHandle
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: Unable to re-install ACPI DSDT Table. Status(%r)\n",
- Status
- ));
- }
- }
-
- FreePool (ReplacementAcpiTable);
- FreePool (mApicIdtoUidMap);
- return Status;
-
-exit_handler:
- ASSERT_EFI_ERROR (Status);
- AmlDeleteTree (RootNode);
- FreePool (mApicIdtoUidMap);
- return Status;
-}
-
-/**
- Event notification function for AcpiSsdtCpuTopologyLib.
-
- @param[in] Event Event whose notification function is being invoked.
- @param[in] Context Pointer to the notification function's context, which is
- implementation-dependent.
-**/
-STATIC
-VOID
-EFIAPI
-AcpiSsdtCpuLibEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- /// Close the Event
- gBS->CloseEvent (Event);
-
- /// Update the CPU SSDT Table
- GenerateAcpiSsdtCpuTable ();
-}
-
-/**
- Implementation of AcpiSsdtCpuTopologyLibConstructor for AMD platforms.
- This is library constructor for AcpiSsdtCpuTopologyLib.
-
- @param[in] ImageHandle Image handle of the loaded driver.
- @param[in] SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS Successfully generated ACPI SSDT CPU Table.
- @retval Others Failed to generate ACPI SSDT CPU Table.
-**/
-EFI_STATUS
-EFIAPI
-AcpiSsdtCpuTopologyLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_EVENT Event;
-
- //
- // Register notify function
- //
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- AcpiSsdtCpuLibEvent,
- NULL,
- &gEfiEventReadyToBootGuid,
- &Event
- );
- ASSERT_EFI_ERROR (Status);
-
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a: Failed to create gEfiEventReadyToBootGuid event. Status(%r)\n",
- __func__,
- Status
- ));
- }
-
- return Status;
-}
-
-/**
- Implementation of AcpiSsdtCpuTopologyLibDestructor for AMD platforms.
- This is library destructor for AcpiSsdtCpuTopologyLib.
-
- @param[in] ImageHandle Image handle of the loaded driver.
- @param[in] SystemTable Pointer to the EFI System Table.
-
- @retval EFI_SUCCESS Successfully destroyed ACPI SSDT CPU Table.
- @retval Others Failed to destroy ACPI SSDT CPU Table.
-**/
-EFI_STATUS
-EFIAPI
-AcpiSsdtCpuTopologyLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.inf
deleted file mode 100644
index 089f9ce5f59204b5e54a199706df812dc65462b6..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtCpuTopologyLib/AcpiSsdtCpuTopologyLib.inf
+++ /dev/null
@@ -1,48 +0,0 @@
-## @file
-# Creates ACPI SSDT CPU tables for AMD platforms.
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = AcpiSsdtCpuTopologyLib
- FILE_GUID = FA22591D-D6FE-4373-93B7-1749B58F6AC9
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|DXE_DRIVER
- CONSTRUCTOR = AcpiSsdtCpuTopologyLibConstructor
- DESTRUCTOR = AcpiSsdtCpuTopologyLibDestructor
-
-[Sources]
- AcpiSsdtCpuTopologyLib.c
-
-[Packages]
- DynamicTablesPkg/DynamicTablesPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
- AmlLib
- BaseLib
- DebugLib
- SortLib
- UefiBootServicesTableLib
- UefiLib
-
-[Protocols]
- gEfiMpServiceProtocolGuid ## CONSUMES
- gEfiAcpiSdtProtocolGuid ## CONSUMES
-
-[Guids]
- gEfiAcpiTableGuid
- gEfiEventReadyToBootGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId ## CONSUMES
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.inf
deleted file mode 100644
index ca6e55f6045dfb2a1c150896a31482c43c6a73cf..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.inf
+++ /dev/null
@@ -1,57 +0,0 @@
-## @file
-# Creates ACPI SSDT PCI tables for AMD platforms.
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = AcpiSsdtPciLib
- FILE_GUID = CF551DAA-C1BD-46FE-A68E-17CA216CF7B9
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|DXE_DRIVER
- CONSTRUCTOR = AcpiSsdtPciLibConstructor
- DESTRUCTOR = AcpiSsdtPciLibDestructor
-
-[Sources]
- AcpiSsdtPciLib.c
-
-[Packages]
- AmdPlatformPkg/AmdPlatformPkg.dec
- DynamicTablesPkg/DynamicTablesPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- PcAtChipsetPkg/PcAtChipsetPkg.dec
-
-[LibraryClasses]
- AmlLib
- BaseLib
- DebugLib
- PlatformSocLib
- UefiBootServicesTableLib
- UefiLib
-
-[Protocols]
- gEfiAcpiSdtProtocolGuid
- gEfiPciRootBridgeIoProtocolGuid
-
-[Guids]
- gEfiAcpiTableGuid
- gEfiEventReadyToBootGuid
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize ## CONSUMES
- gPcAtChipsetPkgTokenSpaceGuid.PcdIoApicBaseAddress ## CONSUMES
-
-[Depex]
- gEfiAcpiTableProtocolGuid AND
- gEfiPciRootBridgeIoProtocolGuid AND
- gEfiPciEnumerationCompleteProtocolGuid
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SampleCmPlatOverrideLib.c b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SampleCmPlatOverrideLib.c
deleted file mode 100644
index 0c1b8914392c8367e618ad3f198fef2a9680c041..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SampleCmPlatOverrideLib.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/** @file
-
- Sample Code for CmPlatOverrideLib library. This library demonstrate the
- functionality to override the default configuration of the Configuration Manager
- Protocol.
-
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier BSD-2-Clause-Patent
-**/
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-static EFI_EVENT mConfigurationManagerProtocolInstalledEvent = NULL;
-static VOID *mConfigurationManagerProtocolRegistration = NULL;
-
-/**
- This function is used to override the default configuration of the Configuration Manager.
-
- @param[in] ConfigurationManager A pointer to the Configuration Manager Protocol.
-
- @retval EFI_SUCCESS The default configuration is successfully overridden.
- @retval EFI_INVALID_PARAMETER ConfigurationManager is NULL.
- @retval Others The default configuration is not overridden.
-**/
-EFI_STATUS
-EFIAPI
-PlatformOverrideConfigurationManager (
- IN EDKII_CONFIGURATION_MANAGER_PROTOCOL *ConfigurationManager
- )
-{
- CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO PmProfile;
- CM_OBJ_DESCRIPTOR PmProfileObjDesc;
- EFI_STATUS Status;
-
- if (ConfigurationManager == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (ConfigurationManager->PlatRepoInfo == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- ///
- /// Example 1: Override the default PmProfile configuration using SetConfigurationData API.
- ///
- DEBUG ((DEBUG_INFO, "Override the default PmProfile configuration\n"));
- PmProfile.PowerManagementProfile = 0x02;
- PmProfileObjDesc.ObjectId = CREATE_CM_OBJECT_ID (EObjNameSpaceArchCommon, EArchCommonObjPowerManagementProfileInfo);
- PmProfileObjDesc.Size = sizeof (CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO);
- PmProfileObjDesc.Data = (VOID *)&PmProfile;
- PmProfileObjDesc.Count = 1;
- Status = ConfigurationManager->SetObject (
- ConfigurationManager,
- PmProfileObjDesc.ObjectId,
- CM_NULL_TOKEN,
- &PmProfileObjDesc
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to set PowerManagementProfile configuration with Status: %r\n", Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- This function is called when the Configuration Manager Protocol is installed.
- It is used to override the default configuration of the Configuration Manager.
-
- @param[in] Event The Event that is being processed.
- @param[in] Context Event Context.
-**/
-VOID
-EFIAPI
-SampleCmPlatOverrideLibOnConfigurationManagerProtocolInstalled (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EDKII_CONFIGURATION_MANAGER_PROTOCOL *ConfigurationManager;
- EFI_STATUS Status;
-
- gBS->CloseEvent (Event);
- mConfigurationManagerProtocolInstalledEvent = NULL;
-
- ///
- /// Locate gEdkiiConfigurationManagerProtocolGuid
- ///
- Status = gBS->LocateProtocol (
- &gEdkiiConfigurationManagerProtocolGuid,
- NULL,
- (VOID **)&ConfigurationManager
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to locate Configuration Manager Protocol\n"));
- return;
- }
-
- Status = PlatformOverrideConfigurationManager (ConfigurationManager);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "PlatformOverrideConfigurationManager failed with Status: %r\n", Status));
- }
-
- return;
-}
-
-/**
- The constructor function initializes the library.
-
- The constructor function locates the Configuration Manager Protocol and
- overrides the default configuration of the Configuration Manager.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor executed successfully.
- @retval Others The constructor did not complete successfully.
-**/
-EFI_STATUS
-EFIAPI
-SampleCmPlatOverrideLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EDKII_CONFIGURATION_MANAGER_PROTOCOL *ConfigurationManager;
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (
- &gEdkiiConfigurationManagerProtocolGuid,
- NULL,
- (VOID **)&ConfigurationManager
- );
- if (EFI_ERROR (Status)) {
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- SampleCmPlatOverrideLibOnConfigurationManagerProtocolInstalled,
- NULL,
- &mConfigurationManagerProtocolInstalledEvent
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to create event for Configuration Manager Protocol installation\n"));
- return Status;
- }
-
- Status = gBS->RegisterProtocolNotify (
- &gEdkiiConfigurationManagerProtocolGuid,
- mConfigurationManagerProtocolInstalledEvent,
- &mConfigurationManagerProtocolRegistration
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to register for Configuration Manager Protocol installation\n"));
- return Status;
- }
-
- return EFI_SUCCESS;
- }
-
- Status = PlatformOverrideConfigurationManager (ConfigurationManager);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "PlatformOverrideConfigurationManager failed with Status: %r\n", Status));
- }
-
- return Status;
-}
-
-/**
- The destructor function frees resources allocated during initialization.
-
- The destructor function frees any resources allocated during the initialization
- of the library.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The destructor executed successfully.
- @retval Others The destructor did not complete successfully.
-**/
-EFI_STATUS
-EFIAPI
-SampleCmPlatOverrideLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- if (mConfigurationManagerProtocolInstalledEvent != NULL) {
- Status = gBS->CloseEvent (mConfigurationManagerProtocolInstalledEvent);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to close event for Configuration Manager Protocol installation\n"));
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SamplecmPlatOverrideLib.inf b/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SamplecmPlatOverrideLib.inf
deleted file mode 100644
index 1b6da6456e9a1a25d9f1e85a16e164ac958cd21b..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/SampleCmPlatOverrideLib/SamplecmPlatOverrideLib.inf
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file
-# This is Sample library to demonstrate how to override the CM table in the platform.
-# Using similar mechanism, platform engineer, IBV or OEM can override the CM table.
-#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 1.30
- BASE_NAME = SampleCmPlatOverrideLib
- FILE_GUID = 51FAD7D4-8C5B-4FE6-B531-AA0923A159ED
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|DXE_DRIVER
- CONSTRUCTOR = SampleCmPlatOverrideLibConstructor
- DESTRUCTOR = SampleCmPlatOverrideLibDestructor
-
-[Sources]
- SampleCmPlatOverrideLib.c
-
-[Packages]
- AmdPlatformPkg/AmdPlatformPkg.dec
- DynamicTablesPkg/DynamicTablesPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- UefiBootServicesTableLib
-
-[Protocols]
- gEdkiiConfigurationManagerProtocolGuid # PROTOCOL ALWAYS_CONSUMED
-
-[Depex]
- TRUE
diff --git a/Platform/AMD/AmdPlatformPkg/Include/AmdConfigurationManager.h b/Platform/AMD/AmdPlatformPkg/Include/AmdConfigurationManager.h
deleted file mode 100755
index abd1a88102b903dcd635a694e842b35ad51999b8..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/Include/AmdConfigurationManager.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @file
-
- Copyright (C) 2024 - 2025 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
- @par Glossary:
- - Cm or CM - Configuration Manager
- - Obj or OBJ - Object
-**/
-
-#ifndef AMD_CONFIGURATION_MANAGER_H_
-#define AMD_CONFIGURATION_MANAGER_H_
-
-#include
-#include
-#include
-#include
-
-/** The number of ACPI tables to install
-*/
-#define PLAT_ACPI_TABLE_COUNT 9
-
-/** The maximum number of ACPI tables to install
-*/
-#define MAX_PLAT_ACPI_TABLE_COUNT 16
-
-/** The configuration manager version.
-*/
-#define CONFIGURATION_MANAGER_REVISION CREATE_REVISION (1, 0)
-
-/** The OEM ID
-*/
-#define CFG_MGR_OEM_ID { 'A', 'M', 'D', 'I', 'N', 'C' }
-
-#pragma pack(1)
-
-/** A structure describing the platform configuration
- manager repository information
-*/
-typedef struct PlatformRepositoryInfo {
- /// Configuration Manager Information
- CM_STD_OBJ_CONFIGURATION_MANAGER_INFO CmInfo;
-
- /// List of ACPI tables
- CM_STD_OBJ_ACPI_TABLE_INFO CmAcpiTableList[MAX_PLAT_ACPI_TABLE_COUNT];
- UINTN CurrentAcpiTableCount;
- CM_X64_FACS_INFO FacsInfo;
- CM_ARCH_COMMON_POWER_MANAGEMENT_PROFILE_INFO PowerManagementProfile;
- CM_ARCH_COMMON_HYPERVISOR_VENDOR_ID HypervisorVendorId;
- CM_ARCH_COMMON_FIXED_FEATURE_FLAGS FixedFeatureFlags;
- CM_X64_FADT_SCI_INTERRUPT SciInterrupt;
- CM_X64_FADT_SCI_CMD_INFO SciCmdinfo;
- CM_X64_FADT_PM_BLOCK_INFO PmBlockInfo;
- CM_X64_FADT_GPE_BLOCK_INFO GpeBlockInfo;
- CM_X64_FADT_X_PM_BLOCK_INFO XpmBlockInfo;
- CM_X64_FADT_X_GPE_BLOCK_INFO XgpeBlockInfo;
- CM_X64_FADT_SLEEP_BLOCK_INFO SleepBlockInfo;
- CM_X64_FADT_RESET_BLOCK_INFO ResetBlockInfo;
- CM_X64_FADT_MISC_INFO FadtMiscInfo;
- CM_X64_HPET_INFO HpetInfo;
- CM_X64_WSMT_FLAGS_INFO WsmtFlagsInfo;
- CM_ARCH_COMMON_SPMI_INTERFACE_INFO SpmiInterfaceInfo;
- CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciConfigSpaceInfo;
- UINTN PciConfigSpaceInfoCount;
- CM_X64_MADT_INFO MadtInfo;
- CM_X64_LOCAL_APIC_X2APIC_INFO *LocalApicX2ApicInfo;
- UINTN LocalApicX2ApicInfoCount;
- CM_X64_IO_APIC_INFO *IoApicInfo;
- UINTN IoApicInfoCount;
- CM_X64_INTR_SOURCE_OVERRIDE_INFO *IntrSourceOverrideInfo;
- UINTN IntrSourceOverrideInfoCount;
- CM_X64_LOCAL_APIC_X2APIC_NMI_INFO *LocalApicX2ApicNmiInfo;
- UINTN LocalApicX2ApicNmiInfoCount;
- CM_X64_LOCAL_APIC_X2APIC_AFFINITY_INFO *LocalApicX2ApicAffinityInfo;
- UINTN LocalApicX2ApicAffinityInfoCount;
- CM_ARCH_COMMON_MEMORY_AFFINITY_INFO *MemoryAffinityInfo;
- UINTN MemoryAffinityInfoCount;
-} EDKII_PLATFORM_REPOSITORY_INFO;
-#pragma pack()
-
-#endif // AMD_CONFIGURATION_MANAGER_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Include/FchRegistersCommon.h b/Platform/AMD/AmdPlatformPkg/Include/FchRegistersCommon.h
deleted file mode 100644
index ec00486c57b143a977c3a3236cd74241a8553401..0000000000000000000000000000000000000000
--- a/Platform/AMD/AmdPlatformPkg/Include/FchRegistersCommon.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/** @file
-
- Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef FCH_REGISTER_COMMON_H_
-#define FCH_REGISTER_COMMON_H_
-
-// Misc
-#define R_FCH_ACPI_PM1_STATUS 0x00
-#define R_FCH_ACPI_PM1_ENABLE 0x02
-#define R_FCH_ACPI_PM_CONTROL 0x04
-
-#define FCH_LPC_BUS 0
-#define FCH_LPC_DEV 20
-#define FCH_LPC_FUNC 3
-
-#define ACPI_MMIO_BASE 0xFED80000ul
-#define SMI_BASE 0x200 // DWORD
-#define IOMUX_BASE 0xD00 // BYTE
-#define MISC_BASE 0xE00
-#define PMIO_BASE 0x300 // DWORD
-
-//
-// FCH LPC Device 0x780E
-// Device 20 (0x14) Func 3
-//
-#define FCH_LPC_REG48 0x48 // IO/Mem Port Decode Enable Register 5- RW
-#define FCH_LPC_REG74 0x74 // Alternative Wide IO Range Enable- W/R
-#define FCH_LPC_REG7C 0x7C // TPM (trusted plant form module) reg- W/R
-#define FCH_LPC_REGA0 0x0A0 // SPI base address
-#define FCH_LPC_REGB8 0x0B8
-
-//
-// FCH MMIO Base (SMI)
-// offset : 0x200
-//
-#define FCH_SMI_REG80 0x80 // SmiStatus0
-#define FCH_SMI_REG84 0x84 // SmiStatus1
-#define FCH_SMI_REG88 0x88 // SmiStatus2
-#define FCH_SMI_REG8C 0x8C // SmiStatus3
-#define FCH_SMI_REG90 0x90 // SmiStatus4
-#define FCH_SMI_REG98 0x98 // SmiTrig
-#define FCH_SMI_REGA0 0xA0
-#define FCH_SMI_REGB0 0xB0
-#define FCH_SMI_REGC4 0xC4
-
-//
-// FCH MMIO Base (PMIO)
-// offset : 0x300
-//
-#define FCH_PMIOA_REG60 0x60 // AcpiPm1EvtBlk
-
-//
-//
-#define FCH_MISC_REG80 0x80
-// FCH SPI
-//
-
-#define FCH_SPI_BASE_ADDRESS 0xFEC10000
-
-#define FCH_SPI_MMIO_REG00 0x00
-#define FCH_SPI_FIFO_PTR_CRL 0x00100000l //
-#define FCH_SPI_BUSY 0x80000000l //
-#define FCH_SPI_MMIO_REG1D 0x1D //
-#define FCH_SPI_MMIO_REG20 0x20
-#define FCH_SPI_MMIO_REG22 0x22 //
-#define FCH_SPI_MMIO_REG30 0x30 //
-#define FCH_SPI_R2VAL24 0x00000001l //
-#define FCH_SPI_R2VAL25 0x00000002l //
-#define FCH_SPI_R2MSK24 0x00000004l //
-#define FCH_SPI_R2MSK25 0x00000008l //
-#define FCH_SPI_MMIO_REG45_CMDCODE 0x45 //
-#define FCH_SPI_MMIO_REG47_CMDTRIGGER 0x47 //
-#define FCH_SPI_MMIO_REG48_TX_BYTE_COUNT 0x48 //
-#define FCH_SPI_MMIO_REG4B_RX_BYTE_COUNT 0x4B //
-#define FCH_SPI_MMIO_REG4C_SPISTATUS 0x4C //
-#define FCH_SPI_MMIO_REG5C_ADDR32_CTRL3 0x5C //
-#define FCH_SPI_SPIROM_PAGE_MASK 0xFF //
-#define FCH_SPI_MMIO_REG80_FIFO 0x80 //
-
-#endif /* FCH_REGISTER_COMMON_H_ */
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Library/AmdPlatformSocLib.h b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdPlatformSocLib.h
index 11939f87de8ef56a28f8f0c5c8dbb135db3f8e6f..d37c2ed765ae4f5ed169422b34bfb3e71d8ad646 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Library/AmdPlatformSocLib.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdPlatformSocLib.h
@@ -2,7 +2,7 @@
AMD Platform SoC Library.
Provides interface to Get/Set platform specific data.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -19,12 +19,6 @@
#define PCIE_MAX_DEVICES 32
#define PCIE_MAX_ROOTPORT (PCIE_MAX_DEVICES * PCIE_MAX_FUNCTIONS)
-#define F1A_BRH_A0_RAW_ID 0x00B00F00ul
-#define F1A_BRH_B0_RAW_ID 0x00B00F10ul
-#define F1A_BRH_B1_RAW_ID 0x00B00F11ul
-#define F1A_BRHD_A0_RAW_ID 0x00B10F00ul
-#define F1A_BRHD_B0_RAW_ID 0x00B10F10ul
-
typedef struct {
UINTN Index;
BOOLEAN Enabled;
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHookLib.h b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHookLib.h
index 6ae76920b4b1da82f93d691aa9013a812a5094b3..1db52f63af23d189a2f7c37ac6817e556b871cdc 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHookLib.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHookLib.h
@@ -1,8 +1,7 @@
/** @file
AMD Smm Core Platform Hook Library
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Pcd/SmbiosPcd.h b/Platform/AMD/AmdPlatformPkg/Include/Pcd/SmbiosPcd.h
index 2dd0480df929c8ba294d22148d44d355072be462..58204dd7641b51cebdbcd1fc83000a819980d3e0 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Pcd/SmbiosPcd.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Pcd/SmbiosPcd.h
@@ -1,11 +1,10 @@
/** @file
Miscellaneous smbios data structures.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
+**/
#ifndef AMD_SMBIOS_PCD_H_
#define AMD_SMBIOS_PCD_H_
@@ -16,43 +15,43 @@
#define AMD_SMBIOS_TYPE41_MAX_ONBOARD_DEVICES 16
typedef struct {
- CHAR8 IntDesignatorStr[SMBIOS_STRING_MAX_LENGTH];
- CHAR8 ExtDesignatorStr[SMBIOS_STRING_MAX_LENGTH];
+ CHAR8 IntDesignatorStr[SMBIOS_STRING_MAX_LENGTH];
+ CHAR8 ExtDesignatorStr[SMBIOS_STRING_MAX_LENGTH];
} PORT_CONNECTOR_STR;
//
// AMD SMBIOS type 8 record structure.
//
typedef struct {
- SMBIOS_TABLE_TYPE8 Type8Data;
- PORT_CONNECTOR_STR DesinatorStr;
+ SMBIOS_TABLE_TYPE8 Type8Data;
+ PORT_CONNECTOR_STR DesinatorStr;
} SMBIOS_PORT_CONNECTOR_RECORD;
//
// AMD SMBIOS type 8 record structure array.
//
typedef struct {
- SMBIOS_PORT_CONNECTOR_RECORD SmbiosPortConnectorRecords[AMD_SMBIOS_TYPE8_MAX_PORT_CONNETORS];
+ SMBIOS_PORT_CONNECTOR_RECORD SmbiosPortConnectorRecords[AMD_SMBIOS_TYPE8_MAX_PORT_CONNETORS];
} SMBIOS_PORT_CONNECTOR_RECORD_ARRAY;
//
// AMD SMBIOS type 41 record structure
//
typedef struct {
- SMBIOS_TABLE_STRING ReferenceDesignation;
- UINT8 DeviceType;
- UINT8 DeviceEnabled;
- UINT8 DeviceTypeInstance;
- UINT16 VendorId;
- UINT16 DeviceId;
- CHAR8 RefDesignationStr[SMBIOS_STRING_MAX_LENGTH];
+ SMBIOS_TABLE_STRING ReferenceDesignation;
+ UINT8 DeviceType;
+ UINT8 DeviceEnabled;
+ UINT8 DeviceTypeInstance;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ CHAR8 RefDesignationStr[SMBIOS_STRING_MAX_LENGTH];
} SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD;
//
// AMD SMBIOS type 41 record structure array.
//
typedef struct {
- SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD SmbiosOnboardDevExtInfos[AMD_SMBIOS_TYPE41_MAX_ONBOARD_DEVICES];
+ SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD SmbiosOnboardDevExtInfos[AMD_SMBIOS_TYPE41_MAX_ONBOARD_DEVICES];
} SMBIOS_ONBOARD_DEV_EXT_INFO_ARRAY;
#endif // AMD_SMBIOS_PCD_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h b/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h
index 0e2bccb3ef0e652e28ffd097f3ed8bb7a0737076..88c7dd4d9f9e0d028194ebc44ebcfd7bb9e3670a 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h
@@ -1,9 +1,9 @@
/** @file
Header file of AMD SMM SPI host controller state protocol
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
+
**/
#ifndef AMD_SMM_SPI_HC_STATE_PROTOCOL_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Register/AmdIoApic.h b/Platform/AMD/AmdPlatformPkg/Include/Register/AmdIoApic.h
new file mode 100644
index 0000000000000000000000000000000000000000..99f09801ecaae5b5376d993e8302a7b61bd5a911
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Include/Register/AmdIoApic.h
@@ -0,0 +1,87 @@
+/** @file
+ I/O APIC Register Definitions from 82093AA I/O Advanced Programmable Interrupt
+ Controller (IOAPIC), 1996.
+
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_IO_APIC_H_
+#define AMD_IO_APIC_H_
+
+///
+/// I/O APIC Register Offsets
+///
+#define IOAPIC_INDEX_OFFSET 0x00
+#define IOAPIC_DATA_OFFSET 0x10
+
+///
+/// I/O APIC Indirect Register Indexes
+///
+#define IO_APIC_IDENTIFICATION_REGISTER_INDEX 0x00
+#define IO_APIC_VERSION_REGISTER_INDEX 0x01
+#define IO_APIC_REDIRECTION_TABLE_ENTRY_INDEX 0x10
+
+///
+/// I/O APIC Interrupt Deliver Modes
+///
+#define IO_APIC_DELIVERY_MODE_FIXED 0
+#define IO_APIC_DELIVERY_MODE_LOWEST_PRIORITY 1
+#define IO_APIC_DELIVERY_MODE_SMI 2
+#define IO_APIC_DELIVERY_MODE_NMI 4
+#define IO_APIC_DELIVERY_MODE_INIT 5
+#define IO_APIC_DELIVERY_MODE_EXTINT 7
+
+#pragma pack(1)
+
+///
+/// The AMD IOAPIC requires an 8-bit Identification field.
+///
+/// IOAPIC_ID_REGISTER Bits Description:
+/// 31:24 id
+/// 23:0 Reserved.
+///
+typedef union {
+ struct {
+ UINT32 Reserved0:24;
+ UINT32 Identification:8;
+ } Bits;
+ UINT32 Uint32;
+} IO_APIC_IDENTIFICATION_REGISTER;
+
+typedef union {
+ struct {
+ UINT32 Version:8;
+ UINT32 Reserved0:8;
+ UINT32 MaximumRedirectionEntry:8;
+ UINT32 Reserved1:8;
+ } Bits;
+ UINT32 Uint32;
+} IO_APIC_VERSION_REGISTER;
+
+typedef union {
+ struct {
+ UINT32 Vector: 8;
+ UINT32 DeliveryMode: 3;
+ UINT32 DestinationMode: 1;
+ UINT32 DeliveryStatus: 1;
+ UINT32 Polarity: 1;
+ UINT32 RemoteIRR: 1;
+ UINT32 TriggerMode: 1;
+ UINT32 Mask: 1;
+ UINT32 Reserved0: 15;
+ UINT32 Reserved1: 24;
+ UINT32 DestinationID: 8;
+ } Bits;
+ struct {
+ UINT32 Low;
+ UINT32 High;
+ } Uint32;
+ UINT64 Uint64;
+} IO_APIC_REDIRECTION_TABLE_ENTRY;
+
+#pragma pack()
+
+#endif
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiDevicePaths.h b/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiDevicePaths.h
index 1631e952afcad6115769ce565b7c4abfc5ab485e..84092dd2b28c2fdbfe1bdafcc9c79b584857177a 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiDevicePaths.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiDevicePaths.h
@@ -1,40 +1,41 @@
/** @file
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
-#ifndef SPI_DEVICE_PATHS_H_
-#define SPI_DEVICE_PATHS_H_
+#ifndef AMD_SPI_DEVICE_PATHS_H_
+#define AMD_SPI_DEVICE_PATHS_H_
#include
#include
#include
+#include
typedef struct {
- CONTROLLER_DEVICE_PATH ControllerDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ CONTROLLER_DEVICE_PATH ControllerDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} SPI_CONTROLLER_DEVICE_PATH;
-#define FCH_DEVICE_PATH { \
- { \
- { \
- HARDWARE_DEVICE_PATH, \
- HW_CONTROLLER_DP, \
- { \
- (UINT8)(sizeof (CONTROLLER_DEVICE_PATH)), \
- (UINT8)((sizeof (CONTROLLER_DEVICE_PATH)) >> 8) \
- } \
- }, \
- 0 \
- }, \
- { \
- END_DEVICE_PATH_TYPE, \
- END_ENTIRE_DEVICE_PATH_SUBTYPE, \
- { 0x4 } \
- } \
+
+SPI_CONTROLLER_DEVICE_PATH mFchDevicePath = {
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_CONTROLLER_DP,
+ {
+ (UINT8)(sizeof (CONTROLLER_DEVICE_PATH)),
+ (UINT8)((sizeof (CONTROLLER_DEVICE_PATH)) >> 8)
+ }
+ },
+ FCH_LPC_BUS << 16 | FCH_LPC_DEV << 8 | FCH_LPC_FUNC
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ {0x4}
}
+};
-#endif // SPI_DEVICE_PATHS_H_
+#endif // AMD_SPI_DEVICE_PATHS_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiHcChipSelectParameters.h b/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiHcChipSelectParameters.h
index c4b16e0975880cb57a07b7329c6b7740faeced1e..e99d0975a33e54f056e30714d86fbf3ae702c08e 100644
--- a/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiHcChipSelectParameters.h
+++ b/Platform/AMD/AmdPlatformPkg/Include/Spi/AmdSpiHcChipSelectParameters.h
@@ -1,25 +1,23 @@
/** @file
Header file of AMD SMM SPI host controller state protocol
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-
-#ifndef SPI_HC_CHIP_SELECT_PARAMETERS_H_
-#define SPI_HC_CHIP_SELECT_PARAMETERS_H_
+#ifndef AMD_SPI_HC_CHIP_SELECT_PARAMETERS_H_
+#define AMD_SPI_HC_CHIP_SELECT_PARAMETERS_H_
#include
#pragma pack (1)
typedef struct _CHIP_SELECT_PARAMETERS {
- UINT8 AndValue;
- UINT8 OrValue;
+ UINT8 AndValue;
+ UINT8 OrValue;
} CHIP_SELECT_PARAMETERS;
#pragma pack ()
-#define CHIP_SELECT_1 { (UINT8)~((UINT8)0x03), 0x0 }
-#define CHIP_SELECT_2 { (UINT8)~((UINT8)0x03), 0x1 }
+CONST CHIP_SELECT_PARAMETERS ChipSelect1 = { (UINT8)~((UINT8)0x03), 0x0 }; // SPI_CS1_L
+CONST CHIP_SELECT_PARAMETERS ChipSelect2 = { (UINT8)~((UINT8)0x03), 0x1 }; // SPI_CS1_L
-#endif // SPI_HC_CHIP_SELECT_PARAMETERS_H_
+#endif // AMD_SPI_HC_CHIP_SELECT_PARAMETERS_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfig.h b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfig.h
new file mode 100644
index 0000000000000000000000000000000000000000..cd9fd94736fa2419403d4e0e56e3d1dcf76200bc
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfig.h
@@ -0,0 +1,41 @@
+/** @file
+
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BOOT_OPTION_CONFIG_H_
+#define BOOT_OPTION_CONFIG_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define UEFI_HARD_DRIVE_NAME L"UEFI Hard Drive"
+
+/**
+ Find the Lan-On-Motherboard device path.
+
+ @param[out] LomDevicePath DevicePath of the LOM device. NULL if the LOM
+ is not found
+ @retval EFI NOT_FOUND LOM device path is not found
+ @retval EFI_SUCCESS LOM device path found
+**/
+EFI_STATUS
+EFIAPI
+GetLomDevicePath (
+ OUT EFI_DEVICE_PATH_PROTOCOL **LomDevicePath
+ );
+
+#endif
diff --git a/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.c b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.c
new file mode 100644
index 0000000000000000000000000000000000000000..44f8a004860827183c1ac80657b9d76a4a67940d
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.c
@@ -0,0 +1,259 @@
+/** @file
+ This library registers the BootOptionPriorityProtocol, if necessary. Searches
+ through PCIE devices to find the LOM to set as default PXE boot.
+
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include
+#include
+#include
+#include
+#include "AmdBdsBootConfig.h"
+
+EFI_HANDLE mBoardBdsHandle = NULL;
+AMD_BOARD_BDS_BOOT_OPTION_PRIORITY_PROTOCOL mBootOptionPriorityProtocol;
+EFI_DEVICE_PATH_PROTOCOL *mLomDevicePath;
+
+/**
+ Compares two device paths to see if FullDevicePath starts with PartialDevicePath.
+
+ @param[in] PartialDevicePath Partial device path pointer.
+ @param[in] FullDevicePath Complete device path pointer
+
+ @retval TRUE PartialDevicePath was found in FullDevicePath.
+ @retval FALSE PartialDevicePath was not found in FullDevicePath.
+
+**/
+BOOLEAN
+StartsWithDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *PartialDevicePath,
+ IN EFI_DEVICE_PATH_PROTOCOL *FullDevicePath
+ )
+{
+ INTN PartialSize;
+ INTN FullSize;
+
+ // Size includes end of device path node, don't want this to be included in comparison
+ PartialSize = (INTN)GetDevicePathSize (PartialDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ FullSize = (INTN)GetDevicePathSize (FullDevicePath) - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ if ((PartialSize <= 0) || (FullSize <= 0)) {
+ return FALSE;
+ }
+
+ if (CompareMem (PartialDevicePath, FullDevicePath, PartialSize) != 0) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ Returns the priority number.
+
+ @param[in] BootOption Load option
+ @retval
+ OptionType EFI
+ ------------------------------------
+ PXE 2
+ DVD 4
+ USB 6
+ NVME 7
+ HDD 8
+ EFI Shell 9
+ Others 100
+**/
+UINTN
+PlatformBootOptionPriority (
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ )
+{
+ //
+ // EFI boot options
+ //
+ switch (BootOptionType (BootOption->FilePath)) {
+ case MSG_MAC_ADDR_DP:
+ case MSG_VLAN_DP:
+ case MSG_IPv4_DP:
+ case MSG_IPv6_DP:
+ return 2;
+
+ case MSG_SATA_DP:
+ case MSG_ATAPI_DP:
+ case MSG_UFS_DP:
+ case MSG_NVME_NAMESPACE_DP:
+ return 4;
+
+ case MSG_USB_DP:
+ return 6;
+ }
+
+ if (StrCmp (BootOption->Description, (CHAR16 *)PcdGetPtr (PcdShellFileDesc)) == 0) {
+ if (PcdGetBool (PcdBootToShellOnly)) {
+ return 0;
+ }
+
+ return 9;
+ }
+
+ if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
+ return 8;
+ }
+
+ return 100;
+}
+
+/**
+ Returns the priority number, giving the LOM device highest priority.
+
+ @param[in] BootOption Load option
+ @retval
+ OptionType EFI
+ ------------------------------------
+ PXE 2
+ DVD 4
+ USB 6
+ NVME 7
+ HDD 8
+ EFI Shell 9
+ Others 100
+**/
+UINTN
+PlatformBootOptionLomPriority (
+ IN CONST EFI_BOOT_MANAGER_LOAD_OPTION *BootOption
+ )
+{
+ // highest priority for LOM
+ if (StartsWithDevicePath (mLomDevicePath, BootOption->FilePath) &&
+ (BootOptionType (BootOption->FilePath) == MSG_IPv4_DP))
+ {
+ return 0;
+ }
+
+ //
+ // EFI boot options
+ //
+ switch (BootOptionType (BootOption->FilePath)) {
+ case MSG_MAC_ADDR_DP:
+ case MSG_VLAN_DP:
+ case MSG_IPv4_DP:
+ case MSG_IPv6_DP:
+ return 2;
+
+ case MSG_SATA_DP:
+ case MSG_ATAPI_DP:
+ case MSG_UFS_DP:
+ case MSG_NVME_NAMESPACE_DP:
+ return 4;
+
+ case MSG_USB_DP:
+ return 6;
+ }
+
+ if (StrCmp (BootOption->Description, (CHAR16 *)PcdGetPtr (PcdShellFileDesc)) == 0) {
+ if (PcdGetBool (PcdBootToShellOnly)) {
+ return 0;
+ }
+
+ return 9;
+ }
+
+ if (StrCmp (BootOption->Description, UEFI_HARD_DRIVE_NAME) == 0) {
+ return 8;
+ }
+
+ return 100;
+}
+
+/**
+ Compares boot priorities of two boot options while giving
+ the LOM device the highest priority.
+
+ @param[in] Left The left boot option
+ @param[in] Right The right boot option
+
+ @return The difference between the Left and Right
+ boot options
+ **/
+INTN
+EFIAPI
+CompareBootOptionPlatformPriorityLom (
+ IN CONST VOID *Left,
+ IN CONST VOID *Right
+ )
+{
+ return PlatformBootOptionLomPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *)Left) -
+ PlatformBootOptionLomPriority ((EFI_BOOT_MANAGER_LOAD_OPTION *)Right);
+}
+
+/**
+ PciEnumerationComplete Protocol notification event handler.
+
+ @param[in] Event Event whose notification function is being invoked.
+ @param[in] Context Pointer to the notification function's context.
+**/
+VOID
+EFIAPI
+OnPciEnumerationComplete (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ EFI_STATUS Status;
+
+ // Handle LOM Device path here
+ Status = GetLomDevicePath (&mLomDevicePath);
+ DEBUG ((DEBUG_INFO, "Searching for LOM device path, Status = %r\n", Status));
+
+ if (!EFI_ERROR (Status)) {
+ mBootOptionPriorityProtocol.IpmiBootDeviceSelectorType = IPMI_BOOT_DEVICE_SELECTOR_PXE;
+ mBootOptionPriorityProtocol.Compare = CompareBootOptionPlatformPriorityLom;
+ // Install Boot Option Priority Protocol here
+ Status = gBS->InstallProtocolInterface (
+ &mBoardBdsHandle,
+ &gAmdBoardBdsBootOptionPriorityProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mBootOptionPriorityProtocol
+ );
+ DEBUG ((DEBUG_INFO, "Installing gBoardBdsBootOptionPriorityProtocolGuid, Status = %r\n", Status));
+ }
+}
+
+/**
+ Constructor function for AmdBdsBootConfig. Register PcieEnumerationComplete
+ Callback to handle IPMI seelctor choice and
+ BootOptionPriorityProtocol installation
+
+ @param[in] ImageHandle Handle for the image of this driver
+ @param[in] SystemTable Pointer to the EFI System Table
+
+ @retval EFI_SUCCESS The data was successfully stored.
+
+**/
+EFI_STATUS
+EFIAPI
+AmdBdsBootConfigConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_EVENT ProtocolNotifyEvent;
+ VOID *Registration;
+
+ ProtocolNotifyEvent = EfiCreateProtocolNotifyEvent (
+ &gEfiPciEnumerationCompleteProtocolGuid,
+ TPL_CALLBACK,
+ OnPciEnumerationComplete,
+ NULL,
+ &Registration
+ );
+
+ if (ProtocolNotifyEvent == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.inf b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.inf
new file mode 100644
index 0000000000000000000000000000000000000000..0e90e61f16787a2460ed63843892de06b17ff71d
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/AmdBdsBootConfigLib.inf
@@ -0,0 +1,71 @@
+## @file
+#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdBdsBootConfigLib
+ FILE_GUID = c2481551-17f3-4ac5-ab4c-ea5396056c9b
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ CONSTRUCTOR = AmdBdsBootConfigConstructor
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ AmdBdsBootConfig.h
+ AmdBdsBootConfigLib.c
+ DefaultLomDevicePath.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AmdPlatformPkg/AmdPlatformPkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaModulePkg/AgesaEdk2Pkg.dec
+ BoardModulePkg/BoardModulePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+ AmdMinBoardPkg/AmdMinBoardPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ DevicePathLib
+ HobLib
+ MemoryAllocationLib
+ NbioCommonDxeLib
+ NbioHandleLib
+ PcdLib
+ PcieConfigLib
+ PciSegmentLib
+ UefiDriverEntryPoint
+ UefiLib
+ IpmiLib
+ IpmiCommandLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ BoardBdsHookLib
+
+[Protocols]
+ gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES
+ gAmdSocLogicalIdProtocolGuid ## CONSUMES
+ gEfiPciIoProtocolGuid ## CONSUMES
+ gAmdBoardBdsBootOptionPriorityProtocolGuid ## PRODUCES SOMETIMES
+
+[Pcd]
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41 ## CONSUMES
+ gAmdPlatformPkgTokenSpaceGuid.PcdAmdSmbiosType41Number ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdBootToShellOnly ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdShellFileDesc ## CONSUMES
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/DefaultLomDevicePath.c b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/DefaultLomDevicePath.c
new file mode 100644
index 0000000000000000000000000000000000000000..c8a4b1b4c006925998da0239fa78a27d829cff61
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Library/AmdBdsBootConfigLib/DefaultLomDevicePath.c
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-2-Clause-Patent
+ *
+*******************************************************************************/
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ Find the Lan-On-Motherboard device path.
+
+ @param[out] LomDevicePath DevicePath of the LOM device. NULL if the LOM
+ is not found
+ @retval EFI NOT_FOUND LOM device path is not found
+ @retval EFI_SUCCESS LOM device path found
+**/
+EFI_STATUS
+EFIAPI
+GetLomDevicePath (
+ OUT EFI_DEVICE_PATH **LomDevicePath
+ )
+{
+ SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *DevExtInfoRecord;
+ EFI_STATUS Status;
+ EFI_HANDLE *PciHandles;
+ UINTN PciHandlesSize;
+ UINTN Index;
+ EFI_PCI_IO_PROTOCOL *PciProtocol;
+ PCI_IO_DEVICE *PciIoDevice;
+ UINT8 NumberOfDevices;
+ UINT8 DevIdx;
+ UINTN SegmentNumber;
+ UINTN BusNumber;
+ UINTN DeviceNumber;
+ UINTN FunctionNumber;
+
+ NumberOfDevices = PcdGet8 (PcdAmdSmbiosType41Number);
+ DevExtInfoRecord = (SMBIOS_ONBOARD_DEV_EXT_INFO_RECORD *)PcdGetPtr (PcdAmdSmbiosType41);
+
+ // No device entries found
+ if (NumberOfDevices == 0) {
+ DEBUG ((DEBUG_INFO, "No onboard devices found.\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ // search through present on board devices, look for onboard ethernet
+ for (DevIdx = 0; DevIdx < NumberOfDevices; DevIdx++) {
+ if (AsciiStrCmp (DevExtInfoRecord->RefDesignationStr, "Onboard Ethernet") == 0) {
+ break;
+ }
+
+ DevExtInfoRecord++;
+ }
+
+ // edge case, no Onboard Ethernet designator
+ if (AsciiStrCmp (DevExtInfoRecord->RefDesignationStr, "Onboard Ethernet") != 0) {
+ DEBUG ((DEBUG_INFO, "No Onboard ethernet SMBIOS designator found!\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiPciIoProtocolGuid,
+ NULL,
+ &PciHandlesSize,
+ &PciHandles
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "Can't locate gEfiPciIoProtocolGuid Protocol: Status = %r\n\n", Status));
+ return Status;
+ }
+
+ for (Index = 0; Index < PciHandlesSize; Index++) {
+ Status = gBS->HandleProtocol (
+ PciHandles[Index],
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&PciProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "ERROR - Status = %r when locating PciIoProtocol\n", Status));
+ continue;
+ }
+
+ PciIoDevice = PCI_IO_DEVICE_FROM_PCI_IO_THIS (PciProtocol);
+ Status = PciIoDevice->PciIo.GetLocation (&PciIoDevice->PciIo, &SegmentNumber, &BusNumber, &DeviceNumber, &FunctionNumber);
+
+ if ((PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegmentNumber, BusNumber, DeviceNumber, FunctionNumber, 2)) == DevExtInfoRecord->DeviceId) &&
+ (PciSegmentRead16 (PCI_SEGMENT_LIB_ADDRESS (SegmentNumber, BusNumber, DeviceNumber, FunctionNumber, 0)) == DevExtInfoRecord->VendorId))
+ {
+ // Making Lan0 default for systems with two LANs
+ if (FunctionNumber == 0) {
+ DEBUG ((DEBUG_INFO, "Found Onboard LOM Device with DeviceID=0x%X, VendorID=0x%X\n", DevExtInfoRecord->DeviceId, DevExtInfoRecord->VendorId));
+ Status = EFI_SUCCESS;
+ *LomDevicePath = PciIoDevice->DevicePath;
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.c b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.c
index e9f176223d9a1154cdffa58a2ac6085a0f17d980..b6fcd9cdbaed0fad79816556263b1070bafceea6 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.c
@@ -1,7 +1,7 @@
/** @file
No functionality of this file.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf
index 4e86256497b4e24a435151fd77d996013f1dafb3..69c76af540d36ac5fed2ce7290b5a23c3232f28e 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.inf
@@ -7,7 +7,7 @@
# The module linked with the NULL class BaseAlwaysFalseDepexLib is still
# put in the FV however it won't be executed.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.uni b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.uni
index 5c7ccf1840e8e7724401d7837a6734237933e147..327df5f9955c6a0f590f25d111ff627ae321ef46 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.uni
+++ b/Platform/AMD/AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.uni
@@ -1,6 +1,6 @@
## @file
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.c b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.c
index 142c3b66a70c1113056e729843c1397f7f447b81..e1d7d6b865832b65e0b3a6d34e1d603a8da9bd61 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.c
@@ -2,7 +2,7 @@
Implements AMD Platform SoC Library.
Provides interface to Get/Set platform specific data.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
index df8eb6b6041df592d96fe289bf92e5bb2c28d3db..4b8aa560d08fefe7ee270c4492d657da1f9b5121 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf
@@ -1,7 +1,7 @@
## @file
# INF file of AMD Platform SoC library
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
diff --git a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.uni b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.uni
index aa2ce2bc2fa058b8df60fe5e0dcd81ed4043fd23..564ed8e0af0aaf0715771e1937b5469f081e821b 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.uni
+++ b/Platform/AMD/AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.uni
@@ -1,7 +1,7 @@
## @file
# UNI file of AMD Platform SoC library
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.c b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.c
index 35842ecddcb3674828ba818eb5934e18219caca4..1eb456e5d75d9041746bba39974146f5ddc3a33c 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.c
@@ -1,7 +1,7 @@
/** @file
AMD simulator port80 serial port library functions.
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf
index 61e2d77f464da737ed1e22d6351c6ee51399d2ae..08a163fc8959e7845addd44ba3fe47dbe172d937 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/SimulatorSerialPortLibPort80/SimulatorSerialPortLibPort80.inf
@@ -1,7 +1,7 @@
## @file
# Simlator port80 instance of serial port library functions.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.c b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.c
index 4284f13a5ee0c0b38e3fdc1bd8b384053560e936..17751b8de616a70a97d880e91d151e3fa02d0400 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.c
@@ -1,9 +1,9 @@
/** @file
SMM core hook for AMD SPI Host Controller State
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
+
**/
#include
#include
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.h b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.h
index 8a5dfe623ca1b8e5224118bb30f66473f88d548e..03b559354b151d80a1ab4cc099840278a66f02bf 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.h
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.h
@@ -1,13 +1,13 @@
/** @file
Header file of SMM core platform hook for AMD SPI Host Controller state library
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
+
**/
-#ifndef SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_
-#define SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_
+#ifndef SMM_CORE_HOOK_AMD_SPI_HC_H_
+#define SMM_CORE_HOOK_AMD_SPI_HC_H_
///
/// Structure of AMD SPI HC State record
@@ -17,4 +17,4 @@ typedef struct {
EFI_HANDLE SmmSpiHcStateHandle; ///< Handle of MD SMM SPI HC State Protocol handle
} SMM_CORE_HOOK_AMD_SPI_HC_STATE_CONTEXT;
-#endif // SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_
+#endif // SMM_CORE_HOOK_AMD_SPI_HC_H_
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
index 9855aa8543ac01543678fea832cec0fd863b071e..626d73f687fc0027a0a12751325b487fff4e217e 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.inf
@@ -1,8 +1,7 @@
## @file
# INF of SMM Core AMD SPI Host Contoller State hook library.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
[Defines]
@@ -24,7 +23,6 @@
[Sources]
SmmCoreAmdSpiHcHookLib.c
- SmmCoreAmdSpiHcHookLib.h
[Packages]
AmdPlatformPkg/AmdPlatformPkg.dec
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.uni b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.uni
index 0a73c4acb4d1808b8250ffb4c22ac911cdce0765..60073b9754e011d2e711579204b52429a3025bdd 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.uni
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.uni
@@ -1,9 +1,9 @@
## @file
# UNI file of SMM Core AMD SPI Host Controller State hook library module
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
##
#string STR_MODULE_ABSTRACT #language en-US "SMM Core AMD SPI HC State Hook Library instance"
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.c b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.c
index ad6a40749f16c63b782fc53a0e9420dcef6fe277..796582fb660efb7e85c05227d503a0aa33524dda 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.c
@@ -1,8 +1,7 @@
/** @file
AMD SMM core hook library
- Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
index a79fc56077256b91bbb931ba6bee09a628b73f6e..8780bca8e3881878e2b2f52b8e7f836528112f59 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf
@@ -1,9 +1,9 @@
## @file
# INF of SMM Core hook library INF file.
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
##
[Defines]
INF_VERSION = 0x00010005
@@ -37,3 +37,5 @@
MemoryAllocationLib
SmmServicesTableLib
+[Protocols]
+ gAmdSpiHcStateProtocolGuid
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.uni b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.uni
index 0b326c159b010ac79e57b863623f139f86072ccb..b7be31000ad881f71a21177d4821d1c93f5c45b8 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.uni
+++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.uni
@@ -1,8 +1,7 @@
## @file
# UNI file of SMM Core hook library module
#
-# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserved.
-#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.c b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.c
similarity index 84%
rename from Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.c
rename to Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.c
index 19750e9c5fc6a07bf52f564cbf8dce4635c0015f..a1811536cce35ecd9a01b197decaaa97827dab51 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.c
@@ -2,8 +2,7 @@
Internal functions used by platform SPI HC library
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -15,12 +14,12 @@
#include
#include
#include
-#include "SpiHcInternal.h"
+#include "AmdSpiHcInternal.h"
extern EFI_PHYSICAL_ADDRESS mHcAddress;
/**
- Check that SPI Conroller is Not Busy.
+ Check that SPI Conroller is Not Busy
@retval EFI_SUCCESS Spi Execute command executed properly
@retval EFI_DEVICE_ERROR Spi Execute command failed
@@ -67,7 +66,7 @@ FchSpiControllerNotBusy (
}
/**
- Check for SPI transaction failure(s).
+ Check for SPI transaction failure(s)
@retval EFI_SUCCESS Spi Execute command executed properly
@retval others Spi Execute command failed
@@ -131,11 +130,6 @@ FchSpiExecute (
Calls to these functions from SMM will only be valid during SMM, restore state
will wipe out any changes.
-
- @param[in] HcAddress Host controller physical address.
- @param[in] Opcode SPI opcode to be passed.
- @retval EFI_SUCCESS If executed successfully.
- Others If fails.
**/
EFI_STATUS
EFIAPI
@@ -186,10 +180,6 @@ InternalFchSpiBlockOpcode (
Calls to these functions from SMM will only be valid during SMM, restore state
will wipe out any changes.
- @param[in] HcAddress Host controller physical address.
- @param[in] Opcode SPI opcode to be passed.
- @retval EFI_SUCCESS If executed successfully.
- Others If fails.
**/
EFI_STATUS
EFIAPI
@@ -223,10 +213,6 @@ InternalFchSpiUnblockOpcode (
Calls to these functions from SMM will only be valid during SMM, restore state
will wipe out any changes.
-
- @param[in] HcAddress Host controller physical address
- @retval EFI_SUCCESS If executed successfully.
- Others If fails
**/
EFI_STATUS
EFIAPI
@@ -246,10 +232,6 @@ InternalFchSpiUnblockAllOpcodes (
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] HcAddress Host controller physical address
- @retval EFI_SUCCESS If executed successfully.
- Others If fails
**/
EFI_STATUS
EFIAPI
@@ -280,11 +262,7 @@ InternalFchSpiLockSpiHostControllerRegisters (
SPIx00[23:22] not equal 11b, so you can write SPIx00[23:22]=00b to lock them.
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
- then you can clear RestrictedCmd0..3 (SPIx04).
-
- @param[in] HcAddress Host controller physical address
- @retval EFI_SUCCESS If executed successfully.
- Others If fails
+ then you can clear RestrictedCmd0..3 (SPIx04)
**/
EFI_STATUS
EFIAPI
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.h b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.h
similarity index 92%
rename from Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.h
rename to Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.h
index a7a6a23c8939ada4f9155352aa8a33d28252c38b..2faa7bdba1f47f8e2d68f8987c63c4102242ea35 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcInternal.h
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcInternal.h
@@ -2,14 +2,13 @@
Internal functions used by platform SPI HC library
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef SPI_HC_INTERNAL_H_
-#define SPI_HC_INTERNAL_H_
+#ifndef AMD_SPI_HC_INTERNAL_H_
+#define AMD_SPI_HC_INTERNAL_H_
#include
#include
@@ -125,4 +124,4 @@ InternalFchSpiUnlockSpiHostControllerRegisters (
IN CONST EFI_PHYSICAL_ADDRESS HcAddress
);
-#endif // SPI_HC_INTERNAL_H__
+#endif // __AMD_SPI_HC_INTERNAL_H__
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.c b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.c
similarity index 85%
rename from Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.c
rename to Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.c
index ce0176e076988c2d190271a067fd90a4ad612bb6..584869d0aa80e8991fab6e648caa6876583cd26e 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.c
@@ -2,18 +2,18 @@
SPI HC SMM state registration function definitions
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include
+#include
#include
#include
#include
#include
-#include "SpiHcSmmState.h"
-#include "SpiHcInternal.h"
+#include "AmdSpiHcSmmState.h"
+#include "AmdSpiHcInternal.h"
extern EFI_PHYSICAL_ADDRESS mHcAddress;
extern BOOLEAN mSmmAlreadySavedState;
@@ -21,7 +21,7 @@ extern VOID *mState;
extern UINT32 mStateSize;
extern UINT32 mStateRecordCount;
-CONST SPI_HC_REGISTER_STATE mSpiHcState[] = {
+CONST struct SpiHcRegisterState mSpiHcState[] = {
// {Register, Size, Count}
{ 0x04, 0x4, 0x1 }, // SPI_RestrictedCmd
{ 0x08, 0x4, 0x1 }, // SPI_RestrictedCmd2
@@ -45,7 +45,7 @@ CONST SPI_HC_REGISTER_STATE mSpiHcState[] = {
};
/**
- Allocate the save state space and update the instance structure.
+ Allocate the save state space and update the instance structure
@retval EFI_SUCCESS The Save State space was allocated
@retval EFI_OUT_OF_RESOURCES The Save State space failed to allocate
@@ -59,7 +59,7 @@ AllocateState (
UINT32 NumRecords;
UINT32 Record;
- NumRecords = sizeof (mSpiHcState) / sizeof (SPI_HC_REGISTER_STATE);
+ NumRecords = sizeof (mSpiHcState) / sizeof (struct SpiHcRegisterState);
// calculate space needed
mStateSize = 0;
@@ -81,7 +81,7 @@ AllocateState (
}
/**
- Save the Host controller state to restore after transaction is complete.
+ Save the Host controler state to restore after transaction is complete
@param[in] This SPI host controller Preserve State Protocol;
@@ -150,7 +150,7 @@ SaveState (
}
/**
- Restore the Host Controller state.
+ Restore the Host Controller state
@param[in] This SPI host controller Preserve State Protocol;
@@ -224,10 +224,6 @@ RestoreState (
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] This A pointer to the SMM_EFI_SPI_HC_STATE_PROTOCOL structure.
- @param[in] Opcode SPI opcode value.
- @retval Others return various return values.
**/
EFI_STATUS
EFIAPI
@@ -250,10 +246,6 @@ FchSpiBlockOpcode (
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] This A pointer to the SMM_EFI_SPI_HC_STATE_PROTOCOL structure.
- @param[in] Opcode SPI opcode value.
- @retval Others Various return values.
**/
EFI_STATUS
EFIAPI
@@ -276,9 +268,6 @@ FchSpiUnblockOpcode (
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] This A pointer to the SMM_EFI_SPI_HC_STATE_PROTOCOL structure.
- @retval Others return various return values.
**/
EFI_STATUS
EFIAPI
@@ -300,9 +289,6 @@ FchSpiUnblockAllOpcodes (
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] This A pointer to the SMM_EFI_SPI_HC_STATE_PROTOCOL structure.
- @retval Others return various return values.
**/
EFI_STATUS
EFIAPI
@@ -317,17 +303,14 @@ FchSpiLockSpiHostControllerRegisters (
}
/**
- Unlock SPI host controller registers.
- This unlock function will only work in SMM.
+ Unlock SPI host controller registers. This unlock function will only work in
+ SMM.
RestrictedCmd0..3 (SPIx04[31:0]) will be locked (write protected) when
SPIx00[23:22] not equal 11b, so you can write SPIx00[23:22]=00b to lock them.
Once SPIx00[23:22] = 00b, they can only be written in SMM,
to clear RestrictedCmd0..3, get into SMM, write SPIx00[23:22]=11b,
then you can clear RestrictedCmd0..3 (SPIx04)
-
- @param[in] This A pointer to the SMM_EFI_SPI_HC_STATE_PROTOCOL
- @retval Others Various return values
**/
EFI_STATUS
EFIAPI
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.h b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.h
similarity index 91%
rename from Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.h
rename to Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.h
index 32e9869593401dc246c9cd4da2ece127dfc66b74..1039864dbade7657eec72b3e7e850cd90964e381 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcSmmState.h
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/AmdSpiHcSmmState.h
@@ -2,25 +2,24 @@
SPI HC SMM state registration function declarations
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#ifndef SPI_HC_SMM_STATE_H_
-#define SPI_HC_SMM_STATE_H_
+#ifndef AMD_SPI_HC_SMM_STATE_H_
+#define AMD_SPI_HC_SMM_STATE_H_
#include
#include
#include
-#include "SpiHcInternal.h"
+#include "AmdSpiHcInternal.h"
-typedef struct {
+struct SpiHcRegisterState {
UINT32 Register;
UINT8 Size; // Size in Bytes
UINT8 Count; // Number of contiguous registers to store
-} SPI_HC_REGISTER_STATE;
+};
/**
Allocate the save state space and update the instance structure
@@ -140,4 +139,4 @@ FchSpiUnlockSpiHostControllerRegisters (
IN CONST SMM_EFI_SPI_HC_STATE_PROTOCOL *This
);
-#endif // SPI_HC_SMM_STATE_H__
+#endif // __AMD_SPI_HC_SMM_STATE_H__
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.c b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.c
index 041676ed5b7e252c205a437f312116deafed7793..45238af377d93dd2b6584c6339d2c65dca93f25a 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.c
@@ -3,8 +3,7 @@
SPI HC platform library implementation. This code touches the SPI controllers and performs
the hardware transaction
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -17,18 +16,17 @@
#include
#include
#include
+#include
#include
#include
#include
#include
-#include "SpiHcInternal.h"
+#include "AmdSpiHcInternal.h"
#include
#include
extern EFI_PHYSICAL_ADDRESS mHcAddress;
-SPI_CONTROLLER_DEVICE_PATH mFchDevicePath = FCH_DEVICE_PATH;
-
/**
This function reports the device path of SPI host controller. This is needed in order for the SpiBus
to match the correct SPI_BUS to the SPI host controller
@@ -36,7 +34,7 @@ SPI_CONTROLLER_DEVICE_PATH mFchDevicePath = FCH_DEVICE_PATH;
@param[out] DevicePath The device path for this SPI HC is returned in this variable
@retval EFI_SUCCESS
-**/
+*/
EFI_STATUS
EFIAPI
GetSpiHcDevicePath (
@@ -49,7 +47,7 @@ GetSpiHcDevicePath (
/**
This is the platform specific Spi Chip select function.
- Assert or de-assert the SPI chip select.
+ Assert or deassert the SPI chip select.
This routine is called at TPL_NOTIFY.
Update the value of the chip select line for a SPI peripheral. The SPI bus
@@ -265,11 +263,11 @@ PlatformSpiHcTransaction (
Status = FchSpiControllerNotBusy ();
if (!EFI_ERROR (Status)) {
MmioWrite8 (
- HcAddress + FCH_SPI_MMIO_REG48_TX_BYTE_COUNT,
+ HcAddress + FCH_SPI_MMIO_REG48_TX_BYTECOUNT,
(UINT8)WriteBytes
);
MmioWrite8 (
- HcAddress + FCH_SPI_MMIO_REG4B_RX_BYTE_COUNT,
+ HcAddress + FCH_SPI_MMIO_REG4B_RXBYTECOUNT,
(UINT8)ReadBytes
);
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.uni b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.uni
index e36816d5d138713a8c216e4f31256f0f64e116db..ca72599eeeed4f7a639bf15b0622d02c94720b83 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.uni
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLib.uni
@@ -1,6 +1,6 @@
// /*****************************************************************************
// *
-// * Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+// * Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
// *
// *
// * SPDX-License-Identifier: BSD-2-Clause-Patent
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.c b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.c
index 8f1e2304f8c339bb6b34b0db2602193c6762405d..1292ab697caa2267fb081181620d369800dfebca 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.c
@@ -2,8 +2,7 @@
Implementation of SpiHcPlatformLib for DXE
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -15,9 +14,10 @@
#include
#include
#include
+#include
#include
#include
-#include "SpiHcInternal.h"
+#include "AmdSpiHcInternal.h"
#include
#include
@@ -35,7 +35,7 @@ EFI_PHYSICAL_ADDRESS mHcAddress;
@retval EFI_SUCCESS SPI_HOST_CONTROLLER_INSTANCE was allocated properly
@retval EFI_OUT_OF_RESOURCES The SPI_HOST_CONTROLLER_INSTANCE could not be allocated
-**/
+*/
EFI_STATUS
EFIAPI
GetPlatformSpiHcDetails (
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf
index de4b9235c38ee043e12476351287901cae31cdfd..e7261daefda1cdd3404dc974310827569f43d18c 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibDxe.inf
@@ -1,22 +1,23 @@
-## @file
-# SpiHcPlatformLibrary DXE_DRIVER inf
+#/** @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# SpiHcPlatformLibrary DXE_DRIVER inf
#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
-##
-
+#**/
[Defines]
INF_VERSION = 0x00010019
BASE_NAME = SpiHcPlatformLibDxe
- FILE_GUID = 1B53F26A-971D-4DFC-A13D-2626CFDF863D
+ FILE_GUID = 3C230948-6DF5-4802-8177-967A190579CF
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 0.1
PI_SPECIFICATION_VERSION = 0x0001000A
LIBRARY_CLASS = SpiHcPlatformLib
[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
AmdPlatformPkg/AmdPlatformPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -38,15 +39,15 @@
[Sources]
SpiHcPlatformLibDxe.c
SpiHcPlatformLib.c
- SpiHcInternal.h
- SpiHcInternal.c
+ AmdSpiHcInternal.h
+ AmdSpiHcInternal.c
[Protocols]
gEfiSpiHcProtocolGuid
[FixedPcd]
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSpiRetryCount
- gEfiMdeModulePkgTokenSpaceGuid.PcdSpiNorFlashOperationDelayMicroseconds
+ gEfiMdePkgTokenSpaceGuid.PcdSpiNorFlashOperationDelayMicroseconds
[Depex]
TRUE
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.c b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.c
index c4b4f5e0e17599f84737eb8baf71fc66d622d6dc..85b4eaaf5d9c3a78b066e3e9a49fd5d64b7fed4c 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.c
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.c
@@ -2,8 +2,7 @@
Implementation of SpiHcPlatformLibrary for SMM
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
+ Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -18,12 +17,13 @@
#include
#include
#include
+#include
#include
#include
#include
#include
-#include "SpiHcInternal.h"
-#include "SpiHcSmmState.h"
+#include "AmdSpiHcInternal.h"
+#include "AmdSpiHcSmmState.h"
#define SPI_HC_MAXIMUM_TRANSFER_BYTES 64
@@ -49,7 +49,7 @@ UINT32 mStateRecordCount;
@retval EFI_SUCCESS SPI_HOST_CONTROLLER_INSTANCE was allocated properly
@retval EFI_OUT_OF_RESOURCES The SPI_HOST_CONTROLLER_INSTANCE could not be allocated
-**/
+*/
EFI_STATUS
EFIAPI
GetPlatformSpiHcDetails (
diff --git a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
index 80c7518807c7879ae31ff6d7bfdcd2d2f00ef5e4..8d248f5f854718d61dfaea0bf4b0ec1f111ec664 100644
--- a/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
+++ b/Platform/AMD/AmdPlatformPkg/Library/SpiHcPlatformLib/SpiHcPlatformLibSmm.inf
@@ -1,12 +1,11 @@
-## @file
-# SpiHcPlatformLibrary DXE_SMM_DRIVER inf
+#/** @file
#
-# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+# SpiHcPlatformLibrary DXE_SMM_DRIVER inf
#
+# Copyright (C) 2024-2025 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
-##
-
+#**/
[Defines]
INF_VERSION = 0x00010019
BASE_NAME = SpiHcPlatformLibSmm
@@ -17,6 +16,8 @@
LIBRARY_CLASS = SpiHcPlatformLib
[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
AmdPlatformPkg/AmdPlatformPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -36,10 +37,10 @@
[Sources]
SpiHcPlatformLibSmm.c
SpiHcPlatformLib.c
- SpiHcInternal.h
- SpiHcInternal.c
- SpiHcSmmState.h
- SpiHcSmmState.c
+ AmdSpiHcInternal.h
+ AmdSpiHcInternal.c
+ AmdSpiHcSmmState.h
+ AmdSpiHcSmmState.c
[Protocols]
gEfiSmmVariableProtocolGuid
@@ -49,7 +50,7 @@
[FixedPcd]
gAmdPlatformPkgTokenSpaceGuid.PcdAmdSpiRetryCount
- gEfiMdeModulePkgTokenSpaceGuid.PcdSpiNorFlashOperationDelayMicroseconds
+ gEfiMdePkgTokenSpaceGuid.PcdSpiNorFlashOperationDelayMicroseconds
[Depex]
TRUE
diff --git a/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.c b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.c
new file mode 100644
index 0000000000000000000000000000000000000000..bfc19788e15f4523dcd0608c8d37e6678bb84f94
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.c
@@ -0,0 +1,224 @@
+/** @file
+
+ FV block I/O protocol driver for SPI flash libary.
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "AcpiCommon.h"
+
+EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol;
+EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol;
+
+/**
+ Locates an existing ACPI Table
+
+ @param[in] Signature - The Acpi table signature
+ @param[in] OemTableId - The Acpi table OEM Table ID. Ignored if 0
+ @param[out] Table - Table if Found or NULL
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+GetExistingAcpiTable (
+ IN UINT32 Signature,
+ IN UINT64 OemTableId,
+ OUT EFI_ACPI_SDT_HEADER **Table
+)
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_ACPI_SDT_HEADER *LocalTable;
+ EFI_ACPI_TABLE_VERSION LocalVersion;
+ UINTN LocalTableKey;
+
+ Status = EFI_NOT_FOUND;
+ *Table = NULL;
+
+ for (Index = 0; ; Index++) {
+ Status = mAcpiSdtProtocol->GetAcpiTable (Index, &LocalTable, &LocalVersion, &LocalTableKey);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!(LocalTable->Signature == Signature)) {
+ continue;
+ }
+ // Accept table if OemTableId is zero.
+ if (OemTableId == 0 ||
+ CompareMem (&LocalTable->OemTableId, &OemTableId, 8) == 0) {
+ *Table = LocalTable;
+ return EFI_SUCCESS;
+ }
+ }
+}
+
+/**
+ Appends generated AML to an existing ACPI Table
+
+ 1. Locate the existing ACPI table
+ 2. Allocate pool for original table plus new data size
+ 3. Copy original table to new buffer
+ 4. Append new data to buffer
+ 5. Update Table header length (Checksum will be calculated on install)
+ 6. Uninstall original ACPI table
+ 7. Install appended table
+ 8. Free new table buffer since ACPI made a copy.
+
+ @param[in] Signature - The Acpi table signature
+ @param[in] OemId - The Acpi table OEM ID
+ @param[in] AmlData - The AML data to append
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+AppendExistingAcpiTable (
+ IN UINT32 Signature,
+ IN UINT64 OemId,
+ IN EFI_ACPI_DESCRIPTION_HEADER *AmlData
+ )
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_ACPI_SDT_HEADER *Table;
+ EFI_ACPI_TABLE_VERSION Version;
+ UINTN TableKey;
+ EFI_ACPI_SDT_HEADER *ReplacementAcpiTable;
+ UINT32 ReplacementAcpiTableLength;
+ UINTN TableHandle;
+
+ for (Index = 0; ; Index++) {
+ Status = mAcpiSdtProtocol->GetAcpiTable (Index, &Table, &Version, &TableKey);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ERROR: ACPI table not found with signature=0x%X\n", Signature));
+ return Status;
+ }
+
+ if ((Table->Signature == Signature) &&
+ (CompareMem (&Table->OemTableId, &OemId, 8) == 0))
+ {
+ break;
+ }
+ }
+
+ // Calculate new DSDT Length and allocate space
+ ReplacementAcpiTableLength = Table->Length + (UINT32)(AmlData->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER));
+ ReplacementAcpiTable = AllocatePool (ReplacementAcpiTableLength);
+ if (ReplacementAcpiTable == NULL) {
+ DEBUG ((DEBUG_ERROR, "ERROR: Unable to allocate Replacement Table space.\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ // Copy the old DSDT to the new buffer
+ CopyMem (ReplacementAcpiTable, Table, Table->Length);
+ // Append new data to DSDT
+ CopyMem (
+ (UINT8 *)ReplacementAcpiTable + Table->Length,
+ (UINT8 *)AmlData + sizeof (EFI_ACPI_DESCRIPTION_HEADER),
+ AmlData->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)
+ );
+ ReplacementAcpiTable->Length = ReplacementAcpiTableLength;
+
+ // Uninstall the original DSDT
+ Status = mAcpiTableProtocol->UninstallAcpiTable (
+ mAcpiTableProtocol,
+ TableKey
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ERROR: Unable to uninstall original ACPI Table signature=0x%X\n", Signature));
+ } else {
+ // Install ACPI table
+ Status = mAcpiTableProtocol->InstallAcpiTable (
+ mAcpiTableProtocol,
+ ReplacementAcpiTable,
+ ReplacementAcpiTableLength,
+ &TableHandle
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "ERROR: Unable to re-install ACPI Table signature=0x%X\n", Signature));
+ }
+ }
+
+ // Release this copy of table
+ FreePool (ReplacementAcpiTable);
+ return Status;
+}
+
+/**
+ Install common platform SSDTs and DSDT additions
+
+ Place to install all generically identifiable SSDT tables. These tables will
+ be programmattically created from UEFI or AGESA resources and should cover
+ many different Processor Family IPs.
+
+ Might need to split this driver into LibraryClasses for each
+ functionality/SSDT while keeping a single driver to reduce the AmlLib overhead.
+
+ @param[in] ImageHandle - Standard UEFI entry point Image Handle
+ @param[in] SystemTable - Standard UEFI entry point System Table
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+InstallAllAcpiTables (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+
+ // Get Acpi Table Protocol
+ Status = gBS->LocateProtocol (
+ &gEfiAcpiTableProtocolGuid,
+ NULL,
+ (VOID **)&mAcpiTableProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // Get Acpi SDT Protocol
+ Status = gBS->LocateProtocol (
+ &gEfiAcpiSdtProtocolGuid,
+ NULL,
+ (VOID **)&mAcpiSdtProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = InstallCpuAcpi (ImageHandle, SystemTable);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: CPU SSDT install error: Status=%r\n",
+ __FUNCTION__,
+ Status
+ ));
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ Status = InstallPciAcpi (ImageHandle, SystemTable);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: PCI SSDT install error: Status=%r\n",
+ __FUNCTION__,
+ Status
+ ));
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ InstallAcpiSpmiTable ();
+
+ return Status;
+}
diff --git a/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.h b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.h
new file mode 100644
index 0000000000000000000000000000000000000000..aae1fa996d8fd83d936e7427e5d2142d6db15f27
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.h
@@ -0,0 +1,120 @@
+/** @file
+
+ FV block I/O protocol driver for SPI flash libary.
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef ACPI_COMMON_H_
+#define ACPI_COMMON_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define AMD_DSDT_OEMID SIGNATURE_64 ('A', 'm', 'd', 'T','a','b','l','e')
+#define CREATOR_REVISION 2
+#define MAX_LOCAL_STRING_SIZE 20
+#define OEM_REVISION_NUMBER 0
+#define CXL_EARLY_DISCOVERY_TABLE_SIGNATURE SIGNATURE_32 ('C', 'E', 'D', 'T') /// "CEDT" CXL Early Discovery Table
+
+extern EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol;
+extern EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol;
+
+/**
+ Locates an existing ACPI Table
+
+ @param[in] Signature - The Acpi table signature
+ @param[in] OemTableId - The Acpi table OEM Table ID. Ignored if 0
+ @param[out] Table - Table if Found or NULL
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+GetExistingAcpiTable (
+ IN UINT32 Signature,
+ IN UINT64 OemTableId,
+ OUT EFI_ACPI_SDT_HEADER **Table
+);
+
+/**
+ Appends generated AML to an existing ACPI Table
+
+ 1. Locate the existing ACPI table
+ 2. Allocate pool for original table plus new data size
+ 3. Copy original table to new buffer
+ 4. Append new data to buffer
+ 5. Update Table header length (Checksum will be calculated on install)
+ 6. Uninstall original ACPI table
+ 7. Install appended table
+ 8. Free new table buffer since ACPI made a copy.
+
+ @param[in] Signature - The Acpi table signature
+ @param[in] OemId - The Acpi table OEM ID
+ @param[in] AmlData - The AML data to append
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+AppendExistingAcpiTable (
+ IN UINT32 Signature,
+ IN UINT64 OemId,
+ IN EFI_ACPI_DESCRIPTION_HEADER *AmlData
+ );
+
+/**
+ Install CPU devices scoped under \_SB into DSDT
+
+ Determine all the CPU threads and create ACPI Device nodes for each thread.
+ AGESA will scope to these CPU records when installing CPU power and
+ performance capabilities.
+
+ @param[in] ImageHandle - Standard UEFI entry point Image Handle
+ @param[in] SystemTable - Standard UEFI entry point System Table
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+InstallCpuAcpi (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+/**
+ Install PCI devices scoped under \_SB into DSDT
+
+ Determine all the PCI Root Bridges and PCI root ports and install resources
+ including needed _HID, _CID, _UID, _ADR, _CRS and _PRT Nodes.
+
+ @param[in] ImageHandle - Standard UEFI entry point Image Handle
+ @param[in] SystemTable - Standard UEFI entry point System Table
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+InstallPciAcpi (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+VOID
+EFIAPI
+InstallAcpiSpmiTable (
+ VOID
+ );
+
+#endif // ACPI_COMMON_H__
diff --git a/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.inf b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.inf
new file mode 100644
index 0000000000000000000000000000000000000000..60afdd7664d3177a4c0318788a758d3572e13b9d
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/AcpiCommon.inf
@@ -0,0 +1,73 @@
+#/** @file
+#
+# Component description file for SpiFvbDxe module
+#
+# Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AcpiCommon
+ FILE_GUID = 66838F31-1062-415C-957A-CC2871D9E6B7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InstallAllAcpiTables
+
+[Sources.common]
+ AcpiCommon.c
+ AcpiCommon.h
+ CpuSsdt.c
+ PciSsdt.c
+ Spmi.c
+
+[Packages]
+ AmdPlatformPkg/AmdPlatformPkg.dec
+ DynamicTablesPkg/DynamicTablesPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ MdePkg/MdePkg.dec
+ MinPlatformPkg/MinPlatformPkg.dec
+
+[LibraryClasses]
+ AmlLib
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ HobLib
+ IoLib
+ MemoryAllocationLib
+ PcdLib
+ PlatformSocLib
+ SortLib
+ UefiDriverEntryPoint
+
+[Protocols]
+ gEfiAcpiSdtProtocolGuid ## CONSUMES
+ gEfiAcpiTableProtocolGuid ## CONSUMES
+ gEfiMpServiceProtocolGuid ## CONSUMES
+ gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
+
+[Pcd]
+ gAmdPlatformPkgTokenSpaceGuid.PcdIpmiInterfaceType ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemTableId ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdIpmiKcsIoBaseAddress ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdIoApicAddress ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdMaxCpuSocketCount ## CONSUMES
+ gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicAddressBase
+
+[Guids]
+ gEfiHobListGuid
+
+[Depex]
+ gEfiMpServiceProtocolGuid AND
+ gEfiAcpiTableProtocolGuid AND
+ gEfiPciRootBridgeIoProtocolGuid AND
+ gEfiPciEnumerationCompleteProtocolGuid
+
diff --git a/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/CpuSsdt.c b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/CpuSsdt.c
new file mode 100644
index 0000000000000000000000000000000000000000..f4edc4d5ca6b61a375ebfb9fb37e7d339cbf6828
--- /dev/null
+++ b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/CpuSsdt.c
@@ -0,0 +1,341 @@
+/** @file
+
+ FV block I/O protocol driver for SPI flash libary.
+
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include "AcpiCommon.h"
+
+#include
+#include
+#include
+#include // for CPUID_EXTENDED_TOPOLOGY
+
+#define AMD_CPUID_EXTENDED_TOPOLOGY_V2 0x26
+#define AMD_CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_CCD 0x04
+#define AMD_CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_CCX 0x03
+#define AMD_CPUID_V2_EXTENDED_TOPOLOGY_LEVEL_TYPE_DIE 0x05
+#define CREATOR_REVISION 2
+#define DEVICE_BATTERY_BIT 0x0010// Control Method Battery Device Only
+#define DEVICE_ENABLED_BIT 0x0002
+#define DEVICE_HEALTH_BIT 0x0008
+#define DEVICE_IN_UI_BIT 0x0004
+#define DEVICE_PRESENT_BIT 0x0001
+#define MAX_TEST_CPU_STRING_SIZE 20
+#define OEM_REVISION_NUMBER 0
+
+EFI_PROCESSOR_INFORMATION *mApicIdtoUidMap = NULL;
+UINT32 mCcdOrder[16] = { 0, 4, 8, 12, 2, 6, 10, 14, 3, 7, 11, 15, 1, 5, 9, 13 };
+UINTN mNumberOfCpus = 0;
+UINTN mNumberOfEnabledCPUs = 0;
+
+/**
+ Callback compare function.
+ Compares CCD number of provided arguments.
+
+ @param[in] LocalX2ApicLeft Pointer to Left Buffer.
+ @param[in] LocalX2ApicRight Pointer to Right Buffer.
+ @return 0 If both are same
+ -1 If left value is less than righ value.
+ 1 If left value is greater than righ value.
+
+**/
+INTN
+EFIAPI
+SortByCcd (
+ IN CONST VOID *LocalX2ApicLeft,
+ IN CONST VOID *LocalX2ApicRight
+ )
+{
+ EFI_PROCESSOR_INFORMATION *Left;
+ EFI_PROCESSOR_INFORMATION *Right;
+ UINT32 Index;
+ UINT32 LeftCcdIndex;
+ UINT32 RightCcdIndex;
+
+ Left = (EFI_PROCESSOR_INFORMATION *)LocalX2ApicLeft;
+ Right = (EFI_PROCESSOR_INFORMATION *)LocalX2ApicRight;
+
+ // Get the CCD Index number
+ LeftCcdIndex = MAX_UINT32;
+ for (Index = 0; Index < ARRAY_SIZE (mCcdOrder); Index++) {
+ if (Left->ExtendedInformation.Location2.Die == mCcdOrder[Index]) {
+ LeftCcdIndex = Index;
+ break;
+ }
+ }
+
+ RightCcdIndex = MAX_UINT32;
+ for (Index = 0; Index < ARRAY_SIZE (mCcdOrder); Index++) {
+ if (Right->ExtendedInformation.Location2.Die == mCcdOrder[Index]) {
+ RightCcdIndex = Index;
+ break;
+ }
+ }
+
+ // Now compare for quick sort
+ if (LeftCcdIndex < RightCcdIndex) {
+ return -1;
+ }
+
+ if (LeftCcdIndex > RightCcdIndex) {
+ return 1;
+ }
+
+ return 0;
+}
+
+EFI_STATUS
+GenerateApicIdtoUidMap (
+ VOID
+ )
+{
+ EFI_MP_SERVICES_PROTOCOL *MpService;
+ EFI_STATUS Status;
+ UINTN Index;
+
+ // Get MP service
+ Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpService);
+ if (EFI_ERROR (Status) || (MpService == NULL)) {
+ return EFI_NOT_FOUND;
+ }
+
+ // Load MpServices
+ Status = MpService->GetNumberOfProcessors (MpService, &mNumberOfCpus, &mNumberOfEnabledCPUs);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DEBUG ((DEBUG_ERROR, "%a: NumberOfCpus = %d mNumberOfEnabledCPUs = %d\n", __func__, mNumberOfCpus, mNumberOfEnabledCPUs));
+
+ mApicIdtoUidMap = AllocateZeroPool (mNumberOfCpus * sizeof (EFI_PROCESSOR_INFORMATION));
+ if (mApicIdtoUidMap == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ Status = MpService->GetProcessorInfo (
+ MpService,
+ Index | CPU_V2_EXTENDED_TOPOLOGY,
+ &mApicIdtoUidMap[Index]
+ );
+ }
+
+ if (FixedPcdGet32 (PcdMaxCpuSocketCount) > 1) {
+ /// Sort by CCD location
+ PerformQuickSort (mApicIdtoUidMap, mNumberOfCpus/2, sizeof (EFI_PROCESSOR_INFORMATION), SortByCcd);
+ PerformQuickSort (mApicIdtoUidMap+(mNumberOfCpus/2), mNumberOfCpus/2, sizeof (EFI_PROCESSOR_INFORMATION), SortByCcd);
+ } else {
+ /// Sort by CCD location
+ PerformQuickSort (mApicIdtoUidMap, mNumberOfCpus, sizeof (EFI_PROCESSOR_INFORMATION), SortByCcd);
+ }
+
+ // Now allocate the Uid
+ for (Index = 0; Index < mNumberOfCpus; Index++) {
+ // Now make Processor as Uid
+ mApicIdtoUidMap[Index].ProcessorId = Index;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Install CPU devices scoped under \_SB into DSDT
+
+ Determine all the CPU threads and create ACPI Device nodes for each thread.
+ AGESA will scope to these CPU records when installing CPU power and
+ performance capabilities.
+
+ @param[in] ImageHandle - Standard UEFI entry point Image Handle
+ @param[in] SystemTable - Standard UEFI entry point System Table
+
+ @retval EFI_SUCCESS, various EFI FAILUREs.
+**/
+EFI_STATUS
+EFIAPI
+InstallCpuAcpi (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ AML_OBJECT_NODE_HANDLE CpuInstanceNode;
+ AML_OBJECT_NODE_HANDLE CpuNode;
+ AML_OBJECT_NODE_HANDLE ScopeNode;
+ AML_ROOT_NODE_HANDLE RootNode;
+ CHAR8 *String;
+ CHAR8 Identifier[MAX_TEST_CPU_STRING_SIZE];
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
+ EFI_MP_SERVICES_PROTOCOL *MpServices;
+ EFI_STATUS Status;
+ EFI_STATUS Status1;
+ UINTN DeviceStatus;
+ UINTN Index;
+ UINTN NumberOfEnabledProcessors;
+ UINTN NumberOfLogicProcessors;
+
+ DEBUG ((DEBUG_INFO, "%a: Entry\n", __FUNCTION__));
+
+ String = &Identifier[0];
+
+ // Get MP service
+ MpServices = NULL;
+ Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpServices);
+ if (EFI_ERROR (Status) || (MpServices == NULL)) {
+ return EFI_NOT_FOUND;
+ }
+
+ // Generate ACPI UID Map
+ Status = GenerateApicIdtoUidMap ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: Could not generate ApicId to ProcessorUid map.\n", __func__));
+ return EFI_NOT_FOUND;
+ }
+
+ // Load MpServices
+ Status = MpServices->GetNumberOfProcessors (MpServices, &NumberOfLogicProcessors, &NumberOfEnabledProcessors);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = AmlCodeGenDefinitionBlock (
+ "SSDT",
+ "AMD ",
+ "SSDTPROC",
+ 0x00,
+ &RootNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ Status = AmlCodeGenScope ("\\_SB_", RootNode, &ScopeNode); // START: Scope (\_SB)
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ CpuNode = ScopeNode;
+
+ for (Index = 0; Index < NumberOfLogicProcessors; Index++) {
+ // Check for valid Processor under the current socket
+ if (!mApicIdtoUidMap[Index].StatusFlag) {
+ continue;
+ }
+
+ // Assumption is that AGESA will have to do the same thing.
+ AsciiSPrint (String, MAX_TEST_CPU_STRING_SIZE, "C%03X", Index);
+ Status = AmlCodeGenDevice (String, CpuNode, &CpuInstanceNode); // START: Device (CXXX)
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // _HID
+ Status = AmlCodeGenNameString ("_HID", "ACPI0007", CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ DeviceStatus = DEVICE_PRESENT_BIT | DEVICE_IN_UI_BIT;
+ if (mApicIdtoUidMap[Index].StatusFlag & PROCESSOR_ENABLED_BIT) {
+ DeviceStatus |= DEVICE_ENABLED_BIT;
+ }
+
+ if (mApicIdtoUidMap[Index].StatusFlag & PROCESSOR_HEALTH_STATUS_BIT) {
+ DeviceStatus |= DEVICE_HEALTH_BIT;
+ }
+
+ // _UID - Must match ACPI Processor UID in MADT
+ Status = AmlCodeGenNameInteger ("_UID", mApicIdtoUidMap[Index].ProcessorId, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // _STA - As defined by 6.3.7
+ Status = AmlCodeGenMethodRetInteger ("_STA", DeviceStatus, 0, FALSE, 0, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // PACK -> Package
+ Status = AmlCodeGenNameInteger ("PACK", mApicIdtoUidMap[Index].ExtendedInformation.Location2.Package, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // CCD_ -> Ccd
+ Status = AmlCodeGenNameInteger ("CCD_", mApicIdtoUidMap[Index].ExtendedInformation.Location2.Die, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // CCX_ -> Ccx
+ Status = AmlCodeGenNameInteger ("CCX_", mApicIdtoUidMap[Index].ExtendedInformation.Location2.Module, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // CORE -> Core Number
+ Status = AmlCodeGenNameInteger ("CORE", mApicIdtoUidMap[Index].ExtendedInformation.Location2.Core, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // THRD -> Thread
+ Status = AmlCodeGenNameInteger ("THRD", mApicIdtoUidMap[Index].ExtendedInformation.Location2.Thread, CpuInstanceNode, NULL);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+ }
+
+ Table = NULL;
+ // Serialize the tree.
+ Status = AmlSerializeDefinitionBlock (
+ RootNode,
+ &Table
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: SSDT-PCI: Failed to Serialize SSDT Table Data."
+ " Status = %r\n",
+ Status
+ ));
+ return (Status);
+ }
+
+ // Cleanup
+ Status1 = AmlDeleteTree (RootNode);
+ if (EFI_ERROR (Status1)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: SSDT-PCI: Failed to cleanup AML tree."
+ " Status = %r\n",
+ Status1
+ ));
+ // If Status was success but we failed to delete the AML Tree
+ // return Status1 else return the original error code, i.e. Status.
+ if (!EFI_ERROR (Status)) {
+ return Status1;
+ }
+ }
+
+ Status = AppendExistingAcpiTable (
+ EFI_ACPI_6_5_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE,
+ AMD_DSDT_OEMID,
+ Table
+ );
+
+ return Status;
+}
diff --git a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.c b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/PciSsdt.c
similarity index 72%
rename from Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.c
rename to Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/PciSsdt.c
index 5646479d2dc4b786eebfa097663e4db31ed6f933..cfcb99210888922ceeaea214a3298a6968263cb6 100644
--- a/Platform/AMD/AmdPlatformPkg/DynamicTables/Library/Acpi/AcpiSsdtPciLib/AcpiSsdtPciLib.c
+++ b/Platform/AMD/AmdPlatformPkg/Universal/Acpi/AcpiCommon/PciSsdt.c
@@ -1,38 +1,28 @@
/** @file
+ Creates SSDT table for PCIe devices
- Generate ACPI SSDT PCI table for AMD platforms.
+ Copyright (C) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
- Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
-
- SPDX-License-Identifier BSD-2-Clause-Patent
**/
-
#include
#include
#include
-#include
#include
#include
-#include
#include
-#include
#include
-#include
-#include
#include
-#include
+#include
#include
+#include "AcpiCommon.h"
-/// "CEDT" CXL Early Discovery Table
-#define CXL_EARLY_DISCOVERY_TABLE_SIGNATURE SIGNATURE_32 ('C', 'E', 'D', 'T')
-#define MAX_PCI_BUS_NUMBER_PER_SEGMENT 0x100
+#define MAX_PCI_BUS_NUMBER_PER_SEGMENT 0x100
-EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol;
-EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol;
-EFI_HANDLE mDriverHandle;
+EFI_HANDLE mDriverHandle;
/**
- Collect and sort the root bridge devices
+ Create sorted Root Bridge instances from AGESA NBIO resources.
Does not include the Root Bridge resources
@@ -65,24 +55,13 @@ InternalCollectSortedRootBridges (
LocalRootBridgeCount = 0;
Status = GetPcieInfo (&LocalRootBridge, &LocalRootBridgeCount);
if (EFI_ERROR (Status) || (LocalRootBridge == NULL) || (LocalRootBridgeCount == 0)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a:%d Cannot obtain Platform PCIe configuration information.\n",
- __func__,
- __LINE__
- ));
+ DEBUG ((DEBUG_ERROR, "%a:%d Cannot obtain Platform PCIe configuration information.\n", __func__, __LINE__));
return EFI_NOT_FOUND;
}
// Sort by PCIe bus number
- for (SortedIndex = 0, SortedRb = LocalRootBridge;
- SortedIndex < LocalRootBridgeCount;
- SortedIndex++, SortedRb++)
- {
- for (UnsortedIndex = 0, UnsortedRb = LocalRootBridge;
- UnsortedIndex < LocalRootBridgeCount;
- UnsortedIndex++, UnsortedRb++)
- {
+ for (SortedIndex = 0, SortedRb = LocalRootBridge; SortedIndex < LocalRootBridgeCount; SortedIndex++, SortedRb++) {
+ for (UnsortedIndex = 0, UnsortedRb = LocalRootBridge; UnsortedIndex < LocalRootBridgeCount; UnsortedIndex++, UnsortedRb++) {
if (SortedRb->Object->BaseBusNumber < UnsortedRb->Object->BaseBusNumber) {
CopyMem (&TempRootBridge, UnsortedRb, sizeof (AMD_PCI_ROOT_BRIDGE_OBJECT_INSTANCE));
CopyMem (UnsortedRb, SortedRb, sizeof (AMD_PCI_ROOT_BRIDGE_OBJECT_INSTANCE));
@@ -124,9 +103,6 @@ InternalInsertRootBridgeInterrupts (
Status = AmlCodeGenNamePackage ("_PRT", NULL, &PrtNode);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
if ((RootBridge->Object->BaseBusNumber == 0) && (RootBridge->Object->Segment == 0)) {
// Package () {0x0014FFFF, 0, 0, 16}, // 0 + 16
@@ -137,9 +113,7 @@ InternalInsertRootBridgeInterrupts (
16,
PrtNode
);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
// Package () {0x0014FFFF, 1, 0, 17}, // 0 + 17
Status = AmlAddPrtEntry (
@@ -149,9 +123,7 @@ InternalInsertRootBridgeInterrupts (
17,
PrtNode
);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
// Package () {0x0014FFFF, 2, 0, 18}, // 0 + 18
Status = AmlAddPrtEntry (
@@ -161,9 +133,7 @@ InternalInsertRootBridgeInterrupts (
18,
PrtNode
);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
// Package () {0x0014FFFF, 3, 0, 19}, // 0 + 19
Status = AmlAddPrtEntry (
@@ -173,12 +143,12 @@ InternalInsertRootBridgeInterrupts (
19,
PrtNode
);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
}
/// Add interrupt for Device 0 function 3 (generic to all function)
+ /// Value is taken from CRB BIOS
+ /// Fix the "pcieport 0000:XX:XX.3: can't derive routing for PCI INT A" error
Status = AmlAddPrtEntry (
0xFFFF,
0,
@@ -189,9 +159,7 @@ InternalInsertRootBridgeInterrupts (
ASSERT_EFI_ERROR (Status);
for (Index = 1; Index <= RootBridge->RootPortCount; Index++) {
- if ((RootBridge->RootPort[Index]->PortPresent == 0) &&
- (RootBridge->RootPort[Index]->Enabled == 0))
- {
+ if ((RootBridge->RootPort[Index]->PortPresent == 0) && (RootBridge->RootPort[Index]->Enabled == 0)) {
continue;
}
@@ -204,35 +172,33 @@ InternalInsertRootBridgeInterrupts (
(UINT32)(RootBridge->GlobalInterruptStart + RootBridge->RootPort[Index]->EndpointInterruptArray[RootBridge->RootPort[Index]->Function - 1]),
PrtNode
);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
}
}
// Attach the _PRT entry.
Status = AmlAttachNode (PciNode, PrtNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ AmlDeleteTree (PrtNode);
+ ASSERT_EFI_ERROR (Status);
}
PrtNode = NULL;
- return Status;
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
-exit_handler:
- ASSERT_EFI_ERROR (Status);
- AmlDeleteTree (PrtNode);
return Status;
}
/**
- Insert Root Bridge resources into AML table
+ Insert Root Bridge resources into the AML table
@param[in] RootBridge - Single Root Bridge instance
- @param[in, out] CrsNode - AML tree node
+ @param[in,out] Crs - AmlLib tree node for CRS
- @retval EFI_SUCCESS, various EFI FAILURES.
+ @retval EFI_SUCCESS, various EFI FAILUREs.
**/
EFI_STATUS
EFIAPI
@@ -241,14 +207,14 @@ InternalInsertRootBridgeResources (
IN OUT AML_OBJECT_NODE_HANDLE CrsNode
)
{
- EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *LocalBuffer;
+ EFI_STATUS Status;
EFI_HANDLE *HandleBuffer;
+ UINTN NumHandles;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Io;
- EFI_STATUS Status;
- UINTN BaseBusNumber;
UINTN Index;
- UINTN NumHandles;
VOID *Configuration; // Never free this buffer
+ EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR *LocalBuffer;
+ UINTN BaseBusNumber;
BaseBusNumber = ~(UINTN)0;
// Get EFI Pci Root Bridge I/O Protocols
@@ -276,19 +242,13 @@ InternalInsertRootBridgeResources (
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
- FreePool (HandleBuffer);
return Status;
}
if (Io->SegmentNumber == RootBridge->Object->Segment) {
Status = Io->Configuration (Io, &Configuration);
if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a: ERROR: Retrieve Root Bridge Configuration failed\n",
- __func__
- ));
- FreePool (HandleBuffer);
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Retrieve Root Bridge Configuration failed\n", __func__));
return Status;
}
@@ -301,7 +261,7 @@ InternalInsertRootBridgeResources (
if ((LocalBuffer->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) &&
(LocalBuffer->AddrRangeMin == RootBridge->Object->BaseBusNumber))
{
- BaseBusNumber = (UINTN)LocalBuffer->AddrRangeMin;
+ BaseBusNumber = LocalBuffer->AddrRangeMin;
break;
}
}
@@ -315,13 +275,8 @@ InternalInsertRootBridgeResources (
}
}
- FreePool (HandleBuffer);
if ((Configuration == NULL) || (LocalBuffer == NULL)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a: ERROR: Retrieve Root Bridge Configuration failed\n",
- __func__
- ));
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Retrieve Root Bridge Configuration failed\n", __func__));
return EFI_NOT_FOUND;
}
@@ -335,7 +290,7 @@ InternalInsertRootBridgeResources (
break;
} else if (LocalBuffer->Header.Header.Byte == ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) {
if (LocalBuffer->ResType == ACPI_ADDRESS_SPACE_TYPE_BUS) {
- BaseBusNumber = (UINTN)LocalBuffer->AddrRangeMin;
+ BaseBusNumber = LocalBuffer->AddrRangeMin;
Status = AmlCodeGenRdWordBusNumber (
FALSE,
TRUE,
@@ -351,9 +306,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
} else if (LocalBuffer->ResType == ACPI_ADDRESS_SPACE_TYPE_IO) {
Status = AmlCodeGenRdWordIo (
FALSE,
@@ -373,9 +325,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
} else if (LocalBuffer->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -396,9 +345,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
}
} else {
DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid Configuration Entry\n", __func__));
@@ -427,9 +373,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -439,7 +382,7 @@ InternalInsertRootBridgeResources (
FALSE, // non cacheable
TRUE,
0,
- PcdGet32 (PcdIoApicBaseAddress),
+ PcdGet32 (PcdPcIoApicAddressBase),
0xFED3FFFF,
0x0,
0x140000,
@@ -450,9 +393,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -463,9 +403,29 @@ InternalInsertRootBridgeResources (
TRUE,
0,
0xFED45000,
+ 0xFED811FF,
+ 0x0,
+ 0x3C200,
+ 0,
+ NULL,
+ 0,
+ TRUE,
+ CrsNode,
+ NULL
+ );
+
+ Status = AmlCodeGenRdQWordMemory (
+ FALSE,
+ TRUE,
+ TRUE,
+ TRUE,
+ FALSE, // non cacheable
+ TRUE,
+ 0,
+ 0xFED81900,
0xFEDC1FFF,
0x0,
- 0x7D000,
+ 0x40700,
0,
NULL,
0,
@@ -473,9 +433,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -496,9 +453,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -519,9 +473,6 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
Status = AmlCodeGenRdQWordMemory (
FALSE,
@@ -542,9 +493,11 @@ InternalInsertRootBridgeResources (
CrsNode,
NULL
);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ }
+
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ return Status;
}
return EFI_SUCCESS;
@@ -567,22 +520,19 @@ InternalInsertRootPorts (
IN OUT AML_OBJECT_NODE_HANDLE PciNode
)
{
- AML_METHOD_PARAM MethodParam[7];
- AML_OBJECT_NODE_HANDLE DeviceNode;
- AML_OBJECT_NODE_HANDLE DsmMethod;
- AML_OBJECT_NODE_HANDLE OstMethod;
- AML_OBJECT_NODE_HANDLE PrtNode;
+ EFI_STATUS Status;
CHAR8 NameSeg[5];
CHAR8 RpName[15];
- EFI_STATUS Status;
- UINTN Index;
UINTN RPIndex;
+ UINTN Index;
+ AML_OBJECT_NODE_HANDLE DeviceNode;
+ AML_OBJECT_NODE_HANDLE PrtNode;
+ AML_OBJECT_NODE_HANDLE DsmMethod;
+ AML_OBJECT_NODE_HANDLE OstMethod;
+ AML_METHOD_PARAM MethodParam[7];
- Status = EFI_SUCCESS;
for (RPIndex = 1; RPIndex <= RootBridge->RootPortCount; RPIndex++) {
- if ((RootBridge->RootPort[RPIndex]->PortPresent == 0) &&
- (RootBridge->RootPort[RPIndex]->Enabled == 0))
- {
+ if ((RootBridge->RootPort[RPIndex]->PortPresent == 0) && (RootBridge->RootPort[RPIndex]->Enabled == 0)) {
continue;
}
@@ -592,6 +542,7 @@ InternalInsertRootPorts (
Status = AmlCodeGenDevice (NameSeg, PciNode, &DeviceNode);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -602,6 +553,7 @@ InternalInsertRootPorts (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -614,15 +566,14 @@ InternalInsertRootPorts (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
}
// _DSM and _OST, handling for root port EDR feature.
// Device 1 to 4 are external PCIe ports, only include them.
- if ((RootBridge->RootPort[RPIndex]->Device > 0) &&
- (RootBridge->RootPort[RPIndex]->Device < 5))
- {
+ if ((RootBridge->RootPort[RPIndex]->Device > 0) && (RootBridge->RootPort[RPIndex]->Device < 5)) {
DEBUG ((
DEBUG_INFO,
"%a:Add EDR support for Uid 0x%x Addr 0x%x\n",
@@ -647,6 +598,7 @@ InternalInsertRootPorts (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -657,6 +609,7 @@ InternalInsertRootPorts (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -671,6 +624,7 @@ InternalInsertRootPorts (
&DsmMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -698,6 +652,7 @@ InternalInsertRootPorts (
DsmMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -712,6 +667,7 @@ InternalInsertRootPorts (
&OstMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -733,15 +689,14 @@ InternalInsertRootPorts (
OstMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
}
// Build Root Port _PRT entry and insert in main ACPI Object list
Status = AmlCodeGenNamePackage ("_PRT", NULL, &PrtNode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ ASSERT_EFI_ERROR (Status);
for (Index = 0; Index <= 3; Index++) {
Status = AmlAddPrtEntry (
@@ -752,8 +707,7 @@ InternalInsertRootPorts (
PrtNode
);
if (EFI_ERROR (Status)) {
- AmlDeleteTree (PrtNode);
- return Status;
+ ASSERT_EFI_ERROR (Status);
}
}
@@ -761,21 +715,23 @@ InternalInsertRootPorts (
Status = AmlAttachNode (DeviceNode, PrtNode);
if (EFI_ERROR (Status)) {
AmlDeleteTree (PrtNode);
- return Status;
+ ASSERT_EFI_ERROR (Status);
}
PrtNode = NULL;
}
+ if (EFI_ERROR (Status)) {
+ Status = EFI_DEVICE_ERROR;
+ }
+
return Status;
}
/**
- Insert CXL Root Bridge into the AML table
+ Insert CXL Root Bridge Port into the AML table
- @param[in] RootBridgeHead - RootBridge information pointer
- @param[in] RootBridgeCount - Number of root bridges
- @param[in,out] PciNode - AmlLib table node
+ @param[in,out] PciNode - AmlLib table node
@retval EFI_SUCCESS, various EFI FAILUREs.
**/
@@ -789,16 +745,16 @@ InternalInsertCxlRootBridge (
{
AMD_PCI_ADDR PciAddr;
AMD_PCI_ROOT_BRIDGE_OBJECT_INSTANCE *RootBridge;
- AML_METHOD_PARAM MethodParam[7];
AML_OBJECT_NODE_HANDLE CrsNode;
AML_OBJECT_NODE_HANDLE DeviceNode;
- AML_OBJECT_NODE_HANDLE OscMethod;
AML_OBJECT_NODE_HANDLE PackageNode;
CHAR8 NameSeg[5];
EFI_STATUS Status;
UINT32 EisaId;
UINT8 DevIndex;
UINT8 Index;
+ AML_METHOD_PARAM MethodParam[7];
+ AML_OBJECT_NODE_HANDLE OscMethod;
DEBUG ((DEBUG_INFO, "%a: Entry\n", __func__));
ZeroMem ((VOID *)&PciAddr, sizeof (PciAddr));
@@ -808,7 +764,6 @@ InternalInsertCxlRootBridge (
// the ACPI Table
//
DevIndex = 0;
- Status = EFI_SUCCESS;
for (Index = 0, RootBridge = RootBridgeHead; Index < RootBridgeCount; Index++, RootBridge++) {
if ((RootBridge->CxlCount == 0) || (RootBridge->CxlPortInfo.IsCxl2 == TRUE)) {
continue;
@@ -825,38 +780,42 @@ InternalInsertCxlRootBridge (
Status = AmlCodeGenDevice (NameSeg, PciNode, &DeviceNode); // RootBridge
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
Status = AmlCodeGenNameString ("_HID", "ACPI0016", DeviceNode, NULL);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
Status = AmlCodeGenNamePackage ("_CID", DeviceNode, &PackageNode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ ASSERT_EFI_ERROR (Status);
// Name (_CID, EISAID("PNP0A03"))
Status = AmlGetEisaIdFromString ("PNP0A03", &EisaId);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
- Status = AmlAddIntegerToNamedPackage (EisaId, PackageNode);
+ Status = AmlAddIntegerPackageEntry (EisaId, PackageNode);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
// Name (_CID, EISAID("PNP0A03"))
Status = AmlGetEisaIdFromString ("PNP0A08", &EisaId);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
- Status = AmlAddIntegerToNamedPackage (EisaId, PackageNode);
+ Status = AmlAddIntegerPackageEntry (EisaId, PackageNode);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -868,12 +827,14 @@ InternalInsertCxlRootBridge (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
// Name (_UID, )
Status = AmlCodeGenNameInteger ("_UID", DevIndex, DeviceNode, NULL);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -885,6 +846,7 @@ InternalInsertCxlRootBridge (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -896,6 +858,7 @@ InternalInsertCxlRootBridge (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
@@ -910,24 +873,27 @@ InternalInsertCxlRootBridge (
NULL
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
// Name (_CRS, )
Status = AmlCodeGenNameResourceTemplate ("_CRS", DeviceNode, &CrsNode);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
Status = InternalInsertRootBridgeResources (RootBridge, CrsNode);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
/// Create AML code for below method
/// Method (_OSC, 4, NotSerialized, 4) // _OSC: Operating System Capabilities
/// {
- /// \_SB.OSCI (Arg0, Arg1, Arg2, Arg3)
+ /// \_SB.OSCI (Arg0, Arg1, Arg2, Arg3, _ADR, _BBN)
/// }
Status = AmlCodeGenMethodRetNameString (
"_OSC",
@@ -939,31 +905,45 @@ InternalInsertCxlRootBridge (
&OscMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
// fill the AML_METHOD_PARAM structure to call the \\_SB.OSCI method
ZeroMem (MethodParam, sizeof (MethodParam));
MethodParam[0].Type = AmlMethodParamTypeArg;
- MethodParam[0].Data.Arg = 0x0; // Arg0 is the first argument to the method
+ MethodParam[0].Data.Arg = 0x0; // Arg0 is the first argument to the method
MethodParam[1].Type = AmlMethodParamTypeArg;
- MethodParam[1].Data.Arg = 0x1; // Arg1 is the second argument to the method
+ MethodParam[1].Data.Arg = 0x1; // Arg1 is the second argument to the method
MethodParam[2].Type = AmlMethodParamTypeArg;
- MethodParam[2].Data.Arg = 0x2; // Arg2 is the third argument to the method
+ MethodParam[2].Data.Arg = 0x2; // Arg2 is the third argument to the method
MethodParam[3].Type = AmlMethodParamTypeArg;
- MethodParam[3].Data.Arg = 0x3; // Arg3 is the fourth argument to the method
+ MethodParam[3].Data.Arg = 0x3; // Arg3 is the fourth argument to the method
+ // _ADR is the fifth argument to the method
+ MethodParam[4].Type = AmlMethodParamTypeInteger;
+ MethodParam[4].Data.Integer = (RootBridge->CxlPortInfo.EndPointBDF.Address.Device << 16) +
+ RootBridge->CxlPortInfo.EndPointBDF.Address.Function;
+ // _BBN is the sixth argument to the method
+ MethodParam[5].Type = AmlMethodParamTypeInteger;
+ MethodParam[5].Data.Integer = RootBridge->CxlPortInfo.EndPointBDF.Address.Bus;
// call the \\_SB.OSCI method
Status = AmlCodeGenInvokeMethod (
"\\_SB.OSCI",
- 4,
+ 6,
MethodParam,
OscMethod
);
if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
return Status;
}
}
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "%a: Failed with Status: %r, Not Critical return SUCCESS\n", __func__, Status));
+ Status = EFI_SUCCESS;
+ }
+
return Status;
}
@@ -1015,171 +995,77 @@ InternalInsertPciExpressBaseSize (
return EFI_SUCCESS;
}
-/**
- Locates an existing ACPI Table
-
- @param[in] Signature - The Acpi table signature
- @param[in] OemTableId - The Acpi table OEM Table ID. Ignored if 0
- @param[out] Table - Table if Found or NULL
-
- @retval EFI_SUCCESS, various EFI FAILUREs.
-**/
-EFI_STATUS
-EFIAPI
-GetExistingAcpiTable (
- IN UINT32 Signature,
- IN UINT64 OemTableId,
- OUT EFI_ACPI_SDT_HEADER **Table
- )
-{
- EFI_ACPI_SDT_HEADER *LocalTable;
- EFI_ACPI_TABLE_VERSION LocalVersion;
- EFI_STATUS Status;
- UINTN Index;
- UINTN LocalTableKey;
-
- Status = EFI_NOT_FOUND;
- *Table = NULL;
-
- for (Index = 0; ; Index++) {
- Status = mAcpiSdtProtocol->GetAcpiTable (Index, &LocalTable, &LocalVersion, &LocalTableKey);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (!(LocalTable->Signature == Signature)) {
- continue;
- }
-
- // Accept table if OemTableId is zero.
- if ((OemTableId == 0) ||
- (CompareMem (&LocalTable->OemTableId, &OemTableId, 8) == 0))
- {
- *Table = LocalTable;
- return EFI_SUCCESS;
- }
- }
-}
-
/**
Install PCI devices scoped under \_SB into DSDT
Determine all the PCI Root Bridges and PCI root ports and install resources
including needed _HID, _CID, _UID, _ADR, _CRS and _PRT Nodes.
+ @param[in] ImageHandle - Standard UEFI entry point Image Handle
+ @param[in] SystemTable - Standard UEFI entry point System Table
+
@retval EFI_SUCCESS, various EFI FAILUREs.
**/
EFI_STATUS
-GenerateAcpiSsdtPciTable (
- VOID
+EFIAPI
+InstallPciAcpi (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
AMD_PCI_ADDR PciAddr;
AMD_PCI_ROOT_BRIDGE_OBJECT_INSTANCE *RootBridge;
AMD_PCI_ROOT_BRIDGE_OBJECT_INSTANCE *RootBridgeHead;
- AML_METHOD_PARAM MethodParam[7];
AML_OBJECT_NODE_HANDLE AmdmNode;
AML_OBJECT_NODE_HANDLE CrsNode;
- AML_OBJECT_NODE_HANDLE CxldNode;
- AML_OBJECT_NODE_HANDLE DsmMethod;
- AML_OBJECT_NODE_HANDLE OscMethod;
AML_OBJECT_NODE_HANDLE PackageNode;
AML_OBJECT_NODE_HANDLE PciNode;
AML_OBJECT_NODE_HANDLE ScopeNode;
+ AML_OBJECT_NODE_HANDLE CxldNode;
+ AML_OBJECT_NODE_HANDLE DsmMethod;
AML_ROOT_NODE_HANDLE RootNode;
CHAR8 AslName[AML_NAME_SEG_SIZE + 1];
EFI_ACPI_DESCRIPTION_HEADER *Table;
- EFI_ACPI_SDT_HEADER *DsdtTable;
- EFI_ACPI_SDT_HEADER *ReplacementAcpiTable;
EFI_ACPI_SDT_HEADER *SdtTable;
- EFI_ACPI_TABLE_VERSION DsdtVersion;
EFI_STATUS Status;
EFI_STATUS Status1;
UINT32 EisaId;
- UINT32 ReplacementAcpiTableLength;
- UINTN DsdtTableKey;
UINTN GlobalInterruptBase;
- UINTN Index;
UINTN RbIndex;
UINTN RootBridgeCount;
- UINTN TableHandle;
-
- DEBUG ((DEBUG_INFO, "Generating ACPI SSDT PCI Table.\n"));
-
- // Get Acpi Table Protocol
- Status = gBS->LocateProtocol (
- &gEfiAcpiTableProtocolGuid,
- NULL,
- (VOID **)&mAcpiTableProtocol
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- // Get Acpi SDT Protocol
- Status = gBS->LocateProtocol (
- &gEfiAcpiSdtProtocolGuid,
- NULL,
- (VOID **)&mAcpiSdtProtocol
- );
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- return Status;
- }
-
- // Find the DSDT table and append to it
- for (Index = 0; ; Index++) {
- Status = mAcpiSdtProtocol->GetAcpiTable (
- Index,
- &DsdtTable,
- &DsdtVersion,
- &DsdtTableKey
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "ERROR: ACPI DSDT table not found. Status(%r)\n",
- Status
- ));
- return Status;
- }
+ AML_METHOD_PARAM MethodParam[7];
+ AML_OBJECT_NODE_HANDLE OscMethod;
+ AML_OBJECT_NODE_HANDLE CdsmMethod;
- if (DsdtTable->Signature == EFI_ACPI_6_5_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) {
- break;
- }
- }
+ DEBUG ((DEBUG_INFO, "%a: Entry\n", __func__));
Status = AmlCodeGenDefinitionBlock (
"SSDT",
"AMD ",
- "PCIE DEV",
+ "AmdTable",
0x00,
&RootNode
);
ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
ZeroMem ((VOID *)&PciAddr, sizeof (PciAddr));
+ mDriverHandle = ImageHandle;
GlobalInterruptBase = 0;
Status = InternalCollectSortedRootBridges (&RootBridgeHead, &RootBridgeCount);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = AmlCodeGenScope ("\\_SB_", RootNode, &ScopeNode); // START: Scope (\_SB)
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Create Root Bridge PCXX devices
- for (RbIndex = 0, RootBridge = RootBridgeHead;
- RbIndex < RootBridgeCount;
- RbIndex++, RootBridge++)
- {
+ for (RbIndex = 0, RootBridge = RootBridgeHead; RbIndex < RootBridgeCount; RbIndex++, RootBridge++) {
GlobalInterruptBase = RootBridge->GlobalInterruptStart;
// Make sure there is always PCI0 since this is a defacto standard. And
// therefore PCI0-PCIF and then PC10-PCFF
@@ -1191,69 +1077,80 @@ GenerateAcpiSsdtPciTable (
Status = AmlCodeGenDevice (AslName, ScopeNode, &PciNode); // RootBridge
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
if ((RootBridge->CxlCount > 0) && (RootBridge->CxlPortInfo.IsCxl2 == TRUE)) {
Status = AmlCodeGenNameString ("_HID", "ACPI0016", PciNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = AmlCodeGenNamePackage ("_CID", PciNode, &PackageNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
}
// Name (_CID, EISAID("PNP0A03"))
Status = AmlGetEisaIdFromString ("PNP0A03", &EisaId);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
- Status = AmlAddIntegerToNamedPackage (EisaId, PackageNode);
+ Status = AmlAddIntegerPackageEntry (EisaId, PackageNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_CID, EISAID("PNP0A03"))
Status = AmlGetEisaIdFromString ("PNP0A08", &EisaId);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
- Status = AmlAddIntegerToNamedPackage (EisaId, PackageNode);
+ Status = AmlAddIntegerPackageEntry (EisaId, PackageNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
} else {
// Name (_HID, EISAID("PNP0A08"))
Status = AmlGetEisaIdFromString ("PNP0A08", &EisaId);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = AmlCodeGenNameInteger ("_HID", EisaId, PciNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_CID, EISAID("PNP0A03"))
Status = AmlGetEisaIdFromString ("PNP0A03", &EisaId);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = AmlCodeGenNameInteger ("_CID", EisaId, PciNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
}
// Name (_UID, )
Status = AmlCodeGenNameInteger ("_UID", RootBridge->Uid, PciNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_BBN, )
@@ -1264,7 +1161,20 @@ GenerateAcpiSsdtPciTable (
NULL
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // Name (_ADR, 0); 0 address for root bridges
+ Status = AmlCodeGenNameInteger (
+ "_ADR",
+ 0,
+ PciNode,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_SEG, )
@@ -1275,7 +1185,8 @@ GenerateAcpiSsdtPciTable (
NULL
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_PXM, SocketId>)
@@ -1289,39 +1200,37 @@ GenerateAcpiSsdtPciTable (
NULL
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_CRS, )
Status = AmlCodeGenNameResourceTemplate ("_CRS", PciNode, &CrsNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = InternalInsertRootBridgeResources (RootBridge, CrsNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_PRT, )
Status = InternalInsertRootBridgeInterrupts (RootBridge, &GlobalInterruptBase, PciNode);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ ASSERT_EFI_ERROR (Status);
// Create Root Port PXXX devices
// Name (_ADR, )
// Name (_PRT, )
// Needs to be offset by previous IOAPICs interrupt count
- Status = InternalInsertRootPorts (RootBridge, RootBridge->GlobalInterruptStart, PciNode);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ InternalInsertRootPorts (RootBridge, RootBridge->GlobalInterruptStart, PciNode);
/// AML code to generate _OSC method
/// Method (_OSC, 4, NotSerialized, 4) // _OSC: Operating System Capabilities
/// {
- /// \_SB.OSCI (Arg0, Arg1, Arg2, Arg3)
+ /// \_SB.OSCI (Arg0, Arg1, Arg2, Arg3, _ADR, _BBN)
/// }
Status = AmlCodeGenMethodRetNameString (
"_OSC",
@@ -1333,11 +1242,57 @@ GenerateAcpiSsdtPciTable (
&OscMethod
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// fill the AML_METHOD_PARAM structure to call the \\_SB.OSCI method
ZeroMem (MethodParam, sizeof (MethodParam));
+ MethodParam[0].Type = AmlMethodParamTypeArg;
+ MethodParam[0].Data.Arg = 0x0; // Arg0 is the first argument to the method
+ MethodParam[1].Type = AmlMethodParamTypeArg;
+ MethodParam[1].Data.Arg = 0x1; // Arg1 is the second argument to the method
+ MethodParam[2].Type = AmlMethodParamTypeArg;
+ MethodParam[2].Data.Arg = 0x2; // Arg2 is the third argument to the method
+ MethodParam[3].Type = AmlMethodParamTypeArg;
+ MethodParam[3].Data.Arg = 0x3; // Arg3 is the fourth argument to the method
+ MethodParam[4].Type = AmlMethodParamTypeInteger;
+ MethodParam[4].Data.Integer = 0; // _ADR is the fifth argument to the method
+ MethodParam[5].Type = AmlMethodParamTypeInteger;
+ MethodParam[5].Data.Integer = RootBridge->Object->BaseBusNumber; // _BBN is the sixth argument to the method
+ // call the \\_SB.OSCI method
+ Status = AmlCodeGenInvokeMethod (
+ "\\_SB.OSCI",
+ 6,
+ MethodParam,
+ OscMethod
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ /// AML code to generate _DSM method
+ /// Method (_DSM, 4, Serialized) // _DSM device specific method
+ /// {
+ /// \_SB.CDSM (Arg0, Arg1, Arg2, Arg3)
+ /// }
+ Status = AmlCodeGenMethodRetNameString (
+ "_DSM",
+ NULL,
+ 4,
+ TRUE,
+ 0,
+ PciNode,
+ &CdsmMethod
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ // fill the AML_METHOD_PARAM structure to call the \\_SB.CDSM method
+ ZeroMem (MethodParam, sizeof (MethodParam));
MethodParam[0].Type = AmlMethodParamTypeArg;
MethodParam[0].Data.Arg = 0x0; // Arg0 is the first argument to the method
MethodParam[1].Type = AmlMethodParamTypeArg;
@@ -1348,16 +1303,20 @@ GenerateAcpiSsdtPciTable (
MethodParam[3].Data.Arg = 0x3; // Arg3 is the fourth argument to the method
// call the \\_SB.OSCI method
Status = AmlCodeGenInvokeMethod (
- "\\_SB.OSCI",
+ "\\_SB.CDSM",
4,
MethodParam,
- OscMethod
+ CdsmMethod
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
}
+ //
+ // Look for CEDT table, As Table Type 1 (CFMWS) is needed for the CXL DSM method
+ //
Status = GetExistingAcpiTable (
CXL_EARLY_DISCOVERY_TABLE_SIGNATURE,
0,
@@ -1367,13 +1326,15 @@ GenerateAcpiSsdtPciTable (
// CXL Root Device Specific Methods (_DSM)
Status = AmlCodeGenDevice ("CXLD", ScopeNode, &CxldNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// _DSM Functions that are associated with the CXL Root Device (HID="ACPI0017")
Status = AmlCodeGenNameString ("_HID", "ACPI0017", CxldNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Create a _DSM method
@@ -1387,7 +1348,8 @@ GenerateAcpiSsdtPciTable (
&DsmMethod
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// fill the AML_METHOD_PARAM structure to call the \\_SB.HDSM method
@@ -1411,7 +1373,8 @@ GenerateAcpiSsdtPciTable (
DsmMethod
);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
}
@@ -1419,42 +1382,45 @@ GenerateAcpiSsdtPciTable (
// CXL device are added as Root Bridges but are not part of
// the AMD PCI Resource Protocol
//
- Status = InternalInsertCxlRootBridge (RootBridgeHead, RootBridgeCount, ScopeNode);
- if (EFI_ERROR (Status)) {
- goto exit_handler;
- }
+ InternalInsertCxlRootBridge (RootBridgeHead, RootBridgeCount, ScopeNode);
// Add Pcie Base Size
Status = AmlCodeGenDevice ("AMDM", ScopeNode, &AmdmNode);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_HID, EISAID("PNP0C02"))
Status = AmlGetEisaIdFromString ("PNP0C02", &EisaId);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
Status = AmlCodeGenNameInteger ("_HID", EisaId, AmdmNode, NULL);
if (EFI_ERROR (Status)) {
- goto exit_handler;
+ ASSERT_EFI_ERROR (Status);
+ return Status;
}
// Name (_UID,