* [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
@ 2024-05-23 4:12 Chang, Abner via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
` (3 more replies)
0 siblings, 4 replies; 16+ messages in thread
From: Chang, Abner via groups.io @ 2024-05-23 4:12 UTC (permalink / raw)
To: devel
Cc: Paul Grimes, Abdul Lateef Attar, Igniculus Fu, Ken Yao, Eric Xing,
Duke Zhai
From: Abner Chang <abner.chang@amd.com>
BZ#: 4777
Initial commit of AMD cross platform/board generic
encapsulated software architecture. This provides
the basic definitions and protocols for the follow-up
AMD open board project.
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
.../AgesaModulePkg/AgesaCommonModulePkg.dec | 39 +
Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec | 18 +
.../AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec | 20 +
.../AMD/AgesaModulePkg/AgesaModuleDfPkg.dec | 25 +
.../AMD/AgesaModulePkg/AgesaModuleFchPkg.dec | 62 +
.../AMD/AgesaModulePkg/AgesaModuleMemPkg.dec | 26 +
.../AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec | 34 +
.../AMD/AgesaModulePkg/AgesaModulePspPkg.dec | 29 +
Platform/AMD/AgesaPkg/AgesaPkg.dec | 435 +++
Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec | 41 +
.../AgesaEdk2PlatformPkg.inc.dsc | 18 +
.../AgesaSp5RsModulePkg.inc.dsc | 48 +
.../CbsInstanceNull/CbsInstanceNull.inc.dsc | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.inc.dsc | 11 +
.../AgesaSp5RsModulePkg.dxe.inc.fdf | 11 +
.../AgesaSp5RsModulePkg.pei.inc.fdf | 9 +
.../CbsInstanceNull.dxe.inc.fdf | 7 +
.../CbsInstanceNull.pei.inc.fdf | 7 +
.../0x19/RS/External/CbsStones.dxe.inc.fdf | 8 +
.../0x19/RS/External/CbsStones.pei.inc.fdf | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf | 7 +
.../Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf | 10 +
.../Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf | 7 +
.../Library/AmdCalloutLib/AmdCalloutLib.inf | 29 +
.../AmdPspMboxLibV2/AmdPspMboxLibV2.inf | 30 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.inf | 27 +
.../AmdPspRomArmorLibNull.inf | 26 +
.../Library/ApcbLibV3/ApcbLibV3.inf | 37 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.inf | 32 +
.../BaseFabricTopologyRsLib.inf | 28 +
.../CcxTscTimerLib/BaseTscTimerLib.inf | 35 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.inf | 42 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.inf | 37 +
.../PciHostBridgeLib.inf | 42 +
.../DxeAmlGenerationLib/AmlGenerationLib.inf | 47 +
.../Library/FchBaseLib/FchBaseLib.inf | 26 +
.../FchBaseResetSystemLib.inf | 35 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.inf | 33 +
.../Library/NbioHandleLib/NbioHandleLib.inf | 24 +
.../Library/PcieConfigLib/PcieConfigLib.inf | 25 +
.../Library/SmnAccessLib/SmnAccessLib.inf | 33 +
.../Library/CommonDxe/NbioCommonDxeLib.inf | 29 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf | 45 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf | 33 +
.../OemAgesaCcxPlatformLibNull.inf | 27 +
.../PciExpressPciCfg2/PciExpressPciCfg2.inf | 61 +
.../PciExpressPciSegmentInfoLib.inf | 32 +
.../AmdPspFlashAccSpiNorLibSmm.inf | 45 +
.../PspRomArmorWhitelistLib.inf | 32 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.inf | 42 +
.../Dxe/PspPlatformDriver/PspPlatform.inf | 32 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.inf | 29 +
.../AmdAutoDynamicCommand.inf | 53 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.inf | 50 +
.../BasePlatformHookLibAmdFchUart.inf | 33 +
Platform/AMD/AgesaModulePkg/Include/AGESA.h | 158 +
Platform/AMD/AgesaModulePkg/Include/AMD.h | 91 +
.../Include/AmdEdk2/CpuRegisters.h | 15 +
.../AgesaModulePkg/Include/AmdPspDirectory.h | 61 +
.../AgesaModulePkg/Include/CpuRegistersDef.h | 156 +
.../Include/FchRegistersCommon.h | 85 +
.../AMD/AgesaModulePkg/Include/Filecode.h | 31 +
Platform/AMD/AgesaModulePkg/Include/Gnb.h | 14 +
Platform/AMD/AgesaModulePkg/Include/GnbDxio.h | 521 ++++
.../AgesaModulePkg/Include/GnbRegistersRS.h | 18 +
.../Include/GnbRegistersRS/IOHC.h | 22 +
.../Include/Guid/GnbPcieInfoHob.h | 31 +
.../Include/Library/AmdBaseLib.h | 16 +
.../Include/Library/AmdPspMboxLibV2.h | 43 +
.../Include/Library/BaseFabricTopologyLib.h | 22 +
.../Include/Library/FchBaseLib.h | 16 +
.../Include/Library/FchEspiCmdLib.h | 413 +++
.../Include/Library/GnbPcieConfigLib.h | 16 +
.../Include/Library/NbioCommonLibDxe.h | 37 +
.../Include/Library/NbioHandleLib.h | 62 +
.../Include/Library/PcieConfigLib.h | 283 ++
.../Include/Library/SmnAccessLib.h | 30 +
.../Protocol/AmdNbioPcieServicesProtocol.h | 47 +
.../Include/Protocol/AmdOemOobPprProtocol.h | 14 +
.../Include/Protocol/FabricNumaServices2.h | 155 +
.../Protocol/FabricTopologyServices2.h | 14 +
.../AMD/AgesaModulePkg/Include/SocLogicalId.h | 23 +
.../Library/DxeAmlGenerationLib/LocalAmlLib.h | 100 +
.../DxeAmlGenerationLib/LocalAmlObjects.h | 150 +
.../AMD/AgesaPkg/Include/AmdPcieComplex.h | 432 +++
Platform/AMD/AgesaPkg/Include/AmdSoc.h | 17 +
.../Include/FabricResourceManagerCmn.h | 42 +
.../AgesaPkg/Include/Guid/AmdMemoryInfoHob.h | 96 +
.../Include/Library/AmdPspBaseLibV2.h | 51 +
.../AgesaPkg/Include/Library/AmdPspFtpmLib.h | 83 +
.../Include/Library/AmdPspRomArmorLib.h | 231 ++
.../Include/Library/AmlGenerationLib.h | 2722 +++++++++++++++++
.../Library/PlatformPspRomArmorWhitelistLib.h | 25 +
.../AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h | 134 +
.../Include/Protocol/AmdCxlServicesProtocol.h | 183 ++
.../Protocol/AmdPciResourcesProtocol.h | 110 +
.../Include/Protocol/AmdPspFtpmProtocol.h | 187 ++
.../FabricResourceManagerServicesProtocol.h | 14 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h | 19 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h | 78 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h | 17 +
.../AMD/AmdCpmPkg/Include/AmdCpmFunction.h | 32 +
.../AmdCpmTableProtocol/AmdCpmTableProtocol.h | 39 +
.../Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c | 31 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.c | 12 +
.../AmdPspRomArmorLibNull.c | 79 +
.../Library/ApcbLibV3/ApcbLibV3.c | 12 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.c | 14 +
.../BaseFabricTopologyRsLib.c | 37 +
.../Library/CcxTscTimerLib/BaseTscTimerLib.c | 8 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.c | 35 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.c | 11 +
.../Library/CcxTscTimerLib/TscTimerLibShare.c | 103 +
.../DxeAmdPciHostBridgeLib/PciHostBridgeLib.c | 95 +
.../DxeAmlGenerationLib/AmlArgObjects.c | 154 +
.../DxeAmlGenerationLib/AmlAssistFunctions.c | 151 +
.../DxeAmlGenerationLib/AmlDataObjects.c | 640 ++++
.../AmlExpressionOpcodes.c | 1294 ++++++++
.../DxeAmlGenerationLib/AmlLocalObjects.c | 158 +
.../DxeAmlGenerationLib/AmlNameString.c | 576 ++++
.../DxeAmlGenerationLib/AmlNamedObject.c | 2138 +++++++++++++
.../AmlNamespaceModifierObjects.c | 360 +++
.../DxeAmlGenerationLib/AmlObjectsDebug.c | 144 +
.../DxeAmlGenerationLib/AmlPkgLength.c | 267 ++
.../AmlResourceDescriptor.c | 1989 ++++++++++++
.../DxeAmlGenerationLib/AmlStatementOpcodes.c | 515 ++++
.../Library/DxeAmlGenerationLib/AmlTable.c | 213 ++
.../DxeAmlGenerationLib/LocalAmlObjects.c | 364 +++
.../Library/FchBaseLib/FchStallLib.c | 13 +
.../FchBaseResetSystemLib.c | 90 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.c | 87 +
.../Library/NbioHandleLib/NbioHandleLib.c | 68 +
.../Library/PcieConfigLib/PcieConfigLib.c | 276 ++
.../PcieConfigLib/PcieInputParserLib.c | 117 +
.../Library/SmnAccessLib/SmnAccessLib.c | 10 +
.../Nbio/Library/CommonDxe/DxeLibFunctions.c | 42 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c | 23 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c | 29 +
.../OemAgesaCcxPlatformLibNull.c | 39 +
.../PciExpressPciCfg2/PciExpressPciCfg2.c | 33 +
.../PciSegmentInfoLib.c | 30 +
.../AmdPspFlashAccSpiNorLibSmm.c | 15 +
.../PspRomArmorWhitelistLib.c | 12 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.c | 36 +
.../Dxe/PspPlatformDriver/PspPlatformDriver.c | 20 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.c | 22 +
.../AmdAutoDynamicCommand.c | 44 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.c | 36 +
.../BasePlatformHookLibAmdFchUart.c | 29 +
.../FchSongshanDxe/FchSongshanI2C_I3C.asl | 9 +
.../AMD/AgesaPkg/Include/AmdUefiStackNasm.inc | 13 +
.../Library/RiscVOpensbiLib/opensbi | 2 +-
152 files changed, 19669 insertions(+), 1 deletion(-)
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
create mode 100644 Platform/AMD/AgesaPkg/AgesaPkg.dec
create mode 100755 Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
create mode 100755 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AGESA.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AMD.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Filecode.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Gnb.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
create mode 100755 Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdSoc.h
create mode 100644 Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
create mode 100644 Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
create mode 100644 Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
new file mode 100644
index 0000000000..d35a1f27b4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
@@ -0,0 +1,39 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCommonPkg
+ PACKAGE_GUID = 6CBE6566-0D3F-4E35-8358-9602354E9F09
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = {0x7788adf0, 0x9788, 0x4a3f, {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}}
+ gAgesaConfigDbPointerVariableGuid = {0x21229d24, 0xc71d, 0x4bc0, {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}}
+ gAmdMemoryInfoHobGuid = {0x1bce3d14, 0xa5fe, 0x4a0b, {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}}
+
+[Protocols]
+ ## Soc Protocols
+ gAmdSocLogicalIdProtocolGuid = {0x72f8e409, 0x0d2a, 0x4b91, {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}}
+ gAmdOemOobPprDxeProtocolGuid = {0x78031be3, 0x54a2, 0x4819, {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupportedV2|2|UINT8|0x00002002 # 2 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|1|UINT8|0x00002003 # 1 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2|8|UINT8|0x00002004 # 8 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannelV2|2|UINT8|0x00002005 # 2 by default
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UINT64|0x00027003
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
new file mode 100644
index 0000000000..1637068432
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
@@ -0,0 +1,18 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaEdk2Pkg
+ PACKAGE_GUID = E866104F-D458-41B1-AB26-FA5951618A8C
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/AmdEdk2
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
new file mode 100755
index 0000000000..b84fe5b738
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
@@ -0,0 +1,20 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCcxPkg
+ PACKAGE_GUID = df325429-029e-40f0-82db-0e69be7f6560
+ PACKAGE_VERSION = 0.1
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FALSE|BOOLEAN|0x000CC029
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
new file mode 100755
index 0000000000..57db15e663
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
@@ -0,0 +1,25 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaDfPkg
+ PACKAGE_GUID = 81e51ee3-c347-4563-92fe-790ba953bf0f
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gAmdTotalNumberOfRootBridgesGuid = {0xfb5703f5, 0xf8a7, 0xf401, {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}}
+ gAmdResourceSizeForEachRbGuid = {0x542b8f2f, 0xbd52, 0x4233, {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}}
+
+[Protocols]
+ gAmdFabricNumaServices2ProtocolGuid = {0xa8ff2e64, 0xf319, 0x4af1, {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}}
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
new file mode 100644
index 0000000000..521957e809
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
@@ -0,0 +1,62 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 1.5
+ PACKAGE_NAME = AgesaFchPkg
+ PACKAGE_GUID = e47c8ed9-3000-4e6e-b1c6-875b365b3849
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = { 0x7788adf0, 0x9788, 0x4a3f, { 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } }
+
+[Protocols]
+ gFchInitDonePolicyProtocolGuid = { 0xc63c0c73, 0xf612, 0x4c02, { 0x84, 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } }
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|0x0003F001
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0x0003F002
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0x0003F003
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x0003F00D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BOOLEAN|0x0003F021
+
+ ### @brief This item allows the customer to change OC signal polarity to be active low. This is universal and applies to all OC pins.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)At present, this control applies to Family17h Model 00h-2Fh.
+ ### @li TRUE - OC pin is low when OC occurs.
+ ### @li FALSE - OC pin is high when OC occurs.
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciOcPolarityCfgLow|FALSE|BOOLEAN|0x0003F309
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFFFFFFFFFFFFF|UINT64|0x0003F340
+ #Die 0
+ #[7:0] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ #[23:0] MTS -- 6 USB 2.0 ports on XHCI controller 0
+ #Die 1
+ #[39:32] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[47:40] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb31OcPinSelect|0xFFFFFFFF|UINT32|0x0003F341
+ #Die 0
+ #[7:0] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ #[15:0] MTS -- 4 USB 3.1 ports on XHCI controller 0
+ #Die 1
+ #[23:16] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[31:24] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLpcEnable|TRUE|BOOLEAN|0x0003F400
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdUsbRSOemConfigurationTable|{0x0}|VOID*|0x0003F40A
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciSsid|0x00000000|UINT32|0x0003FF07
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x00000000|UINT32|0x0003FF81
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
new file mode 100644
index 0000000000..721d3ea73b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
@@ -0,0 +1,26 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaMemPkg
+ PACKAGE_GUID = 445f7303-3171-428c-ad0b-32df4474a7ad
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries|64|UINT32|0x00029001
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
new file mode 100755
index 0000000000..0501774c9b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
@@ -0,0 +1,34 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaNbioPkg
+ PACKAGE_GUID = 1486f0fe-39ee-4856-a39f-222ff2404f26
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Protocols]
+ gAmdNbioPcieServicesProtocolGuid = {0x756db75c, 0xbb9d, 0x4289, {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE|BOOLEAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI phase
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0x00021103 #///< Base NBIO IOAPIC ID. ID assigned start from this value
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x0004101D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x0004101E
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|0x0|UINT32|0x00041200
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
new file mode 100644
index 0000000000..41cf320c76
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
@@ -0,0 +1,29 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPspPkg
+ PACKAGE_GUID = 5c48f900-a98c-431f-8be5-19c09c65bb05
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gApSyncFlagNvVariableGuid = { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb, 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } }
+ gAmdPspApobHobGuid = { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13, 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } }
+
+[Protocols]
+ gPspFlashAccSmmCommReadyProtocolGuid = { 0x9f373486, 0xda76, 0x4c9f, { 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } }
+ gAmdPspFtpmProtocolGuid = { 0xac234e04, 0xb036, 0x476c, { 0x91, 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } }
+
+[Ppis]
+ gAmdPspFtpmPpiGuid = { 0x91774185, 0xf72d, 0x467e, { 0x93, 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } }
+ gAmdPspFtpmFactoryResetPpiGuid = { 0x9c98130a, 0x8921, 0x45eb, { 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } }
diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/AgesaPkg.dec
new file mode 100644
index 0000000000..9377c64cc3
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
@@ -0,0 +1,435 @@
+## @file
+# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
+# file.
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPkg
+ PACKAGE_GUID = DABFEFC6-5A79-444b-862A-1F6FE9F561FE
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaPkgTokenSpaceGuid = { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0, 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } }
+
+[Protocols]
+ gAmdNbioCxlServicesProtocolGuid = {0x125CCFCE, 0x34AF, 0x422C, {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}}
+ gAmdPciResourceProtocolGuid = {0x663d4897, 0xed94, 0x4f0f, {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}}
+ gAmdCapsuleSmmHookProtocolGuid = {0x4fc43bbe, 0x1433, 0x4951, {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}}
+ gAmdFspSetupTableInitDoneGuid = {0xef5394c6, 0x566d, 0x440f, {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}}
+
+[Ppis]
+ gAmdMemoryInfoHobPpiGuid = {0xba16e587, 0x1d66, 0x41b7, {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
+ gCapsuleUpdateDetectedPpiGuid = {0x745dfc73, 0xc401, 0x4ced, {0x8d, 0x3b, 0x1a, 0x82, 0xf3, 0xda, 0xdc, 0xf8}}
+
+[PcdsFixedAtBuild]
+
+ ### @brief Enable EDK-II Protocols
+ ### @details This item enables support for EDKII implementation of ACPI Protocols when set to TRUE
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCompliantEdkIIAcpiSdtProtocol|TRUE|BOOLEAN|0x00020006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize |0x1000|UINT32|0x00020007
+
+ ### @brief assign non volatile storage base address
+ ### @details This assigns the base address to map to flash deivce.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF000000|UINT32|0x00020017
+
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH.h"
+#----------------------------------------------------------------------------
+
+ ### @name General FCH Controls
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1 register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0400)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1EvtBlkAddr|0x400|UINT16|0x0002F004
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1Cnt register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0404)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1CntBlkAddr|0x404|UINT16|0x0002F005
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM Timer as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0408)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPmTmrBlkAddr|0x408|UINT16|0x0002F006
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI CPU Control block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0410)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgCpuControlBlkAddr|0x410|UINT16|0x0002F007
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI GPE0 register block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0420)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|UINT16|0x0002F008
+
+ ### @brief This item defines the SMI command value sent by the host BIOS during the S3 resume sequence, to re-initialize the
+ ### FCH registers. This must be issued before the platform driver restore function is started.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD3)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemBeforePciRestoreSwSmi|0xD3|UINT8|0x0002F010
+
+ ### @brief This item defines the SMI command used by the host BIOS to signal the FCH driver that the platform driver has
+ ### completed its restore function. This allows the FCH driver to perform some final FCH settings.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD4)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|UINT8|0x0002F011
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to activate ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemEnableAcpiSwSmi|0xA0|UINT8|0x0002F012
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to turn off ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA1)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemDisableAcpiSwSmi|0xA1|UINT8|0x0002F013
+
+ ### @brief SMI command used for releasing the SPI controller lock mode. All devices on the SPI bus will be writable.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAA)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiUnlockSwSmi|0xAA|UINT8|0x0002F014
+
+ ### @brief SMI command for setting the lock mode in the SPI controller. This will effectively provide a write protection to the
+ ### SPI Flash ROM; however, write access to secondary SPI devices will also be blocked.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAB)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x0002F015
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH-IRQ.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart0Irq|0x03|UINT8|0x0002F01A
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart1Irq|0x0E|UINT8|0x0002F01B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart2Irq|0x05|UINT8|0x0002F01C
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart3Irq|0x0F|UINT8|0x0002F01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart4Irq|0x10|UINT8|0x0002F01E
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c0Irq|0x0A|UINT8|0x0002F01F
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c1Irq|0x0B|UINT8|0x0002F020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c2Irq|0x04|UINT8|0x0002F021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c3Irq|0x06|UINT8|0x0002F022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c4Irq|0x16|UINT8|0x0002F023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c5Irq|0x17|UINT8|0x0002F024
+#- DF Fixed PCDs
+#-
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+ #Fabric
+
+ ### @name General DF Controls
+
+ ### @brief This item informs the SMBios generation code as to how many physical processor sockets exist in the system and
+ ### therefore how many Type 4 SMBios records to produce.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x01)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdNumberOfPhysicalSocket|1|UINT8|0x000CC103
+#----------------------------------------------------------------------------
+#- CCX Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-MTRR.h"
+#----------------------------------------------------------------------------
+
+
+ ### @brief The base address of temporary page table for accessing PCIE MMIO base address above 4G in PEI phase.
+ ### @brief Permitted Choices: 0x0 - 0xFFFFFFFF (Type: Value)(Default: 0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPeiTempPageTableBaseAddress|0|UINT32|0x000CC11B
+
+#----------------------------------------------------------------------------
+#- CCX ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-ACPI.h"
+#----------------------------------------------------------------------------
+ #ACPI
+ # Cpu SSDT
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName0|0x43|UINT8|0x000AC001
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName1|0x30|UINT8|0x000AC002
+ ### @brief This element specifies whether the ACPI _PSS objects are defined in the system bus or processor scope.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li TRUE - The objects will be under the \_SB scope.
+ ### @li FALSE - The objects will be under the \_PR scope
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeInSb|FALSE|BOOLEAN|0x000AC003
+
+ ### @brief Set the OEM ID field in ACPI table outputs to this string. The string must conform to the ACPI rules for the OEM ID field.
+ ### @brief Permitted Choices: (Type: Value)(Default: "AMD")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|VOID*|0x000AC004
+
+#----------------------------------------------------------------------------
+#- CCX SMBIOS Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-SMBIOS.h"
+#----------------------------------------------------------------------------
+
+ ### @name CCX SMBIOS Controls
+
+ ### @brief When creating the SMBios table entry, use this as the label for the processor socket. This should match the
+ ### silkscreen label on the motherboard.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|"Unknown"|VOID*|0x00001001
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'serial number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket0|"Unknown"|VOID*|0x00001002
+
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Asset Tag' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket0|"Unknown"|VOID*|0x00001003
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Part Number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unknown"|VOID*|0x00001004
+
+ ### @brief SMBios socket 1 Label.
+ ### @details When creating the SMBios table entry, use this as the label for the
+ ### processor socket. This should match the silkscreen label on the motherboard.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|"Unknown"|VOID*|0x00001005
+
+ ### @brief SMBIOS socket 1 Serial Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'serial number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket1|"Unknown"|VOID*|0x00001006
+
+ ### @brief SMBios socket 1 Asset Tag.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Asset Tag' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket1|"Unknown"|VOID*|0x00001007
+
+ ### @brief Socket 1 Part Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Part Number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket1|"Unknown"|VOID*|0x00001008
+
+#----------------------------------------------------------------------------
+#- ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-ACPI.h"
+#----------------------------------------------------------------------------
+
+ ### @name General ACPI Controls
+
+ ### @brief PCD supporting maximum capacity for Type 16 table
+ ### @details This PCD represents maximum memory capacity in KB
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT16MaximumCapacity|0x04000000|UINT32|0x00001009 # 4G - 0x00400000
+ # 8G - 0x00800000
+ # 16G - 0x01000000
+ # 32G - 0x02000000
+ # 64G - 0x04000000
+ # 128G - 0x08000000
+ # 256G - 0x10000000
+ # 512G - 0x20000000
+[PcdsDynamic]
+#----------------------------------------------------------------------------
+# System level Dynamic PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCStateIoBaseAddress|0x413|UINT16|0x000CC002
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x000CC00B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x000CC200
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerInSb|FALSE|BOOLEAN|0x000CC50B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerName|"PLTF"|VOID*|0x000CC50C
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEAN|0x000CC601
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16|0x000CC900
+#----------------------------------------------------------------------------
+#- DF Dynamic PCDs
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+
+ ### @cond (FF3||RN||BA||ZP||RMB||RPL||RS||SSP||MI3||BRH)
+ ### @brief Specifies the top address to be used for MMIO space allocations. No MMIO space will be used above this limit. Some devices have limits on the address space they
+ ### are able to access. For example a device with a 40-bit address limitation can not use MMIO space above 1TeraByte (1T). By setting this PCD to 0x10000000000 (1T), MMIO
+ ### space would not be allocated above 1T. The default is to use all of the space above the end of physical memory.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMmioAbove4GLimit|0xFFFFFFFFFFFFFFFF|UINT64|0x0003FFC2
+ ### @endcond
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFabricResourceDefaultSizePtr|0|UINT64|0x00DF0000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UINT16|0x0003FFC0
+
+ ### I2C-0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UINT32|0x000FC000
+ ### I2C-1
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UINT32|0x000FC001
+ ### I2C-2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UINT32|0x000FC002
+ ### I2C-3
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UINT32|0x000FC003
+ ### I2C-4
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UINT32|0x000FC004
+ ### I2C-5
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UINT32|0x000FC005
+ ### @} end of I2C hold times
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-UART.h"
+#----------------------------------------------------------------------------
+ ### @name UART Legacy IO Assignments
+ ### @{
+ ### @brief These controls allow the platform to specify the legacy IO ranges that are to be used by the UART ports in the processor. Permitted Choices: (Type: value)(Default: Disabled)
+ ### @li 0 - Disabled
+ ### @li 1 - IO range 0x02E8 - 0x02EF
+ ### @li 2 - IO range 0x02F8 - 0x02FF
+ ### @li 3 - IO range 0x03E8 - 0x03EF
+ ### @li 4 - IO range 0x03F8 - 0x03FF
+
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart0LegacyEnable|0x00|UINT8|0x000FC010
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart1LegacyEnable|0x00|UINT8|0x000FC011
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart2LegacyEnable|0x00|UINT8|0x000FC012
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart3LegacyEnable|0x00|UINT8|0x000FC013
+ ### @} end UART Legacy IO assignments
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-USB.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci0Enable|TRUE|BOOLEAN|0x000FC020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci1Enable|TRUE|BOOLEAN|0x000FC021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci2Enable|TRUE|BOOLEAN|0x000FC022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci3Enable|TRUE|BOOLEAN|0x000FC023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhciECCDedErrRptEn|FALSE|BOOLEAN|0x000FC024
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC030
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN|0x000FC039
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x000A6024
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO-BMC.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN|0x0004F004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x0004F005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkDie|0xFF|UINT8|0x0004F006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkLaneNum|0|UINT8|0x0004F03E
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgIommuSupport|TRUE|BOOLEAN|0x0004F027
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdIvInfoDmaReMap|FALSE|BOOLEAN|0x0004F028
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrVddfull_Scale_Current|0x00|UINT32|0x0004F0A0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Current|0x00|UINT32|0x0004F0A2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0x0004F210
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT32|0x0004F211
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT8|0x0004F362
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|UINT8|0x0004F363
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs DYNAMIC
+
+ ### @brief This feature selects the APCB recovery support on x86 side. If or when an instance of a writable APCB is determined to be invalid, the PSP driver will
+ ### attempt a 'recovery' by copying the recovery instance of the APCB (default values as indicated in the APCB descriptor files). Upon boot up, the ABL reads CMOS
+ ### bytes 06/07 at index/data port of 0x72/0x73. If the CMOS flag reads anything else other than 0xA55A or 0x5555, the system boots in APCB recovery mode, in which
+ ### ABL consumes the recovery instances of APCB. Otherwise it boots in normal/non-recovery mode.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE)
+ ### @brief This feature is affected by the platform CMOS power design. Please see Platform CMOS power .
+ ### @li TRUE - the AGESA PSP driver restores the APCB instances from the recovery instance, writes 0xA55A to the CMOS location and triggers a reset . The next time
+ ### the system powers up, ABL runs in normal/non-recovery mode.
+ ### @li FALSE - the AGESA PSP driver writes 0x5555 to the CMOS location without restoring the APCB instances or triggering a reset. In this mode the additional reset
+ ### is avoided at the potential risk of the writeable APCB instance being left corrupted forever.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|BOOLEAN|0x95940008
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE|BOOLEAN|0x95940018
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x00030004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BOOLEAN|0x00030005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BOOLEAN|0x00030006
+[PcdsDynamicEx]
+
+[PcdsFixedAtBuild, PcdsDynamic]
+#----------------------------------------------------------------------------
+#- System control PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ ### @brief Switch for Debug Print function
+ ### @details Switch for Debug Print function to enable or not.
+ ### @li TRUE: Enable IdsDebugPrint output
+ ### @li FALSE: Disable IdsDebugPrint output
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEnable|FALSE|BOOLEAN|0x00020004
+ ### @brief Specify the filter for IdsDebugPrint
+ ### @details When the filter values are matched, the AmdIdsDebugPrint can start to print debug message.
+ ### Refer Library/IdsLib.h for details, and the Master token is PcdAmdIdsDebugPrintEnable.
+ ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ ### @li 0x100401008A300408: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintFilter|0x100401030A300408|UINT64|0x00020005
+ ### @brief Switch for Serial port support of AGESA debug print
+ ### @details Switch for Serial port support of AGESA debug print, NOTE, AGESA will not init the serial port,
+ ### serial port should be initialized before call AGESA debug print.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortEnable|FALSE|BOOLEAN|0x00020009
+ ### @brief The serial port used for debug output can be either 2-wire (Rx/Tx) or 4-wire (adding DSR/CTS). Waiting for CTS on a
+ ### 2-wire port would cause a hang. This control is added to check the cable connection.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li FALSE - Presume a 2-wire port and do not wait for CTS.
+ ### @li TRUE - Wait for both DSR and CTS to be set. DSR is set if a cable is connected. CTS is set if it is ok to transmit data.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCableConnection|FALSE|BOOLEAN|0x0002000A
+
+ ### @brief Selection of UART and UART Legacy IO Serial port for AGESA debug print
+ ### @details Selection of UART and UART Legacy IO Serial port for AGESA debug print and invisible in ACPI name space.
+ ### @li Bit[0]: Select UART0 for AGESA debug print
+ ### @li Bit[1]: Select UART1 for AGESA debug print
+ ### @li Bit[2]: Select UART2 for AGESA debug print
+ ### @li Bit[3]: Select UART3 for AGESA debug print
+ ### @li Bit[4]: Select UART4 for AGESA debug print
+ ### @li Bit[8]: Select UART0 Legacy IO for AGESA debug print
+ ### @li Bit[9]: Select UART1 Legacy IO for AGESA debug print
+ ### @li Bit[10]: Select UART2 Legacy IO for AGESA debug print
+ ### @li Bit[11]: Select UART3 Legacy IO for AGESA debug print
+ ### @li Bit[15]: Set debug print serial port to invisible in ACPI name space at OS runtime
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortSelect|0x0000|UINT16|0x0002718A
+
+ ### @brief Specify the IO port for serial out
+ ### @details ESPI or LPC COM1: 0x3F8, COM2: 0x2F8, COM3: 0x3E8, COM4: 0x2E8,
+ ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000, UART3: 0xFEDCF000, UART4: 0xFEDD1000.
+ ### @li If it's IO port: it must < 0x10000
+ ### @li If it's Memory: it must >= 0x10000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UINT64|0x0002000B
+
+ ### @brief Debug Print Emulation Auto Detect
+ ### @details Auto detect emulation platform to instead of PcdAmdIdsDebugPrintRedirectIOEnable and
+ ### PcdAmdIdsDebugPrintSerialPortEnable.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetect|FALSE|BOOLEAN|0x00020016
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgPlatformPPT|0|UINT32|0x0004F111
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs
+
+ ### @brief Rom Armor selection
+ ### @details Rom Armor selection
+ ### @li 0: Rom Armor is disabled
+ ### @li 1: Rom Armor 1 is enabled (VMR/MTS/CPK)
+ ### @li 2: Rom Armor 2 is enabled (RN/CZN)
+ ### @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
+ ### @li 0x1: PSP fTPM
+ ### @li 0x2: HSP fTPM
+ ### @li 0xFF: no TPM
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8|0x95940024
+
+ ### @cond !BRH
+ ### @brief TPM SMx algorithm flag
+ ### @details TPM SMx algorithm flag, SBIOS needs to set the value in PEI phase.
+ ### @li 0: SM2, SM3 or SM4 crypto algorithms not supported
+ ### @li 1: SM2, SM3 or SM4 crypto algorithms supported
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmAlgSmx|0|UINT8|0x95940025
+ ### @endcond
diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
new file mode 100755
index 0000000000..c8c474637f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
@@ -0,0 +1,41 @@
+## @file
+# AMD Common Platform Module (CPM) Module Package DEC.
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = CpmPkg
+ PACKAGE_GUID = ABE128BA-1061-4A53-A1B8-D07329AA7A67
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+ Library
+
+[Guids]
+ gAmdCpmPkgTokenSpaceGuid = {0x916e0ddd, 0x2bd2, 0x4704, {0x93, 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}}
+ gShellActHiiGuid = {0x340EBE97, 0x3C1C, 0x4272, {0x9C, 0xCE, 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}}
+ gAmdPbsSystemConfigurationGuid = {0xa339d746, 0xf678, 0x49b3, {0x9f, 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}}
+
+[Protocols]
+ gAmdCpmTableProtocolGuid = { 0x3724cf01, 0x00c2, 0x9762, {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }}
+ gAmdCpmAllPciIoProtocolsInstalledProtocolGuid = { 0x676D7012, 0x139B, 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }}
+
+[Ppis]
+ gAmdCpmTablePpiGuid = { 0xd71cf893, 0xa8b5, 0x49d3, { 0xa2, 0x1b, 0x31, 0xe2, 0xf5, 0xc4, 0xa7, 0x47 } }
+
+[PcdsFixedAtBuild]
+ gAmdCpmPkgTokenSpaceGuid.PcdFchUartPort|2|UINT8|0x00000052
+
+ #ACPI
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiHestTableHeaderOemTableId|"AMD HEST"|VOID*|0x000AC001
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiBertTableHeaderOemTableId|"AMD BERT"|VOID*|0x000AC002
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiEinjTableHeaderOemTableId|"AMD EINJ"|VOID*|0x000AC003
+
+ gAmdCpmPkgTokenSpaceGuid.UsePciXAslName|FALSE|BOOLEAN|0x12000003
+ gAmdCpmPkgTokenSpaceGuid.AcpiRestoreSwSmi|0xE3|UINT8|0x00000040
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
new file mode 100644
index 0000000000..37b8d15cb1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
@@ -0,0 +1,18 @@
+## @file
+#
+# 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[LibraryClasses]
+ NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+
+ ## Gnb Lib
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
new file mode 100644
index 0000000000..e7e05fd2d8
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
@@ -0,0 +1,48 @@
+## @file
+# The AGESA DSC file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[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
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+
+ ## DF Lib
+ BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
+
+ ## Gnb Lib
+ 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
+
+ ## Fch Lib
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+
+[Components.IA32]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+
+[Components.X64]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
new file mode 100644
index 0000000000..1f1e04c414
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..2916fecb26
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
@@ -0,0 +1,11 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEFINE AGESA_PKG_PATH = AgesaModulePkg
+ DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
new file mode 100644
index 0000000000..9303d1fac4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
@@ -0,0 +1,11 @@
+## @file
+# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+## APCB V3 Dxe Drivers
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
new file mode 100644
index 0000000000..0ef5a2a806
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
@@ -0,0 +1,9 @@
+## @file
+# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..b790e4ead5
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Platform Package Flash Description File
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100755
index 0000000000..8d3357bf56
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdCalloutLib
+ FILE_GUID = A8FEA621-B381-4c06-9E9D-0897EF78BD78
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdCalloutLib
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
new file mode 100644
index 0000000000..1594a99265
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
@@ -0,0 +1,30 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
new file mode 100644
index 0000000000..c685a26604
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLib
+ FILE_GUID = 55871F80-4658-6EF3-A8AC-15B34FF8C2CE
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLib
+
+[Sources.common]
+ AmdPspRomArmorLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
new file mode 100644
index 0000000000..a3906dc13e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLibNull
+ FILE_GUID = 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLibNull
+
+[Sources.common]
+ AmdPspRomArmorLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
new file mode 100644
index 0000000000..09d5bd38ac
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
@@ -0,0 +1,37 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3
+ 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
+
+[Sources.common]
+ ApcbLibV3.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSmmReadyToLockProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
new file mode 100644
index 0000000000..c031d00d79
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3Pei
+ FILE_GUID = EEA4E007-E408-4daa-82BD-4C52E7058753
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ApcbLibV3Pei|PEIM
+
+[Sources.common]
+ ApcbLibV3Pei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseMemoryLib
+ PeiServicesLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
new file mode 100644
index 0000000000..38a72e26b7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# For EDKII use Only
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseFabricTopologyRsLib
+ FILE_GUID = D0A070DD-630A-43F8-9D76-EAAABDDE5FB9
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseFabricTopologyLib
+ CONSTRUCTOR = BaseFabricTopologyLibConstructor
+
+[Sources]
+ BaseFabricTopologyRsLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+
+[LibraryClasses]
+ BaseLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
new file mode 100644
index 0000000000..d15d8169fe
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
@@ -0,0 +1,35 @@
+## @file
+# Base Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseTscTimerLib
+ FILE_GUID = D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ BaseTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
new file mode 100644
index 0000000000..1e52768a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Dxe Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTscTimerLib
+ FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeTscTimerLibConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ DxeTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ PcdLib
+ BaseLib
+ UefiLib
+ DebugLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
new file mode 100644
index 0000000000..b1eaefd282
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Pei Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTscTimerLib
+ FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|PEIM PEI_CORE
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ PeiTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+ HobLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644
index 0000000000..f60f97905a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Library instance of PciHostBridgeLib library class for coreboot.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciHostBridgeLib
+ FILE_GUID = 74967FD7-A9A4-4B16-8B41-B26BC3230D0A
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciHostBridgeLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ PciHostBridgeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ PciHostBridgeLib
+ DevicePathLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
new file mode 100644
index 0000000000..2a72fa8117
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -0,0 +1,47 @@
+## @file
+#
+# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseLib/FchBaseLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
new file mode 100644
index 0000000000..e63a70e849
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseResetSystemLib/FchBaseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
new file mode 100644
index 0000000000..e422cb69a4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
@@ -0,0 +1,35 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = BaseResetSystemLib
+ FILE_GUID = e669c365-2df2-4540-a343-afec4e85b198
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseResetSystemLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ FchBaseResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PrintLib
+ IoLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
new file mode 100644
index 0000000000..d7f49c40de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
new file mode 100755
index 0000000000..f32bbc9ff2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
@@ -0,0 +1,24 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioHandleLib
+ FILE_GUID = DC4639D3-DB75-486B-AC38-C84AA49601E3
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioHandleLib
+
+[Sources]
+ NbioHandleLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
new file mode 100755
index 0000000000..0d6ba605f5
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PcieConfigLib
+ FILE_GUID = C1205AD2-FE67-4502-A0A7-FB1704A3F9AE
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PcieConfigLib
+
+[Sources]
+ PcieConfigLib.c
+ PcieInputParserLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
new file mode 100644
index 0000000000..ae1dd6cd83
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmnAccessLib
+ FILE_GUID = 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmnAccessLib
+
+[Sources]
+ SmnAccessLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ PrintLib
+ BaseLib
+ DebugPrintErrorLevelLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
new file mode 100644
index 0000000000..da7f5c185d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioCommonDxeLib
+ FILE_GUID = 1BF93335-5D55-46D9-99D9-5D962F039829
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioCommonDxeLib
+
+[Sources]
+ DxeLibFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ BaseLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
new file mode 100644
index 0000000000..54c3514020
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbDxeV3
+ FILE_GUID = 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3DxeDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ DxeServicesTableLib
+ MemoryAllocationLib
+ ApcbLibV3
+
+[Sources]
+ ApcbV3Dxe.c
+
+[Protocols]
+ gEfiDxeSmmReadyToLockProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
new file mode 100644
index 0000000000..7f90aa6ea0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbPeiV3
+ FILE_GUID = E1B8CF4A-FE7B-4676-B4F7-50C7228282A4
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3PeiDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PeimEntryPoint
+ ApcbLibV3Pei
+
+[sources]
+ ApcbV3Pei.c
+
+[Depex]
+ TRUE
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
new file mode 100755
index 0000000000..0f115c362e
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = OemAgesaCcxPlatformLibNull
+ FILE_GUID = B1F58B07-0146-4804-B701-A56CB5716529
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = OemAgesaCcxPlatformLib
+
+[Sources.common]
+ OemAgesaCcxPlatformLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
new file mode 100644
index 0000000000..ba551e5c14
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
@@ -0,0 +1,61 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciCfg2
+ FILE_GUID = 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PeimInitializePciCfg
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
+#
+
+[Sources]
+ PciExpressPciCfg2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+
+[LibraryClasses]
+ PeimEntryPoint
+ BaseLib
+ PcdLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ HobLib
+ IoLib
+
+[Ppis]
+ gEfiPciCfg2PpiGuid ## PRODUCES
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
+[Pcd.IA32,Pcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES
+
+[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
new file mode 100644
index 0000000000..e712a80886
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciSegmentInfoLib
+ FILE_GUID = FA8B1082-88DF-4744-85A3-7F87A9EBF8DC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciSegmentInfoLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ PciSegmentInfoLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
new file mode 100644
index 0000000000..f4b9d0d789
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspFlashAccLibSmm
+ FILE_GUID = 3BBDC3A5-A0E2-4E8A-8240-9E594920F040
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspFlashAccLib | DXE_SMM_DRIVER
+
+[Sources.common]
+ AmdPspFlashAccSpiNorLibSmm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ AmdPspBaseLibV2
+ BaseLib
+ DebugLib
+ SmmServicesTableLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSpiSmmNorFlashProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize ## CONSUMES
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ## CONSUMES
+
+[Depex]
+ gEfiSmmBase2ProtocolGuid AND
+ gEfiSpiSmmNorFlashProtocolGuid
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
new file mode 100644
index 0000000000..57bb0d9e25
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = PspRomArmorWhitelistLib
+ FILE_GUID = B6F8507A-C96B-4036-A8C0-26BAD6AC5F34
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformPspRomArmorWhitelistLib
+
+[Sources]
+ PspRomArmorWhitelistLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ MemoryAllocationLib
+ PcdLib
+ DebugLib
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
new file mode 100644
index 0000000000..64fd2913ad
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
@@ -0,0 +1,42 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+
+
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
new file mode 100644
index 0000000000..f4d7638c1a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
new file mode 100644
index 0000000000..973ace8632
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
new file mode 100644
index 0000000000..2d9dbeb715
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
@@ -0,0 +1,53 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+ UNLOAD_IMAGE = ActLibraryUnregisterActCommand
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ UefiLib
+ FileHandleLib
+ HiiLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+
+[Guids]
+ gShellActHiiGuid ## SOMETIMES_CONSUMES ## HII
+ gAgesaConfigDbPointerVariableGuid
+
+[Protocols]
+ gEfiShellDynamicCommandProtocolGuid
+ gEfiHiiPackageListProtocolGuid
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[DEPEX]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
new file mode 100644
index 0000000000..98c8755ab8
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
@@ -0,0 +1,50 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoToolApp.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ FileHandleLib
+ HiiLib
+ MemoryAllocationLib
+ UefiApplicationEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+ UefiLib
+ UefiRuntimeServicesTableLib
+
+[Protocols]
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[Guids]
+
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
new file mode 100644
index 0000000000..9c3c0dd0a9
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BasePlatformHookLibAmdFchUart
+ FILE_GUID = BF2F3F3F-4BE6-4B97-850D-D5D4941D391C
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformHookLib
+
+[Sources]
+ BasePlatformHookLibAmdFchUart.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ IoLib
+ PlatformHookLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
new file mode 100644
index 0000000000..3ec03aafd3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AGESA_H_
+#define AGESA_H_
+
+#include "AMD.h"
+#include "SocLogicalId.h"
+
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+#define DESCRIPTOR_INITIALIZE_LIST 0x20000000ull
+
+/// PCIe link initialization
+typedef enum {
+ EndpointDetect = 0, ///< Detect endpoint presence
+ EndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} PCIE_ENDPOINT_STATUS;
+
+/// PCIe port misc extended controls
+typedef struct {
+ IN UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ IN UINT8 LinkSafeMode : 2; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through PCIe_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertise maximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 2; ///< Unused space
+} PCIE_PORT_MISC_CONTROL;
+
+/// The IO APIC Interrupt Mapping Info
+typedef struct {
+ IN UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ IN UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< - ABCD
+ ///< - BCDA
+ ///< - CDAB
+ ///< - DABC
+ IN UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< - Entry 0 of IO APIC redirection table
+ ///< - Entry 1 of IO APIC redirection table
+ ///< - Entry 31 of IO APIC redirection table
+} APIC_DEVICE_INFO;
+
+/// GEN3 RxAdaptMode Configuration Structure
+typedef struct {
+ IN BOOLEAN InitOffsetCancellation; ///< Initial Offset Cancellation Enable
+ IN UINT8 DFEControl; ///< DFE Control
+ IN UINT8 LEQControl; ///< LEQ Control
+ IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic Offset Calibration Enable
+ IN BOOLEAN FOMCalculation; ///< FOM Calculation Enable
+ IN BOOLEAN PIOffsetCalibration; ///< PI Offset Calibratino Enable
+} RX_ADAPT_MODE;
+
+/// PCIe port configuration data
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 ChannelType; ///< Channel type.
+ ///< 0 - "lowLoss",
+ ///< 1 - "highLoss",
+ ///< 2 - "mob0db",
+ ///< 3 - "mob3db",
+ ///< 4 - "extnd6db"
+ ///< 5 - "extnd8db"
+ IN UINT8 DeviceNumber; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 FunctionNumber; ///< Reserved for future use
+ IN UINT8 LinkSpeedCapability; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT8 ResetId; ///< Arbitrary number greater than 0 assigned by platform firmware for GPIO
+ ///< identification which control reset for given port.
+ ///< Each port with unique GPIO should have unique ResetId assigned.
+ ///< All ports use same GPIO to control reset should have same ResetId assigned.
+ ///< see AgesaPcieSlotResetContol.
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3 RxAdaptMode configuration
+} PCIE_PORT_DATA;
+
+/// PCIe Complex descriptor
+typedef struct {
+ IN UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ IN UINT32 SocketId; ///< Socket Id
+ IN VOID *Reserved; ///< Reserved for future use
+} PCIE_COMPLEX_DESCRIPTOR;
+
+/// VBIOS image info
+typedef struct {
+ IN AMD_CONFIG_PARAMS StdHeader; ///< Standard configuration header
+ OUT VOID *ImagePtr; ///< Pointer to VBIOS image
+ IN PCI_ADDR GfxPciAddress; ///< PCI address of integrated graphics controller
+ IN UINT32 Flags; ///< BIT[0] - special repost requred
+} GFX_VBIOS_IMAGE_INFO;
+
+//
+// CPU MSR Register definitions
+//
+#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture Programming manual.
+#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture Programming manual.
+#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture Programming manual.
+
+///
+/// VDDP_VDDR Voltage Info for Low Power DIMM
+///
+typedef struct _VDDP_VDDR_VOLTAGE {
+ IN BOOLEAN IsValid; ///< Indicates if daata is valid
+ IN UINT8 Voltage; ///< VDDP VDDR Voltage Value
+} VDDP_VDDR_VOLTAGE;
+
+// CPU Build Configuration structures and definitions
+
+#define AMD_AP_MTRR_FIX64k_00000 0x00000250ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to AMD64 Architecture Programming manual
+
+#endif // AGESA_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/AgesaModulePkg/Include/AMD.h
new file mode 100755
index 0000000000..062d9e1e1a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
@@ -0,0 +1,91 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_H_
+#define AMD_H_
+
+/// The return status for all AGESA public services.
+///
+/// Services return the most severe status of any logged event. Status other than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
+/// will have log entries with more detail.
+///
+typedef enum {
+ AGESA_SUCCESS = 0, ///< 0 - The service completed normally. Info may be logged.
+ AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct had an unimplemented function requested.
+ ///< Not logged.
+ AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of range and the service was not provided.
+ ///< Example, memory address not installed, heap buffer handle not found.
+ ///< Not Logged.
+ AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP communications (used in ABL)
+ AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in ABL)
+
+ // AGESA_STATUS of greater severity (the ones below this line), always have a log entry available.
+ AGESA_ALERT, ///< 5 - An observed condition, but no loss of function. See Log.
+ AGESA_WARNING, ///< 6 - Possible or minor loss of function. See Log.
+ AGESA_ERROR, ///< 7 - Significant loss of function, boot may be possible. See Log.
+ AGESA_CRITICAL, ///< 8 - Continue boot only to notify user. See Log.
+ AGESA_FATAL, ///< 9 - Halt booting. See Log, however Fatal errors pertaining to heap problems
+ ///< may not be able to reliably produce log events.
+ AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory Overclock failure. (used in ABL)
+ AGESA_SKIP_ERROR, ///< 11 - Error, Skip init steps. (used in ABL)
+ AgesaStatusMax ///< Not a status, for limit checking.
+} AGESA_STATUS;
+
+/**
+ Callout method to the host environment.
+
+ Callout using a dispatch with appropriate thunk layer, which is determined by the host environment.
+
+ @param[in] Function The specific callout function being invoked.
+ @param[in] FcnData Function specific data item.
+ @param[in,out] ConfigPtr Reference to Callout params.
+**/
+typedef AGESA_STATUS (*CALLOUT_ENTRY) (
+ IN UINT32 Function,
+ IN UINTN FcnData,
+ IN OUT VOID *ConfigPtr
+ );
+
+/// AGESA Structures
+
+/// Extended PCI address format
+typedef struct {
+ IN OUT UINT32 Register : 12; ///< Register offset
+ IN OUT UINT32 Function : 3; ///< Function number
+ IN OUT UINT32 Device : 5; ///< Device number
+ IN OUT UINT32 Bus : 8; ///< Bus number
+ IN OUT UINT32 Segment : 4; ///< Segment
+} EXT_PCI_ADDR;
+
+/// Union type for PCI address
+typedef union _PCI_ADDR {
+ IN UINT32 AddressValue; ///< Formal address
+ IN EXT_PCI_ADDR Address; ///< Extended address
+} PCI_ADDR;
+
+///
+/// The standard header for all AGESA services.
+///
+typedef struct {
+ IN UINT32 ImageBasePtr; ///< The AGESA Image base address.
+ IN UINT32 Func; ///< The service desired
+ IN UINT32 AltImageBasePtr; ///< Alternate Image location
+ IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
+ IN UINT8 HeapStatus; ///< For heap status from boot time slide.
+ IN UINT64 HeapBasePtr; ///< Location of the heap
+ IN OUT UINT8 Reserved[7]; ///< This space is reserved for future use.
+} AMD_CONFIG_PARAMS;
+
+/// CPUID data received registers format
+typedef struct {
+ OUT UINT32 EAX_Reg; ///< CPUID instruction result in EAX
+ OUT UINT32 EBX_Reg; ///< CPUID instruction result in EBX
+ OUT UINT32 ECX_Reg; ///< CPUID instruction result in ECX
+ OUT UINT32 EDX_Reg; ///< CPUID instruction result in EDX
+} CPUID_DATA;
+#endif // AMD_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
new file mode 100755
index 0000000000..534b03d4a7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
@@ -0,0 +1,15 @@
+/** @file
+ AMD CPU Register Table Related Functions.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_H_
+#define CPU_REGISTERS_H_
+
+#include <CpuRegistersDef.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
new file mode 100644
index 0000000000..e086a4c9b1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
@@ -0,0 +1,61 @@
+/** @file
+ AMD Psp Directory header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_DIR_H_
+#define AMD_PSP_DIR_H_
+
+#pragma pack (push, 1)
+#define PSP_DIRECTORY_HEADER_SIGNATURE 0x50535024ul ///< $PSP
+#define PSP_LV2_DIRECTORY_HEADER_SIGNATURE 0x324C5024ul ///< $PL2
+
+/// Enum define various enum type for PSP entry type
+enum _PSP_DIRECTORY_ENTRY_TYPE {
+ PSP_REGION_A_DIR = 0x48, ///< PSP entry points to PSP DIR in Region A
+ PSP_REGION_B_DIR = 0x4A, ///< PSP entry points to PSP DIR in Region B
+};
+
+/// Define structure for PSP directory
+typedef struct {
+ UINT32 Cookie; ///< "$PSP"
+ UINT32 Checksum; ///< 32 bit CRC of header items below and the entire table
+ UINT32 TotalEntries; ///< Number of PSP Entries
+ UINT32 Reserved; ///< Unused
+} PSP_DIRECTORY_HEADER;
+
+/// Define structure for 32 bits Entry type field
+typedef struct {
+ UINT32 Type : 8; ///< Type of PSP Directory entry
+ UINT32 SubProgram : 8; ///< Specify the SubProgram
+ UINT32 RomId : 2; ///< Specify the ROM ID
+ UINT32 Reserved : 14; ///< Reserved
+} PSP_DIRECTORY_ENTRY_TYPE_FIELD;
+
+/// Define union type for 32 bits Entry type field
+typedef union {
+ PSP_DIRECTORY_ENTRY_TYPE_FIELD Field; ///< Definition of each filed
+ UINT32 Value; ///< Group it as 32bits Int
+} PSP_DIRECTORY_ENTRY_TYPE;
+
+/// Structure for PSP Entry
+typedef struct {
+ PSP_DIRECTORY_ENTRY_TYPE Type; ///< Type of PSP entry; 32 bit long
+ UINT32 Size; ///< Size of PSP Entry in bytes
+ UINT64 Location; ///< Location of PSP Entry (byte offset from start of SPI-ROM)
+} PSP_DIRECTORY_ENTRY;
+
+/// Structure for PSP directory
+typedef struct {
+ PSP_DIRECTORY_HEADER Header; ///< PSP directory header
+ PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PSP entries each pointing to a binary in SPI flash
+ ///< The actual size of this array comes from the
+ ///< header (PSP_DIRECTORY.Header.TotalEntries)
+} PSP_DIRECTORY;
+
+#pragma pack (pop)
+#endif //AMD_PSP_DIR_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
new file mode 100755
index 0000000000..faa8d35b1b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
@@ -0,0 +1,156 @@
+/** @file
+ AMD CPU Register Table Related Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_DEF_H_
+#define CPU_REGISTERS_DEF_H_
+
+#undef BIT0
+#undef BIT1
+#undef BIT2
+#undef BIT3
+#undef BIT4
+#undef BIT5
+#undef BIT6
+#undef BIT7
+#undef BIT8
+#undef BIT9
+#undef BIT10
+#undef BIT10
+#undef BIT11
+#undef BIT12
+#undef BIT13
+#undef BIT14
+#undef BIT15
+#undef BIT16
+#undef BIT17
+#undef BIT18
+#undef BIT19
+#undef BIT20
+#undef BIT21
+#undef BIT22
+#undef BIT23
+#undef BIT24
+#undef BIT25
+#undef BIT26
+#undef BIT27
+#undef BIT28
+#undef BIT29
+#undef BIT30
+#undef BIT31
+#undef BIT32
+#undef BIT33
+#undef BIT34
+#undef BIT35
+#undef BIT36
+#undef BIT37
+#undef BIT38
+#undef BIT39
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT50
+#undef BIT51
+#undef BIT52
+#undef BIT53
+#undef BIT54
+#undef BIT55
+#undef BIT56
+#undef BIT57
+#undef BIT58
+#undef BIT59
+#undef BIT60
+#undef BIT61
+#undef BIT62
+#undef BIT63
+
+#define BIT0 0x0000000000000001ull
+#define BIT1 0x0000000000000002ull
+#define BIT2 0x0000000000000004ull
+#define BIT3 0x0000000000000008ull
+#define BIT4 0x0000000000000010ull
+#define BIT5 0x0000000000000020ull
+#define BIT6 0x0000000000000040ull
+#define BIT7 0x0000000000000080ull
+#define BIT8 0x0000000000000100ull
+#define BIT9 0x0000000000000200ull
+#define BIT10 0x0000000000000400ull
+#define BIT11 0x0000000000000800ull
+#define BIT12 0x0000000000001000ull
+#define BIT13 0x0000000000002000ull
+#define BIT14 0x0000000000004000ull
+#define BIT15 0x0000000000008000ull
+#define BIT16 0x0000000000010000ull
+#define BIT17 0x0000000000020000ull
+#define BIT18 0x0000000000040000ull
+#define BIT19 0x0000000000080000ull
+#define BIT20 0x0000000000100000ull
+#define BIT21 0x0000000000200000ull
+#define BIT22 0x0000000000400000ull
+#define BIT23 0x0000000000800000ull
+#define BIT24 0x0000000001000000ull
+#define BIT25 0x0000000002000000ull
+#define BIT26 0x0000000004000000ull
+#define BIT27 0x0000000008000000ull
+#define BIT28 0x0000000010000000ull
+#define BIT29 0x0000000020000000ull
+#define BIT30 0x0000000040000000ull
+#define BIT31 0x0000000080000000ull
+#define BIT32 0x0000000100000000ull
+#define BIT33 0x0000000200000000ull
+#define BIT34 0x0000000400000000ull
+#define BIT35 0x0000000800000000ull
+#define BIT36 0x0000001000000000ull
+#define BIT37 0x0000002000000000ull
+#define BIT38 0x0000004000000000ull
+#define BIT39 0x0000008000000000ull
+#define BIT40 0x0000010000000000ull
+#define BIT41 0x0000020000000000ull
+#define BIT42 0x0000040000000000ull
+#define BIT43 0x0000080000000000ull
+#define BIT44 0x0000100000000000ull
+#define BIT45 0x0000200000000000ull
+#define BIT46 0x0000400000000000ull
+#define BIT47 0x0000800000000000ull
+#define BIT48 0x0001000000000000ull
+#define BIT49 0x0002000000000000ull
+#define BIT50 0x0004000000000000ull
+#define BIT51 0x0008000000000000ull
+#define BIT52 0x0010000000000000ull
+#define BIT53 0x0020000000000000ull
+#define BIT54 0x0040000000000000ull
+#define BIT55 0x0080000000000000ull
+#define BIT56 0x0100000000000000ull
+#define BIT57 0x0200000000000000ull
+#define BIT58 0x0400000000000000ull
+#define BIT59 0x0800000000000000ull
+#define BIT60 0x1000000000000000ull
+#define BIT61 0x2000000000000000ull
+#define BIT62 0x4000000000000000ull
+#define BIT63 0x8000000000000000ull
+
+#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO Configuration Base Address Register
+
+#endif // CPU_REGISTERS_DEF_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
new file mode 100644
index 0000000000..8ede1be838
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
@@ -0,0 +1,85 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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_TXBYTECOUNT 0x48 //
+#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 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/AgesaModulePkg/Include/Filecode.h b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
new file mode 100644
index 0000000000..726479d79f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * Collectively assign unique filecodes for assert and debug to each source file.
+ *
+ * Publish values for decorated filenames, which can be used for
+ * ASSERT and debug support using a preprocessor define like:
+ * @n <tt> _#define FILECODE MY_C_FILENAME_FILECODE </tt> @n
+ * This file serves as a reference for debugging to associate the code and filename.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: Include
+ * @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800 (Mon, 09 Feb 2015) $
+ */
+
+#ifndef _FILECODE_H_
+#define _FILECODE_H_
+
+#define UNASSIGNED_FILE_FILECODE (0xFFFF)
+
+#endif // _FILECODE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
new file mode 100755
index 0000000000..ddc9309d3d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_H_
+#define GNB_H_
+
+#define PVOID UINT64
+
+#endif // GNB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
new file mode 100644
index 0000000000..192e0d6a8b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
@@ -0,0 +1,521 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBDXIO_H_
+#define GNBDXIO_H_
+
+#pragma pack (push, 1)
+
+#include <AGESA.h>
+#include <Gnb.h>
+
+#define MAX_NUMBER_OF_COMPLEXES 16
+
+#define DESCRIPTOR_TERMINATE_GNB 0x40000000ull
+#define DESCRIPTOR_TERMINATE_TOPOLOGY 0x20000000ull
+#define DESCRIPTOR_ALLOCATED 0x10000000ull
+#define DESCRIPTOR_PLATFORM 0x08000000ull
+#define DESCRIPTOR_COMPLEX 0x04000000ull
+#define DESCRIPTOR_SILICON 0x02000000ull
+#define DESCRIPTOR_PCIE_WRAPPER 0x01000000ull
+#define DESCRIPTOR_PCIE_ENGINE 0x00800000ull
+#define DESCRIPTOR_CXL_ENGINE 0x00200000ull
+
+#define SILICON_CXL_CAPABLE 0x00008000ull
+
+#define DESCRIPTOR_ALL_WRAPPERS (DESCRIPTOR_PCIE_WRAPPER)
+#define DESCRIPTOR_ALL_ENGINES (DESCRIPTOR_PCIE_ENGINE | DESCRIPTOR_CXL_ENGINE)
+
+#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))
+
+typedef UINT16 PCIE_ENGINE_INIT_STATUS;
+
+///
+/// Engine Configuration
+///
+typedef struct {
+ IN UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ IN UINT16 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ IN UINT16 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+} PCIE_ENGINE;
+
+///
+/// PCIe port misc extended controls
+///
+typedef struct {
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 5; ///< Unused space
+} PORT_MISC_CONTROL;
+
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 FunctionNumber : 3; ///< Reserved for future use
+ IN UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 LinkSpeedCapability : 4; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm : 4; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN UINT8 Reserved1; ///< Reserved for future use
+} PORT_DATA;
+
+typedef struct {
+ UINT8 LinkSpeed;
+ UINT8 MaxPayloadSupport;
+ UINT8 AspmCapability;
+ UINT8 PciPmL1_1;
+ UINT8 PciPmL1_2;
+ UINT8 AspmL1_1;
+ UINT8 AspmL1_2;
+ UINT8 EsmSupport;
+ UINT8 LtrSupport;
+ UINT8 SurpriseDownErrorReport;
+ UINT8 TenBitTagSupport;
+ UINT8 AriForwarding;
+ UINT8 AcsSupport;
+ UINT8 AcsSourceValidation;
+ UINT8 AcsTranslationBlocking;
+ UINT8 AcsP2pRequestRedirect;
+ UINT8 AcsP2pCompletionRedirect;
+ UINT8 AcsUpstreamForwarding;
+ UINT8 AcsP2pEgressControl;
+ UINT8 AcsDirectTranslatedP2p;
+ UINT8 LaneMargining;
+ UINT8 DataLinkFeature;
+ UINT8 DownstreamPortContainment;
+ UINT8 AdvancedErrorReporting;
+ UINT8 ECRCSupport;
+ UINT8 MulticastEnable;
+ UINT8 NativePCIeEnclosureManagement;
+ UINT8 Capability1Address;
+ UINT8 Capability1Data;
+ UINT8 Capability2Address;
+ UINT8 Capability2Data;
+ UINT8 Capability3Address;
+ UINT8 Capability3Data;
+ UINT8 Capability4Address;
+ UINT8 Capability4Data;
+} PORT_CAPABILITIES;
+
+///
+/// PCIe PORT_FEATURES
+///
+typedef struct {
+ UINT8 LinkSpeedControl;
+ UINT8 MaxPayloadSizeControl;
+ UINT8 ESMControl;
+ UINT8 LTRControl;
+ UINT8 DataLinkFeatureExchangeControl;
+ UINT8 TenBitTagControl;
+ UINT8 ARIControl;
+ UINT8 ACSControl;
+ UINT8 RxLaneMarginingControl;
+ UINT8 DynLanesPwrState;
+ UINT8 L1PowerDown;
+ UINT8 L11PowerDown;
+ UINT8 L12PowerDown;
+ UINT8 AutoSpdChngEn;
+ UINT8 TurnOffUnusedLanes;
+} PORT_FEATURES;
+
+typedef struct {
+ UINT8 SpcGen1 : 1; ///< SPC Mode 2P5GT
+ UINT8 SpcGen2 : 1; ///< SPC Mode 5GT
+ UINT8 SpcGen3 : 2; ///< SPC Mode 8GT
+ UINT8 SpcGen4 : 2; ///< SPC Mode 16GT
+ UINT8 SpcGen5 : 2; ///< SPC Mode 32GT
+} SPC_MODE;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT32 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT32 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset Mask
+ UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnable
+ UINT32 UNUSED2 : 7; ///< Currently unassigned - for alignment
+} GEN3_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset Mask
+ UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEnable
+ UINT32 UNUSED3 : 13; ///< Currently unassigned - for alignment
+} GEN4_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset Mask
+ UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnable
+ UINT32 PrecodeRequest : 1; ///< Precoding Request
+ UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ To High Rate Support
+ UINT32 UNUSED4 : 11; ///< Currently unassigned - for alignment
+} GEN5_LANE_CNTL;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor0 : 5; ///< PostCursor0
+ UINT32 LcFapeReqPreCursor0 : 4; ///< PreCursor0
+ UINT32 LcFapeReqPostCursor1 : 5; ///< PostCursor1
+ UINT32 LcFapeReqPreCursor1 : 4; ///< PreCursor1
+ UINT32 LcFapeReqPostCursor2 : 5; ///< PostCursor2
+ UINT32 LcFapeReqPreCursor2 : 4; ///< PreCursor2
+ UINT32 UNUSED6 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_0;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor3 : 5; ///< PostCursor3
+ UINT32 LcFapeReqPreCursor3 : 4; ///< PreCursor3
+ UINT32 LcFapeReqPostCursor4 : 5; ///< PostCursor4
+ UINT32 LcFapeReqPreCursor4 : 4; ///< PreCursor4
+ UINT32 LcFapeReqPostCursor5 : 5; ///< PostCursor5
+ UINT32 LcFapeReqPreCursor5 : 4; ///< PreCursor5
+ UINT32 UNUSED7 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_1;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor6 : 5; ///< PostCursor6
+ UINT32 LcFapeReqPreCursor6 : 4; ///< PreCursor6
+ UINT32 LcFapeReqPostCursor7 : 5; ///< PostCursor7
+ UINT32 LcFapeReqPreCursor7 : 4; ///< PreCursor7
+ UINT32 LcFapeReqPostCursor8 : 5; ///< PostCursor8
+ UINT32 LcFapeReqPreCursor8 : 4; ///< PreCursor8
+ UINT32 UNUSED8 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_2;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor9 : 5; ///< PostCursor9
+ UINT32 LcFapeReqPreCursor9 : 4; ///< PreCursor9
+ UINT32 LcFapeReqPostCursor10 : 5; ///< PostCursor10
+ UINT32 LcFapeReqPreCursor10 : 4; ///< PreCursor10
+ UINT32 LcFapeReqPostCursor11 : 5; ///< PostCursor11
+ UINT32 LcFapeReqPreCursor11 : 4; ///< PreCursor11
+ UINT32 UNUSED9 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_3;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor12 : 5; ///< PostCursor12
+ UINT32 LcFapeReqPreCursor12 : 4; ///< PreCursor12
+ UINT32 LcFapeReqPostCursor13 : 5; ///< PostCursor13
+ UINT32 LcFapeReqPreCursor13 : 4; ///< PreCursor13
+ UINT32 LcFapeReqPostCursor14 : 5; ///< PostCursor14
+ UINT32 LcFapeReqPreCursor14 : 4; ///< PreCursor14
+ UINT32 UNUSED10 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_4;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor15 : 5; ///< PostCursor15
+ UINT32 LcFapeReqPreCursor15 : 4; ///< PreCursor15
+ UINT32 LcFapeReqPostCursor16 : 5; ///< PostCursor16
+ UINT32 LcFapeReqPreCursor16 : 4; ///< PreCursor16
+ UINT32 LcFapeReqPostCursor17 : 5; ///< PostCursor17
+ UINT32 LcFapeReqPreCursor17 : 4; ///< PreCursor17
+ UINT32 UNUSED11 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_5;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor18 : 5; ///< PostCursor18
+ UINT32 LcFapeReqPreCursor18 : 4; ///< PreCursor18
+ UINT32 LcFapeReqPostCursor19 : 5; ///< PostCursor19
+ UINT32 LcFapeReqPreCursor19 : 4; ///< PreCursor19
+ UINT32 LcFapeReqPostCursor20 : 5; ///< PostCursor20
+ UINT32 LcFapeReqPreCursor20 : 4; ///< PreCursor20
+ UINT32 UNUSED12 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_6;
+
+///
+/// PCIe port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 IsBmcLocation : 1; ///< Port Location of BMC
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 TXDeEmphasis : 4; ///< TX De-emphasis
+ UINT8 TXMargin : 3; ///< TX Margin
+ UINT8 UNUSED1 : 1; ///< Currently unassigned - for alignment
+
+ PORT_CAPABILITIES PortCapabilities; ///< Port Capabilities CBS
+
+ SPC_MODE SpcMode;
+
+ GEN3_LANE_CNTL LaneEqualizationCntl;
+ GEN4_LANE_CNTL Gen4LaneEqualizationCntl;
+ GEN5_LANE_CNTL Gen5LaneEqualizationCntl;
+
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 UNUSED4 : 1; ///< Currently unassigned - for alignment
+ UINT8 SRIS_SRNS : 1; ///< SRIS SRNS
+ UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SKP Support
+ UINT8 CcixControl : 1; ///< Bit to enable/disable ESM
+ UINT8 CxlControl : 1; ///< Bit to enable CXL Capability
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 SlotPowerLimitScale : 2; ///< Slot Power Limit Scale
+ UINT8 UNUSED5 : 1; ///< Currently unassigned - for alignment
+
+ UINT8 RxMarginPersistence : 1; ///< Bit to enable/disable Rx Margin persistence mode
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 TxVetting : 1; ///< Gen4 Tx Vetting
+ UINT8 RxVetting : 1; ///< Gen4 Rx Vetting
+ UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetting
+ UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetting
+
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 DlfCapDisable : 1; ///< DLF Capability 1:Disable 0:Enable
+ UINT8 DlfExchangeDisable : 1; ///< DLF Exchange 1:Disable 0:Enable
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+
+ UINT8 EqSearchMode : 2; ///< Equalization Search Mode
+ UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ
+ UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 EQ Phase2/3
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset value
+
+ UINT8 EqSearchModeGen4 : 2; ///< Equalization Search Mode for Gen4
+ UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass phase3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset value
+ UINT8 EqSearchModeGen5 : 2; ///< Equalization Search Mode for Gen5
+ UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass phase3 EQ
+ UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass phase2/3 EQ
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset value
+
+ UINT16 PsppPolicyDC; ///< Pspp Policy DC
+ UINT16 PsppPolicyAC; ///< Pspp Policy AC
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+
+ LC_FAPE_GROUP_0 LcFapeSettingsGroup0;
+ LC_FAPE_GROUP_1 LcFapeSettingsGroup1;
+ LC_FAPE_GROUP_2 LcFapeSettingsGroup2;
+ LC_FAPE_GROUP_3 LcFapeSettingsGroup3;
+ LC_FAPE_GROUP_4 LcFapeSettingsGroup4;
+ LC_FAPE_GROUP_5 LcFapeSettingsGroup5;
+ LC_FAPE_GROUP_6 LcFapeSettingsGroup6;
+
+ UINT8 ForceSteering : 1; ///< Steering is forced
+ UINT8 EsmUsTxPreset : 4; ///< ESM Upstream Tx Preset
+ UINT8 UNUSED13 : 3; ///< Currently unassigned - for alignment
+
+ // Used by DXE
+ PORT_FEATURES PortFeatures; ///< Port Features CBS
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 I2CMuxInfo; ///< First I2c Mux on Bus
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:SRIS 2:SRNS 3:SRNS in SRIS 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 ClkReq : 4; ///< ClkReq:[0:3]
+ UINT8 EqPreset : 4; ///< EqPreset:[4:7]
+ UINT8 LinkAspmL1_1 : 1; ///< Enable PM L1 SS L1.1
+ UINT8 LinkAspmL1_2 : 1; ///< Enable PM L1 SS L1.2
+ UINT8 EsmControl : 1; ///< Bit to enable/disable ESM
+ UINT8 EsmDsTxPreset : 4; ///< ESM Downstream Tx Preset
+ UINT8 ClkReqFilterEn : 1; ///< Controls filtering of CLKREQb signal in LC in order to avoid false L1 substate entries/exits.
+} PCIE_PORT_CONFIG;
+
+///
+/// CXL port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 UNUSED0 : 1; ///< Currently unassigned - for alignment
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 CxlIndex;
+ UINT8 CxlDeviceType : 2; ///< Type of CXL device connected
+ UINT8 CxlVersion : 2; ///< Version of CXL device connected (1=CXL1.1, 2=CXL2.0)
+ UINT8 IsCxlScanned : 1; ///< Indicates if the CXL device has been scanned
+ UINT8 ReportToMpioinDxe : 1; ///< Indicates if the CXL info needs to be reported to MPIO in DXE
+ UINT8 UNUSED1 : 2; ///< Currently unassigned - for alignment
+
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT32 Mmio32Base;
+ UINT32 Mmio32Size;
+ UINT64 Mmio64Base;
+ UINT64 Mmio64Size;
+ UINT32 Mmio32Gran;
+} PCIE_CXL_CONFIG;
+
+///
+/// Descriptor header
+///
+typedef struct {
+ UINT32 DescriptorFlags; ///< Descriptor flags
+ UINT16 Parent; ///< Offset of parent descriptor
+ UINT16 Peer; ///< Offset of the peer descriptor
+ UINT16 Child; ///< Offset of the list of child descriptors
+} PCIE_DESCRIPTOR_HEADER;
+
+///
+/// Engine configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor header
+ PCIE_ENGINE EngineData; ///< Engine Data
+ PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initialization Status
+ UINT8 Scratch; ///< Scratch pad
+ union {
+ PCIE_PORT_CONFIG Port; ///< PCIe port configuration data
+ PCIE_CXL_CONFIG Cxl; ///< CXL Configuration data
+ } Type;
+} PCIE_ENGINE_CONFIG;
+
+///
+/// Wrapper configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 WrapId; ///< Wrapper ID
+ UINT8 CcixCoreConfig; ///< Ccix CORE Configuration
+ UINT8 StartPhyLane; ///< Start PHY Lane
+ UINT8 EndPhyLane; ///< End PHY Lane
+ UINT8 StartDxioLane; ///< Start Dxio Lane (Translated)
+ UINT8 EndDxioLane; ///< End Dxio Lane (Translated)
+ struct {
+ UINT8 PowerOffUnusedLanes : 1; ///< Power Off unused lanes
+ UINT8 PowerOffUnusedPlls : 1; ///< Power Off unused Plls
+ UINT8 ClkGating : 1; ///< TXCLK gating
+ UINT8 LclkGating : 1; ///< LCLK gating
+ UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock gating PLL power down
+ UINT8 PllOffInL1 : 1; ///< PLL off in L1
+ UINT8 AccessEncoding : 1; ///< Reg access encoding
+ UINT8 CoreReversed : 1; ///< Indicates lanes are reversed in package connection
+ } Features;
+ UINT8 MasterPll; ///< Bitmap of master PLL
+ UINT32 AcsSupport : 1; ///< Acs Support
+ UINT32 LtrSupport : 1; ///< LTR Support
+ UINT32 AriForwarding : 1; ///< ARI Forwarding
+ UINT32 LaneMargining : 1; ///< Lane Margining
+ UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM
+ UINT32 DownstreamPortContainment : 1; ///< Downstream port containment
+ UINT32 AdvancedErrorReporting : 1; ///< Advacned Error Reporting
+ UINT32 ECRCSupport : 2; ///< ECRC Capability
+ UINT32 Reserved : 23; ///< Reserved bits
+} PCIE_WRAPPER_CONFIG;
+
+///
+/// Silicon configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 SocketId; ///< Socket ID
+ UINT8 DieNumber; ///< Module ID
+ UINT8 RBIndex; ///< Physical Root Bridge
+ UINT8 InstanceId; ///< Logical Instance Identifier
+ PCI_ADDR Address; ///< PCI address of GNB host bridge
+ UINT16 StartLane; ///< Start Lane of this node
+ UINT16 EndLane; ///< End Lane of this node
+ UINT8 BusNumberLimit; ///< Last Bus Number assigned to this node
+ UINT8 SbPresent : 1; ///< Set to 1 if FCH connected to this NBIO
+ UINT8 SmuPresent : 1; ///< Set to 1 if SMU connected to this NBIO
+ UINT8 MP_Instance : 6; ///< MP Instance
+ UINT8 LogicalRBIndex; ///< Logical Root Bridge
+ UINT8 NumEngineDesc; ///< Total number of lane bifurcation descriptors
+} PCIE_SILICON_CONFIG;
+
+typedef PCIE_SILICON_CONFIG GNB_HANDLE;
+
+///
+/// Complex configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 NodeId; ///< Processor Node ID
+ UINT8 Reserved; ///< For alignment
+} PCIE_COMPLEX_CONFIG;
+
+///
+/// PCIe platform configuration info
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ PVOID Reserved1; ///< Reserved
+ UINT32 Reserved2; ///< Reserved
+ UINT32 PhyConfigData; ///< Phy Configuration Data
+ UINT32 Reserved3; ///< Reserved
+ UINT32 Reserved4; ///< Reserved
+ UINT32 PsppTuningParams; ///< Tuning parameters for PSPP
+ UINT32 PsppTuningParams2; ///< Tuning parameters 2 for PSPP
+ UINT8 Reserved5; ///< Reserved
+ UINT8 PsppPolicy; ///< PSPP policy
+ UINT8 Reserved6; ///< Reserved
+ UINT8 RootBridgesPerSocket; ///< Number of root bridges per socket
+ PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES]; ///< Complex
+} PCIE_PLATFORM_CONFIG;
+
+///
+/// PCIe Engine Description
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor on wrapper
+ ///< Bit30 - Descriptor allocated for PCIe port
+ PCIE_ENGINE EngineData; ///< Engine Data
+} PCIE_ENGINE_DESCRIPTOR;
+#pragma pack (pop)
+
+#endif // GNBDXIO_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
new file mode 100644
index 0000000000..90f52cca7b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
@@ -0,0 +1,18 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _GNBREGISTERSRS_H_
+#define _GNBREGISTERSRS_H_
+
+#include "GnbRegistersRS/IOHC.h"
+
+#ifndef NBIO_SPACE
+#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + (HANDLE->RBIndex << 20))
+#endif
+
+#endif /*_GNBREGISTERSRS_H_*/
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
new file mode 100644
index 0000000000..b1a95237de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _IOHC_H_
+#define _IOHC_H_
+
+// Bitfield Description : DBG MMIO enable.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
+
+// Bitfield Description : Locks the DBG MMIO address range and enable until the next warm reset.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
+
+#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 0x13c102f0UL
+
+#endif /* _IOHC_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
new file mode 100644
index 0000000000..f5cc5e2228
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_PCIE_HOB_INFO_H_
+#define GNB_PCIE_HOB_INFO_H_
+
+#define _GNB_PCIE_HOB_INFO_GUID \
+{ \
+ 0x3eb1d90, 0xce14, 0x40d8, 0xa6, 0xba, 0x10, 0x3a, 0x8d, 0x7b, 0xd3, 0x2d \
+}
+extern EFI_GUID gGnbPcieHobInfoGuid;
+
+#pragma pack (push, 1)
+#define MAX_NUMBER_OF_CORES_PER_COMPLEX 3
+#define MAX_NUMBER_OF_PORTS_PER_COMPLEX 22
+
+/// PCIe information HOB data
+typedef struct _GNB_PCIE_INFORMATION_DATA_HOB {
+ EFI_HOB_GUID_TYPE EfiHobGuidType; ///< GUID Hob type structure
+ PCIE_PLATFORM_CONFIG PciePlatformConfigHob; ///< Platform Config Structure
+ UINT32 ComplexConfigs; ///< Allocation for Max Complex Structure suported
+} GNB_PCIE_INFORMATION_DATA_HOB;
+
+#pragma pack (pop)
+
+#endif /* GNB_PCIE_HOB_INFO_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
new file mode 100644
index 0000000000..dc773737b9
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+ Contains interface to the AMD AGESA library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_BASE_LIB_H_
+#define AMD_BASE_LIB_H_
+
+#include "Uefi.h"
+#include "AMD.h"
+
+#endif // AMD_BASE_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
new file mode 100644
index 0000000000..9d9892aa30
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
@@ -0,0 +1,43 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * PSP Mailbox related functions Prototype definition
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: PSP
+ * @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue, 03 Feb 2015) $
+ */
+
+#ifndef _PSP_MBOX_H_
+#define _PSP_MBOX_H_
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ );
+
+#endif //_PSP_MBOX_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
new file mode 100644
index 0000000000..51935f413a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BASE_FABRIC_TOPOLOGY_LIB_H_
+#define BASE_FABRIC_TOPOLOGY_LIB_H_
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ );
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ );
+
+#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
new file mode 100644
index 0000000000..cae3aff9b3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_BASE_LIB_H_
+#define _FCH_BASE_LIB_H_
+
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/BaseLib.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
new file mode 100644
index 0000000000..345e39adce
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
@@ -0,0 +1,413 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_ESPI_CMD_LIB_H_
+#define _FCH_ESPI_CMD_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+#define MAX_ESPI_RETRY 100000ul
+//
+// Cycle Type
+//
+#define CYCLE_TYPE_FLASH_READ 0
+#define CYCLE_TYPE_FLASH_WRITE 1
+#define CYCLE_TYPE_FLASH_ERASE 2
+#define CYCLE_TYPE_RPMC_OP1 3
+#define CYCLE_TYPE_RPMC_OP2 4
+
+// RPMC OP1/OP2 Command Payload Max Length (512 Bits)
+#define RPMC_CMD_PAYLOAD_MAX_LEN 0x40
+
+//
+// Master Registers
+//
+#define SET_CONFIGURATION 0
+#define GET_CONFIGURATION 1
+#define IN_BAND_RESET 2
+#define PC_MSG_DOWN_STREAM 4
+#define VM_DOWN_STREAM 5
+#define OOB_DOWN_STREAM 6
+#define FA_DOWN_STREAM 7
+
+// ESPIx00
+#define DNCMD_STATUS BIT3
+
+// ESPIx2C Master Capability
+#define MASTER_FA_SUPPORT BIT0
+#define MASTER_OOB_SUPPORT BIT1
+#define MASTER_VW_SUPPORT BIT2
+#define MASTER_PERIPHERAL_SUPPORT BIT3
+
+// ESPIx68 Slave0 Configuration
+#define SLAVE_FA_ENABLE BIT0
+#define SLAVE_OOB_ENABLE BIT1
+#define SLAVE_VW_ENABLE BIT2
+#define SLAVE_PC_ENABLE BIT3
+
+/// eSPIx00 eSPI Software Specific Register 0
+#define ESPI_DN_TXHDR_0 0x00
+typedef union {
+ struct {
+ UINT32 SWCommandType : 3;
+ UINT32 CommandStatus : 1;
+ UINT32 PutFlashNpTranActive : 1;
+ UINT32 Reserved : 3;
+ UINT32 DnCmdHdata0 : 8;
+ UINT32 DnCmdHdata1 : 8;
+ UINT32 DnCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx00_DN_TXHDR0;
+
+/// eSPIx04 eSPI Software Specific Register 1
+#define ESPI_DN_TXHDR_1 0x04
+typedef union {
+ struct {
+ UINT32 DnCmdHdata3 : 8;
+ UINT32 DnCmdHdata4 : 8;
+ UINT32 DnCmdHdata5 : 8;
+ UINT32 DnCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx04_DN_TXHDR1;
+
+#define ESPI_DN_TXHDR_2 0x08
+typedef union {
+ struct {
+ UINT32 DnCmdHdata7 : 8;
+ UINT32 Reserved : 24;
+ } Field;
+ UINT32 Value;
+} ESPIx08_DN_TXHDR2;
+
+#define ESPI_DN_TXDATA_PORT 0x0C
+typedef union {
+ struct {
+ UINT32 DnTxData0 : 8;
+ UINT32 DnTxData1 : 8;
+ UINT32 DnTxData2 : 8;
+ UINT32 DnTxData3 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx0C_DN_TXDATA_PORT;
+
+#define ESPI_UP_RXHDR_0 0x10
+typedef union {
+ struct {
+ UINT32 UpCommandType : 3;
+ UINT32 UpCommandStatus : 1;
+ UINT32 SlaveSel : 2;
+ UINT32 Reserved : 2;
+ UINT32 UpCmdHdata0 : 8;
+ UINT32 UpCmdHdata1 : 8;
+ UINT32 UpCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx10_UP_RXHDR0;
+
+#define ESPI_UP_RXHDR_1 0x14
+typedef union {
+ struct {
+ UINT32 UpCmdHdata3 : 8;
+ UINT32 UpCmdHdata4 : 8;
+ UINT32 UpCmdHdata5 : 8;
+ UINT32 UpCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx14_UP_RXHDR1;
+
+#define ESPI_UP_RXDATA_PORT 0x18
+
+/// eSPIx2C eSPI Master Capability
+#define ESPI_MASTER_CAP 0x2C
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelSupport : 1;
+ UINT32 OOBMessageChannelSupport : 1;
+ UINT32 VWChannelSupport : 1;
+ UINT32 PChannelSupport : 1;
+ UINT32 MasterVersion : 3;
+ UINT32 FlashAccessChannelMaxPayload : 3;
+ UINT32 OOBMessageChannelMaxPayload : 3;
+ UINT32 OperatingMaxVWCount : 6;
+ UINT32 PChannelMaxPayloadSize : 3;
+ UINT32 NumberOfSlave : 3;
+ UINT32 OperatingSupportFreq : 3;
+ UINT32 IOMode : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheck : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx2C_MASTER_CAP;
+
+/// eSPIx30 eSPI Global Control 0
+#define ESPI_GLOBAL_CTRL0 0x30
+typedef union {
+ struct {
+ UINT32 WdgEn : 1;
+ UINT32 WaitChkEn : 1;
+ UINT32 PrClkgatEn : 1;
+ UINT32 AlStopEn : 1;
+ UINT32 AlIdleTimer : 3;
+ UINT32 RgDbgclkGatingEn : 1;
+ UINT32 WdgCnt : 16;
+ UINT32 WaitCnt : 6;
+ UINT32 PrRstEnPltrst : 1;
+ UINT32 SafsClkGateEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx30_GLOBAL_CTRL0;
+
+/// eSPIx68 eSPI Slave0 Configuration
+#define ESPI_SLAVE0_CONFIG 0x68
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelEnable : 1;
+ UINT32 OOBMessageChannelEnable : 1;
+ UINT32 VWChannelEnable : 1;
+ UINT32 PChannelEnable : 1;
+ UINT32 FlashSharingMode : 1;
+ UINT32 FlashMaxPayloadSize : 3;
+ UINT32 PutFlashNpHeaderDataEn : 1;
+ UINT32 PutFlashNpHeaderEn : 1;
+ UINT32 SafsDeferValidEn : 1;
+ UINT32 FlashModifierEn : 1;
+ UINT32 Reserved_24_12 : 13;
+ UINT32 OperatingFreq : 3;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheckingEnable : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx68_SLAVE0_CONFIG;
+
+/// eSPIx70 eSPI Slave0 Interrupt Status
+#define ESPI_SLAVE0_INT_STS 0x70
+typedef union {
+ struct {
+ UINT32 BusErrInt : 1;
+ UINT32 WaitTimeoutInt : 1;
+ UINT32 CrcErrInt : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 NoRspInt : 1;
+ UINT32 FatalErrInt : 1;
+ UINT32 NonFatalErrInt : 1;
+ UINT32 UnknownRspInt : 1;
+ UINT32 UnknownCtInt : 1;
+ UINT32 UnsucssCplInt : 1;
+ UINT32 IllegalTagInt : 1;
+ UINT32 IllegalLenInt : 1;
+ UINT32 RxOobOverflowInt : 1;
+ UINT32 RxMsgOverflowInt : 1;
+ UINT32 RxFlashOverflowInt : 1;
+ UINT32 ProtocolErrInt : 1;
+ UINT32 Reserved_16 : 1;
+ UINT32 UpFifoWdgTo : 1;
+ UINT32 MstAbortInt : 1;
+ UINT32 WdgTimeoutInt : 1;
+ UINT32 Reserved_23_20 : 4;
+ UINT32 RxVwGrp0Int : 1;
+ UINT32 RxVwGrp1Int : 1;
+ UINT32 RxVwGrp2Int : 1;
+ UINT32 RxVwGrp3Int : 1;
+ UINT32 DnCmdInt : 1;
+ UINT32 RxMsgInt : 1;
+ UINT32 RxOobInt : 1;
+ UINT32 FlashReqInt : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx70_SLAVE0_INT_STS;
+
+///
+/// Slave Registers
+///
+#define SLAVE_REG_ID 0x04
+#define SLAVE_GENERAL_CAPCFG 0x08
+#define SLAVE_PC_CAPCFG 0x10
+#define SLAVE_VW_CAPCFG 0x20
+#define SLAVE_OOB_CAPCFG 0x30
+#define SLAVE_FA_CAPCFG 0x40
+#define SLAVE_FA_CAPCFG2 0x44
+
+/// Offset 04h: Device Identification
+typedef union {
+ struct {
+ UINT32 RO_VersionID : 8;
+ UINT32 Reserved_31_8 : 24;
+ } Field;
+ UINT32 Value;
+} ESPI_SL04_DEVICE_ID;
+
+// SLAVE offset 0x08 SLAVE_GENERAL_CAPCFG
+#define SLAVE_FA_SUPPORT BIT3
+#define SLAVE_OOB_SUPPORT BIT2
+#define SLAVE_VW_SUPPORT BIT1
+#define SLAVE_PERIPHERAL_SUPPORT BIT0
+/// Offset 08h: General Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 RO_PCSupported : 1;
+ UINT32 RO_VWSupported : 1;
+ UINT32 RO_OOBMsgSupported : 1;
+ UINT32 RO_FASupported : 1;
+ UINT32 Reserved_7_3 : 4;
+ UINT32 Reserved_11_8 : 4;
+ UINT32 RO_MaxWaitStateAllowed : 4;
+ UINT32 RO_MaxFreqSupported : 3;
+ UINT32 RO_OpenDrainAlertSupported : 1;
+ UINT32 OperatingFreq : 3;
+ UINT32 OpenDrainAlertSelect : 1;
+ UINT32 RO_IOModeSupported : 2;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 Reserved_29 : 1;
+ UINT32 ResponseModifierEn : 1;
+ UINT32 CRCCheckingEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPI_SL08_SLAVE_GENERAL_CAPCFG;
+
+/// Offset 10h: Channel 0 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 PCEn : 1;
+ UINT32 RO_PCReady : 1;
+ UINT32 BusMasterEn : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 RO_PCMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 PCMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_11 : 1;
+ UINT32 PCMaxReadRequestSize : 3;
+ UINT32 Reserved_31_15 : 17;
+ } Field;
+ UINT32 Value;
+} ESPI_SL10_SLAVE_PC_CAPCFG;
+
+/// Offset 20h: Channel 1 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 VWEn : 1;
+ UINT32 RO_VWReady : 1;
+ UINT32 Reserved_7_2 : 6;
+ UINT32 RO_MaxVWCntSupported : 6;
+ UINT32 Reserved_15_14 : 2;
+ UINT32 OpMaxVWCnt : 6;
+ UINT32 Reserved_31_22 : 10;
+ } Field;
+ UINT32 Value;
+} ESPI_SL20_SLAVE_VW_CAPCFG;
+
+/// Offset 30h: Channel 2 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 OOBEn : 1;
+ UINT32 RO_OOBReady : 1;
+ UINT32 Reserved_3_2 : 2;
+ UINT32 RO_MsgChMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 MsgChMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_31_11 : 21;
+ } Field;
+ UINT32 Value;
+} ESPI_SL30_SLAVE_OOB_CAPCFG;
+
+/// Offset 40h: Channel 3 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 FAEn : 1;
+ UINT32 RO_FAReady : 1;
+ UINT32 FlashBlockEraseSize : 3;
+ UINT32 RO_ChMaxPayloadSizeSupported : 3;
+ UINT32 ChMaxPayloadSizeSelected : 3;
+ UINT32 RO_FlashSharingMode : 1;
+ UINT32 ChMaxReadReqSize : 3;
+ UINT32 Reserved_15 : 1;
+ UINT32 RO_FlashSharingCapabilitySupported : 2;
+ UINT32 Reserved_19_18 : 2;
+ UINT32 RO_RPMCCounterOn1stDevice : 4;
+ UINT32 RO_RPMCOp1On1stDevice : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL40_SLAVE_FA_CAPCFG;
+
+/// Offset 44h: Channel 3 Capabilities and Configurations2
+typedef union {
+ struct {
+ UINT32 RO_TargetMaxReadReqSizeSupported : 3;
+ UINT32 Reserved_7_3 : 5;
+ UINT32 RO_TargetFlashEraseBlockSize : 8;
+ UINT32 RO_TargetRPMCSupported : 6;
+ UINT32 RO_NumOfRPMCdevices : 2;
+ UINT32 Reserved_31_24 : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL44_SLAVE_FA_CAPCFG2;
+
+//
+// eSPI Command functions
+//
+VOID
+FchEspiCmd_InBandRst (
+ IN UINT32 EspiBase
+ );
+
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ );
+
+VOID
+FchEspiCmd_SetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr,
+ IN UINT32 Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp1 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ IN UINT8 *Data
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp2 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
new file mode 100755
index 0000000000..19688e2548
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
@@ -0,0 +1,16 @@
+/** @file
+ GNB PCIe Library definition.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBPCIECONFIG_LIB_H_
+#define GNBPCIECONFIG_LIB_H_
+
+#include <GnbDxio.h>
+#include <Library/PcieConfigLib.h>
+
+#endif // GNBPCIECONFIG_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
new file mode 100644
index 0000000000..df88274530
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
@@ -0,0 +1,37 @@
+/** @file
+ Header file of AMD NBIO Common DXE library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOCOMMONLIBDXE_H_
+#define NBIOCOMMONLIBDXE_H_
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ );
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ );
+
+#endif // NBIOCOMMONLIBDXE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
new file mode 100755
index 0000000000..4fec578a9f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
@@ -0,0 +1,62 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOHANDLELIB_LIB_H_
+#define NBIOHANDLELIB_LIB_H_
+
+#include <GnbDxio.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ );
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ );
+
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define GnbGetSocketId(Handle) (Handle != NULL ? (Handle)->SocketId : 0)
+#define GnbGetDieNumber(Handle) (Handle != NULL ? (Handle)->DieNumber : 0)
+#define GnbGetRBIndex(Handle) (Handle != NULL ? (Handle)->RBIndex : 0)
+
+#endif // NBIOHANDLELIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
new file mode 100644
index 0000000000..9f53746814
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
@@ -0,0 +1,283 @@
+/** @file
+ Helper functions to access PCIe configuration data area.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PCIECONFIGLIB_LIB_H_
+#define PCIECONFIGLIB_LIB_H_
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_WRAPPER_CALLBACK) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK2) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+typedef VOID (*PCIE_RUN_ON_WRAPPER_CALLBACK2) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_DESCRIPTOR_CALLBACK) (
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ );
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ );
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ );
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ );
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ );
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ );
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ );
+
+#define PcieConfigGetParentWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetParent (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetParentSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetParentComplex(Descriptor) ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX, &((Descriptor)->Header)))
+#define PcieConfigGetPlatform(Descriptor) ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM, &((Descriptor)->Header)))
+#define PcieConfigGetChildWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetChildEngine(Descriptor) ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES, &((Descriptor)->Header)))
+#define PcieConfigGetChildSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetNextDescriptor(Descriptor) ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : ((Descriptor + 1))))
+#define PcieConfigIsPcieEngine(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_PCIE_ENGINE) != 0) : FALSE)
+#define PcieConfigIsSbPcieEngine(Engine) ((Engine != NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.SbLink)) : FALSE)
+#define PcieConfigIsEngineAllocated(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_ALLOCATED) != 0) : FALSE)
+#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) if (Descriptor != NULL) (Descriptor)->Header.DescriptorFlags |= SetDescriptorFlags
+#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) if (Descriptor != NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags &= (~(ResetDescriptorFlags))
+#define PcieInputParsetGetNextDescriptor(Descriptor) ((Descriptor == NULL) ? NULL : ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
+#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination) ((Descriptor == NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags & Termination) != 0) ? NULL : ((UINT8 *) Descriptor + ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Peer))
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define PcieConfigGetNextDataDescriptor(Descriptor) ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0 ? NULL : (Descriptor + 1))
+
+#endif // PCIECONFIGLIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
new file mode 100644
index 0000000000..f0c6d1ccbb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SMNACCESSLIB_H_
+#define _SMNACCESSLIB_H_
+
+VOID
+SmnRegisterReadS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ OUT VOID *Value
+ );
+
+VOID
+SmnRegisterRMWS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrValue,
+ IN UINT32 Flags
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
new file mode 100644
index 0000000000..0e08e64b24
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_PCIE_SERVICES_PROTOCOL_H_
+#define NBIO_PCIE_SERVICES_PROTOCOL_H_
+
+// Current PROTOCOL revision
+#define AMD_NBIO_PCIE_SERVICES_REVISION 0x00
+
+///
+/// Forward declaration for the NBIO_PCIE_SERVICES_PROTOCOL
+///
+typedef struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL;
+
+//
+// Protocol Definitions
+//
+
+/**
+ Returns the NBIO debug options configuration structure
+ This
+ A pointer to the DXE_AMD_NBIO_SMU_SERVICES_PROTOCOL instance.
+ DebugOptions
+ A pointer to a pointer to store the address of the PCIe topology structure
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT)(
+ IN DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL *This,
+ OUT UINT32 **DebugOptions
+ );
+
+///
+/// The Dxe of PCIE Services
+///
+struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL {
+ AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT PcieGetTopology; ///<
+};
+
+extern EFI_GUID gAmdNbioPcieServicesProtocolGuid;
+
+#endif /* NBIO_PCIE_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
new file mode 100644
index 0000000000..10d3b730a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
+#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
+
+extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
new file mode 100644
index 0000000000..a15995188b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
@@ -0,0 +1,155 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_NUMA_SERVICES2_H_
+#define FABRIC_NUMA_SERVICES2_H_
+#include "AMD.h"
+
+#pragma pack (push, 1)
+
+#define MAX_PXM_VALUES_PER_QUADRANT 16
+
+/// Domain type
+typedef enum {
+ NumaDram,
+ NumaSLink,
+ NumaCxl,
+ MaxNumaDomainType2
+} DOMAIN_TYPE2;
+
+/// Reported Domain Info
+typedef struct {
+ DOMAIN_TYPE2 Type; ///< Type
+ UINT32 SocketMap; ///< Bitmap indicating physical socket location
+ UINT32 PhysicalDomain; ///< Physical domain number
+} DOMAIN_INFO2;
+
+/// Physical Dram Info
+typedef struct {
+ UINT32 NormalizedCsMap; ///< Bitmap of CSs comprising this physical domain
+ UINT32 SharingEntityCount; ///< Number of virtual domains sharing this physical domain
+ UINT32 SharingEntityMap; ///< Bitmap of reported domains that share this physical domain
+ UINT32 Reserved; ///< Reserved
+} PHYS_DOMAIN_INFO;
+
+/// Proximity Domain Info
+typedef struct {
+ UINTN Count; ///< Entries in Domain array
+ UINTN Domain[MAX_PXM_VALUES_PER_QUADRANT]; ///< Domains in Quadrant
+} PXM_DOMAIN_INFO;
+
+///
+/// Forward declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL
+///
+typedef struct _FABRIC_NUMA_SERVICES2_PROTOCOL FABRIC_NUMA_SERVICES2_PROTOCOL;
+
+/**
+ * @brief Get the numa domain information.
+ *
+ * @details Get the numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfDomainsInSystem Number of unique NUMA domains
+ * @param[out] DomainInfo An array with information about each domain
+ * @param[out] CcxAsNumaDomain TRUE: each core complex is its own domain
+ * FALSE: physical mapping is employed
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfDomainsInSystem,
+ OUT DOMAIN_INFO2 **DomainInfo,
+ OUT BOOLEAN *CcxAsNumaDomain
+ );
+
+/**
+ * @brief Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @details Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] Socket Zero based socket that the core is attached to
+ * @param[in] Die DF die on socket that the core is attached to
+ * @param[in] Ccd Logical CCD the core is on
+ * @param[in] Ccx Logical core complex
+ * @param[out] Domain Domain the core belongs to
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_DOMAIN_XLAT)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Ccd,
+ IN UINTN Ccx,
+ OUT UINT32 *Domain
+ );
+
+/**
+ * @brief Get physical numa domain information.
+ *
+ * @details Get physical numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfPhysDomainsInSystem Number of valid domains in the system
+ * @param[out] PhysDomainInfo An array with information about each physical domain
+ * @param[out] PhysNodesPerSocket Actual NPS as determined by ABL (not including SLink)
+ * @param[out] NumberOfSystemSLinkDomains Number of domains describing SLink connected memory
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfPhysDomainsInSystem,
+ OUT PHYS_DOMAIN_INFO **PhysDomainInfo,
+ OUT UINT32 *PhysNodesPerSocket,
+ OUT UINT32 *NumberOfSystemSLinkDomains
+ );
+
+/**
+ * @brief Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @details Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] RootPortBDF BDF for root-port bridge in PCI_ADDR format.
+ * @param[out] PxmDomainInfo Pointer to a structure returning associated NUMA node(s).
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN PCI_ADDR RootPortBDF,
+ OUT PXM_DOMAIN_INFO *PxmDomainInfo
+ );
+
+///
+/// When installed, the Fabric NUMA Services 2 Protocol produces a collection of
+/// services that return various information associated with non-uniform memory
+/// architecture.
+///
+struct _FABRIC_NUMA_SERVICES2_PROTOCOL {
+ UINTN Revision; ///< Revision Number
+ FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO GetDomainInfo; ///< Get Domain Info
+ FABRIC_NUMA_SERVICES2_DOMAIN_XLAT DomainXlat; ///< Domain Translation
+ FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO GetPhysDomainInfo; ///< Get Physical Domain Info
+ FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO GetPxmDomainInfo; ///< Get Proximity Domain Info
+};
+
+///
+/// Guid declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL.
+///
+extern EFI_GUID gAmdFabricNumaServices2ProtocolGuid;
+
+#pragma pack (pop)
+#endif // _FABRIC_NUMA_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
new file mode 100644
index 0000000000..485240c0fb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_TOPOLOGY_SERVICES2_H_
+#define FABRIC_TOPOLOGY_SERVICES2_H_
+
+#include <Library/BaseFabricTopologyLib.h>
+
+#endif // FABRIC_TOPOLOGY_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
new file mode 100755
index 0000000000..44093e4097
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
@@ -0,0 +1,23 @@
+/** @file
+ SoC Logical ID Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SOC_LOGICAL_ID_H_
+#define SOC_LOGICAL_ID_H_
+#pragma pack (push, 1)
+
+///
+/// SOC logical ID structure
+///
+typedef struct _SOC_LOGICAL_ID {
+ IN OUT UINT32 Family; ///< Indicates logical ID Family
+ IN OUT UINT16 Revision; ///< Indicates logical ID Revision
+} SOC_LOGICAL_ID;
+
+#pragma pack (pop)
+#endif // SOC_LOGICAL_ID_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
new file mode 100644
index 0000000000..a60ae20d33
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _INTERNAL_AML_LIB_H_
+#define _INTERNAL_AML_LIB_H_
+
+#include <Uefi.h>
+#include <Library/AmlGenerationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <IndustryStandard/Acpi.h>
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
new file mode 100644
index 0000000000..b19b6fe867
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -0,0 +1,150 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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/AgesaPkg/Include/AmdPcieComplex.h b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
new file mode 100755
index 0000000000..3a628ed0b2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
@@ -0,0 +1,432 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCIE_COMPLEX_H_
+#define AMD_PCIE_COMPLEX_H_
+
+//
+// GNB PCIe configuration info
+//
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+
+//
+// Port parameter count
+//
+#define PCIE_PORT_PARAMETER_COUNT 64
+
+///
+/// PCIe link initialization
+/// DXIO endpoint status
+///
+typedef enum {
+ DxioEndpointDetect = 0, ///< Detect endpoint presence
+ DxioEndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} DXIO_ENDPOINT_STATUS;
+
+#pragma pack(push,1)
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific port parameter to set.
+ UINT16 ParamValue; ///< Specifies the value to be assigned to port parameter.
+} PORT_PARAM;
+
+typedef struct {
+ PORT_PARAM PhyParam[PCIE_PORT_PARAMETER_COUNT]; ///< PHY port parameter
+} PORT_PARAMS;
+
+///
+/// Ancillary data struct with table size and address
+///
+typedef struct {
+ IN UINT32 Count; ///< Total count in this Ancillary data table
+ IN UINT32 Ovrd; ///< Ancillary data table address point to ANC_DATA_PARAM[]
+} ANC_DATA;
+
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific PHY parameter
+ UINT16 ParamValue; ///< This specifies the value to be assigned to indicated PHY parameter
+} DXIO_PHY_PARAM;
+
+typedef struct {
+ DXIO_PHY_PARAM PhyParam[44]; ///< physical parameter
+} PHY_DATA;
+
+///
+/// PCIe specific data structures
+/// PCIe port misc extended controls
+///
+typedef struct {
+ UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ UINT8 LinkSafeMode : 1; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through DXIO_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertize muximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ UINT8 ChannelType : 3; ///< Channel Type
+ ///< 0 - Channel Type Not Specified
+ ///< - Channel Type Short Trace
+ ///< 2 - Channel Type Long Trace
+ UINT8 TurnOffUnusedLanes : 1; ///< Turn Off Unused Lanes
+ ///< 0 - Turn on
+ ///< 1 - Turn off
+} DXIO_PORT_MISC_CONTROL;
+
+///
+/// The IO APIC Interrupt Mapping Info
+///
+typedef struct {
+ UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< 0 - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< 1 - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< 2 - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< ...
+ ///< 8 - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< 0 - ABCD
+ ///< 1 - BCDA
+ ///< 2 - CDAB
+ ///< 3 - DABC
+ UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< 0 - Entry 0 of IO APIC redirection table
+ ///< 1 - Entry 1 of IO APIC redirection table
+ ///< ...
+ ///< 31 - Entry 31 of IO APIC redirection table
+} DXIO_APIC_DEVICE_INFO;
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ UINT8 PortPresent : 1; ///< Enable PCIe port for initialization.
+ UINT8 Reserved1 : 2; ///< Reserved
+ UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ UINT8 FunctionNumber : 3; ///< Reserved for future use
+ UINT8 LinkSpeedCapability : 3; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ ///< 4 - Gen4
+ ///< 5 - Gen5
+ UINT8 AutoSpdChng : 2; ///< Upstread Auto Speed Change Allowed/
+ ///< 0 - Use default implementation (Disabled for Gen1, Enabled for Gen2/3)
+ ///< 1 - Always Disabled
+ ///< 2 - Always Enabled
+ ///< 3 - Reserved
+ UINT8 EqPreset : 4; ///< Gen3 Equalization Preset */
+ UINT8 LinkAspm : 2; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ UINT8 LinkAspmL1_1 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 LinkAspmL1_2 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 ClkReq : 4; ///< ASPM Reserved Field
+ ///< 0 - NONE
+ ///< 1 - CLKREQ0 signal
+ ///< 2 - CLKREQ1 signal
+ ///< 3 - CLKREQ2 signal
+ ///< 4 - CLKREQ3 signal
+ ///< 5 - CLKREQG signal
+ UINT8 LinkHotplug : 4; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ UINT8 SlotPowerLimit; ///< PCIe slot power limit.
+ UINT8 SlotPowerLimitScale : 2; ///< PCIe slot power limit Scale.
+ ///< 00b = 1.0x
+ ///< 01b = 0.1x
+ ///< 10b = 0.01x
+ ///< 11b = 0.001x
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 Gen4Features : 5; ///< Unused bits
+ ///< BIT0(DLF_Exchange) 1 - Disable, 0 - Enable
+ ///< IT1(DLF_Capability) 1 - Disable, 0 - Enable
+ UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_NUM
+ UINT16 CsLink : 3; ///< Reserved
+ DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ DXIO_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 EsmControl : 1; ///< Enhanced speed mode control
+ UINT8 CcixControl : 1; ///< Ccix/Cxl control
+ UINT8 TxVetting : 1; ///< Tx Vetting
+ UINT8 RxVetting : 1; ///< Rx Vetting
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+ UINT8 NtbHotplug : 1; ///< NTB Hotplug flag
+ ///< 0b = Disabled
+ ///< 1b = Enabled
+ UINT8 Reserved2 : 1; ///< Reserved
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 Reserved3 : 5; ///< Reserved
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset
+ UINT8 Reserved4 : 4; ///< Reserved
+ UINT16 PsppPolicyDC; ///< Pspp DC control
+ UINT16 PsppPolicyAC; ///< PSPP AC control
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+ UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass phase2/3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 DXIO deemphasis default
+ UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemphasis setting
+ UINT8 Reserved5 : 3; ///< Reserved
+ struct {
+ UINT16 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT16 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT16 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT16 Reserved1 : 2; ///< Unused bits
+ UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downstream Tx Preset
+ UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downstream Rx Preset Hint
+ UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstream Tx Preset
+ UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstream Rx Preset Hint
+ UINT8 Reserved2 : 4; ///< Unused bits
+ } LaneEqualizationCntl; ///< Lane equalization control structure used for Gen3 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen4LaneEqualizationCntl; ///< Lane equalization control structure used for Gen4 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen5LaneEqualizationCntl; ///< Lane equalization control structure used for Gen5 values
+ struct {
+ UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT.
+ UINT32 PresetMask16Gt : 10; ///< Preset Mask 16GT.
+ UINT32 PresetMask32Gt : 10; ///< Preset Mask 32GT.
+ UINT32 Reserved1 : 2; ///< Unused bits
+ UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT Set
+ UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16GT Set
+ UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32GT Set
+ UINT8 Reserved2 : 5; ///< Unused bits
+ } PresetMaskCntl; ///< Preset Mask control structure used for Gen3/Gen4/Gen5 values
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equalization
+ UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equalization
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enable 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 IsBmcLocation : 1; ///< IsBmcLocation
+ UINT8 SetEsmControl : 1; ///< Set ESM Control
+ UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump for ESM
+ UINT8 Reserved6 : 1; ///< Unused bits
+ UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 Reserved7 : 1; ///< Unused bits
+ UINT16 NpemEnable : 12; ///< Controls NPEM Enable
+ UINT16 Reserved8 : 4; ///< Unused bits
+ UINT16 NpemCapability : 12; ///< Controls NPEM Capability
+ UINT8 SwingMode : 3; ///< PCIe Swing Mode
+ UINT16 Reserved9 : 1; ///< Unused bits
+ UINT16 MpioAncDataIdx; ///< Reserved for internal use only
+ UINT8 Reserved10; ///< Reserved bits
+} DXIO_PORT_DATA;
+
+///
+/// EtherNet specific data structures
+///
+typedef struct {
+ UINT32 PortNum : 8; ///< Port Number
+ UINT32 PlatConf : 4; ///< Platform Config
+ ///< 0 = Reserved
+ ///< 1 = 10G/1G BackPlane
+ ///< 2 = 2.5G BackPlane
+ ///< 3= Soldered down 1000Base-T
+ ///< 4 = Soldered down 1000Base-X
+ ///< 5 = Soldered down NBase-T
+ ///< 6 = Soldered down 10GBase-T
+ ///< 7 = Soldered down 10GBase-r
+ ///< 8 = SFP+ Connector
+ UINT32 Reserved1 : 4; ///< Unused 12-15
+ UINT32 MdioId : 5; ///< MDIO ID when MDIO Side band is used
+ UINT32 Reserved2 : 2; ///< Unused 21-22
+ UINT32 SuppSpeed : 4; ///< Supported Speeds by Platform
+ ///< 1 = 100M Supported
+ ///< 2 = 1G Supported
+ ///< 4 = 2.5G Supported
+ ///< 8 = 10G Supported
+ UINT32 Reserved3 : 1; ///< Unused 27
+ UINT32 ConnType : 3; ///< Supported Speeds by Platform
+ ///< 0 = Port not Used
+ ///< 1 = SFP+ Connection I2C interface
+ ///< 2 = MDIO PHY
+ ///< 4 = Backplane Connection
+ UINT32 Reserved4 : 1; ///< Unused 31
+} ETH_PORT_PROPERTY0;
+
+typedef struct {
+ UINT32 MdioReset : 2; ///< MDIO Reset Type
+ ///< 0 = None
+ ///< 1 = I2C GPIO
+ ///< 2 = Integrated GPIO
+ ///< 3 = Reserved
+ UINT32 Reserved1 : 2; ///< Unused 2-3
+ UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO number for reset
+ UINT32 Reserved2 : 2; ///< Unused 6-7
+ UINT32 SfpGpioAdd : 3; ///< Lower I2C address of GPIO Expander PCA9535
+ UINT32 Reserved3 : 1; ///< Unused 11
+ UINT32 TxFault : 4; ///< TX FAULT
+ UINT32 Rs : 4; ///< RS Signal
+ UINT32 ModAbs : 4; ///< MOD_ABS signal
+ UINT32 RxLoss : 4; ///< Rx_LOS signal
+ UINT32 SfpGpioMask : 4; ///< SFP+ sideband signals that are not supported by platform
+} ETH_PORT_PROPERTY3;
+
+typedef struct {
+ UINT32 SfpMux : 3; ///< Lower address of Mux PCA 9545
+ UINT32 Reserved1 : 1; ///< Unused 3
+ UINT32 SfpBusSeg : 3; ///< SFP BUS Segment. Downstream channels of PCA9545
+ UINT32 Reserved2 : 1; ///< Unused 7
+ UINT32 SfpMuxUpAdd : 5; ///< Upper address of Mux PCA 9545
+ UINT32 Reserved3 : 3; ///< Unused 13-15
+ UINT32 RedriverAddress : 7; ///< Address of ReDriver
+ UINT32 RedriverInterface : 1; ///< ReDriver Interface Descriptor
+ UINT32 RedriverLane : 3; ///< ReDriver Lane number
+ UINT32 Reserved4 : 1; ///< Unused 27
+ UINT32 RedriverModel : 3; ///< ReDriver Model
+ UINT32 RedriverPresent : 1; ///< Redriver Present
+} ETH_PORT_PROPERTY4;
+
+typedef struct {
+ UINT32 TxEqPre : 6; ///< TX EQ PRE
+ UINT32 Reserved1 : 2; ///< Unused 7-6
+ UINT32 TxEqMain : 6; ///< TX EQ MAIN
+ UINT32 Reserved2 : 2; ///< Unused 15-14
+ UINT32 TxEqPost : 6; ///< TX EQ POST
+ UINT32 Reserved3 : 10; ///< Unused 31-23
+} ETH_PORT_TXEQ;
+/// Ethernet PCIe port configuration data
+///
+typedef struct {
+ ETH_PORT_PROPERTY0 EthPortProp0; ///< XGBE_PORT_PROPERTY_0
+ ETH_PORT_PROPERTY3 EthPortProp3; ///< XGBE_PORT_PROPERTY_3
+ ETH_PORT_PROPERTY4 EthPortProp4; ///< XGBE_PORT_PROPERTY_4
+ UINT32 PadMux0; ///< PadMux0 Setting (8 bits)
+ UINT32 PadMux1; ///< PadMux1 Setting (8 bits)
+ UINT32 MacAddressLo; ///< Lower 32 bits of MAC Address
+ UINT32 MacAddressHi; ///< Upper 32 bits of MAC Address
+ ETH_PORT_TXEQ EthPortTxEq; ///< TX EQ Settings
+} ETHERNET_PORT_DATA;
+
+///
+/// High level data structures for passing topology from platform to AGESA
+///
+typedef struct {
+ UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ UINT8 HotPluggable : 1; ///< HotPluggable
+ ///< 0 - Link is NOT Hot-Switchable
+ ///< 1 - Link IS Hot-Switchable
+ UINT8 Reserved1 : 7; ///< Unused field, leave as 0
+ UINT8 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 GpioGroupId; ///< Unique identifier for the GPIO or GPIO group associated with
+ ///< this engine. GPIOs are used for hotplug notification and link
+ ///< type (e.g SATA Express or PCIe)
+ UINT8 DxioStartLane; ///< Internal coding of start lane
+ UINT8 DxioEndLane; ///< Internal coding of end lane
+ UINT8 SearchDepth; ///< SearchDepth only uses 1 bit - always initialize to 0 will be updated dynamically
+} DXIO_ENGINE_DATA;
+
+///
+/// PCIe port descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in complex
+ DXIO_ENGINE_DATA EngineData; ///< Engine data
+ DXIO_PORT_DATA Port; ///< PCIe port specific configuration info
+ ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for EtherNet
+ PHY_DATA Phy; ///< Ancillary data for PHY programming customization
+ PORT_PARAMS PortParams; ///< Extensible port parameter list for simplified topology structure
+ ANC_DATA AncData; ///< Ancillary data override
+} DXIO_PORT_DESCRIPTOR;
+
+#pragma pack(pop)
+
+///
+///
+/// PCIe Complex descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR *PciePortList; ///< Pointer to array of PCIe port descriptors or NULL (Last element of array must be terminated with DESCRIPTOR_TERMINATE_LIST).
+ VOID *Reserved2; ///< Reserved for future use
+ UINT8 BmcLinkLocation; ///< Identifies the socket/die location of a BMC link (Used by AGESA, input not required)
+ UINT8 BmcLinkLaneNum; ///< Identifies the socket/die location of a BMC Lane number
+ UINT8 Reserved3[2]; ///< Reserved for future
+} DXIO_COMPLEX_DESCRIPTOR;
+
+///
+/// Engine descriptor type
+///
+typedef enum {
+ DxioUnusedEngine = 0, ///< Unused descriptor Excluded from configuration
+ DxioPcieEngine = 1, ///< PCIe port
+ DxioUSBEngine = 2, ///< USB port
+ ///< __Deprecated__
+ DxioSATAEngine = 3, ///< SATA
+ DxioUSB_OVER_PCIE = 4, ///< USB4 PCIe (internal use only)
+ DxioUBMHFCEngine = 5, ///< New for Genoa UBM HFC Connector for auto-discovery
+ DxioOCP3Engine = 6, ///< New for Genoa OCP3 Bifurcatable Connector
+ DxioUdot3Engine = 7, ///< New for Genoa U.3 Multiprotocol Connector
+ DxioDPEngine = 8, ///< Digital Display __For APU display connector list__
+ DxioEthernetEngine = 0x10, ///< Ethernet (GBe, XGBe)
+ ///< __Deprecated__
+ DxioGOPEngine = 0x20, ///< GOP
+ ///< __Deprecated__
+ DxioNTBDevice = 0x60, ///< For NBIF NTB Enable (internal use only)
+ DxioHDaudioEngine, ///< For NBIF HDaudtio Enable (internal use only)
+ DxioACPEngine, ///< For NBIF ACP Enable (internal use only)
+ DxioMP2Engine, ///< For NBIF MP2 Enable (internal use only)
+ DxioMaxPcieEngine ///< Max engine type for boundary check.
+} DXIO_ENGINE_TYPE;
+
+///
+/// PCIe link speeds
+///
+typedef enum {
+ DxioGenMaxSupported, ///< Maximum supported
+ DxioGen1 = 1, ///< Gen1
+ DxioGen2, ///< Gen2
+ DxioGen3, ///< Gen3
+ DxioGen4, ///< Gen4
+ DxioGen5, ///< Gen5
+ MaxDxioGen ///< Max Gen for boundary check
+} DXIO_LINK_SPEEDS;
+#endif // AMD_PCIE_COMPLEX_H_
diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
new file mode 100644
index 0000000000..d62f260235
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
@@ -0,0 +1,17 @@
+/** @file
+
+ Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_SOC_H_
+#define _AMD_SOC_H_
+
+#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
+#endif // _AMD_SOC_H_
diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
new file mode 100644
index 0000000000..2291f7dc83
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
@@ -0,0 +1,42 @@
+/** @file
+ Fabric resource manager common definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_CMN_H_
+#define FABRIC_RESOURCE_MANAGER_CMN_H_
+#pragma pack (push, 1)
+
+#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets in system.
+#define MAX_RBS_PER_SOCKET 20 ///< Max number of root bridges per socket.
+
+/**
+ * @brief DF address aperture structure.
+ * @details This contains information used to define an MMIO region.
+ */
+typedef struct _FABRIC_ADDR_APERTURE {
+ UINT64 Base; ///< Aperture base Address.
+ UINT64 Size; ///< Aperture size.
+ UINT64 Alignment; ///< Alignment bit map. 0xFFFFF means 1MB align.
+} FABRIC_ADDR_APERTURE;
+
+/**
+ * @brief DF Resource for each RootBridge structure.
+ * @details This contains information used to define the MMIO region for each RootBridge.
+ */
+typedef struct _FABRIC_RESOURCE_FOR_EACH_RB {
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second nonprefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second prefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE IO[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< IO resource(s) @see FABRIC_ADDR_APERTURE
+ UINT16 PciBusNumber[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< PCI bus number(s).
+} FABRIC_RESOURCE_FOR_EACH_RB;
+#pragma pack (pop)
+#endif // FABRIC_RESOURCE_MANAGER_CMN_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
new file mode 100644
index 0000000000..9e58f299b4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
@@ -0,0 +1,96 @@
+/** @file
+ AMD Memory Info Hob Definition
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_MEMORY_INFO_HOB_H_
+#define AMD_MEMORY_INFO_HOB_H_
+
+/**
+ * @brief 128 bit Buffer containing UID Unique Identifier value for Memory Info HOB.
+ * EFI_GUID defined in UefiBaseType.h
+ */
+extern EFI_GUID gAmdMemoryInfoHobGuid;
+
+#pragma pack (push, 1)
+
+/**
+ * @brief Memory descriptor structure for each memory range
+ */
+typedef struct {
+ UINT64 Base; ///< Base address of memory rang
+ UINT64 Size; ///< Size of memory rang
+ UINT32 Attribute; ///< Attribute of memory rang
+ UINT32 Reserved; ///< For alignment purpose
+} AMD_MEMORY_RANGE_DESCRIPTOR;
+
+/**
+ * @brief Memory attribute in the memory range descriptor = AVAILABLE
+ */
+#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1
+
+/**
+ * @brief Memory attribute in the memory range descriptor = UMA
+ */
+#define AMD_MEMORY_ATTRIBUTE_UMA 0x2
+
+/**
+ * @brief Memory attribute in the memory range descriptor = MMIO
+ */
+#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPUMEM
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_SP
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED_TMR
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED_SMUFEATURES
+ */
+#define AMD_MEMORY_ATTRIBUTE_Reserved_SmuFeatures 0x9
+
+/// Memory info HOB structure
+typedef struct {
+ UINT32 Version; ///< Version of HOB structure
+ BOOLEAN AmdMemoryVddioValid; ///< This field determines if Vddio is valid
+ UINT16 AmdMemoryVddio; ///< Vddio Voltage
+ BOOLEAN AmdMemoryVddpVddrValid; ///< This field determines if VddpVddr is valid
+ UINT8 AmdMemoryVddpVddr; ///< VddpVddr voltage
+ BOOLEAN AmdMemoryFrequencyValid; ///< Memory Frequency Valid
+ UINT32 AmdMemoryFrequency; ///< Memory Frquency
+ UINT32 AmdMemoryDdrMaxRate; ///< Memory DdrMaxRate
+ UINT32 NumberOfDescriptor; ///< Number of memory range descriptor
+ AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory ranges array
+} AMD_MEMORY_INFO_HOB;
+
+#pragma pack (pop)
+
+/**
+ * @brief Macro that defines the Memory Info HOB version
+ */
+#define AMD_MEMORY_INFO_HOB_VERISION 0x00000110ul // Ver: 00.00.01.10
+
+#endif // AMD_MEMORY_INFO_HOB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
new file mode 100644
index 0000000000..d144a4ad20
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
@@ -0,0 +1,51 @@
+/** @file
+ AMD Psp Base Lib
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_BASELIB_V2_H_
+#define AMD_PSP_BASELIB_V2_H_
+
+#include <AmdPspDirectory.h>
+
+#define MAX_IMAGE_SLOT_COUNT 32
+
+#define ALIGNMENT_4K BASE_4KB
+#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1)) == 0)
+#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K)
+
+#define IS_VALID_ADDR32(addr) (((UINT32)(addr) != 0) && (UINT32)(addr) != 0xFFFFFFFF)
+
+#pragma pack (push, 1)
+
+#define FIRMWARE_TABLE_SIGNATURE 0x55AA55AAul
+
+/// Define the structure OEM signature table
+typedef struct _FIRMWARE_ENTRY_TABLEV2 {
+ UINT32 Signature; ///< 0x00 Signature should be 0x55AA55AAul
+ UINT32 ImcRomBase; ///< 0x04 Base Address for Imc Firmware
+ UINT32 GecRomBase; ///< 0x08 Base Address for Gmc Firmware
+ UINT32 XHCRomBase; ///< 0x0C Base Address for XHCI Firmware
+ UINT32 LegacyPspDirBase; ///< 0x10 Base Address of PSP directory
+ UINT32 PspDirBase; ///< 0x14 Base Address for PSP directory
+ UINT32 Reserved1; ///< 0x18 Base Address for Reserved BIOS directory
+ UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS directory
+ UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS directory
+ UINT32 Config; ///< 0x24 reserved for EFS Configuration
+ UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all program
+ UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for all programs
+} FIRMWARE_ENTRY_TABLEV2;
+
+/// It also used as structure to store ISH generic information across programs
+typedef struct {
+ UINT32 Priority;
+ UINT32 UpdateRetries;
+ UINT32 GlitchRetries;
+ UINT32 ImageSlotAddr;
+} IMAGE_SLOT_HEADER;
+
+#pragma pack (pop)
+
+#endif // AMD_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
new file mode 100644
index 0000000000..23c90b65c2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
@@ -0,0 +1,83 @@
+/** @file
+ AMD Psp Ftpm Library header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_LIB_H_
+#define PSP_FTPM_LIB_H_
+#include <IndustryStandard/Acpi30.h>
+
+/* SYSTEM_TPM_CONFIG_VAL
+ * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG
+ */
+typedef enum {
+ SYSTEM_TPM_CONFIG_DTPM = 0x00, ///< dTPM
+ SYSTEM_TPM_CONFIG_PSP_FTPM = 0x01, ///< PSP FTPM
+ SYSTEM_TPM_CONFIG_HSP_FTPM = 0x02, ///< HSP FTPM
+ SYSTEM_TPM_CONFIG_NONE = 0xFF, ///< None of TPM
+} SYSTEM_TPM_CONFIG_VAL;
+
+#pragma pack (push, 1)
+/// Define TPM_2_CONTROL_AREA
+typedef struct {
+ // Interface Identifier
+ volatile UINT64 InterfaceIdentifier; ///< Interface Identifier
+ // TPM2 Control Area Extension
+ volatile UINT32 Clear; ///< Clear
+ volatile UINT32 RemainingBytes; ///< RemainingBytes
+ volatile UINT32 StatusReserved; ///< StatusReserved
+ volatile UINT32 StatusError; ///< StatusError
+ volatile UINT32 StatusCancel; ///< StatusCancel
+ volatile UINT32 StatusStart; ///< StatusStart
+ UINT64 InterruptControl; ///< InterruptControl
+ UINT32 CommandSize; ///< CommandSize
+ EFI_PHYSICAL_ADDRESS CommandAddress; ///< CommandAddress
+ UINT32 ResponseSize; ///< ResponseSize
+ EFI_PHYSICAL_ADDRESS ResponseAddress; ///< ResponseAddress
+ // Memory Absent command/response buffer
+ volatile UINT32 CmdRespHWBuffer; ///< Cmd/Rsp HW Buffer
+} TPM2_CONTROL_AREA;
+
+#pragma pack (pop)
+
+/**
+ GET TPM related Info
+
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+EFI_STATUS
+FtpmGetInfo (
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Execute a TPM command
+
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+EFI_STATUS
+FtpmExecuteCommand (
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+#endif //PSP_FTPM_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
new file mode 100644
index 0000000000..4ad4020f95
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
@@ -0,0 +1,231 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PSP_ROM_ARMOR_LIB_H_
+#define _PSP_ROM_ARMOR_LIB_H_
+
+#include "Uefi.h"
+
+#define PSP_MAX_SPI_CMD_SUPPORT (4) ///< Max number of SPI command support
+#define PSP_MAX_SPI_DATA_BUFFER_SIZE (72) ///< Max SPI Command Data Buffer Size
+#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list allowed command array number support
+#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list allowed region array number support
+
+#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chip selects
+#define SPI_CHIP_SELECT_1 (1) ///< Chip Select 1
+#define SPI_CHIP_SELECT_2 (2) ///< Chip Select 2
+
+#define SPI_COMMAND_FREQUENCY_66_66MHZ (0) ///< 0=66.66MHz
+#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=33.33MHz
+#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=22.22MHz
+#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=16.66MHz
+#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=100MHz
+#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=800KHz
+
+#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 = Command not examined/processed
+#define SPI_COMMAND_COMPLETED (1) ///< 1 = Command completed successfully
+#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 = Execution Error (i.e. timeout)
+#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 = Command not allowed by Whitelist
+#define SPI_COMMAND_MALFORMED (4) ///< 4 = Command malformed
+
+#pragma pack (push, 1)
+
+typedef struct {
+ UINT8 ChipSelect; ///< 1 = CS1, 2 = CS2, all other values illegal
+
+ UINT8 Frequency; ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Does not include the
+ ///< SPI Opcode byte, but does include the address, dummy bytes, and
+ ///< data.
+
+ UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx + BytesToRx <= 72
+
+ UINT8 OpCode; ///< The SPI Command OpCode (the first byte sent by the SPI controller)
+
+ UINT8 Reserved[3]; ///< Reserved for future expansion
+
+ UINT8 Buffer[PSP_MAX_SPI_DATA_BUFFER_SIZE]; ///< The remaining 0-72 bytes sent/received by the SPI controller.
+ ///<
+ ///< The SPI Controller will
+ ///< 1. Assert the ChipSelect
+ ///< 2. Send the one byte OpCode
+ ///< 3. Send Buffer[0] to Buffer[BytesToTx-1] to the SPI device
+ ///< 4. Read BytesToRx bytes from the device into Buffer[BytesToTx] to
+ ///< Buffer[BytesToTx+BytesToRx-1]
+ ///< 5. Deassert the ChipSelect line
+ ///<
+ ///< SPI ROM Commands that include a target address send the address
+ ///< immediately after the OpCode (i.e. Buffer[0..2] or Buffer[0..3]
+ ///< depending if 24 or 32bit addresses are associated with the OpCode).
+ ///< See the SPI ROM Device's datasheet for full details on your
+ ///< devices commands and formats.
+} SPI_COMMAND; ///< The struct of Spi Command
+
+typedef union {
+ struct {
+ ///< SPI_COMMUNICATION_RESULT
+ UINT16 Command0Result : 4; ///< Result[ 3: 0] The result of Command[0]
+ UINT16 Command1Result : 4; ///< Result[ 7: 4] The result of Command[1]
+ UINT16 Command2Result : 4; ///< Result[11: 8] The result of Command[2]
+ UINT16 Command3Result : 4; ///< Result[15:12] The result of Command[3]
+ } Field; ///< the struct type of Command0 ~ Command4
+ UINT16 Value; ///< 16 bit value of Command0 ~ Command4
+} SPI_COMMUNICATION_RESULT; ///< The union struct type of Spi Communication Result
+
+typedef struct {
+ UINT8 ReadyToRun; ///< Set to FALSE by x86 while the buffer is being constructed. Set to
+ ///< TRUE by x86 as the last step in building the communication buffer,
+ ///< just before x86 rings the PSP doorbell.
+ ///<
+ ///< Set to FALSE by PSP after the PSP copies the buffer from DRAM to
+ ///< private SRAM.
+
+ UINT8 CommandCount; ///< Number of commands to execute, Valid Values 1-4
+
+ SPI_COMMUNICATION_RESULT SpiCommunicationResult; ///< Set to zero by x86 when the buffer is built. Atomically set to a
+ ///< non-zero value by the PSP to indicate the PSP has finished
+ ///< processing the requests in the communication buffer. The specific
+ ///< value written by the PSP provides per command results
+ ///<
+ ///< Result values with special meaning:
+ ///< 0x0000 = (written by x86) PSP has not finished handling the request
+ ///< 0x1000 = PSP determined the request is malformed (invalid
+ ///< CommandCount, chipselect, BytesToRx/Tx, etc)
+ ///< 0x2000, 0x3000, 0x4000, ... , 0xF000 = Reserved for future errors
+ ///<
+ ///< Generic Result values:
+ ///< SpiCommunicationResult[ 3: 0] The result of Command[0]
+ ///< SpiCommunicationResult[ 7: 4] The result of Command[1]
+ ///< SpiCommunicationResult[11: 8] The result of Command[2]
+ ///< SpiCommunicationResult[15:12] The result of Command[3]
+ ///< 0 = Command not examined/processed
+ ///< 1 = Command completed successfully
+ ///< 2 = Execution Error (i.e. timeout)
+ ///< 3 = Command not allowed by Whitelist
+ ///< 4 = Command malformed
+ ///< 5-15 = reserved for future use
+ ///<
+ ///< Examples of Generic Results:
+ ///< 0x0000 - PSP has not finished the request
+ ///< 0x0001 - PSP ran Command0 successfully, and is now idle
+ ///< 0x0111 - PSP ran Command0/1/2 successfully and is now idle
+ ///< 0x0031 - PSP ran Command0, but Command1 was blocked by whitelist
+
+ SPI_COMMAND SpiCommand[PSP_MAX_SPI_CMD_SUPPORT]; ///< Spi command array
+} SPI_COMMUNICATION_BUFFER; ///< The struct type of Spi Communication Buffer
+
+typedef struct {
+ UINT8 ChipSelect; ///< 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+
+ UINT8 Frequency; ///< The allowed frequency for the command
+ ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 OpCode; ///< The allowed commands opcode
+
+ UINT8 MinTx; ///< The minimum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+ UINT8 MaxTx; ///< The maximum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+
+ UINT8 MinRx; ///< The minimum range of allowed Rx byte counts
+ UINT8 MaxRx; ///< The maximum range of allowed Rx byte counts
+
+ UINT8 AddrChkMethod; ///< 0=No address verification performed
+ ///< 1=Treat Buffer[0-2] as a 24-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+ ///< 2=Treat Buffer[0-3] as a 32-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+
+ UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned power of two sized block
+ ///< of addresses that may be impacted by a given SPI Command. For
+ ///< example, a sector erase command targeted at an address within a
+ ///< 64K block will impact every byte within that 64K block. Likewise
+ ///< a page program SPI command (i.e. write) may impact many bytes
+ ///< within the targeted 256/512 byte page due to page wrap-around, but
+ ///< no bytes outside the page. The ImapctSize field specifies the power
+ ///< of two size of the ImpactZone for this command. If VerifyAddress is
+ ///< zero (no checking) this field must also be zero, otherwise this
+ ///< field must be a power of two between 256 and 64MB (256, 512, ...,
+ ///< 67108864). NOTE: When setting this field, carefully examine your
+ ///< device's datasheet.
+ ///<
+} WHITE_LIST_ALLOWED_COMMAND; ///< The struct type of White List Allowed Command
+
+typedef struct {
+ // 8 bytes
+ UINT32 StartAddress; ///< LSB must be 0x00, bit31 identifies a chipselect: 0=CS1, 1=CS2
+ UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be less than EndAddress
+} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed Region
+
+typedef struct {
+ UINT8 AllowedCmdCount; ///< Allow Command Count
+ UINT8 AllowedRegionCount; ///< Allow Region Count
+ WHITE_LIST_ALLOWED_COMMAND WhitelistAllowedCommands[PSP_MAX_WHITE_LIST_CMD_NUM]; ///< White List Allowed Command Table
+ WHITE_LIST_ALLOWED_REGION WhitelistAllowedRegions[PSP_MAX_WHITE_LIST_REGION_NUM]; ///< White List Allowed Region Table
+} SPI_WHITE_LIST; ///< The struct type of Spi White List
+
+#pragma pack (pop)
+
+/**
+ * @brief Request secures the SPI Controller
+ *
+ * @param[in,out] SpiCommunicationBuffer Spi Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN OUT SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ );
+
+/**
+ * @brief Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI white list structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ );
+
+/**
+ * @brief Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ );
+
+/**
+ * @brief Request PSP firmware switch SPI controller chip select.
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ );
+
+#endif //_PSP_ROM_ARMOR_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
new file mode 100644
index 0000000000..0189910bd1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
@@ -0,0 +1,2722 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AML_LIB_H_
+#define AML_LIB_H_
+
+#include <Uefi.h>
+#include <IndustryStandard/Acpi.h>
+
+typedef enum {
+ AmlStart,
+ AmlClose,
+ AmlInvalid
+} AML_FUNCTION_PHASE;
+
+#define AML_OBJECT_INSTANCE_SIGNATURE SIGNATURE_32 ('a', 'm', 'l', 'o')
+
+//
+// Device Status Bitmap (Section 6.3.7 ACPI version 6.3)
+// Bit [0] - Set if the device is present.
+// Bit [1] - Set if the device is enabled and decoding its resources.
+// Bit [2] - Set if the device should be shown in the UI.
+// Bit [3] - Set if the device is functioning properly (cleared if device
+// failed its diagnostics).
+// Bit [4] - Set if the battery is present.
+// Bits [31:5] - Reserved (must be cleared).
+//
+#define DEVICE_PRESENT_BIT 0x0001
+#define DEVICE_ENABLED_BIT 0x0002
+#define DEVICE_IN_UI_BIT 0x0004
+#define DEVICE_HEALTH_BIT 0x0008
+#define DEVICE_BATTERY_BIT 0x0010 // Control Method Battery Device Only
+
+typedef enum {
+ UnknownObj,
+ IntObj,
+ StrObj,
+ BuffObj,
+ PkgObj,
+ FieldUnitObj,
+ DeviceObj,
+ EventObj,
+ MethodObj,
+ MutexObj,
+ OpRegionObj,
+ PowerResObj,
+ ProcessorObj,
+ ThermalZoneObj,
+ BuffFieldObj,
+ DDBHandlObj,
+ InvalidObj
+} OBJECT_TYPE_KEYWORD;
+
+typedef struct {
+ UINT32 Signature;
+ BOOLEAN Completed;
+ UINTN DataSize;
+ UINT8 *Data;
+ LIST_ENTRY Link;
+} AML_OBJECT_INSTANCE;
+
+// ***************************************************************************
+// AML defines to be consistent with already existing
+// MdePkg/Include/IndustryStandard/Acpi*.h defines.
+// *** These could be upstreamed at some point.
+// ***************************************************************************
+// Limits of (DWord|Word|QWord)Space ResourceType
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MIN 0xC0
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MAX 0xFF
+
+// General Flags: Flags that are common to all resource types
+// Bits[7:4] Reserved(must be 0)
+// Bit[3] Max Address Fixed, _MAF:
+// 1 The specified maximum address is fixed
+// 0 The specified maximum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED (1 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED (0 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MAF EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+// Bit[2] Min Address Fixed, _MIF:
+// 1 The specified minimum address is fixed
+// 0 The specified minimum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED (1 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED (0 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MIF EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+// Bit[1] Decode Type, _DEC:
+// 1 This bridge subtractively decodes this address(top level bridges only)
+// 0 This bridge positively decodes this address
+#define EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE (1 << 1)
+#define EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE (0 << 1)
+#define EFI_ACPI_GENERAL_FLAG_MASK_DEC EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+// Bit[0] Consumer / Producer:
+// 1 This device consumes this resource
+// 0 This device produces and consumes this resource
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER (1 << 0)
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER (0 << 0)
+#define EFI_ACPI_GENERAL_FLAG_MASK_USAGE EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+
+// Memory Resource Flag (Resource Type = 0) DefinitionsBits
+// Memory Resource Flag Masks
+// Bits[7:6] Reserved(must be 0)
+// Bit[5] Memory to I/O Translation, _TTP:
+// 0 TypeStatic
+// 1 Type Translation
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_TTP (1 << 5)
+// Bit[4:3] Memory Attributes, _MTP:
+// 0 AddressRangeMemory
+// 1 AddressRangeReserved
+// 2 AddressRangeACPI
+// 3 AddressRangeNVS
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MTP (3 << 3)
+// Bit[2:1] Memory Attributes, _MEM:
+// 0 The memory is non-cacheable
+// 1 The memory is cacheable
+// 2 The memory is cacheable and supports write-combining
+// 3 The memory is cacheable and prefetchable
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM (3 << 1)
+// Bit[0] Write Status, _RW:
+// 0 This memory range is read-only
+// 1 This memory is read-write
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW (1 << 0)
+
+// I/O Resource Flag (Resource Type = 1) DefinitionsBits
+// I/O Resource Flags
+// Bit [7:6] Reserved (must be 0)
+// Bit [5] Sparse Translation, _TRS. This bit is only meaningful if Bit [4] is set.
+// 1 SparseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = (((port & 0xFFFc) << 10) || (port & 0xFFF)) + _TRA In the address
+// used to access the I/O port, bits[11:2] must be identical to bits[21:12],
+// this gives four bytes of I/O ports on each 4 KB page.
+// 0 DenseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = port + _TRA
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_SPARSE_TRANSLATION (1 << 5)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_DENSE_TRANSLATION (0 << 5)
+// Bit [4] I/O to Memory Translation, _TTP
+// 1 TypeTranslation: This resource, which is I/O on the secondary side of the
+// bridge, is memory on the primary side of the bridge.
+// 0 TypeStatic: This resource, which is I/O on the secondary side of the
+// bridge, is also I/O on the primary side of the bridge.
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION (1 << 4)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC (0 << 4)
+// Bit [3:2] Reserved (must be 0)
+// Bit [1:0] _RNG
+// 3 Memory window covers the entire range
+// 2 ISARangesOnly. This flag is for bridges on systems with multiple bridges.
+// Setting this bit means the memory window specified in this descriptor is
+// limited to the ISA I/O addresses that fall within the specified window. The
+// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. This bit can
+// only be set for bridges entirely configured throughACPI namespace.
+// 1 NonISARangesOnly. This flag is for bridges on systems with multiple
+// bridges. Setting this bit means the memory window specified in this
+// descriptor is limited to the non-ISA I/O addresses that fall within the
+// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7FF,
+// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entirely
+// configured through ACPI namespace.
+// 0 Reserved
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE (3 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY (2 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY (1 << 0)
+
+#define AML_OBJECT_INSTANCE_FROM_LINK(a) BASE_CR (a, AML_OBJECT_INSTANCE, Link)
+
+// Method Serialize Flag Values
+typedef enum {
+ NotSerialized,
+ Serialized,
+ FlagInvalid
+} METHOD_SERIALIZE_FLAG;
+// AccessField Access Attrib Flags.
+// Ref ACPI spec 6.3
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL 0x00
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK 0x02
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE 0x04
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE 0x06
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD 0x08
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK 0x0A
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES 0x0B
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL 0x0C
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL 0x0D
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES 0x0E
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES 0X0F
+
+// AccessField access types
+typedef enum {
+ AnyAcc,
+ ByteAcc,
+ WordAcc,
+ DWordAcc,
+ QWordAcc,
+ BufferAcc,
+} EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS;
+
+// Field lock rules
+typedef enum {
+ NoLock,
+ Lock
+} EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS;
+
+// Field update rules
+typedef enum {
+ Preserve,
+ WriteAsOnes,
+ WriteAsZeros
+} EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS;
+
+// Field access attributes. for AttribBytes, AttribRawBytes and AttribRawProcessBytes
+// the ExtendedAccessField definition is used, as this is what iASL compiles into, rather
+// than the AccessField that is specified in the ACPI spec.
+typedef enum {
+ AttribNormal = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL,
+ AttribQuick = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK,
+ AttribSendReceive = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE,
+ AttribByte = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE,
+ AttribWord = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD,
+ AttribBlock = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK,
+ AttribBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES,
+ AttribProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL,
+ AttribBlockProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL,
+ AttribRawBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES,
+ AttribRawProcessBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
+} EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS;
+
+//
+// Resource Type Specific Flags
+// Ref ACPI specification 6.4.3.5.5
+//
+//
+// DMA Information
+// Ref ACPI specification 6.4.2.2
+//
+// DmaType values
+typedef enum {
+ Compatibility = EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY,
+ TypeA = EFI_ACPI_DMA_SPEED_TYPE_A,
+ TypeB = EFI_ACPI_DMA_SPEED_TYPE_B,
+ TypeF = EFI_ACPI_DMA_SPEED_TYPE_F
+} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS;
+
+// IsBusMaster values
+typedef enum {
+ NotBusMaster = 0,
+ BusMaster = EFI_ACPI_DMA_BUS_MASTER
+} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS;
+
+// DmaTransferSize values
+typedef enum {
+ Transfer8 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT,
+ Transfer8_16 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT,
+ Transfer16 = EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT
+} EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS;
+
+//
+// Interrupt Resource Descriptor Information
+// Ref ACPI specification 6.4.2.1
+//
+// IRQ Information - Wake Capability
+//
+#define EFI_ACPI_IRQ_WAKE_CAPABLE_MASK 0x20
+#define EFI_ACPI_IRQ_NOT_WAKE_CAPABLE 0x0
+#define EFI_ACPI_IRQ_WAKE_CAPABLE 0x20
+
+typedef enum {
+ NotWakeCapable = EFI_ACPI_IRQ_NOT_WAKE_CAPABLE,
+ WakeCapable = EFI_ACPI_IRQ_WAKE_CAPABLE
+} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Sharing
+//
+#define EFI_ACPI_IRQ_EXCLUSIVE 0x0
+
+typedef enum {
+ Exclusive = EFI_ACPI_IRQ_EXCLUSIVE,
+ Shared = EFI_ACPI_IRQ_SHARABLE,
+ ExclusiveAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_EXCLUSIVE,
+ SharedAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_SHARABLE
+} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Polarity
+//
+typedef enum {
+ ActiveHigh = EFI_ACPI_IRQ_HIGH_TRUE,
+ ActiveLow = EFI_ACPI_IRQ_LOW_FALSE
+} EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Mode
+//
+#define EFI_ACPI_IRQ_MODE_MASK 0x1
+typedef enum {
+ LevelTriggered = EFI_ACPI_IRQ_LEVEL_TRIGGERED,
+ EdgeTriggered = EFI_ACPI_IRQ_EDGE_TRIGGERED
+} EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS;
+
+// IO Port Descriptor Information
+// Ref ACPI specification 6.4.2.5
+//
+typedef enum {
+ Decode16 = EFI_ACPI_IO_DECODE_16_BIT,
+ Decode10 = EFI_ACPI_IO_DECODE_10_BIT
+} EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION;
+
+//
+// Memory Resource Information
+// Ref ACPI specification 6.4.3.5
+//
+// Consumer/Producer Bit[0]
+typedef enum {
+ ResourceProducer = EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER,
+ ResourceConsumer = EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+} RESOURCE_USAGE_FLAG;
+
+// Decode Type (_DEC) Bit[1]
+typedef enum {
+ PosDecode = EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE,
+ SubDecode = EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+} MEM_DECODE_FLAG;
+
+// Min Address Fixed (_MIF) Bit[2]
+typedef enum {
+ MinNotFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED,
+ MinFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+} MIN_FIXED_FLAG;
+
+// Max Address Fixed (_MAF) Bit[3]
+typedef enum {
+ MaxNotFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED,
+ MaxFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+} MAX_FIXED_FLAG;
+
+// Memory Attributes (_MEM) Bits[2:1]
+typedef enum {
+ NonCacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE,
+ Cacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE,
+ WriteCombining = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING,
+ Prefetchable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+} CACHEABLE_FLAG;
+
+// Write Status (_RW) Bit[0]
+typedef enum {
+ ReadOnly = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY,
+ ReadWrite = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE
+} READ_WRITE_FLAG;
+
+// Memory Attributes (_MTP) Bits[4:3]
+typedef enum {
+ AddressRangeMemory = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY,
+ AddressRangeReserved = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED,
+ AddressRangeACPI = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI,
+ AddressRangeNVS = EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS
+} MEMORY_RANGE_TYPE;
+
+// Memory to IO Translation (_TTP) Bit[5]
+// Note: IO and Memory Resources use different bits for this.
+// Value must be handled at function level when implemented.
+typedef enum {
+ TypeStatic = 0,
+ TypeTranslation = 1
+} MEMORY_TRANSLATION_TYPE;
+
+// Memory Window Attributes (_RNG) Bits[1:0]
+typedef enum {
+ Reserved = 0,
+ NonISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY,
+ ISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY,
+ EntireRange = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE,
+ ISARangeMax
+} IO_ISA_RANGES;
+
+// Generic Address Space Address IDs
+typedef enum {
+ SystemMemory = EFI_ACPI_6_4_SYSTEM_MEMORY,
+ SystemIO = EFI_ACPI_6_4_SYSTEM_IO,
+ PCI_Config = EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE,
+ EmbeddedControl = EFI_ACPI_6_4_EMBEDDED_CONTROLLER,
+ SMBus = EFI_ACPI_6_4_SMBUS,
+ SystemCMOS = EFI_ACPI_6_4_SYSTEM_CMOS,
+ PciBarTarget = EFI_ACPI_6_4_PCI_BAR_TARGET,
+ IPMI = EFI_ACPI_6_4_IPMI,
+ GeneralPurposeIO = EFI_ACPI_6_4_GENERAL_PURPOSE_IO,
+ GenericSerialBus = EFI_ACPI_6_4_GENERIC_SERIAL_BUS,
+ PCC = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ PlatformCommChannel = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ FFixedHW = EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE
+} GENERIC_ADDRESS_SPACE_ID;
+
+typedef enum {
+ UndefinedSize = EFI_ACPI_6_4_UNDEFINED,
+ ByteSize = EFI_ACPI_6_4_BYTE,
+ WordSize = EFI_ACPI_6_4_WORD,
+ DWordSize = EFI_ACPI_6_4_DWORD,
+ QWordSize = EFI_ACPI_6_4_QWORD
+} ACPI_DATA_SIZE;
+
+typedef ACPI_DATA_SIZE GENERIC_ADDRESS_ACCESS_SIZE;
+
+// ***************************************************************************
+// AML Objects
+// ***************************************************************************
+
+// ---------------------------------------------------------------------------
+// Table and Table Header Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Name Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Namestring AML Object and inserts it into the linked list
+
+ Completes NameString in one call as "one phase"
+ LeadNameChar := 'A'-'Z' | '_'
+ DigitChar := '0'-'9'
+ NameChar := DigitChar | LeadNameChar
+ RootChar := '\'
+ ParentPrefixChar := '^'
+
+ 'A'-'Z' := 0x41 - 0x5A
+ '_' := 0x5F
+ '0'-'9' := 0x30 - 0x39
+ '\' := 0x5C
+ '^' := 0x5E
+
+ NameSeg := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Data Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates an optimized integer object
+
+ 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] Phase - Example: AmlStart, AmlClose
+ @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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a data string object
+
+ ComputationalData := String
+
+ String := StringPrefix AsciiCharList NullChar
+ StringPrefix := 0x0D
+ AsciiCharList := Nothing | <AsciiChar AsciiCharList>
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Package Length Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Package Length AML Object and inserts it into the linked list
+
+ PkgLength := PkgLeadByte |
+ <PkgLeadByte ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Term Objects Encoding
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Namespace Modifier Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ Creates a Name (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := NameOp NameString DataRefObject
+ NameOp := 0x08
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Named Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Field
+
+ Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be created 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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.
+
+ 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 that has completed AccessAs Object
+ after AmlClose.
+
+ @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
+ );
+
+/**
+ 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 since AML does not store
+ ArgTypes here.
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Type 1 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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 pkglength termlist>
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlReturn (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+// ---------------------------------------------------------------------------
+// Type 2 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 PackageElementList>
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] NumElements - Number of elements in the package
+ @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
+ );
+
+// ---------------------------------------------------------------------------
+// Resource Descriptor Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlDWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/*
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlQWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Expression Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Miscellaneous Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Shift Left expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Reult) => 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Assistance Functions
+// ***************************************************************************
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Debug Functions
+// ***************************************************************************
+
+/**
+ 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Buffer - Buffer containing buffer
+ @param[in] BufferSize - Number of bytes to print
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintBuffer (
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ );
+
+/**
+ DEBUG print a 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Object - AML_OBJECT_INSTANCE
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintObject (
+ IN AML_OBJECT_INSTANCE *Object
+ );
+
+/**
+ 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
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintLinkedObjects (
+ IN LIST_ENTRY *ListHead
+ );
+
+#endif // AML_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
new file mode 100644
index 0000000000..d48ca1a90a
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
@@ -0,0 +1,25 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AmdPspRomArmorLib.h>
+
+/*
+ * 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 couldn't be allocated
+ */
+EFI_STATUS
+EFIAPI
+GetPspRomArmorWhitelist (
+ IN SPI_WHITE_LIST **PlatformSpiWhitelist
+ );
diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
new file mode 100644
index 0000000000..6c854651cc
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
@@ -0,0 +1,134 @@
+/** @file
+ AMD Psp Ftpm Ppi Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_PPI_H_
+#define PSP_FTPM_PPI_H_
+#include <Uefi.h>
+
+typedef struct _PSP_FTPM_PPI PSP_FTPM_PPI;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Info
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+ **/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs.
+
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @retval EFI_STATUS 0: Success, Non-Zero Error
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ PSP_FTPM_PPI prototype
+
+ Defines PSP_FTPM_PPI. This PPI is used to get Ftpm info.
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PPI {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+} PSP_FTPM_PPI;
+
+extern EFI_GUID gAmdPspFtpmPpiGuid;
+extern EFI_GUID gAmdPspFtpmFactoryResetPpiGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
new file mode 100644
index 0000000000..715cbbcf78
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
@@ -0,0 +1,183 @@
+/** @file
+ CXL Configuration Services Protocol prototype definition
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_
+#define NBIO_CXL_SERVICES_PROTOCOL_H_
+
+#include "AMD.h"
+#include <Protocol/FabricTopologyServices2.h>
+#include <Protocol/FabricResourceManagerServicesProtocol.h>
+
+#define AMD_NBIO_CXL_SERVICES_REVISION 0x00
+
+/// Forward declaration for the AMD_NBIO_CXL_SERVICES_PROTOCOL
+typedef struct _AMD_NBIO_CXL_SERVICES_PROTOCOL AMD_NBIO_CXL_SERVICES_PROTOCOL;
+
+extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL services protocol calling
+
+#pragma pack (push, 1)
+/// Port Information Structure
+typedef struct _AMD_CXL_PORT_INFO_STRUCT {
+ PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root Port in PCI_ADDR format
+ UINT8 LogicalNbioInstance; ///< Logical Instance ID of NBIO
+ UINT8 PhysicalNbioInstance; ///< Physical Instance ID of NBIO where this port is located
+ UINT8 SocketID; ///< Socket ID for this port
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT8 PortId; ///< Physical port location
+ UINT8 PortWidth; ///< Lane width of the port
+ UINT32 CxlPortAddress; ///< CXL root port address (CXL 2.0 root port or CXL 1.1 RCiEP)
+ BOOLEAN IsSwitch; ///< CXL Switch flag
+} AMD_CXL_PORT_INFO_STRUCT;
+
+/// Port MMIO32 Resources Information Structure
+typedef struct _AMD_CXL_RESOURCES_INFO_STRUCT {
+ UINT32 Mmio32Base[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Size[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Gran;
+} AMD_CXL_RESOURCES_INFO_STRUCT;
+#pragma pack (pop)
+
+// Protocol Definitions
+
+/**
+ This function gets information about a specific PCIe root port.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortInformation
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_ROOT_PORT_INFORMATION)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr
+ IN UINTN PortIndex, ///< port index
+ OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port information ptr
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL capabilities.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port.
+ PortInformation OPTIONAL (can be NULL)
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_CONFIGURE_ROOT_PORT)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< this ptr
+ IN PCI_ADDR EndpointBDF ///< end pt bdf
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL presence
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port such as Socket id,rbindex,port id,segment,bus base,limit or presence.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_AVAILABLE)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT FABRIC_RESOURCE_FOR_EACH_RB *ResourceForEachRb ///<
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_PORT_RB_LOCATION)(
+ ///< get port rb location
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN UINT8 Segment, ///<
+ IN UINT8 BusBase, ///<
+ OUT UINT8 *SocketId, ///<
+ OUT UINT8 *RbIndex ///<
+ );
+
+/**
+ This function gets the CXL MMIO32 values to be used by the fabric resource manager
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ CxlMmio32ResourceForEachRb
+ A pointer to the structure that will hold the MMIO32 base and size values for each root bridge
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_INFORMATION)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT AMD_CXL_RESOURCES_INFO_STRUCT *CxlMmio32Resources ///<
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_REPORT_TO_MPIO)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This ///< ptr to protocol
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_FIND_2P0_DEVICES)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN UINTN PortIndex ///< port index
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+VOID
+(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN PCI_ADDR CxlPciAddress ///< PCI address
+ );
+
+/// The Protocol Definition for CXL Services
+struct _AMD_NBIO_CXL_SERVICES_PROTOCOL {
+ UINT32 Revision; ///< revision
+ UINTN CxlCount; ///< CXL count
+ AMD_CXL_GET_ROOT_PORT_INFORMATION CxlGetRootPortInformation; ///< CXL root port information
+ AMD_CXL_CONFIGURE_ROOT_PORT CxlConfigureRootPort; ///< configuring the root port
+ AMD_CXL_GET_PORT_RB_LOCATION GetCxlPortRBLocation; ///< CXL port RB location
+ AMD_CXL_RESOURCES_AVAILABLE GetCxlAvailableResources; ///< Get resources allocated for CXL RCiEP
+ AMD_CXL_RESOURCES_INFORMATION GetCxlMmio32Resources; ///< Get CXL MMIO resources for CXL RCiEP
+ AMD_CXL_REPORT_TO_MPIO CxlReportToMpio; ///< Sends the CXL info to MPIO
+ AMD_CXL_FIND_2P0_DEVICES CxlFind2p0Devices; ///< Finds CXL 2.0 devices after PCIe enumeration
+ AMD_CXL_ENABLE_SCM_PMEM CxlEnableScmForPersistentMemory; ///< Notifies SMU that CXL persistent memory is present
+};
+
+#endif /* NBIO_CXL_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
new file mode 100644
index 0000000000..7bcff65dc9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
@@ -0,0 +1,110 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCI_RESOURCES_PROTOCOL_H_
+#define AMD_PCI_RESOURCES_PROTOCOL_H_
+
+typedef struct {
+ UINTN Index;
+ UINT8 SocketId;
+ UINTN Segment;
+ UINTN BaseBusNumber;
+} PCI_ROOT_BRIDGE_OBJECT;
+
+typedef struct {
+ UINTN Index;
+ BOOLEAN Enabled;
+ UINT8 PortPresent;
+ UINTN Device;
+ UINTN Function;
+ UINTN SlotNum;
+ // Interrupts are relative to IOAPIC 0->n
+ UINTN BridgeInterrupt; // Redirection table entry for mapped bridge interrupt
+ UINTN EndpointInterruptArray[4]; // Redirection table entries for mapped INT A/B/C/D
+} PCI_ROOT_PORT_OBJECT;
+
+typedef enum {
+ IOMMU = 0,
+ IOAPIC
+} FIXED_RESOURCE_TYPE;
+
+typedef struct {
+ UINTN Index;
+ FIXED_RESOURCE_TYPE ResourceType;
+ UINTN Address;
+ UINTN Limit;
+} FIXED_RESOURCES_OBJECT;
+
+/// Forward declaration for the AMD_PCI_RESOURCES_PROTOCOL.
+typedef struct _AMD_PCI_RESOURCES_PROTOCOL AMD_PCI_RESOURCES_PROTOCOL;
+
+/**
+ * @brief System information through EFI call
+ * @details
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ OUT UINTN *NumberOfRootBridges
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT PCI_ROOT_BRIDGE_OBJECT **RootBridgeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfRootPorts
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN RootPortIndex,
+ OUT PCI_ROOT_PORT_OBJECT **RootPortInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfFixedResources
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN FixedResourceIndex,
+ OUT FIXED_RESOURCES_OBJECT **FixedResourceInfo
+ );
+
+struct _AMD_PCI_RESOURCES_PROTOCOL {
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES AmdPciResourcesGetNumberOfRootBridges;
+ AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO AmdPciResourcesGetRootBridgeInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS AmdPciResourcesGetNumberOfRootPorts;
+ AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO AmdPciResourcesGetRootPortInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES AmdPciResourcesGetNumberOfFixedResources;
+ AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO AmdPciResourcesGetFixedResourceInfo;
+};
+
+extern EFI_GUID gAmdPciResourceProtocolGuid; ///< Guid for calling
+
+#endif // AMD_PCI_RESOURCES_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
new file mode 100644
index 0000000000..ebc7812b18
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
@@ -0,0 +1,187 @@
+/** @file
+ AMD Psp Ftpm Protocol Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FTPM_PROTOCOL_H_
+#define FTPM_PROTOCOL_H_
+
+#include <Uefi.h>
+//
+// GUID definition
+//
+extern EFI_GUID gAmdPspFtpmProtocolGuid;
+
+/**
+ structure definition for HSP mailbox
+
+**/
+typedef struct {
+ // C2H_TPM_L0
+ UINT64 TPM_L0_Address; /// Mailbox address
+ UINT64 TPM_L0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L0(VLT0)
+ UINT64 VLT0_Address; /// Mailbox address
+ UINT64 VLT0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L1(VLT1)
+ UINT64 VLT1_Address; /// Mailbox address
+ UINT64 VLT1_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT1_HSC_MSG_Address; /// Doorbell address HSP->CPU
+
+ // Interrupt Information
+ UINT8 Gsi[4]; /// Gsi[0] is for HSP Channel 0 TPM
+ /// Gsi[1] is for HSP Channel 1 VTL0
+ /// Gsi[2] is for HSP Channel 2 VTL1
+ /// Gsi[3] is reserved
+} HSP_MAILBOX_ADDRESS, *PHSP_MAILBOX_ADDRESS;
+
+typedef union {
+ HSP_MAILBOX_ADDRESS HSP_info;
+} FTPM_INFO;
+
+typedef struct _PSP_FTPM_PROTOCOL PSP_FTPM_PROTOCOL;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Information
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Function prototype for GetHspfTPMInfo. Return Pluton mailbox base address to SBIOS.
+ SBIOS should call this procedure after PCI Enumeration Complete.
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmInfo Point to Pluton mailbox base address
+
+ @return EFI_SUCCESS - Success
+ @return EFI_INVALID_PARAMETER - Input parameter is invalid
+ @return EFI_NOT_READY - Pluton-fTPM device BAR0 MMIO is not ready.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TPM_INFO)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *FtpmInfo
+ );
+
+/**
+ PSP_FTPM_PROTOCOL prototype
+
+ Defines PSP_FTPM_PROTOCOL. This protocol is used to get Ftpm info
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PROTOCOL {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+ FTPM_GET_TPM_INFO GetInfo; ///< Get TPM info
+} PSP_FTPM_PROTOCOL;
+
+#endif //FTPM_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
new file mode 100644
index 0000000000..7f57facf88
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+ Fabric MMIO map manager Protocol prototype definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#include <FabricResourceManagerCmn.h>
+
+#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
new file mode 100644
index 0000000000..a7fef5a35c
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
@@ -0,0 +1,19 @@
+/** @file
+ AMD CPM Base Definitions.
+
+ Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_BASE_H_
+#define AMD_CPM_BASE_H_
+
+#include <Base.h>
+#include <Uefi.h>
+#include <PiPei.h>
+#include <AmdCpmCommon.h>
+#include <Library/DebugLib.h>
+
+#endif // AMD_CPM_BASE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
new file mode 100644
index 0000000000..af192fcf03
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
@@ -0,0 +1,78 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_COMMON_H_
+#define AMD_CPM_COMMON_H_
+
+#pragma pack(push)
+
+#include <AGESA.h>
+#include <AmdPcieComplex.h>
+#include <AmdCpmDefine.h>
+#include <AmdCpmFunction.h>
+
+/// The signatures of CPM table
+
+typedef enum {
+ CPM_SIGNATURE_DXIO_TOPOLOGY = SIGNATURE_32 ('$', 'A', '2', '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE
+ CPM_SIGNATURE_DXIO_TOPOLOGY_S1 = SIGNATURE_32 ('$', 'A', '2', '7') ///< The signature of Socket 1 AMD_CPM_DXIO_TOPOLOGY_TABLE
+} AMD_CPM_TABLE_SIGNATURE;
+
+/// CPM table header
+typedef struct {
+ UINT32 TableSignature; ///< Signature of CPM table
+ UINT16 TableSize; ///< Table size
+ UINT8 FormatRevision; ///< Revision of table format
+ UINT8 ContentRevision; ///< Revision of table content
+ UINT32 PlatformMask; ///< The mask of platform table supports
+ UINT32 Attribute; ///< Table attribute
+} AMD_CPM_TABLE_COMMON_HEADER;
+
+/// Table pointer
+typedef union {
+ VOID *Pointer; ///< Table pointer
+ UINT64 Raw; ///< Table pointer value
+} AMD_CPM_POINTER;
+
+/// DXIO Topology Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR Port[AMD_DXIO_PORT_DESCRIPTOR_SIZE]; ///< DXIO Port Descriptor List
+} AMD_CPM_DXIO_TOPOLOGY_TABLE;
+
+/// AMD CPM Main Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT8 PlatformName[32]; ///< Platform name
+ UINT8 BiosType; ///< BIOS type
+ UINT16 CurrentPlatformId; ///< Current Platform Id
+ UINT32 PcieMemIoBaseAddr; ///< PcieMemIoBaseAddr
+ UINT32 AcpiMemIoBaseAddr; ///< AcpiMemIoBaseAddr
+ AMD_CPM_POINTER Service; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRomList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRamList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInHobList; ///< Reserved for internal use
+ AMD_CPM_POINTER HobTablePtr; ///< Reserved for internal use
+
+ UINT8 ExtClkGen; ///< External ClkGen Config. 0x00~0x7F
+ UINT8 UnusedGppClkOffEn; ///< Config to turn off unused GPP clock
+ UINT8 LpcUartEn; ///< LpcUartEn
+ UINT64 AltAcpiMemIoBaseAddr; ///< Alternate AcpiMemIoBaseAddr for Slave FCH
+} AMD_CPM_MAIN_TABLE;
+
+/// Structure for Chip Id
+typedef struct {
+ UINT8 Cpu; ///< CPU/APU Chip Id
+ UINT8 Sb; ///< SB Chip Id
+ UINT8 Reserved[6];
+} AMD_CPM_CHIP_ID;
+#pragma pack (pop)
+
+#endif //AMD_CPM_COMMON_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
new file mode 100644
index 0000000000..4fc3f97a80
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
@@ -0,0 +1,17 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_DEFINE_H_
+#define AMD_CPM_DEFINE_H_
+
+#ifndef AMD_DXIO_PORT_DESCRIPTOR_SIZE
+#define AMD_DXIO_PORT_DESCRIPTOR_SIZE 0x30
+#endif
+
+#endif // AMD_CPM_DEFINE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
new file mode 100644
index 0000000000..7dce238135
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
@@ -0,0 +1,32 @@
+/** @file
+ AMD CPM Common Functions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_FUNCTION_H_
+#define AMD_CPM_FUNCTION_H_
+
+typedef VOID *(EFIAPI *AMD_CPM_GETTABLEPTR_FN)(
+ IN VOID *This,
+ IN UINT32 TableId
+ );
+
+typedef AGESA_STATUS (EFIAPI *AMD_CPM_GETPOSTEDVBIOSIMAGE_FN)(
+ IN GFX_VBIOS_IMAGE_INFO *VbiosImageInfo
+ );
+
+/// Common Functions for CPM Drivers
+typedef struct _AMD_CPM_COMMON_FUNCTION {
+ AMD_CPM_GETTABLEPTR_FN GetTablePtr2; ///< Get CPM Table Pointer. The table can be re-writable
+} AMD_CPM_COMMON_FUNCTION;
+
+/// CPM Public Functions for platform DXE Driver to use
+typedef struct _AMD_CPM_DXE_PUBLIC_FUNCTION {
+ AMD_CPM_GETPOSTEDVBIOSIMAGE_FN GetPostedVbiosImage; ///< Get posted VBIOS image
+} AMD_CPM_DXE_PUBLIC_FUNCTION;
+
+#endif //AMD_CPM_FUNCTION_H_
diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
new file mode 100644
index 0000000000..4a90aa3d8b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
@@ -0,0 +1,39 @@
+/** @file
+ AMD CPM Table Protocol.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_TABLE_PROTOCOL_H_
+#define AMD_CPM_TABLE_PROTOCOL_H_
+
+#include <AmdCpmBase.h>
+
+//
+// GUID definition
+//
+#define AMD_CPM_TABLE_PROTOCOL_GUID \
+ { 0x3724cf01, 0x00c2, 0x9762, 0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }
+
+#define AMD_CPM_TABLE_SMM_PROTOCOL_GUID \
+ { 0xaf6efacf, 0x7a13, 0x45a3, 0xb1, 0xa5, 0xaa, 0xfc, 0x06, 0x1c, 0x4b, 0x79 }
+
+extern EFI_GUID gAmdCpmTableProtocolGuid;
+extern EFI_GUID gAmdCpmTableSmmProtocolGuid;
+
+/// DXE Protocol Structure
+typedef struct _AMD_CPM_TABLE_PROTOCOL {
+ UINTN Revision; ///< Protocol Revision
+ AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Pointer to CPM Main Table
+ AMD_CPM_CHIP_ID ChipId; ///< Id of SB Chip
+ AMD_CPM_COMMON_FUNCTION CommonFunction; ///< Private Common Functions
+ AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///< Public Function of Protocol
+} AMD_CPM_TABLE_PROTOCOL;
+
+// Current Protocol Revision
+#define AMD_CPM_TABLE_PROTOCOL_REV 0x00
+
+#endif // AMD_CPM_TABLE_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
new file mode 100644
index 0000000000..fa83888e95
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
@@ -0,0 +1,31 @@
+/** @file
+ PSP Mailbox related functions
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
new file mode 100644
index 0000000000..0e9baad955
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
new file mode 100644
index 0000000000..a04bc1f992
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
@@ -0,0 +1,79 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/AmdPspRomArmorLib.h>
+
+/**
+ * Request secures the SPI Controller
+ *
+ * @param[in, out] SpiCommunicationBuffer SPI Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI White List structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @param[in] NONE
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request PSP firmware switch SPI controller chip select.
+ *
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
new file mode 100644
index 0000000000..fce82d75b0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
new file mode 100644
index 0000000000..f8b9eb0bcf
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Base.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
new file mode 100644
index 0000000000..cff678d76b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
@@ -0,0 +1,37 @@
+** @file
+ Fabric Topology Base Lib implementation
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ )
+{
+ return 0;
+}
+
+RETURN_STATUS
+EFIAPI
+BaseFabricTopologyLibConstructor (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
new file mode 100644
index 0000000000..f72cbe7dff
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
@@ -0,0 +1,8 @@
+/** @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.<BR>
+
+ 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
new file mode 100644
index 0000000000..a155978a5d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
@@ -0,0 +1,35 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+
+/** The constructor function determines the actual TSC frequency.
+
+ First, Get TSC frequency from system configuration table with TSC frequency GUID,
+ if the table is not found, install it.
+ This function will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeTscTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
new file mode 100644
index 0000000000..f70aa3de0e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
@@ -0,0 +1,11 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/HobLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
new file mode 100644
index 0000000000..7d14d62e60
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
@@ -0,0 +1,103 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/** Stalls the CPU for at least the specified number of MicroSeconds.
+
+ @param[in] MicroSeconds The minimum number of microseconds to delay.
+
+ @return The value of MicroSeconds input.
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ return 0;
+}
+
+/** Stalls the CPU for at least the specified number of NanoSeconds.
+
+ @param[in] NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return The value of NanoSeconds input.
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ return 0;
+}
+
+/** Retrieves the current value of the 64-bit free running Time-Stamp counter.
+
+ The properties of the counter can be retrieved by the
+ GetPerformanceCounterProperties() function.
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return 0;
+}
+
+/** Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
+ that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
+ EndValue.
+
+ The 64-bit frequency of the performance counter, in Hz, is always returned.
+
+ @param[out] StartValue Pointer to where the performance counter's starting value is saved, or NULL.
+ @param[out] EndValue Pointer to where the performance counter's ending value is saved, or NULL.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ OUT UINT64 *StartValue, OPTIONAL
+ OUT UINT64 *EndValue OPTIONAL
+ )
+{
+ return 0;
+}
+
+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ return 0;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
new file mode 100644
index 0000000000..44e23df62f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
@@ -0,0 +1,95 @@
+/** @file
+ AMD instance of the PCI Host Bridge Library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/PciHostBridgeResourceAllocation.h>
+
+/**
+ Sort all root bridges in bus ascending order and set DevicePath UIDs
+ continuous and ascending from zero
+
+ @param[in,out] RootBridgeList Array of root bridges.
+ @param[in] Count Count of root bridges in RootBridgeList
+
+ @return All the root bridge instances in an array are sorted in bus order.
+ DevicePath UID updated to continuous and ascending numbers starting
+ with 0.
+**/
+VOID
+EFIAPI
+PciHostBridgeSortRootBridges (
+ IN PCI_ROOT_BRIDGE *RootBridgeList,
+ IN UINTN Count
+ )
+{
+}
+
+/**
+ Return all the root bridge instances in an array.
+
+ @param Count Return the count of root bridge instances.
+
+ @return All the root bridge instances in an array.
+ The array should be passed into PciHostBridgeFreeRootBridges()
+ when it's not used.
+**/
+PCI_ROOT_BRIDGE *
+EFIAPI
+PciHostBridgeGetRootBridges (
+ UINTN *Count
+ )
+{
+ return (PCI_ROOT_BRIDGE *)NULL;
+}
+
+/**
+ Free the root bridge instances array returned from PciHostBridgeGetRootBridges().
+
+ @param Bridges The root bridge instances array.
+ @param Count The count of the array.
+**/
+VOID
+EFIAPI
+PciHostBridgeFreeRootBridges (
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
+ )
+{
+}
+
+/**
+ Inform the platform that the resource conflict happens.
+
+ @param HostBridgeHandle Handle of the Host Bridge.
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ for all the root bridges. The resource for each root
+ bridge is terminated with END descriptor and an
+ additional END is appended indicating the end of the
+ entire resources. The resource descriptor field
+ values follow the description in
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
+ .SubmitResources().
+**/
+VOID
+EFIAPI
+PciHostBridgeResourceConflict (
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
new file mode 100644
index 0000000000..318f8e5ad7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -0,0 +1,154 @@
+/** @file
+
+ Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE
+
+/*
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ ArgN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
new file mode 100644
index 0000000000..371537c9aa
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -0,0 +1,151 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLASSISTFUNCTIONS_FILECODE
+
+/**
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ListHead = AllocatePool (sizeof (LIST_ENTRY));
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlFreeObjectList (*ListHead);
+ FreePool (*ListHead);
+ *ListHead = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
new file mode 100644
index 0000000000..b7d4f4c9d7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -0,0 +1,640 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE
+
+/*
+ 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__, 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", __func__, "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", __func__, 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 AsciiCharList>
+ 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",
+ __func__,
+ Index,
+ String
+ ));
+ return Status;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, 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",
+ __func__,
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AsciiStrLen (String) != 0x7) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String' parameter.\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
new file mode 100644
index 0000000000..e8ea9d8e84
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -0,0 +1,1294 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECODE
+
+// ----------------------------------------------------------------------------
+// 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __func__));
+ goto Done;
+ }
+
+ // Start BufferSize
+ Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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",
+ __func__,
+ InternalBufferSize
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ InternalBufferSize,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
new file mode 100644
index 0000000000..21deb200e3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLLOCALOBJECTS_FILECODE
+
+/**
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ LocalN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
new file mode 100644
index 0000000000..0502547a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -0,0 +1,576 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESTRING_FILECODE
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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 := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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", __func__, 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",
+ __func__,
+ 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more than 1 RootChar.\n", __func__, String));
+ goto Done;
+ }
+
+ if (FoundParentPrefixChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
new file mode 100644
index 0000000000..37ae9319be
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -0,0 +1,2138 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMEDOBJECT_FILECODE
+
+#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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ InternalOffsetData = *(UINT64 *)OffsetObject->Data;
+
+ if (InternalOffsetData > BitCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataLength);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, BankName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, IndexName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Offset, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Length, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (BitIndex, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NumBits, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+ } else {
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ Status = AmlOPDataInteger (Index, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FixedFieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
new file mode 100644
index 0000000000..afe51cdcf2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -0,0 +1,360 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_FILECODE
+
+/**
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, AliasName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n", __func__));
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
new file mode 100644
index 0000000000..279bfc782d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -0,0 +1,144 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLOBJECTSDEBUG_FILECODE
+
+/**
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
new file mode 100644
index 0000000000..85d184b759
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -0,0 +1,267 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLPKGLENGTH_FILECODE
+
+#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",
+ __func__,
+ 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", __func__));
+ 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 ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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", __func__));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n", __func__));
+ 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", __func__, "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",
+ __func__,
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
new file mode 100644
index 0000000000..4ef746327b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -0,0 +1,1989 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECODE
+
+/**
+ 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", __func__, "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", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n", __func__, 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", __func__, AddressMaximum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressMaximum == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ 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", __func__, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __func__));
+ 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", __func__));
+ 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed = 0\n", __func__));
+ 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n", __func__, 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", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0, IsMinFixed = 1, and IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both be either 1 or 0\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, Shared));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__, "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", __func__, "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", __func__, Decode));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ 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", __func__, AddressMin));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, 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", __func__, AddressMax));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__, 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", __func__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AccessSize > EFI_ACPI_6_4_QWORD) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n", __func__, AccessSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__, ReadAndWrite));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
new file mode 100644
index 0000000000..03201d0109
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -0,0 +1,515 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLSTATEMENTOPCODES_FILECODE
+
+/**
+ 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 pkglength termlist>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NotifyValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
new file mode 100644
index 0000000000..c9a4399764
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -0,0 +1,213 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLTABLE_FILECODE
+
+// 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", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
new file mode 100644
index 0000000000..b1ad9b7037
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -0,0 +1,364 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE
+
+/**
+ 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 <all others> - 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 <all others> - 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 <all others> - 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", __func__));
+ 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 <all others> - 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 <all others> - 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", __func__, 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 <all others> - 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",
+ __func__,
+ 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 <all others> - 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;
+ UINT8 *TempBuffer;
+
+ 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", __func__));
+ 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
+ TempBuffer = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + ChildObject->DataSize,
+ Object->Data
+ );
+ if (TempBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ FreePool (Object->Data);
+ Object->Data = NULL;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __func__));
+ goto Done;
+ }
+
+ Object->Data = TempBuffer;
+ // 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/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
new file mode 100644
index 0000000000..2f4f676adb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
@@ -0,0 +1,13 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include <Filecode.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
new file mode 100644
index 0000000000..60305ee4a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
@@ -0,0 +1,90 @@
+/** @file
+ Library to support reset library, inheritted from Agesa Cf9Reset module.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+/**
+ This function causes a system-wide reset (cold reset), in which
+ all circuitry within the system returns to its initial state. This type of reset
+ is asynchronous to system operation and operates without regard to
+ cycle boundaries.
+
+ If this function returns, it means that the system does not support cold reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a system-wide initialization (warm reset), in which all processors
+ are set to their initial state. Pending cycles are not corrupted.
+
+ If this function returns, it means that the system does not support warm reset.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shutdown reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a systemwide reset. The exact type of the reset is
+ defined by the EFI_GUID that follows the Null-terminated Unicode string passed
+ into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+ the platform must pick a supported reset type to perform.The platform may
+ optionally log the parameters from any non-normal reset that occurs.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData The data buffer starts with a Null-terminated string,
+ followed by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
new file mode 100644
index 0000000000..d10e676668
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
@@ -0,0 +1,87 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Filecode.h>
+#include <Uefi.h>
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] RegAddr Slave register address
+ *
+ * @retval Register Value
+ */
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ )
+{
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to read
+ * @param[in] Length Length in byte to read
+ * @param[in] Buffer Pointer to the data read to
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to write
+ * @param[in] Length Length in byte to write
+ * @param[in] Value Pointer to the data to write
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to erase
+ * @param[in] Length Block Size to erase
+ *
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
new file mode 100755
index 0000000000..9044d3d497
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
@@ -0,0 +1,68 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/NbioHandleLib.h>
+#include <Library/AmdBaseLib.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ )
+{
+ return NULL;
+}
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ )
+{
+ PCI_ADDR PciAddr;
+
+ PciAddr.AddressValue = 0;
+ return PciAddr;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
new file mode 100755
index 0000000000..d5fbe98d22
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
@@ -0,0 +1,276 @@
+/** @file
+ GNB function to create/locate PCIe configuration data area
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/GnbPcieConfigLib.h>
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ )
+{
+ return FALSE;
+}
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ )
+{
+ return 0;
+}
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ )
+{
+}
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+}
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ )
+{
+ return FALSE;
+}
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+ return NULL;
+}
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ )
+{
+}
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ )
+{
+}
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
new file mode 100755
index 0000000000..5c6be22ee4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
@@ -0,0 +1,117 @@
+/** @file
+ Procedure to parse PCIe input configuration data
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <GnbDxio.h>
+
+/**
+ Get number of complexes in platform topology configuration
+
+ @param[in] ComplexList First complex configuration in complex configuration array
+ @retval Number of Complexes
+
+**/
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of PCIe engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfPcieEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of DDI engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfDdiEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of engines in given complex
+
+
+
+ @param[in] Complex Complex configuration header
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] Index Complex descriptor Index
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] SocketId Socket Id
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptorOfSocket (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINT32 SocketId
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Engine descriptor from given complex by index
+
+ @param[in] Complex Complex descriptor
+ @param[in] Index Engine descriptor index
+ @retval Pointer to Engine Descriptor
+**/
+PCIE_ENGINE_DESCRIPTOR *
+PcieInputParserGetEngineDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
new file mode 100644
index 0000000000..e6be32b071
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
@@ -0,0 +1,10 @@
+/** @file
+ SMN Register Access Methods
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/SmnAccessLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
new file mode 100644
index 0000000000..1dc13900c7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
@@ -0,0 +1,42 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/PcieConfigLib.h>
+#include <Library/NbioCommonLibDxe.h>
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
new file mode 100644
index 0000000000..fbd3ddcf37
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
@@ -0,0 +1,23 @@
+/** @file
+ APCB DXE Driver
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+EFI_STATUS
+EFIAPI
+AmdApcbV3DxeDriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
new file mode 100644
index 0000000000..23d1a8fee0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+
+/**
+ * @brief Amd Apcb V3 Pei Driver Entry
+ *
+ * @param[in] FileHandle File Handie
+ * @param[in] PeiServices Pei Services
+ *
+ * @retval EFI_SUCCESS Set APCB value successfully
+ * Non-EFI_SUCCESS Function Error
+ *
+ **/
+EFI_STATUS
+EFIAPI
+AmdApcbV3PeiDriverEntry (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
new file mode 100644
index 0000000000..74b129931b
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
@@ -0,0 +1,39 @@
+/** @file
+ Required OEM hooks for CCX initialization
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ Hook to store the vector that all APs should jump to out of reset to a non-volatile,
+ shared location.
+
+ @param[in] ApInitAddress Address of the code that AP should jump to
+ @param[in,out] ContentToRestore The current value in the non-volatile storage
+
+**/
+VOID
+SaveApInitVector (
+ IN UINT32 ApInitAddress,
+ IN OUT UINT32 *ContentToRestore
+ )
+{
+}
+
+/**
+ Hook to restore the initial content of the non-volatile storage location.
+
+ @param[in] ContentToRestore The value to restore
+
+**/
+VOID
+RestoreContentVector (
+ IN UINT32 ContentToRestore
+ )
+{
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
new file mode 100644
index 0000000000..54ce202cb1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
@@ -0,0 +1,33 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Ppi/PciCfg2.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+
+/**
+ Module's entry function.
+ This routine will install EFI_PEI_PCI_CFG2_PPI.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @return Whether success to install service.
+**/
+EFI_STATUS
+EFIAPI
+PeimInitializePciCfg (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
new file mode 100644
index 0000000000..643174d7b9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/PciSegmentInfoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+
+/**
+ Return an array of PCI_SEGMENT_INFO holding the segment information.
+
+ Note: The returned array/buffer is owned by callee.
+
+ @param Count Return the count of segments.
+
+ @retval A callee owned array holding the segment information.
+**/
+PCI_SEGMENT_INFO *
+EFIAPI
+GetPciSegmentInfo (
+ UINTN *Count
+ )
+{
+ return (PCI_SEGMENT_INFO *)NULL;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
new file mode 100644
index 0000000000..d83bb6c2d8
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
@@ -0,0 +1,15 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiSmm.h>
+#include <Register/Cpuid.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/SmmBase2.h>
+#include <Library/IoLib.h>
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
new file mode 100644
index 0000000000..a264eb9294
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
@@ -0,0 +1,12 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
new file mode 100644
index 0000000000..e379538e3a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
@@ -0,0 +1,36 @@
+/** @file
+ OEM OOB PPR DXE Driver.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciIo.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TimerLib.h>
+#include <IndustryStandard/Pci22.h>
+
+/**
+* This function installs a protocol used by platform BIOS to provide the hotplug descriptor.
+*
+* @param[in] ImageHandle Image handler
+* @param[in] SystemTable Pointer to the system table
+*
+* @retval EFI_SUCCESS The thread was successfully launched.
+*
+**/
+EFI_STATUS
+EFIAPI
+OobPprEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
new file mode 100644
index 0000000000..5242e6261a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -0,0 +1,20 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+EFI_STATUS
+EFIAPI
+PspPlatformEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
new file mode 100644
index 0000000000..530bd9d4b6
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+EFI_STATUS
+EFIAPI
+HotplugDescEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
new file mode 100644
index 0000000000..fbc372586b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
new file mode 100644
index 0000000000..0a5f4a7e81
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
@@ -0,0 +1,36 @@
+/** @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.<BR>
+
+ 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;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
new file mode 100644
index 0000000000..47eb700f8f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/IoLib.h>
+
+/**
+ Performs platform specific initialization required for the CPU to access
+ the hardware associated with a SerialPortLib instance. This function does
+ not intiailzie the serial port hardware itself. Instead, it initializes
+ hardware devices that are required for the CPU to access the serial port
+ hardware. This function may be called more than once.
+
+ @retval RETURN_SUCCESS The platform specific initialization succeeded.
+ @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
new file mode 100644
index 0000000000..72b9a87639
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
@@ -0,0 +1,9 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
new file mode 100644
index 0000000000..2dfb3190d4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
@@ -0,0 +1,13 @@
+; @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.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+%macro AMD_ENABLE_UEFI_STACK2 2-3
+
+%endmacro
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
index a731c7e369..937caee083 160000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
@@ -1 +1 @@
-Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490
+Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119130): https://edk2.groups.io/g/devel/message/119130
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-23 4:12 [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Chang, Abner via groups.io
@ 2024-05-23 4:12 ` Chang, Abner via groups.io
2024-05-23 7:25 ` Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages Chang, Abner via groups.io
` (2 subsequent siblings)
3 siblings, 2 replies; 16+ messages in thread
From: Chang, Abner via groups.io @ 2024-05-23 4:12 UTC (permalink / raw)
To: devel
Cc: Paul Grimes, Abdul Lateef Attar, Igniculus Fu, Ken Yao, Eric Xing,
Duke Zhai
From: Abner Chang <abner.chang@amd.com>
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
Platform/AMD/Readme.md | 64 ++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/Platform/AMD/Readme.md b/Platform/AMD/Readme.md
index 99d2b990c7..3297c6ba59 100644
--- a/Platform/AMD/Readme.md
+++ b/Platform/AMD/Readme.md
@@ -7,18 +7,25 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Term and Definitions
+* **AGESA**
+
+ AMD Generic Encapsulated Software Architecture that are executed as part of a
+ host platform BIOS.
+
* **AMD Platform** (platform in short)
- AMD platform refers to a platform that supports the particular AMD SoC (processor), such as AMD EPYC Milan and Genoa processors.
+ AMD platform refers to a platform that supports the particular AMD SoC (processor), such as
+ AMD EPYC Milan and Genoa processors.
* **AMD Board** (board in short)
AMD board is a generic terminology refers to a board that is designed based on a
specific AMD SoC architecture (also referred as AMD platform). More than one boards
- are possibly designed to support an AMD platform with different configuration, such as 1-processor socket or 2-processor sockets board.
+ are possibly designed to support an AMD platform with different configuration, such as
+ 1-processor socket or 2-processor sockets board.
* **AMD edk2 Platform Package** (platform package in short)
-
+
The folder has the AMD edk2 platform common modules.
* **AMD edk2 Board Package** (board package in short)
@@ -28,29 +35,52 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Package Definition
+* **AgesaModulePkg**
+
+ This package contains all of the private interfaces and build configuration files for the
+ AGESA support.
+
+* **AgesaPkg**
+
+ This package contains all of the public interfaces and build configuration files
+ for the AGESA support.
+
+* **AmdCbsPkg**
+
+ AMD Configurable BIOS Setting. Provides the edk2 formset following the UEFI HII
+ spec to configure BIOS settings.
+
+* **AmdCpmPkg**
+
+ AMD Common Platform Module software is a BIOS procedure library designed to aid
+ AMD customers to quickly implement AMD platform technology into their products.
+
* **AmdPlatformPkg**
- AMD platform edk2 package under this folder provides the common edk2 modules those
- are leverage by platforms. Usually those modules have no dependencies with
- particular platforms. The module under this scope can provides a common implementation
- for all platforms, or it may just provide a framework but the differences of implementation could be configured through the PCDs declared in AmdPlatformPkg.dec, or
- the board level library provided in the \<Board name\>Pkg.
+ AMD platform edk2 package under this folder provides the common edk2
+ modules that are leveraged by platforms. Usually those modules have no dependencies with
+ particular platforms. Modules under this scope can provide a common implementation
+ for all platforms, or may just provide a framework but the differences of implementation
+ could be configured through the PCDs declared in AmdPlatformPkg.dec, or the board level
+ library provided in the \<Board name\>Pkg.
* **AmdMinBoardPkg**
- This package provides the common edk2 modules those can be leverage across AMD boards those use MinPlatformPkg framework.
+ This package provides the common edk2 modules that can be leveraged across AMD boards using
+ the MinPlatform framework.
* **\<SoC name\>Board**
- This is the folder named by SoC and accommodate one or multiple board packages those
- are designed base on the same SoC platform. <SoC name>Board folder may contain edk2
- package meta files directly or the sub-folders named by \<Board name\>Pkg for a
- variety configurations of a platform.
+ This is the folder named by SoC and accommodates one or multiple board packages
+ that are designed based on the same SoC platform. <SoC name>Board folder may
+ contain edk2 package meta files directly or the sub-folders named by \<Board name\>Pkg for
+ a variety configurations of a platform.
* **<Board name\>Pkg**
- This is the folder that contains edk2 package meta files for a board which is designed base on a platform. Besides the edk2 meta files, <Board name\>Pkg may also provides
- edk2 modules which are specifically to a board.
+ This is the folder that contains edk2 package meta files for a board which is designed base
+ on a platform. Besides the edk2 meta files, <Board name\>Pkg may also provides edk2 modules
+ which are specifically to a board.
```
e.g. OverdriveBoard
@@ -63,6 +93,10 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
```
Platform/AMD
+ |----AgesaModulePkg
+ |----AgesaPkg
+ |----AmdCbsPkg
+ |----AmdCpmPkg
|----AmdPlatformPkg
|----AmdMinBoardPkg
|----OverdriveBoard
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119128): https://edk2.groups.io/g/devel/message/119128
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages
2024-05-23 4:12 [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Chang, Abner via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
@ 2024-05-23 4:12 ` Chang, Abner via groups.io
2024-05-23 16:27 ` Michael D Kinney
2024-05-23 7:26 ` [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
3 siblings, 1 reply; 16+ messages in thread
From: Chang, Abner via groups.io @ 2024-05-23 4:12 UTC (permalink / raw)
To: devel; +Cc: Leif Lindholm, Michael D Kinney
From: Abner Chang <abner.chang@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
Maintainers.txt | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/Maintainers.txt b/Maintainers.txt
index 877620a1b0..af688c3813 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -86,8 +86,20 @@ M: Leif Lindholm <quic_llindhol@quicinc.com>
AMD
F: Platform/AMD
M: Abner Chang <abner.chang@amd.com>
-M: Abdul Lateef Attar <abdattar@amd.com>
+M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
+M: Paul Grimes <paul.grimes@amd.com>
+
+F: Platform/AMD/AgesaModulePkg
+F: Platform/AMD/AgesaPkg
+F: Platform/AMD/AmdCbsPkg
+M: Paul Grimes <paul.grimes@amd.com>
+R: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
+R: Abner Chang <abner.chang@amd.com>
+
+F: Platform/AMD/AmdCpmPkg
+M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
R: Paul Grimes <paul.grimes@amd.com>
+R: Abner Chang <abner.chang@amd.com>
AMD Seattle
F: Platform/AMD/OverdriveBoard/
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119129): https://edk2.groups.io/g/devel/message/119129
Mute This Topic: https://groups.io/mt/106257081/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
@ 2024-05-23 7:25 ` Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
1 sibling, 0 replies; 16+ messages in thread
From: Xing, Eric via groups.io @ 2024-05-23 7:25 UTC (permalink / raw)
To: Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Yao, Ken, Zhai, MingXin (Duke)
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Eric Xing <Eric.Xing@amd.com>
> -----Original Message-----
> From: Chang, Abner <Abner.Chang@amd.com>
> Sent: Thursday, May 23, 2024 12:12 PM
> To: devel@edk2.groups.io
> Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef)
> <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao,
> Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin
> (Duke) <duke.zhai@amd.com>
> Subject: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
>
> From: Abner Chang <abner.chang@amd.com>
>
> Cc: Paul Grimes <paul.grimes@amd.com>
> Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> Cc: Igniculus Fu <igniculus.fu@amd.com>
> Cc: Ken Yao <ken.yao@amd.com>
> Cc: Eric Xing <eric.xing@amd.com>
> Cc: Duke Zhai <Duke.Zhai@amd.com>
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> ---
> Platform/AMD/Readme.md | 64 ++++++++++++++++++++++++++++++++----
> ------
> 1 file changed, 49 insertions(+), 15 deletions(-)
>
> diff --git a/Platform/AMD/Readme.md b/Platform/AMD/Readme.md index
> 99d2b990c7..3297c6ba59 100644
> --- a/Platform/AMD/Readme.md
> +++ b/Platform/AMD/Readme.md
> @@ -7,18 +7,25 @@ booting certain AMD platforms. The definition of sub-
> folders is described in bel
>
> ## Term and Definitions
>
> +* **AGESA**
> +
> + AMD Generic Encapsulated Software Architecture that are executed as
> + part of a host platform BIOS.
> +
> * **AMD Platform** (platform in short)
>
> - AMD platform refers to a platform that supports the particular AMD SoC
> (processor), such as AMD EPYC Milan and Genoa processors.
> + AMD platform refers to a platform that supports the particular AMD
> + SoC (processor), such as AMD EPYC Milan and Genoa processors.
>
> * **AMD Board** (board in short)
>
> AMD board is a generic terminology refers to a board that is designed based
> on a
> specific AMD SoC architecture (also referred as AMD platform). More than
> one boards
> - are possibly designed to support an AMD platform with different
> configuration, such as 1-processor socket or 2-processor sockets board.
> + are possibly designed to support an AMD platform with different
> + configuration, such as 1-processor socket or 2-processor sockets board.
>
> * **AMD edk2 Platform Package** (platform package in short)
> -
> +
> The folder has the AMD edk2 platform common modules.
>
> * **AMD edk2 Board Package** (board package in short) @@ -28,29 +35,52
> @@ booting certain AMD platforms. The definition of sub-folders is described
> in bel
>
> ## Package Definition
>
> +* **AgesaModulePkg**
> +
> + This package contains all of the private interfaces and build
> + configuration files for the AGESA support.
> +
> +* **AgesaPkg**
> +
> + This package contains all of the public interfaces and build
> + configuration files for the AGESA support.
> +
> +* **AmdCbsPkg**
> +
> + AMD Configurable BIOS Setting. Provides the edk2 formset following
> + the UEFI HII spec to configure BIOS settings.
> +
> +* **AmdCpmPkg**
> +
> + AMD Common Platform Module software is a BIOS procedure library
> + designed to aid AMD customers to quickly implement AMD platform
> technology into their products.
> +
> * **AmdPlatformPkg**
>
> - AMD platform edk2 package under this folder provides the common edk2
> modules those
> - are leverage by platforms. Usually those modules have no dependencies
> with
> - particular platforms. The module under this scope can provides a common
> implementation
> - for all platforms, or it may just provide a framework but the differences of
> implementation could be configured through the PCDs declared in
> AmdPlatformPkg.dec, or
> - the board level library provided in the \<Board name\>Pkg.
> + AMD platform edk2 package under this folder provides the common edk2
> + modules that are leveraged by platforms. Usually those modules have no
> + dependencies with particular platforms. Modules under this scope can
> + provide a common implementation for all platforms, or may just
> + provide a framework but the differences of implementation could be
> + configured through the PCDs declared in AmdPlatformPkg.dec, or the board
> level library provided in the \<Board name\>Pkg.
>
> * **AmdMinBoardPkg**
>
> - This package provides the common edk2 modules those can be leverage
> across AMD boards those use MinPlatformPkg framework.
> + This package provides the common edk2 modules that can be leveraged
> + across AMD boards using the MinPlatform framework.
>
> * **\<SoC name\>Board**
>
> - This is the folder named by SoC and accommodate one or multiple board
> packages those
> - are designed base on the same SoC platform. <SoC name>Board folder may
> contain edk2
> - package meta files directly or the sub-folders named by \<Board name\>Pkg
> for a
> - variety configurations of a platform.
> + This is the folder named by SoC and accommodates one or multiple
> + board packages that are designed based on the same SoC platform. <SoC
> + name>Board folder may contain edk2 package meta files directly or the
> + sub-folders named by \<Board name\>Pkg for a variety configurations of a
> platform.
>
> * **<Board name\>Pkg**
>
> - This is the folder that contains edk2 package meta files for a board which is
> designed base on a platform. Besides the edk2 meta files, <Board name\>Pkg
> may also provides
> - edk2 modules which are specifically to a board.
> + This is the folder that contains edk2 package meta files for a board
> + which is designed base on a platform. Besides the edk2 meta files,
> + <Board name\>Pkg may also provides edk2 modules which are specifically
> to a board.
>
> ```
> e.g. OverdriveBoard
> @@ -63,6 +93,10 @@ booting certain AMD platforms. The definition of sub-
> folders is described in bel
>
> ```
> Platform/AMD
> + |----AgesaModulePkg
> + |----AgesaPkg
> + |----AmdCbsPkg
> + |----AmdCpmPkg
> |----AmdPlatformPkg
> |----AmdMinBoardPkg
> |----OverdriveBoard
> --
> 2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119131): https://edk2.groups.io/g/devel/message/119131
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
2024-05-23 4:12 [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Chang, Abner via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages Chang, Abner via groups.io
@ 2024-05-23 7:26 ` Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
3 siblings, 0 replies; 16+ messages in thread
From: Xing, Eric via groups.io @ 2024-05-23 7:26 UTC (permalink / raw)
To: Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Yao, Ken, Zhai, MingXin (Duke)
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Eric Xing <Eric.Xing@amd.com>
> -----Original Message-----
> From: Chang, Abner <Abner.Chang@amd.com>
> Sent: Thursday, May 23, 2024 12:12 PM
> To: devel@edk2.groups.io
> Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef)
> <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao,
> Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin
> (Duke) <duke.zhai@amd.com>
> Subject: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross
> platform/board interfaces
>
> From: Abner Chang <abner.chang@amd.com>
>
> BZ#: 4777
>
> Initial commit of AMD cross platform/board generic
> encapsulated software architecture. This provides
> the basic definitions and protocols for the follow-up
> AMD open board project.
>
> Cc: Paul Grimes <paul.grimes@amd.com>
> Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> Cc: Igniculus Fu <igniculus.fu@amd.com>
> Cc: Ken Yao <ken.yao@amd.com>
> Cc: Eric Xing <eric.xing@amd.com>
> Cc: Duke Zhai <Duke.Zhai@amd.com>
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> ---
> .../AgesaModulePkg/AgesaCommonModulePkg.dec | 39 +
> Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec | 18 +
> .../AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec | 20 +
> .../AMD/AgesaModulePkg/AgesaModuleDfPkg.dec | 25 +
> .../AMD/AgesaModulePkg/AgesaModuleFchPkg.dec | 62 +
> .../AMD/AgesaModulePkg/AgesaModuleMemPkg.dec | 26 +
> .../AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec | 34 +
> .../AMD/AgesaModulePkg/AgesaModulePspPkg.dec | 29 +
> Platform/AMD/AgesaPkg/AgesaPkg.dec | 435 +++
> Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec | 41 +
> .../AgesaEdk2PlatformPkg.inc.dsc | 18 +
> .../AgesaSp5RsModulePkg.inc.dsc | 48 +
> .../CbsInstanceNull/CbsInstanceNull.inc.dsc | 8 +
> .../Genoa/AmdCpmGenoaQuartzPkg.inc.dsc | 11 +
> .../AgesaSp5RsModulePkg.dxe.inc.fdf | 11 +
> .../AgesaSp5RsModulePkg.pei.inc.fdf | 9 +
> .../CbsInstanceNull.dxe.inc.fdf | 7 +
> .../CbsInstanceNull.pei.inc.fdf | 7 +
> .../0x19/RS/External/CbsStones.dxe.inc.fdf | 8 +
> .../0x19/RS/External/CbsStones.pei.inc.fdf | 8 +
> .../Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf | 7 +
> .../Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf | 10 +
> .../Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf | 7 +
> .../Library/AmdCalloutLib/AmdCalloutLib.inf | 29 +
> .../AmdPspMboxLibV2/AmdPspMboxLibV2.inf | 30 +
> .../AmdPspRomArmorLib/AmdPspRomArmorLib.inf | 27 +
> .../AmdPspRomArmorLibNull.inf | 26 +
> .../Library/ApcbLibV3/ApcbLibV3.inf | 37 +
> .../Library/ApcbLibV3Pei/ApcbLibV3Pei.inf | 32 +
> .../BaseFabricTopologyRsLib.inf | 28 +
> .../CcxTscTimerLib/BaseTscTimerLib.inf | 35 +
> .../Library/CcxTscTimerLib/DxeTscTimerLib.inf | 42 +
> .../Library/CcxTscTimerLib/PeiTscTimerLib.inf | 37 +
> .../PciHostBridgeLib.inf | 42 +
> .../DxeAmlGenerationLib/AmlGenerationLib.inf | 47 +
> .../Library/FchBaseLib/FchBaseLib.inf | 26 +
> .../FchBaseResetSystemLib.inf | 35 +
> .../Library/FchEspiCmdLib/FchEspiCmdLib.inf | 33 +
> .../Library/NbioHandleLib/NbioHandleLib.inf | 24 +
> .../Library/PcieConfigLib/PcieConfigLib.inf | 25 +
> .../Library/SmnAccessLib/SmnAccessLib.inf | 33 +
> .../Library/CommonDxe/NbioCommonDxeLib.inf | 29 +
> .../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf | 45 +
> .../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf | 33 +
> .../OemAgesaCcxPlatformLibNull.inf | 27 +
> .../PciExpressPciCfg2/PciExpressPciCfg2.inf | 61 +
> .../PciExpressPciSegmentInfoLib.inf | 32 +
> .../AmdPspFlashAccSpiNorLibSmm.inf | 45 +
> .../PspRomArmorWhitelistLib.inf | 32 +
> .../Addendum/Oem/OobPprDxe/OobPprDxe.inf | 42 +
> .../Dxe/PspPlatformDriver/PspPlatform.inf | 32 +
> .../Dxe/ServerHotplugDxe/ServerHotplugDxe.inf | 29 +
> .../AmdAutoDynamicCommand.inf | 53 +
> .../AmdAutoDynamicCommand/AmdAutoToolApp.inf | 50 +
> .../BasePlatformHookLibAmdFchUart.inf | 33 +
> Platform/AMD/AgesaModulePkg/Include/AGESA.h | 158 +
> Platform/AMD/AgesaModulePkg/Include/AMD.h | 91 +
> .../Include/AmdEdk2/CpuRegisters.h | 15 +
> .../AgesaModulePkg/Include/AmdPspDirectory.h | 61 +
> .../AgesaModulePkg/Include/CpuRegistersDef.h | 156 +
> .../Include/FchRegistersCommon.h | 85 +
> .../AMD/AgesaModulePkg/Include/Filecode.h | 31 +
> Platform/AMD/AgesaModulePkg/Include/Gnb.h | 14 +
> Platform/AMD/AgesaModulePkg/Include/GnbDxio.h | 521 ++++
> .../AgesaModulePkg/Include/GnbRegistersRS.h | 18 +
> .../Include/GnbRegistersRS/IOHC.h | 22 +
> .../Include/Guid/GnbPcieInfoHob.h | 31 +
> .../Include/Library/AmdBaseLib.h | 16 +
> .../Include/Library/AmdPspMboxLibV2.h | 43 +
> .../Include/Library/BaseFabricTopologyLib.h | 22 +
> .../Include/Library/FchBaseLib.h | 16 +
> .../Include/Library/FchEspiCmdLib.h | 413 +++
> .../Include/Library/GnbPcieConfigLib.h | 16 +
> .../Include/Library/NbioCommonLibDxe.h | 37 +
> .../Include/Library/NbioHandleLib.h | 62 +
> .../Include/Library/PcieConfigLib.h | 283 ++
> .../Include/Library/SmnAccessLib.h | 30 +
> .../Protocol/AmdNbioPcieServicesProtocol.h | 47 +
> .../Include/Protocol/AmdOemOobPprProtocol.h | 14 +
> .../Include/Protocol/FabricNumaServices2.h | 155 +
> .../Protocol/FabricTopologyServices2.h | 14 +
> .../AMD/AgesaModulePkg/Include/SocLogicalId.h | 23 +
> .../Library/DxeAmlGenerationLib/LocalAmlLib.h | 100 +
> .../DxeAmlGenerationLib/LocalAmlObjects.h | 150 +
> .../AMD/AgesaPkg/Include/AmdPcieComplex.h | 432 +++
> Platform/AMD/AgesaPkg/Include/AmdSoc.h | 17 +
> .../Include/FabricResourceManagerCmn.h | 42 +
> .../AgesaPkg/Include/Guid/AmdMemoryInfoHob.h | 96 +
> .../Include/Library/AmdPspBaseLibV2.h | 51 +
> .../AgesaPkg/Include/Library/AmdPspFtpmLib.h | 83 +
> .../Include/Library/AmdPspRomArmorLib.h | 231 ++
> .../Include/Library/AmlGenerationLib.h | 2722 +++++++++++++++++
> .../Library/PlatformPspRomArmorWhitelistLib.h | 25 +
> .../AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h | 134 +
> .../Include/Protocol/AmdCxlServicesProtocol.h | 183 ++
> .../Protocol/AmdPciResourcesProtocol.h | 110 +
> .../Include/Protocol/AmdPspFtpmProtocol.h | 187 ++
> .../FabricResourceManagerServicesProtocol.h | 14 +
> Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h | 19 +
> Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h | 78 +
> Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h | 17 +
> .../AMD/AmdCpmPkg/Include/AmdCpmFunction.h | 32 +
> .../AmdCpmTableProtocol/AmdCpmTableProtocol.h | 39 +
> .../Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c | 31 +
> .../AmdPspRomArmorLib/AmdPspRomArmorLib.c | 12 +
> .../AmdPspRomArmorLibNull.c | 79 +
> .../Library/ApcbLibV3/ApcbLibV3.c | 12 +
> .../Library/ApcbLibV3Pei/ApcbLibV3Pei.c | 14 +
> .../BaseFabricTopologyRsLib.c | 37 +
> .../Library/CcxTscTimerLib/BaseTscTimerLib.c | 8 +
> .../Library/CcxTscTimerLib/DxeTscTimerLib.c | 35 +
> .../Library/CcxTscTimerLib/PeiTscTimerLib.c | 11 +
> .../Library/CcxTscTimerLib/TscTimerLibShare.c | 103 +
> .../DxeAmdPciHostBridgeLib/PciHostBridgeLib.c | 95 +
> .../DxeAmlGenerationLib/AmlArgObjects.c | 154 +
> .../DxeAmlGenerationLib/AmlAssistFunctions.c | 151 +
> .../DxeAmlGenerationLib/AmlDataObjects.c | 640 ++++
> .../AmlExpressionOpcodes.c | 1294 ++++++++
> .../DxeAmlGenerationLib/AmlLocalObjects.c | 158 +
> .../DxeAmlGenerationLib/AmlNameString.c | 576 ++++
> .../DxeAmlGenerationLib/AmlNamedObject.c | 2138 +++++++++++++
> .../AmlNamespaceModifierObjects.c | 360 +++
> .../DxeAmlGenerationLib/AmlObjectsDebug.c | 144 +
> .../DxeAmlGenerationLib/AmlPkgLength.c | 267 ++
> .../AmlResourceDescriptor.c | 1989 ++++++++++++
> .../DxeAmlGenerationLib/AmlStatementOpcodes.c | 515 ++++
> .../Library/DxeAmlGenerationLib/AmlTable.c | 213 ++
> .../DxeAmlGenerationLib/LocalAmlObjects.c | 364 +++
> .../Library/FchBaseLib/FchStallLib.c | 13 +
> .../FchBaseResetSystemLib.c | 90 +
> .../Library/FchEspiCmdLib/FchEspiCmdLib.c | 87 +
> .../Library/NbioHandleLib/NbioHandleLib.c | 68 +
> .../Library/PcieConfigLib/PcieConfigLib.c | 276 ++
> .../PcieConfigLib/PcieInputParserLib.c | 117 +
> .../Library/SmnAccessLib/SmnAccessLib.c | 10 +
> .../Nbio/Library/CommonDxe/DxeLibFunctions.c | 42 +
> .../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c | 23 +
> .../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c | 29 +
> .../OemAgesaCcxPlatformLibNull.c | 39 +
> .../PciExpressPciCfg2/PciExpressPciCfg2.c | 33 +
> .../PciSegmentInfoLib.c | 30 +
> .../AmdPspFlashAccSpiNorLibSmm.c | 15 +
> .../PspRomArmorWhitelistLib.c | 12 +
> .../Addendum/Oem/OobPprDxe/OobPprDxe.c | 36 +
> .../Dxe/PspPlatformDriver/PspPlatformDriver.c | 20 +
> .../Dxe/ServerHotplugDxe/ServerHotplugDxe.c | 22 +
> .../AmdAutoDynamicCommand.c | 44 +
> .../AmdAutoDynamicCommand/AmdAutoToolApp.c | 36 +
> .../BasePlatformHookLibAmdFchUart.c | 29 +
> .../FchSongshanDxe/FchSongshanI2C_I3C.asl | 9 +
> .../AMD/AgesaPkg/Include/AmdUefiStackNasm.inc | 13 +
> .../Library/RiscVOpensbiLib/opensbi | 2 +-
> 152 files changed, 19669 insertions(+), 1 deletion(-)
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
> create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
> create mode 100755
> Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
> create mode 100755
> Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
> create mode 100755
> Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
> create mode 100644 Platform/AMD/AgesaPkg/AgesaPkg.dec
> create mode 100755 Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
> create mode 100644
> Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd
> CpmGenoaQuartzPkg.inc.dsc
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
> create mode 100644
> Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
> create mode 100644
> Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.f
> df
> create mode 100644
> Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.f
> df
> create mode 100644
> Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.i
> nc.fdf
> create mode 100644
> Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.in
> c.fdf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd
> CpmGenoaQuartzPkg.dxe.inc.fdf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd
> CpmGenoaQuartzPkg.fdf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd
> CpmGenoaQuartzPkg.pei.inc.fdf
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLi
> bV2.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRom
> ArmorLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspR
> omArmorLibNull.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabri
> cTopologyRsLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBri
> dgeLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerati
> onLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseRes
> etSystemLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDx
> eLib.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> create mode 100644
> Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
> create mode 100755
> Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oem
> AgesaCcxPlatformLibNull.inf
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpr
> essPciCfg2.inf
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfo
> Lib/PciExpressPciSegmentInfoLib.inf
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/Am
> dPspFlashAccSpiNorLibSmm.inf
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRom
> ArmorWhitelistLib.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver
> /PspPlatform.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe
> /ServerHotplugDxe.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDy
> namicCommand.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoTo
> olApp.inf
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFc
> hUart/BasePlatformHookLibAmdFchUart.inf
> create mode 100644 Platform/AMD/AgesaModulePkg/Include/AGESA.h
> create mode 100755 Platform/AMD/AgesaModulePkg/Include/AMD.h
> create mode 100755
> Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
> create mode 100755
> Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
> create mode 100644 Platform/AMD/AgesaModulePkg/Include/Filecode.h
> create mode 100755 Platform/AMD/AgesaModulePkg/Include/Gnb.h
> create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
> create mode 100755
> Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
> create mode 100755
> Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProt
> ocol.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.
> h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
> create mode 100755
> Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.
> h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObj
> ects.h
> create mode 100755 Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
> create mode 100644 Platform/AMD/AgesaPkg/Include/AmdSoc.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.
> h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
> create mode 100644
> Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesP
> rotocol.h
> create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
> create mode 100644
> Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
> create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
> create mode 100644
> Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCp
> mTableProtocol.h
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLi
> bV2.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRom
> ArmorLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspR
> omArmorLibNull.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabri
> cTopologyRsLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBri
> dgeLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjec
> ts.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFun
> ctions.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObje
> cts.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressio
> nOpcodes.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObj
> ects.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameStri
> ng.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedO
> bject.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespa
> ceModifierObjects.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsD
> ebug.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLengt
> h.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResource
> Descriptor.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatemen
> tOpcodes.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObj
> ects.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseRes
> etSystemLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
> create mode 100755
> Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.
> c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oem
> AgesaCcxPlatformLibNull.c
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpr
> essPciCfg2.c
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfo
> Lib/PciSegmentInfoLib.c
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/Am
> dPspFlashAccSpiNorLibSmm.c
> create mode 100644
> Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRom
> ArmorWhitelistLib.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver
> /PspPlatformDriver.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe
> /ServerHotplugDxe.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDy
> namicCommand.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoTo
> olApp.c
> create mode 100644
> Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFc
> hUart/BasePlatformHookLibAmdFchUart.c
> create mode 100644
> Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongsha
> nI2C_I3C.asl
> create mode 100644
> Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
>
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
> new file mode 100644
> index 0000000000..d35a1f27b4
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
> @@ -0,0 +1,39 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaCommonPkg
> + PACKAGE_GUID = 6CBE6566-0D3F-4E35-8358-9602354E9F09
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> +
> +[Guids]
> + gEfiAmdAgesaModulePkgTokenSpaceGuid = {0x7788adf0, 0x9788,
> 0x4a3f, {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}}
> + gAgesaConfigDbPointerVariableGuid = {0x21229d24, 0xc71d, 0x4bc0,
> {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}}
> + gAmdMemoryInfoHobGuid = {0x1bce3d14, 0xa5fe, 0x4a0b,
> {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}}
> +
> +[Protocols]
> + ## Soc Protocols
> + gAmdSocLogicalIdProtocolGuid = {0x72f8e409, 0x0d2a, 0x4b91,
> {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}}
> + gAmdOemOobPprDxeProtocolGuid = {0x78031be3, 0x54a2, 0x4819,
> {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}}
> +
> +[PcdsFixedAtBuild]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupported
> V2|2|UINT8|0x00002002 # 2 by default
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|
> 1|UINT8|0x00002003 # 1 by default
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2
> |8|UINT8|0x00002004 # 8 by default
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannel
> V2|2|UINT8|0x00002005 # 2 by default
> +
> +[PcdsDynamic]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UI
> NT64|0x00027003
> +
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
> new file mode 100644
> index 0000000000..1637068432
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
> @@ -0,0 +1,18 @@
> +## @file
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaEdk2Pkg
> + PACKAGE_GUID = E866104F-D458-41B1-AB26-FA5951618A8C
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include/AmdEdk2
> +
> +
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
> new file mode 100755
> index 0000000000..b84fe5b738
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
> @@ -0,0 +1,20 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaCcxPkg
> + PACKAGE_GUID = df325429-029e-40f0-82db-0e69be7f6560
> + PACKAGE_VERSION = 0.1
> +
> +[PcdsDynamic]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FA
> LSE|BOOLEAN|0x000CC029
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
> new file mode 100755
> index 0000000000..57db15e663
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
> @@ -0,0 +1,25 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaDfPkg
> + PACKAGE_GUID = 81e51ee3-c347-4563-92fe-790ba953bf0f
> + PACKAGE_VERSION = 0.1
> +
> +[Guids]
> + gAmdTotalNumberOfRootBridgesGuid = {0xfb5703f5, 0xf8a7, 0xf401,
> {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}}
> + gAmdResourceSizeForEachRbGuid = {0x542b8f2f, 0xbd52, 0x4233,
> {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}}
> +
> +[Protocols]
> + gAmdFabricNumaServices2ProtocolGuid = {0xa8ff2e64, 0xf319, 0x4af1,
> {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}}
> +
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
> new file mode 100644
> index 0000000000..521957e809
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
> @@ -0,0 +1,62 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 1.5
> + PACKAGE_NAME = AgesaFchPkg
> + PACKAGE_GUID = e47c8ed9-3000-4e6e-b1c6-875b365b3849
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> +
> +[Guids]
> + gEfiAmdAgesaModulePkgTokenSpaceGuid = { 0x7788adf0, 0x9788, 0x4a3f,
> { 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } }
> +
> +[Protocols]
> + gFchInitDonePolicyProtocolGuid = { 0xc63c0c73, 0xf612, 0x4c02, { 0x84,
> 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } }
> +
> +[PcdsDynamic]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|
> 0x0003F001
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0
> x0003F002
> +
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0
> x0003F003
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x00
> 03F00D
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BO
> OLEAN|0x0003F021
> +
> + ### @brief This item allows the customer to change OC signal polarity to be
> active low. This is universal and applies to all OC pins.
> + ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)At present,
> this control applies to Family17h Model 00h-2Fh.
> + ### @li TRUE - OC pin is low when OC occurs.
> + ### @li FALSE - OC pin is high when OC occurs.
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciOcPolarityCfgLow|FALSE|B
> OOLEAN|0x0003F309
> +
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFF
> FFFFFFFFFFF|UINT64|0x0003F340
> + #Die 0
> + #[7:0] SSP -- 2 USB 2.0
> ports on XHCI controller 0
> + #[15:8] SSP -- 2 USB 2.0
> ports on XHCI controller 1
> + #[23:0] MTS -- 6 USB
> 2.0 ports on XHCI controller 0
> + #Die 1
> + #[39:32] SSP -- 2 USB
> 2.0 ports on XHCI controller 0
> + #[47:40] SSP -- 2 USB
> 2.0 ports on XHCI controller 1
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb31OcPinSelect|0xFFFFF
> FFF|UINT32|0x0003F341
> + #Die 0
> + #[7:0] SSP -- 2 USB 3.1
> ports on XHCI controller 0
> + #[15:8] SSP -- 2 USB 3.1
> ports on XHCI controller 1
> + #[15:0] MTS -- 4 USB
> 3.1 ports on XHCI controller 0
> + #Die 1
> + #[23:16] SSP -- 2 USB
> 3.1 ports on XHCI controller 0
> + #[31:24] SSP -- 2 USB
> 3.1 ports on XHCI controller 1
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLpcEnable|TRUE|BOOLEAN|0x
> 0003F400
> +
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdUsbRSOemConfigurationTable|{
> 0x0}|VOID*|0x0003F40A
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciSsid|0x00000000|UINT32|
> 0x0003FF07
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x000000
> 00|UINT32|0x0003FF81
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
> new file mode 100644
> index 0000000000..721d3ea73b
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
> @@ -0,0 +1,26 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaMemPkg
> + PACKAGE_GUID = 445f7303-3171-428c-ad0b-32df4474a7ad
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include/
> +
> +[PcdsFixedAtBuild]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageR
> epairEntries|64|UINT32|0x00029001
> +
> +
> +
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
> new file mode 100755
> index 0000000000..0501774c9b
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
> @@ -0,0 +1,34 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaNbioPkg
> + PACKAGE_GUID = 1486f0fe-39ee-4856-a39f-222ff2404f26
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> +
> +[Protocols]
> + gAmdNbioPcieServicesProtocolGuid = {0x756db75c, 0xbb9d, 0x4289,
> {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}}
> +
> +[PcdsFixedAtBuild]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReserv
> edEnable|FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO
> reserved from GNB driver. 0:Disable
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReserv
> edEnable|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO
> reserved from GNB driver. 0:Disable
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE
> |BOOLEAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI
> phase
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0
> x00021103 #///< Base NBIO IOAPIC ID. ID assigned start from this
> value
> +
> +[PcdsDynamic]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x00
> 04101D
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x000
> 4101E
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|
> 0x0|UINT32|0x00041200
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
> b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
> new file mode 100644
> index 0000000000..41cf320c76
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
> @@ -0,0 +1,29 @@
> +## @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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaPspPkg
> + PACKAGE_GUID = 5c48f900-a98c-431f-8be5-19c09c65bb05
> + PACKAGE_VERSION = 0.1
> +
> +[Guids]
> + gApSyncFlagNvVariableGuid = { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb,
> 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } }
> + gAmdPspApobHobGuid = { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13,
> 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } }
> +
> +[Protocols]
> + gPspFlashAccSmmCommReadyProtocolGuid = { 0x9f373486, 0xda76, 0x4c9f,
> { 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } }
> + gAmdPspFtpmProtocolGuid = { 0xac234e04, 0xb036, 0x476c, { 0x91,
> 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } }
> +
> +[Ppis]
> + gAmdPspFtpmPpiGuid = { 0x91774185, 0xf72d, 0x467e, { 0x93,
> 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } }
> + gAmdPspFtpmFactoryResetPpiGuid = { 0x9c98130a, 0x8921, 0x45eb,
> { 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } }
> diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec
> b/Platform/AMD/AgesaPkg/AgesaPkg.dec
> new file mode 100644
> index 0000000000..9377c64cc3
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
> @@ -0,0 +1,435 @@
> +## @file
> +# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
> +# file.
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = AgesaPkg
> + PACKAGE_GUID = DABFEFC6-5A79-444b-862A-1F6FE9F561FE
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> +
> +[Guids]
> + gEfiAmdAgesaPkgTokenSpaceGuid = { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0,
> 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } }
> +
> +[Protocols]
> + gAmdNbioCxlServicesProtocolGuid = {0x125CCFCE, 0x34AF, 0x422C,
> {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}}
> + gAmdPciResourceProtocolGuid = {0x663d4897, 0xed94, 0x4f0f,
> {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}}
> + gAmdCapsuleSmmHookProtocolGuid = {0x4fc43bbe, 0x1433, 0x4951,
> {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}}
> + gAmdFspSetupTableInitDoneGuid = {0xef5394c6, 0x566d, 0x440f,
> {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}}
> +
> +[Ppis]
> + gAmdMemoryInfoHobPpiGuid = {0xba16e587, 0x1d66, 0x41b7,
> {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
> + gCapsuleUpdateDetectedPpiGuid = {0x745dfc73, 0xc401, 0x4ced,
> {0x8d, 0x3b, 0x1a, 0x82, 0xf3, 0xda, 0xdc, 0xf8}}
> +
> +[PcdsFixedAtBuild]
> +
> + ### @brief Enable EDK-II Protocols
> + ### @details This item enables support for EDKII implementation of ACPI
> Protocols when set to TRUE
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdCompliantEdkIIAcpiSdtProtocol|TRUE|B
> OOLEAN|0x00020006
> + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize
> |0x1000|UINT32|0x00020007
> +
> + ### @brief assign non volatile storage base address
> + ### @details This assigns the base address to map to flash deivce.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF0000
> 00|UINT32|0x00020017
> +
> +#----------------------------------------------------------------------------
> +#- FCH Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-FCH.h"
> +#----------------------------------------------------------------------------
> +
> + ### @name General FCH Controls
> +
> + ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1
> register blocks as defined by ACPI spec.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x0400)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1EvtBlkAddr|0x400
> |UINT16|0x0002F004
> +
> + ### @brief Allows the host BIOS to specify the IO address for the ACPI
> PM1Cnt register blocks as defined by ACPI spec.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x0404)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1CntBlkAddr|0x404
> |UINT16|0x0002F005
> +
> + ### @brief Allows the host BIOS to specify the IO address for the ACPI PM
> Timer as defined by ACPI spec.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x0408)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPmTmrBlkAddr|0x408|
> UINT16|0x0002F006
> +
> + ### @brief Allows the host BIOS to specify the IO address for the ACPI CPU
> Control block as defined by ACPI spec.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x0410)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgCpuControlBlkAddr|0x410|
> UINT16|0x0002F007
> +
> + ### @brief Allows the host BIOS to specify the IO address for the ACPI
> GPE0 register block as defined by ACPI spec.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x0420)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|U
> INT16|0x0002F008
> +
> + ### @brief This item defines the SMI command value sent by the host BIOS
> during the S3 resume sequence, to re-initialize the
> + ### FCH registers. This must be issued before the platform driver restore
> function is started.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xD3)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemBeforePciRestoreSwSmi|0xD3
> |UINT8|0x0002F010
> +
> + ### @brief This item defines the SMI command used by the host BIOS to
> signal the FCH driver that the platform driver has
> + ### completed its restore function. This allows the FCH driver to perform
> some final FCH settings.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xD4)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|U
> INT8|0x0002F011
> +
> + ### @brief Allows the host BIOS to set the SMI command value used by the
> OS to activate ACPI mode.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xA0)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemEnableAcpiSwSmi|0xA0|UINT8
> |0x0002F012
> +
> + ### @brief Allows the host BIOS to set the SMI command value used by the
> OS to turn off ACPI mode.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xA1)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemDisableAcpiSwSmi|0xA1|UINT
> 8|0x0002F013
> +
> + ### @brief SMI command used for releasing the SPI controller lock mode.
> All devices on the SPI bus will be writable.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xAA)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiUnlockSwSmi|0xAA|UINT8|
> 0x0002F014
> +
> + ### @brief SMI command for setting the lock mode in the SPI controller.
> This will effectively provide a write protection to the
> + ### SPI Flash ROM; however, write access to secondary SPI devices will also
> be blocked.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0xAB)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x
> 0002F015
> +#----------------------------------------------------------------------------
> +#- FCH Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-FCH-IRQ.h"
> +#----------------------------------------------------------------------------
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart0Irq|0x03|UINT8|0x0002F01A
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart1Irq|0x0E|UINT8|0x0002F01B
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart2Irq|0x05|UINT8|0x0002F01C
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart3Irq|0x0F|UINT8|0x0002F01D
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart4Irq|0x10|UINT8|0x0002F01E
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c0Irq|0x0A|UINT8|0x0002F01F
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c1Irq|0x0B|UINT8|0x0002F020
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c2Irq|0x04|UINT8|0x0002F021
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c3Irq|0x06|UINT8|0x0002F022
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c4Irq|0x16|UINT8|0x0002F023
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c5Irq|0x17|UINT8|0x0002F024
> +#- DF Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-DF.h"
> +#----------------------------------------------------------------------------
> +
> + #Fabric
> +
> + ### @name General DF Controls
> +
> + ### @brief This item informs the SMBios generation code as to how many
> physical processor sockets exist in the system and
> + ### therefore how many Type 4 SMBios records to produce.
> + ### @brief Permitted Choices: (Type: Value)(Default: 0x01)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdNumberOfPhysicalSocket|1|UINT8
> |0x000CC103
> +#----------------------------------------------------------------------------
> +#- CCX Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-CCX-MTRR.h"
> +#----------------------------------------------------------------------------
> +
> +
> + ### @brief The base address of temporary page table for accessing PCIE
> MMIO base address above 4G in PEI phase.
> + ### @brief Permitted Choices: 0x0 - 0xFFFFFFFF (Type: Value)(Default: 0)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPeiTempPageTableBaseAddress|0
> |UINT32|0x000CC11B
> +
> +#----------------------------------------------------------------------------
> +#- CCX ACPI Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-CCX-ACPI.h"
> +#----------------------------------------------------------------------------
> + #ACPI
> + # Cpu SSDT
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName
> 0|0x43|UINT8|0x000AC001
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName
> 1|0x30|UINT8|0x000AC002
> + ### @brief This element specifies whether the ACPI _PSS objects are
> defined in the system bus or processor scope.
> + ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
> + ### @li TRUE - The objects will be under the \_SB scope.
> + ### @li FALSE - The objects will be under the \_PR scope
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeInSb|
> FALSE|BOOLEAN|0x000AC003
> +
> + ### @brief Set the OEM ID field in ACPI table outputs to this string. The
> string must conform to the ACPI rules for the OEM ID field.
> + ### @brief Permitted Choices: (Type: Value)(Default: "AMD")
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|V
> OID*|0x000AC004
> +
> +#----------------------------------------------------------------------------
> +#- CCX SMBIOS Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-CCX-SMBIOS.h"
> +#----------------------------------------------------------------------------
> +
> + ### @name CCX SMBIOS Controls
> +
> + ### @brief When creating the SMBios table entry, use this as the label for
> the processor socket. This should match the
> + ### silkscreen label on the motherboard.
> + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|
> "Unknown"|VOID*|0x00001001
> +
> + ### @brief When creating the SMBios table entry, use this as the value for
> the 'serial number' field for each processor.
> + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket0|"Unk
> nown"|VOID*|0x00001002
> +
> +
> + ### @brief When creating the SMBios table entry, use this as the value for
> the 'Asset Tag' field for each processor.
> + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket0|"Unknow
> n"|VOID*|0x00001003
> +
> + ### @brief When creating the SMBios table entry, use this as the value for
> the 'Part Number' field for each processor.
> + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unkn
> own"|VOID*|0x00001004
> +
> + ### @brief SMBios socket 1 Label.
> + ### @details When creating the SMBios table entry, use this as the label
> for the
> + ### processor socket. This should match the silkscreen label on the
> motherboard.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|
> "Unknown"|VOID*|0x00001005
> +
> + ### @brief SMBIOS socket 1 Serial Number.
> + ### @details When creating the SMBios table entry, use this as the value
> for
> + ### the 'serial number' field for the processor in socket 1.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket1|"Unk
> nown"|VOID*|0x00001006
> +
> + ### @brief SMBios socket 1 Asset Tag.
> + ### @details When creating the SMBios table entry, use this as the value
> for
> + ### the 'Asset Tag' field for the processor in socket 1.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket1|"Unknow
> n"|VOID*|0x00001007
> +
> + ### @brief Socket 1 Part Number.
> + ### @details When creating the SMBios table entry, use this as the value
> for
> + ### the 'Part Number' field for the processor in socket 1.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket1|"Unkn
> own"|VOID*|0x00001008
> +
> +#----------------------------------------------------------------------------
> +#- ACPI Fixed PCDs
> +#-
> +### Set Doxy_path: "PCD-ACPI.h"
> +#----------------------------------------------------------------------------
> +
> + ### @name General ACPI Controls
> +
> + ### @brief PCD supporting maximum capacity for Type 16 table
> + ### @details This PCD represents maximum memory capacity in KB
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT16MaximumCapacity|0x0
> 4000000|UINT32|0x00001009 # 4G - 0x00400000
> + # 8G - 0x00800000
> + # 16G - 0x01000000
> + # 32G - 0x02000000
> + # 64G - 0x04000000
> + # 128G - 0x08000000
> + # 256G - 0x10000000
> + # 512G - 0x20000000
> +[PcdsDynamic]
> +#----------------------------------------------------------------------------
> +# System level Dynamic PCDs
> +### Set Doxy_path: "PCD-Sys.h"
> +#----------------------------------------------------------------------------
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCStateIoBaseAddress|0x413|UINT
> 16|0x000CC002
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x0
> 00CC00B
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC0
> 1D
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x00
> 0CC200
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerIn
> Sb|FALSE|BOOLEAN|0x000CC50B
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerNa
> me|"PLTF"|VOID*|0x000CC50C
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEA
> N|0x000CC601
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16
> |0x000CC900
> +#----------------------------------------------------------------------------
> +#- DF Dynamic PCDs
> +### Set Doxy_path: "PCD-DF.h"
> +#----------------------------------------------------------------------------
> +
> +
> + ### @cond (FF3||RN||BA||ZP||RMB||RPL||RS||SSP||MI3||BRH)
> + ### @brief Specifies the top address to be used for MMIO space
> allocations. No MMIO space will be used above this limit. Some devices have
> limits on the address space they
> + ### are able to access. For example a device with a 40-bit address
> limitation can not use MMIO space above 1TeraByte (1T). By setting this PCD
> to 0x10000000000 (1T), MMIO
> + ### space would not be allocated above 1T. The default is to use all of the
> space above the end of physical memory.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMmioAbove4GLimit|0xFFFFFFFFFF
> FFFFFF|UINT64|0x0003FFC2
> + ### @endcond
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFabricResourceDefaultSizePtr|0|U
> INT64|0x00DF0000
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UIN
> T16|0x0003FFC0
> +
> + ### I2C-0
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UIN
> T32|0x000FC000
> + ### I2C-1
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UIN
> T32|0x000FC001
> + ### I2C-2
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UIN
> T32|0x000FC002
> + ### I2C-3
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UIN
> T32|0x000FC003
> + ### I2C-4
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UIN
> T32|0x000FC004
> + ### I2C-5
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UIN
> T32|0x000FC005
> + ### @} end of I2C hold times
> +
> +#----------------------------------------------------------------------------
> +#- FCH Dynamic PCDs
> +### Set Doxy_path: "PCD-FCH-UART.h"
> +#----------------------------------------------------------------------------
> + ### @name UART Legacy IO Assignments
> + ### @{
> + ### @brief These controls allow the platform to specify the legacy IO
> ranges that are to be used by the UART ports in the processor. Permitted
> Choices: (Type: value)(Default: Disabled)
> + ### @li 0 - Disabled
> + ### @li 1 - IO range 0x02E8 - 0x02EF
> + ### @li 2 - IO range 0x02F8 - 0x02FF
> + ### @li 3 - IO range 0x03E8 - 0x03EF
> + ### @li 4 - IO range 0x03F8 - 0x03FF
> +
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.FchUart0LegacyEnable|0x00|UINT8|0x000
> FC010
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.FchUart1LegacyEnable|0x00|UINT8|0x000
> FC011
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.FchUart2LegacyEnable|0x00|UINT8|0x000
> FC012
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.FchUart3LegacyEnable|0x00|UINT8|0x000
> FC013
> + ### @} end UART Legacy IO assignments
> +
> +#----------------------------------------------------------------------------
> +#- FCH Dynamic PCDs
> +### Set Doxy_path: "PCD-FCH-USB.h"
> +#----------------------------------------------------------------------------
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci0Enable|TRUE|BOOLEAN|0x000FC
> 020
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci1Enable|TRUE|BOOLEAN|0x000FC
> 021
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci2Enable|TRUE|BOOLEAN|0x000FC
> 022
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci3Enable|TRUE|BOOLEAN|0x000FC
> 023
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhciECCDedErrRptEn|FALSE|BOOLEAN
> |0x000FC024
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC0
> 30
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN
> |0x000FC039
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x00
> 0A6024
> +
> +#----------------------------------------------------------------------------
> +#- NBIO Dynamic PCDs
> +### Set Doxy_path: "PCD-NBIO-BMC.h"
> +#----------------------------------------------------------------------------
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN
> |0x0004F004
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x00
> 04F005
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkDie|0xFF|UINT8|0x0004F
> 006
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkLaneNum|0|UINT8|0x000
> 4F03E
> +
> +#----------------------------------------------------------------------------
> +#- NBIO Dynamic PCDs
> +### Set Doxy_path: "PCD-NBIO.h"
> +#----------------------------------------------------------------------------
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgIommuSupport|TRUE|BOOLEAN|0x
> 0004F027
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdIvInfoDmaReMap|FALSE|BOOLEAN|0x
> 0004F028
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrVddfull_Scale_Curren
> t|0x00|UINT32|0x0004F0A0
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Curren
> t|0x00|UINT32|0x0004F0A2
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0
> x0004F210
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT
> 32|0x0004F211
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT
> 8|0x0004F362
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|U
> INT8|0x0004F363
> +
> +#----------------------------------------------------------------------------
> +#- PSP Dynamic PCDs
> +### Set Doxy_path: "PCD-PSP.h"
> +#----------------------------------------------------------------------------
> + ### PSP PCDs DYNAMIC
> +
> + ### @brief This feature selects the APCB recovery support on x86 side. If
> or when an instance of a writable APCB is determined to be invalid, the PSP
> driver will
> + ### attempt a 'recovery' by copying the recovery instance of the APCB
> (default values as indicated in the APCB descriptor files). Upon boot up, the
> ABL reads CMOS
> + ### bytes 06/07 at index/data port of 0x72/0x73. If the CMOS flag reads
> anything else other than 0xA55A or 0x5555, the system boots in APCB
> recovery mode, in which
> + ### ABL consumes the recovery instances of APCB. Otherwise it boots in
> normal/non-recovery mode.
> + ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE)
> + ### @brief This feature is affected by the platform CMOS power design.
> Please see Platform CMOS power .
> + ### @li TRUE - the AGESA PSP driver restores the APCB instances from the
> recovery instance, writes 0xA55A to the CMOS location and triggers a reset .
> The next time
> + ### the system powers up, ABL runs in normal/non-recovery mode.
> + ### @li FALSE - the AGESA PSP driver writes 0x5555 to the CMOS location
> without restoring the APCB instances or triggering a reset. In this mode the
> additional reset
> + ### is avoided at the potential risk of the writeable APCB instance being left
> corrupted forever.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|B
> OOLEAN|0x95940008
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE
> |BOOLEAN|0x95940018
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BO
> OLEAN|0x00030004
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|
> TRUE|BOOLEAN|0x00030005
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|F
> ALSE|BOOLEAN|0x00030006
> +[PcdsDynamicEx]
> +
> +[PcdsFixedAtBuild, PcdsDynamic]
> +#----------------------------------------------------------------------------
> +#- System control PCDs
> +### Set Doxy_path: "PCD-Sys.h"
> +#----------------------------------------------------------------------------
> + ### @brief Switch for Debug Print function
> + ### @details Switch for Debug Print function to enable or not.
> + ### @li TRUE: Enable IdsDebugPrint output
> + ### @li FALSE: Disable IdsDebugPrint output
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEnable|FALSE|BOOL
> EAN|0x00020004
> + ### @brief Specify the filter for IdsDebugPrint
> + ### @details When the filter values are matched, the AmdIdsDebugPrint
> can start to print debug message.
> + ### Refer Library/IdsLib.h for details, and the Master token is
> PcdAmdIdsDebugPrintEnable.
> + ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC |
> GFX_MISC | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU |
> FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
> + ### @li 0x100401008A300408: (GNB_TRACE | PCIE_MISC | NB_MISC |
> GFX_MISC | CPU_TRACE | MEM_FLOW | FCH_TRACE | MAIN_FLOW|
> TEST_POINT | PSP_TRACE)
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintFilter|0x100401030
> A300408|UINT64|0x00020005
> + ### @brief Switch for Serial port support of AGESA debug print
> + ### @details Switch for Serial port support of AGESA debug print, NOTE,
> AGESA will not init the serial port,
> + ### serial port should be initialized before call AGESA debug print.
> + ### @li TRUE: Enable
> + ### @li FALSE: Disable
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortEnable|FA
> LSE|BOOLEAN|0x00020009
> + ### @brief The serial port used for debug output can be either 2-wire
> (Rx/Tx) or 4-wire (adding DSR/CTS). Waiting for CTS on a
> + ### 2-wire port would cause a hang. This control is added to check the
> cable connection.
> + ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
> + ### @li FALSE - Presume a 2-wire port and do not wait for CTS.
> + ### @li TRUE - Wait for both DSR and CTS to be set. DSR is set if a cable is
> connected. CTS is set if it is ok to transmit data.
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCabl
> eConnection|FALSE|BOOLEAN|0x0002000A
> +
> + ### @brief Selection of UART and UART Legacy IO Serial port for AGESA
> debug print
> + ### @details Selection of UART and UART Legacy IO Serial port for AGESA
> debug print and invisible in ACPI name space.
> + ### @li Bit[0]: Select UART0 for AGESA debug print
> + ### @li Bit[1]: Select UART1 for AGESA debug print
> + ### @li Bit[2]: Select UART2 for AGESA debug print
> + ### @li Bit[3]: Select UART3 for AGESA debug print
> + ### @li Bit[4]: Select UART4 for AGESA debug print
> + ### @li Bit[8]: Select UART0 Legacy IO for AGESA debug print
> + ### @li Bit[9]: Select UART1 Legacy IO for AGESA debug print
> + ### @li Bit[10]: Select UART2 Legacy IO for AGESA debug print
> + ### @li Bit[11]: Select UART3 Legacy IO for AGESA debug print
> + ### @li Bit[15]: Set debug print serial port to invisible in ACPI name space
> at OS runtime
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortSelect|0x0
> 000|UINT16|0x0002718A
> +
> + ### @brief Specify the IO port for serial out
> + ### @details ESPI or LPC COM1: 0x3F8, COM2: 0x2F8, COM3: 0x3E8,
> COM4: 0x2E8,
> + ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000,
> UART3: 0xFEDCF000, UART4: 0xFEDD1000.
> + ### @li If it's IO port: it must < 0x10000
> + ### @li If it's Memory: it must >= 0x10000
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UI
> NT64|0x0002000B
> +
> + ### @brief Debug Print Emulation Auto Detect
> + ### @details Auto detect emulation platform to instead of
> PcdAmdIdsDebugPrintRedirectIOEnable and
> + ### PcdAmdIdsDebugPrintSerialPortEnable.
> + ### @li TRUE: Enable
> + ### @li FALSE: Disable
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetec
> t|FALSE|BOOLEAN|0x00020016
> +
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgPlatformPPT|0|UINT32|0x0004F11
> 1
> +
> +#----------------------------------------------------------------------------
> +#- PSP Dynamic PCDs
> +### Set Doxy_path: "PCD-PSP.h"
> +#----------------------------------------------------------------------------
> + ### PSP PCDs
> +
> + ### @brief Rom Armor selection
> + ### @details Rom Armor selection
> + ### @li 0: Rom Armor is disabled
> + ### @li 1: Rom Armor 1 is enabled (VMR/MTS/CPK)
> + ### @li 2: Rom Armor 2 is enabled (RN/CZN)
> + ### @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
> + ### @li 0x1: PSP fTPM
> + ### @li 0x2: HSP fTPM
> + ### @li 0xFF: no TPM
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8
> |0x95940024
> +
> + ### @cond !BRH
> + ### @brief TPM SMx algorithm flag
> + ### @details TPM SMx algorithm flag, SBIOS needs to set the value in PEI
> phase.
> + ### @li 0: SM2, SM3 or SM4 crypto algorithms not supported
> + ### @li 1: SM2, SM3 or SM4 crypto algorithms supported
> +
> gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmAlgSmx|0|UINT8|0
> x95940025
> + ### @endcond
> diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
> b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
> new file mode 100755
> index 0000000000..c8c474637f
> --- /dev/null
> +++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
> @@ -0,0 +1,41 @@
> +## @file
> +# AMD Common Platform Module (CPM) Module Package DEC.
> +#
> +# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEC_SPECIFICATION = 0x00010005
> + PACKAGE_NAME = CpmPkg
> + PACKAGE_GUID = ABE128BA-1061-4A53-A1B8-D07329AA7A67
> + PACKAGE_VERSION = 0.1
> +
> +[Includes]
> + Include
> + Library
> +
> +[Guids]
> + gAmdCpmPkgTokenSpaceGuid = {0x916e0ddd, 0x2bd2, 0x4704, {0x93,
> 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}}
> + gShellActHiiGuid = {0x340EBE97, 0x3C1C, 0x4272, {0x9C, 0xCE,
> 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}}
> + gAmdPbsSystemConfigurationGuid = {0xa339d746, 0xf678, 0x49b3, {0x9f,
> 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}}
> +
> +[Protocols]
> + gAmdCpmTableProtocolGuid = { 0x3724cf01, 0x00c2, 0x9762,
> {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }}
> + gAmdCpmAllPciIoProtocolsInstalledProtocolGuid = { 0x676D7012, 0x139B,
> 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }}
> +
> +[Ppis]
> + gAmdCpmTablePpiGuid = { 0xd71cf893, 0xa8b5, 0x49d3, { 0xa2, 0x1b,
> 0x31, 0xe2, 0xf5, 0xc4, 0xa7, 0x47 } }
> +
> +[PcdsFixedAtBuild]
> + gAmdCpmPkgTokenSpaceGuid.PcdFchUartPort|2|UINT8|0x00000052
> +
> + #ACPI
> +
> gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiHestTableHeaderOemTableId|"A
> MD HEST"|VOID*|0x000AC001
> +
> gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiBertTableHeaderOemTableId|"A
> MD BERT"|VOID*|0x000AC002
> +
> gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiEinjTableHeaderOemTableId|"AM
> D EINJ"|VOID*|0x000AC003
> +
> +
> gAmdCpmPkgTokenSpaceGuid.UsePciXAslName|FALSE|BOOLEAN|0x120000
> 03
> +
> gAmdCpmPkgTokenSpaceGuid.AcpiRestoreSwSmi|0xE3|UINT8|0x00000040
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
> b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
> new file mode 100644
> index 0000000000..37b8d15cb1
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
> @@ -0,0 +1,18 @@
> +## @file
> +#
> +# 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.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[LibraryClasses]
> +
> NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioComm
> onDxeLib.inf
> +
> + ## Gnb Lib
> + NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
> + PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> +
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
> b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
> new file mode 100644
> index 0000000000..e7e05fd2d8
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
> @@ -0,0 +1,48 @@
> +## @file
> +# The AGESA DSC file for building AMD SP5 Genoa boards.
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[LibraryClasses.Common.PEIM]
> +
> + ## APCB
> + ApcbLibV3Pei|AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
> +
> +[LibraryClasses.Common.DXE_DRIVER]
> +
> AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/A
> mdPspRomArmorLibNull.inf
> + ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> +
> +[LibraryClasses.Common.DXE_SMM_DRIVER]
> +
> AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/A
> mdPspRomArmorLibNull.inf
> + ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> +
> +[LibraryClasses]
> + #
> + # Agesa specific common libraries
> + #
> +
> + ## PSP Libs
> +
> AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspM
> boxLibV2.inf
> +
> + ## DF Lib
> +
> BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/B
> aseFabricTopologyRsLib.inf
> +
> + ## Gnb Lib
> + NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
> + PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> + SmnAccessLib|AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
> +
> NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioComm
> onDxeLib.inf
> +
> + ## Fch Lib
> + FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
> +
> +[Components.IA32]
> + AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
> +
> +[Components.X64]
> + AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> +
> diff --git
> a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
> b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
> new file mode 100644
> index 0000000000..1f1e04c414
> --- /dev/null
> +++
> b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
> @@ -0,0 +1,8 @@
> +## @file
> +#
> +# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Am
> dCpmGenoaQuartzPkg.inc.dsc
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.inc.dsc
> new file mode 100644
> index 0000000000..2916fecb26
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.inc.dsc
> @@ -0,0 +1,11 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + DEFINE AGESA_PKG_PATH = AgesaModulePkg
> + DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
> diff --git
> a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
> b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
> new file mode 100644
> index 0000000000..9303d1fac4
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
> @@ -0,0 +1,11 @@
> +## @file
> +# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
> +#
> +# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +## APCB V3 Dxe Drivers
> + INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
> b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
> new file mode 100644
> index 0000000000..0ef5a2a806
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
> @@ -0,0 +1,9 @@
> +## @file
> +# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
> +#
> +# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> diff --git
> a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.in
> c.fdf
> b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.in
> c.fdf
> new file mode 100644
> index 0000000000..4766ad0447
> --- /dev/null
> +++
> b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.in
> c.fdf
> @@ -0,0 +1,7 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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
> new file mode 100644
> index 0000000000..4766ad0447
> --- /dev/null
> +++
> b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc
> .fdf
> @@ -0,0 +1,7 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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.dx
> e.inc.fdf
> new file mode 100644
> index 0000000000..da3afe6e59
> --- /dev/null
> +++
> b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dx
> e.inc.fdf
> @@ -0,0 +1,8 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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
> new file mode 100644
> index 0000000000..da3afe6e59
> --- /dev/null
> +++
> b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei
> .inc.fdf
> @@ -0,0 +1,8 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Am
> dCpmGenoaQuartzPkg.dxe.inc.fdf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.dxe.inc.fdf
> new file mode 100644
> index 0000000000..4766ad0447
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.dxe.inc.fdf
> @@ -0,0 +1,7 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Am
> dCpmGenoaQuartzPkg.fdf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.fdf
> new file mode 100644
> index 0000000000..b790e4ead5
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.fdf
> @@ -0,0 +1,10 @@
> +## @file
> +#
> +# Platform Package Flash Description File
> +#
> +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Am
> dCpmGenoaQuartzPkg.pei.inc.fdf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.pei.inc.fdf
> new file mode 100644
> index 0000000000..4766ad0447
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/A
> mdCpmGenoaQuartzPkg.pei.inc.fdf
> @@ -0,0 +1,7 @@
> +## @file
> +#
> +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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
> new file mode 100755
> index 0000000000..8d3357bf56
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
> @@ -0,0 +1,29 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = AmdCalloutLib
> + FILE_GUID = A8FEA621-B381-4c06-9E9D-0897EF78BD78
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = AmdCalloutLib
> +
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + PcdLib
> +
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.inf
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.inf
> new file mode 100644
> index 0000000000..1594a99265
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.inf
> @@ -0,0 +1,30 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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/AmdPspRo
> mArmorLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRo
> mArmorLib.inf
> new file mode 100644
> index 0000000000..c685a26604
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRo
> mArmorLib.inf
> @@ -0,0 +1,27 @@
> +## @file
> +#
> +# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = AmdPspRomArmorLib
> + FILE_GUID = 55871F80-4658-6EF3-A8AC-15B34FF8C2CE
> + MODULE_TYPE = DXE_SMM_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = AmdPspRomArmorLib
> +
> +[Sources.common]
> + AmdPspRomArmorLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.inf
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.inf
> new file mode 100644
> index 0000000000..a3906dc13e
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.inf
> @@ -0,0 +1,26 @@
> +## @file
> +#
> +# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = AmdPspRomArmorLibNull
> + FILE_GUID = 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = AmdPspRomArmorLibNull
> +
> +[Sources.common]
> + AmdPspRomArmorLibNull.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +
> diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> new file mode 100644
> index 0000000000..09d5bd38ac
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
> @@ -0,0 +1,37 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = ApcbLibV3
> + 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
> +
> +[Sources.common]
> + ApcbLibV3.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleMemPkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +[Protocols]
> + gEfiSmmBase2ProtocolGuid
> + gEfiSmmReadyToLockProtocolGuid
> +
> +[Pcd]
> +
> gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageR
> epairEntries
> +
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
> new file mode 100644
> index 0000000000..c031d00d79
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
> @@ -0,0 +1,32 @@
> +## @file
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = ApcbLibV3Pei
> + FILE_GUID = EEA4E007-E408-4daa-82BD-4C52E7058753
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = ApcbLibV3Pei|PEIM
> +
> +[Sources.common]
> + ApcbLibV3Pei.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleMemPkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +[LibraryClasses]
> + PcdLib
> + BaseMemoryLib
> + PeiServicesLib
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.inf
> new file mode 100644
> index 0000000000..38a72e26b7
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.inf
> @@ -0,0 +1,28 @@
> +## @file
> +#
> +# For EDKII use Only
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BaseFabricTopologyRsLib
> + FILE_GUID = D0A070DD-630A-43F8-9D76-EAAABDDE5FB9
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BaseFabricTopologyLib
> + CONSTRUCTOR = BaseFabricTopologyLibConstructor
> +
> +[Sources]
> + BaseFabricTopologyRsLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleDfPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.i
> nf
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.i
> nf
> new file mode 100644
> index 0000000000..d15d8169fe
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.i
> nf
> @@ -0,0 +1,35 @@
> +## @file
> +# Base Timer Library which uses the Time Stamp Counter in the processor.
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BaseTscTimerLib
> + FILE_GUID = D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = TimerLib
> +
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources.common]
> + TscTimerLibShare.c
> + BaseTscTimerLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleCcxPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + PcdLib
> + BaseLib
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.in
> f
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.i
> nf
> new file mode 100644
> index 0000000000..1e52768a01
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.i
> nf
> @@ -0,0 +1,42 @@
> +## @file
> +# Dxe Timer Library which uses the Time Stamp Counter in the processor.
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = DxeTscTimerLib
> + FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER
> DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
> SMM_CORE
> +
> + CONSTRUCTOR = DxeTscTimerLibConstructor
> +
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources.common]
> + TscTimerLibShare.c
> + DxeTscTimerLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleCcxPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + UefiBootServicesTableLib
> + PcdLib
> + BaseLib
> + UefiLib
> + DebugLib
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.in
> f
> new file mode 100644
> index 0000000000..b1eaefd282
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.in
> f
> @@ -0,0 +1,37 @@
> +## @file
> +# Pei Timer Library which uses the Time Stamp Counter in the processor.
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PeiTscTimerLib
> + FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = TimerLib|PEIM PEI_CORE
> +
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources.common]
> + TscTimerLibShare.c
> + PeiTscTimerLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleCcxPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + PcdLib
> + BaseLib
> + HobLib
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.inf
> new file mode 100644
> index 0000000000..f60f97905a
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.inf
> @@ -0,0 +1,42 @@
> +## @file
> +# Library instance of PciHostBridgeLib library class for coreboot.
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PciHostBridgeLib
> + FILE_GUID = 74967FD7-A9A4-4B16-8B41-B26BC3230D0A
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = PciHostBridgeLib
> +
> +#
> +# The following information is for reference only and not required by the
> build
> +# tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources]
> + PciHostBridgeLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleDfPkg.dec
> + AgesaModulePkg/AgesaModuleNbioPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + BaseMemoryLib
> + PciHostBridgeLib
> + DevicePathLib
> + MemoryAllocationLib
> + DebugLib
> + UefiBootServicesTableLib
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenera
> tionLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenera
> tionLib.inf
> new file mode 100644
> index 0000000000..2a72fa8117
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenera
> tionLib.inf
> @@ -0,0 +1,47 @@
> +## @file
> +#
> +# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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/FchBaseLib/FchBaseLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
> new file mode 100644
> index 0000000000..e63a70e849
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
> @@ -0,0 +1,26 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.inf
> new file mode 100644
> index 0000000000..e422cb69a4
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.inf
> @@ -0,0 +1,35 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = BaseResetSystemLib
> + FILE_GUID = e669c365-2df2-4540-a343-afec4e85b198
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = BaseResetSystemLib
> +
> +#
> +# VALID_ARCHITECTURES = IA32 X64
> +#
> +
> +[Sources]
> + FchBaseResetSystemLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaModulePkg/AgesaModuleFchPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + PrintLib
> + IoLib
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
> new file mode 100644
> index 0000000000..d7f49c40de
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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.inf
> b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
> new file mode 100755
> index 0000000000..f32bbc9ff2
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
> @@ -0,0 +1,24 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = NbioHandleLib
> + FILE_GUID = DC4639D3-DB75-486B-AC38-C84AA49601E3
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = NbioHandleLib
> +
> +[Sources]
> + NbioHandleLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleNbioPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> new file mode 100755
> index 0000000000..0d6ba605f5
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
> @@ -0,0 +1,25 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PcieConfigLib
> + FILE_GUID = C1205AD2-FE67-4502-A0A7-FB1704A3F9AE
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = PcieConfigLib
> +
> +[Sources]
> + PcieConfigLib.c
> + PcieInputParserLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleNbioPkg.dec
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
> b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
> new file mode 100644
> index 0000000000..ae1dd6cd83
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = SmnAccessLib
> + FILE_GUID = 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = SmnAccessLib
> +
> +[Sources]
> + SmnAccessLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleNbioPkg.dec
> +
> +[LibraryClasses]
> + PrintLib
> + BaseLib
> + DebugPrintErrorLevelLib
> +
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonD
> xeLib.inf
> b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonD
> xeLib.inf
> new file mode 100644
> index 0000000000..da7f5c185d
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonD
> xeLib.inf
> @@ -0,0 +1,29 @@
> +## @file
> +#
> +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = NbioCommonDxeLib
> + FILE_GUID = 1BF93335-5D55-46D9-99D9-5D962F039829
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = NbioCommonDxeLib
> +
> +[Sources]
> + DxeLibFunctions.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModuleNbioPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> new file mode 100644
> index 0000000000..54c3514020
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
> @@ -0,0 +1,45 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = AmdApcbDxeV3
> + FILE_GUID = 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7
> + MODULE_TYPE = DXE_DRIVER
> + VERSION_STRING = 1.0
> + ENTRY_POINT = AmdApcbV3DxeDriverEntry
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + PcdLib
> + BaseMemoryLib
> + UefiBootServicesTableLib
> + UefiRuntimeServicesTableLib
> + UefiDriverEntryPoint
> + DxeServicesTableLib
> + MemoryAllocationLib
> + ApcbLibV3
> +
> +[Sources]
> + ApcbV3Dxe.c
> +
> +[Protocols]
> + gEfiDxeSmmReadyToLockProtocolGuid
> + gEfiSmmCommunicationProtocolGuid
> +
> +[Depex]
> + TRUE
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
> new file mode 100644
> index 0000000000..7f90aa6ea0
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = AmdApcbPeiV3
> + FILE_GUID = E1B8CF4A-FE7B-4676-B4F7-50C7228282A4
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + ENTRY_POINT = AmdApcbV3PeiDriverEntry
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + PeimEntryPoint
> + ApcbLibV3Pei
> +
> +[sources]
> + ApcbV3Pei.c
> +
> +[Depex]
> + TRUE
> +
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.inf
> b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.inf
> new file mode 100755
> index 0000000000..0f115c362e
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.inf
> @@ -0,0 +1,27 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = OemAgesaCcxPlatformLibNull
> + FILE_GUID = B1F58B07-0146-4804-B701-A56CB5716529
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = OemAgesaCcxPlatformLib
> +
> +[Sources.common]
> + OemAgesaCcxPlatformLibNull.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> +
> +[Depex]
> + TRUE
> +
> +
> +
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.inf
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.inf
> new file mode 100644
> index 0000000000..ba551e5c14
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.inf
> @@ -0,0 +1,61 @@
> +## @file
> +#
> +# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PciExpressPciCfg2
> + FILE_GUID = 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + ENTRY_POINT = PeimInitializePciCfg
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
> +#
> +
> +[Sources]
> + PciExpressPciCfg2.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +
> +[LibraryClasses]
> + PeimEntryPoint
> + BaseLib
> + PcdLib
> + DebugLib
> + BaseMemoryLib
> + MemoryAllocationLib
> + HobLib
> + IoLib
> +
> +[Ppis]
> + gEfiPciCfg2PpiGuid ## PRODUCES
> +
> +[Pcd]
> + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
> +
> +[Pcd.IA32,Pcd.X64]
> + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ##
> SOMETIMES_CONSUMES
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMas
> k ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask
> ## CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ##
> CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ##
> SOMETIMES_CONSUMES
> +
> +[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
> + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ##
> SOMETIMES_CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ##
> SOMETIMES_CONSUMES
> + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ##
> SOMETIMES_CONSUMES
> +
> +[Depex]
> + TRUE
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciExpressPciSegmentInfoLib.inf
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciExpressPciSegmentInfoLib.inf
> new file mode 100644
> index 0000000000..e712a80886
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciExpressPciSegmentInfoLib.inf
> @@ -0,0 +1,32 @@
> +## @file
> +#
> +# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = PciExpressPciSegmentInfoLib
> + FILE_GUID = FA8B1082-88DF-4744-85A3-7F87A9EBF8DC
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = PciSegmentInfoLib
> +
> +#
> +# The following information is for reference only and not required by the
> build tools.
> +#
> +# VALID_ARCHITECTURES = IA32 X64 EBC
> +#
> +
> +[Sources]
> + PciSegmentInfoLib.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> +
> +[LibraryClasses]
> + DebugLib
> + BaseLib
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/A
> mdPspFlashAccSpiNorLibSmm.inf
> b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/
> AmdPspFlashAccSpiNorLibSmm.inf
> new file mode 100644
> index 0000000000..f4b9d0d789
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/
> AmdPspFlashAccSpiNorLibSmm.inf
> @@ -0,0 +1,45 @@
> +## @file
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = AmdPspFlashAccLibSmm
> + FILE_GUID = 3BBDC3A5-A0E2-4E8A-8240-9E594920F040
> + MODULE_TYPE = DXE_SMM_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = AmdPspFlashAccLib | DXE_SMM_DRIVER
> +
> +[Sources.common]
> + AmdPspFlashAccSpiNorLibSmm.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaModulePkg/AgesaModulePspPkg.dec
> + UefiCpuPkg/UefiCpuPkg.dec
> + AgesaPkg/AgesaPkg.dec
> +
> +[LibraryClasses]
> + AmdPspBaseLibV2
> + BaseLib
> + DebugLib
> + SmmServicesTableLib
> + UefiBootServicesTableLib
> +
> +[Protocols]
> + gEfiSmmBase2ProtocolGuid
> + gEfiSpiSmmNorFlashProtocolGuid
> +
> +[Pcd]
> + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize ##
> CONSUMES
> + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ##
> CONSUMES
> +
> +[Depex]
> + gEfiSmmBase2ProtocolGuid AND
> + gEfiSpiSmmNorFlashProtocolGuid
> +
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.inf
> b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.inf
> new file mode 100644
> index 0000000000..57bb0d9e25
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.inf
> @@ -0,0 +1,32 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010006
> + BASE_NAME = PspRomArmorWhitelistLib
> + FILE_GUID = B6F8507A-C96B-4036-A8C0-26BAD6AC5F34
> + MODULE_TYPE = DXE_SMM_DRIVER
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = PlatformPspRomArmorWhitelistLib
> +
> +[Sources]
> + PspRomArmorWhitelistLib.c
> +
> +[Packages]
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AgesaPkg/AgesaPkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + BaseMemoryLib
> + MemoryAllocationLib
> + PcdLib
> + DebugLib
> +
> +[Depex]
> + TRUE
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
> new file mode 100644
> index 0000000000..64fd2913ad
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
> @@ -0,0 +1,42 @@
> +## @file
> +#
> +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +#
> +# 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
> +
> +
> +
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatform.inf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatform.inf
> new file mode 100644
> index 0000000000..f4d7638c1a
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatform.inf
> @@ -0,0 +1,32 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.inf
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.inf
> new file mode 100644
> index 0000000000..973ace8632
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.inf
> @@ -0,0 +1,29 @@
> +## @file
> +#
> +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.inf
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.inf
> new file mode 100644
> index 0000000000..2d9dbeb715
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.inf
> @@ -0,0 +1,53 @@
> +## @file
> +#
> +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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
> + UNLOAD_IMAGE = ActLibraryUnregisterActCommand
> + UEFI_HII_RESOURCE_SECTION = TRUE
> +
> +[Sources.common]
> + AmdAutoDynamicCommand.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + ShellPkg/ShellPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AmdCpmPkg/AmdCpmPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + UefiLib
> + FileHandleLib
> + HiiLib
> + DebugLib
> + BaseMemoryLib
> + MemoryAllocationLib
> + UefiRuntimeServicesTableLib
> + UefiDriverEntryPoint
> + UefiBootServicesTableLib
> + UefiHiiServicesLib
> +
> +[Guids]
> + gShellActHiiGuid ## SOMETIMES_CONSUMES ## HII
> + gAgesaConfigDbPointerVariableGuid
> +
> +[Protocols]
> + gEfiShellDynamicCommandProtocolGuid
> + gEfiHiiPackageListProtocolGuid
> + gEfiShellParametersProtocolGuid
> + gEfiUnicodeCollation2ProtocolGuid
> +
> +[DEPEX]
> + TRUE
> diff --git
> a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.inf
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.inf
> new file mode 100644
> index 0000000000..98c8755ab8
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.inf
> @@ -0,0 +1,50 @@
> +## @file
> +#
> +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# 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
> +#
> +# This flag specifies whether HII resource section is generated into PE image.
> +#
> + UEFI_HII_RESOURCE_SECTION = TRUE
> +
> +[Sources.common]
> + AmdAutoToolApp.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + ShellPkg/ShellPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AgesaModulePkg/AgesaCommonModulePkg.dec
> + AmdCpmPkg/AmdCpmPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + FileHandleLib
> + HiiLib
> + MemoryAllocationLib
> + UefiApplicationEntryPoint
> + UefiBootServicesTableLib
> + UefiHiiServicesLib
> + UefiLib
> + UefiRuntimeServicesTableLib
> +
> +[Protocols]
> + gEfiHiiPackageListProtocolGuid ## CONSUMES
> + gEfiShellParametersProtocolGuid
> + gEfiUnicodeCollation2ProtocolGuid
> +
> +[Guids]
> +
> diff --git
> a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.inf
> b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.inf
> new file mode 100644
> index 0000000000..9c3c0dd0a9
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.inf
> @@ -0,0 +1,33 @@
> +## @file
> +#
> +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = BasePlatformHookLibAmdFchUart
> + FILE_GUID = BF2F3F3F-4BE6-4B97-850D-D5D4941D391C
> + MODULE_TYPE = BASE
> + VERSION_STRING = 1.0
> + LIBRARY_CLASS = PlatformHookLib
> +
> +[Sources]
> + BasePlatformHookLibAmdFchUart.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + AmdCpmPkg/AmdCpmPkg.dec
> + AgesaModulePkg/AgesaModuleFchPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + PcdLib
> + IoLib
> + PlatformHookLib
> +
> +
> +
> diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h
> b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
> new file mode 100644
> index 0000000000..3ec03aafd3
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
> @@ -0,0 +1,158 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AGESA_H_
> +#define AGESA_H_
> +
> +#include "AMD.h"
> +#include "SocLogicalId.h"
> +
> +#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
> +#define DESCRIPTOR_IGNORE 0x40000000ull
> +#define DESCRIPTOR_INITIALIZE_LIST 0x20000000ull
> +
> +/// PCIe link initialization
> +typedef enum {
> + EndpointDetect = 0, ///< Detect endpoint presence
> + EndpointNotPresent ///< Endpoint not present (or
> connected). Used in case there is alternative way to determine
> + ///< if device present on board or in slot.
> For example GPIO can be used to determine device presence.
> +} PCIE_ENDPOINT_STATUS;
> +
> +/// PCIe port misc extended controls
> +typedef struct {
> + IN UINT8 LinkComplianceMode : 1; ///< Force port into
> compliance mode (device will not be trained, port output compliance pattern)
> + IN UINT8 LinkSafeMode : 2; ///< Safe mode PCIe capability.
> (Parameter may limit PCIe speed requested through
> PCIe_PORT_DATA::LinkSpeedCapability)
> + ///< 0 - port can advertise maximum
> supported capability
> + ///< 1 - port limit advertized capability and
> speed to PCIe Gen1
> + IN UINT8 SbLink : 1; ///< PCIe link type
> + ///< 0 - General purpose port
> + ///< 1 - Port connected to SB
> + IN UINT8 ClkPmSupport : 1; ///< Clock Power Management
> Support
> + ///< 0 - Clock Power Management not
> configured
> + ///< 1 - Clock Power Management
> configured according to PCIe device capability
> + IN UINT8 CsLink : 1; ///< PCIe link type
> + ///< 0 - General purpose port
> + ///< 1 - Port connected to chipset
> + IN UINT8 Reserved0 : 2; ///< Unused space
> +} PCIE_PORT_MISC_CONTROL;
> +
> +/// The IO APIC Interrupt Mapping Info
> +typedef struct {
> + IN UINT8 GroupMap; ///< Group mapping for slot or
> endpoint device (connected to PCIE port) interrupts .
> + ///< - IGNORE THIS STRUCTURE AND USE
> RECOMMENDED SETTINGS
> + ///< - mapped to Grp 0 (Interrupts 0..3 of
> IO APIC redirection table)
> + ///< - mapped to Grp 1 (Interrupts 4..7 of
> IO APIC redirection table)
> + ///< - mapped to Grp 7 (Interrupts 28..31
> of IO APIC redirection table)
> + IN UINT8 Swizzle; ///< Swizzle interrupt in the Group.
> + ///< - ABCD
> + ///< - BCDA
> + ///< - CDAB
> + ///< - DABC
> + IN UINT8 BridgeInt; ///< IOAPIC redirection table entry
> for PCIE bridge interrupt
> + ///< - Entry 0 of IO APIC redirection table
> + ///< - Entry 1 of IO APIC redirection table
> + ///< - Entry 31 of IO APIC redirection table
> +} APIC_DEVICE_INFO;
> +
> +/// GEN3 RxAdaptMode Configuration Structure
> +typedef struct {
> + IN BOOLEAN InitOffsetCancellation; ///< Initial Offset
> Cancellation Enable
> + IN UINT8 DFEControl; ///< DFE Control
> + IN UINT8 LEQControl; ///< LEQ Control
> + IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic Offset
> Calibration Enable
> + IN BOOLEAN FOMCalculation; ///< FOM Calculation
> Enable
> + IN BOOLEAN PIOffsetCalibration; ///< PI Offset Calibratino
> Enable
> +} RX_ADAPT_MODE;
> +
> +/// PCIe port configuration data
> +typedef struct {
> + IN UINT8 PortPresent; ///< Enable PCIe port for
> initialization.
> + IN UINT8 ChannelType; ///< Channel type.
> + ///< 0 - "lowLoss",
> + ///< 1 - "highLoss",
> + ///< 2 - "mob0db",
> + ///< 3 - "mob3db",
> + ///< 4 - "extnd6db"
> + ///< 5 - "extnd8db"
> + IN UINT8 DeviceNumber; ///< PCI Device number for
> port.
> + ///< 0 - Native port device number
> + ///< N - Port device number (See
> available configurations in BKDG
> + IN UINT8 FunctionNumber; ///< Reserved for future use
> + IN UINT8 LinkSpeedCapability; ///< PCIe link speed/
> + ///< 0 - Maximum supported by silicon
> + ///< 1 - Gen1
> + ///< 2 - Gen2
> + ///< 3 - Gen3
> + IN UINT8 LinkAspm; ///< ASPM control. (see
> AgesaPcieLinkAspm for additional option to control ASPM)
> + ///< 0 - Disabled
> + ///< 1 - L0s only
> + ///< 2 - L1 only
> + ///< 3 - L0s and L1
> + IN UINT8 LinkHotplug; ///< Hotplug control.
> + ///< 0 - Disabled
> + ///< 1 - Basic
> + ///< 2 - Server
> + ///< 3 - Enhanced
> + IN UINT8 ResetId; ///< Arbitrary number greater
> than 0 assigned by platform firmware for GPIO
> + ///< identification which control reset for
> given port.
> + ///< Each port with unique GPIO should
> have unique ResetId assigned.
> + ///< All ports use same GPIO to control
> reset should have same ResetId assigned.
> + ///< see AgesaPcieSlotResetContol.
> + IN UINT16 SlotNum; ///< Physical Slot Number
> + IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc extended
> controls
> + IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device
> programming info
> + IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint
> (device connected to PCIe port) status
> + IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3
> RxAdaptMode configuration
> +} PCIE_PORT_DATA;
> +
> +/// PCIe Complex descriptor
> +typedef struct {
> + IN UINT32 Flags; ///< Descriptor flags
> + ///< Bit31 - last descriptor in topology
> + IN UINT32 SocketId; ///< Socket Id
> + IN VOID *Reserved; ///< Reserved for future use
> +} PCIE_COMPLEX_DESCRIPTOR;
> +
> +/// VBIOS image info
> +typedef struct {
> + IN AMD_CONFIG_PARAMS StdHeader; ///< Standard
> configuration header
> + OUT VOID *ImagePtr; ///< Pointer to VBIOS image
> + IN PCI_ADDR GfxPciAddress; ///< PCI address of integrated
> graphics controller
> + IN UINT32 Flags; ///< BIT[0] - special repost requred
> +} GFX_VBIOS_IMAGE_INFO;
> +
> +//
> +// CPU MSR Register definitions
> +//
> +#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture
> Programming manual.
> +#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture
> Programming manual.
> +#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture
> Programming manual.
> +
> +///
> +/// VDDP_VDDR Voltage Info for Low Power DIMM
> +///
> +typedef struct _VDDP_VDDR_VOLTAGE {
> + IN BOOLEAN IsValid; ///< Indicates if daata is valid
> + IN UINT8 Voltage; ///< VDDP VDDR Voltage Value
> +} VDDP_VDDR_VOLTAGE;
> +
> +// CPU Build Configuration structures and definitions
> +
> +#define AMD_AP_MTRR_FIX64k_00000 0x00000250ul ///< Refer to
> AMD64 Architecture Programming manual.
> +#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to
> AMD64 Architecture Programming manual.
> +#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to
> AMD64 Architecture Programming manual.
> +#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to
> AMD64 Architecture Programming manual.
> +#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to
> AMD64 Architecture Programming manual.
> +#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to
> AMD64 Architecture Programming manual
> +#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to
> AMD64 Architecture Programming manual
> +#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to
> AMD64 Architecture Programming manual
> +#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to
> AMD64 Architecture Programming manual
> +#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to
> AMD64 Architecture Programming manual
> +#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to
> AMD64 Architecture Programming manual
> +
> +#endif // AGESA_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h
> b/Platform/AMD/AgesaModulePkg/Include/AMD.h
> new file mode 100755
> index 0000000000..062d9e1e1a
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
> @@ -0,0 +1,91 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_H_
> +#define AMD_H_
> +
> +/// The return status for all AGESA public services.
> +///
> +/// Services return the most severe status of any logged event. Status other
> than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
> +/// will have log entries with more detail.
> +///
> +typedef enum {
> + AGESA_SUCCESS = 0, ///< 0 - The service completed normally. Info
> may be logged.
> + AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct had
> an unimplemented function requested.
> + ///< Not logged.
> + AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of
> range and the service was not provided.
> + ///< Example, memory address not installed, heap buffer
> handle not found.
> + ///< Not Logged.
> + AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP
> communications (used in ABL)
> + AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in ABL)
> +
> + // AGESA_STATUS of greater severity (the ones below this line), always have
> a log entry available.
> + AGESA_ALERT, ///< 5 - An observed condition, but no loss of
> function. See Log.
> + AGESA_WARNING, ///< 6 - Possible or minor loss of function. See
> Log.
> + AGESA_ERROR, ///< 7 - Significant loss of function, boot may be
> possible. See Log.
> + AGESA_CRITICAL, ///< 8 - Continue boot only to notify user. See
> Log.
> + AGESA_FATAL, ///< 9 - Halt booting. See Log, however Fatal
> errors pertaining to heap problems
> + ///< may not be able to reliably produce log events.
> + AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory
> Overclock failure. (used in ABL)
> + AGESA_SKIP_ERROR, ///< 11 - Error, Skip init steps. (used in ABL)
> + AgesaStatusMax ///< Not a status, for limit checking.
> +} AGESA_STATUS;
> +
> +/**
> + Callout method to the host environment.
> +
> + Callout using a dispatch with appropriate thunk layer, which is determined
> by the host environment.
> +
> + @param[in] Function The specific callout function being invoked.
> + @param[in] FcnData Function specific data item.
> + @param[in,out] ConfigPtr Reference to Callout params.
> +**/
> +typedef AGESA_STATUS (*CALLOUT_ENTRY) (
> + IN UINT32 Function,
> + IN UINTN FcnData,
> + IN OUT VOID *ConfigPtr
> + );
> +
> +/// AGESA Structures
> +
> +/// Extended PCI address format
> +typedef struct {
> + IN OUT UINT32 Register : 12; ///< Register offset
> + IN OUT UINT32 Function : 3; ///< Function number
> + IN OUT UINT32 Device : 5; ///< Device number
> + IN OUT UINT32 Bus : 8; ///< Bus number
> + IN OUT UINT32 Segment : 4; ///< Segment
> +} EXT_PCI_ADDR;
> +
> +/// Union type for PCI address
> +typedef union _PCI_ADDR {
> + IN UINT32 AddressValue; ///< Formal address
> + IN EXT_PCI_ADDR Address; ///< Extended address
> +} PCI_ADDR;
> +
> +///
> +/// The standard header for all AGESA services.
> +///
> +typedef struct {
> + IN UINT32 ImageBasePtr; ///< The AGESA Image base address.
> + IN UINT32 Func; ///< The service desired
> + IN UINT32 AltImageBasePtr; ///< Alternate Image location
> + IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
> + IN UINT8 HeapStatus; ///< For heap status from boot time
> slide.
> + IN UINT64 HeapBasePtr; ///< Location of the heap
> + IN OUT UINT8 Reserved[7]; ///< This space is reserved for
> future use.
> +} AMD_CONFIG_PARAMS;
> +
> +/// CPUID data received registers format
> +typedef struct {
> + OUT UINT32 EAX_Reg; ///< CPUID instruction result in EAX
> + OUT UINT32 EBX_Reg; ///< CPUID instruction result in EBX
> + OUT UINT32 ECX_Reg; ///< CPUID instruction result in ECX
> + OUT UINT32 EDX_Reg; ///< CPUID instruction result in EDX
> +} CPUID_DATA;
> +#endif // AMD_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
> b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
> new file mode 100755
> index 0000000000..534b03d4a7
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
> @@ -0,0 +1,15 @@
> +/** @file
> + AMD CPU Register Table Related Functions.
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef CPU_REGISTERS_H_
> +#define CPU_REGISTERS_H_
> +
> +#include <CpuRegistersDef.h>
> +
> +#endif
> diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
> b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
> new file mode 100644
> index 0000000000..e086a4c9b1
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
> @@ -0,0 +1,61 @@
> +/** @file
> + AMD Psp Directory header file
> +
> + Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_PSP_DIR_H_
> +#define AMD_PSP_DIR_H_
> +
> +#pragma pack (push, 1)
> +#define PSP_DIRECTORY_HEADER_SIGNATURE 0x50535024ul ///< $PSP
> +#define PSP_LV2_DIRECTORY_HEADER_SIGNATURE 0x324C5024ul ///<
> $PL2
> +
> +/// Enum define various enum type for PSP entry type
> +enum _PSP_DIRECTORY_ENTRY_TYPE {
> + PSP_REGION_A_DIR = 0x48, ///< PSP entry points to PSP
> DIR in Region A
> + PSP_REGION_B_DIR = 0x4A, ///< PSP entry points to PSP
> DIR in Region B
> +};
> +
> +/// Define structure for PSP directory
> +typedef struct {
> + UINT32 Cookie; ///< "$PSP"
> + UINT32 Checksum; ///< 32 bit CRC of header items
> below and the entire table
> + UINT32 TotalEntries; ///< Number of PSP Entries
> + UINT32 Reserved; ///< Unused
> +} PSP_DIRECTORY_HEADER;
> +
> +/// Define structure for 32 bits Entry type field
> +typedef struct {
> + UINT32 Type : 8; ///< Type of PSP Directory entry
> + UINT32 SubProgram : 8; ///< Specify the SubProgram
> + UINT32 RomId : 2; ///< Specify the ROM ID
> + UINT32 Reserved : 14; ///< Reserved
> +} PSP_DIRECTORY_ENTRY_TYPE_FIELD;
> +
> +/// Define union type for 32 bits Entry type field
> +typedef union {
> + PSP_DIRECTORY_ENTRY_TYPE_FIELD Field; ///< Definition of each
> filed
> + UINT32 Value; ///< Group it as 32bits Int
> +} PSP_DIRECTORY_ENTRY_TYPE;
> +
> +/// Structure for PSP Entry
> +typedef struct {
> + PSP_DIRECTORY_ENTRY_TYPE Type; ///< Type of PSP entry;
> 32 bit long
> + UINT32 Size; ///< Size of PSP Entry in bytes
> + UINT64 Location; ///< Location of PSP Entry (byte
> offset from start of SPI-ROM)
> +} PSP_DIRECTORY_ENTRY;
> +
> +/// Structure for PSP directory
> +typedef struct {
> + PSP_DIRECTORY_HEADER Header; ///< PSP directory header
> + PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PSP entries
> each pointing to a binary in SPI flash
> + ///< The actual size of this array comes from
> the
> + ///< header
> (PSP_DIRECTORY.Header.TotalEntries)
> +} PSP_DIRECTORY;
> +
> +#pragma pack (pop)
> +#endif //AMD_PSP_DIR_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
> b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
> new file mode 100755
> index 0000000000..faa8d35b1b
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
> @@ -0,0 +1,156 @@
> +/** @file
> + AMD CPU Register Table Related Definitions.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef CPU_REGISTERS_DEF_H_
> +#define CPU_REGISTERS_DEF_H_
> +
> +#undef BIT0
> +#undef BIT1
> +#undef BIT2
> +#undef BIT3
> +#undef BIT4
> +#undef BIT5
> +#undef BIT6
> +#undef BIT7
> +#undef BIT8
> +#undef BIT9
> +#undef BIT10
> +#undef BIT10
> +#undef BIT11
> +#undef BIT12
> +#undef BIT13
> +#undef BIT14
> +#undef BIT15
> +#undef BIT16
> +#undef BIT17
> +#undef BIT18
> +#undef BIT19
> +#undef BIT20
> +#undef BIT21
> +#undef BIT22
> +#undef BIT23
> +#undef BIT24
> +#undef BIT25
> +#undef BIT26
> +#undef BIT27
> +#undef BIT28
> +#undef BIT29
> +#undef BIT30
> +#undef BIT31
> +#undef BIT32
> +#undef BIT33
> +#undef BIT34
> +#undef BIT35
> +#undef BIT36
> +#undef BIT37
> +#undef BIT38
> +#undef BIT39
> +#undef BIT40
> +#undef BIT41
> +#undef BIT42
> +#undef BIT43
> +#undef BIT44
> +#undef BIT45
> +#undef BIT46
> +#undef BIT47
> +#undef BIT48
> +#undef BIT49
> +#undef BIT40
> +#undef BIT41
> +#undef BIT42
> +#undef BIT43
> +#undef BIT44
> +#undef BIT45
> +#undef BIT46
> +#undef BIT47
> +#undef BIT48
> +#undef BIT49
> +#undef BIT50
> +#undef BIT51
> +#undef BIT52
> +#undef BIT53
> +#undef BIT54
> +#undef BIT55
> +#undef BIT56
> +#undef BIT57
> +#undef BIT58
> +#undef BIT59
> +#undef BIT60
> +#undef BIT61
> +#undef BIT62
> +#undef BIT63
> +
> +#define BIT0 0x0000000000000001ull
> +#define BIT1 0x0000000000000002ull
> +#define BIT2 0x0000000000000004ull
> +#define BIT3 0x0000000000000008ull
> +#define BIT4 0x0000000000000010ull
> +#define BIT5 0x0000000000000020ull
> +#define BIT6 0x0000000000000040ull
> +#define BIT7 0x0000000000000080ull
> +#define BIT8 0x0000000000000100ull
> +#define BIT9 0x0000000000000200ull
> +#define BIT10 0x0000000000000400ull
> +#define BIT11 0x0000000000000800ull
> +#define BIT12 0x0000000000001000ull
> +#define BIT13 0x0000000000002000ull
> +#define BIT14 0x0000000000004000ull
> +#define BIT15 0x0000000000008000ull
> +#define BIT16 0x0000000000010000ull
> +#define BIT17 0x0000000000020000ull
> +#define BIT18 0x0000000000040000ull
> +#define BIT19 0x0000000000080000ull
> +#define BIT20 0x0000000000100000ull
> +#define BIT21 0x0000000000200000ull
> +#define BIT22 0x0000000000400000ull
> +#define BIT23 0x0000000000800000ull
> +#define BIT24 0x0000000001000000ull
> +#define BIT25 0x0000000002000000ull
> +#define BIT26 0x0000000004000000ull
> +#define BIT27 0x0000000008000000ull
> +#define BIT28 0x0000000010000000ull
> +#define BIT29 0x0000000020000000ull
> +#define BIT30 0x0000000040000000ull
> +#define BIT31 0x0000000080000000ull
> +#define BIT32 0x0000000100000000ull
> +#define BIT33 0x0000000200000000ull
> +#define BIT34 0x0000000400000000ull
> +#define BIT35 0x0000000800000000ull
> +#define BIT36 0x0000001000000000ull
> +#define BIT37 0x0000002000000000ull
> +#define BIT38 0x0000004000000000ull
> +#define BIT39 0x0000008000000000ull
> +#define BIT40 0x0000010000000000ull
> +#define BIT41 0x0000020000000000ull
> +#define BIT42 0x0000040000000000ull
> +#define BIT43 0x0000080000000000ull
> +#define BIT44 0x0000100000000000ull
> +#define BIT45 0x0000200000000000ull
> +#define BIT46 0x0000400000000000ull
> +#define BIT47 0x0000800000000000ull
> +#define BIT48 0x0001000000000000ull
> +#define BIT49 0x0002000000000000ull
> +#define BIT50 0x0004000000000000ull
> +#define BIT51 0x0008000000000000ull
> +#define BIT52 0x0010000000000000ull
> +#define BIT53 0x0020000000000000ull
> +#define BIT54 0x0040000000000000ull
> +#define BIT55 0x0080000000000000ull
> +#define BIT56 0x0100000000000000ull
> +#define BIT57 0x0200000000000000ull
> +#define BIT58 0x0400000000000000ull
> +#define BIT59 0x0800000000000000ull
> +#define BIT60 0x1000000000000000ull
> +#define BIT61 0x2000000000000000ull
> +#define BIT62 0x4000000000000000ull
> +#define BIT63 0x8000000000000000ull
> +
> +#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO
> Configuration Base Address Register
> +
> +#endif // CPU_REGISTERS_DEF_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
> b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
> new file mode 100644
> index 0000000000..8ede1be838
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
> @@ -0,0 +1,85 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + 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_TXBYTECOUNT 0x48 //
> +#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 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/AgesaModulePkg/Include/Filecode.h
> b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
> new file mode 100644
> index 0000000000..726479d79f
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
> @@ -0,0 +1,31 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +/* $NoKeywords:$ */
> +
> +/**
> + * @file
> + *
> + * Collectively assign unique filecodes for assert and debug to each source
> file.
> + *
> + * Publish values for decorated filenames, which can be used for
> + * ASSERT and debug support using a preprocessor define like:
> + * @n <tt> _#define FILECODE MY_C_FILENAME_FILECODE </tt> @n
> + * This file serves as a reference for debugging to associate the code and
> filename.
> + *
> + * @xrefitem bom "File Content Label" "Release Content"
> + * @e project: AGESA
> + * @e sub-project: Include
> + * @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800
> (Mon, 09 Feb 2015) $
> + */
> +
> +#ifndef _FILECODE_H_
> +#define _FILECODE_H_
> +
> +#define UNASSIGNED_FILE_FILECODE (0xFFFF)
> +
> +#endif // _FILECODE_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h
> b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
> new file mode 100755
> index 0000000000..ddc9309d3d
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
> @@ -0,0 +1,14 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef GNB_H_
> +#define GNB_H_
> +
> +#define PVOID UINT64
> +
> +#endif // GNB_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
> b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
> new file mode 100644
> index 0000000000..192e0d6a8b
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
> @@ -0,0 +1,521 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef GNBDXIO_H_
> +#define GNBDXIO_H_
> +
> +#pragma pack (push, 1)
> +
> +#include <AGESA.h>
> +#include <Gnb.h>
> +
> +#define MAX_NUMBER_OF_COMPLEXES 16
> +
> +#define DESCRIPTOR_TERMINATE_GNB 0x40000000ull
> +#define DESCRIPTOR_TERMINATE_TOPOLOGY 0x20000000ull
> +#define DESCRIPTOR_ALLOCATED 0x10000000ull
> +#define DESCRIPTOR_PLATFORM 0x08000000ull
> +#define DESCRIPTOR_COMPLEX 0x04000000ull
> +#define DESCRIPTOR_SILICON 0x02000000ull
> +#define DESCRIPTOR_PCIE_WRAPPER 0x01000000ull
> +#define DESCRIPTOR_PCIE_ENGINE 0x00800000ull
> +#define DESCRIPTOR_CXL_ENGINE 0x00200000ull
> +
> +#define SILICON_CXL_CAPABLE 0x00008000ull
> +
> +#define DESCRIPTOR_ALL_WRAPPERS (DESCRIPTOR_PCIE_WRAPPER)
> +#define DESCRIPTOR_ALL_ENGINES (DESCRIPTOR_PCIE_ENGINE |
> DESCRIPTOR_CXL_ENGINE)
> +
> +#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))
> +
> +typedef UINT16 PCIE_ENGINE_INIT_STATUS;
> +
> +///
> +/// Engine Configuration
> +///
> +typedef struct {
> + IN UINT8 EngineType; ///< Engine type
> + ///< 0 - Ignore engine configuration
> + ///< 1 - PCIe port
> + IN UINT16 StartLane; ///< Start Lane ID (in reversed
> configuration StartLane > EndLane)
> + ///< Refer to lane descriptions and
> supported configurations in BKDG
> + IN UINT16 EndLane; ///< End lane ID (in reversed
> configuration StartLane > EndLane)
> + ///< Refer to lane descriptions and
> supported configurations in BKDG
> +} PCIE_ENGINE;
> +
> +///
> +/// PCIe port misc extended controls
> +///
> +typedef struct {
> + IN UINT8 SbLink : 1; ///< PCIe link type
> + ///< 0 - General purpose port
> + ///< 1 - Port connected to SB
> + IN UINT8 ClkPmSupport : 1; ///< Clock Power Management
> Support
> + ///< 0 - Clock Power Management not
> configured
> + ///< 1 - Clock Power Management
> configured according to PCIe device capability
> + IN UINT8 CsLink : 1; ///< PCIe link type
> + ///< 0 - General purpose port
> + ///< 1 - Port connected to chipset
> + IN UINT8 Reserved0 : 5; ///< Unused space
> +} PORT_MISC_CONTROL;
> +
> +///
> +/// PCIe port configuration data
> +///
> +typedef struct {
> + IN UINT8 PortPresent; ///< Enable PCIe port for
> initialization.
> + IN UINT8 FunctionNumber : 3; ///< Reserved for future use
> + IN UINT8 DeviceNumber : 5; ///< PCI Device number for
> port.
> + ///< 0 - Native port device number
> + ///< N - Port device number (See
> available configurations in BKDG
> + IN UINT8 LinkSpeedCapability : 4; ///< PCIe link speed/
> + ///< 0 - Maximum supported by silicon
> + ///< 1 - Gen1
> + ///< 2 - Gen2
> + ///< 3 - Gen3
> + IN UINT8 LinkAspm : 4; ///< ASPM control. (see
> AgesaPcieLinkAspm for additional option to control ASPM)
> + ///< 0 - Disabled
> + ///< 1 - L0s only
> + ///< 2 - L1 only
> + ///< 3 - L0s and L1
> + IN UINT8 LinkHotplug; ///< Hotplug control.
> + ///< 0 - Disabled
> + ///< 1 - Basic
> + ///< 2 - Server
> + ///< 3 - Enhanced
> + IN UINT16 SlotNum; ///< Physical Slot Number
> + IN PORT_MISC_CONTROL MiscControls; ///< Misc extended
> controls
> + IN UINT8 Reserved1; ///< Reserved for future use
> +} PORT_DATA;
> +
> +typedef struct {
> + UINT8 LinkSpeed;
> + UINT8 MaxPayloadSupport;
> + UINT8 AspmCapability;
> + UINT8 PciPmL1_1;
> + UINT8 PciPmL1_2;
> + UINT8 AspmL1_1;
> + UINT8 AspmL1_2;
> + UINT8 EsmSupport;
> + UINT8 LtrSupport;
> + UINT8 SurpriseDownErrorReport;
> + UINT8 TenBitTagSupport;
> + UINT8 AriForwarding;
> + UINT8 AcsSupport;
> + UINT8 AcsSourceValidation;
> + UINT8 AcsTranslationBlocking;
> + UINT8 AcsP2pRequestRedirect;
> + UINT8 AcsP2pCompletionRedirect;
> + UINT8 AcsUpstreamForwarding;
> + UINT8 AcsP2pEgressControl;
> + UINT8 AcsDirectTranslatedP2p;
> + UINT8 LaneMargining;
> + UINT8 DataLinkFeature;
> + UINT8 DownstreamPortContainment;
> + UINT8 AdvancedErrorReporting;
> + UINT8 ECRCSupport;
> + UINT8 MulticastEnable;
> + UINT8 NativePCIeEnclosureManagement;
> + UINT8 Capability1Address;
> + UINT8 Capability1Data;
> + UINT8 Capability2Address;
> + UINT8 Capability2Data;
> + UINT8 Capability3Address;
> + UINT8 Capability3Data;
> + UINT8 Capability4Address;
> + UINT8 Capability4Data;
> +} PORT_CAPABILITIES;
> +
> +///
> +/// PCIe PORT_FEATURES
> +///
> +typedef struct {
> + UINT8 LinkSpeedControl;
> + UINT8 MaxPayloadSizeControl;
> + UINT8 ESMControl;
> + UINT8 LTRControl;
> + UINT8 DataLinkFeatureExchangeControl;
> + UINT8 TenBitTagControl;
> + UINT8 ARIControl;
> + UINT8 ACSControl;
> + UINT8 RxLaneMarginingControl;
> + UINT8 DynLanesPwrState;
> + UINT8 L1PowerDown;
> + UINT8 L11PowerDown;
> + UINT8 L12PowerDown;
> + UINT8 AutoSpdChngEn;
> + UINT8 TurnOffUnusedLanes;
> +} PORT_FEATURES;
> +
> +typedef struct {
> + UINT8 SpcGen1 : 1; ///< SPC Mode 2P5GT
> + UINT8 SpcGen2 : 1; ///< SPC Mode 5GT
> + UINT8 SpcGen3 : 2; ///< SPC Mode 8GT
> + UINT8 SpcGen4 : 2; ///< SPC Mode 16GT
> + UINT8 SpcGen5 : 2; ///< SPC Mode 32GT
> +} SPC_MODE;
> +
> +typedef struct {
> + UINT32 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
> + UINT32 DsRxPresetHint : 3; ///< Gen3 Downstream Rx
> Preset Hint
> + UINT32 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
> + UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset
> Hint
> + UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset Mask
> + UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnable
> + UINT32 UNUSED2 : 7; ///< Currently unassigned - for
> alignment
> +} GEN3_LANE_CNTL;
> +
> +typedef struct {
> + UINT32 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
> + UINT32 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
> + UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset Mask
> + UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEnable
> + UINT32 UNUSED3 : 13; ///< Currently unassigned - for
> alignment
> +} GEN4_LANE_CNTL;
> +
> +typedef struct {
> + UINT32 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
> + UINT32 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
> + UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset Mask
> + UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnable
> + UINT32 PrecodeRequest : 1; ///< Precoding Request
> + UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ To High
> Rate Support
> + UINT32 UNUSED4 : 11; ///< Currently unassigned - for
> alignment
> +} GEN5_LANE_CNTL;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor0 : 5; ///< PostCursor0
> + UINT32 LcFapeReqPreCursor0 : 4; ///< PreCursor0
> + UINT32 LcFapeReqPostCursor1 : 5; ///< PostCursor1
> + UINT32 LcFapeReqPreCursor1 : 4; ///< PreCursor1
> + UINT32 LcFapeReqPostCursor2 : 5; ///< PostCursor2
> + UINT32 LcFapeReqPreCursor2 : 4; ///< PreCursor2
> + UINT32 UNUSED6 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_0;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor3 : 5; ///< PostCursor3
> + UINT32 LcFapeReqPreCursor3 : 4; ///< PreCursor3
> + UINT32 LcFapeReqPostCursor4 : 5; ///< PostCursor4
> + UINT32 LcFapeReqPreCursor4 : 4; ///< PreCursor4
> + UINT32 LcFapeReqPostCursor5 : 5; ///< PostCursor5
> + UINT32 LcFapeReqPreCursor5 : 4; ///< PreCursor5
> + UINT32 UNUSED7 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_1;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor6 : 5; ///< PostCursor6
> + UINT32 LcFapeReqPreCursor6 : 4; ///< PreCursor6
> + UINT32 LcFapeReqPostCursor7 : 5; ///< PostCursor7
> + UINT32 LcFapeReqPreCursor7 : 4; ///< PreCursor7
> + UINT32 LcFapeReqPostCursor8 : 5; ///< PostCursor8
> + UINT32 LcFapeReqPreCursor8 : 4; ///< PreCursor8
> + UINT32 UNUSED8 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_2;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor9 : 5; ///< PostCursor9
> + UINT32 LcFapeReqPreCursor9 : 4; ///< PreCursor9
> + UINT32 LcFapeReqPostCursor10 : 5; ///< PostCursor10
> + UINT32 LcFapeReqPreCursor10 : 4; ///< PreCursor10
> + UINT32 LcFapeReqPostCursor11 : 5; ///< PostCursor11
> + UINT32 LcFapeReqPreCursor11 : 4; ///< PreCursor11
> + UINT32 UNUSED9 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_3;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor12 : 5; ///< PostCursor12
> + UINT32 LcFapeReqPreCursor12 : 4; ///< PreCursor12
> + UINT32 LcFapeReqPostCursor13 : 5; ///< PostCursor13
> + UINT32 LcFapeReqPreCursor13 : 4; ///< PreCursor13
> + UINT32 LcFapeReqPostCursor14 : 5; ///< PostCursor14
> + UINT32 LcFapeReqPreCursor14 : 4; ///< PreCursor14
> + UINT32 UNUSED10 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_4;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor15 : 5; ///< PostCursor15
> + UINT32 LcFapeReqPreCursor15 : 4; ///< PreCursor15
> + UINT32 LcFapeReqPostCursor16 : 5; ///< PostCursor16
> + UINT32 LcFapeReqPreCursor16 : 4; ///< PreCursor16
> + UINT32 LcFapeReqPostCursor17 : 5; ///< PostCursor17
> + UINT32 LcFapeReqPreCursor17 : 4; ///< PreCursor17
> + UINT32 UNUSED11 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_5;
> +
> +typedef struct {
> + UINT32 LcFapeReqPostCursor18 : 5; ///< PostCursor18
> + UINT32 LcFapeReqPreCursor18 : 4; ///< PreCursor18
> + UINT32 LcFapeReqPostCursor19 : 5; ///< PostCursor19
> + UINT32 LcFapeReqPreCursor19 : 4; ///< PreCursor19
> + UINT32 LcFapeReqPostCursor20 : 5; ///< PostCursor20
> + UINT32 LcFapeReqPreCursor20 : 4; ///< PreCursor20
> + UINT32 UNUSED12 : 5; ///< Currently unassigned - for
> alignment
> +} LC_FAPE_GROUP_6;
> +
> +///
> +/// PCIe port configuration info
> +///
> +typedef struct {
> + PORT_DATA PortData; ///< Port data
> + UINT8 StartCoreLane; ///< Start Core Lane
> + UINT8 EndCoreLane; ///< End Core lane
> + UINT8 NativeDevNumber : 5; ///< Native PCI device number
> of the port
> + UINT8 NativeFunNumber : 3; ///< Native PCI function
> number of the port
> + UINT8 CoreId : 4; ///< PCIe core ID
> + UINT8 PortId : 4; ///< Port ID on wrapper
> + PCI_ADDR Address; ///< PCI address of the port
> + UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
> + UINT8 IsBmcLocation : 1; ///< Port Location of BMC
> + UINT8 LogicalBridgeId; ///< Logical Bridge ID
> + UINT8 SlotPowerLimit; ///< Slot Power Limit
> + UINT8 MaxPayloadSize; ///< Max_Payload_Size
> +
> + UINT8 TXDeEmphasis : 4; ///< TX De-emphasis
> + UINT8 TXMargin : 3; ///< TX Margin
> + UINT8 UNUSED1 : 1; ///< Currently unassigned - for
> alignment
> +
> + PORT_CAPABILITIES PortCapabilities; ///< Port Capabilities CBS
> +
> + SPC_MODE SpcMode;
> +
> + GEN3_LANE_CNTL LaneEqualizationCntl;
> + GEN4_LANE_CNTL Gen4LaneEqualizationCntl;
> + GEN5_LANE_CNTL Gen5LaneEqualizationCntl;
> +
> + UINT8 LowerSkpOsGenSup; ///< Controls
> LOWER_SKP_OS_GEN_SUPPORT
> + UINT8 LowerSkpOsRcvSup; ///< Controls
> LOWER_SKP_OS_RCV_SUPPORT
> + UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation
> interval
> + UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval
> Selection Mode
> + UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for
> SKP ordered set interval when generated based on elasticity buffer pointer
> slip feedback from PCS
> + UINT8 UNUSED4 : 1; ///< Currently unassigned - for
> alignment
> + UINT8 SRIS_SRNS : 1; ///< SRIS SRNS
> + UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SKP Support
> + UINT8 CcixControl : 1; ///< Bit to enable/disable ESM
> + UINT8 CxlControl : 1; ///< Bit to enable CXL Capability
> + UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE
> port
> + UINT8 SlotPowerLimitScale : 2; ///< Slot Power Limit Scale
> + UINT8 UNUSED5 : 1; ///< Currently unassigned - for
> alignment
> +
> + UINT8 RxMarginPersistence : 1; ///< Bit to enable/disable Rx
> Margin persistence mode
> + UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
> + UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
> + UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
> + UINT8 TxVetting : 1; ///< Gen4 Tx Vetting
> + UINT8 RxVetting : 1; ///< Gen4 Rx Vetting
> + UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetting
> + UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetting
> +
> + UINT8 IsMasterPLL : 1; ///< IsMasterPLL
> + UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
> + UINT8 DlfCapDisable : 1; ///< DLF Capability 1:Disable
> 0:Enable
> + UINT8 DlfExchangeDisable : 1; ///< DLF Exchange 1:Disable
> 0:Enable
> + UINT8 InvertPolarity : 1; ///< Invert RX Polarity
> + UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
> +
> + UINT8 EqSearchMode : 2; ///< Equalization Search Mode
> + UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ
> + UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 EQ Phase2/3
> + UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset value
> +
> + UINT8 EqSearchModeGen4 : 2; ///< Equalization Search
> Mode for Gen4
> + UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass phase3 EQ
> + UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
> + UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset value
> + UINT8 EqSearchModeGen5 : 2; ///< Equalization Search
> Mode for Gen5
> + UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass phase3 EQ
> + UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass phase2/3 EQ
> + UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset value
> +
> + UINT16 PsppPolicyDC; ///< Pspp Policy DC
> + UINT16 PsppPolicyAC; ///< Pspp Policy AC
> + UINT8 PsppDeviceType; ///< Pspp Device Type
> +
> + LC_FAPE_GROUP_0 LcFapeSettingsGroup0;
> + LC_FAPE_GROUP_1 LcFapeSettingsGroup1;
> + LC_FAPE_GROUP_2 LcFapeSettingsGroup2;
> + LC_FAPE_GROUP_3 LcFapeSettingsGroup3;
> + LC_FAPE_GROUP_4 LcFapeSettingsGroup4;
> + LC_FAPE_GROUP_5 LcFapeSettingsGroup5;
> + LC_FAPE_GROUP_6 LcFapeSettingsGroup6;
> +
> + UINT8 ForceSteering : 1; ///< Steering is forced
> + UINT8 EsmUsTxPreset : 4; ///< ESM Upstream Tx Preset
> + UINT8 UNUSED13 : 3; ///< Currently unassigned - for
> alignment
> +
> + // Used by DXE
> + PORT_FEATURES PortFeatures; ///< Port Features CBS
> + UINT8 EsmSpeedBump; ///< Speed bump for ESM
> + UINT8 I2CMuxInfo; ///< First I2c Mux on Bus
> + UINT8 SrisEnableMode : 4; ///< 0:Disable 1:SRIS 2:SRNS
> 3:SRNS in SRIS 0xF:Auto
> + UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect
> mode 0:Disable 1:Enable 0xF:Auto
> + UINT8 ClkReq : 4; ///< ClkReq:[0:3]
> + UINT8 EqPreset : 4; ///< EqPreset:[4:7]
> + UINT8 LinkAspmL1_1 : 1; ///< Enable PM L1 SS L1.1
> + UINT8 LinkAspmL1_2 : 1; ///< Enable PM L1 SS L1.2
> + UINT8 EsmControl : 1; ///< Bit to enable/disable ESM
> + UINT8 EsmDsTxPreset : 4; ///< ESM Downstream Tx Preset
> + UINT8 ClkReqFilterEn : 1; ///< Controls filtering of CLKREQb
> signal in LC in order to avoid false L1 substate entries/exits.
> +} PCIE_PORT_CONFIG;
> +
> +///
> +/// CXL port configuration info
> +///
> +typedef struct {
> + PORT_DATA PortData; ///< Port data
> + UINT8 StartCoreLane; ///< Start Core Lane
> + UINT8 EndCoreLane; ///< End Core lane
> + UINT8 NativeDevNumber : 5; ///< Native PCI device number
> of the port
> + UINT8 NativeFunNumber : 3; ///< Native PCI function
> number of the port
> + UINT8 CoreId : 4; ///< PCIe core ID
> + UINT8 PortId : 4; ///< Port ID on wrapper
> + PCI_ADDR Address; ///< PCI address of the port
> + UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
> + UINT8 UNUSED0 : 1; ///< Currently unassigned - for
> alignment
> + UINT8 LogicalBridgeId; ///< Logical Bridge ID
> + UINT8 SlotPowerLimit; ///< Slot Power Limit
> + UINT8 MaxPayloadSize; ///< Max_Payload_Size
> +
> + UINT8 CxlIndex;
> + UINT8 CxlDeviceType : 2; ///< Type of CXL device
> connected
> + UINT8 CxlVersion : 2; ///< Version of CXL device
> connected (1=CXL1.1, 2=CXL2.0)
> + UINT8 IsCxlScanned : 1; ///< Indicates if the CXL device has
> been scanned
> + UINT8 ReportToMpioinDxe : 1; ///< Indicates if the CXL info
> needs to be reported to MPIO in DXE
> + UINT8 UNUSED1 : 2; ///< Currently unassigned - for
> alignment
> +
> + UINT32 UsRcrb; ///< Upstream Port RCRB address
> + UINT32 DsRcrb; ///< Downstream Port RCRB address
> + UINT32 UsMemBar0; ///< Upstream port MEMBAR0
> + UINT32 DsMemBar0; ///< Downstream port MEMBAR0
> + UINT32 Mmio32Base;
> + UINT32 Mmio32Size;
> + UINT64 Mmio64Base;
> + UINT64 Mmio64Size;
> + UINT32 Mmio32Gran;
> +} PCIE_CXL_CONFIG;
> +
> +///
> +/// Descriptor header
> +///
> +typedef struct {
> + UINT32 DescriptorFlags; ///< Descriptor flags
> + UINT16 Parent; ///< Offset of parent descriptor
> + UINT16 Peer; ///< Offset of the peer descriptor
> + UINT16 Child; ///< Offset of the list of child
> descriptors
> +} PCIE_DESCRIPTOR_HEADER;
> +
> +///
> +/// Engine configuration data
> +///
> +typedef struct {
> + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor header
> + PCIE_ENGINE EngineData; ///< Engine Data
> + PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initialization Status
> + UINT8 Scratch; ///< Scratch pad
> + union {
> + PCIE_PORT_CONFIG Port; ///< PCIe port configuration
> data
> + PCIE_CXL_CONFIG Cxl; ///< CXL Configuration data
> + } Type;
> +} PCIE_ENGINE_CONFIG;
> +
> +///
> +/// Wrapper configuration data
> +///
> +typedef struct {
> + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
> + UINT8 WrapId; ///< Wrapper ID
> + UINT8 CcixCoreConfig; ///< Ccix CORE Configuration
> + UINT8 StartPhyLane; ///< Start PHY Lane
> + UINT8 EndPhyLane; ///< End PHY Lane
> + UINT8 StartDxioLane; ///< Start Dxio Lane (Translated)
> + UINT8 EndDxioLane; ///< End Dxio Lane (Translated)
> + struct {
> + UINT8 PowerOffUnusedLanes : 1; ///< Power Off unused lanes
> + UINT8 PowerOffUnusedPlls : 1; ///< Power Off unused Plls
> + UINT8 ClkGating : 1; ///< TXCLK gating
> + UINT8 LclkGating : 1; ///< LCLK gating
> + UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock gating PLL
> power down
> + UINT8 PllOffInL1 : 1; ///< PLL off in L1
> + UINT8 AccessEncoding : 1; ///< Reg access encoding
> + UINT8 CoreReversed : 1; ///< Indicates lanes are reversed
> in package connection
> + } Features;
> + UINT8 MasterPll; ///< Bitmap of master PLL
> + UINT32 AcsSupport : 1; ///< Acs Support
> + UINT32 LtrSupport : 1; ///< LTR Support
> + UINT32 AriForwarding : 1; ///< ARI Forwarding
> + UINT32 LaneMargining : 1; ///< Lane Margining
> + UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM
> + UINT32 DownstreamPortContainment : 1; ///< Downstream port
> containment
> + UINT32 AdvancedErrorReporting : 1; ///< Advacned Error
> Reporting
> + UINT32 ECRCSupport : 2; ///< ECRC Capability
> + UINT32 Reserved : 23; ///< Reserved bits
> +} PCIE_WRAPPER_CONFIG;
> +
> +///
> +/// Silicon configuration data
> +///
> +typedef struct {
> + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
> + UINT8 SocketId; ///< Socket ID
> + UINT8 DieNumber; ///< Module ID
> + UINT8 RBIndex; ///< Physical Root Bridge
> + UINT8 InstanceId; ///< Logical Instance Identifier
> + PCI_ADDR Address; ///< PCI address of GNB host bridge
> + UINT16 StartLane; ///< Start Lane of this node
> + UINT16 EndLane; ///< End Lane of this node
> + UINT8 BusNumberLimit; ///< Last Bus Number assigned to
> this node
> + UINT8 SbPresent : 1; ///< Set to 1 if FCH connected to
> this NBIO
> + UINT8 SmuPresent : 1; ///< Set to 1 if SMU connected to
> this NBIO
> + UINT8 MP_Instance : 6; ///< MP Instance
> + UINT8 LogicalRBIndex; ///< Logical Root Bridge
> + UINT8 NumEngineDesc; ///< Total number of lane
> bifurcation descriptors
> +} PCIE_SILICON_CONFIG;
> +
> +typedef PCIE_SILICON_CONFIG GNB_HANDLE;
> +
> +///
> +/// Complex configuration data
> +///
> +typedef struct {
> + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
> + UINT8 NodeId; ///< Processor Node ID
> + UINT8 Reserved; ///< For alignment
> +} PCIE_COMPLEX_CONFIG;
> +
> +///
> +/// PCIe platform configuration info
> +///
> +typedef struct {
> + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor
> Header
> + PVOID Reserved1; ///< Reserved
> + UINT32 Reserved2; ///< Reserved
> + UINT32 PhyConfigData; ///< Phy Configuration Data
> + UINT32 Reserved3; ///< Reserved
> + UINT32 Reserved4; ///< Reserved
> + UINT32 PsppTuningParams; ///< Tuning parameters
> for PSPP
> + UINT32 PsppTuningParams2; ///< Tuning parameters 2
> for PSPP
> + UINT8 Reserved5; ///< Reserved
> + UINT8 PsppPolicy; ///< PSPP policy
> + UINT8 Reserved6; ///< Reserved
> + UINT8 RootBridgesPerSocket; ///< Number of root
> bridges per socket
> + PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES];
> ///< Complex
> +} PCIE_PLATFORM_CONFIG;
> +
> +///
> +/// PCIe Engine Description
> +///
> +typedef struct {
> + UINT32 Flags; ///< Descriptor flags
> + ///< Bit31 - last descriptor on wrapper
> + ///< Bit30 - Descriptor allocated for PCIe
> port
> + PCIE_ENGINE EngineData; ///< Engine Data
> +} PCIE_ENGINE_DESCRIPTOR;
> +#pragma pack (pop)
> +
> +#endif // GNBDXIO_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
> b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
> new file mode 100644
> index 0000000000..90f52cca7b
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
> @@ -0,0 +1,18 @@
> +/** @file
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _GNBREGISTERSRS_H_
> +#define _GNBREGISTERSRS_H_
> +
> +#include "GnbRegistersRS/IOHC.h"
> +
> +#ifndef NBIO_SPACE
> +#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + (HANDLE->RBIndex
> << 20))
> +#endif
> +
> +#endif /*_GNBREGISTERSRS_H_*/
> diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
> b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
> new file mode 100644
> index 0000000000..b1a95237de
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
> @@ -0,0 +1,22 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _IOHC_H_
> +#define _IOHC_H_
> +
> +// Bitfield Description : DBG MMIO enable.
> +#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
> +
> +// Bitfield Description : Locks the DBG MMIO address range and enable until
> the next warm reset.
> +#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
> +
> +#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
> 0x13c102f0UL
> +
> +#endif /* _IOHC_H_ */
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
> b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
> new file mode 100644
> index 0000000000..f5cc5e2228
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
> @@ -0,0 +1,31 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef GNB_PCIE_HOB_INFO_H_
> +#define GNB_PCIE_HOB_INFO_H_
> +
> +#define _GNB_PCIE_HOB_INFO_GUID \
> +{ \
> + 0x3eb1d90, 0xce14, 0x40d8, 0xa6, 0xba, 0x10, 0x3a, 0x8d, 0x7b, 0xd3,
> 0x2d \
> +}
> +extern EFI_GUID gGnbPcieHobInfoGuid;
> +
> +#pragma pack (push, 1)
> +#define MAX_NUMBER_OF_CORES_PER_COMPLEX 3
> +#define MAX_NUMBER_OF_PORTS_PER_COMPLEX 22
> +
> +/// PCIe information HOB data
> +typedef struct _GNB_PCIE_INFORMATION_DATA_HOB {
> + EFI_HOB_GUID_TYPE EfiHobGuidType; ///< GUID Hob type
> structure
> + PCIE_PLATFORM_CONFIG PciePlatformConfigHob; ///< Platform Config
> Structure
> + UINT32 ComplexConfigs; ///< Allocation for Max Complex
> Structure suported
> +} GNB_PCIE_INFORMATION_DATA_HOB;
> +
> +#pragma pack (pop)
> +
> +#endif /* GNB_PCIE_HOB_INFO_H_ */
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
> new file mode 100644
> index 0000000000..dc773737b9
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
> @@ -0,0 +1,16 @@
> +/** @file
> + Contains interface to the AMD AGESA library.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_BASE_LIB_H_
> +#define AMD_BASE_LIB_H_
> +
> +#include "Uefi.h"
> +#include "AMD.h"
> +
> +#endif // AMD_BASE_LIB_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
> new file mode 100644
> index 0000000000..9d9892aa30
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
> @@ -0,0 +1,43 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +/* $NoKeywords:$ */
> +
> +/**
> + * @file
> + *
> + * PSP Mailbox related functions Prototype definition
> + *
> + *
> + * @xrefitem bom "File Content Label" "Release Content"
> + * @e project: AGESA
> + * @e sub-project: PSP
> + * @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue,
> 03 Feb 2015) $
> + */
> +
> +#ifndef _PSP_MBOX_H_
> +#define _PSP_MBOX_H_
> +
> +/**
> + * @brief Bios send these commands to PSP to grant dTPM status and event
> log
> + *
> + * @param[out] DesiredConfig dTPM configuration requested
> + * @param[out] ConfigStatus 0 - success. non-zero failure.
> + * @param[in,out] LogDataSize Size of LogData buffer
> + * @param[out] LogData Point to allocated event log buffer
> + *
> + * @retval EFI_STATUS 0: Success, NonZero Error
> + */
> +EFI_STATUS
> +PspMboxGetDTPMData (
> + OUT UINT32 *DesiredConfig,
> + OUT UINT32 *ConfigStatus,
> + IN OUT UINT32 *LogDataSize,
> + OUT VOID *LogData
> + );
> +
> +#endif //_PSP_MBOX_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
> new file mode 100644
> index 0000000000..51935f413a
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
> @@ -0,0 +1,22 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef BASE_FABRIC_TOPOLOGY_LIB_H_
> +#define BASE_FABRIC_TOPOLOGY_LIB_H_
> +
> +UINTN
> +FabricTopologyGetNumberOfProcessorsPresent (
> + VOID
> + );
> +
> +UINTN
> +FabricTopologyGetNumberOfRootBridgesOnSocket (
> + IN UINTN Socket
> + );
> +
> +#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
> new file mode 100644
> index 0000000000..cae3aff9b3
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
> @@ -0,0 +1,16 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _FCH_BASE_LIB_H_
> +#define _FCH_BASE_LIB_H_
> +
> +#include <Library/IoLib.h>
> +#include <Library/PciLib.h>
> +#include <Library/BaseLib.h>
> +
> +#endif
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
> new file mode 100644
> index 0000000000..345e39adce
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
> @@ -0,0 +1,413 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _FCH_ESPI_CMD_LIB_H_
> +#define _FCH_ESPI_CMD_LIB_H_
> +
> +#include <Uefi/UefiBaseType.h>
> +
> +#define MAX_ESPI_RETRY 100000ul
> +//
> +// Cycle Type
> +//
> +#define CYCLE_TYPE_FLASH_READ 0
> +#define CYCLE_TYPE_FLASH_WRITE 1
> +#define CYCLE_TYPE_FLASH_ERASE 2
> +#define CYCLE_TYPE_RPMC_OP1 3
> +#define CYCLE_TYPE_RPMC_OP2 4
> +
> +// RPMC OP1/OP2 Command Payload Max Length (512 Bits)
> +#define RPMC_CMD_PAYLOAD_MAX_LEN 0x40
> +
> +//
> +// Master Registers
> +//
> +#define SET_CONFIGURATION 0
> +#define GET_CONFIGURATION 1
> +#define IN_BAND_RESET 2
> +#define PC_MSG_DOWN_STREAM 4
> +#define VM_DOWN_STREAM 5
> +#define OOB_DOWN_STREAM 6
> +#define FA_DOWN_STREAM 7
> +
> +// ESPIx00
> +#define DNCMD_STATUS BIT3
> +
> +// ESPIx2C Master Capability
> +#define MASTER_FA_SUPPORT BIT0
> +#define MASTER_OOB_SUPPORT BIT1
> +#define MASTER_VW_SUPPORT BIT2
> +#define MASTER_PERIPHERAL_SUPPORT BIT3
> +
> +// ESPIx68 Slave0 Configuration
> +#define SLAVE_FA_ENABLE BIT0
> +#define SLAVE_OOB_ENABLE BIT1
> +#define SLAVE_VW_ENABLE BIT2
> +#define SLAVE_PC_ENABLE BIT3
> +
> +/// eSPIx00 eSPI Software Specific Register 0
> +#define ESPI_DN_TXHDR_0 0x00
> +typedef union {
> + struct {
> + UINT32 SWCommandType : 3;
> + UINT32 CommandStatus : 1;
> + UINT32 PutFlashNpTranActive : 1;
> + UINT32 Reserved : 3;
> + UINT32 DnCmdHdata0 : 8;
> + UINT32 DnCmdHdata1 : 8;
> + UINT32 DnCmdHdata2 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPIx00_DN_TXHDR0;
> +
> +/// eSPIx04 eSPI Software Specific Register 1
> +#define ESPI_DN_TXHDR_1 0x04
> +typedef union {
> + struct {
> + UINT32 DnCmdHdata3 : 8;
> + UINT32 DnCmdHdata4 : 8;
> + UINT32 DnCmdHdata5 : 8;
> + UINT32 DnCmdHdata6 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPIx04_DN_TXHDR1;
> +
> +#define ESPI_DN_TXHDR_2 0x08
> +typedef union {
> + struct {
> + UINT32 DnCmdHdata7 : 8;
> + UINT32 Reserved : 24;
> + } Field;
> + UINT32 Value;
> +} ESPIx08_DN_TXHDR2;
> +
> +#define ESPI_DN_TXDATA_PORT 0x0C
> +typedef union {
> + struct {
> + UINT32 DnTxData0 : 8;
> + UINT32 DnTxData1 : 8;
> + UINT32 DnTxData2 : 8;
> + UINT32 DnTxData3 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPIx0C_DN_TXDATA_PORT;
> +
> +#define ESPI_UP_RXHDR_0 0x10
> +typedef union {
> + struct {
> + UINT32 UpCommandType : 3;
> + UINT32 UpCommandStatus : 1;
> + UINT32 SlaveSel : 2;
> + UINT32 Reserved : 2;
> + UINT32 UpCmdHdata0 : 8;
> + UINT32 UpCmdHdata1 : 8;
> + UINT32 UpCmdHdata2 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPIx10_UP_RXHDR0;
> +
> +#define ESPI_UP_RXHDR_1 0x14
> +typedef union {
> + struct {
> + UINT32 UpCmdHdata3 : 8;
> + UINT32 UpCmdHdata4 : 8;
> + UINT32 UpCmdHdata5 : 8;
> + UINT32 UpCmdHdata6 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPIx14_UP_RXHDR1;
> +
> +#define ESPI_UP_RXDATA_PORT 0x18
> +
> +/// eSPIx2C eSPI Master Capability
> +#define ESPI_MASTER_CAP 0x2C
> +typedef union {
> + struct {
> + UINT32 FlashAccessChannelSupport : 1;
> + UINT32 OOBMessageChannelSupport : 1;
> + UINT32 VWChannelSupport : 1;
> + UINT32 PChannelSupport : 1;
> + UINT32 MasterVersion : 3;
> + UINT32 FlashAccessChannelMaxPayload : 3;
> + UINT32 OOBMessageChannelMaxPayload : 3;
> + UINT32 OperatingMaxVWCount : 6;
> + UINT32 PChannelMaxPayloadSize : 3;
> + UINT32 NumberOfSlave : 3;
> + UINT32 OperatingSupportFreq : 3;
> + UINT32 IOMode : 2;
> + UINT32 AlertMode : 1;
> + UINT32 CRCCheck : 1;
> + } Field;
> + UINT32 Value;
> +} ESPIx2C_MASTER_CAP;
> +
> +/// eSPIx30 eSPI Global Control 0
> +#define ESPI_GLOBAL_CTRL0 0x30
> +typedef union {
> + struct {
> + UINT32 WdgEn : 1;
> + UINT32 WaitChkEn : 1;
> + UINT32 PrClkgatEn : 1;
> + UINT32 AlStopEn : 1;
> + UINT32 AlIdleTimer : 3;
> + UINT32 RgDbgclkGatingEn : 1;
> + UINT32 WdgCnt : 16;
> + UINT32 WaitCnt : 6;
> + UINT32 PrRstEnPltrst : 1;
> + UINT32 SafsClkGateEn : 1;
> + } Field;
> + UINT32 Value;
> +} ESPIx30_GLOBAL_CTRL0;
> +
> +/// eSPIx68 eSPI Slave0 Configuration
> +#define ESPI_SLAVE0_CONFIG 0x68
> +typedef union {
> + struct {
> + UINT32 FlashAccessChannelEnable : 1;
> + UINT32 OOBMessageChannelEnable : 1;
> + UINT32 VWChannelEnable : 1;
> + UINT32 PChannelEnable : 1;
> + UINT32 FlashSharingMode : 1;
> + UINT32 FlashMaxPayloadSize : 3;
> + UINT32 PutFlashNpHeaderDataEn : 1;
> + UINT32 PutFlashNpHeaderEn : 1;
> + UINT32 SafsDeferValidEn : 1;
> + UINT32 FlashModifierEn : 1;
> + UINT32 Reserved_24_12 : 13;
> + UINT32 OperatingFreq : 3;
> + UINT32 IOModeSelect : 2;
> + UINT32 AlertMode : 1;
> + UINT32 CRCCheckingEnable : 1;
> + } Field;
> + UINT32 Value;
> +} ESPIx68_SLAVE0_CONFIG;
> +
> +/// eSPIx70 eSPI Slave0 Interrupt Status
> +#define ESPI_SLAVE0_INT_STS 0x70
> +typedef union {
> + struct {
> + UINT32 BusErrInt : 1;
> + UINT32 WaitTimeoutInt : 1;
> + UINT32 CrcErrInt : 1;
> + UINT32 Reserved_3 : 1;
> + UINT32 NoRspInt : 1;
> + UINT32 FatalErrInt : 1;
> + UINT32 NonFatalErrInt : 1;
> + UINT32 UnknownRspInt : 1;
> + UINT32 UnknownCtInt : 1;
> + UINT32 UnsucssCplInt : 1;
> + UINT32 IllegalTagInt : 1;
> + UINT32 IllegalLenInt : 1;
> + UINT32 RxOobOverflowInt : 1;
> + UINT32 RxMsgOverflowInt : 1;
> + UINT32 RxFlashOverflowInt : 1;
> + UINT32 ProtocolErrInt : 1;
> + UINT32 Reserved_16 : 1;
> + UINT32 UpFifoWdgTo : 1;
> + UINT32 MstAbortInt : 1;
> + UINT32 WdgTimeoutInt : 1;
> + UINT32 Reserved_23_20 : 4;
> + UINT32 RxVwGrp0Int : 1;
> + UINT32 RxVwGrp1Int : 1;
> + UINT32 RxVwGrp2Int : 1;
> + UINT32 RxVwGrp3Int : 1;
> + UINT32 DnCmdInt : 1;
> + UINT32 RxMsgInt : 1;
> + UINT32 RxOobInt : 1;
> + UINT32 FlashReqInt : 1;
> + } Field;
> + UINT32 Value;
> +} ESPIx70_SLAVE0_INT_STS;
> +
> +///
> +/// Slave Registers
> +///
> +#define SLAVE_REG_ID 0x04
> +#define SLAVE_GENERAL_CAPCFG 0x08
> +#define SLAVE_PC_CAPCFG 0x10
> +#define SLAVE_VW_CAPCFG 0x20
> +#define SLAVE_OOB_CAPCFG 0x30
> +#define SLAVE_FA_CAPCFG 0x40
> +#define SLAVE_FA_CAPCFG2 0x44
> +
> +/// Offset 04h: Device Identification
> +typedef union {
> + struct {
> + UINT32 RO_VersionID : 8;
> + UINT32 Reserved_31_8 : 24;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL04_DEVICE_ID;
> +
> +// SLAVE offset 0x08 SLAVE_GENERAL_CAPCFG
> +#define SLAVE_FA_SUPPORT BIT3
> +#define SLAVE_OOB_SUPPORT BIT2
> +#define SLAVE_VW_SUPPORT BIT1
> +#define SLAVE_PERIPHERAL_SUPPORT BIT0
> +/// Offset 08h: General Capabilities and Configurations
> +typedef union {
> + struct {
> + UINT32 RO_PCSupported : 1;
> + UINT32 RO_VWSupported : 1;
> + UINT32 RO_OOBMsgSupported : 1;
> + UINT32 RO_FASupported : 1;
> + UINT32 Reserved_7_3 : 4;
> + UINT32 Reserved_11_8 : 4;
> + UINT32 RO_MaxWaitStateAllowed : 4;
> + UINT32 RO_MaxFreqSupported : 3;
> + UINT32 RO_OpenDrainAlertSupported : 1;
> + UINT32 OperatingFreq : 3;
> + UINT32 OpenDrainAlertSelect : 1;
> + UINT32 RO_IOModeSupported : 2;
> + UINT32 IOModeSelect : 2;
> + UINT32 AlertMode : 1;
> + UINT32 Reserved_29 : 1;
> + UINT32 ResponseModifierEn : 1;
> + UINT32 CRCCheckingEn : 1;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL08_SLAVE_GENERAL_CAPCFG;
> +
> +/// Offset 10h: Channel 0 Capabilities and Configurations
> +typedef union {
> + struct {
> + UINT32 PCEn : 1;
> + UINT32 RO_PCReady : 1;
> + UINT32 BusMasterEn : 1;
> + UINT32 Reserved_3 : 1;
> + UINT32 RO_PCMaxPayloadSizeSupported : 3;
> + UINT32 Reserved_7 : 1;
> + UINT32 PCMaxPayloadSizeSelected : 3;
> + UINT32 Reserved_11 : 1;
> + UINT32 PCMaxReadRequestSize : 3;
> + UINT32 Reserved_31_15 : 17;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL10_SLAVE_PC_CAPCFG;
> +
> +/// Offset 20h: Channel 1 Capabilities and Configurations
> +typedef union {
> + struct {
> + UINT32 VWEn : 1;
> + UINT32 RO_VWReady : 1;
> + UINT32 Reserved_7_2 : 6;
> + UINT32 RO_MaxVWCntSupported : 6;
> + UINT32 Reserved_15_14 : 2;
> + UINT32 OpMaxVWCnt : 6;
> + UINT32 Reserved_31_22 : 10;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL20_SLAVE_VW_CAPCFG;
> +
> +/// Offset 30h: Channel 2 Capabilities and Configurations
> +typedef union {
> + struct {
> + UINT32 OOBEn : 1;
> + UINT32 RO_OOBReady : 1;
> + UINT32 Reserved_3_2 : 2;
> + UINT32 RO_MsgChMaxPayloadSizeSupported : 3;
> + UINT32 Reserved_7 : 1;
> + UINT32 MsgChMaxPayloadSizeSelected : 3;
> + UINT32 Reserved_31_11 : 21;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL30_SLAVE_OOB_CAPCFG;
> +
> +/// Offset 40h: Channel 3 Capabilities and Configurations
> +typedef union {
> + struct {
> + UINT32 FAEn : 1;
> + UINT32 RO_FAReady : 1;
> + UINT32 FlashBlockEraseSize : 3;
> + UINT32 RO_ChMaxPayloadSizeSupported : 3;
> + UINT32 ChMaxPayloadSizeSelected : 3;
> + UINT32 RO_FlashSharingMode : 1;
> + UINT32 ChMaxReadReqSize : 3;
> + UINT32 Reserved_15 : 1;
> + UINT32 RO_FlashSharingCapabilitySupported : 2;
> + UINT32 Reserved_19_18 : 2;
> + UINT32 RO_RPMCCounterOn1stDevice : 4;
> + UINT32 RO_RPMCOp1On1stDevice : 8;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL40_SLAVE_FA_CAPCFG;
> +
> +/// Offset 44h: Channel 3 Capabilities and Configurations2
> +typedef union {
> + struct {
> + UINT32 RO_TargetMaxReadReqSizeSupported : 3;
> + UINT32 Reserved_7_3 : 5;
> + UINT32 RO_TargetFlashEraseBlockSize : 8;
> + UINT32 RO_TargetRPMCSupported : 6;
> + UINT32 RO_NumOfRPMCdevices : 2;
> + UINT32 Reserved_31_24 : 8;
> + } Field;
> + UINT32 Value;
> +} ESPI_SL44_SLAVE_FA_CAPCFG2;
> +
> +//
> +// eSPI Command functions
> +//
> +VOID
> +FchEspiCmd_InBandRst (
> + IN UINT32 EspiBase
> + );
> +
> +UINT32
> +FchEspiCmd_GetConfiguration (
> + IN UINT32 EspiBase,
> + IN UINT32 RegAddr
> + );
> +
> +VOID
> +FchEspiCmd_SetConfiguration (
> + IN UINT32 EspiBase,
> + IN UINT32 RegAddr,
> + IN UINT32 Value
> + );
> +
> +EFI_STATUS
> +FchEspiCmd_SafsFlashRead (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length,
> + OUT UINT8 *Buffer
> + );
> +
> +EFI_STATUS
> +FchEspiCmd_SafsFlashWrite (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length,
> + IN UINT8 *Value
> + );
> +
> +EFI_STATUS
> +FchEspiCmd_SafsFlashErase (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length
> + );
> +
> +EFI_STATUS
> +FchEspiCmd_SafsRpmcOp1 (
> + IN UINT32 EspiBase,
> + IN UINT8 RpmcFlashDev,
> + IN UINT32 Length,
> + IN UINT8 *Data
> + );
> +
> +EFI_STATUS
> +FchEspiCmd_SafsRpmcOp2 (
> + IN UINT32 EspiBase,
> + IN UINT8 RpmcFlashDev,
> + IN UINT32 Length,
> + OUT UINT8 *Buffer
> + );
> +
> +#endif
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
> new file mode 100755
> index 0000000000..19688e2548
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
> @@ -0,0 +1,16 @@
> +/** @file
> + GNB PCIe Library definition.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef GNBPCIECONFIG_LIB_H_
> +#define GNBPCIECONFIG_LIB_H_
> +
> +#include <GnbDxio.h>
> +#include <Library/PcieConfigLib.h>
> +
> +#endif // GNBPCIECONFIG_LIB_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
> new file mode 100644
> index 0000000000..df88274530
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
> @@ -0,0 +1,37 @@
> +/** @file
> + Header file of AMD NBIO Common DXE library.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef NBIOCOMMONLIBDXE_H_
> +#define NBIOCOMMONLIBDXE_H_
> +
> +/**
> + Function to retrieve SOC_LOGICAL_ID
> +
> + @param[out] LogicalId Pointer to SOC_LOGICAL_ID
> + @retval EFI_UNSUPPORTED
> +
> +**/
> +EFI_STATUS
> +PcieGetLogicalId (
> + OUT SOC_LOGICAL_ID *LogicalId
> + );
> +
> +/**
> + Function to retrieve PCIE_PLATFORM_CONFIG
> +
> + @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
> + @retval EFI_UNSUPPORTED
> +
> +**/
> +EFI_STATUS
> +PcieGetPcieDxe (
> + OUT PCIE_PLATFORM_CONFIG **Pcie
> + );
> +
> +#endif // NBIOCOMMONLIBDXE_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
> new file mode 100755
> index 0000000000..4fec578a9f
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
> @@ -0,0 +1,62 @@
> +/** @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.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef NBIOHANDLELIB_LIB_H_
> +#define NBIOHANDLELIB_LIB_H_
> +
> +#include <GnbDxio.h>
> +
> +/**
> + Get GNB handle
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +
> +**/
> +GNB_HANDLE *
> +NbioGetHandle (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Get GNB handle of alternate host bridge (e.g. MI200)
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +GNB_HANDLE *
> +NbioGetAltHandle (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Get GNB handle of next socket
> +
> + @param[in] NbioHandle Pointer to current GnbHandle
> +**/
> +GNB_HANDLE *
> +NbioGetNextSocket (
> + IN GNB_HANDLE *NbioHandle
> + );
> +
> +/**
> + Get PCI_ADDR of GNB
> +
> + @param[in] Handle Pointer to GNB_HANDLE
> +**/
> +PCI_ADDR
> +NbioGetHostPciAddress (
> + IN GNB_HANDLE *Handle
> + );
> +
> +#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *)
> PcieConfigGetNextTopologyDescriptor (Descriptor,
> DESCRIPTOR_TERMINATE_TOPOLOGY)
> +#define GnbGetSocketId(Handle) (Handle != NULL ? (Handle)->SocketId :
> 0)
> +#define GnbGetDieNumber(Handle) (Handle != NULL ? (Handle)-
> >DieNumber : 0)
> +#define GnbGetRBIndex(Handle) (Handle != NULL ? (Handle)->RBIndex :
> 0)
> +
> +#endif // NBIOHANDLELIB_LIB_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
> new file mode 100644
> index 0000000000..9f53746814
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
> @@ -0,0 +1,283 @@
> +/** @file
> + Helper functions to access PCIe configuration data area.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PCIECONFIGLIB_LIB_H_
> +#define PCIECONFIGLIB_LIB_H_
> +
> +typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK) (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +typedef AGESA_STATUS (*PCIE_RUN_ON_WRAPPER_CALLBACK) (
> + IN PCIE_WRAPPER_CONFIG *Wrapper,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK2) (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN OUT VOID *Buffer,
> + IN PCIE_WRAPPER_CONFIG *Wrapper
> + );
> +
> +typedef VOID (*PCIE_RUN_ON_WRAPPER_CALLBACK2) (
> + IN PCIE_WRAPPER_CONFIG *Wrapper,
> + IN OUT VOID *Buffer,
> + IN GNB_HANDLE *GnbHandle
> + );
> +
> +typedef AGESA_STATUS (*PCIE_RUN_ON_DESCRIPTOR_CALLBACK) (
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Check Port Status
> +
> + @param[in] Engine Pointer to engine config descriptor
> + @param[in] PortStatus Check if status asserted for port
> + @retval TRUE if status asserted
> +**/
> +BOOLEAN
> +PcieConfigCheckPortStatus (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN UINT32 PortStatus
> + );
> +
> +/**
> + Set/Reset port status
> +
> + @param[in] Engine Pointer to engine config descriptor
> + @param[in] SetStatus SetStatus
> + @param[in] ResetStatus ResetStatus
> +
> +**/
> +UINT16
> +PcieConfigUpdatePortStatus (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN PCIE_ENGINE_INIT_STATUS SetStatus,
> + IN PCIE_ENGINE_INIT_STATUS ResetStatus
> + );
> +
> +/**
> + Execute callback on all engine in topology
> +
> + @param[in] DescriptorFlags Engine flags.
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllEngines (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Execute callback on all engine in wrapper
> +
> + @param[in] DescriptorFlags Engine flags.
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllEnginesInWrapper (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_WRAPPER_CONFIG *Wrapper
> + );
> +
> +/**
> + Execute callback on all wrappers in topology
> +
> + @param[in] DescriptorFlags Wrapper Flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +AGESA_STATUS
> +PcieConfigRunProcForAllWrappers (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Execute callback on all wrappers in NBIO
> +
> +
> + @param[in] DescriptorFlags Wrapper Flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllWrappersInNbio (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
> + IN OUT VOID *Buffer,
> + IN GNB_HANDLE *GnbHandle
> + );
> +
> +/**
> + Execute callback on all descriptor of specific type
> +
> + @param[in] InDescriptorFlags Include descriptor flags
> + @param[in] OutDescriptorFlags Exclude descriptor flags
> + @param[in] TerminationFlags Termination flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +AGESA_STATUS
> +PcieConfigRunProcForAllDescriptors (
> + IN UINT32 InDescriptorFlags,
> + IN UINT32 OutDescriptorFlags,
> + IN UINT32 TerminationFlags,
> + IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Get parent descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetParent (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + );
> +
> +/**
> + Get child descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetChild (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + );
> +
> +/**
> + Get peer descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetPeer (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + );
> +
> +/**
> + Check is engine is active or potentially active
> +
> + @param[in] Engine Pointer to engine descriptor
> + @retval TRUE - engine active
> + @retval FALSE - engine not active
> +**/
> +BOOLEAN
> +PcieConfigIsActivePcieEngine (
> + IN PCIE_ENGINE_CONFIG *Engine
> + );
> +
> +/**
> + Locate SB engine on wrapper
> +
> + @param[in] Wrapper Pointer to wrapper config descriptor
> + @retval SB engine pointer or NULL
> +**/
> +PCIE_ENGINE_CONFIG *
> +PcieConfigLocateSbEngine (
> + IN PCIE_WRAPPER_CONFIG *Wrapper
> + );
> +
> +/**
> + Helper function to dump configuration to debug out
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigDebugDump (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + );
> +
> +/**
> + Helper function to dump wrapper configuration
> +
> + @param[in] WrapperList Wrapper Configuration
> +**/
> +VOID
> +PcieConfigWrapperDebugDump (
> + IN PCIE_WRAPPER_CONFIG *WrapperList
> + );
> +
> +/**
> + Helper function to dump engine configuration
> +
> + @param[in] EngineList Engine Configuration
> +**/
> +VOID
> +PcieConfigEngineDebugDump (
> + IN PCIE_ENGINE_CONFIG *EngineList
> + );
> +
> +/**
> + Helper function to dump input configuration to debug out
> +
> + @param[in] ComplexDescriptor Pointer to user defined complex
> descriptor
> +**/
> +VOID
> +PcieUserConfigConfigDump (
> + IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
> + );
> +
> +/**
> + Helper function to dump input configuration to user engine descriptor
> +
> + @param[in] EngineDescriptor Pointer to engine descriptor
> +**/
> +VOID
> +PcieUserDescriptorConfigDump (
> + IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
> + );
> +
> +#define PcieConfigGetParentWrapper(Descriptor)
> ((PCIE_WRAPPER_CONFIG *) PcieConfigGetParent
> (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
> +#define PcieConfigGetParentSilicon(Descriptor)
> ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON,
> &((Descriptor)->Header)))
> +#define PcieConfigGetParentComplex(Descriptor)
> ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX,
> &((Descriptor)->Header)))
> +#define PcieConfigGetPlatform(Descriptor)
> ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM,
> &((Descriptor)->Header)))
> +#define PcieConfigGetChildWrapper(Descriptor)
> ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild
> (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
> +#define PcieConfigGetChildEngine(Descriptor)
> ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES,
> &((Descriptor)->Header)))
> +#define PcieConfigGetChildSilicon(Descriptor)
> ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON,
> &((Descriptor)->Header)))
> +#define PcieConfigGetNextDescriptor(Descriptor)
> ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) !=
> 0) ? NULL : ((Descriptor + 1))))
> +#define PcieConfigIsPcieEngine(Descriptor) ((Descriptor !=
> NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_PCIE_ENGINE) !=
> 0) : FALSE)
> +#define PcieConfigIsSbPcieEngine(Engine) ((Engine !=
> NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.SbLink)) :
> FALSE)
> +#define PcieConfigIsEngineAllocated(Descriptor)
> ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags &
> DESCRIPTOR_ALLOCATED) != 0) : FALSE)
> +#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) if
> (Descriptor != NULL) (Descriptor)->Header.DescriptorFlags |=
> SetDescriptorFlags
> +#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) if
> (Descriptor != NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)-
> >DescriptorFlags &= (~(ResetDescriptorFlags))
> +#define PcieInputParsetGetNextDescriptor(Descriptor)
> ((Descriptor == NULL) ? NULL : ((Descriptor->Flags &
> DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
> +#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination)
> ((Descriptor == NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor)-
> >DescriptorFlags & Termination) != 0) ? NULL : ((UINT8 *) Descriptor +
> ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Peer))
> +#define GnbGetNextHandle(Descriptor) (GNB_HANDLE
> *) PcieConfigGetNextTopologyDescriptor (Descriptor,
> DESCRIPTOR_TERMINATE_TOPOLOGY)
> +#define PcieConfigGetNextDataDescriptor(Descriptor)
> ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0 ? NULL : (Descriptor
> + 1))
> +
> +#endif // PCIECONFIGLIB_LIB_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
> b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
> new file mode 100644
> index 0000000000..f0c6d1ccbb
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
> @@ -0,0 +1,30 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _SMNACCESSLIB_H_
> +#define _SMNACCESSLIB_H_
> +
> +VOID
> +SmnRegisterReadS (
> + IN UINT32 SegmentNumber,
> + IN UINT32 BusNumber,
> + IN UINT32 Address,
> + OUT VOID *Value
> + );
> +
> +VOID
> +SmnRegisterRMWS (
> + IN UINT32 SegmentNumber,
> + IN UINT32 BusNumber,
> + IN UINT32 Address,
> + IN UINT32 AndMask,
> + IN UINT32 OrValue,
> + IN UINT32 Flags
> + );
> +
> +#endif
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesPr
> otocol.h
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesPr
> otocol.h
> new file mode 100644
> index 0000000000..0e08e64b24
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesPr
> otocol.h
> @@ -0,0 +1,47 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef NBIO_PCIE_SERVICES_PROTOCOL_H_
> +#define NBIO_PCIE_SERVICES_PROTOCOL_H_
> +
> +// Current PROTOCOL revision
> +#define AMD_NBIO_PCIE_SERVICES_REVISION 0x00
> +
> +///
> +/// Forward declaration for the NBIO_PCIE_SERVICES_PROTOCOL
> +///
> +typedef struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL
> DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL;
> +
> +//
> +// Protocol Definitions
> +//
> +
> +/**
> + Returns the NBIO debug options configuration structure
> + This
> + A pointer to the DXE_AMD_NBIO_SMU_SERVICES_PROTOCOL instance.
> + DebugOptions
> + A pointer to a pointer to store the address of the PCIe topology structure
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT)(
> + IN DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL *This,
> + OUT UINT32 **DebugOptions
> + );
> +
> +///
> +/// The Dxe of PCIE Services
> +///
> +struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL {
> + AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT PcieGetTopology; ///<
> +};
> +
> +extern EFI_GUID gAmdNbioPcieServicesProtocolGuid;
> +
> +#endif /* NBIO_PCIE_SERVICES_PROTOCOL_H */
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtoc
> ol.h
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtoc
> ol.h
> new file mode 100644
> index 0000000000..10d3b730a6
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtoc
> ol.h
> @@ -0,0 +1,14 @@
> +/** @file
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
> +#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
> +
> +extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
> +
> +#endif
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
> new file mode 100644
> index 0000000000..a15995188b
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
> @@ -0,0 +1,155 @@
> +/** @file
> +
> + Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef FABRIC_NUMA_SERVICES2_H_
> +#define FABRIC_NUMA_SERVICES2_H_
> +#include "AMD.h"
> +
> +#pragma pack (push, 1)
> +
> +#define MAX_PXM_VALUES_PER_QUADRANT 16
> +
> +/// Domain type
> +typedef enum {
> + NumaDram,
> + NumaSLink,
> + NumaCxl,
> + MaxNumaDomainType2
> +} DOMAIN_TYPE2;
> +
> +/// Reported Domain Info
> +typedef struct {
> + DOMAIN_TYPE2 Type; ///< Type
> + UINT32 SocketMap; ///< Bitmap indicating physical socket location
> + UINT32 PhysicalDomain; ///< Physical domain number
> +} DOMAIN_INFO2;
> +
> +/// Physical Dram Info
> +typedef struct {
> + UINT32 NormalizedCsMap; ///< Bitmap of CSs comprising this
> physical domain
> + UINT32 SharingEntityCount; ///< Number of virtual domains
> sharing this physical domain
> + UINT32 SharingEntityMap; ///< Bitmap of reported domains that
> share this physical domain
> + UINT32 Reserved; ///< Reserved
> +} PHYS_DOMAIN_INFO;
> +
> +/// Proximity Domain Info
> +typedef struct {
> + UINTN Count; ///< Entries in Domain array
> + UINTN Domain[MAX_PXM_VALUES_PER_QUADRANT]; ///< Domains in
> Quadrant
> +} PXM_DOMAIN_INFO;
> +
> +///
> +/// Forward declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL
> +///
> +typedef struct _FABRIC_NUMA_SERVICES2_PROTOCOL
> FABRIC_NUMA_SERVICES2_PROTOCOL;
> +
> +/**
> + * @brief Get the numa domain information.
> + *
> + * @details Get the numa domain information.
> + *
> + * @param[in] This A pointer to the
> FABRIC_NUMA_SERVICES2_PROTOCOL instance.
> + * @param[out] NumberOfDomainsInSystem Number of unique NUMA
> domains
> + * @param[out] DomainInfo An array with information about each
> domain
> + * @param[out] CcxAsNumaDomain TRUE: each core complex is its
> own domain
> + * FALSE: physical mapping is employed
> + * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO)(
> + IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
> + OUT UINT32 *NumberOfDomainsInSystem,
> + OUT DOMAIN_INFO2 **DomainInfo,
> + OUT BOOLEAN *CcxAsNumaDomain
> + );
> +
> +/**
> + * @brief Translates a core's physical location to the appropriate NUMA
> domain.
> + *
> + * @details Translates a core's physical location to the appropriate NUMA
> domain.
> + *
> + * @param[in] This A pointer to the
> FABRIC_NUMA_SERVICES2_PROTOCOL instance.
> + * @param[in] Socket Zero based socket that the core is attached to
> + * @param[in] Die DF die on socket that the core is attached to
> + * @param[in] Ccd Logical CCD the core is on
> + * @param[in] Ccx Logical core complex
> + * @param[out] Domain Domain the core belongs to
> + * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *FABRIC_NUMA_SERVICES2_DOMAIN_XLAT)(
> + IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
> + IN UINTN Socket,
> + IN UINTN Die,
> + IN UINTN Ccd,
> + IN UINTN Ccx,
> + OUT UINT32 *Domain
> + );
> +
> +/**
> + * @brief Get physical numa domain information.
> + *
> + * @details Get physical numa domain information.
> + *
> + * @param[in] This A pointer to the
> FABRIC_NUMA_SERVICES2_PROTOCOL instance.
> + * @param[out] NumberOfPhysDomainsInSystem Number of valid domains
> in the system
> + * @param[out] PhysDomainInfo An array with information about
> each physical domain
> + * @param[out] PhysNodesPerSocket Actual NPS as determined by
> ABL (not including SLink)
> + * @param[out] NumberOfSystemSLinkDomains Number of domains
> describing SLink connected memory
> + * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO)(
> + IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
> + OUT UINT32 *NumberOfPhysDomainsInSystem,
> + OUT PHYS_DOMAIN_INFO **PhysDomainInfo,
> + OUT UINT32 *PhysNodesPerSocket,
> + OUT UINT32 *NumberOfSystemSLinkDomains
> + );
> +
> +/**
> + * @brief Get the proximity domain information about a PCIe root-port
> bridge
> + *
> + * @details Get the proximity domain information about a PCIe root-port
> bridge
> + *
> + * @param[in] This A pointer to the
> FABRIC_NUMA_SERVICES2_PROTOCOL instance.
> + * @param[in] RootPortBDF BDF for root-port bridge in PCI_ADDR
> format.
> + * @param[out] PxmDomainInfo Pointer to a structure returning
> associated NUMA node(s).
> + * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO)(
> + IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
> + IN PCI_ADDR RootPortBDF,
> + OUT PXM_DOMAIN_INFO *PxmDomainInfo
> + );
> +
> +///
> +/// When installed, the Fabric NUMA Services 2 Protocol produces a
> collection of
> +/// services that return various information associated with non-uniform
> memory
> +/// architecture.
> +///
> +struct _FABRIC_NUMA_SERVICES2_PROTOCOL {
> + UINTN Revision; ///< Revision Number
> + FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO GetDomainInfo;
> ///< Get Domain Info
> + FABRIC_NUMA_SERVICES2_DOMAIN_XLAT DomainXlat; ///<
> Domain Translation
> + FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO
> GetPhysDomainInfo; ///< Get Physical Domain Info
> + FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO
> GetPxmDomainInfo; ///< Get Proximity Domain Info
> +};
> +
> +///
> +/// Guid declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL.
> +///
> +extern EFI_GUID gAmdFabricNumaServices2ProtocolGuid;
> +
> +#pragma pack (pop)
> +#endif // _FABRIC_NUMA_SERVICES2_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices
> 2.h
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices
> 2.h
> new file mode 100644
> index 0000000000..485240c0fb
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices
> 2.h
> @@ -0,0 +1,14 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef FABRIC_TOPOLOGY_SERVICES2_H_
> +#define FABRIC_TOPOLOGY_SERVICES2_H_
> +
> +#include <Library/BaseFabricTopologyLib.h>
> +
> +#endif // FABRIC_TOPOLOGY_SERVICES2_H_
> diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
> b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
> new file mode 100755
> index 0000000000..44093e4097
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
> @@ -0,0 +1,23 @@
> +/** @file
> + SoC Logical ID Definitions.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef SOC_LOGICAL_ID_H_
> +#define SOC_LOGICAL_ID_H_
> +#pragma pack (push, 1)
> +
> +///
> +/// SOC logical ID structure
> +///
> +typedef struct _SOC_LOGICAL_ID {
> + IN OUT UINT32 Family; ///< Indicates logical ID Family
> + IN OUT UINT16 Revision; ///< Indicates logical ID Revision
> +} SOC_LOGICAL_ID;
> +
> +#pragma pack (pop)
> +#endif // SOC_LOGICAL_ID_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLi
> b.h
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLi
> b.h
> new file mode 100644
> index 0000000000..a60ae20d33
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLi
> b.h
> @@ -0,0 +1,100 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _INTERNAL_AML_LIB_H_
> +#define _INTERNAL_AML_LIB_H_
> +
> +#include <Uefi.h>
> +#include <Library/AmlGenerationLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <IndustryStandard/Acpi.h>
> +
> +#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 := <leadnamechar namechar namechar namechar>
> +
> + 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
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.h
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.h
> new file mode 100644
> index 0000000000..b19b6fe867
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.h
> @@ -0,0 +1,150 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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/AgesaPkg/Include/AmdPcieComplex.h
> b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
> new file mode 100755
> index 0000000000..3a628ed0b2
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
> @@ -0,0 +1,432 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_PCIE_COMPLEX_H_
> +#define AMD_PCIE_COMPLEX_H_
> +
> +//
> +// GNB PCIe configuration info
> +//
> +#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
> +#define DESCRIPTOR_IGNORE 0x40000000ull
> +
> +//
> +// Port parameter count
> +//
> +#define PCIE_PORT_PARAMETER_COUNT 64
> +
> +///
> +/// PCIe link initialization
> +/// DXIO endpoint status
> +///
> +typedef enum {
> + DxioEndpointDetect = 0, ///< Detect endpoint presence
> + DxioEndpointNotPresent ///< Endpoint not present (or
> connected). Used in case there is alternative way to determine
> + ///< if device present on board or in slot.
> For example GPIO can be used to determine device presence.
> +} DXIO_ENDPOINT_STATUS;
> +
> +#pragma pack(push,1)
> +typedef struct {
> + UINT16 ParamType; ///< This identifies a specific port
> parameter to set.
> + UINT16 ParamValue; ///< Specifies the value to be assigned
> to port parameter.
> +} PORT_PARAM;
> +
> +typedef struct {
> + PORT_PARAM PhyParam[PCIE_PORT_PARAMETER_COUNT]; ///<
> PHY port parameter
> +} PORT_PARAMS;
> +
> +///
> +/// Ancillary data struct with table size and address
> +///
> +typedef struct {
> + IN UINT32 Count; ///< Total count in this Ancillary data
> table
> + IN UINT32 Ovrd; ///< Ancillary data table address point
> to ANC_DATA_PARAM[]
> +} ANC_DATA;
> +
> +typedef struct {
> + UINT16 ParamType; ///< This identifies a specific PHY parameter
> + UINT16 ParamValue; ///< This specifies the value to be assigned
> to indicated PHY parameter
> +} DXIO_PHY_PARAM;
> +
> +typedef struct {
> + DXIO_PHY_PARAM PhyParam[44]; ///< physical parameter
> +} PHY_DATA;
> +
> +///
> +/// PCIe specific data structures
> +/// PCIe port misc extended controls
> +///
> +typedef struct {
> + UINT8 LinkComplianceMode : 1; ///< Force port into
> compliance mode (device will not be trained, port output compliance pattern)
> + UINT8 LinkSafeMode : 1; ///< Safe mode PCIe capability.
> (Parameter may limit PCIe speed requested through
> DXIO_PORT_DATA::LinkSpeedCapability)
> + ///< 0 - port can advertize muximum
> supported capability
> + ///< 1 - port limit advertized capability and
> speed to PCIe Gen1
> + UINT8 SbLink : 1; ///< PCIe link type
> + ///< 0 - General purpose port
> + ///< 1 - Port connected to SB
> + UINT8 ClkPmSupport : 1; ///< Clock Power Management
> Support
> + ///< 0 - Clock Power Management not
> configured
> + ///< 1 - Clock Power Management
> configured according to PCIe device capability
> + UINT8 ChannelType : 3; ///< Channel Type
> + ///< 0 - Channel Type Not Specified
> + ///< - Channel Type Short Trace
> + ///< 2 - Channel Type Long Trace
> + UINT8 TurnOffUnusedLanes : 1; ///< Turn Off Unused Lanes
> + ///< 0 - Turn on
> + ///< 1 - Turn off
> +} DXIO_PORT_MISC_CONTROL;
> +
> +///
> +/// The IO APIC Interrupt Mapping Info
> +///
> +typedef struct {
> + UINT8 GroupMap; ///< Group mapping for slot or
> endpoint device (connected to PCIE port) interrupts .
> + ///< 0 - IGNORE THIS STRUCTURE AND USE
> RECOMMENDED SETTINGS
> + ///< 1 - mapped to Grp 0 (Interrupts 0..3 of IO
> APIC redirection table)
> + ///< 2 - mapped to Grp 1 (Interrupts 4..7 of IO
> APIC redirection table)
> + ///< ...
> + ///< 8 - mapped to Grp 7 (Interrupts 28..31 of
> IO APIC redirection table)
> + UINT8 Swizzle; ///< Swizzle interrupt in the Group.
> + ///< 0 - ABCD
> + ///< 1 - BCDA
> + ///< 2 - CDAB
> + ///< 3 - DABC
> + UINT8 BridgeInt; ///< IOAPIC redirection table entry for
> PCIE bridge interrupt
> + ///< 0 - Entry 0 of IO APIC redirection table
> + ///< 1 - Entry 1 of IO APIC redirection table
> + ///< ...
> + ///< 31 - Entry 31 of IO APIC redirection table
> +} DXIO_APIC_DEVICE_INFO;
> +///
> +/// PCIe port configuration data
> +///
> +typedef struct {
> + UINT8 PortPresent : 1; ///< Enable PCIe port for
> initialization.
> + UINT8 Reserved1 : 2; ///< Reserved
> + UINT8 DeviceNumber : 5; ///< PCI Device number for port.
> + ///< 0 - Native port device number
> + ///< N - Port device number (See available
> configurations in BKDG
> + UINT8 FunctionNumber : 3; ///< Reserved for future use
> + UINT8 LinkSpeedCapability : 3; ///< PCIe link speed/
> + ///< 0 - Maximum supported by silicon
> + ///< 1 - Gen1
> + ///< 2 - Gen2
> + ///< 3 - Gen3
> + ///< 4 - Gen4
> + ///< 5 - Gen5
> + UINT8 AutoSpdChng : 2; ///< Upstread Auto Speed Change
> Allowed/
> + ///< 0 - Use default implementation (Disabled
> for Gen1, Enabled for Gen2/3)
> + ///< 1 - Always Disabled
> + ///< 2 - Always Enabled
> + ///< 3 - Reserved
> + UINT8 EqPreset : 4; ///< Gen3 Equalization Preset */
> + UINT8 LinkAspm : 2; ///< ASPM control. (see
> AgesaPcieLinkAspm for additional option to control ASPM)
> + ///< 0 - Disabled
> + ///< 1 - L0s only
> + ///< 2 - L1 only
> + ///< 3 - L0s and L1
> + UINT8 LinkAspmL1_1 : 1; ///< ASPM control. (see
> AgesaPcieLinkAspm for additional option to control ASPM)
> + ///< 0 - Disabled
> + ///< 1 - Enabled
> + UINT8 LinkAspmL1_2 : 1; ///< ASPM control. (see
> AgesaPcieLinkAspm for additional option to control ASPM)
> + ///< 0 - Disabled
> + ///< 1 - Enabled
> + UINT8 ClkReq : 4; ///< ASPM Reserved Field
> + ///< 0 - NONE
> + ///< 1 - CLKREQ0 signal
> + ///< 2 - CLKREQ1 signal
> + ///< 3 - CLKREQ2 signal
> + ///< 4 - CLKREQ3 signal
> + ///< 5 - CLKREQG signal
> + UINT8 LinkHotplug : 4; ///< Hotplug control.
> + ///< 0 - Disabled
> + ///< 1 - Basic
> + ///< 2 - Server
> + ///< 3 - Enhanced
> + UINT8 SlotPowerLimit; ///< PCIe slot power limit.
> + UINT8 SlotPowerLimitScale : 2; ///< PCIe slot power limit Scale.
> + ///< 00b = 1.0x
> + ///< 01b = 0.1x
> + ///< 10b = 0.01x
> + ///< 11b = 0.001x
> + UINT8 IsMasterPLL : 1; ///< IsMasterPLL
> + UINT8 Gen4Features : 5; ///< Unused bits
> + ///< BIT0(DLF_Exchange) 1 - Disable, 0 -
> Enable
> + ///< IT1(DLF_Capability) 1 - Disable, 0 - Enable
> + UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_NUM
> + UINT16 CsLink : 3; ///< Reserved
> + DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended
> controls
> + DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device
> programming info
> + DXIO_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint
> (device connected to PCIe port) status
> + UINT8 EsmSpeedBump; ///< Speed bump for ESM
> + UINT8 EsmControl : 1; ///< Enhanced speed mode control
> + UINT8 CcixControl : 1; ///< Ccix/Cxl control
> + UINT8 TxVetting : 1; ///< Tx Vetting
> + UINT8 RxVetting : 1; ///< Rx Vetting
> + UINT8 InvertPolarity : 1; ///< Invert RX Polarity
> + UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
> + UINT8 NtbHotplug : 1; ///< NTB Hotplug flag
> + ///< 0b = Disabled
> + ///< 1b = Enabled
> + UINT8 Reserved2 : 1; ///< Reserved
> + UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
> + UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
> + UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
> + UINT8 Reserved3 : 5; ///< Reserved
> + UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset
> + UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset
> + UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset
> + UINT8 Reserved4 : 4; ///< Reserved
> + UINT16 PsppPolicyDC; ///< Pspp DC control
> + UINT16 PsppPolicyAC; ///< PSPP AC control
> + UINT8 PsppDeviceType; ///< Pspp Device Type
> + UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass phase2/3 EQ
> + UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
> + UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 DXIO
> deemphasis default
> + UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemphasis
> setting
> + UINT8 Reserved5 : 3; ///< Reserved
> + struct {
> + UINT16 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
> + UINT16 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset
> Hint
> + UINT16 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
> + UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset
> Hint
> + UINT16 Reserved1 : 2; ///< Unused bits
> + UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downstream Tx
> Preset
> + UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downstream Rx
> Preset Hint
> + UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstream Tx Preset
> + UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstream Rx
> Preset Hint
> + UINT8 Reserved2 : 4; ///< Unused bits
> + } LaneEqualizationCntl; ///< Lane equalization control
> structure used for Gen3 values
> + struct {
> + UINT8 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
> + UINT8 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
> + UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downstream Tx
> Preset
> + UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstream Tx Preset
> + UINT8 Reserved1 : 6; ///< Unused bits
> + } Gen4LaneEqualizationCntl; ///< Lane equalization control
> structure used for Gen4 values
> + struct {
> + UINT8 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
> + UINT8 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
> + UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downstream Tx
> Preset
> + UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstream Tx Preset
> + UINT8 Reserved1 : 6; ///< Unused bits
> + } Gen5LaneEqualizationCntl; ///< Lane equalization control
> structure used for Gen5 values
> + struct {
> + UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT.
> + UINT32 PresetMask16Gt : 10; ///< Preset Mask 16GT.
> + UINT32 PresetMask32Gt : 10; ///< Preset Mask 32GT.
> + UINT32 Reserved1 : 2; ///< Unused bits
> + UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT Set
> + UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16GT Set
> + UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32GT Set
> + UINT8 Reserved2 : 5; ///< Unused bits
> + } PresetMaskCntl; ///< Preset Mask control structure
> used for Gen3/Gen4/Gen5 values
> + UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
> + UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equalization
> + UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equalization
> + UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation
> interval
> + UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enable 0xF:Auto
> + UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect
> mode 0:Disable 1:Enable 0xF:Auto
> + UINT8 LowerSkpOsGenSup; ///< Controls
> LOWER_SKP_OS_GEN_SUPPORT
> + UINT8 LowerSkpOsRcvSup; ///< Controls
> LOWER_SKP_OS_RCV_SUPPORT
> + UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval
> Selection Mode
> + UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for
> SKP ordered set interval when generated based on elasticity buffer pointer
> slip feedback from PCS
> + UINT8 IsBmcLocation : 1; ///< IsBmcLocation
> + UINT8 SetEsmControl : 1; ///< Set ESM Control
> + UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump for ESM
> + UINT8 Reserved6 : 1; ///< Unused bits
> + UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch
> + UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE
> port
> + UINT8 Reserved7 : 1; ///< Unused bits
> + UINT16 NpemEnable : 12; ///< Controls NPEM Enable
> + UINT16 Reserved8 : 4; ///< Unused bits
> + UINT16 NpemCapability : 12; ///< Controls NPEM Capability
> + UINT8 SwingMode : 3; ///< PCIe Swing Mode
> + UINT16 Reserved9 : 1; ///< Unused bits
> + UINT16 MpioAncDataIdx; ///< Reserved for internal use only
> + UINT8 Reserved10; ///< Reserved bits
> +} DXIO_PORT_DATA;
> +
> +///
> +/// EtherNet specific data structures
> +///
> +typedef struct {
> + UINT32 PortNum : 8; ///< Port Number
> + UINT32 PlatConf : 4; ///< Platform Config
> + ///< 0 = Reserved
> + ///< 1 = 10G/1G BackPlane
> + ///< 2 = 2.5G BackPlane
> + ///< 3= Soldered down 1000Base-T
> + ///< 4 = Soldered down 1000Base-X
> + ///< 5 = Soldered down NBase-T
> + ///< 6 = Soldered down 10GBase-T
> + ///< 7 = Soldered down 10GBase-r
> + ///< 8 = SFP+ Connector
> + UINT32 Reserved1 : 4; ///< Unused 12-15
> + UINT32 MdioId : 5; ///< MDIO ID when MDIO Side band is
> used
> + UINT32 Reserved2 : 2; ///< Unused 21-22
> + UINT32 SuppSpeed : 4; ///< Supported Speeds by Platform
> + ///< 1 = 100M Supported
> + ///< 2 = 1G Supported
> + ///< 4 = 2.5G Supported
> + ///< 8 = 10G Supported
> + UINT32 Reserved3 : 1; ///< Unused 27
> + UINT32 ConnType : 3; ///< Supported Speeds by Platform
> + ///< 0 = Port not Used
> + ///< 1 = SFP+ Connection I2C interface
> + ///< 2 = MDIO PHY
> + ///< 4 = Backplane Connection
> + UINT32 Reserved4 : 1; ///< Unused 31
> +} ETH_PORT_PROPERTY0;
> +
> +typedef struct {
> + UINT32 MdioReset : 2; ///< MDIO Reset Type
> + ///< 0 = None
> + ///< 1 = I2C GPIO
> + ///< 2 = Integrated GPIO
> + ///< 3 = Reserved
> + UINT32 Reserved1 : 2; ///< Unused 2-3
> + UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO number for
> reset
> + UINT32 Reserved2 : 2; ///< Unused 6-7
> + UINT32 SfpGpioAdd : 3; ///< Lower I2C address of GPIO
> Expander PCA9535
> + UINT32 Reserved3 : 1; ///< Unused 11
> + UINT32 TxFault : 4; ///< TX FAULT
> + UINT32 Rs : 4; ///< RS Signal
> + UINT32 ModAbs : 4; ///< MOD_ABS signal
> + UINT32 RxLoss : 4; ///< Rx_LOS signal
> + UINT32 SfpGpioMask : 4; ///< SFP+ sideband signals that are
> not supported by platform
> +} ETH_PORT_PROPERTY3;
> +
> +typedef struct {
> + UINT32 SfpMux : 3; ///< Lower address of Mux PCA 9545
> + UINT32 Reserved1 : 1; ///< Unused 3
> + UINT32 SfpBusSeg : 3; ///< SFP BUS Segment. Downstream
> channels of PCA9545
> + UINT32 Reserved2 : 1; ///< Unused 7
> + UINT32 SfpMuxUpAdd : 5; ///< Upper address of Mux PCA
> 9545
> + UINT32 Reserved3 : 3; ///< Unused 13-15
> + UINT32 RedriverAddress : 7; ///< Address of ReDriver
> + UINT32 RedriverInterface : 1; ///< ReDriver Interface Descriptor
> + UINT32 RedriverLane : 3; ///< ReDriver Lane number
> + UINT32 Reserved4 : 1; ///< Unused 27
> + UINT32 RedriverModel : 3; ///< ReDriver Model
> + UINT32 RedriverPresent : 1; ///< Redriver Present
> +} ETH_PORT_PROPERTY4;
> +
> +typedef struct {
> + UINT32 TxEqPre : 6; ///< TX EQ PRE
> + UINT32 Reserved1 : 2; ///< Unused 7-6
> + UINT32 TxEqMain : 6; ///< TX EQ MAIN
> + UINT32 Reserved2 : 2; ///< Unused 15-14
> + UINT32 TxEqPost : 6; ///< TX EQ POST
> + UINT32 Reserved3 : 10; ///< Unused 31-23
> +} ETH_PORT_TXEQ;
> +/// Ethernet PCIe port configuration data
> +///
> +typedef struct {
> + ETH_PORT_PROPERTY0 EthPortProp0; ///<
> XGBE_PORT_PROPERTY_0
> + ETH_PORT_PROPERTY3 EthPortProp3; ///<
> XGBE_PORT_PROPERTY_3
> + ETH_PORT_PROPERTY4 EthPortProp4; ///<
> XGBE_PORT_PROPERTY_4
> + UINT32 PadMux0; ///< PadMux0 Setting (8 bits)
> + UINT32 PadMux1; ///< PadMux1 Setting (8 bits)
> + UINT32 MacAddressLo; ///< Lower 32 bits of MAC Address
> + UINT32 MacAddressHi; ///< Upper 32 bits of MAC Address
> + ETH_PORT_TXEQ EthPortTxEq; ///< TX EQ Settings
> +} ETHERNET_PORT_DATA;
> +
> +///
> +/// High level data structures for passing topology from platform to AGESA
> +///
> +typedef struct {
> + UINT8 EngineType; ///< Engine type
> + ///< 0 - Ignore engine configuration
> + ///< 1 - PCIe port
> + UINT8 HotPluggable : 1; ///< HotPluggable
> + ///< 0 - Link is NOT Hot-Switchable
> + ///< 1 - Link IS Hot-Switchable
> + UINT8 Reserved1 : 7; ///< Unused field, leave as 0
> + UINT8 StartLane; ///< Start Lane ID (in reversed
> configuration StartLane > EndLane)
> + ///< Refer to lane descriptions and supported
> configurations in BKDG
> + UINT8 EndLane; ///< End lane ID (in reversed
> configuration StartLane > EndLane)
> + ///< Refer to lane descriptions and supported
> configurations in BKDG
> + UINT8 GpioGroupId; ///< Unique identifier for the GPIO or
> GPIO group associated with
> + ///< this engine. GPIOs are used for hotplug
> notification and link
> + ///< type (e.g SATA Express or PCIe)
> + UINT8 DxioStartLane; ///< Internal coding of start lane
> + UINT8 DxioEndLane; ///< Internal coding of end lane
> + UINT8 SearchDepth; ///< SearchDepth only uses 1 bit -
> always initialize to 0 will be updated dynamically
> +} DXIO_ENGINE_DATA;
> +
> +///
> +/// PCIe port descriptor
> +///
> +typedef struct {
> + UINT32 Flags; ///< Descriptor flags
> + ///< Bit31 - last descriptor in complex
> + DXIO_ENGINE_DATA EngineData; ///< Engine data
> + DXIO_PORT_DATA Port; ///< PCIe port specific configuration
> info
> + ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for EtherNet
> + PHY_DATA Phy; ///< Ancillary data for PHY programming
> customization
> + PORT_PARAMS PortParams; ///< Extensible port parameter list
> for simplified topology structure
> + ANC_DATA AncData; ///< Ancillary data override
> +} DXIO_PORT_DESCRIPTOR;
> +
> +#pragma pack(pop)
> +
> +///
> +///
> +/// PCIe Complex descriptor
> +///
> +typedef struct {
> + UINT32 Flags; ///< Descriptor flags
> + ///< Bit31 - last descriptor in topology
> + UINT32 SocketId; ///< Socket Id
> + DXIO_PORT_DESCRIPTOR *PciePortList; ///< Pointer to array of PCIe
> port descriptors or NULL (Last element of array must be terminated with
> DESCRIPTOR_TERMINATE_LIST).
> + VOID *Reserved2; ///< Reserved for future use
> + UINT8 BmcLinkLocation; ///< Identifies the socket/die location
> of a BMC link (Used by AGESA, input not required)
> + UINT8 BmcLinkLaneNum; ///< Identifies the socket/die
> location of a BMC Lane number
> + UINT8 Reserved3[2]; ///< Reserved for future
> +} DXIO_COMPLEX_DESCRIPTOR;
> +
> +///
> +/// Engine descriptor type
> +///
> +typedef enum {
> + DxioUnusedEngine = 0, ///< Unused descriptor Excluded
> from configuration
> + DxioPcieEngine = 1, ///< PCIe port
> + DxioUSBEngine = 2, ///< USB port
> + ///< __Deprecated__
> + DxioSATAEngine = 3, ///< SATA
> + DxioUSB_OVER_PCIE = 4, ///< USB4 PCIe (internal use
> only)
> + DxioUBMHFCEngine = 5, ///< New for Genoa UBM HFC
> Connector for auto-discovery
> + DxioOCP3Engine = 6, ///< New for Genoa OCP3
> Bifurcatable Connector
> + DxioUdot3Engine = 7, ///< New for Genoa U.3
> Multiprotocol Connector
> + DxioDPEngine = 8, ///< Digital Display __For APU
> display connector list__
> + DxioEthernetEngine = 0x10, ///< Ethernet (GBe, XGBe)
> + ///< __Deprecated__
> + DxioGOPEngine = 0x20, ///< GOP
> + ///< __Deprecated__
> + DxioNTBDevice = 0x60, ///< For NBIF NTB Enable
> (internal use only)
> + DxioHDaudioEngine, ///< For NBIF HDaudtio Enable
> (internal use only)
> + DxioACPEngine, ///< For NBIF ACP Enable (internal
> use only)
> + DxioMP2Engine, ///< For NBIF MP2 Enable (internal
> use only)
> + DxioMaxPcieEngine ///< Max engine type for
> boundary check.
> +} DXIO_ENGINE_TYPE;
> +
> +///
> +/// PCIe link speeds
> +///
> +typedef enum {
> + DxioGenMaxSupported, ///< Maximum supported
> + DxioGen1 = 1, ///< Gen1
> + DxioGen2, ///< Gen2
> + DxioGen3, ///< Gen3
> + DxioGen4, ///< Gen4
> + DxioGen5, ///< Gen5
> + MaxDxioGen ///< Max Gen for boundary check
> +} DXIO_LINK_SPEEDS;
> +#endif // AMD_PCIE_COMPLEX_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h
> b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
> new file mode 100644
> index 0000000000..d62f260235
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
> @@ -0,0 +1,17 @@
> +/** @file
> +
> + Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _AMD_SOC_H_
> +#define _AMD_SOC_H_
> +
> +#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
> +#endif // _AMD_SOC_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
> b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
> new file mode 100644
> index 0000000000..2291f7dc83
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
> @@ -0,0 +1,42 @@
> +/** @file
> + Fabric resource manager common definition
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef FABRIC_RESOURCE_MANAGER_CMN_H_
> +#define FABRIC_RESOURCE_MANAGER_CMN_H_
> +#pragma pack (push, 1)
> +
> +#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets
> in system.
> +#define MAX_RBS_PER_SOCKET 20 ///< Max number of root
> bridges per socket.
> +
> +/**
> + * @brief DF address aperture structure.
> + * @details This contains information used to define an MMIO region.
> + */
> +typedef struct _FABRIC_ADDR_APERTURE {
> + UINT64 Base; ///< Aperture base Address.
> + UINT64 Size; ///< Aperture size.
> + UINT64 Alignment; ///< Alignment bit map. 0xFFFFF means 1MB
> align.
> +} FABRIC_ADDR_APERTURE;
> +
> +/**
> + * @brief DF Resource for each RootBridge structure.
> + * @details This contains information used to define the MMIO region for
> each RootBridge.
> + */
> +typedef struct _FABRIC_RESOURCE_FOR_EACH_RB {
> + FABRIC_ADDR_APERTURE
> NonPrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_
> PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER
> _SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_
> PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_
> SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; ///<
> Primary RootBridge's second nonprefetchable MMIO size below 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> PrimaryRbSecondPrefetchableMmioSizeBelow4G; ///<
> Primary RootBridge's second prefetchable MMIO size below 4G. @see
> FABRIC_ADDR_APERTURE
> + FABRIC_ADDR_APERTURE
> IO[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
> ///< IO resource(s) @see FABRIC_ADDR_APERTURE
> + UINT16
> PciBusNumber[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
> ///< PCI bus number(s).
> +} FABRIC_RESOURCE_FOR_EACH_RB;
> +#pragma pack (pop)
> +#endif // FABRIC_RESOURCE_MANAGER_CMN_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
> b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
> new file mode 100644
> index 0000000000..9e58f299b4
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
> @@ -0,0 +1,96 @@
> +/** @file
> + AMD Memory Info Hob Definition
> +
> + Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_MEMORY_INFO_HOB_H_
> +#define AMD_MEMORY_INFO_HOB_H_
> +
> +/**
> + * @brief 128 bit Buffer containing UID Unique Identifier value for Memory
> Info HOB.
> + * EFI_GUID defined in UefiBaseType.h
> + */
> +extern EFI_GUID gAmdMemoryInfoHobGuid;
> +
> +#pragma pack (push, 1)
> +
> +/**
> + * @brief Memory descriptor structure for each memory range
> + */
> +typedef struct {
> + UINT64 Base; ///< Base address of memory rang
> + UINT64 Size; ///< Size of memory rang
> + UINT32 Attribute; ///< Attribute of memory rang
> + UINT32 Reserved; ///< For alignment purpose
> +} AMD_MEMORY_RANGE_DESCRIPTOR;
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = AVAILABLE
> + */
> +#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = UMA
> + */
> +#define AMD_MEMORY_ATTRIBUTE_UMA 0x2
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = MMIO
> + */
> +#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = RESERVED
> + */
> +#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = GPUMEM
> + */
> +#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor = GPU_SP
> + */
> +#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor =
> GPU_RESERVED
> + */
> +#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor =
> GPU_RESERVED_TMR
> + */
> +#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8
> +
> +/**
> + * @brief Memory attribute in the memory range descriptor =
> RESERVED_SMUFEATURES
> + */
> +#define AMD_MEMORY_ATTRIBUTE_Reserved_SmuFeatures 0x9
> +
> +/// Memory info HOB structure
> +typedef struct {
> + UINT32 Version; ///< Version of HOB structure
> + BOOLEAN AmdMemoryVddioValid; ///< This field
> determines if Vddio is valid
> + UINT16 AmdMemoryVddio; ///< Vddio Voltage
> + BOOLEAN AmdMemoryVddpVddrValid; ///< This field
> determines if VddpVddr is valid
> + UINT8 AmdMemoryVddpVddr; ///< VddpVddr voltage
> + BOOLEAN AmdMemoryFrequencyValid; ///< Memory
> Frequency Valid
> + UINT32 AmdMemoryFrequency; ///< Memory Frquency
> + UINT32 AmdMemoryDdrMaxRate; ///< Memory
> DdrMaxRate
> + UINT32 NumberOfDescriptor; ///< Number of memory
> range descriptor
> + AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory
> ranges array
> +} AMD_MEMORY_INFO_HOB;
> +
> +#pragma pack (pop)
> +
> +/**
> + * @brief Macro that defines the Memory Info HOB version
> + */
> +#define AMD_MEMORY_INFO_HOB_VERISION 0x00000110ul // Ver:
> 00.00.01.10
> +
> +#endif // AMD_MEMORY_INFO_HOB_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
> b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
> new file mode 100644
> index 0000000000..d144a4ad20
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
> @@ -0,0 +1,51 @@
> +/** @file
> + AMD Psp Base Lib
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_PSP_BASELIB_V2_H_
> +#define AMD_PSP_BASELIB_V2_H_
> +
> +#include <AmdPspDirectory.h>
> +
> +#define MAX_IMAGE_SLOT_COUNT 32
> +
> +#define ALIGNMENT_4K BASE_4KB
> +#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1))
> == 0)
> +#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K)
> +
> +#define IS_VALID_ADDR32(addr) (((UINT32)(addr) != 0) &&
> (UINT32)(addr) != 0xFFFFFFFF)
> +
> +#pragma pack (push, 1)
> +
> +#define FIRMWARE_TABLE_SIGNATURE 0x55AA55AAul
> +
> +/// Define the structure OEM signature table
> +typedef struct _FIRMWARE_ENTRY_TABLEV2 {
> + UINT32 Signature; ///< 0x00 Signature should be 0x55AA55AAul
> + UINT32 ImcRomBase; ///< 0x04 Base Address for Imc Firmware
> + UINT32 GecRomBase; ///< 0x08 Base Address for Gmc Firmware
> + UINT32 XHCRomBase; ///< 0x0C Base Address for XHCI Firmware
> + UINT32 LegacyPspDirBase; ///< 0x10 Base Address of PSP directory
> + UINT32 PspDirBase; ///< 0x14 Base Address for PSP directory
> + UINT32 Reserved1; ///< 0x18 Base Address for Reserved BIOS
> directory
> + UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS
> directory
> + UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS
> directory
> + UINT32 Config; ///< 0x24 reserved for EFS Configuration
> + UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all
> program
> + UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for
> all programs
> +} FIRMWARE_ENTRY_TABLEV2;
> +
> +/// It also used as structure to store ISH generic information across programs
> +typedef struct {
> + UINT32 Priority;
> + UINT32 UpdateRetries;
> + UINT32 GlitchRetries;
> + UINT32 ImageSlotAddr;
> +} IMAGE_SLOT_HEADER;
> +
> +#pragma pack (pop)
> +
> +#endif // AMD_LIB_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
> b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
> new file mode 100644
> index 0000000000..23c90b65c2
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
> @@ -0,0 +1,83 @@
> +/** @file
> + AMD Psp Ftpm Library header file
> +
> + Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PSP_FTPM_LIB_H_
> +#define PSP_FTPM_LIB_H_
> +#include <IndustryStandard/Acpi30.h>
> +
> +/* SYSTEM_TPM_CONFIG_VAL
> + * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG
> + */
> +typedef enum {
> + SYSTEM_TPM_CONFIG_DTPM = 0x00, ///< dTPM
> + SYSTEM_TPM_CONFIG_PSP_FTPM = 0x01, ///< PSP FTPM
> + SYSTEM_TPM_CONFIG_HSP_FTPM = 0x02, ///< HSP FTPM
> + SYSTEM_TPM_CONFIG_NONE = 0xFF, ///< None of TPM
> +} SYSTEM_TPM_CONFIG_VAL;
> +
> +#pragma pack (push, 1)
> +/// Define TPM_2_CONTROL_AREA
> +typedef struct {
> + // Interface Identifier
> + volatile UINT64 InterfaceIdentifier; ///< Interface Identifier
> + // TPM2 Control Area Extension
> + volatile UINT32 Clear; ///< Clear
> + volatile UINT32 RemainingBytes; ///< RemainingBytes
> + volatile UINT32 StatusReserved; ///< StatusReserved
> + volatile UINT32 StatusError; ///< StatusError
> + volatile UINT32 StatusCancel; ///< StatusCancel
> + volatile UINT32 StatusStart; ///< StatusStart
> + UINT64 InterruptControl; ///< InterruptControl
> + UINT32 CommandSize; ///< CommandSize
> + EFI_PHYSICAL_ADDRESS CommandAddress; ///< CommandAddress
> + UINT32 ResponseSize; ///< ResponseSize
> + EFI_PHYSICAL_ADDRESS ResponseAddress; ///< ResponseAddress
> + // Memory Absent command/response buffer
> + volatile UINT32 CmdRespHWBuffer; ///< Cmd/Rsp HW Buffer
> +} TPM2_CONTROL_AREA;
> +
> +#pragma pack (pop)
> +
> +/**
> + GET TPM related Info
> +
> + @param[in,out] FtpmStatus Used to hold more detail info (Unused
> Currently)
> +
> + @return EFI_SUCCESS Ftpm function supported
> + @return EFI_UNSUPPORTED Ftpm function unsupported
> +
> +**/
> +EFI_STATUS
> +FtpmGetInfo (
> + IN OUT UINTN *FtpmStatus
> + );
> +
> +/**
> + Execute a TPM command
> +
> + @param[in] CommandBuffer Point to the TPM command buffer
> + @param[in] CommandSize Size of the TPM command buffer
> + @param[in, out] ResponseBuffer Point to the TPM response buffer
> + @param[in, out] ResponseSize Size of the TPM response buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold
> the response
> +
> +**/
> +EFI_STATUS
> +FtpmExecuteCommand (
> + IN VOID *CommandBuffer,
> + IN UINT32 CommandSize,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINT32 *ResponseSize
> + );
> +
> +#endif //PSP_FTPM_LIB_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
> b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
> new file mode 100644
> index 0000000000..4ad4020f95
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
> @@ -0,0 +1,231 @@
> +/** @file
> +
> + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _PSP_ROM_ARMOR_LIB_H_
> +#define _PSP_ROM_ARMOR_LIB_H_
> +
> +#include "Uefi.h"
> +
> +#define PSP_MAX_SPI_CMD_SUPPORT (4) ///< Max number of SPI
> command support
> +#define PSP_MAX_SPI_DATA_BUFFER_SIZE (72) ///< Max SPI Command
> Data Buffer Size
> +#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list
> allowed command array number support
> +#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list
> allowed region array number support
> +
> +#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chip selects
> +#define SPI_CHIP_SELECT_1 (1) ///< Chip Select 1
> +#define SPI_CHIP_SELECT_2 (2) ///< Chip Select 2
> +
> +#define SPI_COMMAND_FREQUENCY_66_66MHZ (0) ///< 0=66.66MHz
> +#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=33.33MHz
> +#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=22.22MHz
> +#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=16.66MHz
> +#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=100MHz
> +#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=800KHz
> +
> +#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 = Command not
> examined/processed
> +#define SPI_COMMAND_COMPLETED (1) ///< 1 = Command
> completed successfully
> +#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 = Execution
> Error (i.e. timeout)
> +#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 = Command not
> allowed by Whitelist
> +#define SPI_COMMAND_MALFORMED (4) ///< 4 = Command
> malformed
> +
> +#pragma pack (push, 1)
> +
> +typedef struct {
> + UINT8 ChipSelect; ///< 1 = CS1, 2 = CS2, all other values illegal
> +
> + UINT8 Frequency; ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
> + ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
> +
> + UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Does not
> include the
> + ///< SPI Opcode byte, but does include the address, dummy
> bytes, and
> + ///< data.
> +
> + UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx +
> BytesToRx <= 72
> +
> + UINT8 OpCode; ///< The SPI Command OpCode (the first byte sent by
> the SPI controller)
> +
> + UINT8 Reserved[3]; ///< Reserved for future expansion
> +
> + UINT8 Buffer[PSP_MAX_SPI_DATA_BUFFER_SIZE]; ///< The remaining
> 0-72 bytes sent/received by the SPI controller.
> + ///<
> + ///< The SPI Controller will
> + ///< 1. Assert the ChipSelect
> + ///< 2. Send the one byte OpCode
> + ///< 3. Send Buffer[0] to Buffer[BytesToTx-1]
> to the SPI device
> + ///< 4. Read BytesToRx bytes from the device
> into Buffer[BytesToTx] to
> + ///< Buffer[BytesToTx+BytesToRx-1]
> + ///< 5. Deassert the ChipSelect line
> + ///<
> + ///< SPI ROM Commands that include a target
> address send the address
> + ///< immediately after the OpCode (i.e.
> Buffer[0..2] or Buffer[0..3]
> + ///< depending if 24 or 32bit addresses are
> associated with the OpCode).
> + ///< See the SPI ROM Device's datasheet for
> full details on your
> + ///< devices commands and formats.
> +} SPI_COMMAND; ///< The struct of Spi Command
> +
> +typedef union {
> + struct {
> + ///< SPI_COMMUNICATION_RESULT
> + UINT16 Command0Result : 4; ///< Result[ 3: 0] The result of
> Command[0]
> + UINT16 Command1Result : 4; ///< Result[ 7: 4] The result of
> Command[1]
> + UINT16 Command2Result : 4; ///< Result[11: 8] The result of
> Command[2]
> + UINT16 Command3Result : 4; ///< Result[15:12] The result of
> Command[3]
> + } Field; ///< the struct type of Command0 ~ Command4
> + UINT16 Value; ///< 16 bit value of Command0 ~ Command4
> +} SPI_COMMUNICATION_RESULT; ///< The union struct type of Spi
> Communication Result
> +
> +typedef struct {
> + UINT8 ReadyToRun; ///< Set to FALSE by x86 while the buffer is
> being constructed. Set to
> + ///< TRUE by x86 as the last step in building the
> communication buffer,
> + ///< just before x86 rings the PSP doorbell.
> + ///<
> + ///< Set to FALSE by PSP after the PSP copies the
> buffer from DRAM to
> + ///< private SRAM.
> +
> + UINT8 CommandCount; ///< Number of commands to execute,
> Valid Values 1-4
> +
> + SPI_COMMUNICATION_RESULT SpiCommunicationResult; ///< Set to zero
> by x86 when the buffer is built. Atomically set to a
> + ///< non-zero value by the PSP to indicate the
> PSP has finished
> + ///< processing the requests in the
> communication buffer. The specific
> + ///< value written by the PSP provides per
> command results
> + ///<
> + ///< Result values with special meaning:
> + ///< 0x0000 = (written by x86) PSP has not
> finished handling the request
> + ///< 0x1000 = PSP determined the request is
> malformed (invalid
> + ///< CommandCount, chipselect,
> BytesToRx/Tx, etc)
> + ///< 0x2000, 0x3000, 0x4000, ... , 0xF000 =
> Reserved for future errors
> + ///<
> + ///< Generic Result values:
> + ///< SpiCommunicationResult[ 3: 0] The
> result of Command[0]
> + ///< SpiCommunicationResult[ 7: 4] The
> result of Command[1]
> + ///< SpiCommunicationResult[11: 8] The
> result of Command[2]
> + ///< SpiCommunicationResult[15:12] The
> result of Command[3]
> + ///< 0 = Command not examined/processed
> + ///< 1 = Command completed successfully
> + ///< 2 = Execution Error (i.e. timeout)
> + ///< 3 = Command not allowed by Whitelist
> + ///< 4 = Command malformed
> + ///< 5-15 = reserved for future use
> + ///<
> + ///< Examples of Generic Results:
> + ///< 0x0000 - PSP has not finished the
> request
> + ///< 0x0001 - PSP ran Command0
> successfully, and is now idle
> + ///< 0x0111 - PSP ran Command0/1/2
> successfully and is now idle
> + ///< 0x0031 - PSP ran Command0, but
> Command1 was blocked by whitelist
> +
> + SPI_COMMAND SpiCommand[PSP_MAX_SPI_CMD_SUPPORT]; ///< Spi
> command array
> +} SPI_COMMUNICATION_BUFFER; ///< The struct type of Spi
> Communication Buffer
> +
> +typedef struct {
> + UINT8 ChipSelect; ///< 0= Allowed on all chip selects, 1= CS1, 2= CS2, all
> else invalid
> +
> + UINT8 Frequency; ///< The allowed frequency for the command
> + ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
> + ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
> +
> + UINT8 OpCode; ///< The allowed commands opcode
> +
> + UINT8 MinTx; ///< The minimum range of allowed transmit byte
> counts for this command
> + ///< (does not include opcode)
> + UINT8 MaxTx; ///< The maximum range of allowed transmit byte
> counts for this command
> + ///< (does not include opcode)
> +
> + UINT8 MinRx; ///< The minimum range of allowed Rx byte counts
> + UINT8 MaxRx; ///< The maximum range of allowed Rx byte counts
> +
> + UINT8 AddrChkMethod; ///< 0=No address verification performed
> + ///< 1=Treat Buffer[0-2] as a 24-bit address, and verify the
> entire
> + ///< ImpactZone of the command falls within one of the
> allowed regions
> + ///< 2=Treat Buffer[0-3] as a 32-bit address, and verify the
> entire
> + ///< ImpactZone of the command falls within one of the
> allowed regions
> +
> + UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned power
> of two sized block
> + ///< of addresses that may be impacted by a given SPI
> Command. For
> + ///< example, a sector erase command targeted at an address
> within a
> + ///< 64K block will impact every byte within that 64K block.
> Likewise
> + ///< a page program SPI command (i.e. write) may impact
> many bytes
> + ///< within the targeted 256/512 byte page due to page
> wrap-around, but
> + ///< no bytes outside the page. The ImapctSize field specifies
> the power
> + ///< of two size of the ImpactZone for this command. If
> VerifyAddress is
> + ///< zero (no checking) this field must also be zero, otherwise
> this
> + ///< field must be a power of two between 256 and 64MB
> (256, 512, ...,
> + ///< 67108864). NOTE: When setting this field, carefully
> examine your
> + ///< device's datasheet.
> + ///<
> +} WHITE_LIST_ALLOWED_COMMAND; ///< The struct type of White List
> Allowed Command
> +
> +typedef struct {
> + // 8 bytes
> + UINT32 StartAddress; ///< LSB must be 0x00, bit31 identifies a
> chipselect: 0=CS1, 1=CS2
> + UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be less
> than EndAddress
> +} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed
> Region
> +
> +typedef struct {
> + UINT8 AllowedCmdCount; ///< Allow
> Command Count
> + UINT8 AllowedRegionCount; ///< Allow
> Region Count
> + WHITE_LIST_ALLOWED_COMMAND
> WhitelistAllowedCommands[PSP_MAX_WHITE_LIST_CMD_NUM]; ///< White
> List Allowed Command Table
> + WHITE_LIST_ALLOWED_REGION
> WhitelistAllowedRegions[PSP_MAX_WHITE_LIST_REGION_NUM]; ///< White
> List Allowed Region Table
> +} SPI_WHITE_LIST; ///< The struct type of Spi White List
> +
> +#pragma pack (pop)
> +
> +/**
> + * @brief Request secures the SPI Controller
> + *
> + * @param[in,out] SpiCommunicationBuffer Spi Communication Structure
> Buffer pointer
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspEnterSmmOnlyMode (
> + IN OUT SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
> + );
> +
> +/**
> + * @brief Loads the whitelist into the PSP.
> + *
> + * @param[in] SpiWhitelist SPI white list structure buffer pointer.
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspEnforceWhitelist (
> + IN SPI_WHITE_LIST *SpiWhitelist
> + );
> +
> +/**
> + * @brief Request execute SPI command provide in TSEG comm buffer.
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspExecuteSpiCommand (
> + VOID
> + );
> +
> +/**
> + * @brief Request PSP firmware switch SPI controller chip select.
> + *
> + * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip
> selects, 1= CS1, 2= CS2, all else invalid
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspSwitchChipSelect (
> + IN UINT8 ChipSelect
> + );
> +
> +#endif //_PSP_ROM_ARMOR_LIB_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
> b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
> new file mode 100644
> index 0000000000..0189910bd1
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
> @@ -0,0 +1,2722 @@
> +/** @file
> +
> + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AML_LIB_H_
> +#define AML_LIB_H_
> +
> +#include <Uefi.h>
> +#include <IndustryStandard/Acpi.h>
> +
> +typedef enum {
> + AmlStart,
> + AmlClose,
> + AmlInvalid
> +} AML_FUNCTION_PHASE;
> +
> +#define AML_OBJECT_INSTANCE_SIGNATURE SIGNATURE_32 ('a', 'm', 'l', 'o')
> +
> +//
> +// Device Status Bitmap (Section 6.3.7 ACPI version 6.3)
> +// Bit [0] - Set if the device is present.
> +// Bit [1] - Set if the device is enabled and decoding its resources.
> +// Bit [2] - Set if the device should be shown in the UI.
> +// Bit [3] - Set if the device is functioning properly (cleared if device
> +// failed its diagnostics).
> +// Bit [4] - Set if the battery is present.
> +// Bits [31:5] - Reserved (must be cleared).
> +//
> +#define DEVICE_PRESENT_BIT 0x0001
> +#define DEVICE_ENABLED_BIT 0x0002
> +#define DEVICE_IN_UI_BIT 0x0004
> +#define DEVICE_HEALTH_BIT 0x0008
> +#define DEVICE_BATTERY_BIT 0x0010 // Control Method Battery Device
> Only
> +
> +typedef enum {
> + UnknownObj,
> + IntObj,
> + StrObj,
> + BuffObj,
> + PkgObj,
> + FieldUnitObj,
> + DeviceObj,
> + EventObj,
> + MethodObj,
> + MutexObj,
> + OpRegionObj,
> + PowerResObj,
> + ProcessorObj,
> + ThermalZoneObj,
> + BuffFieldObj,
> + DDBHandlObj,
> + InvalidObj
> +} OBJECT_TYPE_KEYWORD;
> +
> +typedef struct {
> + UINT32 Signature;
> + BOOLEAN Completed;
> + UINTN DataSize;
> + UINT8 *Data;
> + LIST_ENTRY Link;
> +} AML_OBJECT_INSTANCE;
> +
> +//
> ************************************************************
> ***************
> +// AML defines to be consistent with already existing
> +// MdePkg/Include/IndustryStandard/Acpi*.h defines.
> +// *** These could be upstreamed at some point.
> +//
> ************************************************************
> ***************
> +// Limits of (DWord|Word|QWord)Space ResourceType
> +#define EFI_ACPI_SPACE_RESOURCE_TYPE_MIN 0xC0
> +#define EFI_ACPI_SPACE_RESOURCE_TYPE_MAX 0xFF
> +
> +// General Flags: Flags that are common to all resource types
> +// Bits[7:4] Reserved(must be 0)
> +// Bit[3] Max Address Fixed, _MAF:
> +// 1 The specified maximum address is fixed
> +// 0 The specified maximum address is not fixed and can be changed
> +#define EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED (1 << 3)
> +#define EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED (0 << 3)
> +#define EFI_ACPI_GENERAL_FLAG_MASK_MAF
> EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
> +// Bit[2] Min Address Fixed, _MIF:
> +// 1 The specified minimum address is fixed
> +// 0 The specified minimum address is not fixed and can be changed
> +#define EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED (1 << 2)
> +#define EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED (0 << 2)
> +#define EFI_ACPI_GENERAL_FLAG_MASK_MIF
> EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
> +// Bit[1] Decode Type, _DEC:
> +// 1 This bridge subtractively decodes this address(top level bridges only)
> +// 0 This bridge positively decodes this address
> +#define EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE (1 << 1)
> +#define EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE (0 << 1)
> +#define EFI_ACPI_GENERAL_FLAG_MASK_DEC
> EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
> +// Bit[0] Consumer / Producer:
> +// 1 This device consumes this resource
> +// 0 This device produces and consumes this resource
> +#define EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER (1 << 0)
> +#define EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER (0 << 0)
> +#define EFI_ACPI_GENERAL_FLAG_MASK_USAGE
> EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
> +
> +// Memory Resource Flag (Resource Type = 0) DefinitionsBits
> +// Memory Resource Flag Masks
> +// Bits[7:6] Reserved(must be 0)
> +// Bit[5] Memory to I/O Translation, _TTP:
> +// 0 TypeStatic
> +// 1 Type Translation
> +#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_TTP (1 << 5)
> +// Bit[4:3] Memory Attributes, _MTP:
> +// 0 AddressRangeMemory
> +// 1 AddressRangeReserved
> +// 2 AddressRangeACPI
> +// 3 AddressRangeNVS
> +#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MTP (3 << 3)
> +// Bit[2:1] Memory Attributes, _MEM:
> +// 0 The memory is non-cacheable
> +// 1 The memory is cacheable
> +// 2 The memory is cacheable and supports write-combining
> +// 3 The memory is cacheable and prefetchable
> +#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM (3 << 1)
> +// Bit[0] Write Status, _RW:
> +// 0 This memory range is read-only
> +// 1 This memory is read-write
> +#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW (1 << 0)
> +
> +// I/O Resource Flag (Resource Type = 1) DefinitionsBits
> +// I/O Resource Flags
> +// Bit [7:6] Reserved (must be 0)
> +// Bit [5] Sparse Translation, _TRS. This bit is only meaningful if Bit [4] is set.
> +// 1 SparseTranslation: The primary-side memory address of any specific
> I/O port
> +// within the secondary-side range can be found using the following
> function.
> +// address = (((port & 0xFFFc) << 10) || (port & 0xFFF)) + _TRA In the
> address
> +// used to access the I/O port, bits[11:2] must be identical to bits[21:12],
> +// this gives four bytes of I/O ports on each 4 KB page.
> +// 0 DenseTranslation: The primary-side memory address of any specific
> I/O port
> +// within the secondary-side range can be found using the following
> function.
> +// address = port + _TRA
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_SPARSE_TRANSLATION (1
> << 5)
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_DENSE_TRANSLATION (0
> << 5)
> +// Bit [4] I/O to Memory Translation, _TTP
> +// 1 TypeTranslation: This resource, which is I/O on the secondary side of
> the
> +// bridge, is memory on the primary side of the bridge.
> +// 0 TypeStatic: This resource, which is I/O on the secondary side of the
> +// bridge, is also I/O on the primary side of the bridge.
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION (1 <<
> 4)
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC (0 << 4)
> +// Bit [3:2] Reserved (must be 0)
> +// Bit [1:0] _RNG
> +// 3 Memory window covers the entire range
> +// 2 ISARangesOnly. This flag is for bridges on systems with multiple
> bridges.
> +// Setting this bit means the memory window specified in this descriptor
> is
> +// limited to the ISA I/O addresses that fall within the specified window.
> The
> +// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. This
> bit can
> +// only be set for bridges entirely configured throughACPI namespace.
> +// 1 NonISARangesOnly. This flag is for bridges on systems with multiple
> +// bridges. Setting this bit means the memory window specified in this
> +// descriptor is limited to the non-ISA I/O addresses that fall within the
> +// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7FF,
> +// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entirely
> +// configured through ACPI namespace.
> +// 0 Reserved
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE
> (3 << 0)
> +#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY
> (2 << 0)
> +#define
> EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY (1 <<
> 0)
> +
> +#define AML_OBJECT_INSTANCE_FROM_LINK(a) BASE_CR (a,
> AML_OBJECT_INSTANCE, Link)
> +
> +// Method Serialize Flag Values
> +typedef enum {
> + NotSerialized,
> + Serialized,
> + FlagInvalid
> +} METHOD_SERIALIZE_FLAG;
> +// AccessField Access Attrib Flags.
> +// Ref ACPI spec 6.3
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL
> 0x00
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK
> 0x02
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE
> 0x04
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE 0x06
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD
> 0x08
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK
> 0x0A
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES 0x0B
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL
> 0x0C
> +#define
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL
> 0x0D
> +#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES
> 0x0E
> +#define
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
> 0X0F
> +
> +// AccessField access types
> +typedef enum {
> + AnyAcc,
> + ByteAcc,
> + WordAcc,
> + DWordAcc,
> + QWordAcc,
> + BufferAcc,
> +} EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS;
> +
> +// Field lock rules
> +typedef enum {
> + NoLock,
> + Lock
> +} EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS;
> +
> +// Field update rules
> +typedef enum {
> + Preserve,
> + WriteAsOnes,
> + WriteAsZeros
> +} EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS;
> +
> +// Field access attributes. for AttribBytes, AttribRawBytes and
> AttribRawProcessBytes
> +// the ExtendedAccessField definition is used, as this is what iASL compiles
> into, rather
> +// than the AccessField that is specified in the ACPI spec.
> +typedef enum {
> + AttribNormal =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL,
> + AttribQuick = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK,
> + AttribSendReceive =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE,
> + AttribByte = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE,
> + AttribWord =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD,
> + AttribBlock = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK,
> + AttribBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES,
> + AttribProcessCall =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL,
> + AttribBlockProcessCall =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL,
> + AttribRawBytes =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES,
> + AttribRawProcessBytes =
> EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
> +} EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS;
> +
> +//
> +// Resource Type Specific Flags
> +// Ref ACPI specification 6.4.3.5.5
> +//
> +//
> +// DMA Information
> +// Ref ACPI specification 6.4.2.2
> +//
> +// DmaType values
> +typedef enum {
> + Compatibility = EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY,
> + TypeA = EFI_ACPI_DMA_SPEED_TYPE_A,
> + TypeB = EFI_ACPI_DMA_SPEED_TYPE_B,
> + TypeF = EFI_ACPI_DMA_SPEED_TYPE_F
> +} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS;
> +
> +// IsBusMaster values
> +typedef enum {
> + NotBusMaster = 0,
> + BusMaster = EFI_ACPI_DMA_BUS_MASTER
> +} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS;
> +
> +// DmaTransferSize values
> +typedef enum {
> + Transfer8 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT,
> + Transfer8_16 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT,
> + Transfer16 = EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT
> +} EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS;
> +
> +//
> +// Interrupt Resource Descriptor Information
> +// Ref ACPI specification 6.4.2.1
> +//
> +// IRQ Information - Wake Capability
> +//
> +#define EFI_ACPI_IRQ_WAKE_CAPABLE_MASK 0x20
> +#define EFI_ACPI_IRQ_NOT_WAKE_CAPABLE 0x0
> +#define EFI_ACPI_IRQ_WAKE_CAPABLE 0x20
> +
> +typedef enum {
> + NotWakeCapable = EFI_ACPI_IRQ_NOT_WAKE_CAPABLE,
> + WakeCapable = EFI_ACPI_IRQ_WAKE_CAPABLE
> +} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS;
> +
> +//
> +// IRQ Information - Interrupt Sharing
> +//
> +#define EFI_ACPI_IRQ_EXCLUSIVE 0x0
> +
> +typedef enum {
> + Exclusive = EFI_ACPI_IRQ_EXCLUSIVE,
> + Shared = EFI_ACPI_IRQ_SHARABLE,
> + ExclusiveAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE |
> EFI_ACPI_IRQ_EXCLUSIVE,
> + SharedAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE |
> EFI_ACPI_IRQ_SHARABLE
> +} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS;
> +
> +//
> +// IRQ Information - Interrupt Polarity
> +//
> +typedef enum {
> + ActiveHigh = EFI_ACPI_IRQ_HIGH_TRUE,
> + ActiveLow = EFI_ACPI_IRQ_LOW_FALSE
> +} EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS;
> +
> +//
> +// IRQ Information - Interrupt Mode
> +//
> +#define EFI_ACPI_IRQ_MODE_MASK 0x1
> +typedef enum {
> + LevelTriggered = EFI_ACPI_IRQ_LEVEL_TRIGGERED,
> + EdgeTriggered = EFI_ACPI_IRQ_EDGE_TRIGGERED
> +} EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS;
> +
> +// IO Port Descriptor Information
> +// Ref ACPI specification 6.4.2.5
> +//
> +typedef enum {
> + Decode16 = EFI_ACPI_IO_DECODE_16_BIT,
> + Decode10 = EFI_ACPI_IO_DECODE_10_BIT
> +} EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION;
> +
> +//
> +// Memory Resource Information
> +// Ref ACPI specification 6.4.3.5
> +//
> +// Consumer/Producer Bit[0]
> +typedef enum {
> + ResourceProducer = EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER,
> + ResourceConsumer = EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
> +} RESOURCE_USAGE_FLAG;
> +
> +// Decode Type (_DEC) Bit[1]
> +typedef enum {
> + PosDecode = EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE,
> + SubDecode = EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
> +} MEM_DECODE_FLAG;
> +
> +// Min Address Fixed (_MIF) Bit[2]
> +typedef enum {
> + MinNotFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED,
> + MinFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
> +} MIN_FIXED_FLAG;
> +
> +// Max Address Fixed (_MAF) Bit[3]
> +typedef enum {
> + MaxNotFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED,
> + MaxFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
> +} MAX_FIXED_FLAG;
> +
> +// Memory Attributes (_MEM) Bits[2:1]
> +typedef enum {
> + NonCacheable =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE,
> + Cacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE,
> + WriteCombining =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINI
> NG,
> + Prefetchable =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
> +} CACHEABLE_FLAG;
> +
> +// Write Status (_RW) Bit[0]
> +typedef enum {
> + ReadOnly = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY,
> + ReadWrite = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE
> +} READ_WRITE_FLAG;
> +
> +// Memory Attributes (_MTP) Bits[4:3]
> +typedef enum {
> + AddressRangeMemory =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY,
> + AddressRangeReserved =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED,
> + AddressRangeACPI =
> EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI,
> + AddressRangeNVS =
> EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS
> +} MEMORY_RANGE_TYPE;
> +
> +// Memory to IO Translation (_TTP) Bit[5]
> +// Note: IO and Memory Resources use different bits for this.
> +// Value must be handled at function level when implemented.
> +typedef enum {
> + TypeStatic = 0,
> + TypeTranslation = 1
> +} MEMORY_TRANSLATION_TYPE;
> +
> +// Memory Window Attributes (_RNG) Bits[1:0]
> +typedef enum {
> + Reserved = 0,
> + NonISAOnly =
> EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY,
> + ISAOnly =
> EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY,
> + EntireRange =
> EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE,
> + ISARangeMax
> +} IO_ISA_RANGES;
> +
> +// Generic Address Space Address IDs
> +typedef enum {
> + SystemMemory = EFI_ACPI_6_4_SYSTEM_MEMORY,
> + SystemIO = EFI_ACPI_6_4_SYSTEM_IO,
> + PCI_Config = EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE,
> + EmbeddedControl = EFI_ACPI_6_4_EMBEDDED_CONTROLLER,
> + SMBus = EFI_ACPI_6_4_SMBUS,
> + SystemCMOS = EFI_ACPI_6_4_SYSTEM_CMOS,
> + PciBarTarget = EFI_ACPI_6_4_PCI_BAR_TARGET,
> + IPMI = EFI_ACPI_6_4_IPMI,
> + GeneralPurposeIO = EFI_ACPI_6_4_GENERAL_PURPOSE_IO,
> + GenericSerialBus = EFI_ACPI_6_4_GENERIC_SERIAL_BUS,
> + PCC = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
> + PlatformCommChannel =
> EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
> + FFixedHW = EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE
> +} GENERIC_ADDRESS_SPACE_ID;
> +
> +typedef enum {
> + UndefinedSize = EFI_ACPI_6_4_UNDEFINED,
> + ByteSize = EFI_ACPI_6_4_BYTE,
> + WordSize = EFI_ACPI_6_4_WORD,
> + DWordSize = EFI_ACPI_6_4_DWORD,
> + QWordSize = EFI_ACPI_6_4_QWORD
> +} ACPI_DATA_SIZE;
> +
> +typedef ACPI_DATA_SIZE GENERIC_ADDRESS_ACCESS_SIZE;
> +
> +//
> ************************************************************
> ***************
> +// AML Objects
> +//
> ************************************************************
> ***************
> +
> +// ---------------------------------------------------------------------------
> +// Table and Table Header Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Name Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + Creates a Namestring AML Object and inserts it into the linked list
> +
> + Completes NameString in one call as "one phase"
> + LeadNameChar := 'A'-'Z' | '_'
> + DigitChar := '0'-'9'
> + NameChar := DigitChar | LeadNameChar
> + RootChar := '\'
> + ParentPrefixChar := '^'
> +
> + 'A'-'Z' := 0x41 - 0x5A
> + '_' := 0x5F
> + '0'-'9' := 0x30 - 0x39
> + '\' := 0x5C
> + '^' := 0x5E
> +
> + NameSeg := <LeadNameChar NameChar NameChar NameChar>
> + // Notice that NameSegs shorter than 4 characters are filled with
> + // trailing underscores ('_'s).
> + NameString := <RootChar NamePath> | <PrefixPath NamePath>
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Data Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + Creates an optimized integer object
> +
> + 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] Phase - Example: AmlStart, AmlClose
> + @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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + Creates a data string object
> +
> + ComputationalData := String
> +
> + String := StringPrefix AsciiCharList NullChar
> + StringPrefix := 0x0D
> + AsciiCharList := Nothing | <AsciiChar AsciiCharList>
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Package Length Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + Creates a Package Length AML Object and inserts it into the linked list
> +
> + PkgLength := PkgLeadByte |
> + <PkgLeadByte ByteData> |
> + <PkgLeadByte ByteData ByteData> |
> + <PkgLeadByte ByteData ByteData ByteData>
> +
> + PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
> + <bit 5-4: Only used if PkgLength < 63>
> + <bit 3-0: Least significant package length nybble>
> +
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Term Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +// ---------------------------------------------------------------------------
> +// Namespace Modifier Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +/**
> + Creates a Name (ObjectName, Object)
> +
> + Object must be created between AmlStart and AmlClose Phase
> +
> + DefName := NameOp NameString DataRefObject
> + NameOp := 0x08
> +
> + @param[in] Phase - Either AmlStart or AmlClose
> + @param[in] Name - Named Object name
> + @param[in,out] ListHead - Linked list has completed Name 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
> + );
> +
> +/**
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Named Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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] Name - Named Object name
> + @param[in,out] ListHead - Linked list has completed Name 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + Creates a Field
> +
> + Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
> +
> + FieldUnitList must be created 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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.
> +
> + 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 that has completed AccessAs
> Object
> + after AmlClose.
> +
> + @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
> + );
> +
> +/**
> + 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 since AML does not store
> + ArgTypes here.
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Type 1 Opcodes Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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 pkglength termlist>
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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 - Head of linked list of Objects
> +
> + @retval EFI_SUCCESS
> + @retval Error status
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlReturn (
> + IN AML_FUNCTION_PHASE Phase,
> + IN OUT LIST_ENTRY *ListHead
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Type 2 Opcodes Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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 PackageElementList>
> + PackageElement := DataRefObject | NameString
> +
> + @param[in] Phase - Either AmlStart or AmlClose
> + @param[in] NumElements - Number of elements in the package
> + @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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Resource Descriptor Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + AmlDWordSpace ()
> +
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/*
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + AmlQWordSpace ()
> +
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Expression Opcodes Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +// ---------------------------------------------------------------------------
> +// Miscellaneous Objects Encoding
> +// ---------------------------------------------------------------------------
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + Creates a Shift Left expression
> +
> + Syntax:
> + ShiftLeft (Source, ShiftCount, Reult) => 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +//
> ************************************************************
> ***************
> +// AML Assistance Functions
> +//
> ************************************************************
> ***************
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +/**
> + 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
> + );
> +
> +//
> ************************************************************
> ***************
> +// AML Debug Functions
> +//
> ************************************************************
> ***************
> +
> +/**
> + 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
> + Completed=(TRUE|FALSE)
> +
> + @param[in] Buffer - Buffer containing buffer
> + @param[in] BufferSize - Number of bytes to print
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlDebugPrintBuffer (
> + IN VOID *Buffer,
> + IN UINTN BufferSize
> + );
> +
> +/**
> + DEBUG print a 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
> + Completed=(TRUE|FALSE)
> +
> + @param[in] Object - AML_OBJECT_INSTANCE
> +
> + @retval EFI_SUCCESS
> + @retval Error status
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlDebugPrintObject (
> + IN AML_OBJECT_INSTANCE *Object
> + );
> +
> +/**
> + 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
> +
> + @retval EFI_SUCCESS
> + @retval Error status
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlDebugPrintLinkedObjects (
> + IN LIST_ENTRY *ListHead
> + );
> +
> +#endif // AML_LIB_H_
> diff --git
> a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLi
> b.h
> b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLi
> b.h
> new file mode 100644
> index 0000000000..d48ca1a90a
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLi
> b.h
> @@ -0,0 +1,25 @@
> +/** @file
> + Platform ROM Armor Whitelist table
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/AmdPspRomArmorLib.h>
> +
> +/*
> + * 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 couldn't be
> allocated
> + */
> +EFI_STATUS
> +EFIAPI
> +GetPspRomArmorWhitelist (
> + IN SPI_WHITE_LIST **PlatformSpiWhitelist
> + );
> diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
> b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
> new file mode 100644
> index 0000000000..6c854651cc
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
> @@ -0,0 +1,134 @@
> +/** @file
> + AMD Psp Ftpm Ppi Header
> +
> + Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef PSP_FTPM_PPI_H_
> +#define PSP_FTPM_PPI_H_
> +#include <Uefi.h>
> +
> +typedef struct _PSP_FTPM_PPI PSP_FTPM_PPI;
> +
> +/**
> + Define function prototype: Execute a TPM command
> +
> + @param[in] This Point to PSP_FTPM_PPI itself
> + @param[in] CommandBuffer Point to the TPM command buffer
> + @param[in] CommandSize Size of the TPM command buffer
> + @param[in,out] ResponseBuffer Point to the TPM response buffer
> + @param[in,out] ResponseSize Size of the TPM response buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status
> set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to
> hold the response
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_EXECUTE)(
> + IN PSP_FTPM_PPI *This,
> + IN VOID *CommandBuffer,
> + IN UINTN CommandSize,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINTN *ResponseSize
> + );
> +
> +/**
> + Define function prototype: GET TPM related Info
> +
> + @param[in] This Point to PSP_FTPM_PPI itself
> + @param[in,out] FtpmStatus Used to hold more detail info (Unused
> Currently)
> +
> + @return EFI_SUCCESS Ftpm function supported
> + @return EFI_UNSUPPORTED Ftpm function unsupported
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_CHECK_STATUS)(
> + IN PSP_FTPM_PPI *This,
> + IN OUT UINTN *FtpmStatus
> + );
> +
> +/**
> + Define function prototype: Send a TPM command
> +
> + @param[in] This Point to PSP_FTPM_PPI itself
> + @param[in] CommandBuffer Point to the TPM command buffer
> + @param[in] CommandSize Size of the TPM command buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold
> the response
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_SEND_COMMAND)(
> + IN PSP_FTPM_PPI *This,
> + IN VOID *CommandBuffer,
> + IN UINTN CommandSize
> + );
> +
> +/**
> + Define function prototype: Get a TPM command's response
> +
> + @param[in] This Point to PSP_FTPM_PPI itself
> + @param[in,out] ResponseBuffer Point to the TPM response buffer
> + @param[in,out] ResponseSize Size of the TPM response buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status
> set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to
> hold the response
> + **/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_GET_RESPONSE)(
> + IN PSP_FTPM_PPI *This,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINTN *ResponseSize
> + );
> +
> +/**
> + Define function prototype: Get TCG Logs.
> +
> + This function only implemented on Pluton-fTPM
> +
> + @param[in] This Point to PSP_FTPM_PPI itself
> + @param[in,out] ResponseBuffer Point to the TPM response buffer
> + @param[in,out] ResponseSize Size of the TPM response buffer
> +
> + @retval EFI_STATUS 0: Success, Non-Zero Error
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_GET_TCG_LOGS)(
> + IN PSP_FTPM_PPI *This,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINTN *ResponseSize
> + );
> +
> +/**
> + PSP_FTPM_PPI prototype
> +
> + Defines PSP_FTPM_PPI. This PPI is used to get Ftpm info.
> + Send TPM command, Get TPM command's response, Execute TPM
> command(Include send & get response)
> +**/
> +typedef struct _PSP_FTPM_PPI {
> + FTPM_EXECUTE Execute; ///< Execute TPM command,
> include send & get response
> + FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
> + FTPM_SEND_COMMAND SendCommand; ///< Send TPM
> command
> + FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM
> command response
> + FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
> +} PSP_FTPM_PPI;
> +
> +extern EFI_GUID gAmdPspFtpmPpiGuid;
> +extern EFI_GUID gAmdPspFtpmFactoryResetPpiGuid;
> +
> +#endif
> diff --git
> a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
> b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
> new file mode 100644
> index 0000000000..715cbbcf78
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
> @@ -0,0 +1,183 @@
> +/** @file
> + CXL Configuration Services Protocol prototype definition
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_
> +#define NBIO_CXL_SERVICES_PROTOCOL_H_
> +
> +#include "AMD.h"
> +#include <Protocol/FabricTopologyServices2.h>
> +#include <Protocol/FabricResourceManagerServicesProtocol.h>
> +
> +#define AMD_NBIO_CXL_SERVICES_REVISION 0x00
> +
> +/// Forward declaration for the AMD_NBIO_CXL_SERVICES_PROTOCOL
> +typedef struct _AMD_NBIO_CXL_SERVICES_PROTOCOL
> AMD_NBIO_CXL_SERVICES_PROTOCOL;
> +
> +extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL services
> protocol calling
> +
> +#pragma pack (push, 1)
> +/// Port Information Structure
> +typedef struct _AMD_CXL_PORT_INFO_STRUCT {
> + PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root Port in
> PCI_ADDR format
> + UINT8 LogicalNbioInstance; ///< Logical Instance ID of NBIO
> + UINT8 PhysicalNbioInstance; ///< Physical Instance ID of NBIO where
> this port is located
> + UINT8 SocketID; ///< Socket ID for this port
> + UINT32 UsRcrb; ///< Upstream Port RCRB address
> + UINT32 DsRcrb; ///< Downstream Port RCRB address
> + UINT32 UsMemBar0; ///< Upstream port MEMBAR0
> + UINT32 DsMemBar0; ///< Downstream port MEMBAR0
> + UINT8 PortId; ///< Physical port location
> + UINT8 PortWidth; ///< Lane width of the port
> + UINT32 CxlPortAddress; ///< CXL root port address (CXL 2.0 root
> port or CXL 1.1 RCiEP)
> + BOOLEAN IsSwitch; ///< CXL Switch flag
> +} AMD_CXL_PORT_INFO_STRUCT;
> +
> +/// Port MMIO32 Resources Information Structure
> +typedef struct _AMD_CXL_RESOURCES_INFO_STRUCT {
> + UINT32
> Mmio32Base[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
> + UINT32
> Mmio32Size[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
> + UINT32 Mmio32Gran;
> +} AMD_CXL_RESOURCES_INFO_STRUCT;
> +#pragma pack (pop)
> +
> +// Protocol Definitions
> +
> +/**
> + This function gets information about a specific PCIe root port.
> +
> + This
> + A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
> + EndpointBDF
> + Bus/Device/Function of Endpoint in PCI_ADDR format.
> + PortInformation
> + A pointer to an information structure to be populated by this function to
> + identify the location of the CXL port.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_GET_ROOT_PORT_INFORMATION)(
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr
> + IN UINTN PortIndex, ///< port index
> + OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port
> information ptr
> + );
> +
> +/**
> + This function configures a specific PCIe root port for CXL capabilities.
> +
> + This
> + A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
> + EndpointBDF
> + Bus/Device/Function of Endpoint in PCI_ADDR format.
> + PortConfiguration
> + A pointer to a configuration structure that contains the information
> necessary
> + to configurare the CXL port.
> + PortInformation OPTIONAL (can be NULL)
> + A pointer to an information structure to be populated by this function to
> + identify the location of the CXL port.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_CONFIGURE_ROOT_PORT)(
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< this ptr
> + IN PCI_ADDR EndpointBDF ///< end pt bdf
> + );
> +
> +/**
> + This function configures a specific PCIe root port for CXL presence
> +
> + This
> + A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
> + EndpointBDF
> + Bus/Device/Function of Endpoint in PCI_ADDR format.
> + PortConfiguration
> + A pointer to a configuration structure that contains the information
> necessary
> + to configurare the CXL port such as Socket id,rbindex,port id,segment,bus
> base,limit or presence.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_RESOURCES_AVAILABLE)(
> + ///< cxl port presence info
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
> + IN OUT FABRIC_RESOURCE_FOR_EACH_RB *ResourceForEachRb ///<
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_GET_PORT_RB_LOCATION)(
> + ///< get port rb location
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
> + IN UINT8 Segment, ///<
> + IN UINT8 BusBase, ///<
> + OUT UINT8 *SocketId, ///<
> + OUT UINT8 *RbIndex ///<
> + );
> +
> +/**
> + This function gets the CXL MMIO32 values to be used by the fabric
> resource manager
> +
> + This
> + A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
> + CxlMmio32ResourceForEachRb
> + A pointer to the structure that will hold the MMIO32 base and size values
> for each root bridge
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_RESOURCES_INFORMATION)(
> + ///< cxl port presence info
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
> + IN OUT AMD_CXL_RESOURCES_INFO_STRUCT *CxlMmio32Resources ///<
> + );
> +
> +/**
> + * @brief
> + *
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_REPORT_TO_MPIO)(
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This ///< ptr to
> protocol
> + );
> +
> +/**
> + * @brief
> + *
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_CXL_FIND_2P0_DEVICES)(
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to
> protocol
> + IN UINTN PortIndex ///< port index
> + );
> +
> +/**
> + * @brief
> + *
> + */
> +typedef
> +VOID
> +(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)(
> + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to
> protocol
> + IN PCI_ADDR CxlPciAddress ///< PCI address
> + );
> +
> +/// The Protocol Definition for CXL Services
> +struct _AMD_NBIO_CXL_SERVICES_PROTOCOL {
> + UINT32 Revision; ///< revision
> + UINTN CxlCount; ///< CXL count
> + AMD_CXL_GET_ROOT_PORT_INFORMATION CxlGetRootPortInformation;
> ///< CXL root port information
> + AMD_CXL_CONFIGURE_ROOT_PORT CxlConfigureRootPort; ///<
> configuring the root port
> + AMD_CXL_GET_PORT_RB_LOCATION GetCxlPortRBLocation; ///<
> CXL port RB location
> + AMD_CXL_RESOURCES_AVAILABLE GetCxlAvailableResources;
> ///< Get resources allocated for CXL RCiEP
> + AMD_CXL_RESOURCES_INFORMATION GetCxlMmio32Resources;
> ///< Get CXL MMIO resources for CXL RCiEP
> + AMD_CXL_REPORT_TO_MPIO CxlReportToMpio; ///<
> Sends the CXL info to MPIO
> + AMD_CXL_FIND_2P0_DEVICES CxlFind2p0Devices; ///< Finds
> CXL 2.0 devices after PCIe enumeration
> + AMD_CXL_ENABLE_SCM_PMEM
> CxlEnableScmForPersistentMemory; ///< Notifies SMU that CXL persistent
> memory is present
> +};
> +
> +#endif /* NBIO_CXL_SERVICES_PROTOCOL_H */
> diff --git
> a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
> b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
> new file mode 100644
> index 0000000000..7bcff65dc9
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
> @@ -0,0 +1,110 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_PCI_RESOURCES_PROTOCOL_H_
> +#define AMD_PCI_RESOURCES_PROTOCOL_H_
> +
> +typedef struct {
> + UINTN Index;
> + UINT8 SocketId;
> + UINTN Segment;
> + UINTN BaseBusNumber;
> +} PCI_ROOT_BRIDGE_OBJECT;
> +
> +typedef struct {
> + UINTN Index;
> + BOOLEAN Enabled;
> + UINT8 PortPresent;
> + UINTN Device;
> + UINTN Function;
> + UINTN SlotNum;
> + // Interrupts are relative to IOAPIC 0->n
> + UINTN BridgeInterrupt; // Redirection table entry for mapped
> bridge interrupt
> + UINTN EndpointInterruptArray[4]; // Redirection table entries for
> mapped INT A/B/C/D
> +} PCI_ROOT_PORT_OBJECT;
> +
> +typedef enum {
> + IOMMU = 0,
> + IOAPIC
> +} FIXED_RESOURCE_TYPE;
> +
> +typedef struct {
> + UINTN Index;
> + FIXED_RESOURCE_TYPE ResourceType;
> + UINTN Address;
> + UINTN Limit;
> +} FIXED_RESOURCES_OBJECT;
> +
> +/// Forward declaration for the AMD_PCI_RESOURCES_PROTOCOL.
> +typedef struct _AMD_PCI_RESOURCES_PROTOCOL
> AMD_PCI_RESOURCES_PROTOCOL;
> +
> +/**
> + * @brief System information through EFI call
> + * @details
> + */
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + OUT UINTN *NumberOfRootBridges
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + IN UINTN RootBridgeIndex,
> + OUT PCI_ROOT_BRIDGE_OBJECT **RootBridgeInfo
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + IN UINTN RootBridgeIndex,
> + OUT UINTN *NumberOfRootPorts
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + IN UINTN RootBridgeIndex,
> + IN UINTN RootPortIndex,
> + OUT PCI_ROOT_PORT_OBJECT **RootPortInfo
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + IN UINTN RootBridgeIndex,
> + OUT UINTN *NumberOfFixedResources
> + );
> +
> +typedef
> +EFI_STATUS
> +(EFIAPI *AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO)(
> + IN AMD_PCI_RESOURCES_PROTOCOL *This,
> + IN UINTN RootBridgeIndex,
> + IN UINTN FixedResourceIndex,
> + OUT FIXED_RESOURCES_OBJECT **FixedResourceInfo
> + );
> +
> +struct _AMD_PCI_RESOURCES_PROTOCOL {
> + AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES
> AmdPciResourcesGetNumberOfRootBridges;
> + AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO
> AmdPciResourcesGetRootBridgeInfo;
> + AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS
> AmdPciResourcesGetNumberOfRootPorts;
> + AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO
> AmdPciResourcesGetRootPortInfo;
> + AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES
> AmdPciResourcesGetNumberOfFixedResources;
> + AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO
> AmdPciResourcesGetFixedResourceInfo;
> +};
> +
> +extern EFI_GUID gAmdPciResourceProtocolGuid; ///< Guid for calling
> +
> +#endif // AMD_PCI_RESOURCES_PROTOCOL_H_
> diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
> b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
> new file mode 100644
> index 0000000000..ebc7812b18
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
> @@ -0,0 +1,187 @@
> +/** @file
> + AMD Psp Ftpm Protocol Header
> +
> + Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef FTPM_PROTOCOL_H_
> +#define FTPM_PROTOCOL_H_
> +
> +#include <Uefi.h>
> +//
> +// GUID definition
> +//
> +extern EFI_GUID gAmdPspFtpmProtocolGuid;
> +
> +/**
> + structure definition for HSP mailbox
> +
> +**/
> +typedef struct {
> + // C2H_TPM_L0
> + UINT64 TPM_L0_Address; /// Mailbox address
> + UINT64 TPM_L0_C2H_MSG_Address; /// Doorbell address CPU-
> >HSP
> + UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address HSP-
> >CPU
> +
> + // C2H_HSP_L0(VLT0)
> + UINT64 VLT0_Address; /// Mailbox address
> + UINT64 VLT0_C2H_MSG_Address; /// Doorbell address CPU-
> >HSP
> + UINT64 VLT0_H2C_MSG_Address; /// Doorbell address HSP-
> >CPU
> +
> + // C2H_HSP_L1(VLT1)
> + UINT64 VLT1_Address; /// Mailbox address
> + UINT64 VLT1_C2H_MSG_Address; /// Doorbell address CPU-
> >HSP
> + UINT64 VLT1_HSC_MSG_Address; /// Doorbell address HSP-
> >CPU
> +
> + // Interrupt Information
> + UINT8 Gsi[4]; /// Gsi[0] is for HSP Channel 0 TPM
> + /// Gsi[1] is for HSP Channel 1 VTL0
> + /// Gsi[2] is for HSP Channel 2 VTL1
> + /// Gsi[3] is reserved
> +} HSP_MAILBOX_ADDRESS, *PHSP_MAILBOX_ADDRESS;
> +
> +typedef union {
> + HSP_MAILBOX_ADDRESS HSP_info;
> +} FTPM_INFO;
> +
> +typedef struct _PSP_FTPM_PROTOCOL PSP_FTPM_PROTOCOL;
> +
> +/**
> + Define function prototype: Execute a TPM command
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in] CommandBuffer Point to the TPM command buffer
> + @param[in] CommandSize Size of the TPM command buffer
> + @param[in, out] ResponseBuffer Point to the TPM response buffer
> + @param[in, out] ResponseSize Size of the TPM response buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold
> the response
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_EXECUTE)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN VOID *CommandBuffer,
> + IN UINT32 CommandSize,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINT32 *ResponseSize
> + );
> +
> +/**
> + Define function prototype: GET TPM related Information
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in,out] FtpmStatus Used to hold more detail info (Unused
> Currently)
> +
> + @return EFI_SUCCESS Ftpm function supported
> + @return EFI_UNSUPPORTED Ftpm function unsupported
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_CHECK_STATUS)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN OUT UINTN *FtpmStatus
> + );
> +
> +/**
> + Define function prototype: Send a TPM command
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in] CommandBuffer Point to the TPM command buffer
> + @param[in] CommandSize Size of the TPM command buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold
> the response
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_SEND_COMMAND)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN VOID *CommandBuffer,
> + IN UINT32 CommandSize
> + );
> +
> +/**
> + Define function prototype: Get a TPM command's response
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in, out] ResponseBuffer Point to the TPM response buffer
> + @param[in, out] ResponseSize Size of the TPM response buffer
> +
> + @return EFI_SUCCESS Command executed successfully
> + @return EFI_UNSUPPORTED Device unsupported
> + @return EFI_TIMEOUT Command fail due the time out
> + @return EFI_DEVICE_ERROR Command fail due the error status set
> + @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold
> the response
> +
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_GET_RESPONSE)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINT32 *ResponseSize
> + );
> +
> +/**
> + Define function prototype: Get TCG Logs
> + This function only implemented on Pluton-fTPM
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in, out] ResponseBuffer Point to the TPM response buffer
> + @param[in, out] ResponseSize Size of the TPM response buffer
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_GET_TCG_LOGS)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN OUT VOID *ResponseBuffer,
> + IN OUT UINTN *ResponseSize
> + );
> +
> +/**
> + Function prototype for GetHspfTPMInfo. Return Pluton mailbox base
> address to SBIOS.
> + SBIOS should call this procedure after PCI Enumeration Complete.
> +
> + @param[in] This Point to PSP_FTPM_PROTOCOL itself
> + @param[in,out] FtpmInfo Point to Pluton mailbox base address
> +
> + @return EFI_SUCCESS - Success
> + @return EFI_INVALID_PARAMETER - Input parameter is invalid
> + @return EFI_NOT_READY - Pluton-fTPM device BAR0 MMIO is not
> ready.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *FTPM_GET_TPM_INFO)(
> + IN PSP_FTPM_PROTOCOL *This,
> + IN OUT VOID *FtpmInfo
> + );
> +
> +/**
> + PSP_FTPM_PROTOCOL prototype
> +
> + Defines PSP_FTPM_PROTOCOL. This protocol is used to get Ftpm info
> + Send TPM command, Get TPM command's response, Execute TPM
> command(Include send & get response)
> +**/
> +typedef struct _PSP_FTPM_PROTOCOL {
> + FTPM_EXECUTE Execute; ///< Execute TPM command,
> include send & get response
> + FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
> + FTPM_SEND_COMMAND SendCommand; ///< Send TPM
> command
> + FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command
> response
> + FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
> + FTPM_GET_TPM_INFO GetInfo; ///< Get TPM info
> +} PSP_FTPM_PROTOCOL;
> +
> +#endif //FTPM_PROTOCOL_H_
> diff --git
> a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerService
> sProtocol.h
> b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerService
> sProtocol.h
> new file mode 100644
> index 0000000000..7f57facf88
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerService
> sProtocol.h
> @@ -0,0 +1,14 @@
> +/** @file
> + Fabric MMIO map manager Protocol prototype definition
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
> +#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
> +#include <FabricResourceManagerCmn.h>
> +
> +#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
> diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
> b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
> new file mode 100644
> index 0000000000..a7fef5a35c
> --- /dev/null
> +++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
> @@ -0,0 +1,19 @@
> +/** @file
> + AMD CPM Base Definitions.
> +
> + Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_CPM_BASE_H_
> +#define AMD_CPM_BASE_H_
> +
> +#include <Base.h>
> +#include <Uefi.h>
> +#include <PiPei.h>
> +#include <AmdCpmCommon.h>
> +#include <Library/DebugLib.h>
> +
> +#endif // AMD_CPM_BASE_H_
> diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
> b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
> new file mode 100644
> index 0000000000..af192fcf03
> --- /dev/null
> +++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
> @@ -0,0 +1,78 @@
> +/** @file
> + AMD CPM Common Definitions.
> +
> + Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_CPM_COMMON_H_
> +#define AMD_CPM_COMMON_H_
> +
> +#pragma pack(push)
> +
> +#include <AGESA.h>
> +#include <AmdPcieComplex.h>
> +#include <AmdCpmDefine.h>
> +#include <AmdCpmFunction.h>
> +
> +/// The signatures of CPM table
> +
> +typedef enum {
> + CPM_SIGNATURE_DXIO_TOPOLOGY = SIGNATURE_32 ('$', 'A', '2',
> '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE
> + CPM_SIGNATURE_DXIO_TOPOLOGY_S1 = SIGNATURE_32 ('$', 'A', '2',
> '7') ///< The signature of Socket 1 AMD_CPM_DXIO_TOPOLOGY_TABLE
> +} AMD_CPM_TABLE_SIGNATURE;
> +
> +/// CPM table header
> +typedef struct {
> + UINT32 TableSignature; ///< Signature of CPM table
> + UINT16 TableSize; ///< Table size
> + UINT8 FormatRevision; ///< Revision of table format
> + UINT8 ContentRevision; ///< Revision of table content
> + UINT32 PlatformMask; ///< The mask of platform table
> supports
> + UINT32 Attribute; ///< Table attribute
> +} AMD_CPM_TABLE_COMMON_HEADER;
> +
> +/// Table pointer
> +typedef union {
> + VOID *Pointer; ///< Table pointer
> + UINT64 Raw; ///< Table pointer value
> +} AMD_CPM_POINTER;
> +
> +/// DXIO Topology Table
> +typedef struct {
> + AMD_CPM_TABLE_COMMON_HEADER Header; ///<
> Table header
> + UINT32 SocketId; ///< Socket Id
> + DXIO_PORT_DESCRIPTOR Port[AMD_DXIO_PORT_DESCRIPTOR_SIZE];
> ///< DXIO Port Descriptor List
> +} AMD_CPM_DXIO_TOPOLOGY_TABLE;
> +
> +/// AMD CPM Main Table
> +typedef struct {
> + AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table
> header
> + UINT8 PlatformName[32]; ///< Platform name
> + UINT8 BiosType; ///< BIOS type
> + UINT16 CurrentPlatformId; ///< Current Platform Id
> + UINT32 PcieMemIoBaseAddr; ///<
> PcieMemIoBaseAddr
> + UINT32 AcpiMemIoBaseAddr; ///<
> AcpiMemIoBaseAddr
> + AMD_CPM_POINTER Service; ///< Reserved for
> internal use
> + AMD_CPM_POINTER TableInRomList; ///< Reserved for
> internal use
> + AMD_CPM_POINTER TableInRamList; ///< Reserved for
> internal use
> + AMD_CPM_POINTER TableInHobList; ///< Reserved for
> internal use
> + AMD_CPM_POINTER HobTablePtr; ///< Reserved for
> internal use
> +
> + UINT8 ExtClkGen; ///< External ClkGen Config.
> 0x00~0x7F
> + UINT8 UnusedGppClkOffEn; ///< Config to turn off
> unused GPP clock
> + UINT8 LpcUartEn; ///< LpcUartEn
> + UINT64 AltAcpiMemIoBaseAddr; ///< Alternate
> AcpiMemIoBaseAddr for Slave FCH
> +} AMD_CPM_MAIN_TABLE;
> +
> +/// Structure for Chip Id
> +typedef struct {
> + UINT8 Cpu; ///< CPU/APU Chip Id
> + UINT8 Sb; ///< SB Chip Id
> + UINT8 Reserved[6];
> +} AMD_CPM_CHIP_ID;
> +#pragma pack (pop)
> +
> +#endif //AMD_CPM_COMMON_H_
> diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
> b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
> new file mode 100644
> index 0000000000..4fc3f97a80
> --- /dev/null
> +++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
> @@ -0,0 +1,17 @@
> +/** @file
> + AMD CPM Common Definitions.
> +
> + Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_CPM_DEFINE_H_
> +#define AMD_CPM_DEFINE_H_
> +
> +#ifndef AMD_DXIO_PORT_DESCRIPTOR_SIZE
> +#define AMD_DXIO_PORT_DESCRIPTOR_SIZE 0x30
> +#endif
> +
> +#endif // AMD_CPM_DEFINE_H_
> diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
> b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
> new file mode 100644
> index 0000000000..7dce238135
> --- /dev/null
> +++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
> @@ -0,0 +1,32 @@
> +/** @file
> + AMD CPM Common Functions.
> +
> + Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_CPM_FUNCTION_H_
> +#define AMD_CPM_FUNCTION_H_
> +
> +typedef VOID *(EFIAPI *AMD_CPM_GETTABLEPTR_FN)(
> + IN VOID *This,
> + IN UINT32 TableId
> + );
> +
> +typedef AGESA_STATUS (EFIAPI *AMD_CPM_GETPOSTEDVBIOSIMAGE_FN)(
> + IN GFX_VBIOS_IMAGE_INFO *VbiosImageInfo
> + );
> +
> +/// Common Functions for CPM Drivers
> +typedef struct _AMD_CPM_COMMON_FUNCTION {
> + AMD_CPM_GETTABLEPTR_FN GetTablePtr2; ///< Get CPM Table
> Pointer. The table can be re-writable
> +} AMD_CPM_COMMON_FUNCTION;
> +
> +/// CPM Public Functions for platform DXE Driver to use
> +typedef struct _AMD_CPM_DXE_PUBLIC_FUNCTION {
> + AMD_CPM_GETPOSTEDVBIOSIMAGE_FN GetPostedVbiosImage; ///<
> Get posted VBIOS image
> +} AMD_CPM_DXE_PUBLIC_FUNCTION;
> +
> +#endif //AMD_CPM_FUNCTION_H_
> diff --git
> a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/Amd
> CpmTableProtocol.h
> b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/Amd
> CpmTableProtocol.h
> new file mode 100644
> index 0000000000..4a90aa3d8b
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/Amd
> CpmTableProtocol.h
> @@ -0,0 +1,39 @@
> +/** @file
> + AMD CPM Table Protocol.
> +
> + Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef AMD_CPM_TABLE_PROTOCOL_H_
> +#define AMD_CPM_TABLE_PROTOCOL_H_
> +
> +#include <AmdCpmBase.h>
> +
> +//
> +// GUID definition
> +//
> +#define AMD_CPM_TABLE_PROTOCOL_GUID \
> + { 0x3724cf01, 0x00c2, 0x9762, 0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72,
> 0x00 }
> +
> +#define AMD_CPM_TABLE_SMM_PROTOCOL_GUID \
> + { 0xaf6efacf, 0x7a13, 0x45a3, 0xb1, 0xa5, 0xaa, 0xfc, 0x06, 0x1c, 0x4b,
> 0x79 }
> +
> +extern EFI_GUID gAmdCpmTableProtocolGuid;
> +extern EFI_GUID gAmdCpmTableSmmProtocolGuid;
> +
> +/// DXE Protocol Structure
> +typedef struct _AMD_CPM_TABLE_PROTOCOL {
> + UINTN Revision; ///< Protocol Revision
> + AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Pointer to
> CPM Main Table
> + AMD_CPM_CHIP_ID ChipId; ///< Id of SB Chip
> + AMD_CPM_COMMON_FUNCTION CommonFunction; ///<
> Private Common Functions
> + AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///<
> Public Function of Protocol
> +} AMD_CPM_TABLE_PROTOCOL;
> +
> +// Current Protocol Revision
> +#define AMD_CPM_TABLE_PROTOCOL_REV 0x00
> +
> +#endif // AMD_CPM_TABLE_PROTOCOL_H_
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.c
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.c
> new file mode 100644
> index 0000000000..fa83888e95
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMbox
> LibV2.c
> @@ -0,0 +1,31 @@
> +/** @file
> + PSP Mailbox related functions
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +
> +/**
> + * @brief Bios send these commands to PSP to grant dTPM status and event
> log
> + *
> + * @param[out] DesiredConfig dTPM configuration requested
> + * @param[out] ConfigStatus 0 - success. non-zero failure.
> + * @param[in,out] LogDataSize Size of LogData buffer
> + * @param[out] LogData Point to allocated event log buffer
> + *
> + * @retval EFI_STATUS 0: Success, NonZero Error
> + */
> +EFI_STATUS
> +PspMboxGetDTPMData (
> + OUT UINT32 *DesiredConfig,
> + OUT UINT32 *ConfigStatus,
> + IN OUT UINT32 *LogDataSize,
> + OUT VOID *LogData
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRo
> mArmorLib.c
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRo
> mArmorLib.c
> new file mode 100644
> index 0000000000..0e9baad955
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRo
> mArmorLib.c
> @@ -0,0 +1,12 @@
> +/** @file
> +
> + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/SmmServicesTableLib.h>
> +#include <Protocol/SmmBase2.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.c
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.c
> new file mode 100644
> index 0000000000..a04bc1f992
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPs
> pRomArmorLibNull.c
> @@ -0,0 +1,79 @@
> +/** @file
> +
> + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/AmdPspRomArmorLib.h>
> +
> +/**
> + * Request secures the SPI Controller
> + *
> + * @param[in, out] SpiCommunicationBuffer SPI Communication Structure
> Buffer pointer
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspEnterSmmOnlyMode (
> + IN SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/**
> + * Loads the whitelist into the PSP.
> + *
> + * @param[in] SpiWhitelist SPI White List structure buffer pointer.
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspEnforceWhitelist (
> + IN SPI_WHITE_LIST *SpiWhitelist
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/**
> + * Request execute SPI command provide in TSEG comm buffer.
> + *
> + * @param[in] NONE
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspExecuteSpiCommand (
> + VOID
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/**
> + * Request PSP firmware switch SPI controller chip select.
> + *
> + *
> + * @param[in] Chipset SPI controller chip select, 0= Allowed on
> all chip selects, 1= CS1, 2= CS2, all else invalid
> + *
> + * @retval EFI_SUCCESS Initial success
> + * @retval Others Error happens during initialize
> + */
> +EFI_STATUS
> +EFIAPI
> +PspSwitchChipSelect (
> + IN UINT8 ChipSelect
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
> new file mode 100644
> index 0000000000..fce82d75b0
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
> @@ -0,0 +1,12 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Library/PcdLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Protocol/SmmBase2.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
> new file mode 100644
> index 0000000000..f8b9eb0bcf
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
> @@ -0,0 +1,14 @@
> +/** @file
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <PiPei.h>
> +#include <Base.h>
> +#include <Library/PcdLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/PeiServicesLib.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.c
> b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.c
> new file mode 100644
> index 0000000000..cff678d76b
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFab
> ricTopologyRsLib.c
> @@ -0,0 +1,37 @@
> +** @file
> + Fabric Topology Base Lib implementation
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +
> +UINTN
> +FabricTopologyGetNumberOfProcessorsPresent (
> + VOID
> + )
> +{
> + return 0;
> +}
> +
> +UINTN
> +FabricTopologyGetNumberOfRootBridgesOnSocket (
> + IN UINTN Socket
> + )
> +{
> + return 0;
> +}
> +
> +RETURN_STATUS
> +EFIAPI
> +BaseFabricTopologyLibConstructor (
> + VOID
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.
> c
> new file mode 100644
> index 0000000000..f72cbe7dff
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.
> c
> @@ -0,0 +1,8 @@
> +/** @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.<BR>
> +
> + 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
> new file mode 100644
> index 0000000000..a155978a5d
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
> @@ -0,0 +1,35 @@
> +/** @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.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DebugLib.h>
> +
> +/** The constructor function determines the actual TSC frequency.
> +
> + First, Get TSC frequency from system configuration table with TSC
> frequency GUID,
> + if the table is not found, install it.
> + This function will always return EFI_SUCCESS.
> +
> + @param ImageHandle The firmware allocated handle for the EFI image.
> + @param SystemTable A pointer to the EFI System Table.
> +
> + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +DxeTscTimerLibConstructor (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
> new file mode 100644
> index 0000000000..f70aa3de0e
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
> @@ -0,0 +1,11 @@
> +/** @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.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiPei.h>
> +#include <Library/HobLib.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.
> c
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare
> .c
> new file mode 100644
> index 0000000000..7d14d62e60
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare
> .c
> @@ -0,0 +1,103 @@
> +/** @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.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +/** Stalls the CPU for at least the specified number of MicroSeconds.
> +
> + @param[in] MicroSeconds The minimum number of microseconds to
> delay.
> +
> + @return The value of MicroSeconds input.
> +
> +**/
> +UINTN
> +EFIAPI
> +MicroSecondDelay (
> + IN UINTN MicroSeconds
> + )
> +{
> + return 0;
> +}
> +
> +/** Stalls the CPU for at least the specified number of NanoSeconds.
> +
> + @param[in] NanoSeconds The minimum number of nanoseconds to delay.
> +
> + @return The value of NanoSeconds input.
> +
> +**/
> +UINTN
> +EFIAPI
> +NanoSecondDelay (
> + IN UINTN NanoSeconds
> + )
> +{
> + return 0;
> +}
> +
> +/** Retrieves the current value of the 64-bit free running Time-Stamp
> counter.
> +
> + The properties of the counter can be retrieved by the
> + GetPerformanceCounterProperties() function.
> +
> + @return The current value of the free running performance counter.
> +
> +**/
> +UINT64
> +EFIAPI
> +GetPerformanceCounter (
> + VOID
> + )
> +{
> + return 0;
> +}
> +
> +/** Retrieves the 64-bit frequency in Hz and the range of performance
> counter
> + values.
> +
> + If StartValue is not NULL, then the value that the performance counter
> starts
> + with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
> + that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
> + EndValue.
> +
> + The 64-bit frequency of the performance counter, in Hz, is always returned.
> +
> + @param[out] StartValue Pointer to where the performance counter's
> starting value is saved, or NULL.
> + @param[out] EndValue Pointer to where the performance counter's
> ending value is saved, or NULL.
> +
> + @return The frequency in Hz.
> +
> +**/
> +UINT64
> +EFIAPI
> +GetPerformanceCounterProperties (
> + OUT UINT64 *StartValue, OPTIONAL
> + OUT UINT64 *EndValue OPTIONAL
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Converts elapsed ticks of performance counter to time in nanoseconds.
> +
> + This function converts the elapsed ticks of running performance counter to
> + time value in unit of nanoseconds.
> +
> + @param Ticks The number of elapsed ticks of running performance
> counter.
> +
> + @return The elapsed time in nanoseconds.
> +
> +**/
> +UINT64
> +EFIAPI
> +GetTimeInNanoSecond (
> + IN UINT64 Ticks
> + )
> +{
> + return 0;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.c
> new file mode 100644
> index 0000000000..44e23df62f
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHost
> BridgeLib.c
> @@ -0,0 +1,95 @@
> +/** @file
> + AMD instance of the PCI Host Bridge Library.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/PciHostBridgeLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/DevicePathLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Protocol/PciRootBridgeIo.h>
> +#include <Protocol/PciHostBridgeResourceAllocation.h>
> +
> +/**
> + Sort all root bridges in bus ascending order and set DevicePath UIDs
> + continuous and ascending from zero
> +
> + @param[in,out] RootBridgeList Array of root bridges.
> + @param[in] Count Count of root bridges in RootBridgeList
> +
> + @return All the root bridge instances in an array are sorted in bus order.
> + DevicePath UID updated to continuous and ascending numbers starting
> + with 0.
> +**/
> +VOID
> +EFIAPI
> +PciHostBridgeSortRootBridges (
> + IN PCI_ROOT_BRIDGE *RootBridgeList,
> + IN UINTN Count
> + )
> +{
> +}
> +
> +/**
> + Return all the root bridge instances in an array.
> +
> + @param Count Return the count of root bridge instances.
> +
> + @return All the root bridge instances in an array.
> + The array should be passed into PciHostBridgeFreeRootBridges()
> + when it's not used.
> +**/
> +PCI_ROOT_BRIDGE *
> +EFIAPI
> +PciHostBridgeGetRootBridges (
> + UINTN *Count
> + )
> +{
> + return (PCI_ROOT_BRIDGE *)NULL;
> +}
> +
> +/**
> + Free the root bridge instances array returned from
> PciHostBridgeGetRootBridges().
> +
> + @param Bridges The root bridge instances array.
> + @param Count The count of the array.
> +**/
> +VOID
> +EFIAPI
> +PciHostBridgeFreeRootBridges (
> + PCI_ROOT_BRIDGE *Bridges,
> + UINTN Count
> + )
> +{
> +}
> +
> +/**
> + Inform the platform that the resource conflict happens.
> +
> + @param HostBridgeHandle Handle of the Host Bridge.
> + @param Configuration Pointer to PCI I/O and PCI memory resource
> + descriptors. The Configuration contains the resources
> + for all the root bridges. The resource for each root
> + bridge is terminated with END descriptor and an
> + additional END is appended indicating the end of the
> + entire resources. The resource descriptor field
> + values follow the description in
> + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
> + .SubmitResources().
> +**/
> +VOID
> +EFIAPI
> +PciHostBridgeResourceConflict (
> + EFI_HANDLE HostBridgeHandle,
> + VOID *Configuration
> + )
> +{
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObj
> ects.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObj
> ects.c
> new file mode 100644
> index 0000000000..318f8e5ad7
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObj
> ects.c
> @@ -0,0 +1,154 @@
> +/** @file
> +
> + Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE
> +
> +/*
> + 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",
> + __func__
> + ));
> + 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",
> + __func__,
> + "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",
> + __func__,
> + ArgN
> + ));
> + goto Done;
> + }
> +
> + Object->Completed = TRUE;
> +
> + Status = EFI_SUCCESS;
> +
> +Done:
> + if (EFI_ERROR (Status)) {
> + InternalFreeAmlObject (&Object, ListHead);
> + }
> +
> + return Status;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistF
> unctions.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistF
> unctions.c
> new file mode 100644
> index 0000000000..371537c9aa
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistF
> unctions.c
> @@ -0,0 +1,151 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLASSISTFUNCTIONS_FILECODE
> +
> +/**
> + 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",
> __func__));
> + 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", __func__));
> + 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", __func__));
> + 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", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *ListHead = AllocatePool (sizeof (LIST_ENTRY));
> + if (*ListHead == NULL) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n",
> __func__));
> + 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",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + AmlFreeObjectList (*ListHead);
> + FreePool (*ListHead);
> + *ListHead = NULL;
> +
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataOb
> jects.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataOb
> jects.c
> new file mode 100644
> index 0000000000..b7d4f4c9d7
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataOb
> jects.c
> @@ -0,0 +1,640 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE
> +
> +/*
> + 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", __func__, 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__,
> "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",
> __func__, 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", __func__,
> "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",
> __func__, 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 AsciiCharList>
> + 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",
> + __func__,
> + Index,
> + String
> + ));
> + return Status;
> + }
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__,
> 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",
> + __func__,
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (AsciiStrLen (String) != 0x7) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String'
> parameter.\n", __func__));
> + 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",
> __func__));
> + 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", __func__));
> + return Status;
> + }
> +
> + return Status;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpress
> ionOpcodes.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpres
> sionOpcodes.c
> new file mode 100644
> index 0000000000..e8ea9d8e84
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpres
> sionOpcodes.c
> @@ -0,0 +1,1294 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECODE
> +
> +// ----------------------------------------------------------------------------
> +// 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",
> __func__, 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",
> __func__));
> + goto Done;
> + }
> +
> + // Start required PkgLength
> + Status = AmlPkgLength (AmlStart, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n",
> __func__));
> + goto Done;
> + }
> +
> + // Start BufferSize
> + Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> + __func__,
> + InternalBufferSize
> + ));
> + goto Done;
> + }
> +
> + Status = InternalAmlDataIntegerBuffer (
> + InternalBufferSize,
> + (VOID **)&Object->Data,
> + &Object->DataSize
> + );
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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 PackageElementList>
> + 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",
> __func__));
> + 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", __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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 PackageElementList>
> + 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",
> __func__));
> + goto Done;
> + }
> +
> + // Start required PkgLength
> + Status = AmlPkgLength (AmlStart, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalO
> bjects.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalO
> bjects.c
> new file mode 100644
> index 0000000000..21deb200e3
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalO
> bjects.c
> @@ -0,0 +1,158 @@
> +/** @file
> +
> + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLLOCALOBJECTS_FILECODE
> +
> +/**
> + 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",
> + __func__
> + ));
> + 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",
> + __func__,
> + "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",
> + __func__,
> + LocalN
> + ));
> + goto Done;
> + }
> +
> + Object->Completed = TRUE;
> +
> + Status = EFI_SUCCESS;
> +
> +Done:
> + if (EFI_ERROR (Status)) {
> + InternalFreeAmlObject (&Object, ListHead);
> + }
> +
> + return Status;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameSt
> ring.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameS
> tring.c
> new file mode 100644
> index 0000000000..0502547a01
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameS
> tring.c
> @@ -0,0 +1,576 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESTRING_FILECODE
> +
> +#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 := <leadnamechar namechar namechar namechar>
> +
> + 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 := <LeadNameChar NameChar NameChar NameChar>
> + // Notice that NameSegs shorter than 4 characters are filled with
> + // trailing underscores ('_'s).
> + NameString := <RootChar NamePath> | <PrefixPath NamePath>
> + 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",
> __func__, 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",
> + __func__,
> + 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", __func__, StringIndex, String));
> + goto Done;
> + }
> +
> + if (FoundRootChar) {
> + Status = EFI_INVALID_PARAMETER;
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more
> than 1 RootChar.\n", __func__, String));
> + goto Done;
> + }
> +
> + if (FoundParentPrefixChar) {
> + Status = EFI_INVALID_PARAMETER;
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar
> and ParentPrefixChar.\n", __func__, 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", __func__, StringIndex, String));
> + goto Done;
> + }
> +
> + if (FoundRootChar) {
> + Status = EFI_INVALID_PARAMETER;
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar
> and ParentPrefixChar.\n", __func__, 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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",
> + __func__,
> + 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamed
> Object.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamed
> Object.c
> new file mode 100644
> index 0000000000..37ae9319be
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamed
> Object.c
> @@ -0,0 +1,2138 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLNAMEDOBJECT_FILECODE
> +
> +#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",
> __func__, 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",
> __func__, 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", __func__, 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",
> __func__, String));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__));
> + 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", __func__));
> + 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", __func__));
> + 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", __func__));
> + 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", __func__,
> Name));
> + goto Done;
> + }
> +
> + // Insert required NameString
> + Status = AmlOPNameString (Name, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n",
> __func__, Name));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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", __func__,
> 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",
> __func__, 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",
> __func__));
> + goto Done;
> + }
> +
> + InternalOffsetData = *(UINT64 *)OffsetObject->Data;
> +
> + if (InternalOffsetData > BitCount) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n",
> __func__));
> + 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",
> __func__));
> + goto Done;
> + }
> +
> + Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength,
> &DataLength);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__, 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", __func__, 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", __func__, 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",
> __func__, 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",
> __func__));
> + 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", __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, Name));
> + goto Done;
> + }
> +
> + Status = InternalFreeAmlObject (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n",
> __func__, 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", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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", __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, BankName));
> + goto Done;
> + }
> +
> + Status = InternalFreeAmlObject (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n",
> __func__, 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", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, IndexName));
> + goto Done;
> + }
> +
> + Status = InternalFreeAmlObject (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n",
> __func__, 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", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, RegionName));
> + goto Done;
> + }
> +
> + Status = AmlOPNameString (RegionName, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n",
> __func__, 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", __func__, RegionName));
> + goto Done;
> + }
> +
> + Status = AmlOPDataInteger (Offset, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n",
> __func__, RegionName));
> + goto Done;
> + }
> +
> + Status = AmlOPDataInteger (Length, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n",
> __func__, RegionName));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, FieldName));
> + goto Done;
> + }
> +
> + Status = AmlOPNameString (SourceBuffer, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n",
> __func__, FieldName));
> + goto Done;
> + }
> +
> + Status = AmlOPDataInteger (BitIndex, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__,
> FieldName));
> + goto Done;
> + }
> +
> + Status = AmlOPDataInteger (NumBits, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__,
> FieldName));
> + goto Done;
> + }
> +
> + Status = AmlOPNameString (FieldName, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n",
> __func__, FieldName));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__,
> 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", __func__,
> FixedFieldName));
> + goto Done;
> + }
> + }
> + } else {
> + Status = AmlOPNameString (SourceBuffer, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n",
> __func__, FixedFieldName));
> + goto Done;
> + }
> + }
> +
> + Status = AmlOPDataInteger (Index, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__,
> FixedFieldName));
> + goto Done;
> + }
> +
> + Status = AmlOPNameString (FixedFieldName, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n",
> __func__, FixedFieldName));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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",
> __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, 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",
> __func__, 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", __func__, 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", __func__, 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", __func__, 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",
> __func__, 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",
> __func__, Name));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "Method",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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",
> __func__, 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",
> __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNames
> paceModifierObjects.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNames
> paceModifierObjects.c
> new file mode 100644
> index 0000000000..afe51cdcf2
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNames
> paceModifierObjects.c
> @@ -0,0 +1,360 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_FILEC
> ODE
> +
> +/**
> + 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", __func__,
> 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",
> __func__, 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", __func__, 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",
> __func__, String));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__,
> 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", __func__,
> 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",
> __func__, 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", __func__,
> 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",
> __func__, 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", __func__,
> 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", __func__,
> 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",
> __func__, 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",
> __func__));
> + 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",
> __func__, 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",
> __func__, AliasName));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n",
> __func__));
> + 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", __func__,
> 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",
> __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjects
> Debug.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObject
> sDebug.c
> new file mode 100644
> index 0000000000..279bfc782d
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObject
> sDebug.c
> @@ -0,0 +1,144 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLOBJECTSDEBUG_FILECODE
> +
> +/**
> + 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLen
> gth.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLen
> gth.c
> new file mode 100644
> index 0000000000..85d184b759
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLen
> gth.c
> @@ -0,0 +1,267 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLPKGLENGTH_FILECODE
> +
> +#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",
> + __func__,
> + 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", __func__));
> + 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 ByteData> |
> + <PkgLeadByte ByteData ByteData> |
> + <PkgLeadByte ByteData ByteData ByteData>
> +
> + PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
> + <bit 5-4: Only used if PkgLength < 63>
> + <bit 3-0: Least significant package length nybble>
> +
> + 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", __func__));
> + goto Done;
> + }
> +
> + break;
> + case AmlClose:
> + Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH",
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n",
> __func__));
> + 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", __func__,
> "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",
> + __func__,
> + 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", __func__));
> + 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResour
> ceDescriptor.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResour
> ceDescriptor.c
> new file mode 100644
> index 0000000000..4ef746327b
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResour
> ceDescriptor.c
> @@ -0,0 +1,1989 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECODE
> +
> +/**
> + 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", __func__,
> "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", __func__,
> "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", __func__,
> "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",
> __func__));
> + 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", __func__));
> + 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", __func__,
> "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", __func__));
> + 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", __func__));
> + 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", __func__));
> + DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n",
> __func__, 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", __func__, AddressMaximum));
> + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n",
> __func__, AddressGranularity));
> + DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (AddressMaximum == 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n",
> __func__));
> + DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
> + 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", __func__, AddressMinimum));
> + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n",
> __func__, AddressGranularity));
> + DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __func__));
> + 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", __func__));
> + 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", __func__, RangeLength));
> + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n",
> __func__, AddressGranularity));
> + DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed =
> 0\n", __func__));
> + 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", __func__,
> RangeLength, AddressMaximum, AddressMinimum));
> + DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n",
> __func__, 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",
> __func__, AddressGranularity));
> + DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0,
> IsMinFixed = 1, and IsMaxFixed = 1\n", __func__, 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", __func__,
> RangeLength, AddressMaximum, AddressMinimum));
> + DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n",
> __func__, 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",
> __func__, RangeLength));
> + DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both
> be either 1 or 0\n", __func__));
> + 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", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed
> Parameter\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed
> Parameter\n", __func__));
> + 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", __func__));
> + return Status;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__,
> "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", __func__,
> "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",
> __func__, 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",
> __func__, 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",
> __func__, DmaType));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (ListHead == NULL) {
> + // Invalid
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot
> == NULL.\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.",
> __func__, "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", __func__,
> "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", __func__));
> + 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",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + } else if (ISARanges > 3) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n",
> __func__));
> + 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", __func__, (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",
> __func__));
> + 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", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed
> Parameter\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed
> Parameter\n", __func__));
> + 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", __func__));
> + return Status;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__,
> "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", __func__,
> "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",
> __func__, 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",
> __func__, 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",
> __func__, Shared));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (ListHead == NULL) {
> + // Invalid
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot
> == NULL.\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__,
> "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", __func__,
> "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",
> __func__, Decode));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (ListHead == NULL) {
> + // Invalid
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot
> == NULL.\n", __func__));
> + 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", __func__, AddressMin));
> + DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n",
> __func__, 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", __func__, AddressMax));
> + DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n",
> __func__, AddressAlignment));
> + return EFI_INVALID_PARAMETER;
> + }
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.",
> __func__, "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", __func__,
> "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", __func__, 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", __func__, AddressSpaceKeyword));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (AccessSize > EFI_ACPI_6_4_QWORD) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n",
> __func__, AccessSize));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.",
> __func__, "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", __func__,
> "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", __func__));
> + 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",
> __func__, ReadAndWrite));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (ListHead == NULL) {
> + // Invalid
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot
> == NULL.\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.",
> __func__, "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", __func__,
> "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",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + } else if (ISARanges > 3) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n",
> __func__));
> + 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", __func__, (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",
> __func__));
> + 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", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed
> Parameter\n", __func__));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed
> Parameter\n", __func__));
> + 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", __func__));
> + return Status;
> + }
> +
> + Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__,
> "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", __func__,
> "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", __func__));
> + 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",
> __func__));
> + return EFI_INVALID_PARAMETER;
> + } else if (ISARanges > 3) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n",
> __func__));
> + 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatem
> entOpcodes.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatem
> entOpcodes.c
> new file mode 100644
> index 0000000000..03201d0109
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatem
> entOpcodes.c
> @@ -0,0 +1,515 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_AMLSTATEMENTOPCODES_FILECODE
> +
> +/**
> + 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 pkglength termlist>
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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", __func__));
> + goto Done;
> + }
> +
> + Status = AmlOPDataInteger (NotifyValue, ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue
> Integer\n", __func__));
> + goto Done;
> + }
> +
> + Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject,
> ListHead);
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n",
> __func__));
> + 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", __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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",
> __func__));
> + 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
> new file mode 100644
> index 0000000000..c9a4399764
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
> @@ -0,0 +1,213 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLTABLE_FILECODE
> +
> +// 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", __func__,
> 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", __func__,
> 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",
> __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.c
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.c
> new file mode 100644
> index 0000000000..b1ad9b7037
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlO
> bjects.c
> @@ -0,0 +1,364 @@
> +/** @file
> +
> + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "LocalAmlLib.h"
> +#include <Filecode.h>
> +
> +#define FILECODE
> LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE
> +
> +/**
> + 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 <all others> - 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 <all others> - 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 <all others> - 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",
> __func__));
> + 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 <all others> - 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 <all others> - 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",
> __func__, 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 <all others> - 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",
> + __func__,
> + 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 <all others> - 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;
> + UINT8 *TempBuffer;
> +
> + 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",
> __func__));
> + 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
> + TempBuffer = ReallocatePool (
> + Object->DataSize,
> + Object->DataSize + ChildObject->DataSize,
> + Object->Data
> + );
> + if (TempBuffer == NULL) {
> + Status = EFI_OUT_OF_RESOURCES;
> + FreePool (Object->Data);
> + Object->Data = NULL;
> + DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n",
> __func__));
> + goto Done;
> + }
> +
> + Object->Data = TempBuffer;
> + // 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/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
> new file mode 100644
> index 0000000000..2f4f676adb
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
> @@ -0,0 +1,13 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +/*----------------------------------------------------------------------------------------
> + * M O D U L E S U S E D
> + *----------------------------------------------------------------------------------------
> + */
> +#include <Filecode.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.c
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.c
> new file mode 100644
> index 0000000000..60305ee4a6
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseR
> esetSystemLib.c
> @@ -0,0 +1,90 @@
> +/** @file
> + Library to support reset library, inheritted from Agesa Cf9Reset module.
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/IoLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/PcdLib.h>
> +
> +/**
> + This function causes a system-wide reset (cold reset), in which
> + all circuitry within the system returns to its initial state. This type of reset
> + is asynchronous to system operation and operates without regard to
> + cycle boundaries.
> +
> + If this function returns, it means that the system does not support cold reset.
> +**/
> +VOID
> +EFIAPI
> +ResetCold (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + This function causes a system-wide initialization (warm reset), in which all
> processors
> + are set to their initial state. Pending cycles are not corrupted.
> +
> + If this function returns, it means that the system does not support warm
> reset.
> +**/
> +VOID
> +EFIAPI
> +ResetWarm (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + This function causes the system to enter a power state equivalent
> + to the ACPI G2/S5 or G3 states.
> +
> + If this function returns, it means that the system does not support shutdown
> reset.
> +**/
> +VOID
> +EFIAPI
> +ResetShutdown (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + This function causes the system to enter S3 and then wake up immediately.
> +
> + If this function returns, it means that the system does not support S3
> feature.
> +**/
> +VOID
> +EFIAPI
> +EnterS3WithImmediateWake (
> + VOID
> + )
> +{
> +}
> +
> +/**
> + This function causes a systemwide reset. The exact type of the reset is
> + defined by the EFI_GUID that follows the Null-terminated Unicode string
> passed
> + into ResetData. If the platform does not recognize the EFI_GUID in
> ResetData
> + the platform must pick a supported reset type to perform.The platform may
> + optionally log the parameters from any non-normal reset that occurs.
> +
> + @param[in] DataSize The size, in bytes, of ResetData.
> + @param[in] ResetData The data buffer starts with a Null-terminated string,
> + followed by the EFI_GUID.
> +**/
> +VOID
> +EFIAPI
> +ResetPlatformSpecific (
> + IN UINTN DataSize,
> + IN VOID *ResetData
> + )
> +{
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
> b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
> new file mode 100644
> index 0000000000..d10e676668
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
> @@ -0,0 +1,87 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Filecode.h>
> +#include <Uefi.h>
> +/*----------------------------------------------------------------------------------------*/
> +
> +/**
> + * @param[in] EspiBase Espi MMIO base
> + * @param[in] RegAddr Slave register address
> + *
> + * @retval Register Value
> + */
> +UINT32
> +FchEspiCmd_GetConfiguration (
> + IN UINT32 EspiBase,
> + IN UINT32 RegAddr
> + )
> +{
> + return 0;
> +}
> +
> +/*----------------------------------------------------------------------------------------*/
> +
> +/**
> + *
> + * @param[in] EspiBase Espi MMIO base
> + * @param[in] Address Address to read
> + * @param[in] Length Length in byte to read
> + * @param[in] Buffer Pointer to the data read to
> + *
> + */
> +EFI_STATUS
> +FchEspiCmd_SafsFlashRead (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length,
> + OUT UINT8 *Buffer
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> +/*----------------------------------------------------------------------------------------*/
> +
> +/**
> + *
> + * @param[in] EspiBase Espi MMIO base
> + * @param[in] Address Address to write
> + * @param[in] Length Length in byte to write
> + * @param[in] Value Pointer to the data to write
> + *
> + */
> +EFI_STATUS
> +FchEspiCmd_SafsFlashWrite (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length,
> + IN UINT8 *Value
> + )
> +{
> + return EFI_SUCCESS;
> +}
> +
> +/*----------------------------------------------------------------------------------------*/
> +
> +/**
> + *
> + * @param[in] EspiBase Espi MMIO base
> + * @param[in] Address Address to erase
> + * @param[in] Length Block Size to erase
> + *
> + *
> + */
> +EFI_STATUS
> +FchEspiCmd_SafsFlashErase (
> + IN UINT32 EspiBase,
> + IN UINT32 Address,
> + IN UINT32 Length
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
> b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
> new file mode 100755
> index 0000000000..9044d3d497
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
> @@ -0,0 +1,68 @@
> +/** @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.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <GnbDxio.h>
> +#include <Library/NbioHandleLib.h>
> +#include <Library/AmdBaseLib.h>
> +
> +/**
> + Get GNB handle
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +
> +**/
> +GNB_HANDLE *
> +NbioGetHandle (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get GNB handle of alternate host bridge (e.g. MI200)
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +GNB_HANDLE *
> +NbioGetAltHandle (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get GNB handle of next socket
> +
> + @param[in] NbioHandle Pointer to current GnbHandle
> +**/
> +GNB_HANDLE *
> +NbioGetNextSocket (
> + IN GNB_HANDLE *NbioHandle
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get PCI_ADDR of GNB
> +
> + @param[in] Handle Pointer to GNB_HANDLE
> +**/
> +PCI_ADDR
> +NbioGetHostPciAddress (
> + IN GNB_HANDLE *Handle
> + )
> +{
> + PCI_ADDR PciAddr;
> +
> + PciAddr.AddressValue = 0;
> + return PciAddr;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
> b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
> new file mode 100755
> index 0000000000..d5fbe98d22
> --- /dev/null
> +++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
> @@ -0,0 +1,276 @@
> +/** @file
> + GNB function to create/locate PCIe configuration data area
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <GnbDxio.h>
> +#include <Library/AmdBaseLib.h>
> +#include <Library/GnbPcieConfigLib.h>
> +
> +/**
> + Check Port Status
> +
> + @param[in] Engine Pointer to engine config descriptor
> + @param[in] PortStatus Check if status asserted for port
> + @retval TRUE if status asserted
> +**/
> +BOOLEAN
> +PcieConfigCheckPortStatus (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN UINT32 PortStatus
> + )
> +{
> + return FALSE;
> +}
> +
> +/**
> + Set/Reset port status
> +
> + @param[in] Engine Pointer to engine config descriptor
> + @param[in] SetStatus SetStatus
> + @param[in] ResetStatus ResetStatus
> +
> +**/
> +UINT16
> +PcieConfigUpdatePortStatus (
> + IN PCIE_ENGINE_CONFIG *Engine,
> + IN PCIE_ENGINE_INIT_STATUS SetStatus,
> + IN PCIE_ENGINE_INIT_STATUS ResetStatus
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Execute callback on all descriptor of specific type
> +
> + @param[in] InDescriptorFlags Include descriptor flags
> + @param[in] OutDescriptorFlags Exclude descriptor flags
> + @param[in] TerminationFlags Termination flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +AGESA_STATUS
> +PcieConfigRunProcForAllDescriptors (
> + IN UINT32 InDescriptorFlags,
> + IN UINT32 OutDescriptorFlags,
> + IN UINT32 TerminationFlags,
> + IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> + return AGESA_UNSUPPORTED;
> +}
> +
> +/**
> + Execute callback on all wrappers in topology
> +
> + @param[in] DescriptorFlags Wrapper Flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +AGESA_STATUS
> +PcieConfigRunProcForAllWrappers (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> + return AGESA_UNSUPPORTED;
> +}
> +
> +/**
> + Execute callback on all wrappers in NBIO
> +
> +
> + @param[in] DescriptorFlags Wrapper Flags
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllWrappersInNbio (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
> + IN OUT VOID *Buffer,
> + IN GNB_HANDLE *GnbHandle
> + )
> +{
> +}
> +
> +/**
> + Execute callback on all engine in topology
> +
> + @param[in] DescriptorFlags Engine flags.
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllEngines (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> +}
> +
> +/**
> + Execute callback on all engine in wrapper
> +
> + @param[in] DescriptorFlags Engine flags.
> + @param[in] Callback Pointer to callback function
> + @param[in, out] Buffer Pointer to buffer to pass information to
> callback
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigRunProcForAllEnginesInWrapper (
> + IN UINT32 DescriptorFlags,
> + IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
> + IN OUT VOID *Buffer,
> + IN PCIE_WRAPPER_CONFIG *Wrapper
> + )
> +{
> +}
> +
> +/**
> + Get parent descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetParent (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get child descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetChild (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get peer descriptor of specific type
> +
> + @param[in] Type Descriptor type
> + @param[in] Descriptor Pointer to buffer to pass information to
> callback
> +**/
> +PCIE_DESCRIPTOR_HEADER *
> +PcieConfigGetPeer (
> + IN UINT32 Type,
> + IN PCIE_DESCRIPTOR_HEADER *Descriptor
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Check is engine is active or potentially active
> +
> + @param[in] Engine Pointer to engine descriptor
> + @retval TRUE - engine active
> + @retval FALSE - engine not active
> +**/
> +BOOLEAN
> +PcieConfigIsActivePcieEngine (
> + IN PCIE_ENGINE_CONFIG *Engine
> + )
> +{
> + return FALSE;
> +}
> +
> +/**
> + Locate SB engine on wrapper
> +
> + @param[in] Wrapper Pointer to wrapper config descriptor
> + @retval SB engine pointer or NULL
> +**/
> +PCIE_ENGINE_CONFIG *
> +PcieConfigLocateSbEngine (
> + IN PCIE_WRAPPER_CONFIG *Wrapper
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Helper function to dump engine configuration
> +
> + @param[in] EngineList Engine Configuration
> +**/
> +VOID
> +PcieConfigEngineDebugDump (
> + IN PCIE_ENGINE_CONFIG *EngineList
> + )
> +{
> +}
> +
> +/**
> + Helper function to dump wrapper configuration
> +
> + @param[in] WrapperList Wrapper Configuration
> +**/
> +VOID
> +PcieConfigWrapperDebugDump (
> + IN PCIE_WRAPPER_CONFIG *WrapperList
> + )
> +{
> +}
> +
> +/**
> + Helper function to dump configuration to debug out
> +
> + @param[in] Pcie Pointer to global PCIe configuration
> +**/
> +VOID
> +PcieConfigDebugDump (
> + IN PCIE_PLATFORM_CONFIG *Pcie
> + )
> +{
> +}
> +
> +/**
> + Helper function to dump input configuration to user engine descriptor
> +
> + @param[in] EngineDescriptor Pointer to engine descriptor
> +**/
> +VOID
> +PcieUserDescriptorConfigDump (
> + IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
> + )
> +{
> +}
> +
> +/**
> + Helper function to dump input configuration to debug out
> +
> + @param[in] ComplexDescriptor Pointer to user defined complex
> descriptor
> +**/
> +VOID
> +PcieUserConfigConfigDump (
> + IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
> + )
> +{
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.
> c
> b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.
> c
> new file mode 100755
> index 0000000000..5c6be22ee4
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.
> c
> @@ -0,0 +1,117 @@
> +/** @file
> + Procedure to parse PCIe input configuration data
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <GnbDxio.h>
> +
> +/**
> + Get number of complexes in platform topology configuration
> +
> + @param[in] ComplexList First complex configuration in complex
> configuration array
> + @retval Number of Complexes
> +
> +**/
> +UINTN
> +PcieInputParserGetNumberOfComplexes (
> + IN PCIE_COMPLEX_DESCRIPTOR *ComplexList
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Get number of PCIe engines in given complex
> +
> + @param[in] Complex Complex configuration
> + @retval Number of Engines
> +**/
> +UINTN
> +PcieInputParserGetLengthOfPcieEnginesList (
> + IN PCIE_COMPLEX_DESCRIPTOR *Complex
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Get number of DDI engines in given complex
> +
> + @param[in] Complex Complex configuration
> + @retval Number of Engines
> +**/
> +UINTN
> +PcieInputParserGetLengthOfDdiEnginesList (
> + IN PCIE_COMPLEX_DESCRIPTOR *Complex
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Get number of engines in given complex
> +
> +
> +
> + @param[in] Complex Complex configuration header
> + @retval Number of Engines
> +**/
> +UINTN
> +PcieInputParserGetNumberOfEngines (
> + IN PCIE_COMPLEX_DESCRIPTOR *Complex
> + )
> +{
> + return 0;
> +}
> +
> +/**
> + Get Complex descriptor by index from given Platform configuration
> +
> + @param[in] ComplexList Platform topology configuration
> + @param[in] Index Complex descriptor Index
> + @retval Pointer to Complex Descriptor
> +**/
> +PCIE_COMPLEX_DESCRIPTOR *
> +PcieInputParserGetComplexDescriptor (
> + IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
> + IN UINTN Index
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get Complex descriptor by index from given Platform configuration
> +
> + @param[in] ComplexList Platform topology configuration
> + @param[in] SocketId Socket Id
> + @retval Pointer to Complex Descriptor
> +**/
> +PCIE_COMPLEX_DESCRIPTOR *
> +PcieInputParserGetComplexDescriptorOfSocket (
> + IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
> + IN UINT32 SocketId
> + )
> +{
> + return NULL;
> +}
> +
> +/**
> + Get Engine descriptor from given complex by index
> +
> + @param[in] Complex Complex descriptor
> + @param[in] Index Engine descriptor index
> + @retval Pointer to Engine Descriptor
> +**/
> +PCIE_ENGINE_DESCRIPTOR *
> +PcieInputParserGetEngineDescriptor (
> + IN PCIE_COMPLEX_DESCRIPTOR *Complex,
> + IN UINTN Index
> + )
> +{
> + return NULL;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
> b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
> new file mode 100644
> index 0000000000..e6be32b071
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
> @@ -0,0 +1,10 @@
> +/** @file
> + SMN Register Access Methods
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/SmnAccessLib.h>
> diff --git
> a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctio
> ns.c
> b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctio
> ns.c
> new file mode 100644
> index 0000000000..1dc13900c7
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctio
> ns.c
> @@ -0,0 +1,42 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <PiDxe.h>
> +#include <GnbDxio.h>
> +#include <Library/AmdBaseLib.h>
> +#include <Library/PcieConfigLib.h>
> +#include <Library/NbioCommonLibDxe.h>
> +
> +/**
> + Function to retrieve SOC_LOGICAL_ID
> +
> + @param[out] LogicalId Pointer to SOC_LOGICAL_ID
> + @retval EFI_UNSUPPORTED
> +
> +**/
> +EFI_STATUS
> +PcieGetLogicalId (
> + OUT SOC_LOGICAL_ID *LogicalId
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> +
> +/**
> + Function to retrieve PCIE_PLATFORM_CONFIG
> +
> + @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
> + @retval EFI_UNSUPPORTED
> +
> +**/
> +EFI_STATUS
> +PcieGetPcieDxe (
> + OUT PCIE_PLATFORM_CONFIG **Pcie
> + )
> +{
> + return EFI_UNSUPPORTED;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
> new file mode 100644
> index 0000000000..fbd3ddcf37
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
> @@ -0,0 +1,23 @@
> +/** @file
> + APCB DXE Driver
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiDxe.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/PcdLib.h>
> +
> +EFI_STATUS
> +EFIAPI
> +AmdApcbV3DxeDriverEntry (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
> new file mode 100644
> index 0000000000..23d1a8fee0
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
> @@ -0,0 +1,29 @@
> +/** @file
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiPei.h>
> +
> +/**
> + * @brief Amd Apcb V3 Pei Driver Entry
> + *
> + * @param[in] FileHandle File Handie
> + * @param[in] PeiServices Pei Services
> + *
> + * @retval EFI_SUCCESS Set APCB value successfully
> + * Non-EFI_SUCCESS Function Error
> + *
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmdApcbV3PeiDriverEntry (
> + IN EFI_PEI_FILE_HANDLE FileHandle,
> + IN CONST EFI_PEI_SERVICES **PeiServices
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.c
> b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.c
> new file mode 100644
> index 0000000000..74b129931b
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/Oe
> mAgesaCcxPlatformLibNull.c
> @@ -0,0 +1,39 @@
> +/** @file
> + Required OEM hooks for CCX initialization
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Uefi.h>
> +
> +/**
> + Hook to store the vector that all APs should jump to out of reset to a non-
> volatile,
> + shared location.
> +
> + @param[in] ApInitAddress Address of the code that AP should jump to
> + @param[in,out] ContentToRestore The current value in the non-volatile
> storage
> +
> +**/
> +VOID
> +SaveApInitVector (
> + IN UINT32 ApInitAddress,
> + IN OUT UINT32 *ContentToRestore
> + )
> +{
> +}
> +
> +/**
> + Hook to restore the initial content of the non-volatile storage location.
> +
> + @param[in] ContentToRestore The value to restore
> +
> +**/
> +VOID
> +RestoreContentVector (
> + IN UINT32 ContentToRestore
> + )
> +{
> +}
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.c
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.c
> new file mode 100644
> index 0000000000..54ce202cb1
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciEx
> pressPciCfg2.c
> @@ -0,0 +1,33 @@
> +/** @file
> +
> + Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiPei.h>
> +#include <Ppi/PciCfg2.h>
> +#include <Library/BaseLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/IoLib.h>
> +
> +/**
> + Module's entry function.
> + This routine will install EFI_PEI_PCI_CFG2_PPI.
> +
> + @param FileHandle Handle of the file being invoked.
> + @param PeiServices Describes the list of possible PEI Services.
> +
> + @return Whether success to install service.
> +**/
> +EFI_STATUS
> +EFIAPI
> +PeimInitializePciCfg (
> + IN EFI_PEI_FILE_HANDLE FileHandle,
> + IN CONST EFI_PEI_SERVICES **PeiServices
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciSegmentInfoLib.c
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciSegmentInfoLib.c
> new file mode 100644
> index 0000000000..643174d7b9
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentIn
> foLib/PciSegmentInfoLib.c
> @@ -0,0 +1,30 @@
> +/** @file
> +
> + Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Base.h>
> +#include <Library/PciSegmentInfoLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/BaseLib.h>
> +
> +/**
> + Return an array of PCI_SEGMENT_INFO holding the segment information.
> +
> + Note: The returned array/buffer is owned by callee.
> +
> + @param Count Return the count of segments.
> +
> + @retval A callee owned array holding the segment information.
> +**/
> +PCI_SEGMENT_INFO *
> +EFIAPI
> +GetPciSegmentInfo (
> + UINTN *Count
> + )
> +{
> + return (PCI_SEGMENT_INFO *)NULL;
> +}
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/A
> mdPspFlashAccSpiNorLibSmm.c
> b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/
> AmdPspFlashAccSpiNorLibSmm.c
> new file mode 100644
> index 0000000000..d83bb6c2d8
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/
> AmdPspFlashAccSpiNorLibSmm.c
> @@ -0,0 +1,15 @@
> +/** @file
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <PiSmm.h>
> +#include <Register/Cpuid.h>
> +#include <Library/BaseLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/SmmServicesTableLib.h>
> +#include <Library/DebugLib.h>
> +#include <Protocol/SmmBase2.h>
> +#include <Library/IoLib.h>
> diff --git
> a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.c
> b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.c
> new file mode 100644
> index 0000000000..a264eb9294
> --- /dev/null
> +++
> b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRo
> mArmorWhitelistLib.c
> @@ -0,0 +1,12 @@
> +/** @file
> + Platform ROM Armor Whitelist table
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Library/DebugLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/PcdLib.h>
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
> new file mode 100644
> index 0000000000..e379538e3a
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
> @@ -0,0 +1,36 @@
> +/** @file
> + OEM OOB PPR DXE Driver.
> +
> + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <PiDxe.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Protocol/PciIo.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/TimerLib.h>
> +#include <IndustryStandard/Pci22.h>
> +
> +/**
> +* This function installs a protocol used by platform BIOS to provide the
> hotplug descriptor.
> +*
> +* @param[in] ImageHandle Image handler
> +* @param[in] SystemTable Pointer to the system table
> +*
> +* @retval EFI_SUCCESS The thread was successfully launched.
> +*
> +**/
> +EFI_STATUS
> +EFIAPI
> +OobPprEntry (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatformDriver.c
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatformDriver.c
> new file mode 100644
> index 0000000000..5242e6261a
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriv
> er/PspPlatformDriver.c
> @@ -0,0 +1,20 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Library/BaseLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/DebugLib.h>
> +
> +EFI_STATUS
> +EFIAPI
> +PspPlatformEntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.c
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.c
> new file mode 100644
> index 0000000000..530bd9d4b6
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugD
> xe/ServerHotplugDxe.c
> @@ -0,0 +1,22 @@
> +/** @file
> +
> + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <PiPei.h>
> +#include <Library/BaseLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +
> +EFI_STATUS
> +EFIAPI
> +HotplugDescEntry (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + return EFI_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.c
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.c
> new file mode 100644
> index 0000000000..fbc372586b
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> DynamicCommand.c
> @@ -0,0 +1,44 @@
> +/** @file
> +
> + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + 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/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.c
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.c
> new file mode 100644
> index 0000000000..0a5f4a7e81
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAuto
> ToolApp.c
> @@ -0,0 +1,36 @@
> +/** @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.<BR>
> +
> + 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;
> +}
> diff --git
> a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.c
> b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.c
> new file mode 100644
> index 0000000000..47eb700f8f
> --- /dev/null
> +++
> b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmd
> FchUart/BasePlatformHookLibAmdFchUart.c
> @@ -0,0 +1,29 @@
> +/** @file
> +
> + Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/IoLib.h>
> +
> +/**
> + Performs platform specific initialization required for the CPU to access
> + the hardware associated with a SerialPortLib instance. This function does
> + not intiailzie the serial port hardware itself. Instead, it initializes
> + hardware devices that are required for the CPU to access the serial port
> + hardware. This function may be called more than once.
> +
> + @retval RETURN_SUCCESS The platform specific initialization succeeded.
> + @retval RETURN_DEVICE_ERROR The platform specific initialization could
> not be completed.
> +
> +**/
> +RETURN_STATUS
> +EFIAPI
> +PlatformHookSerialPortInitialize (
> + VOID
> + )
> +{
> + return RETURN_SUCCESS;
> +}
> diff --git
> a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongs
> hanI2C_I3C.asl
> b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongs
> hanI2C_I3C.asl
> new file mode 100644
> index 0000000000..72b9a87639
> --- /dev/null
> +++
> b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongs
> hanI2C_I3C.asl
> @@ -0,0 +1,9 @@
> +/** @file
> +
> + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights
> reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +
> diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
> b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
> new file mode 100644
> index 0000000000..2dfb3190d4
> --- /dev/null
> +++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
> @@ -0,0 +1,13 @@
> +; @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.<BR>
> +;
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> +;
> +%macro AMD_ENABLE_UEFI_STACK2 2-3
> +
> +%endmacro
> diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
> b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
> index a731c7e369..937caee083 160000
> --- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
> +++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
> @@ -1 +1 @@
> -Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490
> +Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368
> --
> 2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119132): https://edk2.groups.io/g/devel/message/119132
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
2024-05-23 7:25 ` Xing, Eric via groups.io
@ 2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
2024-05-23 8:30 ` Yao, Ken via groups.io
1 sibling, 1 reply; 16+ messages in thread
From: Zhai, MingXin (Duke) via groups.io @ 2024-05-23 7:47 UTC (permalink / raw)
To: Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Yao, Ken, Xing, Eric
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
From: Abner Chang <abner.chang@amd.com>
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
Platform/AMD/Readme.md | 64 ++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/Platform/AMD/Readme.md b/Platform/AMD/Readme.md index 99d2b990c7..3297c6ba59 100644
--- a/Platform/AMD/Readme.md
+++ b/Platform/AMD/Readme.md
@@ -7,18 +7,25 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Term and Definitions
+* **AGESA**
+
+ AMD Generic Encapsulated Software Architecture that are executed as
+ part of a host platform BIOS.
+
* **AMD Platform** (platform in short)
- AMD platform refers to a platform that supports the particular AMD SoC (processor), such as AMD EPYC Milan and Genoa processors.
+ AMD platform refers to a platform that supports the particular AMD
+ SoC (processor), such as AMD EPYC Milan and Genoa processors.
* **AMD Board** (board in short)
AMD board is a generic terminology refers to a board that is designed based on a
specific AMD SoC architecture (also referred as AMD platform). More than one boards
- are possibly designed to support an AMD platform with different configuration, such as 1-processor socket or 2-processor sockets board.
+ are possibly designed to support an AMD platform with different
+ configuration, such as 1-processor socket or 2-processor sockets board.
* **AMD edk2 Platform Package** (platform package in short)
-
+
The folder has the AMD edk2 platform common modules.
* **AMD edk2 Board Package** (board package in short) @@ -28,29 +35,52 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Package Definition
+* **AgesaModulePkg**
+
+ This package contains all of the private interfaces and build
+ configuration files for the AGESA support.
+
+* **AgesaPkg**
+
+ This package contains all of the public interfaces and build
+ configuration files for the AGESA support.
+
+* **AmdCbsPkg**
+
+ AMD Configurable BIOS Setting. Provides the edk2 formset following
+ the UEFI HII spec to configure BIOS settings.
+
+* **AmdCpmPkg**
+
+ AMD Common Platform Module software is a BIOS procedure library
+ designed to aid AMD customers to quickly implement AMD platform technology into their products.
+
* **AmdPlatformPkg**
- AMD platform edk2 package under this folder provides the common edk2 modules those
- are leverage by platforms. Usually those modules have no dependencies with
- particular platforms. The module under this scope can provides a common implementation
- for all platforms, or it may just provide a framework but the differences of implementation could be configured through the PCDs declared in AmdPlatformPkg.dec, or
- the board level library provided in the \<Board name\>Pkg.
+ AMD platform edk2 package under this folder provides the common edk2
+ modules that are leveraged by platforms. Usually those modules have no
+ dependencies with particular platforms. Modules under this scope can
+ provide a common implementation for all platforms, or may just
+ provide a framework but the differences of implementation could be
+ configured through the PCDs declared in AmdPlatformPkg.dec, or the board level library provided in the \<Board name\>Pkg.
* **AmdMinBoardPkg**
- This package provides the common edk2 modules those can be leverage across AMD boards those use MinPlatformPkg framework.
+ This package provides the common edk2 modules that can be leveraged
+ across AMD boards using the MinPlatform framework.
* **\<SoC name\>Board**
- This is the folder named by SoC and accommodate one or multiple board packages those
- are designed base on the same SoC platform. <SoC name>Board folder may contain edk2
- package meta files directly or the sub-folders named by \<Board name\>Pkg for a
- variety configurations of a platform.
+ This is the folder named by SoC and accommodates one or multiple
+ board packages that are designed based on the same SoC platform. <SoC
+ name>Board folder may contain edk2 package meta files directly or the
+ sub-folders named by \<Board name\>Pkg for a variety configurations of a platform.
* **<Board name\>Pkg**
- This is the folder that contains edk2 package meta files for a board which is designed base on a platform. Besides the edk2 meta files, <Board name\>Pkg may also provides
- edk2 modules which are specifically to a board.
+ This is the folder that contains edk2 package meta files for a board
+ which is designed base on a platform. Besides the edk2 meta files,
+ <Board name\>Pkg may also provides edk2 modules which are specifically to a board.
```
e.g. OverdriveBoard
@@ -63,6 +93,10 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
```
Platform/AMD
+ |----AgesaModulePkg
+ |----AgesaPkg
+ |----AmdCbsPkg
+ |----AmdCpmPkg
|----AmdPlatformPkg
|----AmdMinBoardPkg
|----OverdriveBoard
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119134): https://edk2.groups.io/g/devel/message/119134
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
2024-05-23 4:12 [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Chang, Abner via groups.io
` (2 preceding siblings ...)
2024-05-23 7:26 ` [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Xing, Eric via groups.io
@ 2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
2024-05-23 8:31 ` Yao, Ken via groups.io
3 siblings, 1 reply; 16+ messages in thread
From: Zhai, MingXin (Duke) via groups.io @ 2024-05-23 7:47 UTC (permalink / raw)
To: Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Yao, Ken, Xing, Eric
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
From: Abner Chang <abner.chang@amd.com>
BZ#: 4777
Initial commit of AMD cross platform/board generic
encapsulated software architecture. This provides
the basic definitions and protocols for the follow-up
AMD open board project.
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
.../AgesaModulePkg/AgesaCommonModulePkg.dec | 39 +
Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec | 18 +
.../AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec | 20 +
.../AMD/AgesaModulePkg/AgesaModuleDfPkg.dec | 25 +
.../AMD/AgesaModulePkg/AgesaModuleFchPkg.dec | 62 +
.../AMD/AgesaModulePkg/AgesaModuleMemPkg.dec | 26 +
.../AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec | 34 +
.../AMD/AgesaModulePkg/AgesaModulePspPkg.dec | 29 +
Platform/AMD/AgesaPkg/AgesaPkg.dec | 435 +++
Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec | 41 +
.../AgesaEdk2PlatformPkg.inc.dsc | 18 +
.../AgesaSp5RsModulePkg.inc.dsc | 48 +
.../CbsInstanceNull/CbsInstanceNull.inc.dsc | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.inc.dsc | 11 +
.../AgesaSp5RsModulePkg.dxe.inc.fdf | 11 +
.../AgesaSp5RsModulePkg.pei.inc.fdf | 9 +
.../CbsInstanceNull.dxe.inc.fdf | 7 +
.../CbsInstanceNull.pei.inc.fdf | 7 +
.../0x19/RS/External/CbsStones.dxe.inc.fdf | 8 +
.../0x19/RS/External/CbsStones.pei.inc.fdf | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf | 7 +
.../Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf | 10 +
.../Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf | 7 +
.../Library/AmdCalloutLib/AmdCalloutLib.inf | 29 +
.../AmdPspMboxLibV2/AmdPspMboxLibV2.inf | 30 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.inf | 27 +
.../AmdPspRomArmorLibNull.inf | 26 +
.../Library/ApcbLibV3/ApcbLibV3.inf | 37 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.inf | 32 +
.../BaseFabricTopologyRsLib.inf | 28 +
.../CcxTscTimerLib/BaseTscTimerLib.inf | 35 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.inf | 42 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.inf | 37 +
.../PciHostBridgeLib.inf | 42 +
.../DxeAmlGenerationLib/AmlGenerationLib.inf | 47 +
.../Library/FchBaseLib/FchBaseLib.inf | 26 +
.../FchBaseResetSystemLib.inf | 35 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.inf | 33 +
.../Library/NbioHandleLib/NbioHandleLib.inf | 24 +
.../Library/PcieConfigLib/PcieConfigLib.inf | 25 +
.../Library/SmnAccessLib/SmnAccessLib.inf | 33 +
.../Library/CommonDxe/NbioCommonDxeLib.inf | 29 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf | 45 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf | 33 +
.../OemAgesaCcxPlatformLibNull.inf | 27 +
.../PciExpressPciCfg2/PciExpressPciCfg2.inf | 61 +
.../PciExpressPciSegmentInfoLib.inf | 32 +
.../AmdPspFlashAccSpiNorLibSmm.inf | 45 +
.../PspRomArmorWhitelistLib.inf | 32 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.inf | 42 +
.../Dxe/PspPlatformDriver/PspPlatform.inf | 32 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.inf | 29 +
.../AmdAutoDynamicCommand.inf | 53 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.inf | 50 +
.../BasePlatformHookLibAmdFchUart.inf | 33 +
Platform/AMD/AgesaModulePkg/Include/AGESA.h | 158 +
Platform/AMD/AgesaModulePkg/Include/AMD.h | 91 +
.../Include/AmdEdk2/CpuRegisters.h | 15 +
.../AgesaModulePkg/Include/AmdPspDirectory.h | 61 +
.../AgesaModulePkg/Include/CpuRegistersDef.h | 156 +
.../Include/FchRegistersCommon.h | 85 +
.../AMD/AgesaModulePkg/Include/Filecode.h | 31 +
Platform/AMD/AgesaModulePkg/Include/Gnb.h | 14 +
Platform/AMD/AgesaModulePkg/Include/GnbDxio.h | 521 ++++
.../AgesaModulePkg/Include/GnbRegistersRS.h | 18 +
.../Include/GnbRegistersRS/IOHC.h | 22 +
.../Include/Guid/GnbPcieInfoHob.h | 31 +
.../Include/Library/AmdBaseLib.h | 16 +
.../Include/Library/AmdPspMboxLibV2.h | 43 +
.../Include/Library/BaseFabricTopologyLib.h | 22 +
.../Include/Library/FchBaseLib.h | 16 +
.../Include/Library/FchEspiCmdLib.h | 413 +++
.../Include/Library/GnbPcieConfigLib.h | 16 +
.../Include/Library/NbioCommonLibDxe.h | 37 +
.../Include/Library/NbioHandleLib.h | 62 +
.../Include/Library/PcieConfigLib.h | 283 ++
.../Include/Library/SmnAccessLib.h | 30 +
.../Protocol/AmdNbioPcieServicesProtocol.h | 47 +
.../Include/Protocol/AmdOemOobPprProtocol.h | 14 +
.../Include/Protocol/FabricNumaServices2.h | 155 +
.../Protocol/FabricTopologyServices2.h | 14 +
.../AMD/AgesaModulePkg/Include/SocLogicalId.h | 23 +
.../Library/DxeAmlGenerationLib/LocalAmlLib.h | 100 +
.../DxeAmlGenerationLib/LocalAmlObjects.h | 150 +
.../AMD/AgesaPkg/Include/AmdPcieComplex.h | 432 +++
Platform/AMD/AgesaPkg/Include/AmdSoc.h | 17 +
.../Include/FabricResourceManagerCmn.h | 42 +
.../AgesaPkg/Include/Guid/AmdMemoryInfoHob.h | 96 +
.../Include/Library/AmdPspBaseLibV2.h | 51 +
.../AgesaPkg/Include/Library/AmdPspFtpmLib.h | 83 +
.../Include/Library/AmdPspRomArmorLib.h | 231 ++
.../Include/Library/AmlGenerationLib.h | 2722 +++++++++++++++++
.../Library/PlatformPspRomArmorWhitelistLib.h | 25 +
.../AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h | 134 +
.../Include/Protocol/AmdCxlServicesProtocol.h | 183 ++
.../Protocol/AmdPciResourcesProtocol.h | 110 +
.../Include/Protocol/AmdPspFtpmProtocol.h | 187 ++
.../FabricResourceManagerServicesProtocol.h | 14 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h | 19 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h | 78 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h | 17 +
.../AMD/AmdCpmPkg/Include/AmdCpmFunction.h | 32 +
.../AmdCpmTableProtocol/AmdCpmTableProtocol.h | 39 +
.../Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c | 31 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.c | 12 +
.../AmdPspRomArmorLibNull.c | 79 +
.../Library/ApcbLibV3/ApcbLibV3.c | 12 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.c | 14 +
.../BaseFabricTopologyRsLib.c | 37 +
.../Library/CcxTscTimerLib/BaseTscTimerLib.c | 8 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.c | 35 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.c | 11 +
.../Library/CcxTscTimerLib/TscTimerLibShare.c | 103 +
.../DxeAmdPciHostBridgeLib/PciHostBridgeLib.c | 95 +
.../DxeAmlGenerationLib/AmlArgObjects.c | 154 +
.../DxeAmlGenerationLib/AmlAssistFunctions.c | 151 +
.../DxeAmlGenerationLib/AmlDataObjects.c | 640 ++++
.../AmlExpressionOpcodes.c | 1294 ++++++++
.../DxeAmlGenerationLib/AmlLocalObjects.c | 158 +
.../DxeAmlGenerationLib/AmlNameString.c | 576 ++++
.../DxeAmlGenerationLib/AmlNamedObject.c | 2138 +++++++++++++
.../AmlNamespaceModifierObjects.c | 360 +++
.../DxeAmlGenerationLib/AmlObjectsDebug.c | 144 +
.../DxeAmlGenerationLib/AmlPkgLength.c | 267 ++
.../AmlResourceDescriptor.c | 1989 ++++++++++++
.../DxeAmlGenerationLib/AmlStatementOpcodes.c | 515 ++++
.../Library/DxeAmlGenerationLib/AmlTable.c | 213 ++
.../DxeAmlGenerationLib/LocalAmlObjects.c | 364 +++
.../Library/FchBaseLib/FchStallLib.c | 13 +
.../FchBaseResetSystemLib.c | 90 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.c | 87 +
.../Library/NbioHandleLib/NbioHandleLib.c | 68 +
.../Library/PcieConfigLib/PcieConfigLib.c | 276 ++
.../PcieConfigLib/PcieInputParserLib.c | 117 +
.../Library/SmnAccessLib/SmnAccessLib.c | 10 +
.../Nbio/Library/CommonDxe/DxeLibFunctions.c | 42 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c | 23 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c | 29 +
.../OemAgesaCcxPlatformLibNull.c | 39 +
.../PciExpressPciCfg2/PciExpressPciCfg2.c | 33 +
.../PciSegmentInfoLib.c | 30 +
.../AmdPspFlashAccSpiNorLibSmm.c | 15 +
.../PspRomArmorWhitelistLib.c | 12 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.c | 36 +
.../Dxe/PspPlatformDriver/PspPlatformDriver.c | 20 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.c | 22 +
.../AmdAutoDynamicCommand.c | 44 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.c | 36 +
.../BasePlatformHookLibAmdFchUart.c | 29 +
.../FchSongshanDxe/FchSongshanI2C_I3C.asl | 9 +
.../AMD/AgesaPkg/Include/AmdUefiStackNasm.inc | 13 +
.../Library/RiscVOpensbiLib/opensbi | 2 +-
152 files changed, 19669 insertions(+), 1 deletion(-)
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
create mode 100644 Platform/AMD/AgesaPkg/AgesaPkg.dec
create mode 100755 Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
create mode 100755 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AGESA.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AMD.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Filecode.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Gnb.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
create mode 100755 Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdSoc.h
create mode 100644 Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
create mode 100644 Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
create mode 100644 Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
new file mode 100644
index 0000000000..d35a1f27b4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
@@ -0,0 +1,39 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCommonPkg
+ PACKAGE_GUID = 6CBE6566-0D3F-4E35-8358-9602354E9F09
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = {0x7788adf0, 0x9788, 0x4a3f, {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}}
+ gAgesaConfigDbPointerVariableGuid = {0x21229d24, 0xc71d, 0x4bc0, {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}}
+ gAmdMemoryInfoHobGuid = {0x1bce3d14, 0xa5fe, 0x4a0b, {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}}
+
+[Protocols]
+ ## Soc Protocols
+ gAmdSocLogicalIdProtocolGuid = {0x72f8e409, 0x0d2a, 0x4b91, {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}}
+ gAmdOemOobPprDxeProtocolGuid = {0x78031be3, 0x54a2, 0x4819, {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupportedV2|2|UINT8|0x00002002 # 2 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|1|UINT8|0x00002003 # 1 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2|8|UINT8|0x00002004 # 8 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannelV2|2|UINT8|0x00002005 # 2 by default
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UINT64|0x00027003
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
new file mode 100644
index 0000000000..1637068432
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
@@ -0,0 +1,18 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaEdk2Pkg
+ PACKAGE_GUID = E866104F-D458-41B1-AB26-FA5951618A8C
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/AmdEdk2
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
new file mode 100755
index 0000000000..b84fe5b738
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
@@ -0,0 +1,20 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCcxPkg
+ PACKAGE_GUID = df325429-029e-40f0-82db-0e69be7f6560
+ PACKAGE_VERSION = 0.1
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FALSE|BOOLEAN|0x000CC029
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
new file mode 100755
index 0000000000..57db15e663
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
@@ -0,0 +1,25 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaDfPkg
+ PACKAGE_GUID = 81e51ee3-c347-4563-92fe-790ba953bf0f
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gAmdTotalNumberOfRootBridgesGuid = {0xfb5703f5, 0xf8a7, 0xf401, {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}}
+ gAmdResourceSizeForEachRbGuid = {0x542b8f2f, 0xbd52, 0x4233, {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}}
+
+[Protocols]
+ gAmdFabricNumaServices2ProtocolGuid = {0xa8ff2e64, 0xf319, 0x4af1, {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}}
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
new file mode 100644
index 0000000000..521957e809
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
@@ -0,0 +1,62 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 1.5
+ PACKAGE_NAME = AgesaFchPkg
+ PACKAGE_GUID = e47c8ed9-3000-4e6e-b1c6-875b365b3849
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = { 0x7788adf0, 0x9788, 0x4a3f, { 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } }
+
+[Protocols]
+ gFchInitDonePolicyProtocolGuid = { 0xc63c0c73, 0xf612, 0x4c02, { 0x84, 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } }
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|0x0003F001
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0x0003F002
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0x0003F003
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x0003F00D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BOOLEAN|0x0003F021
+
+ ### @brief This item allows the customer to change OC signal polarity to be active low. This is universal and applies to all OC pins.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)At present, this control applies to Family17h Model 00h-2Fh.
+ ### @li TRUE - OC pin is low when OC occurs.
+ ### @li FALSE - OC pin is high when OC occurs.
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciOcPolarityCfgLow|FALSE|BOOLEAN|0x0003F309
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFFFFFFFFFFFFF|UINT64|0x0003F340
+ #Die 0
+ #[7:0] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ #[23:0] MTS -- 6 USB 2.0 ports on XHCI controller 0
+ #Die 1
+ #[39:32] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[47:40] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb31OcPinSelect|0xFFFFFFFF|UINT32|0x0003F341
+ #Die 0
+ #[7:0] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ #[15:0] MTS -- 4 USB 3.1 ports on XHCI controller 0
+ #Die 1
+ #[23:16] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[31:24] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLpcEnable|TRUE|BOOLEAN|0x0003F400
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdUsbRSOemConfigurationTable|{0x0}|VOID*|0x0003F40A
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciSsid|0x00000000|UINT32|0x0003FF07
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x00000000|UINT32|0x0003FF81
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
new file mode 100644
index 0000000000..721d3ea73b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
@@ -0,0 +1,26 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaMemPkg
+ PACKAGE_GUID = 445f7303-3171-428c-ad0b-32df4474a7ad
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries|64|UINT32|0x00029001
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
new file mode 100755
index 0000000000..0501774c9b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
@@ -0,0 +1,34 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaNbioPkg
+ PACKAGE_GUID = 1486f0fe-39ee-4856-a39f-222ff2404f26
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Protocols]
+ gAmdNbioPcieServicesProtocolGuid = {0x756db75c, 0xbb9d, 0x4289, {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE|BOOLEAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI phase
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0x00021103 #///< Base NBIO IOAPIC ID. ID assigned start from this value
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x0004101D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x0004101E
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|0x0|UINT32|0x00041200
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
new file mode 100644
index 0000000000..41cf320c76
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
@@ -0,0 +1,29 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPspPkg
+ PACKAGE_GUID = 5c48f900-a98c-431f-8be5-19c09c65bb05
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gApSyncFlagNvVariableGuid = { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb, 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } }
+ gAmdPspApobHobGuid = { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13, 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } }
+
+[Protocols]
+ gPspFlashAccSmmCommReadyProtocolGuid = { 0x9f373486, 0xda76, 0x4c9f, { 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } }
+ gAmdPspFtpmProtocolGuid = { 0xac234e04, 0xb036, 0x476c, { 0x91, 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } }
+
+[Ppis]
+ gAmdPspFtpmPpiGuid = { 0x91774185, 0xf72d, 0x467e, { 0x93, 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } }
+ gAmdPspFtpmFactoryResetPpiGuid = { 0x9c98130a, 0x8921, 0x45eb, { 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } }
diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/AgesaPkg.dec
new file mode 100644
index 0000000000..9377c64cc3
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
@@ -0,0 +1,435 @@
+## @file
+# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
+# file.
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPkg
+ PACKAGE_GUID = DABFEFC6-5A79-444b-862A-1F6FE9F561FE
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaPkgTokenSpaceGuid = { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0, 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } }
+
+[Protocols]
+ gAmdNbioCxlServicesProtocolGuid = {0x125CCFCE, 0x34AF, 0x422C, {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}}
+ gAmdPciResourceProtocolGuid = {0x663d4897, 0xed94, 0x4f0f, {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}}
+ gAmdCapsuleSmmHookProtocolGuid = {0x4fc43bbe, 0x1433, 0x4951, {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}}
+ gAmdFspSetupTableInitDoneGuid = {0xef5394c6, 0x566d, 0x440f, {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}}
+
+[Ppis]
+ gAmdMemoryInfoHobPpiGuid = {0xba16e587, 0x1d66, 0x41b7, {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
+ gCapsuleUpdateDetectedPpiGuid = {0x745dfc73, 0xc401, 0x4ced, {0x8d, 0x3b, 0x1a, 0x82, 0xf3, 0xda, 0xdc, 0xf8}}
+
+[PcdsFixedAtBuild]
+
+ ### @brief Enable EDK-II Protocols
+ ### @details This item enables support for EDKII implementation of ACPI Protocols when set to TRUE
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCompliantEdkIIAcpiSdtProtocol|TRUE|BOOLEAN|0x00020006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize |0x1000|UINT32|0x00020007
+
+ ### @brief assign non volatile storage base address
+ ### @details This assigns the base address to map to flash deivce.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF000000|UINT32|0x00020017
+
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH.h"
+#----------------------------------------------------------------------------
+
+ ### @name General FCH Controls
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1 register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0400)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1EvtBlkAddr|0x400|UINT16|0x0002F004
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1Cnt register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0404)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1CntBlkAddr|0x404|UINT16|0x0002F005
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM Timer as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0408)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPmTmrBlkAddr|0x408|UINT16|0x0002F006
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI CPU Control block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0410)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgCpuControlBlkAddr|0x410|UINT16|0x0002F007
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI GPE0 register block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0420)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|UINT16|0x0002F008
+
+ ### @brief This item defines the SMI command value sent by the host BIOS during the S3 resume sequence, to re-initialize the
+ ### FCH registers. This must be issued before the platform driver restore function is started.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD3)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemBeforePciRestoreSwSmi|0xD3|UINT8|0x0002F010
+
+ ### @brief This item defines the SMI command used by the host BIOS to signal the FCH driver that the platform driver has
+ ### completed its restore function. This allows the FCH driver to perform some final FCH settings.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD4)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|UINT8|0x0002F011
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to activate ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemEnableAcpiSwSmi|0xA0|UINT8|0x0002F012
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to turn off ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA1)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemDisableAcpiSwSmi|0xA1|UINT8|0x0002F013
+
+ ### @brief SMI command used for releasing the SPI controller lock mode. All devices on the SPI bus will be writable.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAA)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiUnlockSwSmi|0xAA|UINT8|0x0002F014
+
+ ### @brief SMI command for setting the lock mode in the SPI controller. This will effectively provide a write protection to the
+ ### SPI Flash ROM; however, write access to secondary SPI devices will also be blocked.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAB)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x0002F015
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH-IRQ.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart0Irq|0x03|UINT8|0x0002F01A
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart1Irq|0x0E|UINT8|0x0002F01B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart2Irq|0x05|UINT8|0x0002F01C
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart3Irq|0x0F|UINT8|0x0002F01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart4Irq|0x10|UINT8|0x0002F01E
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c0Irq|0x0A|UINT8|0x0002F01F
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c1Irq|0x0B|UINT8|0x0002F020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c2Irq|0x04|UINT8|0x0002F021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c3Irq|0x06|UINT8|0x0002F022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c4Irq|0x16|UINT8|0x0002F023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c5Irq|0x17|UINT8|0x0002F024
+#- DF Fixed PCDs
+#-
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+ #Fabric
+
+ ### @name General DF Controls
+
+ ### @brief This item informs the SMBios generation code as to how many physical processor sockets exist in the system and
+ ### therefore how many Type 4 SMBios records to produce.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x01)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdNumberOfPhysicalSocket|1|UINT8|0x000CC103
+#----------------------------------------------------------------------------
+#- CCX Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-MTRR.h"
+#----------------------------------------------------------------------------
+
+
+ ### @brief The base address of temporary page table for accessing PCIE MMIO base address above 4G in PEI phase.
+ ### @brief Permitted Choices: 0x0 - 0xFFFFFFFF (Type: Value)(Default: 0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPeiTempPageTableBaseAddress|0|UINT32|0x000CC11B
+
+#----------------------------------------------------------------------------
+#- CCX ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-ACPI.h"
+#----------------------------------------------------------------------------
+ #ACPI
+ # Cpu SSDT
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName0|0x43|UINT8|0x000AC001
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName1|0x30|UINT8|0x000AC002
+ ### @brief This element specifies whether the ACPI _PSS objects are defined in the system bus or processor scope.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li TRUE - The objects will be under the \_SB scope.
+ ### @li FALSE - The objects will be under the \_PR scope
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeInSb|FALSE|BOOLEAN|0x000AC003
+
+ ### @brief Set the OEM ID field in ACPI table outputs to this string. The string must conform to the ACPI rules for the OEM ID field.
+ ### @brief Permitted Choices: (Type: Value)(Default: "AMD")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|VOID*|0x000AC004
+
+#----------------------------------------------------------------------------
+#- CCX SMBIOS Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-SMBIOS.h"
+#----------------------------------------------------------------------------
+
+ ### @name CCX SMBIOS Controls
+
+ ### @brief When creating the SMBios table entry, use this as the label for the processor socket. This should match the
+ ### silkscreen label on the motherboard.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|"Unknown"|VOID*|0x00001001
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'serial number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket0|"Unknown"|VOID*|0x00001002
+
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Asset Tag' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket0|"Unknown"|VOID*|0x00001003
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Part Number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unknown"|VOID*|0x00001004
+
+ ### @brief SMBios socket 1 Label.
+ ### @details When creating the SMBios table entry, use this as the label for the
+ ### processor socket. This should match the silkscreen label on the motherboard.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|"Unknown"|VOID*|0x00001005
+
+ ### @brief SMBIOS socket 1 Serial Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'serial number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket1|"Unknown"|VOID*|0x00001006
+
+ ### @brief SMBios socket 1 Asset Tag.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Asset Tag' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket1|"Unknown"|VOID*|0x00001007
+
+ ### @brief Socket 1 Part Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Part Number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket1|"Unknown"|VOID*|0x00001008
+
+#----------------------------------------------------------------------------
+#- ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-ACPI.h"
+#----------------------------------------------------------------------------
+
+ ### @name General ACPI Controls
+
+ ### @brief PCD supporting maximum capacity for Type 16 table
+ ### @details This PCD represents maximum memory capacity in KB
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT16MaximumCapacity|0x04000000|UINT32|0x00001009 # 4G - 0x00400000
+ # 8G - 0x00800000
+ # 16G - 0x01000000
+ # 32G - 0x02000000
+ # 64G - 0x04000000
+ # 128G - 0x08000000
+ # 256G - 0x10000000
+ # 512G - 0x20000000
+[PcdsDynamic]
+#----------------------------------------------------------------------------
+# System level Dynamic PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCStateIoBaseAddress|0x413|UINT16|0x000CC002
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x000CC00B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x000CC200
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerInSb|FALSE|BOOLEAN|0x000CC50B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerName|"PLTF"|VOID*|0x000CC50C
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEAN|0x000CC601
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16|0x000CC900
+#----------------------------------------------------------------------------
+#- DF Dynamic PCDs
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+
+ ### @cond (FF3||RN||BA||ZP||RMB||RPL||RS||SSP||MI3||BRH)
+ ### @brief Specifies the top address to be used for MMIO space allocations. No MMIO space will be used above this limit. Some devices have limits on the address space they
+ ### are able to access. For example a device with a 40-bit address limitation can not use MMIO space above 1TeraByte (1T). By setting this PCD to 0x10000000000 (1T), MMIO
+ ### space would not be allocated above 1T. The default is to use all of the space above the end of physical memory.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMmioAbove4GLimit|0xFFFFFFFFFFFFFFFF|UINT64|0x0003FFC2
+ ### @endcond
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFabricResourceDefaultSizePtr|0|UINT64|0x00DF0000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UINT16|0x0003FFC0
+
+ ### I2C-0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UINT32|0x000FC000
+ ### I2C-1
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UINT32|0x000FC001
+ ### I2C-2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UINT32|0x000FC002
+ ### I2C-3
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UINT32|0x000FC003
+ ### I2C-4
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UINT32|0x000FC004
+ ### I2C-5
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UINT32|0x000FC005
+ ### @} end of I2C hold times
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-UART.h"
+#----------------------------------------------------------------------------
+ ### @name UART Legacy IO Assignments
+ ### @{
+ ### @brief These controls allow the platform to specify the legacy IO ranges that are to be used by the UART ports in the processor. Permitted Choices: (Type: value)(Default: Disabled)
+ ### @li 0 - Disabled
+ ### @li 1 - IO range 0x02E8 - 0x02EF
+ ### @li 2 - IO range 0x02F8 - 0x02FF
+ ### @li 3 - IO range 0x03E8 - 0x03EF
+ ### @li 4 - IO range 0x03F8 - 0x03FF
+
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart0LegacyEnable|0x00|UINT8|0x000FC010
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart1LegacyEnable|0x00|UINT8|0x000FC011
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart2LegacyEnable|0x00|UINT8|0x000FC012
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart3LegacyEnable|0x00|UINT8|0x000FC013
+ ### @} end UART Legacy IO assignments
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-USB.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci0Enable|TRUE|BOOLEAN|0x000FC020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci1Enable|TRUE|BOOLEAN|0x000FC021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci2Enable|TRUE|BOOLEAN|0x000FC022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci3Enable|TRUE|BOOLEAN|0x000FC023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhciECCDedErrRptEn|FALSE|BOOLEAN|0x000FC024
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC030
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN|0x000FC039
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x000A6024
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO-BMC.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN|0x0004F004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x0004F005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkDie|0xFF|UINT8|0x0004F006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkLaneNum|0|UINT8|0x0004F03E
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgIommuSupport|TRUE|BOOLEAN|0x0004F027
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdIvInfoDmaReMap|FALSE|BOOLEAN|0x0004F028
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrVddfull_Scale_Current|0x00|UINT32|0x0004F0A0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Current|0x00|UINT32|0x0004F0A2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0x0004F210
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT32|0x0004F211
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT8|0x0004F362
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|UINT8|0x0004F363
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs DYNAMIC
+
+ ### @brief This feature selects the APCB recovery support on x86 side. If or when an instance of a writable APCB is determined to be invalid, the PSP driver will
+ ### attempt a 'recovery' by copying the recovery instance of the APCB (default values as indicated in the APCB descriptor files). Upon boot up, the ABL reads CMOS
+ ### bytes 06/07 at index/data port of 0x72/0x73. If the CMOS flag reads anything else other than 0xA55A or 0x5555, the system boots in APCB recovery mode, in which
+ ### ABL consumes the recovery instances of APCB. Otherwise it boots in normal/non-recovery mode.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE)
+ ### @brief This feature is affected by the platform CMOS power design. Please see Platform CMOS power .
+ ### @li TRUE - the AGESA PSP driver restores the APCB instances from the recovery instance, writes 0xA55A to the CMOS location and triggers a reset . The next time
+ ### the system powers up, ABL runs in normal/non-recovery mode.
+ ### @li FALSE - the AGESA PSP driver writes 0x5555 to the CMOS location without restoring the APCB instances or triggering a reset. In this mode the additional reset
+ ### is avoided at the potential risk of the writeable APCB instance being left corrupted forever.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|BOOLEAN|0x95940008
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE|BOOLEAN|0x95940018
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x00030004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BOOLEAN|0x00030005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BOOLEAN|0x00030006
+[PcdsDynamicEx]
+
+[PcdsFixedAtBuild, PcdsDynamic]
+#----------------------------------------------------------------------------
+#- System control PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ ### @brief Switch for Debug Print function
+ ### @details Switch for Debug Print function to enable or not.
+ ### @li TRUE: Enable IdsDebugPrint output
+ ### @li FALSE: Disable IdsDebugPrint output
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEnable|FALSE|BOOLEAN|0x00020004
+ ### @brief Specify the filter for IdsDebugPrint
+ ### @details When the filter values are matched, the AmdIdsDebugPrint can start to print debug message.
+ ### Refer Library/IdsLib.h for details, and the Master token is PcdAmdIdsDebugPrintEnable.
+ ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ ### @li 0x100401008A300408: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintFilter|0x100401030A300408|UINT64|0x00020005
+ ### @brief Switch for Serial port support of AGESA debug print
+ ### @details Switch for Serial port support of AGESA debug print, NOTE, AGESA will not init the serial port,
+ ### serial port should be initialized before call AGESA debug print.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortEnable|FALSE|BOOLEAN|0x00020009
+ ### @brief The serial port used for debug output can be either 2-wire (Rx/Tx) or 4-wire (adding DSR/CTS). Waiting for CTS on a
+ ### 2-wire port would cause a hang. This control is added to check the cable connection.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li FALSE - Presume a 2-wire port and do not wait for CTS.
+ ### @li TRUE - Wait for both DSR and CTS to be set. DSR is set if a cable is connected. CTS is set if it is ok to transmit data.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCableConnection|FALSE|BOOLEAN|0x0002000A
+
+ ### @brief Selection of UART and UART Legacy IO Serial port for AGESA debug print
+ ### @details Selection of UART and UART Legacy IO Serial port for AGESA debug print and invisible in ACPI name space.
+ ### @li Bit[0]: Select UART0 for AGESA debug print
+ ### @li Bit[1]: Select UART1 for AGESA debug print
+ ### @li Bit[2]: Select UART2 for AGESA debug print
+ ### @li Bit[3]: Select UART3 for AGESA debug print
+ ### @li Bit[4]: Select UART4 for AGESA debug print
+ ### @li Bit[8]: Select UART0 Legacy IO for AGESA debug print
+ ### @li Bit[9]: Select UART1 Legacy IO for AGESA debug print
+ ### @li Bit[10]: Select UART2 Legacy IO for AGESA debug print
+ ### @li Bit[11]: Select UART3 Legacy IO for AGESA debug print
+ ### @li Bit[15]: Set debug print serial port to invisible in ACPI name space at OS runtime
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortSelect|0x0000|UINT16|0x0002718A
+
+ ### @brief Specify the IO port for serial out
+ ### @details ESPI or LPC COM1: 0x3F8, COM2: 0x2F8, COM3: 0x3E8, COM4: 0x2E8,
+ ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000, UART3: 0xFEDCF000, UART4: 0xFEDD1000.
+ ### @li If it's IO port: it must < 0x10000
+ ### @li If it's Memory: it must >= 0x10000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UINT64|0x0002000B
+
+ ### @brief Debug Print Emulation Auto Detect
+ ### @details Auto detect emulation platform to instead of PcdAmdIdsDebugPrintRedirectIOEnable and
+ ### PcdAmdIdsDebugPrintSerialPortEnable.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetect|FALSE|BOOLEAN|0x00020016
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgPlatformPPT|0|UINT32|0x0004F111
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs
+
+ ### @brief Rom Armor selection
+ ### @details Rom Armor selection
+ ### @li 0: Rom Armor is disabled
+ ### @li 1: Rom Armor 1 is enabled (VMR/MTS/CPK)
+ ### @li 2: Rom Armor 2 is enabled (RN/CZN)
+ ### @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
+ ### @li 0x1: PSP fTPM
+ ### @li 0x2: HSP fTPM
+ ### @li 0xFF: no TPM
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8|0x95940024
+
+ ### @cond !BRH
+ ### @brief TPM SMx algorithm flag
+ ### @details TPM SMx algorithm flag, SBIOS needs to set the value in PEI phase.
+ ### @li 0: SM2, SM3 or SM4 crypto algorithms not supported
+ ### @li 1: SM2, SM3 or SM4 crypto algorithms supported
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmAlgSmx|0|UINT8|0x95940025
+ ### @endcond
diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
new file mode 100755
index 0000000000..c8c474637f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
@@ -0,0 +1,41 @@
+## @file
+# AMD Common Platform Module (CPM) Module Package DEC.
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = CpmPkg
+ PACKAGE_GUID = ABE128BA-1061-4A53-A1B8-D07329AA7A67
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+ Library
+
+[Guids]
+ gAmdCpmPkgTokenSpaceGuid = {0x916e0ddd, 0x2bd2, 0x4704, {0x93, 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}}
+ gShellActHiiGuid = {0x340EBE97, 0x3C1C, 0x4272, {0x9C, 0xCE, 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}}
+ gAmdPbsSystemConfigurationGuid = {0xa339d746, 0xf678, 0x49b3, {0x9f, 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}}
+
+[Protocols]
+ gAmdCpmTableProtocolGuid = { 0x3724cf01, 0x00c2, 0x9762, {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }}
+ gAmdCpmAllPciIoProtocolsInstalledProtocolGuid = { 0x676D7012, 0x139B, 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }}
+
+[Ppis]
+ gAmdCpmTablePpiGuid = { 0xd71cf893, 0xa8b5, 0x49d3, { 0xa2, 0x1b, 0x31, 0xe2, 0xf5, 0xc4, 0xa7, 0x47 } }
+
+[PcdsFixedAtBuild]
+ gAmdCpmPkgTokenSpaceGuid.PcdFchUartPort|2|UINT8|0x00000052
+
+ #ACPI
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiHestTableHeaderOemTableId|"AMD HEST"|VOID*|0x000AC001
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiBertTableHeaderOemTableId|"AMD BERT"|VOID*|0x000AC002
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiEinjTableHeaderOemTableId|"AMD EINJ"|VOID*|0x000AC003
+
+ gAmdCpmPkgTokenSpaceGuid.UsePciXAslName|FALSE|BOOLEAN|0x12000003
+ gAmdCpmPkgTokenSpaceGuid.AcpiRestoreSwSmi|0xE3|UINT8|0x00000040
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
new file mode 100644
index 0000000000..37b8d15cb1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
@@ -0,0 +1,18 @@
+## @file
+#
+# 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[LibraryClasses]
+ NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+
+ ## Gnb Lib
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
new file mode 100644
index 0000000000..e7e05fd2d8
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
@@ -0,0 +1,48 @@
+## @file
+# The AGESA DSC file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[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
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+
+ ## DF Lib
+ BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
+
+ ## Gnb Lib
+ 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
+
+ ## Fch Lib
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+
+[Components.IA32]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+
+[Components.X64]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
new file mode 100644
index 0000000000..1f1e04c414
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..2916fecb26
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
@@ -0,0 +1,11 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEFINE AGESA_PKG_PATH = AgesaModulePkg
+ DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
new file mode 100644
index 0000000000..9303d1fac4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
@@ -0,0 +1,11 @@
+## @file
+# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+## APCB V3 Dxe Drivers
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
new file mode 100644
index 0000000000..0ef5a2a806
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
@@ -0,0 +1,9 @@
+## @file
+# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..b790e4ead5
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Platform Package Flash Description File
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100755
index 0000000000..8d3357bf56
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdCalloutLib
+ FILE_GUID = A8FEA621-B381-4c06-9E9D-0897EF78BD78
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdCalloutLib
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
new file mode 100644
index 0000000000..1594a99265
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
@@ -0,0 +1,30 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
new file mode 100644
index 0000000000..c685a26604
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLib
+ FILE_GUID = 55871F80-4658-6EF3-A8AC-15B34FF8C2CE
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLib
+
+[Sources.common]
+ AmdPspRomArmorLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
new file mode 100644
index 0000000000..a3906dc13e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLibNull
+ FILE_GUID = 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLibNull
+
+[Sources.common]
+ AmdPspRomArmorLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
new file mode 100644
index 0000000000..09d5bd38ac
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
@@ -0,0 +1,37 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3
+ 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
+
+[Sources.common]
+ ApcbLibV3.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSmmReadyToLockProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
new file mode 100644
index 0000000000..c031d00d79
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3Pei
+ FILE_GUID = EEA4E007-E408-4daa-82BD-4C52E7058753
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ApcbLibV3Pei|PEIM
+
+[Sources.common]
+ ApcbLibV3Pei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseMemoryLib
+ PeiServicesLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
new file mode 100644
index 0000000000..38a72e26b7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# For EDKII use Only
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseFabricTopologyRsLib
+ FILE_GUID = D0A070DD-630A-43F8-9D76-EAAABDDE5FB9
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseFabricTopologyLib
+ CONSTRUCTOR = BaseFabricTopologyLibConstructor
+
+[Sources]
+ BaseFabricTopologyRsLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+
+[LibraryClasses]
+ BaseLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
new file mode 100644
index 0000000000..d15d8169fe
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
@@ -0,0 +1,35 @@
+## @file
+# Base Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseTscTimerLib
+ FILE_GUID = D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ BaseTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
new file mode 100644
index 0000000000..1e52768a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Dxe Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTscTimerLib
+ FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeTscTimerLibConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ DxeTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ PcdLib
+ BaseLib
+ UefiLib
+ DebugLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
new file mode 100644
index 0000000000..b1eaefd282
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Pei Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTscTimerLib
+ FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|PEIM PEI_CORE
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ PeiTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+ HobLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644
index 0000000000..f60f97905a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Library instance of PciHostBridgeLib library class for coreboot.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciHostBridgeLib
+ FILE_GUID = 74967FD7-A9A4-4B16-8B41-B26BC3230D0A
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciHostBridgeLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ PciHostBridgeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ PciHostBridgeLib
+ DevicePathLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
new file mode 100644
index 0000000000..2a72fa8117
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -0,0 +1,47 @@
+## @file
+#
+# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseLib/FchBaseLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
new file mode 100644
index 0000000000..e63a70e849
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseResetSystemLib/FchBaseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
new file mode 100644
index 0000000000..e422cb69a4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
@@ -0,0 +1,35 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = BaseResetSystemLib
+ FILE_GUID = e669c365-2df2-4540-a343-afec4e85b198
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseResetSystemLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ FchBaseResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PrintLib
+ IoLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
new file mode 100644
index 0000000000..d7f49c40de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
new file mode 100755
index 0000000000..f32bbc9ff2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
@@ -0,0 +1,24 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioHandleLib
+ FILE_GUID = DC4639D3-DB75-486B-AC38-C84AA49601E3
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioHandleLib
+
+[Sources]
+ NbioHandleLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
new file mode 100755
index 0000000000..0d6ba605f5
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PcieConfigLib
+ FILE_GUID = C1205AD2-FE67-4502-A0A7-FB1704A3F9AE
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PcieConfigLib
+
+[Sources]
+ PcieConfigLib.c
+ PcieInputParserLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
new file mode 100644
index 0000000000..ae1dd6cd83
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmnAccessLib
+ FILE_GUID = 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmnAccessLib
+
+[Sources]
+ SmnAccessLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ PrintLib
+ BaseLib
+ DebugPrintErrorLevelLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
new file mode 100644
index 0000000000..da7f5c185d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioCommonDxeLib
+ FILE_GUID = 1BF93335-5D55-46D9-99D9-5D962F039829
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioCommonDxeLib
+
+[Sources]
+ DxeLibFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ BaseLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
new file mode 100644
index 0000000000..54c3514020
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbDxeV3
+ FILE_GUID = 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3DxeDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ DxeServicesTableLib
+ MemoryAllocationLib
+ ApcbLibV3
+
+[Sources]
+ ApcbV3Dxe.c
+
+[Protocols]
+ gEfiDxeSmmReadyToLockProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
new file mode 100644
index 0000000000..7f90aa6ea0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbPeiV3
+ FILE_GUID = E1B8CF4A-FE7B-4676-B4F7-50C7228282A4
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3PeiDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PeimEntryPoint
+ ApcbLibV3Pei
+
+[sources]
+ ApcbV3Pei.c
+
+[Depex]
+ TRUE
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
new file mode 100755
index 0000000000..0f115c362e
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = OemAgesaCcxPlatformLibNull
+ FILE_GUID = B1F58B07-0146-4804-B701-A56CB5716529
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = OemAgesaCcxPlatformLib
+
+[Sources.common]
+ OemAgesaCcxPlatformLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
new file mode 100644
index 0000000000..ba551e5c14
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
@@ -0,0 +1,61 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciCfg2
+ FILE_GUID = 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PeimInitializePciCfg
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
+#
+
+[Sources]
+ PciExpressPciCfg2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+
+[LibraryClasses]
+ PeimEntryPoint
+ BaseLib
+ PcdLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ HobLib
+ IoLib
+
+[Ppis]
+ gEfiPciCfg2PpiGuid ## PRODUCES
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
+[Pcd.IA32,Pcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES
+
+[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
new file mode 100644
index 0000000000..e712a80886
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciSegmentInfoLib
+ FILE_GUID = FA8B1082-88DF-4744-85A3-7F87A9EBF8DC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciSegmentInfoLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ PciSegmentInfoLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
new file mode 100644
index 0000000000..f4b9d0d789
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspFlashAccLibSmm
+ FILE_GUID = 3BBDC3A5-A0E2-4E8A-8240-9E594920F040
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspFlashAccLib | DXE_SMM_DRIVER
+
+[Sources.common]
+ AmdPspFlashAccSpiNorLibSmm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ AmdPspBaseLibV2
+ BaseLib
+ DebugLib
+ SmmServicesTableLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSpiSmmNorFlashProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize ## CONSUMES
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ## CONSUMES
+
+[Depex]
+ gEfiSmmBase2ProtocolGuid AND
+ gEfiSpiSmmNorFlashProtocolGuid
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
new file mode 100644
index 0000000000..57bb0d9e25
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = PspRomArmorWhitelistLib
+ FILE_GUID = B6F8507A-C96B-4036-A8C0-26BAD6AC5F34
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformPspRomArmorWhitelistLib
+
+[Sources]
+ PspRomArmorWhitelistLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ MemoryAllocationLib
+ PcdLib
+ DebugLib
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
new file mode 100644
index 0000000000..64fd2913ad
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
@@ -0,0 +1,42 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+
+
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
new file mode 100644
index 0000000000..f4d7638c1a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
new file mode 100644
index 0000000000..973ace8632
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
new file mode 100644
index 0000000000..2d9dbeb715
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
@@ -0,0 +1,53 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+ UNLOAD_IMAGE = ActLibraryUnregisterActCommand
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ UefiLib
+ FileHandleLib
+ HiiLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+
+[Guids]
+ gShellActHiiGuid ## SOMETIMES_CONSUMES ## HII
+ gAgesaConfigDbPointerVariableGuid
+
+[Protocols]
+ gEfiShellDynamicCommandProtocolGuid
+ gEfiHiiPackageListProtocolGuid
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[DEPEX]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
new file mode 100644
index 0000000000..98c8755ab8
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
@@ -0,0 +1,50 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoToolApp.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ FileHandleLib
+ HiiLib
+ MemoryAllocationLib
+ UefiApplicationEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+ UefiLib
+ UefiRuntimeServicesTableLib
+
+[Protocols]
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[Guids]
+
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
new file mode 100644
index 0000000000..9c3c0dd0a9
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BasePlatformHookLibAmdFchUart
+ FILE_GUID = BF2F3F3F-4BE6-4B97-850D-D5D4941D391C
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformHookLib
+
+[Sources]
+ BasePlatformHookLibAmdFchUart.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ IoLib
+ PlatformHookLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
new file mode 100644
index 0000000000..3ec03aafd3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AGESA_H_
+#define AGESA_H_
+
+#include "AMD.h"
+#include "SocLogicalId.h"
+
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+#define DESCRIPTOR_INITIALIZE_LIST 0x20000000ull
+
+/// PCIe link initialization
+typedef enum {
+ EndpointDetect = 0, ///< Detect endpoint presence
+ EndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} PCIE_ENDPOINT_STATUS;
+
+/// PCIe port misc extended controls
+typedef struct {
+ IN UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ IN UINT8 LinkSafeMode : 2; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through PCIe_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertise maximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 2; ///< Unused space
+} PCIE_PORT_MISC_CONTROL;
+
+/// The IO APIC Interrupt Mapping Info
+typedef struct {
+ IN UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ IN UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< - ABCD
+ ///< - BCDA
+ ///< - CDAB
+ ///< - DABC
+ IN UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< - Entry 0 of IO APIC redirection table
+ ///< - Entry 1 of IO APIC redirection table
+ ///< - Entry 31 of IO APIC redirection table
+} APIC_DEVICE_INFO;
+
+/// GEN3 RxAdaptMode Configuration Structure
+typedef struct {
+ IN BOOLEAN InitOffsetCancellation; ///< Initial Offset Cancellation Enable
+ IN UINT8 DFEControl; ///< DFE Control
+ IN UINT8 LEQControl; ///< LEQ Control
+ IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic Offset Calibration Enable
+ IN BOOLEAN FOMCalculation; ///< FOM Calculation Enable
+ IN BOOLEAN PIOffsetCalibration; ///< PI Offset Calibratino Enable
+} RX_ADAPT_MODE;
+
+/// PCIe port configuration data
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 ChannelType; ///< Channel type.
+ ///< 0 - "lowLoss",
+ ///< 1 - "highLoss",
+ ///< 2 - "mob0db",
+ ///< 3 - "mob3db",
+ ///< 4 - "extnd6db"
+ ///< 5 - "extnd8db"
+ IN UINT8 DeviceNumber; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 FunctionNumber; ///< Reserved for future use
+ IN UINT8 LinkSpeedCapability; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT8 ResetId; ///< Arbitrary number greater than 0 assigned by platform firmware for GPIO
+ ///< identification which control reset for given port.
+ ///< Each port with unique GPIO should have unique ResetId assigned.
+ ///< All ports use same GPIO to control reset should have same ResetId assigned.
+ ///< see AgesaPcieSlotResetContol.
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3 RxAdaptMode configuration
+} PCIE_PORT_DATA;
+
+/// PCIe Complex descriptor
+typedef struct {
+ IN UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ IN UINT32 SocketId; ///< Socket Id
+ IN VOID *Reserved; ///< Reserved for future use
+} PCIE_COMPLEX_DESCRIPTOR;
+
+/// VBIOS image info
+typedef struct {
+ IN AMD_CONFIG_PARAMS StdHeader; ///< Standard configuration header
+ OUT VOID *ImagePtr; ///< Pointer to VBIOS image
+ IN PCI_ADDR GfxPciAddress; ///< PCI address of integrated graphics controller
+ IN UINT32 Flags; ///< BIT[0] - special repost requred
+} GFX_VBIOS_IMAGE_INFO;
+
+//
+// CPU MSR Register definitions
+//
+#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture Programming manual.
+#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture Programming manual.
+#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture Programming manual.
+
+///
+/// VDDP_VDDR Voltage Info for Low Power DIMM
+///
+typedef struct _VDDP_VDDR_VOLTAGE {
+ IN BOOLEAN IsValid; ///< Indicates if daata is valid
+ IN UINT8 Voltage; ///< VDDP VDDR Voltage Value
+} VDDP_VDDR_VOLTAGE;
+
+// CPU Build Configuration structures and definitions
+
+#define AMD_AP_MTRR_FIX64k_00000 0x00000250ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to AMD64 Architecture Programming manual
+
+#endif // AGESA_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/AgesaModulePkg/Include/AMD.h
new file mode 100755
index 0000000000..062d9e1e1a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
@@ -0,0 +1,91 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_H_
+#define AMD_H_
+
+/// The return status for all AGESA public services.
+///
+/// Services return the most severe status of any logged event. Status other than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
+/// will have log entries with more detail.
+///
+typedef enum {
+ AGESA_SUCCESS = 0, ///< 0 - The service completed normally. Info may be logged.
+ AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct had an unimplemented function requested.
+ ///< Not logged.
+ AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of range and the service was not provided.
+ ///< Example, memory address not installed, heap buffer handle not found.
+ ///< Not Logged.
+ AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP communications (used in ABL)
+ AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in ABL)
+
+ // AGESA_STATUS of greater severity (the ones below this line), always have a log entry available.
+ AGESA_ALERT, ///< 5 - An observed condition, but no loss of function. See Log.
+ AGESA_WARNING, ///< 6 - Possible or minor loss of function. See Log.
+ AGESA_ERROR, ///< 7 - Significant loss of function, boot may be possible. See Log.
+ AGESA_CRITICAL, ///< 8 - Continue boot only to notify user. See Log.
+ AGESA_FATAL, ///< 9 - Halt booting. See Log, however Fatal errors pertaining to heap problems
+ ///< may not be able to reliably produce log events.
+ AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory Overclock failure. (used in ABL)
+ AGESA_SKIP_ERROR, ///< 11 - Error, Skip init steps. (used in ABL)
+ AgesaStatusMax ///< Not a status, for limit checking.
+} AGESA_STATUS;
+
+/**
+ Callout method to the host environment.
+
+ Callout using a dispatch with appropriate thunk layer, which is determined by the host environment.
+
+ @param[in] Function The specific callout function being invoked.
+ @param[in] FcnData Function specific data item.
+ @param[in,out] ConfigPtr Reference to Callout params.
+**/
+typedef AGESA_STATUS (*CALLOUT_ENTRY) (
+ IN UINT32 Function,
+ IN UINTN FcnData,
+ IN OUT VOID *ConfigPtr
+ );
+
+/// AGESA Structures
+
+/// Extended PCI address format
+typedef struct {
+ IN OUT UINT32 Register : 12; ///< Register offset
+ IN OUT UINT32 Function : 3; ///< Function number
+ IN OUT UINT32 Device : 5; ///< Device number
+ IN OUT UINT32 Bus : 8; ///< Bus number
+ IN OUT UINT32 Segment : 4; ///< Segment
+} EXT_PCI_ADDR;
+
+/// Union type for PCI address
+typedef union _PCI_ADDR {
+ IN UINT32 AddressValue; ///< Formal address
+ IN EXT_PCI_ADDR Address; ///< Extended address
+} PCI_ADDR;
+
+///
+/// The standard header for all AGESA services.
+///
+typedef struct {
+ IN UINT32 ImageBasePtr; ///< The AGESA Image base address.
+ IN UINT32 Func; ///< The service desired
+ IN UINT32 AltImageBasePtr; ///< Alternate Image location
+ IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
+ IN UINT8 HeapStatus; ///< For heap status from boot time slide.
+ IN UINT64 HeapBasePtr; ///< Location of the heap
+ IN OUT UINT8 Reserved[7]; ///< This space is reserved for future use.
+} AMD_CONFIG_PARAMS;
+
+/// CPUID data received registers format
+typedef struct {
+ OUT UINT32 EAX_Reg; ///< CPUID instruction result in EAX
+ OUT UINT32 EBX_Reg; ///< CPUID instruction result in EBX
+ OUT UINT32 ECX_Reg; ///< CPUID instruction result in ECX
+ OUT UINT32 EDX_Reg; ///< CPUID instruction result in EDX
+} CPUID_DATA;
+#endif // AMD_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
new file mode 100755
index 0000000000..534b03d4a7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
@@ -0,0 +1,15 @@
+/** @file
+ AMD CPU Register Table Related Functions.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_H_
+#define CPU_REGISTERS_H_
+
+#include <CpuRegistersDef.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
new file mode 100644
index 0000000000..e086a4c9b1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
@@ -0,0 +1,61 @@
+/** @file
+ AMD Psp Directory header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_DIR_H_
+#define AMD_PSP_DIR_H_
+
+#pragma pack (push, 1)
+#define PSP_DIRECTORY_HEADER_SIGNATURE 0x50535024ul ///< $PSP
+#define PSP_LV2_DIRECTORY_HEADER_SIGNATURE 0x324C5024ul ///< $PL2
+
+/// Enum define various enum type for PSP entry type
+enum _PSP_DIRECTORY_ENTRY_TYPE {
+ PSP_REGION_A_DIR = 0x48, ///< PSP entry points to PSP DIR in Region A
+ PSP_REGION_B_DIR = 0x4A, ///< PSP entry points to PSP DIR in Region B
+};
+
+/// Define structure for PSP directory
+typedef struct {
+ UINT32 Cookie; ///< "$PSP"
+ UINT32 Checksum; ///< 32 bit CRC of header items below and the entire table
+ UINT32 TotalEntries; ///< Number of PSP Entries
+ UINT32 Reserved; ///< Unused
+} PSP_DIRECTORY_HEADER;
+
+/// Define structure for 32 bits Entry type field
+typedef struct {
+ UINT32 Type : 8; ///< Type of PSP Directory entry
+ UINT32 SubProgram : 8; ///< Specify the SubProgram
+ UINT32 RomId : 2; ///< Specify the ROM ID
+ UINT32 Reserved : 14; ///< Reserved
+} PSP_DIRECTORY_ENTRY_TYPE_FIELD;
+
+/// Define union type for 32 bits Entry type field
+typedef union {
+ PSP_DIRECTORY_ENTRY_TYPE_FIELD Field; ///< Definition of each filed
+ UINT32 Value; ///< Group it as 32bits Int
+} PSP_DIRECTORY_ENTRY_TYPE;
+
+/// Structure for PSP Entry
+typedef struct {
+ PSP_DIRECTORY_ENTRY_TYPE Type; ///< Type of PSP entry; 32 bit long
+ UINT32 Size; ///< Size of PSP Entry in bytes
+ UINT64 Location; ///< Location of PSP Entry (byte offset from start of SPI-ROM)
+} PSP_DIRECTORY_ENTRY;
+
+/// Structure for PSP directory
+typedef struct {
+ PSP_DIRECTORY_HEADER Header; ///< PSP directory header
+ PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PSP entries each pointing to a binary in SPI flash
+ ///< The actual size of this array comes from the
+ ///< header (PSP_DIRECTORY.Header.TotalEntries)
+} PSP_DIRECTORY;
+
+#pragma pack (pop)
+#endif //AMD_PSP_DIR_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
new file mode 100755
index 0000000000..faa8d35b1b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
@@ -0,0 +1,156 @@
+/** @file
+ AMD CPU Register Table Related Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_DEF_H_
+#define CPU_REGISTERS_DEF_H_
+
+#undef BIT0
+#undef BIT1
+#undef BIT2
+#undef BIT3
+#undef BIT4
+#undef BIT5
+#undef BIT6
+#undef BIT7
+#undef BIT8
+#undef BIT9
+#undef BIT10
+#undef BIT10
+#undef BIT11
+#undef BIT12
+#undef BIT13
+#undef BIT14
+#undef BIT15
+#undef BIT16
+#undef BIT17
+#undef BIT18
+#undef BIT19
+#undef BIT20
+#undef BIT21
+#undef BIT22
+#undef BIT23
+#undef BIT24
+#undef BIT25
+#undef BIT26
+#undef BIT27
+#undef BIT28
+#undef BIT29
+#undef BIT30
+#undef BIT31
+#undef BIT32
+#undef BIT33
+#undef BIT34
+#undef BIT35
+#undef BIT36
+#undef BIT37
+#undef BIT38
+#undef BIT39
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT50
+#undef BIT51
+#undef BIT52
+#undef BIT53
+#undef BIT54
+#undef BIT55
+#undef BIT56
+#undef BIT57
+#undef BIT58
+#undef BIT59
+#undef BIT60
+#undef BIT61
+#undef BIT62
+#undef BIT63
+
+#define BIT0 0x0000000000000001ull
+#define BIT1 0x0000000000000002ull
+#define BIT2 0x0000000000000004ull
+#define BIT3 0x0000000000000008ull
+#define BIT4 0x0000000000000010ull
+#define BIT5 0x0000000000000020ull
+#define BIT6 0x0000000000000040ull
+#define BIT7 0x0000000000000080ull
+#define BIT8 0x0000000000000100ull
+#define BIT9 0x0000000000000200ull
+#define BIT10 0x0000000000000400ull
+#define BIT11 0x0000000000000800ull
+#define BIT12 0x0000000000001000ull
+#define BIT13 0x0000000000002000ull
+#define BIT14 0x0000000000004000ull
+#define BIT15 0x0000000000008000ull
+#define BIT16 0x0000000000010000ull
+#define BIT17 0x0000000000020000ull
+#define BIT18 0x0000000000040000ull
+#define BIT19 0x0000000000080000ull
+#define BIT20 0x0000000000100000ull
+#define BIT21 0x0000000000200000ull
+#define BIT22 0x0000000000400000ull
+#define BIT23 0x0000000000800000ull
+#define BIT24 0x0000000001000000ull
+#define BIT25 0x0000000002000000ull
+#define BIT26 0x0000000004000000ull
+#define BIT27 0x0000000008000000ull
+#define BIT28 0x0000000010000000ull
+#define BIT29 0x0000000020000000ull
+#define BIT30 0x0000000040000000ull
+#define BIT31 0x0000000080000000ull
+#define BIT32 0x0000000100000000ull
+#define BIT33 0x0000000200000000ull
+#define BIT34 0x0000000400000000ull
+#define BIT35 0x0000000800000000ull
+#define BIT36 0x0000001000000000ull
+#define BIT37 0x0000002000000000ull
+#define BIT38 0x0000004000000000ull
+#define BIT39 0x0000008000000000ull
+#define BIT40 0x0000010000000000ull
+#define BIT41 0x0000020000000000ull
+#define BIT42 0x0000040000000000ull
+#define BIT43 0x0000080000000000ull
+#define BIT44 0x0000100000000000ull
+#define BIT45 0x0000200000000000ull
+#define BIT46 0x0000400000000000ull
+#define BIT47 0x0000800000000000ull
+#define BIT48 0x0001000000000000ull
+#define BIT49 0x0002000000000000ull
+#define BIT50 0x0004000000000000ull
+#define BIT51 0x0008000000000000ull
+#define BIT52 0x0010000000000000ull
+#define BIT53 0x0020000000000000ull
+#define BIT54 0x0040000000000000ull
+#define BIT55 0x0080000000000000ull
+#define BIT56 0x0100000000000000ull
+#define BIT57 0x0200000000000000ull
+#define BIT58 0x0400000000000000ull
+#define BIT59 0x0800000000000000ull
+#define BIT60 0x1000000000000000ull
+#define BIT61 0x2000000000000000ull
+#define BIT62 0x4000000000000000ull
+#define BIT63 0x8000000000000000ull
+
+#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO Configuration Base Address Register
+
+#endif // CPU_REGISTERS_DEF_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
new file mode 100644
index 0000000000..8ede1be838
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
@@ -0,0 +1,85 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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_TXBYTECOUNT 0x48 //
+#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 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/AgesaModulePkg/Include/Filecode.h b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
new file mode 100644
index 0000000000..726479d79f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * Collectively assign unique filecodes for assert and debug to each source file.
+ *
+ * Publish values for decorated filenames, which can be used for
+ * ASSERT and debug support using a preprocessor define like:
+ * @n <tt> _#define FILECODE MY_C_FILENAME_FILECODE </tt> @n
+ * This file serves as a reference for debugging to associate the code and filename.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: Include
+ * @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800 (Mon, 09 Feb 2015) $
+ */
+
+#ifndef _FILECODE_H_
+#define _FILECODE_H_
+
+#define UNASSIGNED_FILE_FILECODE (0xFFFF)
+
+#endif // _FILECODE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
new file mode 100755
index 0000000000..ddc9309d3d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_H_
+#define GNB_H_
+
+#define PVOID UINT64
+
+#endif // GNB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
new file mode 100644
index 0000000000..192e0d6a8b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
@@ -0,0 +1,521 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBDXIO_H_
+#define GNBDXIO_H_
+
+#pragma pack (push, 1)
+
+#include <AGESA.h>
+#include <Gnb.h>
+
+#define MAX_NUMBER_OF_COMPLEXES 16
+
+#define DESCRIPTOR_TERMINATE_GNB 0x40000000ull
+#define DESCRIPTOR_TERMINATE_TOPOLOGY 0x20000000ull
+#define DESCRIPTOR_ALLOCATED 0x10000000ull
+#define DESCRIPTOR_PLATFORM 0x08000000ull
+#define DESCRIPTOR_COMPLEX 0x04000000ull
+#define DESCRIPTOR_SILICON 0x02000000ull
+#define DESCRIPTOR_PCIE_WRAPPER 0x01000000ull
+#define DESCRIPTOR_PCIE_ENGINE 0x00800000ull
+#define DESCRIPTOR_CXL_ENGINE 0x00200000ull
+
+#define SILICON_CXL_CAPABLE 0x00008000ull
+
+#define DESCRIPTOR_ALL_WRAPPERS (DESCRIPTOR_PCIE_WRAPPER)
+#define DESCRIPTOR_ALL_ENGINES (DESCRIPTOR_PCIE_ENGINE | DESCRIPTOR_CXL_ENGINE)
+
+#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))
+
+typedef UINT16 PCIE_ENGINE_INIT_STATUS;
+
+///
+/// Engine Configuration
+///
+typedef struct {
+ IN UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ IN UINT16 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ IN UINT16 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+} PCIE_ENGINE;
+
+///
+/// PCIe port misc extended controls
+///
+typedef struct {
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 5; ///< Unused space
+} PORT_MISC_CONTROL;
+
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 FunctionNumber : 3; ///< Reserved for future use
+ IN UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 LinkSpeedCapability : 4; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm : 4; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN UINT8 Reserved1; ///< Reserved for future use
+} PORT_DATA;
+
+typedef struct {
+ UINT8 LinkSpeed;
+ UINT8 MaxPayloadSupport;
+ UINT8 AspmCapability;
+ UINT8 PciPmL1_1;
+ UINT8 PciPmL1_2;
+ UINT8 AspmL1_1;
+ UINT8 AspmL1_2;
+ UINT8 EsmSupport;
+ UINT8 LtrSupport;
+ UINT8 SurpriseDownErrorReport;
+ UINT8 TenBitTagSupport;
+ UINT8 AriForwarding;
+ UINT8 AcsSupport;
+ UINT8 AcsSourceValidation;
+ UINT8 AcsTranslationBlocking;
+ UINT8 AcsP2pRequestRedirect;
+ UINT8 AcsP2pCompletionRedirect;
+ UINT8 AcsUpstreamForwarding;
+ UINT8 AcsP2pEgressControl;
+ UINT8 AcsDirectTranslatedP2p;
+ UINT8 LaneMargining;
+ UINT8 DataLinkFeature;
+ UINT8 DownstreamPortContainment;
+ UINT8 AdvancedErrorReporting;
+ UINT8 ECRCSupport;
+ UINT8 MulticastEnable;
+ UINT8 NativePCIeEnclosureManagement;
+ UINT8 Capability1Address;
+ UINT8 Capability1Data;
+ UINT8 Capability2Address;
+ UINT8 Capability2Data;
+ UINT8 Capability3Address;
+ UINT8 Capability3Data;
+ UINT8 Capability4Address;
+ UINT8 Capability4Data;
+} PORT_CAPABILITIES;
+
+///
+/// PCIe PORT_FEATURES
+///
+typedef struct {
+ UINT8 LinkSpeedControl;
+ UINT8 MaxPayloadSizeControl;
+ UINT8 ESMControl;
+ UINT8 LTRControl;
+ UINT8 DataLinkFeatureExchangeControl;
+ UINT8 TenBitTagControl;
+ UINT8 ARIControl;
+ UINT8 ACSControl;
+ UINT8 RxLaneMarginingControl;
+ UINT8 DynLanesPwrState;
+ UINT8 L1PowerDown;
+ UINT8 L11PowerDown;
+ UINT8 L12PowerDown;
+ UINT8 AutoSpdChngEn;
+ UINT8 TurnOffUnusedLanes;
+} PORT_FEATURES;
+
+typedef struct {
+ UINT8 SpcGen1 : 1; ///< SPC Mode 2P5GT
+ UINT8 SpcGen2 : 1; ///< SPC Mode 5GT
+ UINT8 SpcGen3 : 2; ///< SPC Mode 8GT
+ UINT8 SpcGen4 : 2; ///< SPC Mode 16GT
+ UINT8 SpcGen5 : 2; ///< SPC Mode 32GT
+} SPC_MODE;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT32 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT32 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset Mask
+ UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnable
+ UINT32 UNUSED2 : 7; ///< Currently unassigned - for alignment
+} GEN3_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset Mask
+ UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEnable
+ UINT32 UNUSED3 : 13; ///< Currently unassigned - for alignment
+} GEN4_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset Mask
+ UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnable
+ UINT32 PrecodeRequest : 1; ///< Precoding Request
+ UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ To High Rate Support
+ UINT32 UNUSED4 : 11; ///< Currently unassigned - for alignment
+} GEN5_LANE_CNTL;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor0 : 5; ///< PostCursor0
+ UINT32 LcFapeReqPreCursor0 : 4; ///< PreCursor0
+ UINT32 LcFapeReqPostCursor1 : 5; ///< PostCursor1
+ UINT32 LcFapeReqPreCursor1 : 4; ///< PreCursor1
+ UINT32 LcFapeReqPostCursor2 : 5; ///< PostCursor2
+ UINT32 LcFapeReqPreCursor2 : 4; ///< PreCursor2
+ UINT32 UNUSED6 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_0;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor3 : 5; ///< PostCursor3
+ UINT32 LcFapeReqPreCursor3 : 4; ///< PreCursor3
+ UINT32 LcFapeReqPostCursor4 : 5; ///< PostCursor4
+ UINT32 LcFapeReqPreCursor4 : 4; ///< PreCursor4
+ UINT32 LcFapeReqPostCursor5 : 5; ///< PostCursor5
+ UINT32 LcFapeReqPreCursor5 : 4; ///< PreCursor5
+ UINT32 UNUSED7 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_1;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor6 : 5; ///< PostCursor6
+ UINT32 LcFapeReqPreCursor6 : 4; ///< PreCursor6
+ UINT32 LcFapeReqPostCursor7 : 5; ///< PostCursor7
+ UINT32 LcFapeReqPreCursor7 : 4; ///< PreCursor7
+ UINT32 LcFapeReqPostCursor8 : 5; ///< PostCursor8
+ UINT32 LcFapeReqPreCursor8 : 4; ///< PreCursor8
+ UINT32 UNUSED8 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_2;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor9 : 5; ///< PostCursor9
+ UINT32 LcFapeReqPreCursor9 : 4; ///< PreCursor9
+ UINT32 LcFapeReqPostCursor10 : 5; ///< PostCursor10
+ UINT32 LcFapeReqPreCursor10 : 4; ///< PreCursor10
+ UINT32 LcFapeReqPostCursor11 : 5; ///< PostCursor11
+ UINT32 LcFapeReqPreCursor11 : 4; ///< PreCursor11
+ UINT32 UNUSED9 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_3;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor12 : 5; ///< PostCursor12
+ UINT32 LcFapeReqPreCursor12 : 4; ///< PreCursor12
+ UINT32 LcFapeReqPostCursor13 : 5; ///< PostCursor13
+ UINT32 LcFapeReqPreCursor13 : 4; ///< PreCursor13
+ UINT32 LcFapeReqPostCursor14 : 5; ///< PostCursor14
+ UINT32 LcFapeReqPreCursor14 : 4; ///< PreCursor14
+ UINT32 UNUSED10 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_4;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor15 : 5; ///< PostCursor15
+ UINT32 LcFapeReqPreCursor15 : 4; ///< PreCursor15
+ UINT32 LcFapeReqPostCursor16 : 5; ///< PostCursor16
+ UINT32 LcFapeReqPreCursor16 : 4; ///< PreCursor16
+ UINT32 LcFapeReqPostCursor17 : 5; ///< PostCursor17
+ UINT32 LcFapeReqPreCursor17 : 4; ///< PreCursor17
+ UINT32 UNUSED11 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_5;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor18 : 5; ///< PostCursor18
+ UINT32 LcFapeReqPreCursor18 : 4; ///< PreCursor18
+ UINT32 LcFapeReqPostCursor19 : 5; ///< PostCursor19
+ UINT32 LcFapeReqPreCursor19 : 4; ///< PreCursor19
+ UINT32 LcFapeReqPostCursor20 : 5; ///< PostCursor20
+ UINT32 LcFapeReqPreCursor20 : 4; ///< PreCursor20
+ UINT32 UNUSED12 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_6;
+
+///
+/// PCIe port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 IsBmcLocation : 1; ///< Port Location of BMC
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 TXDeEmphasis : 4; ///< TX De-emphasis
+ UINT8 TXMargin : 3; ///< TX Margin
+ UINT8 UNUSED1 : 1; ///< Currently unassigned - for alignment
+
+ PORT_CAPABILITIES PortCapabilities; ///< Port Capabilities CBS
+
+ SPC_MODE SpcMode;
+
+ GEN3_LANE_CNTL LaneEqualizationCntl;
+ GEN4_LANE_CNTL Gen4LaneEqualizationCntl;
+ GEN5_LANE_CNTL Gen5LaneEqualizationCntl;
+
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 UNUSED4 : 1; ///< Currently unassigned - for alignment
+ UINT8 SRIS_SRNS : 1; ///< SRIS SRNS
+ UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SKP Support
+ UINT8 CcixControl : 1; ///< Bit to enable/disable ESM
+ UINT8 CxlControl : 1; ///< Bit to enable CXL Capability
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 SlotPowerLimitScale : 2; ///< Slot Power Limit Scale
+ UINT8 UNUSED5 : 1; ///< Currently unassigned - for alignment
+
+ UINT8 RxMarginPersistence : 1; ///< Bit to enable/disable Rx Margin persistence mode
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 TxVetting : 1; ///< Gen4 Tx Vetting
+ UINT8 RxVetting : 1; ///< Gen4 Rx Vetting
+ UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetting
+ UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetting
+
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 DlfCapDisable : 1; ///< DLF Capability 1:Disable 0:Enable
+ UINT8 DlfExchangeDisable : 1; ///< DLF Exchange 1:Disable 0:Enable
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+
+ UINT8 EqSearchMode : 2; ///< Equalization Search Mode
+ UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ
+ UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 EQ Phase2/3
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset value
+
+ UINT8 EqSearchModeGen4 : 2; ///< Equalization Search Mode for Gen4
+ UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass phase3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset value
+ UINT8 EqSearchModeGen5 : 2; ///< Equalization Search Mode for Gen5
+ UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass phase3 EQ
+ UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass phase2/3 EQ
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset value
+
+ UINT16 PsppPolicyDC; ///< Pspp Policy DC
+ UINT16 PsppPolicyAC; ///< Pspp Policy AC
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+
+ LC_FAPE_GROUP_0 LcFapeSettingsGroup0;
+ LC_FAPE_GROUP_1 LcFapeSettingsGroup1;
+ LC_FAPE_GROUP_2 LcFapeSettingsGroup2;
+ LC_FAPE_GROUP_3 LcFapeSettingsGroup3;
+ LC_FAPE_GROUP_4 LcFapeSettingsGroup4;
+ LC_FAPE_GROUP_5 LcFapeSettingsGroup5;
+ LC_FAPE_GROUP_6 LcFapeSettingsGroup6;
+
+ UINT8 ForceSteering : 1; ///< Steering is forced
+ UINT8 EsmUsTxPreset : 4; ///< ESM Upstream Tx Preset
+ UINT8 UNUSED13 : 3; ///< Currently unassigned - for alignment
+
+ // Used by DXE
+ PORT_FEATURES PortFeatures; ///< Port Features CBS
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 I2CMuxInfo; ///< First I2c Mux on Bus
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:SRIS 2:SRNS 3:SRNS in SRIS 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 ClkReq : 4; ///< ClkReq:[0:3]
+ UINT8 EqPreset : 4; ///< EqPreset:[4:7]
+ UINT8 LinkAspmL1_1 : 1; ///< Enable PM L1 SS L1.1
+ UINT8 LinkAspmL1_2 : 1; ///< Enable PM L1 SS L1.2
+ UINT8 EsmControl : 1; ///< Bit to enable/disable ESM
+ UINT8 EsmDsTxPreset : 4; ///< ESM Downstream Tx Preset
+ UINT8 ClkReqFilterEn : 1; ///< Controls filtering of CLKREQb signal in LC in order to avoid false L1 substate entries/exits.
+} PCIE_PORT_CONFIG;
+
+///
+/// CXL port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 UNUSED0 : 1; ///< Currently unassigned - for alignment
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 CxlIndex;
+ UINT8 CxlDeviceType : 2; ///< Type of CXL device connected
+ UINT8 CxlVersion : 2; ///< Version of CXL device connected (1=CXL1.1, 2=CXL2.0)
+ UINT8 IsCxlScanned : 1; ///< Indicates if the CXL device has been scanned
+ UINT8 ReportToMpioinDxe : 1; ///< Indicates if the CXL info needs to be reported to MPIO in DXE
+ UINT8 UNUSED1 : 2; ///< Currently unassigned - for alignment
+
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT32 Mmio32Base;
+ UINT32 Mmio32Size;
+ UINT64 Mmio64Base;
+ UINT64 Mmio64Size;
+ UINT32 Mmio32Gran;
+} PCIE_CXL_CONFIG;
+
+///
+/// Descriptor header
+///
+typedef struct {
+ UINT32 DescriptorFlags; ///< Descriptor flags
+ UINT16 Parent; ///< Offset of parent descriptor
+ UINT16 Peer; ///< Offset of the peer descriptor
+ UINT16 Child; ///< Offset of the list of child descriptors
+} PCIE_DESCRIPTOR_HEADER;
+
+///
+/// Engine configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor header
+ PCIE_ENGINE EngineData; ///< Engine Data
+ PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initialization Status
+ UINT8 Scratch; ///< Scratch pad
+ union {
+ PCIE_PORT_CONFIG Port; ///< PCIe port configuration data
+ PCIE_CXL_CONFIG Cxl; ///< CXL Configuration data
+ } Type;
+} PCIE_ENGINE_CONFIG;
+
+///
+/// Wrapper configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 WrapId; ///< Wrapper ID
+ UINT8 CcixCoreConfig; ///< Ccix CORE Configuration
+ UINT8 StartPhyLane; ///< Start PHY Lane
+ UINT8 EndPhyLane; ///< End PHY Lane
+ UINT8 StartDxioLane; ///< Start Dxio Lane (Translated)
+ UINT8 EndDxioLane; ///< End Dxio Lane (Translated)
+ struct {
+ UINT8 PowerOffUnusedLanes : 1; ///< Power Off unused lanes
+ UINT8 PowerOffUnusedPlls : 1; ///< Power Off unused Plls
+ UINT8 ClkGating : 1; ///< TXCLK gating
+ UINT8 LclkGating : 1; ///< LCLK gating
+ UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock gating PLL power down
+ UINT8 PllOffInL1 : 1; ///< PLL off in L1
+ UINT8 AccessEncoding : 1; ///< Reg access encoding
+ UINT8 CoreReversed : 1; ///< Indicates lanes are reversed in package connection
+ } Features;
+ UINT8 MasterPll; ///< Bitmap of master PLL
+ UINT32 AcsSupport : 1; ///< Acs Support
+ UINT32 LtrSupport : 1; ///< LTR Support
+ UINT32 AriForwarding : 1; ///< ARI Forwarding
+ UINT32 LaneMargining : 1; ///< Lane Margining
+ UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM
+ UINT32 DownstreamPortContainment : 1; ///< Downstream port containment
+ UINT32 AdvancedErrorReporting : 1; ///< Advacned Error Reporting
+ UINT32 ECRCSupport : 2; ///< ECRC Capability
+ UINT32 Reserved : 23; ///< Reserved bits
+} PCIE_WRAPPER_CONFIG;
+
+///
+/// Silicon configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 SocketId; ///< Socket ID
+ UINT8 DieNumber; ///< Module ID
+ UINT8 RBIndex; ///< Physical Root Bridge
+ UINT8 InstanceId; ///< Logical Instance Identifier
+ PCI_ADDR Address; ///< PCI address of GNB host bridge
+ UINT16 StartLane; ///< Start Lane of this node
+ UINT16 EndLane; ///< End Lane of this node
+ UINT8 BusNumberLimit; ///< Last Bus Number assigned to this node
+ UINT8 SbPresent : 1; ///< Set to 1 if FCH connected to this NBIO
+ UINT8 SmuPresent : 1; ///< Set to 1 if SMU connected to this NBIO
+ UINT8 MP_Instance : 6; ///< MP Instance
+ UINT8 LogicalRBIndex; ///< Logical Root Bridge
+ UINT8 NumEngineDesc; ///< Total number of lane bifurcation descriptors
+} PCIE_SILICON_CONFIG;
+
+typedef PCIE_SILICON_CONFIG GNB_HANDLE;
+
+///
+/// Complex configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 NodeId; ///< Processor Node ID
+ UINT8 Reserved; ///< For alignment
+} PCIE_COMPLEX_CONFIG;
+
+///
+/// PCIe platform configuration info
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ PVOID Reserved1; ///< Reserved
+ UINT32 Reserved2; ///< Reserved
+ UINT32 PhyConfigData; ///< Phy Configuration Data
+ UINT32 Reserved3; ///< Reserved
+ UINT32 Reserved4; ///< Reserved
+ UINT32 PsppTuningParams; ///< Tuning parameters for PSPP
+ UINT32 PsppTuningParams2; ///< Tuning parameters 2 for PSPP
+ UINT8 Reserved5; ///< Reserved
+ UINT8 PsppPolicy; ///< PSPP policy
+ UINT8 Reserved6; ///< Reserved
+ UINT8 RootBridgesPerSocket; ///< Number of root bridges per socket
+ PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES]; ///< Complex
+} PCIE_PLATFORM_CONFIG;
+
+///
+/// PCIe Engine Description
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor on wrapper
+ ///< Bit30 - Descriptor allocated for PCIe port
+ PCIE_ENGINE EngineData; ///< Engine Data
+} PCIE_ENGINE_DESCRIPTOR;
+#pragma pack (pop)
+
+#endif // GNBDXIO_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
new file mode 100644
index 0000000000..90f52cca7b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
@@ -0,0 +1,18 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _GNBREGISTERSRS_H_
+#define _GNBREGISTERSRS_H_
+
+#include "GnbRegistersRS/IOHC.h"
+
+#ifndef NBIO_SPACE
+#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + (HANDLE->RBIndex << 20))
+#endif
+
+#endif /*_GNBREGISTERSRS_H_*/
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
new file mode 100644
index 0000000000..b1a95237de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _IOHC_H_
+#define _IOHC_H_
+
+// Bitfield Description : DBG MMIO enable.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
+
+// Bitfield Description : Locks the DBG MMIO address range and enable until the next warm reset.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
+
+#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 0x13c102f0UL
+
+#endif /* _IOHC_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
new file mode 100644
index 0000000000..f5cc5e2228
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_PCIE_HOB_INFO_H_
+#define GNB_PCIE_HOB_INFO_H_
+
+#define _GNB_PCIE_HOB_INFO_GUID \
+{ \
+ 0x3eb1d90, 0xce14, 0x40d8, 0xa6, 0xba, 0x10, 0x3a, 0x8d, 0x7b, 0xd3, 0x2d \
+}
+extern EFI_GUID gGnbPcieHobInfoGuid;
+
+#pragma pack (push, 1)
+#define MAX_NUMBER_OF_CORES_PER_COMPLEX 3
+#define MAX_NUMBER_OF_PORTS_PER_COMPLEX 22
+
+/// PCIe information HOB data
+typedef struct _GNB_PCIE_INFORMATION_DATA_HOB {
+ EFI_HOB_GUID_TYPE EfiHobGuidType; ///< GUID Hob type structure
+ PCIE_PLATFORM_CONFIG PciePlatformConfigHob; ///< Platform Config Structure
+ UINT32 ComplexConfigs; ///< Allocation for Max Complex Structure suported
+} GNB_PCIE_INFORMATION_DATA_HOB;
+
+#pragma pack (pop)
+
+#endif /* GNB_PCIE_HOB_INFO_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
new file mode 100644
index 0000000000..dc773737b9
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+ Contains interface to the AMD AGESA library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_BASE_LIB_H_
+#define AMD_BASE_LIB_H_
+
+#include "Uefi.h"
+#include "AMD.h"
+
+#endif // AMD_BASE_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
new file mode 100644
index 0000000000..9d9892aa30
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
@@ -0,0 +1,43 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * PSP Mailbox related functions Prototype definition
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: PSP
+ * @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue, 03 Feb 2015) $
+ */
+
+#ifndef _PSP_MBOX_H_
+#define _PSP_MBOX_H_
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ );
+
+#endif //_PSP_MBOX_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
new file mode 100644
index 0000000000..51935f413a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BASE_FABRIC_TOPOLOGY_LIB_H_
+#define BASE_FABRIC_TOPOLOGY_LIB_H_
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ );
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ );
+
+#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
new file mode 100644
index 0000000000..cae3aff9b3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_BASE_LIB_H_
+#define _FCH_BASE_LIB_H_
+
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/BaseLib.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
new file mode 100644
index 0000000000..345e39adce
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
@@ -0,0 +1,413 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_ESPI_CMD_LIB_H_
+#define _FCH_ESPI_CMD_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+#define MAX_ESPI_RETRY 100000ul
+//
+// Cycle Type
+//
+#define CYCLE_TYPE_FLASH_READ 0
+#define CYCLE_TYPE_FLASH_WRITE 1
+#define CYCLE_TYPE_FLASH_ERASE 2
+#define CYCLE_TYPE_RPMC_OP1 3
+#define CYCLE_TYPE_RPMC_OP2 4
+
+// RPMC OP1/OP2 Command Payload Max Length (512 Bits)
+#define RPMC_CMD_PAYLOAD_MAX_LEN 0x40
+
+//
+// Master Registers
+//
+#define SET_CONFIGURATION 0
+#define GET_CONFIGURATION 1
+#define IN_BAND_RESET 2
+#define PC_MSG_DOWN_STREAM 4
+#define VM_DOWN_STREAM 5
+#define OOB_DOWN_STREAM 6
+#define FA_DOWN_STREAM 7
+
+// ESPIx00
+#define DNCMD_STATUS BIT3
+
+// ESPIx2C Master Capability
+#define MASTER_FA_SUPPORT BIT0
+#define MASTER_OOB_SUPPORT BIT1
+#define MASTER_VW_SUPPORT BIT2
+#define MASTER_PERIPHERAL_SUPPORT BIT3
+
+// ESPIx68 Slave0 Configuration
+#define SLAVE_FA_ENABLE BIT0
+#define SLAVE_OOB_ENABLE BIT1
+#define SLAVE_VW_ENABLE BIT2
+#define SLAVE_PC_ENABLE BIT3
+
+/// eSPIx00 eSPI Software Specific Register 0
+#define ESPI_DN_TXHDR_0 0x00
+typedef union {
+ struct {
+ UINT32 SWCommandType : 3;
+ UINT32 CommandStatus : 1;
+ UINT32 PutFlashNpTranActive : 1;
+ UINT32 Reserved : 3;
+ UINT32 DnCmdHdata0 : 8;
+ UINT32 DnCmdHdata1 : 8;
+ UINT32 DnCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx00_DN_TXHDR0;
+
+/// eSPIx04 eSPI Software Specific Register 1
+#define ESPI_DN_TXHDR_1 0x04
+typedef union {
+ struct {
+ UINT32 DnCmdHdata3 : 8;
+ UINT32 DnCmdHdata4 : 8;
+ UINT32 DnCmdHdata5 : 8;
+ UINT32 DnCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx04_DN_TXHDR1;
+
+#define ESPI_DN_TXHDR_2 0x08
+typedef union {
+ struct {
+ UINT32 DnCmdHdata7 : 8;
+ UINT32 Reserved : 24;
+ } Field;
+ UINT32 Value;
+} ESPIx08_DN_TXHDR2;
+
+#define ESPI_DN_TXDATA_PORT 0x0C
+typedef union {
+ struct {
+ UINT32 DnTxData0 : 8;
+ UINT32 DnTxData1 : 8;
+ UINT32 DnTxData2 : 8;
+ UINT32 DnTxData3 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx0C_DN_TXDATA_PORT;
+
+#define ESPI_UP_RXHDR_0 0x10
+typedef union {
+ struct {
+ UINT32 UpCommandType : 3;
+ UINT32 UpCommandStatus : 1;
+ UINT32 SlaveSel : 2;
+ UINT32 Reserved : 2;
+ UINT32 UpCmdHdata0 : 8;
+ UINT32 UpCmdHdata1 : 8;
+ UINT32 UpCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx10_UP_RXHDR0;
+
+#define ESPI_UP_RXHDR_1 0x14
+typedef union {
+ struct {
+ UINT32 UpCmdHdata3 : 8;
+ UINT32 UpCmdHdata4 : 8;
+ UINT32 UpCmdHdata5 : 8;
+ UINT32 UpCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx14_UP_RXHDR1;
+
+#define ESPI_UP_RXDATA_PORT 0x18
+
+/// eSPIx2C eSPI Master Capability
+#define ESPI_MASTER_CAP 0x2C
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelSupport : 1;
+ UINT32 OOBMessageChannelSupport : 1;
+ UINT32 VWChannelSupport : 1;
+ UINT32 PChannelSupport : 1;
+ UINT32 MasterVersion : 3;
+ UINT32 FlashAccessChannelMaxPayload : 3;
+ UINT32 OOBMessageChannelMaxPayload : 3;
+ UINT32 OperatingMaxVWCount : 6;
+ UINT32 PChannelMaxPayloadSize : 3;
+ UINT32 NumberOfSlave : 3;
+ UINT32 OperatingSupportFreq : 3;
+ UINT32 IOMode : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheck : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx2C_MASTER_CAP;
+
+/// eSPIx30 eSPI Global Control 0
+#define ESPI_GLOBAL_CTRL0 0x30
+typedef union {
+ struct {
+ UINT32 WdgEn : 1;
+ UINT32 WaitChkEn : 1;
+ UINT32 PrClkgatEn : 1;
+ UINT32 AlStopEn : 1;
+ UINT32 AlIdleTimer : 3;
+ UINT32 RgDbgclkGatingEn : 1;
+ UINT32 WdgCnt : 16;
+ UINT32 WaitCnt : 6;
+ UINT32 PrRstEnPltrst : 1;
+ UINT32 SafsClkGateEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx30_GLOBAL_CTRL0;
+
+/// eSPIx68 eSPI Slave0 Configuration
+#define ESPI_SLAVE0_CONFIG 0x68
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelEnable : 1;
+ UINT32 OOBMessageChannelEnable : 1;
+ UINT32 VWChannelEnable : 1;
+ UINT32 PChannelEnable : 1;
+ UINT32 FlashSharingMode : 1;
+ UINT32 FlashMaxPayloadSize : 3;
+ UINT32 PutFlashNpHeaderDataEn : 1;
+ UINT32 PutFlashNpHeaderEn : 1;
+ UINT32 SafsDeferValidEn : 1;
+ UINT32 FlashModifierEn : 1;
+ UINT32 Reserved_24_12 : 13;
+ UINT32 OperatingFreq : 3;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheckingEnable : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx68_SLAVE0_CONFIG;
+
+/// eSPIx70 eSPI Slave0 Interrupt Status
+#define ESPI_SLAVE0_INT_STS 0x70
+typedef union {
+ struct {
+ UINT32 BusErrInt : 1;
+ UINT32 WaitTimeoutInt : 1;
+ UINT32 CrcErrInt : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 NoRspInt : 1;
+ UINT32 FatalErrInt : 1;
+ UINT32 NonFatalErrInt : 1;
+ UINT32 UnknownRspInt : 1;
+ UINT32 UnknownCtInt : 1;
+ UINT32 UnsucssCplInt : 1;
+ UINT32 IllegalTagInt : 1;
+ UINT32 IllegalLenInt : 1;
+ UINT32 RxOobOverflowInt : 1;
+ UINT32 RxMsgOverflowInt : 1;
+ UINT32 RxFlashOverflowInt : 1;
+ UINT32 ProtocolErrInt : 1;
+ UINT32 Reserved_16 : 1;
+ UINT32 UpFifoWdgTo : 1;
+ UINT32 MstAbortInt : 1;
+ UINT32 WdgTimeoutInt : 1;
+ UINT32 Reserved_23_20 : 4;
+ UINT32 RxVwGrp0Int : 1;
+ UINT32 RxVwGrp1Int : 1;
+ UINT32 RxVwGrp2Int : 1;
+ UINT32 RxVwGrp3Int : 1;
+ UINT32 DnCmdInt : 1;
+ UINT32 RxMsgInt : 1;
+ UINT32 RxOobInt : 1;
+ UINT32 FlashReqInt : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx70_SLAVE0_INT_STS;
+
+///
+/// Slave Registers
+///
+#define SLAVE_REG_ID 0x04
+#define SLAVE_GENERAL_CAPCFG 0x08
+#define SLAVE_PC_CAPCFG 0x10
+#define SLAVE_VW_CAPCFG 0x20
+#define SLAVE_OOB_CAPCFG 0x30
+#define SLAVE_FA_CAPCFG 0x40
+#define SLAVE_FA_CAPCFG2 0x44
+
+/// Offset 04h: Device Identification
+typedef union {
+ struct {
+ UINT32 RO_VersionID : 8;
+ UINT32 Reserved_31_8 : 24;
+ } Field;
+ UINT32 Value;
+} ESPI_SL04_DEVICE_ID;
+
+// SLAVE offset 0x08 SLAVE_GENERAL_CAPCFG
+#define SLAVE_FA_SUPPORT BIT3
+#define SLAVE_OOB_SUPPORT BIT2
+#define SLAVE_VW_SUPPORT BIT1
+#define SLAVE_PERIPHERAL_SUPPORT BIT0
+/// Offset 08h: General Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 RO_PCSupported : 1;
+ UINT32 RO_VWSupported : 1;
+ UINT32 RO_OOBMsgSupported : 1;
+ UINT32 RO_FASupported : 1;
+ UINT32 Reserved_7_3 : 4;
+ UINT32 Reserved_11_8 : 4;
+ UINT32 RO_MaxWaitStateAllowed : 4;
+ UINT32 RO_MaxFreqSupported : 3;
+ UINT32 RO_OpenDrainAlertSupported : 1;
+ UINT32 OperatingFreq : 3;
+ UINT32 OpenDrainAlertSelect : 1;
+ UINT32 RO_IOModeSupported : 2;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 Reserved_29 : 1;
+ UINT32 ResponseModifierEn : 1;
+ UINT32 CRCCheckingEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPI_SL08_SLAVE_GENERAL_CAPCFG;
+
+/// Offset 10h: Channel 0 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 PCEn : 1;
+ UINT32 RO_PCReady : 1;
+ UINT32 BusMasterEn : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 RO_PCMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 PCMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_11 : 1;
+ UINT32 PCMaxReadRequestSize : 3;
+ UINT32 Reserved_31_15 : 17;
+ } Field;
+ UINT32 Value;
+} ESPI_SL10_SLAVE_PC_CAPCFG;
+
+/// Offset 20h: Channel 1 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 VWEn : 1;
+ UINT32 RO_VWReady : 1;
+ UINT32 Reserved_7_2 : 6;
+ UINT32 RO_MaxVWCntSupported : 6;
+ UINT32 Reserved_15_14 : 2;
+ UINT32 OpMaxVWCnt : 6;
+ UINT32 Reserved_31_22 : 10;
+ } Field;
+ UINT32 Value;
+} ESPI_SL20_SLAVE_VW_CAPCFG;
+
+/// Offset 30h: Channel 2 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 OOBEn : 1;
+ UINT32 RO_OOBReady : 1;
+ UINT32 Reserved_3_2 : 2;
+ UINT32 RO_MsgChMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 MsgChMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_31_11 : 21;
+ } Field;
+ UINT32 Value;
+} ESPI_SL30_SLAVE_OOB_CAPCFG;
+
+/// Offset 40h: Channel 3 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 FAEn : 1;
+ UINT32 RO_FAReady : 1;
+ UINT32 FlashBlockEraseSize : 3;
+ UINT32 RO_ChMaxPayloadSizeSupported : 3;
+ UINT32 ChMaxPayloadSizeSelected : 3;
+ UINT32 RO_FlashSharingMode : 1;
+ UINT32 ChMaxReadReqSize : 3;
+ UINT32 Reserved_15 : 1;
+ UINT32 RO_FlashSharingCapabilitySupported : 2;
+ UINT32 Reserved_19_18 : 2;
+ UINT32 RO_RPMCCounterOn1stDevice : 4;
+ UINT32 RO_RPMCOp1On1stDevice : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL40_SLAVE_FA_CAPCFG;
+
+/// Offset 44h: Channel 3 Capabilities and Configurations2
+typedef union {
+ struct {
+ UINT32 RO_TargetMaxReadReqSizeSupported : 3;
+ UINT32 Reserved_7_3 : 5;
+ UINT32 RO_TargetFlashEraseBlockSize : 8;
+ UINT32 RO_TargetRPMCSupported : 6;
+ UINT32 RO_NumOfRPMCdevices : 2;
+ UINT32 Reserved_31_24 : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL44_SLAVE_FA_CAPCFG2;
+
+//
+// eSPI Command functions
+//
+VOID
+FchEspiCmd_InBandRst (
+ IN UINT32 EspiBase
+ );
+
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ );
+
+VOID
+FchEspiCmd_SetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr,
+ IN UINT32 Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp1 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ IN UINT8 *Data
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp2 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
new file mode 100755
index 0000000000..19688e2548
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
@@ -0,0 +1,16 @@
+/** @file
+ GNB PCIe Library definition.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBPCIECONFIG_LIB_H_
+#define GNBPCIECONFIG_LIB_H_
+
+#include <GnbDxio.h>
+#include <Library/PcieConfigLib.h>
+
+#endif // GNBPCIECONFIG_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
new file mode 100644
index 0000000000..df88274530
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
@@ -0,0 +1,37 @@
+/** @file
+ Header file of AMD NBIO Common DXE library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOCOMMONLIBDXE_H_
+#define NBIOCOMMONLIBDXE_H_
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ );
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ );
+
+#endif // NBIOCOMMONLIBDXE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
new file mode 100755
index 0000000000..4fec578a9f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
@@ -0,0 +1,62 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOHANDLELIB_LIB_H_
+#define NBIOHANDLELIB_LIB_H_
+
+#include <GnbDxio.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ );
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ );
+
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define GnbGetSocketId(Handle) (Handle != NULL ? (Handle)->SocketId : 0)
+#define GnbGetDieNumber(Handle) (Handle != NULL ? (Handle)->DieNumber : 0)
+#define GnbGetRBIndex(Handle) (Handle != NULL ? (Handle)->RBIndex : 0)
+
+#endif // NBIOHANDLELIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
new file mode 100644
index 0000000000..9f53746814
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
@@ -0,0 +1,283 @@
+/** @file
+ Helper functions to access PCIe configuration data area.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PCIECONFIGLIB_LIB_H_
+#define PCIECONFIGLIB_LIB_H_
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_WRAPPER_CALLBACK) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK2) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+typedef VOID (*PCIE_RUN_ON_WRAPPER_CALLBACK2) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_DESCRIPTOR_CALLBACK) (
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ );
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ );
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ );
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ );
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ );
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ );
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ );
+
+#define PcieConfigGetParentWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetParent (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetParentSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetParentComplex(Descriptor) ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX, &((Descriptor)->Header)))
+#define PcieConfigGetPlatform(Descriptor) ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM, &((Descriptor)->Header)))
+#define PcieConfigGetChildWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetChildEngine(Descriptor) ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES, &((Descriptor)->Header)))
+#define PcieConfigGetChildSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetNextDescriptor(Descriptor) ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : ((Descriptor + 1))))
+#define PcieConfigIsPcieEngine(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_PCIE_ENGINE) != 0) : FALSE)
+#define PcieConfigIsSbPcieEngine(Engine) ((Engine != NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.SbLink)) : FALSE)
+#define PcieConfigIsEngineAllocated(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_ALLOCATED) != 0) : FALSE)
+#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) if (Descriptor != NULL) (Descriptor)->Header.DescriptorFlags |= SetDescriptorFlags
+#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) if (Descriptor != NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags &= (~(ResetDescriptorFlags))
+#define PcieInputParsetGetNextDescriptor(Descriptor) ((Descriptor == NULL) ? NULL : ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
+#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination) ((Descriptor == NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags & Termination) != 0) ? NULL : ((UINT8 *) Descriptor + ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Peer))
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define PcieConfigGetNextDataDescriptor(Descriptor) ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0 ? NULL : (Descriptor + 1))
+
+#endif // PCIECONFIGLIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
new file mode 100644
index 0000000000..f0c6d1ccbb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SMNACCESSLIB_H_
+#define _SMNACCESSLIB_H_
+
+VOID
+SmnRegisterReadS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ OUT VOID *Value
+ );
+
+VOID
+SmnRegisterRMWS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrValue,
+ IN UINT32 Flags
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
new file mode 100644
index 0000000000..0e08e64b24
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_PCIE_SERVICES_PROTOCOL_H_
+#define NBIO_PCIE_SERVICES_PROTOCOL_H_
+
+// Current PROTOCOL revision
+#define AMD_NBIO_PCIE_SERVICES_REVISION 0x00
+
+///
+/// Forward declaration for the NBIO_PCIE_SERVICES_PROTOCOL
+///
+typedef struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL;
+
+//
+// Protocol Definitions
+//
+
+/**
+ Returns the NBIO debug options configuration structure
+ This
+ A pointer to the DXE_AMD_NBIO_SMU_SERVICES_PROTOCOL instance.
+ DebugOptions
+ A pointer to a pointer to store the address of the PCIe topology structure
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT)(
+ IN DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL *This,
+ OUT UINT32 **DebugOptions
+ );
+
+///
+/// The Dxe of PCIE Services
+///
+struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL {
+ AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT PcieGetTopology; ///<
+};
+
+extern EFI_GUID gAmdNbioPcieServicesProtocolGuid;
+
+#endif /* NBIO_PCIE_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
new file mode 100644
index 0000000000..10d3b730a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
+#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
+
+extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
new file mode 100644
index 0000000000..a15995188b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
@@ -0,0 +1,155 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_NUMA_SERVICES2_H_
+#define FABRIC_NUMA_SERVICES2_H_
+#include "AMD.h"
+
+#pragma pack (push, 1)
+
+#define MAX_PXM_VALUES_PER_QUADRANT 16
+
+/// Domain type
+typedef enum {
+ NumaDram,
+ NumaSLink,
+ NumaCxl,
+ MaxNumaDomainType2
+} DOMAIN_TYPE2;
+
+/// Reported Domain Info
+typedef struct {
+ DOMAIN_TYPE2 Type; ///< Type
+ UINT32 SocketMap; ///< Bitmap indicating physical socket location
+ UINT32 PhysicalDomain; ///< Physical domain number
+} DOMAIN_INFO2;
+
+/// Physical Dram Info
+typedef struct {
+ UINT32 NormalizedCsMap; ///< Bitmap of CSs comprising this physical domain
+ UINT32 SharingEntityCount; ///< Number of virtual domains sharing this physical domain
+ UINT32 SharingEntityMap; ///< Bitmap of reported domains that share this physical domain
+ UINT32 Reserved; ///< Reserved
+} PHYS_DOMAIN_INFO;
+
+/// Proximity Domain Info
+typedef struct {
+ UINTN Count; ///< Entries in Domain array
+ UINTN Domain[MAX_PXM_VALUES_PER_QUADRANT]; ///< Domains in Quadrant
+} PXM_DOMAIN_INFO;
+
+///
+/// Forward declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL
+///
+typedef struct _FABRIC_NUMA_SERVICES2_PROTOCOL FABRIC_NUMA_SERVICES2_PROTOCOL;
+
+/**
+ * @brief Get the numa domain information.
+ *
+ * @details Get the numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfDomainsInSystem Number of unique NUMA domains
+ * @param[out] DomainInfo An array with information about each domain
+ * @param[out] CcxAsNumaDomain TRUE: each core complex is its own domain
+ * FALSE: physical mapping is employed
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfDomainsInSystem,
+ OUT DOMAIN_INFO2 **DomainInfo,
+ OUT BOOLEAN *CcxAsNumaDomain
+ );
+
+/**
+ * @brief Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @details Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] Socket Zero based socket that the core is attached to
+ * @param[in] Die DF die on socket that the core is attached to
+ * @param[in] Ccd Logical CCD the core is on
+ * @param[in] Ccx Logical core complex
+ * @param[out] Domain Domain the core belongs to
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_DOMAIN_XLAT)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Ccd,
+ IN UINTN Ccx,
+ OUT UINT32 *Domain
+ );
+
+/**
+ * @brief Get physical numa domain information.
+ *
+ * @details Get physical numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfPhysDomainsInSystem Number of valid domains in the system
+ * @param[out] PhysDomainInfo An array with information about each physical domain
+ * @param[out] PhysNodesPerSocket Actual NPS as determined by ABL (not including SLink)
+ * @param[out] NumberOfSystemSLinkDomains Number of domains describing SLink connected memory
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfPhysDomainsInSystem,
+ OUT PHYS_DOMAIN_INFO **PhysDomainInfo,
+ OUT UINT32 *PhysNodesPerSocket,
+ OUT UINT32 *NumberOfSystemSLinkDomains
+ );
+
+/**
+ * @brief Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @details Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] RootPortBDF BDF for root-port bridge in PCI_ADDR format.
+ * @param[out] PxmDomainInfo Pointer to a structure returning associated NUMA node(s).
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN PCI_ADDR RootPortBDF,
+ OUT PXM_DOMAIN_INFO *PxmDomainInfo
+ );
+
+///
+/// When installed, the Fabric NUMA Services 2 Protocol produces a collection of
+/// services that return various information associated with non-uniform memory
+/// architecture.
+///
+struct _FABRIC_NUMA_SERVICES2_PROTOCOL {
+ UINTN Revision; ///< Revision Number
+ FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO GetDomainInfo; ///< Get Domain Info
+ FABRIC_NUMA_SERVICES2_DOMAIN_XLAT DomainXlat; ///< Domain Translation
+ FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO GetPhysDomainInfo; ///< Get Physical Domain Info
+ FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO GetPxmDomainInfo; ///< Get Proximity Domain Info
+};
+
+///
+/// Guid declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL.
+///
+extern EFI_GUID gAmdFabricNumaServices2ProtocolGuid;
+
+#pragma pack (pop)
+#endif // _FABRIC_NUMA_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
new file mode 100644
index 0000000000..485240c0fb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_TOPOLOGY_SERVICES2_H_
+#define FABRIC_TOPOLOGY_SERVICES2_H_
+
+#include <Library/BaseFabricTopologyLib.h>
+
+#endif // FABRIC_TOPOLOGY_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
new file mode 100755
index 0000000000..44093e4097
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
@@ -0,0 +1,23 @@
+/** @file
+ SoC Logical ID Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SOC_LOGICAL_ID_H_
+#define SOC_LOGICAL_ID_H_
+#pragma pack (push, 1)
+
+///
+/// SOC logical ID structure
+///
+typedef struct _SOC_LOGICAL_ID {
+ IN OUT UINT32 Family; ///< Indicates logical ID Family
+ IN OUT UINT16 Revision; ///< Indicates logical ID Revision
+} SOC_LOGICAL_ID;
+
+#pragma pack (pop)
+#endif // SOC_LOGICAL_ID_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
new file mode 100644
index 0000000000..a60ae20d33
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _INTERNAL_AML_LIB_H_
+#define _INTERNAL_AML_LIB_H_
+
+#include <Uefi.h>
+#include <Library/AmlGenerationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <IndustryStandard/Acpi.h>
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
new file mode 100644
index 0000000000..b19b6fe867
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -0,0 +1,150 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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/AgesaPkg/Include/AmdPcieComplex.h b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
new file mode 100755
index 0000000000..3a628ed0b2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
@@ -0,0 +1,432 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCIE_COMPLEX_H_
+#define AMD_PCIE_COMPLEX_H_
+
+//
+// GNB PCIe configuration info
+//
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+
+//
+// Port parameter count
+//
+#define PCIE_PORT_PARAMETER_COUNT 64
+
+///
+/// PCIe link initialization
+/// DXIO endpoint status
+///
+typedef enum {
+ DxioEndpointDetect = 0, ///< Detect endpoint presence
+ DxioEndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} DXIO_ENDPOINT_STATUS;
+
+#pragma pack(push,1)
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific port parameter to set.
+ UINT16 ParamValue; ///< Specifies the value to be assigned to port parameter.
+} PORT_PARAM;
+
+typedef struct {
+ PORT_PARAM PhyParam[PCIE_PORT_PARAMETER_COUNT]; ///< PHY port parameter
+} PORT_PARAMS;
+
+///
+/// Ancillary data struct with table size and address
+///
+typedef struct {
+ IN UINT32 Count; ///< Total count in this Ancillary data table
+ IN UINT32 Ovrd; ///< Ancillary data table address point to ANC_DATA_PARAM[]
+} ANC_DATA;
+
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific PHY parameter
+ UINT16 ParamValue; ///< This specifies the value to be assigned to indicated PHY parameter
+} DXIO_PHY_PARAM;
+
+typedef struct {
+ DXIO_PHY_PARAM PhyParam[44]; ///< physical parameter
+} PHY_DATA;
+
+///
+/// PCIe specific data structures
+/// PCIe port misc extended controls
+///
+typedef struct {
+ UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ UINT8 LinkSafeMode : 1; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through DXIO_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertize muximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ UINT8 ChannelType : 3; ///< Channel Type
+ ///< 0 - Channel Type Not Specified
+ ///< - Channel Type Short Trace
+ ///< 2 - Channel Type Long Trace
+ UINT8 TurnOffUnusedLanes : 1; ///< Turn Off Unused Lanes
+ ///< 0 - Turn on
+ ///< 1 - Turn off
+} DXIO_PORT_MISC_CONTROL;
+
+///
+/// The IO APIC Interrupt Mapping Info
+///
+typedef struct {
+ UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< 0 - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< 1 - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< 2 - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< ...
+ ///< 8 - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< 0 - ABCD
+ ///< 1 - BCDA
+ ///< 2 - CDAB
+ ///< 3 - DABC
+ UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< 0 - Entry 0 of IO APIC redirection table
+ ///< 1 - Entry 1 of IO APIC redirection table
+ ///< ...
+ ///< 31 - Entry 31 of IO APIC redirection table
+} DXIO_APIC_DEVICE_INFO;
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ UINT8 PortPresent : 1; ///< Enable PCIe port for initialization.
+ UINT8 Reserved1 : 2; ///< Reserved
+ UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ UINT8 FunctionNumber : 3; ///< Reserved for future use
+ UINT8 LinkSpeedCapability : 3; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ ///< 4 - Gen4
+ ///< 5 - Gen5
+ UINT8 AutoSpdChng : 2; ///< Upstread Auto Speed Change Allowed/
+ ///< 0 - Use default implementation (Disabled for Gen1, Enabled for Gen2/3)
+ ///< 1 - Always Disabled
+ ///< 2 - Always Enabled
+ ///< 3 - Reserved
+ UINT8 EqPreset : 4; ///< Gen3 Equalization Preset */
+ UINT8 LinkAspm : 2; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ UINT8 LinkAspmL1_1 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 LinkAspmL1_2 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 ClkReq : 4; ///< ASPM Reserved Field
+ ///< 0 - NONE
+ ///< 1 - CLKREQ0 signal
+ ///< 2 - CLKREQ1 signal
+ ///< 3 - CLKREQ2 signal
+ ///< 4 - CLKREQ3 signal
+ ///< 5 - CLKREQG signal
+ UINT8 LinkHotplug : 4; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ UINT8 SlotPowerLimit; ///< PCIe slot power limit.
+ UINT8 SlotPowerLimitScale : 2; ///< PCIe slot power limit Scale.
+ ///< 00b = 1.0x
+ ///< 01b = 0.1x
+ ///< 10b = 0.01x
+ ///< 11b = 0.001x
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 Gen4Features : 5; ///< Unused bits
+ ///< BIT0(DLF_Exchange) 1 - Disable, 0 - Enable
+ ///< IT1(DLF_Capability) 1 - Disable, 0 - Enable
+ UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_NUM
+ UINT16 CsLink : 3; ///< Reserved
+ DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ DXIO_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 EsmControl : 1; ///< Enhanced speed mode control
+ UINT8 CcixControl : 1; ///< Ccix/Cxl control
+ UINT8 TxVetting : 1; ///< Tx Vetting
+ UINT8 RxVetting : 1; ///< Rx Vetting
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+ UINT8 NtbHotplug : 1; ///< NTB Hotplug flag
+ ///< 0b = Disabled
+ ///< 1b = Enabled
+ UINT8 Reserved2 : 1; ///< Reserved
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 Reserved3 : 5; ///< Reserved
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset
+ UINT8 Reserved4 : 4; ///< Reserved
+ UINT16 PsppPolicyDC; ///< Pspp DC control
+ UINT16 PsppPolicyAC; ///< PSPP AC control
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+ UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass phase2/3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 DXIO deemphasis default
+ UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemphasis setting
+ UINT8 Reserved5 : 3; ///< Reserved
+ struct {
+ UINT16 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT16 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT16 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT16 Reserved1 : 2; ///< Unused bits
+ UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downstream Tx Preset
+ UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downstream Rx Preset Hint
+ UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstream Tx Preset
+ UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstream Rx Preset Hint
+ UINT8 Reserved2 : 4; ///< Unused bits
+ } LaneEqualizationCntl; ///< Lane equalization control structure used for Gen3 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen4LaneEqualizationCntl; ///< Lane equalization control structure used for Gen4 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen5LaneEqualizationCntl; ///< Lane equalization control structure used for Gen5 values
+ struct {
+ UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT.
+ UINT32 PresetMask16Gt : 10; ///< Preset Mask 16GT.
+ UINT32 PresetMask32Gt : 10; ///< Preset Mask 32GT.
+ UINT32 Reserved1 : 2; ///< Unused bits
+ UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT Set
+ UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16GT Set
+ UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32GT Set
+ UINT8 Reserved2 : 5; ///< Unused bits
+ } PresetMaskCntl; ///< Preset Mask control structure used for Gen3/Gen4/Gen5 values
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equalization
+ UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equalization
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enable 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 IsBmcLocation : 1; ///< IsBmcLocation
+ UINT8 SetEsmControl : 1; ///< Set ESM Control
+ UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump for ESM
+ UINT8 Reserved6 : 1; ///< Unused bits
+ UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 Reserved7 : 1; ///< Unused bits
+ UINT16 NpemEnable : 12; ///< Controls NPEM Enable
+ UINT16 Reserved8 : 4; ///< Unused bits
+ UINT16 NpemCapability : 12; ///< Controls NPEM Capability
+ UINT8 SwingMode : 3; ///< PCIe Swing Mode
+ UINT16 Reserved9 : 1; ///< Unused bits
+ UINT16 MpioAncDataIdx; ///< Reserved for internal use only
+ UINT8 Reserved10; ///< Reserved bits
+} DXIO_PORT_DATA;
+
+///
+/// EtherNet specific data structures
+///
+typedef struct {
+ UINT32 PortNum : 8; ///< Port Number
+ UINT32 PlatConf : 4; ///< Platform Config
+ ///< 0 = Reserved
+ ///< 1 = 10G/1G BackPlane
+ ///< 2 = 2.5G BackPlane
+ ///< 3= Soldered down 1000Base-T
+ ///< 4 = Soldered down 1000Base-X
+ ///< 5 = Soldered down NBase-T
+ ///< 6 = Soldered down 10GBase-T
+ ///< 7 = Soldered down 10GBase-r
+ ///< 8 = SFP+ Connector
+ UINT32 Reserved1 : 4; ///< Unused 12-15
+ UINT32 MdioId : 5; ///< MDIO ID when MDIO Side band is used
+ UINT32 Reserved2 : 2; ///< Unused 21-22
+ UINT32 SuppSpeed : 4; ///< Supported Speeds by Platform
+ ///< 1 = 100M Supported
+ ///< 2 = 1G Supported
+ ///< 4 = 2.5G Supported
+ ///< 8 = 10G Supported
+ UINT32 Reserved3 : 1; ///< Unused 27
+ UINT32 ConnType : 3; ///< Supported Speeds by Platform
+ ///< 0 = Port not Used
+ ///< 1 = SFP+ Connection I2C interface
+ ///< 2 = MDIO PHY
+ ///< 4 = Backplane Connection
+ UINT32 Reserved4 : 1; ///< Unused 31
+} ETH_PORT_PROPERTY0;
+
+typedef struct {
+ UINT32 MdioReset : 2; ///< MDIO Reset Type
+ ///< 0 = None
+ ///< 1 = I2C GPIO
+ ///< 2 = Integrated GPIO
+ ///< 3 = Reserved
+ UINT32 Reserved1 : 2; ///< Unused 2-3
+ UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO number for reset
+ UINT32 Reserved2 : 2; ///< Unused 6-7
+ UINT32 SfpGpioAdd : 3; ///< Lower I2C address of GPIO Expander PCA9535
+ UINT32 Reserved3 : 1; ///< Unused 11
+ UINT32 TxFault : 4; ///< TX FAULT
+ UINT32 Rs : 4; ///< RS Signal
+ UINT32 ModAbs : 4; ///< MOD_ABS signal
+ UINT32 RxLoss : 4; ///< Rx_LOS signal
+ UINT32 SfpGpioMask : 4; ///< SFP+ sideband signals that are not supported by platform
+} ETH_PORT_PROPERTY3;
+
+typedef struct {
+ UINT32 SfpMux : 3; ///< Lower address of Mux PCA 9545
+ UINT32 Reserved1 : 1; ///< Unused 3
+ UINT32 SfpBusSeg : 3; ///< SFP BUS Segment. Downstream channels of PCA9545
+ UINT32 Reserved2 : 1; ///< Unused 7
+ UINT32 SfpMuxUpAdd : 5; ///< Upper address of Mux PCA 9545
+ UINT32 Reserved3 : 3; ///< Unused 13-15
+ UINT32 RedriverAddress : 7; ///< Address of ReDriver
+ UINT32 RedriverInterface : 1; ///< ReDriver Interface Descriptor
+ UINT32 RedriverLane : 3; ///< ReDriver Lane number
+ UINT32 Reserved4 : 1; ///< Unused 27
+ UINT32 RedriverModel : 3; ///< ReDriver Model
+ UINT32 RedriverPresent : 1; ///< Redriver Present
+} ETH_PORT_PROPERTY4;
+
+typedef struct {
+ UINT32 TxEqPre : 6; ///< TX EQ PRE
+ UINT32 Reserved1 : 2; ///< Unused 7-6
+ UINT32 TxEqMain : 6; ///< TX EQ MAIN
+ UINT32 Reserved2 : 2; ///< Unused 15-14
+ UINT32 TxEqPost : 6; ///< TX EQ POST
+ UINT32 Reserved3 : 10; ///< Unused 31-23
+} ETH_PORT_TXEQ;
+/// Ethernet PCIe port configuration data
+///
+typedef struct {
+ ETH_PORT_PROPERTY0 EthPortProp0; ///< XGBE_PORT_PROPERTY_0
+ ETH_PORT_PROPERTY3 EthPortProp3; ///< XGBE_PORT_PROPERTY_3
+ ETH_PORT_PROPERTY4 EthPortProp4; ///< XGBE_PORT_PROPERTY_4
+ UINT32 PadMux0; ///< PadMux0 Setting (8 bits)
+ UINT32 PadMux1; ///< PadMux1 Setting (8 bits)
+ UINT32 MacAddressLo; ///< Lower 32 bits of MAC Address
+ UINT32 MacAddressHi; ///< Upper 32 bits of MAC Address
+ ETH_PORT_TXEQ EthPortTxEq; ///< TX EQ Settings
+} ETHERNET_PORT_DATA;
+
+///
+/// High level data structures for passing topology from platform to AGESA
+///
+typedef struct {
+ UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ UINT8 HotPluggable : 1; ///< HotPluggable
+ ///< 0 - Link is NOT Hot-Switchable
+ ///< 1 - Link IS Hot-Switchable
+ UINT8 Reserved1 : 7; ///< Unused field, leave as 0
+ UINT8 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 GpioGroupId; ///< Unique identifier for the GPIO or GPIO group associated with
+ ///< this engine. GPIOs are used for hotplug notification and link
+ ///< type (e.g SATA Express or PCIe)
+ UINT8 DxioStartLane; ///< Internal coding of start lane
+ UINT8 DxioEndLane; ///< Internal coding of end lane
+ UINT8 SearchDepth; ///< SearchDepth only uses 1 bit - always initialize to 0 will be updated dynamically
+} DXIO_ENGINE_DATA;
+
+///
+/// PCIe port descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in complex
+ DXIO_ENGINE_DATA EngineData; ///< Engine data
+ DXIO_PORT_DATA Port; ///< PCIe port specific configuration info
+ ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for EtherNet
+ PHY_DATA Phy; ///< Ancillary data for PHY programming customization
+ PORT_PARAMS PortParams; ///< Extensible port parameter list for simplified topology structure
+ ANC_DATA AncData; ///< Ancillary data override
+} DXIO_PORT_DESCRIPTOR;
+
+#pragma pack(pop)
+
+///
+///
+/// PCIe Complex descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR *PciePortList; ///< Pointer to array of PCIe port descriptors or NULL (Last element of array must be terminated with DESCRIPTOR_TERMINATE_LIST).
+ VOID *Reserved2; ///< Reserved for future use
+ UINT8 BmcLinkLocation; ///< Identifies the socket/die location of a BMC link (Used by AGESA, input not required)
+ UINT8 BmcLinkLaneNum; ///< Identifies the socket/die location of a BMC Lane number
+ UINT8 Reserved3[2]; ///< Reserved for future
+} DXIO_COMPLEX_DESCRIPTOR;
+
+///
+/// Engine descriptor type
+///
+typedef enum {
+ DxioUnusedEngine = 0, ///< Unused descriptor Excluded from configuration
+ DxioPcieEngine = 1, ///< PCIe port
+ DxioUSBEngine = 2, ///< USB port
+ ///< __Deprecated__
+ DxioSATAEngine = 3, ///< SATA
+ DxioUSB_OVER_PCIE = 4, ///< USB4 PCIe (internal use only)
+ DxioUBMHFCEngine = 5, ///< New for Genoa UBM HFC Connector for auto-discovery
+ DxioOCP3Engine = 6, ///< New for Genoa OCP3 Bifurcatable Connector
+ DxioUdot3Engine = 7, ///< New for Genoa U.3 Multiprotocol Connector
+ DxioDPEngine = 8, ///< Digital Display __For APU display connector list__
+ DxioEthernetEngine = 0x10, ///< Ethernet (GBe, XGBe)
+ ///< __Deprecated__
+ DxioGOPEngine = 0x20, ///< GOP
+ ///< __Deprecated__
+ DxioNTBDevice = 0x60, ///< For NBIF NTB Enable (internal use only)
+ DxioHDaudioEngine, ///< For NBIF HDaudtio Enable (internal use only)
+ DxioACPEngine, ///< For NBIF ACP Enable (internal use only)
+ DxioMP2Engine, ///< For NBIF MP2 Enable (internal use only)
+ DxioMaxPcieEngine ///< Max engine type for boundary check.
+} DXIO_ENGINE_TYPE;
+
+///
+/// PCIe link speeds
+///
+typedef enum {
+ DxioGenMaxSupported, ///< Maximum supported
+ DxioGen1 = 1, ///< Gen1
+ DxioGen2, ///< Gen2
+ DxioGen3, ///< Gen3
+ DxioGen4, ///< Gen4
+ DxioGen5, ///< Gen5
+ MaxDxioGen ///< Max Gen for boundary check
+} DXIO_LINK_SPEEDS;
+#endif // AMD_PCIE_COMPLEX_H_
diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
new file mode 100644
index 0000000000..d62f260235
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
@@ -0,0 +1,17 @@
+/** @file
+
+ Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_SOC_H_
+#define _AMD_SOC_H_
+
+#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
+#endif // _AMD_SOC_H_
diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
new file mode 100644
index 0000000000..2291f7dc83
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
@@ -0,0 +1,42 @@
+/** @file
+ Fabric resource manager common definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_CMN_H_
+#define FABRIC_RESOURCE_MANAGER_CMN_H_
+#pragma pack (push, 1)
+
+#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets in system.
+#define MAX_RBS_PER_SOCKET 20 ///< Max number of root bridges per socket.
+
+/**
+ * @brief DF address aperture structure.
+ * @details This contains information used to define an MMIO region.
+ */
+typedef struct _FABRIC_ADDR_APERTURE {
+ UINT64 Base; ///< Aperture base Address.
+ UINT64 Size; ///< Aperture size.
+ UINT64 Alignment; ///< Alignment bit map. 0xFFFFF means 1MB align.
+} FABRIC_ADDR_APERTURE;
+
+/**
+ * @brief DF Resource for each RootBridge structure.
+ * @details This contains information used to define the MMIO region for each RootBridge.
+ */
+typedef struct _FABRIC_RESOURCE_FOR_EACH_RB {
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second nonprefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second prefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE IO[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< IO resource(s) @see FABRIC_ADDR_APERTURE
+ UINT16 PciBusNumber[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< PCI bus number(s).
+} FABRIC_RESOURCE_FOR_EACH_RB;
+#pragma pack (pop)
+#endif // FABRIC_RESOURCE_MANAGER_CMN_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
new file mode 100644
index 0000000000..9e58f299b4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
@@ -0,0 +1,96 @@
+/** @file
+ AMD Memory Info Hob Definition
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_MEMORY_INFO_HOB_H_
+#define AMD_MEMORY_INFO_HOB_H_
+
+/**
+ * @brief 128 bit Buffer containing UID Unique Identifier value for Memory Info HOB.
+ * EFI_GUID defined in UefiBaseType.h
+ */
+extern EFI_GUID gAmdMemoryInfoHobGuid;
+
+#pragma pack (push, 1)
+
+/**
+ * @brief Memory descriptor structure for each memory range
+ */
+typedef struct {
+ UINT64 Base; ///< Base address of memory rang
+ UINT64 Size; ///< Size of memory rang
+ UINT32 Attribute; ///< Attribute of memory rang
+ UINT32 Reserved; ///< For alignment purpose
+} AMD_MEMORY_RANGE_DESCRIPTOR;
+
+/**
+ * @brief Memory attribute in the memory range descriptor = AVAILABLE
+ */
+#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1
+
+/**
+ * @brief Memory attribute in the memory range descriptor = UMA
+ */
+#define AMD_MEMORY_ATTRIBUTE_UMA 0x2
+
+/**
+ * @brief Memory attribute in the memory range descriptor = MMIO
+ */
+#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPUMEM
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_SP
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED_TMR
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED_SMUFEATURES
+ */
+#define AMD_MEMORY_ATTRIBUTE_Reserved_SmuFeatures 0x9
+
+/// Memory info HOB structure
+typedef struct {
+ UINT32 Version; ///< Version of HOB structure
+ BOOLEAN AmdMemoryVddioValid; ///< This field determines if Vddio is valid
+ UINT16 AmdMemoryVddio; ///< Vddio Voltage
+ BOOLEAN AmdMemoryVddpVddrValid; ///< This field determines if VddpVddr is valid
+ UINT8 AmdMemoryVddpVddr; ///< VddpVddr voltage
+ BOOLEAN AmdMemoryFrequencyValid; ///< Memory Frequency Valid
+ UINT32 AmdMemoryFrequency; ///< Memory Frquency
+ UINT32 AmdMemoryDdrMaxRate; ///< Memory DdrMaxRate
+ UINT32 NumberOfDescriptor; ///< Number of memory range descriptor
+ AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory ranges array
+} AMD_MEMORY_INFO_HOB;
+
+#pragma pack (pop)
+
+/**
+ * @brief Macro that defines the Memory Info HOB version
+ */
+#define AMD_MEMORY_INFO_HOB_VERISION 0x00000110ul // Ver: 00.00.01.10
+
+#endif // AMD_MEMORY_INFO_HOB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
new file mode 100644
index 0000000000..d144a4ad20
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
@@ -0,0 +1,51 @@
+/** @file
+ AMD Psp Base Lib
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_BASELIB_V2_H_
+#define AMD_PSP_BASELIB_V2_H_
+
+#include <AmdPspDirectory.h>
+
+#define MAX_IMAGE_SLOT_COUNT 32
+
+#define ALIGNMENT_4K BASE_4KB
+#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1)) == 0)
+#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K)
+
+#define IS_VALID_ADDR32(addr) (((UINT32)(addr) != 0) && (UINT32)(addr) != 0xFFFFFFFF)
+
+#pragma pack (push, 1)
+
+#define FIRMWARE_TABLE_SIGNATURE 0x55AA55AAul
+
+/// Define the structure OEM signature table
+typedef struct _FIRMWARE_ENTRY_TABLEV2 {
+ UINT32 Signature; ///< 0x00 Signature should be 0x55AA55AAul
+ UINT32 ImcRomBase; ///< 0x04 Base Address for Imc Firmware
+ UINT32 GecRomBase; ///< 0x08 Base Address for Gmc Firmware
+ UINT32 XHCRomBase; ///< 0x0C Base Address for XHCI Firmware
+ UINT32 LegacyPspDirBase; ///< 0x10 Base Address of PSP directory
+ UINT32 PspDirBase; ///< 0x14 Base Address for PSP directory
+ UINT32 Reserved1; ///< 0x18 Base Address for Reserved BIOS directory
+ UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS directory
+ UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS directory
+ UINT32 Config; ///< 0x24 reserved for EFS Configuration
+ UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all program
+ UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for all programs
+} FIRMWARE_ENTRY_TABLEV2;
+
+/// It also used as structure to store ISH generic information across programs
+typedef struct {
+ UINT32 Priority;
+ UINT32 UpdateRetries;
+ UINT32 GlitchRetries;
+ UINT32 ImageSlotAddr;
+} IMAGE_SLOT_HEADER;
+
+#pragma pack (pop)
+
+#endif // AMD_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
new file mode 100644
index 0000000000..23c90b65c2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
@@ -0,0 +1,83 @@
+/** @file
+ AMD Psp Ftpm Library header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_LIB_H_
+#define PSP_FTPM_LIB_H_
+#include <IndustryStandard/Acpi30.h>
+
+/* SYSTEM_TPM_CONFIG_VAL
+ * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG
+ */
+typedef enum {
+ SYSTEM_TPM_CONFIG_DTPM = 0x00, ///< dTPM
+ SYSTEM_TPM_CONFIG_PSP_FTPM = 0x01, ///< PSP FTPM
+ SYSTEM_TPM_CONFIG_HSP_FTPM = 0x02, ///< HSP FTPM
+ SYSTEM_TPM_CONFIG_NONE = 0xFF, ///< None of TPM
+} SYSTEM_TPM_CONFIG_VAL;
+
+#pragma pack (push, 1)
+/// Define TPM_2_CONTROL_AREA
+typedef struct {
+ // Interface Identifier
+ volatile UINT64 InterfaceIdentifier; ///< Interface Identifier
+ // TPM2 Control Area Extension
+ volatile UINT32 Clear; ///< Clear
+ volatile UINT32 RemainingBytes; ///< RemainingBytes
+ volatile UINT32 StatusReserved; ///< StatusReserved
+ volatile UINT32 StatusError; ///< StatusError
+ volatile UINT32 StatusCancel; ///< StatusCancel
+ volatile UINT32 StatusStart; ///< StatusStart
+ UINT64 InterruptControl; ///< InterruptControl
+ UINT32 CommandSize; ///< CommandSize
+ EFI_PHYSICAL_ADDRESS CommandAddress; ///< CommandAddress
+ UINT32 ResponseSize; ///< ResponseSize
+ EFI_PHYSICAL_ADDRESS ResponseAddress; ///< ResponseAddress
+ // Memory Absent command/response buffer
+ volatile UINT32 CmdRespHWBuffer; ///< Cmd/Rsp HW Buffer
+} TPM2_CONTROL_AREA;
+
+#pragma pack (pop)
+
+/**
+ GET TPM related Info
+
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+EFI_STATUS
+FtpmGetInfo (
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Execute a TPM command
+
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+EFI_STATUS
+FtpmExecuteCommand (
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+#endif //PSP_FTPM_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
new file mode 100644
index 0000000000..4ad4020f95
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
@@ -0,0 +1,231 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PSP_ROM_ARMOR_LIB_H_
+#define _PSP_ROM_ARMOR_LIB_H_
+
+#include "Uefi.h"
+
+#define PSP_MAX_SPI_CMD_SUPPORT (4) ///< Max number of SPI command support
+#define PSP_MAX_SPI_DATA_BUFFER_SIZE (72) ///< Max SPI Command Data Buffer Size
+#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list allowed command array number support
+#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list allowed region array number support
+
+#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chip selects
+#define SPI_CHIP_SELECT_1 (1) ///< Chip Select 1
+#define SPI_CHIP_SELECT_2 (2) ///< Chip Select 2
+
+#define SPI_COMMAND_FREQUENCY_66_66MHZ (0) ///< 0=66.66MHz
+#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=33.33MHz
+#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=22.22MHz
+#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=16.66MHz
+#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=100MHz
+#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=800KHz
+
+#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 = Command not examined/processed
+#define SPI_COMMAND_COMPLETED (1) ///< 1 = Command completed successfully
+#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 = Execution Error (i.e. timeout)
+#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 = Command not allowed by Whitelist
+#define SPI_COMMAND_MALFORMED (4) ///< 4 = Command malformed
+
+#pragma pack (push, 1)
+
+typedef struct {
+ UINT8 ChipSelect; ///< 1 = CS1, 2 = CS2, all other values illegal
+
+ UINT8 Frequency; ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Does not include the
+ ///< SPI Opcode byte, but does include the address, dummy bytes, and
+ ///< data.
+
+ UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx + BytesToRx <= 72
+
+ UINT8 OpCode; ///< The SPI Command OpCode (the first byte sent by the SPI controller)
+
+ UINT8 Reserved[3]; ///< Reserved for future expansion
+
+ UINT8 Buffer[PSP_MAX_SPI_DATA_BUFFER_SIZE]; ///< The remaining 0-72 bytes sent/received by the SPI controller.
+ ///<
+ ///< The SPI Controller will
+ ///< 1. Assert the ChipSelect
+ ///< 2. Send the one byte OpCode
+ ///< 3. Send Buffer[0] to Buffer[BytesToTx-1] to the SPI device
+ ///< 4. Read BytesToRx bytes from the device into Buffer[BytesToTx] to
+ ///< Buffer[BytesToTx+BytesToRx-1]
+ ///< 5. Deassert the ChipSelect line
+ ///<
+ ///< SPI ROM Commands that include a target address send the address
+ ///< immediately after the OpCode (i.e. Buffer[0..2] or Buffer[0..3]
+ ///< depending if 24 or 32bit addresses are associated with the OpCode).
+ ///< See the SPI ROM Device's datasheet for full details on your
+ ///< devices commands and formats.
+} SPI_COMMAND; ///< The struct of Spi Command
+
+typedef union {
+ struct {
+ ///< SPI_COMMUNICATION_RESULT
+ UINT16 Command0Result : 4; ///< Result[ 3: 0] The result of Command[0]
+ UINT16 Command1Result : 4; ///< Result[ 7: 4] The result of Command[1]
+ UINT16 Command2Result : 4; ///< Result[11: 8] The result of Command[2]
+ UINT16 Command3Result : 4; ///< Result[15:12] The result of Command[3]
+ } Field; ///< the struct type of Command0 ~ Command4
+ UINT16 Value; ///< 16 bit value of Command0 ~ Command4
+} SPI_COMMUNICATION_RESULT; ///< The union struct type of Spi Communication Result
+
+typedef struct {
+ UINT8 ReadyToRun; ///< Set to FALSE by x86 while the buffer is being constructed. Set to
+ ///< TRUE by x86 as the last step in building the communication buffer,
+ ///< just before x86 rings the PSP doorbell.
+ ///<
+ ///< Set to FALSE by PSP after the PSP copies the buffer from DRAM to
+ ///< private SRAM.
+
+ UINT8 CommandCount; ///< Number of commands to execute, Valid Values 1-4
+
+ SPI_COMMUNICATION_RESULT SpiCommunicationResult; ///< Set to zero by x86 when the buffer is built. Atomically set to a
+ ///< non-zero value by the PSP to indicate the PSP has finished
+ ///< processing the requests in the communication buffer. The specific
+ ///< value written by the PSP provides per command results
+ ///<
+ ///< Result values with special meaning:
+ ///< 0x0000 = (written by x86) PSP has not finished handling the request
+ ///< 0x1000 = PSP determined the request is malformed (invalid
+ ///< CommandCount, chipselect, BytesToRx/Tx, etc)
+ ///< 0x2000, 0x3000, 0x4000, ... , 0xF000 = Reserved for future errors
+ ///<
+ ///< Generic Result values:
+ ///< SpiCommunicationResult[ 3: 0] The result of Command[0]
+ ///< SpiCommunicationResult[ 7: 4] The result of Command[1]
+ ///< SpiCommunicationResult[11: 8] The result of Command[2]
+ ///< SpiCommunicationResult[15:12] The result of Command[3]
+ ///< 0 = Command not examined/processed
+ ///< 1 = Command completed successfully
+ ///< 2 = Execution Error (i.e. timeout)
+ ///< 3 = Command not allowed by Whitelist
+ ///< 4 = Command malformed
+ ///< 5-15 = reserved for future use
+ ///<
+ ///< Examples of Generic Results:
+ ///< 0x0000 - PSP has not finished the request
+ ///< 0x0001 - PSP ran Command0 successfully, and is now idle
+ ///< 0x0111 - PSP ran Command0/1/2 successfully and is now idle
+ ///< 0x0031 - PSP ran Command0, but Command1 was blocked by whitelist
+
+ SPI_COMMAND SpiCommand[PSP_MAX_SPI_CMD_SUPPORT]; ///< Spi command array
+} SPI_COMMUNICATION_BUFFER; ///< The struct type of Spi Communication Buffer
+
+typedef struct {
+ UINT8 ChipSelect; ///< 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+
+ UINT8 Frequency; ///< The allowed frequency for the command
+ ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 OpCode; ///< The allowed commands opcode
+
+ UINT8 MinTx; ///< The minimum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+ UINT8 MaxTx; ///< The maximum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+
+ UINT8 MinRx; ///< The minimum range of allowed Rx byte counts
+ UINT8 MaxRx; ///< The maximum range of allowed Rx byte counts
+
+ UINT8 AddrChkMethod; ///< 0=No address verification performed
+ ///< 1=Treat Buffer[0-2] as a 24-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+ ///< 2=Treat Buffer[0-3] as a 32-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+
+ UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned power of two sized block
+ ///< of addresses that may be impacted by a given SPI Command. For
+ ///< example, a sector erase command targeted at an address within a
+ ///< 64K block will impact every byte within that 64K block. Likewise
+ ///< a page program SPI command (i.e. write) may impact many bytes
+ ///< within the targeted 256/512 byte page due to page wrap-around, but
+ ///< no bytes outside the page. The ImapctSize field specifies the power
+ ///< of two size of the ImpactZone for this command. If VerifyAddress is
+ ///< zero (no checking) this field must also be zero, otherwise this
+ ///< field must be a power of two between 256 and 64MB (256, 512, ...,
+ ///< 67108864). NOTE: When setting this field, carefully examine your
+ ///< device's datasheet.
+ ///<
+} WHITE_LIST_ALLOWED_COMMAND; ///< The struct type of White List Allowed Command
+
+typedef struct {
+ // 8 bytes
+ UINT32 StartAddress; ///< LSB must be 0x00, bit31 identifies a chipselect: 0=CS1, 1=CS2
+ UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be less than EndAddress
+} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed Region
+
+typedef struct {
+ UINT8 AllowedCmdCount; ///< Allow Command Count
+ UINT8 AllowedRegionCount; ///< Allow Region Count
+ WHITE_LIST_ALLOWED_COMMAND WhitelistAllowedCommands[PSP_MAX_WHITE_LIST_CMD_NUM]; ///< White List Allowed Command Table
+ WHITE_LIST_ALLOWED_REGION WhitelistAllowedRegions[PSP_MAX_WHITE_LIST_REGION_NUM]; ///< White List Allowed Region Table
+} SPI_WHITE_LIST; ///< The struct type of Spi White List
+
+#pragma pack (pop)
+
+/**
+ * @brief Request secures the SPI Controller
+ *
+ * @param[in,out] SpiCommunicationBuffer Spi Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN OUT SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ );
+
+/**
+ * @brief Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI white list structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ );
+
+/**
+ * @brief Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ );
+
+/**
+ * @brief Request PSP firmware switch SPI controller chip select.
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ );
+
+#endif //_PSP_ROM_ARMOR_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
new file mode 100644
index 0000000000..0189910bd1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
@@ -0,0 +1,2722 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AML_LIB_H_
+#define AML_LIB_H_
+
+#include <Uefi.h>
+#include <IndustryStandard/Acpi.h>
+
+typedef enum {
+ AmlStart,
+ AmlClose,
+ AmlInvalid
+} AML_FUNCTION_PHASE;
+
+#define AML_OBJECT_INSTANCE_SIGNATURE SIGNATURE_32 ('a', 'm', 'l', 'o')
+
+//
+// Device Status Bitmap (Section 6.3.7 ACPI version 6.3)
+// Bit [0] - Set if the device is present.
+// Bit [1] - Set if the device is enabled and decoding its resources.
+// Bit [2] - Set if the device should be shown in the UI.
+// Bit [3] - Set if the device is functioning properly (cleared if device
+// failed its diagnostics).
+// Bit [4] - Set if the battery is present.
+// Bits [31:5] - Reserved (must be cleared).
+//
+#define DEVICE_PRESENT_BIT 0x0001
+#define DEVICE_ENABLED_BIT 0x0002
+#define DEVICE_IN_UI_BIT 0x0004
+#define DEVICE_HEALTH_BIT 0x0008
+#define DEVICE_BATTERY_BIT 0x0010 // Control Method Battery Device Only
+
+typedef enum {
+ UnknownObj,
+ IntObj,
+ StrObj,
+ BuffObj,
+ PkgObj,
+ FieldUnitObj,
+ DeviceObj,
+ EventObj,
+ MethodObj,
+ MutexObj,
+ OpRegionObj,
+ PowerResObj,
+ ProcessorObj,
+ ThermalZoneObj,
+ BuffFieldObj,
+ DDBHandlObj,
+ InvalidObj
+} OBJECT_TYPE_KEYWORD;
+
+typedef struct {
+ UINT32 Signature;
+ BOOLEAN Completed;
+ UINTN DataSize;
+ UINT8 *Data;
+ LIST_ENTRY Link;
+} AML_OBJECT_INSTANCE;
+
+// ***************************************************************************
+// AML defines to be consistent with already existing
+// MdePkg/Include/IndustryStandard/Acpi*.h defines.
+// *** These could be upstreamed at some point.
+// ***************************************************************************
+// Limits of (DWord|Word|QWord)Space ResourceType
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MIN 0xC0
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MAX 0xFF
+
+// General Flags: Flags that are common to all resource types
+// Bits[7:4] Reserved(must be 0)
+// Bit[3] Max Address Fixed, _MAF:
+// 1 The specified maximum address is fixed
+// 0 The specified maximum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED (1 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED (0 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MAF EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+// Bit[2] Min Address Fixed, _MIF:
+// 1 The specified minimum address is fixed
+// 0 The specified minimum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED (1 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED (0 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MIF EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+// Bit[1] Decode Type, _DEC:
+// 1 This bridge subtractively decodes this address(top level bridges only)
+// 0 This bridge positively decodes this address
+#define EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE (1 << 1)
+#define EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE (0 << 1)
+#define EFI_ACPI_GENERAL_FLAG_MASK_DEC EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+// Bit[0] Consumer / Producer:
+// 1 This device consumes this resource
+// 0 This device produces and consumes this resource
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER (1 << 0)
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER (0 << 0)
+#define EFI_ACPI_GENERAL_FLAG_MASK_USAGE EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+
+// Memory Resource Flag (Resource Type = 0) DefinitionsBits
+// Memory Resource Flag Masks
+// Bits[7:6] Reserved(must be 0)
+// Bit[5] Memory to I/O Translation, _TTP:
+// 0 TypeStatic
+// 1 Type Translation
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_TTP (1 << 5)
+// Bit[4:3] Memory Attributes, _MTP:
+// 0 AddressRangeMemory
+// 1 AddressRangeReserved
+// 2 AddressRangeACPI
+// 3 AddressRangeNVS
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MTP (3 << 3)
+// Bit[2:1] Memory Attributes, _MEM:
+// 0 The memory is non-cacheable
+// 1 The memory is cacheable
+// 2 The memory is cacheable and supports write-combining
+// 3 The memory is cacheable and prefetchable
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM (3 << 1)
+// Bit[0] Write Status, _RW:
+// 0 This memory range is read-only
+// 1 This memory is read-write
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW (1 << 0)
+
+// I/O Resource Flag (Resource Type = 1) DefinitionsBits
+// I/O Resource Flags
+// Bit [7:6] Reserved (must be 0)
+// Bit [5] Sparse Translation, _TRS. This bit is only meaningful if Bit [4] is set.
+// 1 SparseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = (((port & 0xFFFc) << 10) || (port & 0xFFF)) + _TRA In the address
+// used to access the I/O port, bits[11:2] must be identical to bits[21:12],
+// this gives four bytes of I/O ports on each 4 KB page.
+// 0 DenseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = port + _TRA
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_SPARSE_TRANSLATION (1 << 5)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_DENSE_TRANSLATION (0 << 5)
+// Bit [4] I/O to Memory Translation, _TTP
+// 1 TypeTranslation: This resource, which is I/O on the secondary side of the
+// bridge, is memory on the primary side of the bridge.
+// 0 TypeStatic: This resource, which is I/O on the secondary side of the
+// bridge, is also I/O on the primary side of the bridge.
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION (1 << 4)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC (0 << 4)
+// Bit [3:2] Reserved (must be 0)
+// Bit [1:0] _RNG
+// 3 Memory window covers the entire range
+// 2 ISARangesOnly. This flag is for bridges on systems with multiple bridges.
+// Setting this bit means the memory window specified in this descriptor is
+// limited to the ISA I/O addresses that fall within the specified window. The
+// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. This bit can
+// only be set for bridges entirely configured throughACPI namespace.
+// 1 NonISARangesOnly. This flag is for bridges on systems with multiple
+// bridges. Setting this bit means the memory window specified in this
+// descriptor is limited to the non-ISA I/O addresses that fall within the
+// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7FF,
+// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entirely
+// configured through ACPI namespace.
+// 0 Reserved
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE (3 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY (2 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY (1 << 0)
+
+#define AML_OBJECT_INSTANCE_FROM_LINK(a) BASE_CR (a, AML_OBJECT_INSTANCE, Link)
+
+// Method Serialize Flag Values
+typedef enum {
+ NotSerialized,
+ Serialized,
+ FlagInvalid
+} METHOD_SERIALIZE_FLAG;
+// AccessField Access Attrib Flags.
+// Ref ACPI spec 6.3
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL 0x00
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK 0x02
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE 0x04
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE 0x06
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD 0x08
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK 0x0A
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES 0x0B
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL 0x0C
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL 0x0D
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES 0x0E
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES 0X0F
+
+// AccessField access types
+typedef enum {
+ AnyAcc,
+ ByteAcc,
+ WordAcc,
+ DWordAcc,
+ QWordAcc,
+ BufferAcc,
+} EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS;
+
+// Field lock rules
+typedef enum {
+ NoLock,
+ Lock
+} EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS;
+
+// Field update rules
+typedef enum {
+ Preserve,
+ WriteAsOnes,
+ WriteAsZeros
+} EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS;
+
+// Field access attributes. for AttribBytes, AttribRawBytes and AttribRawProcessBytes
+// the ExtendedAccessField definition is used, as this is what iASL compiles into, rather
+// than the AccessField that is specified in the ACPI spec.
+typedef enum {
+ AttribNormal = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL,
+ AttribQuick = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK,
+ AttribSendReceive = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE,
+ AttribByte = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE,
+ AttribWord = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD,
+ AttribBlock = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK,
+ AttribBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES,
+ AttribProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL,
+ AttribBlockProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL,
+ AttribRawBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES,
+ AttribRawProcessBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
+} EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS;
+
+//
+// Resource Type Specific Flags
+// Ref ACPI specification 6.4.3.5.5
+//
+//
+// DMA Information
+// Ref ACPI specification 6.4.2.2
+//
+// DmaType values
+typedef enum {
+ Compatibility = EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY,
+ TypeA = EFI_ACPI_DMA_SPEED_TYPE_A,
+ TypeB = EFI_ACPI_DMA_SPEED_TYPE_B,
+ TypeF = EFI_ACPI_DMA_SPEED_TYPE_F
+} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS;
+
+// IsBusMaster values
+typedef enum {
+ NotBusMaster = 0,
+ BusMaster = EFI_ACPI_DMA_BUS_MASTER
+} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS;
+
+// DmaTransferSize values
+typedef enum {
+ Transfer8 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT,
+ Transfer8_16 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT,
+ Transfer16 = EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT
+} EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS;
+
+//
+// Interrupt Resource Descriptor Information
+// Ref ACPI specification 6.4.2.1
+//
+// IRQ Information - Wake Capability
+//
+#define EFI_ACPI_IRQ_WAKE_CAPABLE_MASK 0x20
+#define EFI_ACPI_IRQ_NOT_WAKE_CAPABLE 0x0
+#define EFI_ACPI_IRQ_WAKE_CAPABLE 0x20
+
+typedef enum {
+ NotWakeCapable = EFI_ACPI_IRQ_NOT_WAKE_CAPABLE,
+ WakeCapable = EFI_ACPI_IRQ_WAKE_CAPABLE
+} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Sharing
+//
+#define EFI_ACPI_IRQ_EXCLUSIVE 0x0
+
+typedef enum {
+ Exclusive = EFI_ACPI_IRQ_EXCLUSIVE,
+ Shared = EFI_ACPI_IRQ_SHARABLE,
+ ExclusiveAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_EXCLUSIVE,
+ SharedAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_SHARABLE
+} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Polarity
+//
+typedef enum {
+ ActiveHigh = EFI_ACPI_IRQ_HIGH_TRUE,
+ ActiveLow = EFI_ACPI_IRQ_LOW_FALSE
+} EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Mode
+//
+#define EFI_ACPI_IRQ_MODE_MASK 0x1
+typedef enum {
+ LevelTriggered = EFI_ACPI_IRQ_LEVEL_TRIGGERED,
+ EdgeTriggered = EFI_ACPI_IRQ_EDGE_TRIGGERED
+} EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS;
+
+// IO Port Descriptor Information
+// Ref ACPI specification 6.4.2.5
+//
+typedef enum {
+ Decode16 = EFI_ACPI_IO_DECODE_16_BIT,
+ Decode10 = EFI_ACPI_IO_DECODE_10_BIT
+} EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION;
+
+//
+// Memory Resource Information
+// Ref ACPI specification 6.4.3.5
+//
+// Consumer/Producer Bit[0]
+typedef enum {
+ ResourceProducer = EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER,
+ ResourceConsumer = EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+} RESOURCE_USAGE_FLAG;
+
+// Decode Type (_DEC) Bit[1]
+typedef enum {
+ PosDecode = EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE,
+ SubDecode = EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+} MEM_DECODE_FLAG;
+
+// Min Address Fixed (_MIF) Bit[2]
+typedef enum {
+ MinNotFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED,
+ MinFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+} MIN_FIXED_FLAG;
+
+// Max Address Fixed (_MAF) Bit[3]
+typedef enum {
+ MaxNotFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED,
+ MaxFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+} MAX_FIXED_FLAG;
+
+// Memory Attributes (_MEM) Bits[2:1]
+typedef enum {
+ NonCacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE,
+ Cacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE,
+ WriteCombining = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING,
+ Prefetchable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+} CACHEABLE_FLAG;
+
+// Write Status (_RW) Bit[0]
+typedef enum {
+ ReadOnly = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY,
+ ReadWrite = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE
+} READ_WRITE_FLAG;
+
+// Memory Attributes (_MTP) Bits[4:3]
+typedef enum {
+ AddressRangeMemory = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY,
+ AddressRangeReserved = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED,
+ AddressRangeACPI = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI,
+ AddressRangeNVS = EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS
+} MEMORY_RANGE_TYPE;
+
+// Memory to IO Translation (_TTP) Bit[5]
+// Note: IO and Memory Resources use different bits for this.
+// Value must be handled at function level when implemented.
+typedef enum {
+ TypeStatic = 0,
+ TypeTranslation = 1
+} MEMORY_TRANSLATION_TYPE;
+
+// Memory Window Attributes (_RNG) Bits[1:0]
+typedef enum {
+ Reserved = 0,
+ NonISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY,
+ ISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY,
+ EntireRange = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE,
+ ISARangeMax
+} IO_ISA_RANGES;
+
+// Generic Address Space Address IDs
+typedef enum {
+ SystemMemory = EFI_ACPI_6_4_SYSTEM_MEMORY,
+ SystemIO = EFI_ACPI_6_4_SYSTEM_IO,
+ PCI_Config = EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE,
+ EmbeddedControl = EFI_ACPI_6_4_EMBEDDED_CONTROLLER,
+ SMBus = EFI_ACPI_6_4_SMBUS,
+ SystemCMOS = EFI_ACPI_6_4_SYSTEM_CMOS,
+ PciBarTarget = EFI_ACPI_6_4_PCI_BAR_TARGET,
+ IPMI = EFI_ACPI_6_4_IPMI,
+ GeneralPurposeIO = EFI_ACPI_6_4_GENERAL_PURPOSE_IO,
+ GenericSerialBus = EFI_ACPI_6_4_GENERIC_SERIAL_BUS,
+ PCC = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ PlatformCommChannel = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ FFixedHW = EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE
+} GENERIC_ADDRESS_SPACE_ID;
+
+typedef enum {
+ UndefinedSize = EFI_ACPI_6_4_UNDEFINED,
+ ByteSize = EFI_ACPI_6_4_BYTE,
+ WordSize = EFI_ACPI_6_4_WORD,
+ DWordSize = EFI_ACPI_6_4_DWORD,
+ QWordSize = EFI_ACPI_6_4_QWORD
+} ACPI_DATA_SIZE;
+
+typedef ACPI_DATA_SIZE GENERIC_ADDRESS_ACCESS_SIZE;
+
+// ***************************************************************************
+// AML Objects
+// ***************************************************************************
+
+// ---------------------------------------------------------------------------
+// Table and Table Header Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Name Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Namestring AML Object and inserts it into the linked list
+
+ Completes NameString in one call as "one phase"
+ LeadNameChar := 'A'-'Z' | '_'
+ DigitChar := '0'-'9'
+ NameChar := DigitChar | LeadNameChar
+ RootChar := '\'
+ ParentPrefixChar := '^'
+
+ 'A'-'Z' := 0x41 - 0x5A
+ '_' := 0x5F
+ '0'-'9' := 0x30 - 0x39
+ '\' := 0x5C
+ '^' := 0x5E
+
+ NameSeg := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Data Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates an optimized integer object
+
+ 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] Phase - Example: AmlStart, AmlClose
+ @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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a data string object
+
+ ComputationalData := String
+
+ String := StringPrefix AsciiCharList NullChar
+ StringPrefix := 0x0D
+ AsciiCharList := Nothing | <AsciiChar AsciiCharList>
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Package Length Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Package Length AML Object and inserts it into the linked list
+
+ PkgLength := PkgLeadByte |
+ <PkgLeadByte ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Term Objects Encoding
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Namespace Modifier Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ Creates a Name (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := NameOp NameString DataRefObject
+ NameOp := 0x08
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Named Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Field
+
+ Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be created 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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.
+
+ 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 that has completed AccessAs Object
+ after AmlClose.
+
+ @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
+ );
+
+/**
+ 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 since AML does not store
+ ArgTypes here.
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Type 1 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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 pkglength termlist>
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlReturn (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+// ---------------------------------------------------------------------------
+// Type 2 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 PackageElementList>
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] NumElements - Number of elements in the package
+ @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
+ );
+
+// ---------------------------------------------------------------------------
+// Resource Descriptor Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlDWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/*
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlQWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Expression Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Miscellaneous Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Shift Left expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Reult) => 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Assistance Functions
+// ***************************************************************************
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Debug Functions
+// ***************************************************************************
+
+/**
+ 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Buffer - Buffer containing buffer
+ @param[in] BufferSize - Number of bytes to print
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintBuffer (
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ );
+
+/**
+ DEBUG print a 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Object - AML_OBJECT_INSTANCE
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintObject (
+ IN AML_OBJECT_INSTANCE *Object
+ );
+
+/**
+ 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
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintLinkedObjects (
+ IN LIST_ENTRY *ListHead
+ );
+
+#endif // AML_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
new file mode 100644
index 0000000000..d48ca1a90a
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
@@ -0,0 +1,25 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AmdPspRomArmorLib.h>
+
+/*
+ * 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 couldn't be allocated
+ */
+EFI_STATUS
+EFIAPI
+GetPspRomArmorWhitelist (
+ IN SPI_WHITE_LIST **PlatformSpiWhitelist
+ );
diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
new file mode 100644
index 0000000000..6c854651cc
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
@@ -0,0 +1,134 @@
+/** @file
+ AMD Psp Ftpm Ppi Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_PPI_H_
+#define PSP_FTPM_PPI_H_
+#include <Uefi.h>
+
+typedef struct _PSP_FTPM_PPI PSP_FTPM_PPI;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Info
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+ **/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs.
+
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @retval EFI_STATUS 0: Success, Non-Zero Error
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ PSP_FTPM_PPI prototype
+
+ Defines PSP_FTPM_PPI. This PPI is used to get Ftpm info.
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PPI {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+} PSP_FTPM_PPI;
+
+extern EFI_GUID gAmdPspFtpmPpiGuid;
+extern EFI_GUID gAmdPspFtpmFactoryResetPpiGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
new file mode 100644
index 0000000000..715cbbcf78
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
@@ -0,0 +1,183 @@
+/** @file
+ CXL Configuration Services Protocol prototype definition
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_
+#define NBIO_CXL_SERVICES_PROTOCOL_H_
+
+#include "AMD.h"
+#include <Protocol/FabricTopologyServices2.h>
+#include <Protocol/FabricResourceManagerServicesProtocol.h>
+
+#define AMD_NBIO_CXL_SERVICES_REVISION 0x00
+
+/// Forward declaration for the AMD_NBIO_CXL_SERVICES_PROTOCOL
+typedef struct _AMD_NBIO_CXL_SERVICES_PROTOCOL AMD_NBIO_CXL_SERVICES_PROTOCOL;
+
+extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL services protocol calling
+
+#pragma pack (push, 1)
+/// Port Information Structure
+typedef struct _AMD_CXL_PORT_INFO_STRUCT {
+ PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root Port in PCI_ADDR format
+ UINT8 LogicalNbioInstance; ///< Logical Instance ID of NBIO
+ UINT8 PhysicalNbioInstance; ///< Physical Instance ID of NBIO where this port is located
+ UINT8 SocketID; ///< Socket ID for this port
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT8 PortId; ///< Physical port location
+ UINT8 PortWidth; ///< Lane width of the port
+ UINT32 CxlPortAddress; ///< CXL root port address (CXL 2.0 root port or CXL 1.1 RCiEP)
+ BOOLEAN IsSwitch; ///< CXL Switch flag
+} AMD_CXL_PORT_INFO_STRUCT;
+
+/// Port MMIO32 Resources Information Structure
+typedef struct _AMD_CXL_RESOURCES_INFO_STRUCT {
+ UINT32 Mmio32Base[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Size[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Gran;
+} AMD_CXL_RESOURCES_INFO_STRUCT;
+#pragma pack (pop)
+
+// Protocol Definitions
+
+/**
+ This function gets information about a specific PCIe root port.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortInformation
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_ROOT_PORT_INFORMATION)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr
+ IN UINTN PortIndex, ///< port index
+ OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port information ptr
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL capabilities.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port.
+ PortInformation OPTIONAL (can be NULL)
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_CONFIGURE_ROOT_PORT)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< this ptr
+ IN PCI_ADDR EndpointBDF ///< end pt bdf
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL presence
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port such as Socket id,rbindex,port id,segment,bus base,limit or presence.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_AVAILABLE)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT FABRIC_RESOURCE_FOR_EACH_RB *ResourceForEachRb ///<
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_PORT_RB_LOCATION)(
+ ///< get port rb location
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN UINT8 Segment, ///<
+ IN UINT8 BusBase, ///<
+ OUT UINT8 *SocketId, ///<
+ OUT UINT8 *RbIndex ///<
+ );
+
+/**
+ This function gets the CXL MMIO32 values to be used by the fabric resource manager
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ CxlMmio32ResourceForEachRb
+ A pointer to the structure that will hold the MMIO32 base and size values for each root bridge
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_INFORMATION)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT AMD_CXL_RESOURCES_INFO_STRUCT *CxlMmio32Resources ///<
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_REPORT_TO_MPIO)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This ///< ptr to protocol
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_FIND_2P0_DEVICES)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN UINTN PortIndex ///< port index
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+VOID
+(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN PCI_ADDR CxlPciAddress ///< PCI address
+ );
+
+/// The Protocol Definition for CXL Services
+struct _AMD_NBIO_CXL_SERVICES_PROTOCOL {
+ UINT32 Revision; ///< revision
+ UINTN CxlCount; ///< CXL count
+ AMD_CXL_GET_ROOT_PORT_INFORMATION CxlGetRootPortInformation; ///< CXL root port information
+ AMD_CXL_CONFIGURE_ROOT_PORT CxlConfigureRootPort; ///< configuring the root port
+ AMD_CXL_GET_PORT_RB_LOCATION GetCxlPortRBLocation; ///< CXL port RB location
+ AMD_CXL_RESOURCES_AVAILABLE GetCxlAvailableResources; ///< Get resources allocated for CXL RCiEP
+ AMD_CXL_RESOURCES_INFORMATION GetCxlMmio32Resources; ///< Get CXL MMIO resources for CXL RCiEP
+ AMD_CXL_REPORT_TO_MPIO CxlReportToMpio; ///< Sends the CXL info to MPIO
+ AMD_CXL_FIND_2P0_DEVICES CxlFind2p0Devices; ///< Finds CXL 2.0 devices after PCIe enumeration
+ AMD_CXL_ENABLE_SCM_PMEM CxlEnableScmForPersistentMemory; ///< Notifies SMU that CXL persistent memory is present
+};
+
+#endif /* NBIO_CXL_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
new file mode 100644
index 0000000000..7bcff65dc9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
@@ -0,0 +1,110 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCI_RESOURCES_PROTOCOL_H_
+#define AMD_PCI_RESOURCES_PROTOCOL_H_
+
+typedef struct {
+ UINTN Index;
+ UINT8 SocketId;
+ UINTN Segment;
+ UINTN BaseBusNumber;
+} PCI_ROOT_BRIDGE_OBJECT;
+
+typedef struct {
+ UINTN Index;
+ BOOLEAN Enabled;
+ UINT8 PortPresent;
+ UINTN Device;
+ UINTN Function;
+ UINTN SlotNum;
+ // Interrupts are relative to IOAPIC 0->n
+ UINTN BridgeInterrupt; // Redirection table entry for mapped bridge interrupt
+ UINTN EndpointInterruptArray[4]; // Redirection table entries for mapped INT A/B/C/D
+} PCI_ROOT_PORT_OBJECT;
+
+typedef enum {
+ IOMMU = 0,
+ IOAPIC
+} FIXED_RESOURCE_TYPE;
+
+typedef struct {
+ UINTN Index;
+ FIXED_RESOURCE_TYPE ResourceType;
+ UINTN Address;
+ UINTN Limit;
+} FIXED_RESOURCES_OBJECT;
+
+/// Forward declaration for the AMD_PCI_RESOURCES_PROTOCOL.
+typedef struct _AMD_PCI_RESOURCES_PROTOCOL AMD_PCI_RESOURCES_PROTOCOL;
+
+/**
+ * @brief System information through EFI call
+ * @details
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ OUT UINTN *NumberOfRootBridges
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT PCI_ROOT_BRIDGE_OBJECT **RootBridgeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfRootPorts
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN RootPortIndex,
+ OUT PCI_ROOT_PORT_OBJECT **RootPortInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfFixedResources
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN FixedResourceIndex,
+ OUT FIXED_RESOURCES_OBJECT **FixedResourceInfo
+ );
+
+struct _AMD_PCI_RESOURCES_PROTOCOL {
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES AmdPciResourcesGetNumberOfRootBridges;
+ AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO AmdPciResourcesGetRootBridgeInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS AmdPciResourcesGetNumberOfRootPorts;
+ AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO AmdPciResourcesGetRootPortInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES AmdPciResourcesGetNumberOfFixedResources;
+ AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO AmdPciResourcesGetFixedResourceInfo;
+};
+
+extern EFI_GUID gAmdPciResourceProtocolGuid; ///< Guid for calling
+
+#endif // AMD_PCI_RESOURCES_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
new file mode 100644
index 0000000000..ebc7812b18
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
@@ -0,0 +1,187 @@
+/** @file
+ AMD Psp Ftpm Protocol Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FTPM_PROTOCOL_H_
+#define FTPM_PROTOCOL_H_
+
+#include <Uefi.h>
+//
+// GUID definition
+//
+extern EFI_GUID gAmdPspFtpmProtocolGuid;
+
+/**
+ structure definition for HSP mailbox
+
+**/
+typedef struct {
+ // C2H_TPM_L0
+ UINT64 TPM_L0_Address; /// Mailbox address
+ UINT64 TPM_L0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L0(VLT0)
+ UINT64 VLT0_Address; /// Mailbox address
+ UINT64 VLT0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L1(VLT1)
+ UINT64 VLT1_Address; /// Mailbox address
+ UINT64 VLT1_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT1_HSC_MSG_Address; /// Doorbell address HSP->CPU
+
+ // Interrupt Information
+ UINT8 Gsi[4]; /// Gsi[0] is for HSP Channel 0 TPM
+ /// Gsi[1] is for HSP Channel 1 VTL0
+ /// Gsi[2] is for HSP Channel 2 VTL1
+ /// Gsi[3] is reserved
+} HSP_MAILBOX_ADDRESS, *PHSP_MAILBOX_ADDRESS;
+
+typedef union {
+ HSP_MAILBOX_ADDRESS HSP_info;
+} FTPM_INFO;
+
+typedef struct _PSP_FTPM_PROTOCOL PSP_FTPM_PROTOCOL;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Information
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Function prototype for GetHspfTPMInfo. Return Pluton mailbox base address to SBIOS.
+ SBIOS should call this procedure after PCI Enumeration Complete.
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmInfo Point to Pluton mailbox base address
+
+ @return EFI_SUCCESS - Success
+ @return EFI_INVALID_PARAMETER - Input parameter is invalid
+ @return EFI_NOT_READY - Pluton-fTPM device BAR0 MMIO is not ready.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TPM_INFO)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *FtpmInfo
+ );
+
+/**
+ PSP_FTPM_PROTOCOL prototype
+
+ Defines PSP_FTPM_PROTOCOL. This protocol is used to get Ftpm info
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PROTOCOL {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+ FTPM_GET_TPM_INFO GetInfo; ///< Get TPM info
+} PSP_FTPM_PROTOCOL;
+
+#endif //FTPM_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
new file mode 100644
index 0000000000..7f57facf88
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+ Fabric MMIO map manager Protocol prototype definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#include <FabricResourceManagerCmn.h>
+
+#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
new file mode 100644
index 0000000000..a7fef5a35c
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
@@ -0,0 +1,19 @@
+/** @file
+ AMD CPM Base Definitions.
+
+ Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_BASE_H_
+#define AMD_CPM_BASE_H_
+
+#include <Base.h>
+#include <Uefi.h>
+#include <PiPei.h>
+#include <AmdCpmCommon.h>
+#include <Library/DebugLib.h>
+
+#endif // AMD_CPM_BASE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
new file mode 100644
index 0000000000..af192fcf03
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
@@ -0,0 +1,78 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_COMMON_H_
+#define AMD_CPM_COMMON_H_
+
+#pragma pack(push)
+
+#include <AGESA.h>
+#include <AmdPcieComplex.h>
+#include <AmdCpmDefine.h>
+#include <AmdCpmFunction.h>
+
+/// The signatures of CPM table
+
+typedef enum {
+ CPM_SIGNATURE_DXIO_TOPOLOGY = SIGNATURE_32 ('$', 'A', '2', '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE
+ CPM_SIGNATURE_DXIO_TOPOLOGY_S1 = SIGNATURE_32 ('$', 'A', '2', '7') ///< The signature of Socket 1 AMD_CPM_DXIO_TOPOLOGY_TABLE
+} AMD_CPM_TABLE_SIGNATURE;
+
+/// CPM table header
+typedef struct {
+ UINT32 TableSignature; ///< Signature of CPM table
+ UINT16 TableSize; ///< Table size
+ UINT8 FormatRevision; ///< Revision of table format
+ UINT8 ContentRevision; ///< Revision of table content
+ UINT32 PlatformMask; ///< The mask of platform table supports
+ UINT32 Attribute; ///< Table attribute
+} AMD_CPM_TABLE_COMMON_HEADER;
+
+/// Table pointer
+typedef union {
+ VOID *Pointer; ///< Table pointer
+ UINT64 Raw; ///< Table pointer value
+} AMD_CPM_POINTER;
+
+/// DXIO Topology Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR Port[AMD_DXIO_PORT_DESCRIPTOR_SIZE]; ///< DXIO Port Descriptor List
+} AMD_CPM_DXIO_TOPOLOGY_TABLE;
+
+/// AMD CPM Main Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT8 PlatformName[32]; ///< Platform name
+ UINT8 BiosType; ///< BIOS type
+ UINT16 CurrentPlatformId; ///< Current Platform Id
+ UINT32 PcieMemIoBaseAddr; ///< PcieMemIoBaseAddr
+ UINT32 AcpiMemIoBaseAddr; ///< AcpiMemIoBaseAddr
+ AMD_CPM_POINTER Service; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRomList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRamList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInHobList; ///< Reserved for internal use
+ AMD_CPM_POINTER HobTablePtr; ///< Reserved for internal use
+
+ UINT8 ExtClkGen; ///< External ClkGen Config. 0x00~0x7F
+ UINT8 UnusedGppClkOffEn; ///< Config to turn off unused GPP clock
+ UINT8 LpcUartEn; ///< LpcUartEn
+ UINT64 AltAcpiMemIoBaseAddr; ///< Alternate AcpiMemIoBaseAddr for Slave FCH
+} AMD_CPM_MAIN_TABLE;
+
+/// Structure for Chip Id
+typedef struct {
+ UINT8 Cpu; ///< CPU/APU Chip Id
+ UINT8 Sb; ///< SB Chip Id
+ UINT8 Reserved[6];
+} AMD_CPM_CHIP_ID;
+#pragma pack (pop)
+
+#endif //AMD_CPM_COMMON_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
new file mode 100644
index 0000000000..4fc3f97a80
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
@@ -0,0 +1,17 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_DEFINE_H_
+#define AMD_CPM_DEFINE_H_
+
+#ifndef AMD_DXIO_PORT_DESCRIPTOR_SIZE
+#define AMD_DXIO_PORT_DESCRIPTOR_SIZE 0x30
+#endif
+
+#endif // AMD_CPM_DEFINE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
new file mode 100644
index 0000000000..7dce238135
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
@@ -0,0 +1,32 @@
+/** @file
+ AMD CPM Common Functions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_FUNCTION_H_
+#define AMD_CPM_FUNCTION_H_
+
+typedef VOID *(EFIAPI *AMD_CPM_GETTABLEPTR_FN)(
+ IN VOID *This,
+ IN UINT32 TableId
+ );
+
+typedef AGESA_STATUS (EFIAPI *AMD_CPM_GETPOSTEDVBIOSIMAGE_FN)(
+ IN GFX_VBIOS_IMAGE_INFO *VbiosImageInfo
+ );
+
+/// Common Functions for CPM Drivers
+typedef struct _AMD_CPM_COMMON_FUNCTION {
+ AMD_CPM_GETTABLEPTR_FN GetTablePtr2; ///< Get CPM Table Pointer. The table can be re-writable
+} AMD_CPM_COMMON_FUNCTION;
+
+/// CPM Public Functions for platform DXE Driver to use
+typedef struct _AMD_CPM_DXE_PUBLIC_FUNCTION {
+ AMD_CPM_GETPOSTEDVBIOSIMAGE_FN GetPostedVbiosImage; ///< Get posted VBIOS image
+} AMD_CPM_DXE_PUBLIC_FUNCTION;
+
+#endif //AMD_CPM_FUNCTION_H_
diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
new file mode 100644
index 0000000000..4a90aa3d8b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
@@ -0,0 +1,39 @@
+/** @file
+ AMD CPM Table Protocol.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_TABLE_PROTOCOL_H_
+#define AMD_CPM_TABLE_PROTOCOL_H_
+
+#include <AmdCpmBase.h>
+
+//
+// GUID definition
+//
+#define AMD_CPM_TABLE_PROTOCOL_GUID \
+ { 0x3724cf01, 0x00c2, 0x9762, 0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }
+
+#define AMD_CPM_TABLE_SMM_PROTOCOL_GUID \
+ { 0xaf6efacf, 0x7a13, 0x45a3, 0xb1, 0xa5, 0xaa, 0xfc, 0x06, 0x1c, 0x4b, 0x79 }
+
+extern EFI_GUID gAmdCpmTableProtocolGuid;
+extern EFI_GUID gAmdCpmTableSmmProtocolGuid;
+
+/// DXE Protocol Structure
+typedef struct _AMD_CPM_TABLE_PROTOCOL {
+ UINTN Revision; ///< Protocol Revision
+ AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Pointer to CPM Main Table
+ AMD_CPM_CHIP_ID ChipId; ///< Id of SB Chip
+ AMD_CPM_COMMON_FUNCTION CommonFunction; ///< Private Common Functions
+ AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///< Public Function of Protocol
+} AMD_CPM_TABLE_PROTOCOL;
+
+// Current Protocol Revision
+#define AMD_CPM_TABLE_PROTOCOL_REV 0x00
+
+#endif // AMD_CPM_TABLE_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
new file mode 100644
index 0000000000..fa83888e95
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
@@ -0,0 +1,31 @@
+/** @file
+ PSP Mailbox related functions
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
new file mode 100644
index 0000000000..0e9baad955
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
new file mode 100644
index 0000000000..a04bc1f992
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
@@ -0,0 +1,79 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/AmdPspRomArmorLib.h>
+
+/**
+ * Request secures the SPI Controller
+ *
+ * @param[in, out] SpiCommunicationBuffer SPI Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI White List structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @param[in] NONE
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request PSP firmware switch SPI controller chip select.
+ *
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
new file mode 100644
index 0000000000..fce82d75b0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
new file mode 100644
index 0000000000..f8b9eb0bcf
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Base.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
new file mode 100644
index 0000000000..cff678d76b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
@@ -0,0 +1,37 @@
+** @file
+ Fabric Topology Base Lib implementation
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ )
+{
+ return 0;
+}
+
+RETURN_STATUS
+EFIAPI
+BaseFabricTopologyLibConstructor (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
new file mode 100644
index 0000000000..f72cbe7dff
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
@@ -0,0 +1,8 @@
+/** @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.<BR>
+
+ 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
new file mode 100644
index 0000000000..a155978a5d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
@@ -0,0 +1,35 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+
+/** The constructor function determines the actual TSC frequency.
+
+ First, Get TSC frequency from system configuration table with TSC frequency GUID,
+ if the table is not found, install it.
+ This function will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeTscTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
new file mode 100644
index 0000000000..f70aa3de0e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
@@ -0,0 +1,11 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/HobLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
new file mode 100644
index 0000000000..7d14d62e60
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
@@ -0,0 +1,103 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/** Stalls the CPU for at least the specified number of MicroSeconds.
+
+ @param[in] MicroSeconds The minimum number of microseconds to delay.
+
+ @return The value of MicroSeconds input.
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ return 0;
+}
+
+/** Stalls the CPU for at least the specified number of NanoSeconds.
+
+ @param[in] NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return The value of NanoSeconds input.
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ return 0;
+}
+
+/** Retrieves the current value of the 64-bit free running Time-Stamp counter.
+
+ The properties of the counter can be retrieved by the
+ GetPerformanceCounterProperties() function.
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return 0;
+}
+
+/** Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
+ that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
+ EndValue.
+
+ The 64-bit frequency of the performance counter, in Hz, is always returned.
+
+ @param[out] StartValue Pointer to where the performance counter's starting value is saved, or NULL.
+ @param[out] EndValue Pointer to where the performance counter's ending value is saved, or NULL.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ OUT UINT64 *StartValue, OPTIONAL
+ OUT UINT64 *EndValue OPTIONAL
+ )
+{
+ return 0;
+}
+
+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ return 0;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
new file mode 100644
index 0000000000..44e23df62f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
@@ -0,0 +1,95 @@
+/** @file
+ AMD instance of the PCI Host Bridge Library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/PciHostBridgeResourceAllocation.h>
+
+/**
+ Sort all root bridges in bus ascending order and set DevicePath UIDs
+ continuous and ascending from zero
+
+ @param[in,out] RootBridgeList Array of root bridges.
+ @param[in] Count Count of root bridges in RootBridgeList
+
+ @return All the root bridge instances in an array are sorted in bus order.
+ DevicePath UID updated to continuous and ascending numbers starting
+ with 0.
+**/
+VOID
+EFIAPI
+PciHostBridgeSortRootBridges (
+ IN PCI_ROOT_BRIDGE *RootBridgeList,
+ IN UINTN Count
+ )
+{
+}
+
+/**
+ Return all the root bridge instances in an array.
+
+ @param Count Return the count of root bridge instances.
+
+ @return All the root bridge instances in an array.
+ The array should be passed into PciHostBridgeFreeRootBridges()
+ when it's not used.
+**/
+PCI_ROOT_BRIDGE *
+EFIAPI
+PciHostBridgeGetRootBridges (
+ UINTN *Count
+ )
+{
+ return (PCI_ROOT_BRIDGE *)NULL;
+}
+
+/**
+ Free the root bridge instances array returned from PciHostBridgeGetRootBridges().
+
+ @param Bridges The root bridge instances array.
+ @param Count The count of the array.
+**/
+VOID
+EFIAPI
+PciHostBridgeFreeRootBridges (
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
+ )
+{
+}
+
+/**
+ Inform the platform that the resource conflict happens.
+
+ @param HostBridgeHandle Handle of the Host Bridge.
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ for all the root bridges. The resource for each root
+ bridge is terminated with END descriptor and an
+ additional END is appended indicating the end of the
+ entire resources. The resource descriptor field
+ values follow the description in
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
+ .SubmitResources().
+**/
+VOID
+EFIAPI
+PciHostBridgeResourceConflict (
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
new file mode 100644
index 0000000000..318f8e5ad7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -0,0 +1,154 @@
+/** @file
+
+ Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE
+
+/*
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ ArgN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
new file mode 100644
index 0000000000..371537c9aa
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -0,0 +1,151 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLASSISTFUNCTIONS_FILECODE
+
+/**
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ListHead = AllocatePool (sizeof (LIST_ENTRY));
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlFreeObjectList (*ListHead);
+ FreePool (*ListHead);
+ *ListHead = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
new file mode 100644
index 0000000000..b7d4f4c9d7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -0,0 +1,640 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE
+
+/*
+ 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__, 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", __func__, "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", __func__, 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 AsciiCharList>
+ 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",
+ __func__,
+ Index,
+ String
+ ));
+ return Status;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, 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",
+ __func__,
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AsciiStrLen (String) != 0x7) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String' parameter.\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
new file mode 100644
index 0000000000..e8ea9d8e84
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -0,0 +1,1294 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECODE
+
+// ----------------------------------------------------------------------------
+// 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __func__));
+ goto Done;
+ }
+
+ // Start BufferSize
+ Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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",
+ __func__,
+ InternalBufferSize
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ InternalBufferSize,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
new file mode 100644
index 0000000000..21deb200e3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLLOCALOBJECTS_FILECODE
+
+/**
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ LocalN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
new file mode 100644
index 0000000000..0502547a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -0,0 +1,576 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESTRING_FILECODE
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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 := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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", __func__, 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",
+ __func__,
+ 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more than 1 RootChar.\n", __func__, String));
+ goto Done;
+ }
+
+ if (FoundParentPrefixChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
new file mode 100644
index 0000000000..37ae9319be
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -0,0 +1,2138 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMEDOBJECT_FILECODE
+
+#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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ InternalOffsetData = *(UINT64 *)OffsetObject->Data;
+
+ if (InternalOffsetData > BitCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataLength);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, BankName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, IndexName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Offset, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Length, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (BitIndex, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NumBits, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+ } else {
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ Status = AmlOPDataInteger (Index, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FixedFieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
new file mode 100644
index 0000000000..afe51cdcf2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -0,0 +1,360 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_FILECODE
+
+/**
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, AliasName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n", __func__));
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
new file mode 100644
index 0000000000..279bfc782d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -0,0 +1,144 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLOBJECTSDEBUG_FILECODE
+
+/**
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
new file mode 100644
index 0000000000..85d184b759
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -0,0 +1,267 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLPKGLENGTH_FILECODE
+
+#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",
+ __func__,
+ 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", __func__));
+ 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 ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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", __func__));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n", __func__));
+ 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", __func__, "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",
+ __func__,
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
new file mode 100644
index 0000000000..4ef746327b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -0,0 +1,1989 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECODE
+
+/**
+ 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", __func__, "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", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n", __func__, 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", __func__, AddressMaximum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressMaximum == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ 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", __func__, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __func__));
+ 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", __func__));
+ 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed = 0\n", __func__));
+ 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n", __func__, 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", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0, IsMinFixed = 1, and IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both be either 1 or 0\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, Shared));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__, "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", __func__, "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", __func__, Decode));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ 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", __func__, AddressMin));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, 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", __func__, AddressMax));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__, 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", __func__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AccessSize > EFI_ACPI_6_4_QWORD) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n", __func__, AccessSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__, ReadAndWrite));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
new file mode 100644
index 0000000000..03201d0109
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -0,0 +1,515 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLSTATEMENTOPCODES_FILECODE
+
+/**
+ 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 pkglength termlist>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NotifyValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
new file mode 100644
index 0000000000..c9a4399764
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -0,0 +1,213 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLTABLE_FILECODE
+
+// 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", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
new file mode 100644
index 0000000000..b1ad9b7037
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -0,0 +1,364 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE
+
+/**
+ 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 <all others> - 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 <all others> - 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 <all others> - 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", __func__));
+ 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 <all others> - 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 <all others> - 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", __func__, 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 <all others> - 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",
+ __func__,
+ 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 <all others> - 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;
+ UINT8 *TempBuffer;
+
+ 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", __func__));
+ 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
+ TempBuffer = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + ChildObject->DataSize,
+ Object->Data
+ );
+ if (TempBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ FreePool (Object->Data);
+ Object->Data = NULL;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __func__));
+ goto Done;
+ }
+
+ Object->Data = TempBuffer;
+ // 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/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
new file mode 100644
index 0000000000..2f4f676adb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
@@ -0,0 +1,13 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include <Filecode.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
new file mode 100644
index 0000000000..60305ee4a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
@@ -0,0 +1,90 @@
+/** @file
+ Library to support reset library, inheritted from Agesa Cf9Reset module.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+/**
+ This function causes a system-wide reset (cold reset), in which
+ all circuitry within the system returns to its initial state. This type of reset
+ is asynchronous to system operation and operates without regard to
+ cycle boundaries.
+
+ If this function returns, it means that the system does not support cold reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a system-wide initialization (warm reset), in which all processors
+ are set to their initial state. Pending cycles are not corrupted.
+
+ If this function returns, it means that the system does not support warm reset.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shutdown reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a systemwide reset. The exact type of the reset is
+ defined by the EFI_GUID that follows the Null-terminated Unicode string passed
+ into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+ the platform must pick a supported reset type to perform.The platform may
+ optionally log the parameters from any non-normal reset that occurs.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData The data buffer starts with a Null-terminated string,
+ followed by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
new file mode 100644
index 0000000000..d10e676668
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
@@ -0,0 +1,87 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Filecode.h>
+#include <Uefi.h>
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] RegAddr Slave register address
+ *
+ * @retval Register Value
+ */
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ )
+{
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to read
+ * @param[in] Length Length in byte to read
+ * @param[in] Buffer Pointer to the data read to
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to write
+ * @param[in] Length Length in byte to write
+ * @param[in] Value Pointer to the data to write
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to erase
+ * @param[in] Length Block Size to erase
+ *
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
new file mode 100755
index 0000000000..9044d3d497
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
@@ -0,0 +1,68 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/NbioHandleLib.h>
+#include <Library/AmdBaseLib.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ )
+{
+ return NULL;
+}
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ )
+{
+ PCI_ADDR PciAddr;
+
+ PciAddr.AddressValue = 0;
+ return PciAddr;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
new file mode 100755
index 0000000000..d5fbe98d22
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
@@ -0,0 +1,276 @@
+/** @file
+ GNB function to create/locate PCIe configuration data area
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/GnbPcieConfigLib.h>
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ )
+{
+ return FALSE;
+}
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ )
+{
+ return 0;
+}
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ )
+{
+}
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+}
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ )
+{
+ return FALSE;
+}
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+ return NULL;
+}
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ )
+{
+}
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ )
+{
+}
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
new file mode 100755
index 0000000000..5c6be22ee4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
@@ -0,0 +1,117 @@
+/** @file
+ Procedure to parse PCIe input configuration data
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <GnbDxio.h>
+
+/**
+ Get number of complexes in platform topology configuration
+
+ @param[in] ComplexList First complex configuration in complex configuration array
+ @retval Number of Complexes
+
+**/
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of PCIe engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfPcieEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of DDI engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfDdiEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of engines in given complex
+
+
+
+ @param[in] Complex Complex configuration header
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] Index Complex descriptor Index
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] SocketId Socket Id
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptorOfSocket (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINT32 SocketId
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Engine descriptor from given complex by index
+
+ @param[in] Complex Complex descriptor
+ @param[in] Index Engine descriptor index
+ @retval Pointer to Engine Descriptor
+**/
+PCIE_ENGINE_DESCRIPTOR *
+PcieInputParserGetEngineDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
new file mode 100644
index 0000000000..e6be32b071
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
@@ -0,0 +1,10 @@
+/** @file
+ SMN Register Access Methods
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/SmnAccessLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
new file mode 100644
index 0000000000..1dc13900c7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
@@ -0,0 +1,42 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/PcieConfigLib.h>
+#include <Library/NbioCommonLibDxe.h>
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
new file mode 100644
index 0000000000..fbd3ddcf37
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
@@ -0,0 +1,23 @@
+/** @file
+ APCB DXE Driver
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+EFI_STATUS
+EFIAPI
+AmdApcbV3DxeDriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
new file mode 100644
index 0000000000..23d1a8fee0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+
+/**
+ * @brief Amd Apcb V3 Pei Driver Entry
+ *
+ * @param[in] FileHandle File Handie
+ * @param[in] PeiServices Pei Services
+ *
+ * @retval EFI_SUCCESS Set APCB value successfully
+ * Non-EFI_SUCCESS Function Error
+ *
+ **/
+EFI_STATUS
+EFIAPI
+AmdApcbV3PeiDriverEntry (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
new file mode 100644
index 0000000000..74b129931b
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
@@ -0,0 +1,39 @@
+/** @file
+ Required OEM hooks for CCX initialization
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ Hook to store the vector that all APs should jump to out of reset to a non-volatile,
+ shared location.
+
+ @param[in] ApInitAddress Address of the code that AP should jump to
+ @param[in,out] ContentToRestore The current value in the non-volatile storage
+
+**/
+VOID
+SaveApInitVector (
+ IN UINT32 ApInitAddress,
+ IN OUT UINT32 *ContentToRestore
+ )
+{
+}
+
+/**
+ Hook to restore the initial content of the non-volatile storage location.
+
+ @param[in] ContentToRestore The value to restore
+
+**/
+VOID
+RestoreContentVector (
+ IN UINT32 ContentToRestore
+ )
+{
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
new file mode 100644
index 0000000000..54ce202cb1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
@@ -0,0 +1,33 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Ppi/PciCfg2.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+
+/**
+ Module's entry function.
+ This routine will install EFI_PEI_PCI_CFG2_PPI.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @return Whether success to install service.
+**/
+EFI_STATUS
+EFIAPI
+PeimInitializePciCfg (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
new file mode 100644
index 0000000000..643174d7b9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/PciSegmentInfoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+
+/**
+ Return an array of PCI_SEGMENT_INFO holding the segment information.
+
+ Note: The returned array/buffer is owned by callee.
+
+ @param Count Return the count of segments.
+
+ @retval A callee owned array holding the segment information.
+**/
+PCI_SEGMENT_INFO *
+EFIAPI
+GetPciSegmentInfo (
+ UINTN *Count
+ )
+{
+ return (PCI_SEGMENT_INFO *)NULL;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
new file mode 100644
index 0000000000..d83bb6c2d8
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
@@ -0,0 +1,15 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiSmm.h>
+#include <Register/Cpuid.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/SmmBase2.h>
+#include <Library/IoLib.h>
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
new file mode 100644
index 0000000000..a264eb9294
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
@@ -0,0 +1,12 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
new file mode 100644
index 0000000000..e379538e3a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
@@ -0,0 +1,36 @@
+/** @file
+ OEM OOB PPR DXE Driver.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciIo.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TimerLib.h>
+#include <IndustryStandard/Pci22.h>
+
+/**
+* This function installs a protocol used by platform BIOS to provide the hotplug descriptor.
+*
+* @param[in] ImageHandle Image handler
+* @param[in] SystemTable Pointer to the system table
+*
+* @retval EFI_SUCCESS The thread was successfully launched.
+*
+**/
+EFI_STATUS
+EFIAPI
+OobPprEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
new file mode 100644
index 0000000000..5242e6261a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -0,0 +1,20 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+EFI_STATUS
+EFIAPI
+PspPlatformEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
new file mode 100644
index 0000000000..530bd9d4b6
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+EFI_STATUS
+EFIAPI
+HotplugDescEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
new file mode 100644
index 0000000000..fbc372586b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
new file mode 100644
index 0000000000..0a5f4a7e81
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
@@ -0,0 +1,36 @@
+/** @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.<BR>
+
+ 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;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
new file mode 100644
index 0000000000..47eb700f8f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/IoLib.h>
+
+/**
+ Performs platform specific initialization required for the CPU to access
+ the hardware associated with a SerialPortLib instance. This function does
+ not intiailzie the serial port hardware itself. Instead, it initializes
+ hardware devices that are required for the CPU to access the serial port
+ hardware. This function may be called more than once.
+
+ @retval RETURN_SUCCESS The platform specific initialization succeeded.
+ @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
new file mode 100644
index 0000000000..72b9a87639
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
@@ -0,0 +1,9 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
new file mode 100644
index 0000000000..2dfb3190d4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
@@ -0,0 +1,13 @@
+; @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.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+%macro AMD_ENABLE_UEFI_STACK2 2-3
+
+%endmacro
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
index a731c7e369..937caee083 160000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
@@ -1 +1 @@
-Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490
+Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119135): https://edk2.groups.io/g/devel/message/119135
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
@ 2024-05-23 8:30 ` Yao, Ken via groups.io
2024-05-24 4:40 ` Paul via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Yao, Ken via groups.io @ 2024-05-23 8:30 UTC (permalink / raw)
To: Zhai, MingXin (Duke), Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Xing, Eric
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Ken Yao <Ken.Yao@amd.com>
-----Original Message-----
From: Zhai, MingXin (Duke) <duke.zhai@amd.com>
Sent: Thursday, May 23, 2024 3:47 PM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
From: Abner Chang <abner.chang@amd.com>
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
Platform/AMD/Readme.md | 64 ++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/Platform/AMD/Readme.md b/Platform/AMD/Readme.md index 99d2b990c7..3297c6ba59 100644
--- a/Platform/AMD/Readme.md
+++ b/Platform/AMD/Readme.md
@@ -7,18 +7,25 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Term and Definitions
+* **AGESA**
+
+ AMD Generic Encapsulated Software Architecture that are executed as
+ part of a host platform BIOS.
+
* **AMD Platform** (platform in short)
- AMD platform refers to a platform that supports the particular AMD SoC (processor), such as AMD EPYC Milan and Genoa processors.
+ AMD platform refers to a platform that supports the particular AMD
+ SoC (processor), such as AMD EPYC Milan and Genoa processors.
* **AMD Board** (board in short)
AMD board is a generic terminology refers to a board that is designed based on a
specific AMD SoC architecture (also referred as AMD platform). More than one boards
- are possibly designed to support an AMD platform with different configuration, such as 1-processor socket or 2-processor sockets board.
+ are possibly designed to support an AMD platform with different
+ configuration, such as 1-processor socket or 2-processor sockets board.
* **AMD edk2 Platform Package** (platform package in short)
-
+
The folder has the AMD edk2 platform common modules.
* **AMD edk2 Board Package** (board package in short) @@ -28,29 +35,52 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Package Definition
+* **AgesaModulePkg**
+
+ This package contains all of the private interfaces and build
+ configuration files for the AGESA support.
+
+* **AgesaPkg**
+
+ This package contains all of the public interfaces and build
+ configuration files for the AGESA support.
+
+* **AmdCbsPkg**
+
+ AMD Configurable BIOS Setting. Provides the edk2 formset following
+ the UEFI HII spec to configure BIOS settings.
+
+* **AmdCpmPkg**
+
+ AMD Common Platform Module software is a BIOS procedure library
+ designed to aid AMD customers to quickly implement AMD platform technology into their products.
+
* **AmdPlatformPkg**
- AMD platform edk2 package under this folder provides the common edk2 modules those
- are leverage by platforms. Usually those modules have no dependencies with
- particular platforms. The module under this scope can provides a common implementation
- for all platforms, or it may just provide a framework but the differences of implementation could be configured through the PCDs declared in AmdPlatformPkg.dec, or
- the board level library provided in the \<Board name\>Pkg.
+ AMD platform edk2 package under this folder provides the common edk2
+ modules that are leveraged by platforms. Usually those modules have no
+ dependencies with particular platforms. Modules under this scope can
+ provide a common implementation for all platforms, or may just
+ provide a framework but the differences of implementation could be
+ configured through the PCDs declared in AmdPlatformPkg.dec, or the board level library provided in the \<Board name\>Pkg.
* **AmdMinBoardPkg**
- This package provides the common edk2 modules those can be leverage across AMD boards those use MinPlatformPkg framework.
+ This package provides the common edk2 modules that can be leveraged
+ across AMD boards using the MinPlatform framework.
* **\<SoC name\>Board**
- This is the folder named by SoC and accommodate one or multiple board packages those
- are designed base on the same SoC platform. <SoC name>Board folder may contain edk2
- package meta files directly or the sub-folders named by \<Board name\>Pkg for a
- variety configurations of a platform.
+ This is the folder named by SoC and accommodates one or multiple
+ board packages that are designed based on the same SoC platform. <SoC
+ name>Board folder may contain edk2 package meta files directly or the
+ sub-folders named by \<Board name\>Pkg for a variety configurations of a platform.
* **<Board name\>Pkg**
- This is the folder that contains edk2 package meta files for a board which is designed base on a platform. Besides the edk2 meta files, <Board name\>Pkg may also provides
- edk2 modules which are specifically to a board.
+ This is the folder that contains edk2 package meta files for a board
+ which is designed base on a platform. Besides the edk2 meta files,
+ <Board name\>Pkg may also provides edk2 modules which are specifically to a board.
```
e.g. OverdriveBoard
@@ -63,6 +93,10 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
```
Platform/AMD
+ |----AgesaModulePkg
+ |----AgesaPkg
+ |----AmdCbsPkg
+ |----AmdCpmPkg
|----AmdPlatformPkg
|----AmdMinBoardPkg
|----OverdriveBoard
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119162): https://edk2.groups.io/g/devel/message/119162
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
@ 2024-05-23 8:31 ` Yao, Ken via groups.io
2024-05-24 4:39 ` Paul via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Yao, Ken via groups.io @ 2024-05-23 8:31 UTC (permalink / raw)
To: Zhai, MingXin (Duke), Chang, Abner, devel@edk2.groups.io
Cc: Grimes, Paul, Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus,
Xing, Eric
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Ken Yao <Ken.Yao@amd.com>
-----Original Message-----
From: Zhai, MingXin (Duke) <duke.zhai@amd.com>
Sent: Thursday, May 23, 2024 3:48 PM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
From: Abner Chang <abner.chang@amd.com>
BZ#: 4777
Initial commit of AMD cross platform/board generic
encapsulated software architecture. This provides
the basic definitions and protocols for the follow-up
AMD open board project.
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
.../AgesaModulePkg/AgesaCommonModulePkg.dec | 39 +
Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec | 18 +
.../AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec | 20 +
.../AMD/AgesaModulePkg/AgesaModuleDfPkg.dec | 25 +
.../AMD/AgesaModulePkg/AgesaModuleFchPkg.dec | 62 +
.../AMD/AgesaModulePkg/AgesaModuleMemPkg.dec | 26 +
.../AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec | 34 +
.../AMD/AgesaModulePkg/AgesaModulePspPkg.dec | 29 +
Platform/AMD/AgesaPkg/AgesaPkg.dec | 435 +++
Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec | 41 +
.../AgesaEdk2PlatformPkg.inc.dsc | 18 +
.../AgesaSp5RsModulePkg.inc.dsc | 48 +
.../CbsInstanceNull/CbsInstanceNull.inc.dsc | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.inc.dsc | 11 +
.../AgesaSp5RsModulePkg.dxe.inc.fdf | 11 +
.../AgesaSp5RsModulePkg.pei.inc.fdf | 9 +
.../CbsInstanceNull.dxe.inc.fdf | 7 +
.../CbsInstanceNull.pei.inc.fdf | 7 +
.../0x19/RS/External/CbsStones.dxe.inc.fdf | 8 +
.../0x19/RS/External/CbsStones.pei.inc.fdf | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf | 7 +
.../Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf | 10 +
.../Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf | 7 +
.../Library/AmdCalloutLib/AmdCalloutLib.inf | 29 +
.../AmdPspMboxLibV2/AmdPspMboxLibV2.inf | 30 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.inf | 27 +
.../AmdPspRomArmorLibNull.inf | 26 +
.../Library/ApcbLibV3/ApcbLibV3.inf | 37 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.inf | 32 +
.../BaseFabricTopologyRsLib.inf | 28 +
.../CcxTscTimerLib/BaseTscTimerLib.inf | 35 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.inf | 42 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.inf | 37 +
.../PciHostBridgeLib.inf | 42 +
.../DxeAmlGenerationLib/AmlGenerationLib.inf | 47 +
.../Library/FchBaseLib/FchBaseLib.inf | 26 +
.../FchBaseResetSystemLib.inf | 35 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.inf | 33 +
.../Library/NbioHandleLib/NbioHandleLib.inf | 24 +
.../Library/PcieConfigLib/PcieConfigLib.inf | 25 +
.../Library/SmnAccessLib/SmnAccessLib.inf | 33 +
.../Library/CommonDxe/NbioCommonDxeLib.inf | 29 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf | 45 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf | 33 +
.../OemAgesaCcxPlatformLibNull.inf | 27 +
.../PciExpressPciCfg2/PciExpressPciCfg2.inf | 61 +
.../PciExpressPciSegmentInfoLib.inf | 32 +
.../AmdPspFlashAccSpiNorLibSmm.inf | 45 +
.../PspRomArmorWhitelistLib.inf | 32 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.inf | 42 +
.../Dxe/PspPlatformDriver/PspPlatform.inf | 32 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.inf | 29 +
.../AmdAutoDynamicCommand.inf | 53 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.inf | 50 +
.../BasePlatformHookLibAmdFchUart.inf | 33 +
Platform/AMD/AgesaModulePkg/Include/AGESA.h | 158 +
Platform/AMD/AgesaModulePkg/Include/AMD.h | 91 +
.../Include/AmdEdk2/CpuRegisters.h | 15 +
.../AgesaModulePkg/Include/AmdPspDirectory.h | 61 +
.../AgesaModulePkg/Include/CpuRegistersDef.h | 156 +
.../Include/FchRegistersCommon.h | 85 +
.../AMD/AgesaModulePkg/Include/Filecode.h | 31 +
Platform/AMD/AgesaModulePkg/Include/Gnb.h | 14 +
Platform/AMD/AgesaModulePkg/Include/GnbDxio.h | 521 ++++
.../AgesaModulePkg/Include/GnbRegistersRS.h | 18 +
.../Include/GnbRegistersRS/IOHC.h | 22 +
.../Include/Guid/GnbPcieInfoHob.h | 31 +
.../Include/Library/AmdBaseLib.h | 16 +
.../Include/Library/AmdPspMboxLibV2.h | 43 +
.../Include/Library/BaseFabricTopologyLib.h | 22 +
.../Include/Library/FchBaseLib.h | 16 +
.../Include/Library/FchEspiCmdLib.h | 413 +++
.../Include/Library/GnbPcieConfigLib.h | 16 +
.../Include/Library/NbioCommonLibDxe.h | 37 +
.../Include/Library/NbioHandleLib.h | 62 +
.../Include/Library/PcieConfigLib.h | 283 ++
.../Include/Library/SmnAccessLib.h | 30 +
.../Protocol/AmdNbioPcieServicesProtocol.h | 47 +
.../Include/Protocol/AmdOemOobPprProtocol.h | 14 +
.../Include/Protocol/FabricNumaServices2.h | 155 +
.../Protocol/FabricTopologyServices2.h | 14 +
.../AMD/AgesaModulePkg/Include/SocLogicalId.h | 23 +
.../Library/DxeAmlGenerationLib/LocalAmlLib.h | 100 +
.../DxeAmlGenerationLib/LocalAmlObjects.h | 150 +
.../AMD/AgesaPkg/Include/AmdPcieComplex.h | 432 +++
Platform/AMD/AgesaPkg/Include/AmdSoc.h | 17 +
.../Include/FabricResourceManagerCmn.h | 42 +
.../AgesaPkg/Include/Guid/AmdMemoryInfoHob.h | 96 +
.../Include/Library/AmdPspBaseLibV2.h | 51 +
.../AgesaPkg/Include/Library/AmdPspFtpmLib.h | 83 +
.../Include/Library/AmdPspRomArmorLib.h | 231 ++
.../Include/Library/AmlGenerationLib.h | 2722 +++++++++++++++++
.../Library/PlatformPspRomArmorWhitelistLib.h | 25 +
.../AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h | 134 +
.../Include/Protocol/AmdCxlServicesProtocol.h | 183 ++
.../Protocol/AmdPciResourcesProtocol.h | 110 +
.../Include/Protocol/AmdPspFtpmProtocol.h | 187 ++
.../FabricResourceManagerServicesProtocol.h | 14 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h | 19 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h | 78 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h | 17 +
.../AMD/AmdCpmPkg/Include/AmdCpmFunction.h | 32 +
.../AmdCpmTableProtocol/AmdCpmTableProtocol.h | 39 +
.../Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c | 31 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.c | 12 +
.../AmdPspRomArmorLibNull.c | 79 +
.../Library/ApcbLibV3/ApcbLibV3.c | 12 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.c | 14 +
.../BaseFabricTopologyRsLib.c | 37 +
.../Library/CcxTscTimerLib/BaseTscTimerLib.c | 8 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.c | 35 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.c | 11 +
.../Library/CcxTscTimerLib/TscTimerLibShare.c | 103 +
.../DxeAmdPciHostBridgeLib/PciHostBridgeLib.c | 95 +
.../DxeAmlGenerationLib/AmlArgObjects.c | 154 +
.../DxeAmlGenerationLib/AmlAssistFunctions.c | 151 +
.../DxeAmlGenerationLib/AmlDataObjects.c | 640 ++++
.../AmlExpressionOpcodes.c | 1294 ++++++++
.../DxeAmlGenerationLib/AmlLocalObjects.c | 158 +
.../DxeAmlGenerationLib/AmlNameString.c | 576 ++++
.../DxeAmlGenerationLib/AmlNamedObject.c | 2138 +++++++++++++
.../AmlNamespaceModifierObjects.c | 360 +++
.../DxeAmlGenerationLib/AmlObjectsDebug.c | 144 +
.../DxeAmlGenerationLib/AmlPkgLength.c | 267 ++
.../AmlResourceDescriptor.c | 1989 ++++++++++++
.../DxeAmlGenerationLib/AmlStatementOpcodes.c | 515 ++++
.../Library/DxeAmlGenerationLib/AmlTable.c | 213 ++
.../DxeAmlGenerationLib/LocalAmlObjects.c | 364 +++
.../Library/FchBaseLib/FchStallLib.c | 13 +
.../FchBaseResetSystemLib.c | 90 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.c | 87 +
.../Library/NbioHandleLib/NbioHandleLib.c | 68 +
.../Library/PcieConfigLib/PcieConfigLib.c | 276 ++
.../PcieConfigLib/PcieInputParserLib.c | 117 +
.../Library/SmnAccessLib/SmnAccessLib.c | 10 +
.../Nbio/Library/CommonDxe/DxeLibFunctions.c | 42 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c | 23 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c | 29 +
.../OemAgesaCcxPlatformLibNull.c | 39 +
.../PciExpressPciCfg2/PciExpressPciCfg2.c | 33 +
.../PciSegmentInfoLib.c | 30 +
.../AmdPspFlashAccSpiNorLibSmm.c | 15 +
.../PspRomArmorWhitelistLib.c | 12 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.c | 36 +
.../Dxe/PspPlatformDriver/PspPlatformDriver.c | 20 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.c | 22 +
.../AmdAutoDynamicCommand.c | 44 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.c | 36 +
.../BasePlatformHookLibAmdFchUart.c | 29 +
.../FchSongshanDxe/FchSongshanI2C_I3C.asl | 9 +
.../AMD/AgesaPkg/Include/AmdUefiStackNasm.inc | 13 +
.../Library/RiscVOpensbiLib/opensbi | 2 +-
152 files changed, 19669 insertions(+), 1 deletion(-)
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
create mode 100644 Platform/AMD/AgesaPkg/AgesaPkg.dec
create mode 100755 Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
create mode 100755 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AGESA.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AMD.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Filecode.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Gnb.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
create mode 100755 Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdSoc.h
create mode 100644 Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
create mode 100644 Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
create mode 100644 Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
new file mode 100644
index 0000000000..d35a1f27b4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
@@ -0,0 +1,39 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCommonPkg
+ PACKAGE_GUID = 6CBE6566-0D3F-4E35-8358-9602354E9F09
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = {0x7788adf0, 0x9788, 0x4a3f, {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}}
+ gAgesaConfigDbPointerVariableGuid = {0x21229d24, 0xc71d, 0x4bc0, {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}}
+ gAmdMemoryInfoHobGuid = {0x1bce3d14, 0xa5fe, 0x4a0b, {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}}
+
+[Protocols]
+ ## Soc Protocols
+ gAmdSocLogicalIdProtocolGuid = {0x72f8e409, 0x0d2a, 0x4b91, {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}}
+ gAmdOemOobPprDxeProtocolGuid = {0x78031be3, 0x54a2, 0x4819, {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupportedV2|2|UINT8|0x00002002 # 2 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|1|UINT8|0x00002003 # 1 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2|8|UINT8|0x00002004 # 8 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannelV2|2|UINT8|0x00002005 # 2 by default
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UINT64|0x00027003
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
new file mode 100644
index 0000000000..1637068432
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
@@ -0,0 +1,18 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaEdk2Pkg
+ PACKAGE_GUID = E866104F-D458-41B1-AB26-FA5951618A8C
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/AmdEdk2
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
new file mode 100755
index 0000000000..b84fe5b738
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
@@ -0,0 +1,20 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCcxPkg
+ PACKAGE_GUID = df325429-029e-40f0-82db-0e69be7f6560
+ PACKAGE_VERSION = 0.1
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FALSE|BOOLEAN|0x000CC029
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
new file mode 100755
index 0000000000..57db15e663
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
@@ -0,0 +1,25 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaDfPkg
+ PACKAGE_GUID = 81e51ee3-c347-4563-92fe-790ba953bf0f
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gAmdTotalNumberOfRootBridgesGuid = {0xfb5703f5, 0xf8a7, 0xf401, {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}}
+ gAmdResourceSizeForEachRbGuid = {0x542b8f2f, 0xbd52, 0x4233, {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}}
+
+[Protocols]
+ gAmdFabricNumaServices2ProtocolGuid = {0xa8ff2e64, 0xf319, 0x4af1, {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}}
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
new file mode 100644
index 0000000000..521957e809
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
@@ -0,0 +1,62 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 1.5
+ PACKAGE_NAME = AgesaFchPkg
+ PACKAGE_GUID = e47c8ed9-3000-4e6e-b1c6-875b365b3849
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = { 0x7788adf0, 0x9788, 0x4a3f, { 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } }
+
+[Protocols]
+ gFchInitDonePolicyProtocolGuid = { 0xc63c0c73, 0xf612, 0x4c02, { 0x84, 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } }
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|0x0003F001
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0x0003F002
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0x0003F003
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x0003F00D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BOOLEAN|0x0003F021
+
+ ### @brief This item allows the customer to change OC signal polarity to be active low. This is universal and applies to all OC pins.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)At present, this control applies to Family17h Model 00h-2Fh.
+ ### @li TRUE - OC pin is low when OC occurs.
+ ### @li FALSE - OC pin is high when OC occurs.
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciOcPolarityCfgLow|FALSE|BOOLEAN|0x0003F309
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFFFFFFFFFFFFF|UINT64|0x0003F340
+ #Die 0
+ #[7:0] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ #[23:0] MTS -- 6 USB 2.0 ports on XHCI controller 0
+ #Die 1
+ #[39:32] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[47:40] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb31OcPinSelect|0xFFFFFFFF|UINT32|0x0003F341
+ #Die 0
+ #[7:0] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ #[15:0] MTS -- 4 USB 3.1 ports on XHCI controller 0
+ #Die 1
+ #[23:16] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[31:24] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLpcEnable|TRUE|BOOLEAN|0x0003F400
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdUsbRSOemConfigurationTable|{0x0}|VOID*|0x0003F40A
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciSsid|0x00000000|UINT32|0x0003FF07
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x00000000|UINT32|0x0003FF81
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
new file mode 100644
index 0000000000..721d3ea73b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
@@ -0,0 +1,26 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaMemPkg
+ PACKAGE_GUID = 445f7303-3171-428c-ad0b-32df4474a7ad
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries|64|UINT32|0x00029001
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
new file mode 100755
index 0000000000..0501774c9b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
@@ -0,0 +1,34 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaNbioPkg
+ PACKAGE_GUID = 1486f0fe-39ee-4856-a39f-222ff2404f26
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Protocols]
+ gAmdNbioPcieServicesProtocolGuid = {0x756db75c, 0xbb9d, 0x4289, {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE|BOOLEAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI phase
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0x00021103 #///< Base NBIO IOAPIC ID. ID assigned start from this value
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x0004101D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x0004101E
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|0x0|UINT32|0x00041200
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
new file mode 100644
index 0000000000..41cf320c76
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
@@ -0,0 +1,29 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPspPkg
+ PACKAGE_GUID = 5c48f900-a98c-431f-8be5-19c09c65bb05
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gApSyncFlagNvVariableGuid = { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb, 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } }
+ gAmdPspApobHobGuid = { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13, 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } }
+
+[Protocols]
+ gPspFlashAccSmmCommReadyProtocolGuid = { 0x9f373486, 0xda76, 0x4c9f, { 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } }
+ gAmdPspFtpmProtocolGuid = { 0xac234e04, 0xb036, 0x476c, { 0x91, 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } }
+
+[Ppis]
+ gAmdPspFtpmPpiGuid = { 0x91774185, 0xf72d, 0x467e, { 0x93, 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } }
+ gAmdPspFtpmFactoryResetPpiGuid = { 0x9c98130a, 0x8921, 0x45eb, { 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } }
diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/AgesaPkg.dec
new file mode 100644
index 0000000000..9377c64cc3
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
@@ -0,0 +1,435 @@
+## @file
+# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
+# file.
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPkg
+ PACKAGE_GUID = DABFEFC6-5A79-444b-862A-1F6FE9F561FE
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaPkgTokenSpaceGuid = { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0, 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } }
+
+[Protocols]
+ gAmdNbioCxlServicesProtocolGuid = {0x125CCFCE, 0x34AF, 0x422C, {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}}
+ gAmdPciResourceProtocolGuid = {0x663d4897, 0xed94, 0x4f0f, {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}}
+ gAmdCapsuleSmmHookProtocolGuid = {0x4fc43bbe, 0x1433, 0x4951, {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}}
+ gAmdFspSetupTableInitDoneGuid = {0xef5394c6, 0x566d, 0x440f, {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}}
+
+[Ppis]
+ gAmdMemoryInfoHobPpiGuid = {0xba16e587, 0x1d66, 0x41b7, {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
+ gCapsuleUpdateDetectedPpiGuid = {0x745dfc73, 0xc401, 0x4ced, {0x8d, 0x3b, 0x1a, 0x82, 0xf3, 0xda, 0xdc, 0xf8}}
+
+[PcdsFixedAtBuild]
+
+ ### @brief Enable EDK-II Protocols
+ ### @details This item enables support for EDKII implementation of ACPI Protocols when set to TRUE
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCompliantEdkIIAcpiSdtProtocol|TRUE|BOOLEAN|0x00020006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize |0x1000|UINT32|0x00020007
+
+ ### @brief assign non volatile storage base address
+ ### @details This assigns the base address to map to flash deivce.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF000000|UINT32|0x00020017
+
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH.h"
+#----------------------------------------------------------------------------
+
+ ### @name General FCH Controls
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1 register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0400)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1EvtBlkAddr|0x400|UINT16|0x0002F004
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1Cnt register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0404)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1CntBlkAddr|0x404|UINT16|0x0002F005
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM Timer as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0408)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPmTmrBlkAddr|0x408|UINT16|0x0002F006
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI CPU Control block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0410)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgCpuControlBlkAddr|0x410|UINT16|0x0002F007
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI GPE0 register block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0420)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|UINT16|0x0002F008
+
+ ### @brief This item defines the SMI command value sent by the host BIOS during the S3 resume sequence, to re-initialize the
+ ### FCH registers. This must be issued before the platform driver restore function is started.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD3)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemBeforePciRestoreSwSmi|0xD3|UINT8|0x0002F010
+
+ ### @brief This item defines the SMI command used by the host BIOS to signal the FCH driver that the platform driver has
+ ### completed its restore function. This allows the FCH driver to perform some final FCH settings.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD4)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|UINT8|0x0002F011
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to activate ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemEnableAcpiSwSmi|0xA0|UINT8|0x0002F012
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to turn off ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA1)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemDisableAcpiSwSmi|0xA1|UINT8|0x0002F013
+
+ ### @brief SMI command used for releasing the SPI controller lock mode. All devices on the SPI bus will be writable.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAA)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiUnlockSwSmi|0xAA|UINT8|0x0002F014
+
+ ### @brief SMI command for setting the lock mode in the SPI controller. This will effectively provide a write protection to the
+ ### SPI Flash ROM; however, write access to secondary SPI devices will also be blocked.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAB)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x0002F015
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH-IRQ.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart0Irq|0x03|UINT8|0x0002F01A
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart1Irq|0x0E|UINT8|0x0002F01B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart2Irq|0x05|UINT8|0x0002F01C
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart3Irq|0x0F|UINT8|0x0002F01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart4Irq|0x10|UINT8|0x0002F01E
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c0Irq|0x0A|UINT8|0x0002F01F
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c1Irq|0x0B|UINT8|0x0002F020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c2Irq|0x04|UINT8|0x0002F021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c3Irq|0x06|UINT8|0x0002F022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c4Irq|0x16|UINT8|0x0002F023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c5Irq|0x17|UINT8|0x0002F024
+#- DF Fixed PCDs
+#-
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+ #Fabric
+
+ ### @name General DF Controls
+
+ ### @brief This item informs the SMBios generation code as to how many physical processor sockets exist in the system and
+ ### therefore how many Type 4 SMBios records to produce.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x01)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdNumberOfPhysicalSocket|1|UINT8|0x000CC103
+#----------------------------------------------------------------------------
+#- CCX Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-MTRR.h"
+#----------------------------------------------------------------------------
+
+
+ ### @brief The base address of temporary page table for accessing PCIE MMIO base address above 4G in PEI phase.
+ ### @brief Permitted Choices: 0x0 - 0xFFFFFFFF (Type: Value)(Default: 0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPeiTempPageTableBaseAddress|0|UINT32|0x000CC11B
+
+#----------------------------------------------------------------------------
+#- CCX ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-ACPI.h"
+#----------------------------------------------------------------------------
+ #ACPI
+ # Cpu SSDT
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName0|0x43|UINT8|0x000AC001
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName1|0x30|UINT8|0x000AC002
+ ### @brief This element specifies whether the ACPI _PSS objects are defined in the system bus or processor scope.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li TRUE - The objects will be under the \_SB scope.
+ ### @li FALSE - The objects will be under the \_PR scope
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeInSb|FALSE|BOOLEAN|0x000AC003
+
+ ### @brief Set the OEM ID field in ACPI table outputs to this string. The string must conform to the ACPI rules for the OEM ID field.
+ ### @brief Permitted Choices: (Type: Value)(Default: "AMD")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|VOID*|0x000AC004
+
+#----------------------------------------------------------------------------
+#- CCX SMBIOS Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-SMBIOS.h"
+#----------------------------------------------------------------------------
+
+ ### @name CCX SMBIOS Controls
+
+ ### @brief When creating the SMBios table entry, use this as the label for the processor socket. This should match the
+ ### silkscreen label on the motherboard.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|"Unknown"|VOID*|0x00001001
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'serial number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket0|"Unknown"|VOID*|0x00001002
+
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Asset Tag' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket0|"Unknown"|VOID*|0x00001003
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Part Number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unknown"|VOID*|0x00001004
+
+ ### @brief SMBios socket 1 Label.
+ ### @details When creating the SMBios table entry, use this as the label for the
+ ### processor socket. This should match the silkscreen label on the motherboard.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|"Unknown"|VOID*|0x00001005
+
+ ### @brief SMBIOS socket 1 Serial Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'serial number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket1|"Unknown"|VOID*|0x00001006
+
+ ### @brief SMBios socket 1 Asset Tag.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Asset Tag' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket1|"Unknown"|VOID*|0x00001007
+
+ ### @brief Socket 1 Part Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Part Number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket1|"Unknown"|VOID*|0x00001008
+
+#----------------------------------------------------------------------------
+#- ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-ACPI.h"
+#----------------------------------------------------------------------------
+
+ ### @name General ACPI Controls
+
+ ### @brief PCD supporting maximum capacity for Type 16 table
+ ### @details This PCD represents maximum memory capacity in KB
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT16MaximumCapacity|0x04000000|UINT32|0x00001009 # 4G - 0x00400000
+ # 8G - 0x00800000
+ # 16G - 0x01000000
+ # 32G - 0x02000000
+ # 64G - 0x04000000
+ # 128G - 0x08000000
+ # 256G - 0x10000000
+ # 512G - 0x20000000
+[PcdsDynamic]
+#----------------------------------------------------------------------------
+# System level Dynamic PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCStateIoBaseAddress|0x413|UINT16|0x000CC002
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x000CC00B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x000CC200
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerInSb|FALSE|BOOLEAN|0x000CC50B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerName|"PLTF"|VOID*|0x000CC50C
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEAN|0x000CC601
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16|0x000CC900
+#----------------------------------------------------------------------------
+#- DF Dynamic PCDs
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+
+ ### @cond (FF3||RN||BA||ZP||RMB||RPL||RS||SSP||MI3||BRH)
+ ### @brief Specifies the top address to be used for MMIO space allocations. No MMIO space will be used above this limit. Some devices have limits on the address space they
+ ### are able to access. For example a device with a 40-bit address limitation can not use MMIO space above 1TeraByte (1T). By setting this PCD to 0x10000000000 (1T), MMIO
+ ### space would not be allocated above 1T. The default is to use all of the space above the end of physical memory.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMmioAbove4GLimit|0xFFFFFFFFFFFFFFFF|UINT64|0x0003FFC2
+ ### @endcond
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFabricResourceDefaultSizePtr|0|UINT64|0x00DF0000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UINT16|0x0003FFC0
+
+ ### I2C-0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UINT32|0x000FC000
+ ### I2C-1
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UINT32|0x000FC001
+ ### I2C-2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UINT32|0x000FC002
+ ### I2C-3
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UINT32|0x000FC003
+ ### I2C-4
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UINT32|0x000FC004
+ ### I2C-5
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UINT32|0x000FC005
+ ### @} end of I2C hold times
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-UART.h"
+#----------------------------------------------------------------------------
+ ### @name UART Legacy IO Assignments
+ ### @{
+ ### @brief These controls allow the platform to specify the legacy IO ranges that are to be used by the UART ports in the processor. Permitted Choices: (Type: value)(Default: Disabled)
+ ### @li 0 - Disabled
+ ### @li 1 - IO range 0x02E8 - 0x02EF
+ ### @li 2 - IO range 0x02F8 - 0x02FF
+ ### @li 3 - IO range 0x03E8 - 0x03EF
+ ### @li 4 - IO range 0x03F8 - 0x03FF
+
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart0LegacyEnable|0x00|UINT8|0x000FC010
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart1LegacyEnable|0x00|UINT8|0x000FC011
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart2LegacyEnable|0x00|UINT8|0x000FC012
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart3LegacyEnable|0x00|UINT8|0x000FC013
+ ### @} end UART Legacy IO assignments
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-USB.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci0Enable|TRUE|BOOLEAN|0x000FC020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci1Enable|TRUE|BOOLEAN|0x000FC021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci2Enable|TRUE|BOOLEAN|0x000FC022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci3Enable|TRUE|BOOLEAN|0x000FC023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhciECCDedErrRptEn|FALSE|BOOLEAN|0x000FC024
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC030
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN|0x000FC039
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x000A6024
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO-BMC.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN|0x0004F004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x0004F005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkDie|0xFF|UINT8|0x0004F006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkLaneNum|0|UINT8|0x0004F03E
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgIommuSupport|TRUE|BOOLEAN|0x0004F027
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdIvInfoDmaReMap|FALSE|BOOLEAN|0x0004F028
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrVddfull_Scale_Current|0x00|UINT32|0x0004F0A0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Current|0x00|UINT32|0x0004F0A2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0x0004F210
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT32|0x0004F211
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT8|0x0004F362
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|UINT8|0x0004F363
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs DYNAMIC
+
+ ### @brief This feature selects the APCB recovery support on x86 side. If or when an instance of a writable APCB is determined to be invalid, the PSP driver will
+ ### attempt a 'recovery' by copying the recovery instance of the APCB (default values as indicated in the APCB descriptor files). Upon boot up, the ABL reads CMOS
+ ### bytes 06/07 at index/data port of 0x72/0x73. If the CMOS flag reads anything else other than 0xA55A or 0x5555, the system boots in APCB recovery mode, in which
+ ### ABL consumes the recovery instances of APCB. Otherwise it boots in normal/non-recovery mode.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE)
+ ### @brief This feature is affected by the platform CMOS power design. Please see Platform CMOS power .
+ ### @li TRUE - the AGESA PSP driver restores the APCB instances from the recovery instance, writes 0xA55A to the CMOS location and triggers a reset . The next time
+ ### the system powers up, ABL runs in normal/non-recovery mode.
+ ### @li FALSE - the AGESA PSP driver writes 0x5555 to the CMOS location without restoring the APCB instances or triggering a reset. In this mode the additional reset
+ ### is avoided at the potential risk of the writeable APCB instance being left corrupted forever.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|BOOLEAN|0x95940008
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE|BOOLEAN|0x95940018
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x00030004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BOOLEAN|0x00030005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BOOLEAN|0x00030006
+[PcdsDynamicEx]
+
+[PcdsFixedAtBuild, PcdsDynamic]
+#----------------------------------------------------------------------------
+#- System control PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ ### @brief Switch for Debug Print function
+ ### @details Switch for Debug Print function to enable or not.
+ ### @li TRUE: Enable IdsDebugPrint output
+ ### @li FALSE: Disable IdsDebugPrint output
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEnable|FALSE|BOOLEAN|0x00020004
+ ### @brief Specify the filter for IdsDebugPrint
+ ### @details When the filter values are matched, the AmdIdsDebugPrint can start to print debug message.
+ ### Refer Library/IdsLib.h for details, and the Master token is PcdAmdIdsDebugPrintEnable.
+ ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ ### @li 0x100401008A300408: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintFilter|0x100401030A300408|UINT64|0x00020005
+ ### @brief Switch for Serial port support of AGESA debug print
+ ### @details Switch for Serial port support of AGESA debug print, NOTE, AGESA will not init the serial port,
+ ### serial port should be initialized before call AGESA debug print.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortEnable|FALSE|BOOLEAN|0x00020009
+ ### @brief The serial port used for debug output can be either 2-wire (Rx/Tx) or 4-wire (adding DSR/CTS). Waiting for CTS on a
+ ### 2-wire port would cause a hang. This control is added to check the cable connection.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li FALSE - Presume a 2-wire port and do not wait for CTS.
+ ### @li TRUE - Wait for both DSR and CTS to be set. DSR is set if a cable is connected. CTS is set if it is ok to transmit data.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCableConnection|FALSE|BOOLEAN|0x0002000A
+
+ ### @brief Selection of UART and UART Legacy IO Serial port for AGESA debug print
+ ### @details Selection of UART and UART Legacy IO Serial port for AGESA debug print and invisible in ACPI name space.
+ ### @li Bit[0]: Select UART0 for AGESA debug print
+ ### @li Bit[1]: Select UART1 for AGESA debug print
+ ### @li Bit[2]: Select UART2 for AGESA debug print
+ ### @li Bit[3]: Select UART3 for AGESA debug print
+ ### @li Bit[4]: Select UART4 for AGESA debug print
+ ### @li Bit[8]: Select UART0 Legacy IO for AGESA debug print
+ ### @li Bit[9]: Select UART1 Legacy IO for AGESA debug print
+ ### @li Bit[10]: Select UART2 Legacy IO for AGESA debug print
+ ### @li Bit[11]: Select UART3 Legacy IO for AGESA debug print
+ ### @li Bit[15]: Set debug print serial port to invisible in ACPI name space at OS runtime
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortSelect|0x0000|UINT16|0x0002718A
+
+ ### @brief Specify the IO port for serial out
+ ### @details ESPI or LPC COM1: 0x3F8, COM2: 0x2F8, COM3: 0x3E8, COM4: 0x2E8,
+ ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000, UART3: 0xFEDCF000, UART4: 0xFEDD1000.
+ ### @li If it's IO port: it must < 0x10000
+ ### @li If it's Memory: it must >= 0x10000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UINT64|0x0002000B
+
+ ### @brief Debug Print Emulation Auto Detect
+ ### @details Auto detect emulation platform to instead of PcdAmdIdsDebugPrintRedirectIOEnable and
+ ### PcdAmdIdsDebugPrintSerialPortEnable.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetect|FALSE|BOOLEAN|0x00020016
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgPlatformPPT|0|UINT32|0x0004F111
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs
+
+ ### @brief Rom Armor selection
+ ### @details Rom Armor selection
+ ### @li 0: Rom Armor is disabled
+ ### @li 1: Rom Armor 1 is enabled (VMR/MTS/CPK)
+ ### @li 2: Rom Armor 2 is enabled (RN/CZN)
+ ### @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
+ ### @li 0x1: PSP fTPM
+ ### @li 0x2: HSP fTPM
+ ### @li 0xFF: no TPM
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8|0x95940024
+
+ ### @cond !BRH
+ ### @brief TPM SMx algorithm flag
+ ### @details TPM SMx algorithm flag, SBIOS needs to set the value in PEI phase.
+ ### @li 0: SM2, SM3 or SM4 crypto algorithms not supported
+ ### @li 1: SM2, SM3 or SM4 crypto algorithms supported
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmAlgSmx|0|UINT8|0x95940025
+ ### @endcond
diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
new file mode 100755
index 0000000000..c8c474637f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
@@ -0,0 +1,41 @@
+## @file
+# AMD Common Platform Module (CPM) Module Package DEC.
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = CpmPkg
+ PACKAGE_GUID = ABE128BA-1061-4A53-A1B8-D07329AA7A67
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+ Library
+
+[Guids]
+ gAmdCpmPkgTokenSpaceGuid = {0x916e0ddd, 0x2bd2, 0x4704, {0x93, 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}}
+ gShellActHiiGuid = {0x340EBE97, 0x3C1C, 0x4272, {0x9C, 0xCE, 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}}
+ gAmdPbsSystemConfigurationGuid = {0xa339d746, 0xf678, 0x49b3, {0x9f, 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}}
+
+[Protocols]
+ gAmdCpmTableProtocolGuid = { 0x3724cf01, 0x00c2, 0x9762, {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }}
+ gAmdCpmAllPciIoProtocolsInstalledProtocolGuid = { 0x676D7012, 0x139B, 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }}
+
+[Ppis]
+ gAmdCpmTablePpiGuid = { 0xd71cf893, 0xa8b5, 0x49d3, { 0xa2, 0x1b, 0x31, 0xe2, 0xf5, 0xc4, 0xa7, 0x47 } }
+
+[PcdsFixedAtBuild]
+ gAmdCpmPkgTokenSpaceGuid.PcdFchUartPort|2|UINT8|0x00000052
+
+ #ACPI
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiHestTableHeaderOemTableId|"AMD HEST"|VOID*|0x000AC001
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiBertTableHeaderOemTableId|"AMD BERT"|VOID*|0x000AC002
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiEinjTableHeaderOemTableId|"AMD EINJ"|VOID*|0x000AC003
+
+ gAmdCpmPkgTokenSpaceGuid.UsePciXAslName|FALSE|BOOLEAN|0x12000003
+ gAmdCpmPkgTokenSpaceGuid.AcpiRestoreSwSmi|0xE3|UINT8|0x00000040
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
new file mode 100644
index 0000000000..37b8d15cb1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
@@ -0,0 +1,18 @@
+## @file
+#
+# 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[LibraryClasses]
+ NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+
+ ## Gnb Lib
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
new file mode 100644
index 0000000000..e7e05fd2d8
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
@@ -0,0 +1,48 @@
+## @file
+# The AGESA DSC file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[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
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+
+ ## DF Lib
+ BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
+
+ ## Gnb Lib
+ 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
+
+ ## Fch Lib
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+
+[Components.IA32]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+
+[Components.X64]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
new file mode 100644
index 0000000000..1f1e04c414
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..2916fecb26
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
@@ -0,0 +1,11 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEFINE AGESA_PKG_PATH = AgesaModulePkg
+ DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
new file mode 100644
index 0000000000..9303d1fac4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
@@ -0,0 +1,11 @@
+## @file
+# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+## APCB V3 Dxe Drivers
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
new file mode 100644
index 0000000000..0ef5a2a806
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
@@ -0,0 +1,9 @@
+## @file
+# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..b790e4ead5
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Platform Package Flash Description File
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100755
index 0000000000..8d3357bf56
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdCalloutLib
+ FILE_GUID = A8FEA621-B381-4c06-9E9D-0897EF78BD78
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdCalloutLib
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
new file mode 100644
index 0000000000..1594a99265
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
@@ -0,0 +1,30 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
new file mode 100644
index 0000000000..c685a26604
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLib
+ FILE_GUID = 55871F80-4658-6EF3-A8AC-15B34FF8C2CE
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLib
+
+[Sources.common]
+ AmdPspRomArmorLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
new file mode 100644
index 0000000000..a3906dc13e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLibNull
+ FILE_GUID = 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLibNull
+
+[Sources.common]
+ AmdPspRomArmorLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
new file mode 100644
index 0000000000..09d5bd38ac
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
@@ -0,0 +1,37 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3
+ 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
+
+[Sources.common]
+ ApcbLibV3.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSmmReadyToLockProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
new file mode 100644
index 0000000000..c031d00d79
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3Pei
+ FILE_GUID = EEA4E007-E408-4daa-82BD-4C52E7058753
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ApcbLibV3Pei|PEIM
+
+[Sources.common]
+ ApcbLibV3Pei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseMemoryLib
+ PeiServicesLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
new file mode 100644
index 0000000000..38a72e26b7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# For EDKII use Only
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseFabricTopologyRsLib
+ FILE_GUID = D0A070DD-630A-43F8-9D76-EAAABDDE5FB9
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseFabricTopologyLib
+ CONSTRUCTOR = BaseFabricTopologyLibConstructor
+
+[Sources]
+ BaseFabricTopologyRsLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+
+[LibraryClasses]
+ BaseLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
new file mode 100644
index 0000000000..d15d8169fe
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
@@ -0,0 +1,35 @@
+## @file
+# Base Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseTscTimerLib
+ FILE_GUID = D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ BaseTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
new file mode 100644
index 0000000000..1e52768a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Dxe Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTscTimerLib
+ FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeTscTimerLibConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ DxeTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ PcdLib
+ BaseLib
+ UefiLib
+ DebugLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
new file mode 100644
index 0000000000..b1eaefd282
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Pei Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTscTimerLib
+ FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|PEIM PEI_CORE
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ PeiTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+ HobLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644
index 0000000000..f60f97905a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Library instance of PciHostBridgeLib library class for coreboot.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciHostBridgeLib
+ FILE_GUID = 74967FD7-A9A4-4B16-8B41-B26BC3230D0A
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciHostBridgeLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ PciHostBridgeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ PciHostBridgeLib
+ DevicePathLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
new file mode 100644
index 0000000000..2a72fa8117
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -0,0 +1,47 @@
+## @file
+#
+# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseLib/FchBaseLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
new file mode 100644
index 0000000000..e63a70e849
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseResetSystemLib/FchBaseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
new file mode 100644
index 0000000000..e422cb69a4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
@@ -0,0 +1,35 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = BaseResetSystemLib
+ FILE_GUID = e669c365-2df2-4540-a343-afec4e85b198
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseResetSystemLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ FchBaseResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PrintLib
+ IoLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
new file mode 100644
index 0000000000..d7f49c40de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
new file mode 100755
index 0000000000..f32bbc9ff2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
@@ -0,0 +1,24 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioHandleLib
+ FILE_GUID = DC4639D3-DB75-486B-AC38-C84AA49601E3
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioHandleLib
+
+[Sources]
+ NbioHandleLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
new file mode 100755
index 0000000000..0d6ba605f5
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PcieConfigLib
+ FILE_GUID = C1205AD2-FE67-4502-A0A7-FB1704A3F9AE
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PcieConfigLib
+
+[Sources]
+ PcieConfigLib.c
+ PcieInputParserLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
new file mode 100644
index 0000000000..ae1dd6cd83
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmnAccessLib
+ FILE_GUID = 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmnAccessLib
+
+[Sources]
+ SmnAccessLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ PrintLib
+ BaseLib
+ DebugPrintErrorLevelLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
new file mode 100644
index 0000000000..da7f5c185d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioCommonDxeLib
+ FILE_GUID = 1BF93335-5D55-46D9-99D9-5D962F039829
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioCommonDxeLib
+
+[Sources]
+ DxeLibFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ BaseLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
new file mode 100644
index 0000000000..54c3514020
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbDxeV3
+ FILE_GUID = 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3DxeDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ DxeServicesTableLib
+ MemoryAllocationLib
+ ApcbLibV3
+
+[Sources]
+ ApcbV3Dxe.c
+
+[Protocols]
+ gEfiDxeSmmReadyToLockProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
new file mode 100644
index 0000000000..7f90aa6ea0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbPeiV3
+ FILE_GUID = E1B8CF4A-FE7B-4676-B4F7-50C7228282A4
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3PeiDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PeimEntryPoint
+ ApcbLibV3Pei
+
+[sources]
+ ApcbV3Pei.c
+
+[Depex]
+ TRUE
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
new file mode 100755
index 0000000000..0f115c362e
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = OemAgesaCcxPlatformLibNull
+ FILE_GUID = B1F58B07-0146-4804-B701-A56CB5716529
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = OemAgesaCcxPlatformLib
+
+[Sources.common]
+ OemAgesaCcxPlatformLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
new file mode 100644
index 0000000000..ba551e5c14
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
@@ -0,0 +1,61 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciCfg2
+ FILE_GUID = 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PeimInitializePciCfg
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
+#
+
+[Sources]
+ PciExpressPciCfg2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+
+[LibraryClasses]
+ PeimEntryPoint
+ BaseLib
+ PcdLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ HobLib
+ IoLib
+
+[Ppis]
+ gEfiPciCfg2PpiGuid ## PRODUCES
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
+[Pcd.IA32,Pcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES
+
+[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
new file mode 100644
index 0000000000..e712a80886
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciSegmentInfoLib
+ FILE_GUID = FA8B1082-88DF-4744-85A3-7F87A9EBF8DC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciSegmentInfoLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ PciSegmentInfoLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
new file mode 100644
index 0000000000..f4b9d0d789
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspFlashAccLibSmm
+ FILE_GUID = 3BBDC3A5-A0E2-4E8A-8240-9E594920F040
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspFlashAccLib | DXE_SMM_DRIVER
+
+[Sources.common]
+ AmdPspFlashAccSpiNorLibSmm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ AmdPspBaseLibV2
+ BaseLib
+ DebugLib
+ SmmServicesTableLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSpiSmmNorFlashProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize ## CONSUMES
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ## CONSUMES
+
+[Depex]
+ gEfiSmmBase2ProtocolGuid AND
+ gEfiSpiSmmNorFlashProtocolGuid
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
new file mode 100644
index 0000000000..57bb0d9e25
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = PspRomArmorWhitelistLib
+ FILE_GUID = B6F8507A-C96B-4036-A8C0-26BAD6AC5F34
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformPspRomArmorWhitelistLib
+
+[Sources]
+ PspRomArmorWhitelistLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ MemoryAllocationLib
+ PcdLib
+ DebugLib
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
new file mode 100644
index 0000000000..64fd2913ad
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
@@ -0,0 +1,42 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+
+
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
new file mode 100644
index 0000000000..f4d7638c1a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
new file mode 100644
index 0000000000..973ace8632
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
new file mode 100644
index 0000000000..2d9dbeb715
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
@@ -0,0 +1,53 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+ UNLOAD_IMAGE = ActLibraryUnregisterActCommand
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ UefiLib
+ FileHandleLib
+ HiiLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+
+[Guids]
+ gShellActHiiGuid ## SOMETIMES_CONSUMES ## HII
+ gAgesaConfigDbPointerVariableGuid
+
+[Protocols]
+ gEfiShellDynamicCommandProtocolGuid
+ gEfiHiiPackageListProtocolGuid
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[DEPEX]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
new file mode 100644
index 0000000000..98c8755ab8
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
@@ -0,0 +1,50 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoToolApp.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ FileHandleLib
+ HiiLib
+ MemoryAllocationLib
+ UefiApplicationEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+ UefiLib
+ UefiRuntimeServicesTableLib
+
+[Protocols]
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[Guids]
+
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
new file mode 100644
index 0000000000..9c3c0dd0a9
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BasePlatformHookLibAmdFchUart
+ FILE_GUID = BF2F3F3F-4BE6-4B97-850D-D5D4941D391C
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformHookLib
+
+[Sources]
+ BasePlatformHookLibAmdFchUart.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ IoLib
+ PlatformHookLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
new file mode 100644
index 0000000000..3ec03aafd3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AGESA_H_
+#define AGESA_H_
+
+#include "AMD.h"
+#include "SocLogicalId.h"
+
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+#define DESCRIPTOR_INITIALIZE_LIST 0x20000000ull
+
+/// PCIe link initialization
+typedef enum {
+ EndpointDetect = 0, ///< Detect endpoint presence
+ EndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} PCIE_ENDPOINT_STATUS;
+
+/// PCIe port misc extended controls
+typedef struct {
+ IN UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ IN UINT8 LinkSafeMode : 2; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through PCIe_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertise maximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 2; ///< Unused space
+} PCIE_PORT_MISC_CONTROL;
+
+/// The IO APIC Interrupt Mapping Info
+typedef struct {
+ IN UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ IN UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< - ABCD
+ ///< - BCDA
+ ///< - CDAB
+ ///< - DABC
+ IN UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< - Entry 0 of IO APIC redirection table
+ ///< - Entry 1 of IO APIC redirection table
+ ///< - Entry 31 of IO APIC redirection table
+} APIC_DEVICE_INFO;
+
+/// GEN3 RxAdaptMode Configuration Structure
+typedef struct {
+ IN BOOLEAN InitOffsetCancellation; ///< Initial Offset Cancellation Enable
+ IN UINT8 DFEControl; ///< DFE Control
+ IN UINT8 LEQControl; ///< LEQ Control
+ IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic Offset Calibration Enable
+ IN BOOLEAN FOMCalculation; ///< FOM Calculation Enable
+ IN BOOLEAN PIOffsetCalibration; ///< PI Offset Calibratino Enable
+} RX_ADAPT_MODE;
+
+/// PCIe port configuration data
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 ChannelType; ///< Channel type.
+ ///< 0 - "lowLoss",
+ ///< 1 - "highLoss",
+ ///< 2 - "mob0db",
+ ///< 3 - "mob3db",
+ ///< 4 - "extnd6db"
+ ///< 5 - "extnd8db"
+ IN UINT8 DeviceNumber; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 FunctionNumber; ///< Reserved for future use
+ IN UINT8 LinkSpeedCapability; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT8 ResetId; ///< Arbitrary number greater than 0 assigned by platform firmware for GPIO
+ ///< identification which control reset for given port.
+ ///< Each port with unique GPIO should have unique ResetId assigned.
+ ///< All ports use same GPIO to control reset should have same ResetId assigned.
+ ///< see AgesaPcieSlotResetContol.
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3 RxAdaptMode configuration
+} PCIE_PORT_DATA;
+
+/// PCIe Complex descriptor
+typedef struct {
+ IN UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ IN UINT32 SocketId; ///< Socket Id
+ IN VOID *Reserved; ///< Reserved for future use
+} PCIE_COMPLEX_DESCRIPTOR;
+
+/// VBIOS image info
+typedef struct {
+ IN AMD_CONFIG_PARAMS StdHeader; ///< Standard configuration header
+ OUT VOID *ImagePtr; ///< Pointer to VBIOS image
+ IN PCI_ADDR GfxPciAddress; ///< PCI address of integrated graphics controller
+ IN UINT32 Flags; ///< BIT[0] - special repost requred
+} GFX_VBIOS_IMAGE_INFO;
+
+//
+// CPU MSR Register definitions
+//
+#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture Programming manual.
+#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture Programming manual.
+#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture Programming manual.
+
+///
+/// VDDP_VDDR Voltage Info for Low Power DIMM
+///
+typedef struct _VDDP_VDDR_VOLTAGE {
+ IN BOOLEAN IsValid; ///< Indicates if daata is valid
+ IN UINT8 Voltage; ///< VDDP VDDR Voltage Value
+} VDDP_VDDR_VOLTAGE;
+
+// CPU Build Configuration structures and definitions
+
+#define AMD_AP_MTRR_FIX64k_00000 0x00000250ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to AMD64 Architecture Programming manual
+
+#endif // AGESA_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/AgesaModulePkg/Include/AMD.h
new file mode 100755
index 0000000000..062d9e1e1a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
@@ -0,0 +1,91 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_H_
+#define AMD_H_
+
+/// The return status for all AGESA public services.
+///
+/// Services return the most severe status of any logged event. Status other than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
+/// will have log entries with more detail.
+///
+typedef enum {
+ AGESA_SUCCESS = 0, ///< 0 - The service completed normally. Info may be logged.
+ AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct had an unimplemented function requested.
+ ///< Not logged.
+ AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of range and the service was not provided.
+ ///< Example, memory address not installed, heap buffer handle not found.
+ ///< Not Logged.
+ AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP communications (used in ABL)
+ AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in ABL)
+
+ // AGESA_STATUS of greater severity (the ones below this line), always have a log entry available.
+ AGESA_ALERT, ///< 5 - An observed condition, but no loss of function. See Log.
+ AGESA_WARNING, ///< 6 - Possible or minor loss of function. See Log.
+ AGESA_ERROR, ///< 7 - Significant loss of function, boot may be possible. See Log.
+ AGESA_CRITICAL, ///< 8 - Continue boot only to notify user. See Log.
+ AGESA_FATAL, ///< 9 - Halt booting. See Log, however Fatal errors pertaining to heap problems
+ ///< may not be able to reliably produce log events.
+ AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory Overclock failure. (used in ABL)
+ AGESA_SKIP_ERROR, ///< 11 - Error, Skip init steps. (used in ABL)
+ AgesaStatusMax ///< Not a status, for limit checking.
+} AGESA_STATUS;
+
+/**
+ Callout method to the host environment.
+
+ Callout using a dispatch with appropriate thunk layer, which is determined by the host environment.
+
+ @param[in] Function The specific callout function being invoked.
+ @param[in] FcnData Function specific data item.
+ @param[in,out] ConfigPtr Reference to Callout params.
+**/
+typedef AGESA_STATUS (*CALLOUT_ENTRY) (
+ IN UINT32 Function,
+ IN UINTN FcnData,
+ IN OUT VOID *ConfigPtr
+ );
+
+/// AGESA Structures
+
+/// Extended PCI address format
+typedef struct {
+ IN OUT UINT32 Register : 12; ///< Register offset
+ IN OUT UINT32 Function : 3; ///< Function number
+ IN OUT UINT32 Device : 5; ///< Device number
+ IN OUT UINT32 Bus : 8; ///< Bus number
+ IN OUT UINT32 Segment : 4; ///< Segment
+} EXT_PCI_ADDR;
+
+/// Union type for PCI address
+typedef union _PCI_ADDR {
+ IN UINT32 AddressValue; ///< Formal address
+ IN EXT_PCI_ADDR Address; ///< Extended address
+} PCI_ADDR;
+
+///
+/// The standard header for all AGESA services.
+///
+typedef struct {
+ IN UINT32 ImageBasePtr; ///< The AGESA Image base address.
+ IN UINT32 Func; ///< The service desired
+ IN UINT32 AltImageBasePtr; ///< Alternate Image location
+ IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
+ IN UINT8 HeapStatus; ///< For heap status from boot time slide.
+ IN UINT64 HeapBasePtr; ///< Location of the heap
+ IN OUT UINT8 Reserved[7]; ///< This space is reserved for future use.
+} AMD_CONFIG_PARAMS;
+
+/// CPUID data received registers format
+typedef struct {
+ OUT UINT32 EAX_Reg; ///< CPUID instruction result in EAX
+ OUT UINT32 EBX_Reg; ///< CPUID instruction result in EBX
+ OUT UINT32 ECX_Reg; ///< CPUID instruction result in ECX
+ OUT UINT32 EDX_Reg; ///< CPUID instruction result in EDX
+} CPUID_DATA;
+#endif // AMD_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
new file mode 100755
index 0000000000..534b03d4a7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
@@ -0,0 +1,15 @@
+/** @file
+ AMD CPU Register Table Related Functions.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_H_
+#define CPU_REGISTERS_H_
+
+#include <CpuRegistersDef.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
new file mode 100644
index 0000000000..e086a4c9b1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
@@ -0,0 +1,61 @@
+/** @file
+ AMD Psp Directory header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_DIR_H_
+#define AMD_PSP_DIR_H_
+
+#pragma pack (push, 1)
+#define PSP_DIRECTORY_HEADER_SIGNATURE 0x50535024ul ///< $PSP
+#define PSP_LV2_DIRECTORY_HEADER_SIGNATURE 0x324C5024ul ///< $PL2
+
+/// Enum define various enum type for PSP entry type
+enum _PSP_DIRECTORY_ENTRY_TYPE {
+ PSP_REGION_A_DIR = 0x48, ///< PSP entry points to PSP DIR in Region A
+ PSP_REGION_B_DIR = 0x4A, ///< PSP entry points to PSP DIR in Region B
+};
+
+/// Define structure for PSP directory
+typedef struct {
+ UINT32 Cookie; ///< "$PSP"
+ UINT32 Checksum; ///< 32 bit CRC of header items below and the entire table
+ UINT32 TotalEntries; ///< Number of PSP Entries
+ UINT32 Reserved; ///< Unused
+} PSP_DIRECTORY_HEADER;
+
+/// Define structure for 32 bits Entry type field
+typedef struct {
+ UINT32 Type : 8; ///< Type of PSP Directory entry
+ UINT32 SubProgram : 8; ///< Specify the SubProgram
+ UINT32 RomId : 2; ///< Specify the ROM ID
+ UINT32 Reserved : 14; ///< Reserved
+} PSP_DIRECTORY_ENTRY_TYPE_FIELD;
+
+/// Define union type for 32 bits Entry type field
+typedef union {
+ PSP_DIRECTORY_ENTRY_TYPE_FIELD Field; ///< Definition of each filed
+ UINT32 Value; ///< Group it as 32bits Int
+} PSP_DIRECTORY_ENTRY_TYPE;
+
+/// Structure for PSP Entry
+typedef struct {
+ PSP_DIRECTORY_ENTRY_TYPE Type; ///< Type of PSP entry; 32 bit long
+ UINT32 Size; ///< Size of PSP Entry in bytes
+ UINT64 Location; ///< Location of PSP Entry (byte offset from start of SPI-ROM)
+} PSP_DIRECTORY_ENTRY;
+
+/// Structure for PSP directory
+typedef struct {
+ PSP_DIRECTORY_HEADER Header; ///< PSP directory header
+ PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PSP entries each pointing to a binary in SPI flash
+ ///< The actual size of this array comes from the
+ ///< header (PSP_DIRECTORY.Header.TotalEntries)
+} PSP_DIRECTORY;
+
+#pragma pack (pop)
+#endif //AMD_PSP_DIR_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
new file mode 100755
index 0000000000..faa8d35b1b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
@@ -0,0 +1,156 @@
+/** @file
+ AMD CPU Register Table Related Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_DEF_H_
+#define CPU_REGISTERS_DEF_H_
+
+#undef BIT0
+#undef BIT1
+#undef BIT2
+#undef BIT3
+#undef BIT4
+#undef BIT5
+#undef BIT6
+#undef BIT7
+#undef BIT8
+#undef BIT9
+#undef BIT10
+#undef BIT10
+#undef BIT11
+#undef BIT12
+#undef BIT13
+#undef BIT14
+#undef BIT15
+#undef BIT16
+#undef BIT17
+#undef BIT18
+#undef BIT19
+#undef BIT20
+#undef BIT21
+#undef BIT22
+#undef BIT23
+#undef BIT24
+#undef BIT25
+#undef BIT26
+#undef BIT27
+#undef BIT28
+#undef BIT29
+#undef BIT30
+#undef BIT31
+#undef BIT32
+#undef BIT33
+#undef BIT34
+#undef BIT35
+#undef BIT36
+#undef BIT37
+#undef BIT38
+#undef BIT39
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT50
+#undef BIT51
+#undef BIT52
+#undef BIT53
+#undef BIT54
+#undef BIT55
+#undef BIT56
+#undef BIT57
+#undef BIT58
+#undef BIT59
+#undef BIT60
+#undef BIT61
+#undef BIT62
+#undef BIT63
+
+#define BIT0 0x0000000000000001ull
+#define BIT1 0x0000000000000002ull
+#define BIT2 0x0000000000000004ull
+#define BIT3 0x0000000000000008ull
+#define BIT4 0x0000000000000010ull
+#define BIT5 0x0000000000000020ull
+#define BIT6 0x0000000000000040ull
+#define BIT7 0x0000000000000080ull
+#define BIT8 0x0000000000000100ull
+#define BIT9 0x0000000000000200ull
+#define BIT10 0x0000000000000400ull
+#define BIT11 0x0000000000000800ull
+#define BIT12 0x0000000000001000ull
+#define BIT13 0x0000000000002000ull
+#define BIT14 0x0000000000004000ull
+#define BIT15 0x0000000000008000ull
+#define BIT16 0x0000000000010000ull
+#define BIT17 0x0000000000020000ull
+#define BIT18 0x0000000000040000ull
+#define BIT19 0x0000000000080000ull
+#define BIT20 0x0000000000100000ull
+#define BIT21 0x0000000000200000ull
+#define BIT22 0x0000000000400000ull
+#define BIT23 0x0000000000800000ull
+#define BIT24 0x0000000001000000ull
+#define BIT25 0x0000000002000000ull
+#define BIT26 0x0000000004000000ull
+#define BIT27 0x0000000008000000ull
+#define BIT28 0x0000000010000000ull
+#define BIT29 0x0000000020000000ull
+#define BIT30 0x0000000040000000ull
+#define BIT31 0x0000000080000000ull
+#define BIT32 0x0000000100000000ull
+#define BIT33 0x0000000200000000ull
+#define BIT34 0x0000000400000000ull
+#define BIT35 0x0000000800000000ull
+#define BIT36 0x0000001000000000ull
+#define BIT37 0x0000002000000000ull
+#define BIT38 0x0000004000000000ull
+#define BIT39 0x0000008000000000ull
+#define BIT40 0x0000010000000000ull
+#define BIT41 0x0000020000000000ull
+#define BIT42 0x0000040000000000ull
+#define BIT43 0x0000080000000000ull
+#define BIT44 0x0000100000000000ull
+#define BIT45 0x0000200000000000ull
+#define BIT46 0x0000400000000000ull
+#define BIT47 0x0000800000000000ull
+#define BIT48 0x0001000000000000ull
+#define BIT49 0x0002000000000000ull
+#define BIT50 0x0004000000000000ull
+#define BIT51 0x0008000000000000ull
+#define BIT52 0x0010000000000000ull
+#define BIT53 0x0020000000000000ull
+#define BIT54 0x0040000000000000ull
+#define BIT55 0x0080000000000000ull
+#define BIT56 0x0100000000000000ull
+#define BIT57 0x0200000000000000ull
+#define BIT58 0x0400000000000000ull
+#define BIT59 0x0800000000000000ull
+#define BIT60 0x1000000000000000ull
+#define BIT61 0x2000000000000000ull
+#define BIT62 0x4000000000000000ull
+#define BIT63 0x8000000000000000ull
+
+#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO Configuration Base Address Register
+
+#endif // CPU_REGISTERS_DEF_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
new file mode 100644
index 0000000000..8ede1be838
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
@@ -0,0 +1,85 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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_TXBYTECOUNT 0x48 //
+#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 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/AgesaModulePkg/Include/Filecode.h b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
new file mode 100644
index 0000000000..726479d79f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * Collectively assign unique filecodes for assert and debug to each source file.
+ *
+ * Publish values for decorated filenames, which can be used for
+ * ASSERT and debug support using a preprocessor define like:
+ * @n <tt> _#define FILECODE MY_C_FILENAME_FILECODE </tt> @n
+ * This file serves as a reference for debugging to associate the code and filename.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: Include
+ * @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800 (Mon, 09 Feb 2015) $
+ */
+
+#ifndef _FILECODE_H_
+#define _FILECODE_H_
+
+#define UNASSIGNED_FILE_FILECODE (0xFFFF)
+
+#endif // _FILECODE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
new file mode 100755
index 0000000000..ddc9309d3d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_H_
+#define GNB_H_
+
+#define PVOID UINT64
+
+#endif // GNB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
new file mode 100644
index 0000000000..192e0d6a8b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
@@ -0,0 +1,521 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBDXIO_H_
+#define GNBDXIO_H_
+
+#pragma pack (push, 1)
+
+#include <AGESA.h>
+#include <Gnb.h>
+
+#define MAX_NUMBER_OF_COMPLEXES 16
+
+#define DESCRIPTOR_TERMINATE_GNB 0x40000000ull
+#define DESCRIPTOR_TERMINATE_TOPOLOGY 0x20000000ull
+#define DESCRIPTOR_ALLOCATED 0x10000000ull
+#define DESCRIPTOR_PLATFORM 0x08000000ull
+#define DESCRIPTOR_COMPLEX 0x04000000ull
+#define DESCRIPTOR_SILICON 0x02000000ull
+#define DESCRIPTOR_PCIE_WRAPPER 0x01000000ull
+#define DESCRIPTOR_PCIE_ENGINE 0x00800000ull
+#define DESCRIPTOR_CXL_ENGINE 0x00200000ull
+
+#define SILICON_CXL_CAPABLE 0x00008000ull
+
+#define DESCRIPTOR_ALL_WRAPPERS (DESCRIPTOR_PCIE_WRAPPER)
+#define DESCRIPTOR_ALL_ENGINES (DESCRIPTOR_PCIE_ENGINE | DESCRIPTOR_CXL_ENGINE)
+
+#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))
+
+typedef UINT16 PCIE_ENGINE_INIT_STATUS;
+
+///
+/// Engine Configuration
+///
+typedef struct {
+ IN UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ IN UINT16 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ IN UINT16 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+} PCIE_ENGINE;
+
+///
+/// PCIe port misc extended controls
+///
+typedef struct {
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 5; ///< Unused space
+} PORT_MISC_CONTROL;
+
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 FunctionNumber : 3; ///< Reserved for future use
+ IN UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 LinkSpeedCapability : 4; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm : 4; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN UINT8 Reserved1; ///< Reserved for future use
+} PORT_DATA;
+
+typedef struct {
+ UINT8 LinkSpeed;
+ UINT8 MaxPayloadSupport;
+ UINT8 AspmCapability;
+ UINT8 PciPmL1_1;
+ UINT8 PciPmL1_2;
+ UINT8 AspmL1_1;
+ UINT8 AspmL1_2;
+ UINT8 EsmSupport;
+ UINT8 LtrSupport;
+ UINT8 SurpriseDownErrorReport;
+ UINT8 TenBitTagSupport;
+ UINT8 AriForwarding;
+ UINT8 AcsSupport;
+ UINT8 AcsSourceValidation;
+ UINT8 AcsTranslationBlocking;
+ UINT8 AcsP2pRequestRedirect;
+ UINT8 AcsP2pCompletionRedirect;
+ UINT8 AcsUpstreamForwarding;
+ UINT8 AcsP2pEgressControl;
+ UINT8 AcsDirectTranslatedP2p;
+ UINT8 LaneMargining;
+ UINT8 DataLinkFeature;
+ UINT8 DownstreamPortContainment;
+ UINT8 AdvancedErrorReporting;
+ UINT8 ECRCSupport;
+ UINT8 MulticastEnable;
+ UINT8 NativePCIeEnclosureManagement;
+ UINT8 Capability1Address;
+ UINT8 Capability1Data;
+ UINT8 Capability2Address;
+ UINT8 Capability2Data;
+ UINT8 Capability3Address;
+ UINT8 Capability3Data;
+ UINT8 Capability4Address;
+ UINT8 Capability4Data;
+} PORT_CAPABILITIES;
+
+///
+/// PCIe PORT_FEATURES
+///
+typedef struct {
+ UINT8 LinkSpeedControl;
+ UINT8 MaxPayloadSizeControl;
+ UINT8 ESMControl;
+ UINT8 LTRControl;
+ UINT8 DataLinkFeatureExchangeControl;
+ UINT8 TenBitTagControl;
+ UINT8 ARIControl;
+ UINT8 ACSControl;
+ UINT8 RxLaneMarginingControl;
+ UINT8 DynLanesPwrState;
+ UINT8 L1PowerDown;
+ UINT8 L11PowerDown;
+ UINT8 L12PowerDown;
+ UINT8 AutoSpdChngEn;
+ UINT8 TurnOffUnusedLanes;
+} PORT_FEATURES;
+
+typedef struct {
+ UINT8 SpcGen1 : 1; ///< SPC Mode 2P5GT
+ UINT8 SpcGen2 : 1; ///< SPC Mode 5GT
+ UINT8 SpcGen3 : 2; ///< SPC Mode 8GT
+ UINT8 SpcGen4 : 2; ///< SPC Mode 16GT
+ UINT8 SpcGen5 : 2; ///< SPC Mode 32GT
+} SPC_MODE;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT32 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT32 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset Mask
+ UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnable
+ UINT32 UNUSED2 : 7; ///< Currently unassigned - for alignment
+} GEN3_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset Mask
+ UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEnable
+ UINT32 UNUSED3 : 13; ///< Currently unassigned - for alignment
+} GEN4_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset Mask
+ UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnable
+ UINT32 PrecodeRequest : 1; ///< Precoding Request
+ UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ To High Rate Support
+ UINT32 UNUSED4 : 11; ///< Currently unassigned - for alignment
+} GEN5_LANE_CNTL;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor0 : 5; ///< PostCursor0
+ UINT32 LcFapeReqPreCursor0 : 4; ///< PreCursor0
+ UINT32 LcFapeReqPostCursor1 : 5; ///< PostCursor1
+ UINT32 LcFapeReqPreCursor1 : 4; ///< PreCursor1
+ UINT32 LcFapeReqPostCursor2 : 5; ///< PostCursor2
+ UINT32 LcFapeReqPreCursor2 : 4; ///< PreCursor2
+ UINT32 UNUSED6 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_0;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor3 : 5; ///< PostCursor3
+ UINT32 LcFapeReqPreCursor3 : 4; ///< PreCursor3
+ UINT32 LcFapeReqPostCursor4 : 5; ///< PostCursor4
+ UINT32 LcFapeReqPreCursor4 : 4; ///< PreCursor4
+ UINT32 LcFapeReqPostCursor5 : 5; ///< PostCursor5
+ UINT32 LcFapeReqPreCursor5 : 4; ///< PreCursor5
+ UINT32 UNUSED7 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_1;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor6 : 5; ///< PostCursor6
+ UINT32 LcFapeReqPreCursor6 : 4; ///< PreCursor6
+ UINT32 LcFapeReqPostCursor7 : 5; ///< PostCursor7
+ UINT32 LcFapeReqPreCursor7 : 4; ///< PreCursor7
+ UINT32 LcFapeReqPostCursor8 : 5; ///< PostCursor8
+ UINT32 LcFapeReqPreCursor8 : 4; ///< PreCursor8
+ UINT32 UNUSED8 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_2;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor9 : 5; ///< PostCursor9
+ UINT32 LcFapeReqPreCursor9 : 4; ///< PreCursor9
+ UINT32 LcFapeReqPostCursor10 : 5; ///< PostCursor10
+ UINT32 LcFapeReqPreCursor10 : 4; ///< PreCursor10
+ UINT32 LcFapeReqPostCursor11 : 5; ///< PostCursor11
+ UINT32 LcFapeReqPreCursor11 : 4; ///< PreCursor11
+ UINT32 UNUSED9 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_3;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor12 : 5; ///< PostCursor12
+ UINT32 LcFapeReqPreCursor12 : 4; ///< PreCursor12
+ UINT32 LcFapeReqPostCursor13 : 5; ///< PostCursor13
+ UINT32 LcFapeReqPreCursor13 : 4; ///< PreCursor13
+ UINT32 LcFapeReqPostCursor14 : 5; ///< PostCursor14
+ UINT32 LcFapeReqPreCursor14 : 4; ///< PreCursor14
+ UINT32 UNUSED10 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_4;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor15 : 5; ///< PostCursor15
+ UINT32 LcFapeReqPreCursor15 : 4; ///< PreCursor15
+ UINT32 LcFapeReqPostCursor16 : 5; ///< PostCursor16
+ UINT32 LcFapeReqPreCursor16 : 4; ///< PreCursor16
+ UINT32 LcFapeReqPostCursor17 : 5; ///< PostCursor17
+ UINT32 LcFapeReqPreCursor17 : 4; ///< PreCursor17
+ UINT32 UNUSED11 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_5;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor18 : 5; ///< PostCursor18
+ UINT32 LcFapeReqPreCursor18 : 4; ///< PreCursor18
+ UINT32 LcFapeReqPostCursor19 : 5; ///< PostCursor19
+ UINT32 LcFapeReqPreCursor19 : 4; ///< PreCursor19
+ UINT32 LcFapeReqPostCursor20 : 5; ///< PostCursor20
+ UINT32 LcFapeReqPreCursor20 : 4; ///< PreCursor20
+ UINT32 UNUSED12 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_6;
+
+///
+/// PCIe port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 IsBmcLocation : 1; ///< Port Location of BMC
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 TXDeEmphasis : 4; ///< TX De-emphasis
+ UINT8 TXMargin : 3; ///< TX Margin
+ UINT8 UNUSED1 : 1; ///< Currently unassigned - for alignment
+
+ PORT_CAPABILITIES PortCapabilities; ///< Port Capabilities CBS
+
+ SPC_MODE SpcMode;
+
+ GEN3_LANE_CNTL LaneEqualizationCntl;
+ GEN4_LANE_CNTL Gen4LaneEqualizationCntl;
+ GEN5_LANE_CNTL Gen5LaneEqualizationCntl;
+
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 UNUSED4 : 1; ///< Currently unassigned - for alignment
+ UINT8 SRIS_SRNS : 1; ///< SRIS SRNS
+ UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SKP Support
+ UINT8 CcixControl : 1; ///< Bit to enable/disable ESM
+ UINT8 CxlControl : 1; ///< Bit to enable CXL Capability
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 SlotPowerLimitScale : 2; ///< Slot Power Limit Scale
+ UINT8 UNUSED5 : 1; ///< Currently unassigned - for alignment
+
+ UINT8 RxMarginPersistence : 1; ///< Bit to enable/disable Rx Margin persistence mode
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 TxVetting : 1; ///< Gen4 Tx Vetting
+ UINT8 RxVetting : 1; ///< Gen4 Rx Vetting
+ UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetting
+ UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetting
+
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 DlfCapDisable : 1; ///< DLF Capability 1:Disable 0:Enable
+ UINT8 DlfExchangeDisable : 1; ///< DLF Exchange 1:Disable 0:Enable
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+
+ UINT8 EqSearchMode : 2; ///< Equalization Search Mode
+ UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ
+ UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 EQ Phase2/3
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset value
+
+ UINT8 EqSearchModeGen4 : 2; ///< Equalization Search Mode for Gen4
+ UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass phase3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset value
+ UINT8 EqSearchModeGen5 : 2; ///< Equalization Search Mode for Gen5
+ UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass phase3 EQ
+ UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass phase2/3 EQ
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset value
+
+ UINT16 PsppPolicyDC; ///< Pspp Policy DC
+ UINT16 PsppPolicyAC; ///< Pspp Policy AC
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+
+ LC_FAPE_GROUP_0 LcFapeSettingsGroup0;
+ LC_FAPE_GROUP_1 LcFapeSettingsGroup1;
+ LC_FAPE_GROUP_2 LcFapeSettingsGroup2;
+ LC_FAPE_GROUP_3 LcFapeSettingsGroup3;
+ LC_FAPE_GROUP_4 LcFapeSettingsGroup4;
+ LC_FAPE_GROUP_5 LcFapeSettingsGroup5;
+ LC_FAPE_GROUP_6 LcFapeSettingsGroup6;
+
+ UINT8 ForceSteering : 1; ///< Steering is forced
+ UINT8 EsmUsTxPreset : 4; ///< ESM Upstream Tx Preset
+ UINT8 UNUSED13 : 3; ///< Currently unassigned - for alignment
+
+ // Used by DXE
+ PORT_FEATURES PortFeatures; ///< Port Features CBS
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 I2CMuxInfo; ///< First I2c Mux on Bus
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:SRIS 2:SRNS 3:SRNS in SRIS 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 ClkReq : 4; ///< ClkReq:[0:3]
+ UINT8 EqPreset : 4; ///< EqPreset:[4:7]
+ UINT8 LinkAspmL1_1 : 1; ///< Enable PM L1 SS L1.1
+ UINT8 LinkAspmL1_2 : 1; ///< Enable PM L1 SS L1.2
+ UINT8 EsmControl : 1; ///< Bit to enable/disable ESM
+ UINT8 EsmDsTxPreset : 4; ///< ESM Downstream Tx Preset
+ UINT8 ClkReqFilterEn : 1; ///< Controls filtering of CLKREQb signal in LC in order to avoid false L1 substate entries/exits.
+} PCIE_PORT_CONFIG;
+
+///
+/// CXL port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 UNUSED0 : 1; ///< Currently unassigned - for alignment
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 CxlIndex;
+ UINT8 CxlDeviceType : 2; ///< Type of CXL device connected
+ UINT8 CxlVersion : 2; ///< Version of CXL device connected (1=CXL1.1, 2=CXL2.0)
+ UINT8 IsCxlScanned : 1; ///< Indicates if the CXL device has been scanned
+ UINT8 ReportToMpioinDxe : 1; ///< Indicates if the CXL info needs to be reported to MPIO in DXE
+ UINT8 UNUSED1 : 2; ///< Currently unassigned - for alignment
+
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT32 Mmio32Base;
+ UINT32 Mmio32Size;
+ UINT64 Mmio64Base;
+ UINT64 Mmio64Size;
+ UINT32 Mmio32Gran;
+} PCIE_CXL_CONFIG;
+
+///
+/// Descriptor header
+///
+typedef struct {
+ UINT32 DescriptorFlags; ///< Descriptor flags
+ UINT16 Parent; ///< Offset of parent descriptor
+ UINT16 Peer; ///< Offset of the peer descriptor
+ UINT16 Child; ///< Offset of the list of child descriptors
+} PCIE_DESCRIPTOR_HEADER;
+
+///
+/// Engine configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor header
+ PCIE_ENGINE EngineData; ///< Engine Data
+ PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initialization Status
+ UINT8 Scratch; ///< Scratch pad
+ union {
+ PCIE_PORT_CONFIG Port; ///< PCIe port configuration data
+ PCIE_CXL_CONFIG Cxl; ///< CXL Configuration data
+ } Type;
+} PCIE_ENGINE_CONFIG;
+
+///
+/// Wrapper configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 WrapId; ///< Wrapper ID
+ UINT8 CcixCoreConfig; ///< Ccix CORE Configuration
+ UINT8 StartPhyLane; ///< Start PHY Lane
+ UINT8 EndPhyLane; ///< End PHY Lane
+ UINT8 StartDxioLane; ///< Start Dxio Lane (Translated)
+ UINT8 EndDxioLane; ///< End Dxio Lane (Translated)
+ struct {
+ UINT8 PowerOffUnusedLanes : 1; ///< Power Off unused lanes
+ UINT8 PowerOffUnusedPlls : 1; ///< Power Off unused Plls
+ UINT8 ClkGating : 1; ///< TXCLK gating
+ UINT8 LclkGating : 1; ///< LCLK gating
+ UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock gating PLL power down
+ UINT8 PllOffInL1 : 1; ///< PLL off in L1
+ UINT8 AccessEncoding : 1; ///< Reg access encoding
+ UINT8 CoreReversed : 1; ///< Indicates lanes are reversed in package connection
+ } Features;
+ UINT8 MasterPll; ///< Bitmap of master PLL
+ UINT32 AcsSupport : 1; ///< Acs Support
+ UINT32 LtrSupport : 1; ///< LTR Support
+ UINT32 AriForwarding : 1; ///< ARI Forwarding
+ UINT32 LaneMargining : 1; ///< Lane Margining
+ UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM
+ UINT32 DownstreamPortContainment : 1; ///< Downstream port containment
+ UINT32 AdvancedErrorReporting : 1; ///< Advacned Error Reporting
+ UINT32 ECRCSupport : 2; ///< ECRC Capability
+ UINT32 Reserved : 23; ///< Reserved bits
+} PCIE_WRAPPER_CONFIG;
+
+///
+/// Silicon configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 SocketId; ///< Socket ID
+ UINT8 DieNumber; ///< Module ID
+ UINT8 RBIndex; ///< Physical Root Bridge
+ UINT8 InstanceId; ///< Logical Instance Identifier
+ PCI_ADDR Address; ///< PCI address of GNB host bridge
+ UINT16 StartLane; ///< Start Lane of this node
+ UINT16 EndLane; ///< End Lane of this node
+ UINT8 BusNumberLimit; ///< Last Bus Number assigned to this node
+ UINT8 SbPresent : 1; ///< Set to 1 if FCH connected to this NBIO
+ UINT8 SmuPresent : 1; ///< Set to 1 if SMU connected to this NBIO
+ UINT8 MP_Instance : 6; ///< MP Instance
+ UINT8 LogicalRBIndex; ///< Logical Root Bridge
+ UINT8 NumEngineDesc; ///< Total number of lane bifurcation descriptors
+} PCIE_SILICON_CONFIG;
+
+typedef PCIE_SILICON_CONFIG GNB_HANDLE;
+
+///
+/// Complex configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 NodeId; ///< Processor Node ID
+ UINT8 Reserved; ///< For alignment
+} PCIE_COMPLEX_CONFIG;
+
+///
+/// PCIe platform configuration info
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ PVOID Reserved1; ///< Reserved
+ UINT32 Reserved2; ///< Reserved
+ UINT32 PhyConfigData; ///< Phy Configuration Data
+ UINT32 Reserved3; ///< Reserved
+ UINT32 Reserved4; ///< Reserved
+ UINT32 PsppTuningParams; ///< Tuning parameters for PSPP
+ UINT32 PsppTuningParams2; ///< Tuning parameters 2 for PSPP
+ UINT8 Reserved5; ///< Reserved
+ UINT8 PsppPolicy; ///< PSPP policy
+ UINT8 Reserved6; ///< Reserved
+ UINT8 RootBridgesPerSocket; ///< Number of root bridges per socket
+ PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES]; ///< Complex
+} PCIE_PLATFORM_CONFIG;
+
+///
+/// PCIe Engine Description
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor on wrapper
+ ///< Bit30 - Descriptor allocated for PCIe port
+ PCIE_ENGINE EngineData; ///< Engine Data
+} PCIE_ENGINE_DESCRIPTOR;
+#pragma pack (pop)
+
+#endif // GNBDXIO_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
new file mode 100644
index 0000000000..90f52cca7b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
@@ -0,0 +1,18 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _GNBREGISTERSRS_H_
+#define _GNBREGISTERSRS_H_
+
+#include "GnbRegistersRS/IOHC.h"
+
+#ifndef NBIO_SPACE
+#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + (HANDLE->RBIndex << 20))
+#endif
+
+#endif /*_GNBREGISTERSRS_H_*/
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
new file mode 100644
index 0000000000..b1a95237de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _IOHC_H_
+#define _IOHC_H_
+
+// Bitfield Description : DBG MMIO enable.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
+
+// Bitfield Description : Locks the DBG MMIO address range and enable until the next warm reset.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
+
+#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 0x13c102f0UL
+
+#endif /* _IOHC_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
new file mode 100644
index 0000000000..f5cc5e2228
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_PCIE_HOB_INFO_H_
+#define GNB_PCIE_HOB_INFO_H_
+
+#define _GNB_PCIE_HOB_INFO_GUID \
+{ \
+ 0x3eb1d90, 0xce14, 0x40d8, 0xa6, 0xba, 0x10, 0x3a, 0x8d, 0x7b, 0xd3, 0x2d \
+}
+extern EFI_GUID gGnbPcieHobInfoGuid;
+
+#pragma pack (push, 1)
+#define MAX_NUMBER_OF_CORES_PER_COMPLEX 3
+#define MAX_NUMBER_OF_PORTS_PER_COMPLEX 22
+
+/// PCIe information HOB data
+typedef struct _GNB_PCIE_INFORMATION_DATA_HOB {
+ EFI_HOB_GUID_TYPE EfiHobGuidType; ///< GUID Hob type structure
+ PCIE_PLATFORM_CONFIG PciePlatformConfigHob; ///< Platform Config Structure
+ UINT32 ComplexConfigs; ///< Allocation for Max Complex Structure suported
+} GNB_PCIE_INFORMATION_DATA_HOB;
+
+#pragma pack (pop)
+
+#endif /* GNB_PCIE_HOB_INFO_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
new file mode 100644
index 0000000000..dc773737b9
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+ Contains interface to the AMD AGESA library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_BASE_LIB_H_
+#define AMD_BASE_LIB_H_
+
+#include "Uefi.h"
+#include "AMD.h"
+
+#endif // AMD_BASE_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
new file mode 100644
index 0000000000..9d9892aa30
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
@@ -0,0 +1,43 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * PSP Mailbox related functions Prototype definition
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: PSP
+ * @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue, 03 Feb 2015) $
+ */
+
+#ifndef _PSP_MBOX_H_
+#define _PSP_MBOX_H_
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ );
+
+#endif //_PSP_MBOX_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
new file mode 100644
index 0000000000..51935f413a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BASE_FABRIC_TOPOLOGY_LIB_H_
+#define BASE_FABRIC_TOPOLOGY_LIB_H_
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ );
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ );
+
+#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
new file mode 100644
index 0000000000..cae3aff9b3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_BASE_LIB_H_
+#define _FCH_BASE_LIB_H_
+
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/BaseLib.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
new file mode 100644
index 0000000000..345e39adce
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
@@ -0,0 +1,413 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_ESPI_CMD_LIB_H_
+#define _FCH_ESPI_CMD_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+#define MAX_ESPI_RETRY 100000ul
+//
+// Cycle Type
+//
+#define CYCLE_TYPE_FLASH_READ 0
+#define CYCLE_TYPE_FLASH_WRITE 1
+#define CYCLE_TYPE_FLASH_ERASE 2
+#define CYCLE_TYPE_RPMC_OP1 3
+#define CYCLE_TYPE_RPMC_OP2 4
+
+// RPMC OP1/OP2 Command Payload Max Length (512 Bits)
+#define RPMC_CMD_PAYLOAD_MAX_LEN 0x40
+
+//
+// Master Registers
+//
+#define SET_CONFIGURATION 0
+#define GET_CONFIGURATION 1
+#define IN_BAND_RESET 2
+#define PC_MSG_DOWN_STREAM 4
+#define VM_DOWN_STREAM 5
+#define OOB_DOWN_STREAM 6
+#define FA_DOWN_STREAM 7
+
+// ESPIx00
+#define DNCMD_STATUS BIT3
+
+// ESPIx2C Master Capability
+#define MASTER_FA_SUPPORT BIT0
+#define MASTER_OOB_SUPPORT BIT1
+#define MASTER_VW_SUPPORT BIT2
+#define MASTER_PERIPHERAL_SUPPORT BIT3
+
+// ESPIx68 Slave0 Configuration
+#define SLAVE_FA_ENABLE BIT0
+#define SLAVE_OOB_ENABLE BIT1
+#define SLAVE_VW_ENABLE BIT2
+#define SLAVE_PC_ENABLE BIT3
+
+/// eSPIx00 eSPI Software Specific Register 0
+#define ESPI_DN_TXHDR_0 0x00
+typedef union {
+ struct {
+ UINT32 SWCommandType : 3;
+ UINT32 CommandStatus : 1;
+ UINT32 PutFlashNpTranActive : 1;
+ UINT32 Reserved : 3;
+ UINT32 DnCmdHdata0 : 8;
+ UINT32 DnCmdHdata1 : 8;
+ UINT32 DnCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx00_DN_TXHDR0;
+
+/// eSPIx04 eSPI Software Specific Register 1
+#define ESPI_DN_TXHDR_1 0x04
+typedef union {
+ struct {
+ UINT32 DnCmdHdata3 : 8;
+ UINT32 DnCmdHdata4 : 8;
+ UINT32 DnCmdHdata5 : 8;
+ UINT32 DnCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx04_DN_TXHDR1;
+
+#define ESPI_DN_TXHDR_2 0x08
+typedef union {
+ struct {
+ UINT32 DnCmdHdata7 : 8;
+ UINT32 Reserved : 24;
+ } Field;
+ UINT32 Value;
+} ESPIx08_DN_TXHDR2;
+
+#define ESPI_DN_TXDATA_PORT 0x0C
+typedef union {
+ struct {
+ UINT32 DnTxData0 : 8;
+ UINT32 DnTxData1 : 8;
+ UINT32 DnTxData2 : 8;
+ UINT32 DnTxData3 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx0C_DN_TXDATA_PORT;
+
+#define ESPI_UP_RXHDR_0 0x10
+typedef union {
+ struct {
+ UINT32 UpCommandType : 3;
+ UINT32 UpCommandStatus : 1;
+ UINT32 SlaveSel : 2;
+ UINT32 Reserved : 2;
+ UINT32 UpCmdHdata0 : 8;
+ UINT32 UpCmdHdata1 : 8;
+ UINT32 UpCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx10_UP_RXHDR0;
+
+#define ESPI_UP_RXHDR_1 0x14
+typedef union {
+ struct {
+ UINT32 UpCmdHdata3 : 8;
+ UINT32 UpCmdHdata4 : 8;
+ UINT32 UpCmdHdata5 : 8;
+ UINT32 UpCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx14_UP_RXHDR1;
+
+#define ESPI_UP_RXDATA_PORT 0x18
+
+/// eSPIx2C eSPI Master Capability
+#define ESPI_MASTER_CAP 0x2C
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelSupport : 1;
+ UINT32 OOBMessageChannelSupport : 1;
+ UINT32 VWChannelSupport : 1;
+ UINT32 PChannelSupport : 1;
+ UINT32 MasterVersion : 3;
+ UINT32 FlashAccessChannelMaxPayload : 3;
+ UINT32 OOBMessageChannelMaxPayload : 3;
+ UINT32 OperatingMaxVWCount : 6;
+ UINT32 PChannelMaxPayloadSize : 3;
+ UINT32 NumberOfSlave : 3;
+ UINT32 OperatingSupportFreq : 3;
+ UINT32 IOMode : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheck : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx2C_MASTER_CAP;
+
+/// eSPIx30 eSPI Global Control 0
+#define ESPI_GLOBAL_CTRL0 0x30
+typedef union {
+ struct {
+ UINT32 WdgEn : 1;
+ UINT32 WaitChkEn : 1;
+ UINT32 PrClkgatEn : 1;
+ UINT32 AlStopEn : 1;
+ UINT32 AlIdleTimer : 3;
+ UINT32 RgDbgclkGatingEn : 1;
+ UINT32 WdgCnt : 16;
+ UINT32 WaitCnt : 6;
+ UINT32 PrRstEnPltrst : 1;
+ UINT32 SafsClkGateEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx30_GLOBAL_CTRL0;
+
+/// eSPIx68 eSPI Slave0 Configuration
+#define ESPI_SLAVE0_CONFIG 0x68
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelEnable : 1;
+ UINT32 OOBMessageChannelEnable : 1;
+ UINT32 VWChannelEnable : 1;
+ UINT32 PChannelEnable : 1;
+ UINT32 FlashSharingMode : 1;
+ UINT32 FlashMaxPayloadSize : 3;
+ UINT32 PutFlashNpHeaderDataEn : 1;
+ UINT32 PutFlashNpHeaderEn : 1;
+ UINT32 SafsDeferValidEn : 1;
+ UINT32 FlashModifierEn : 1;
+ UINT32 Reserved_24_12 : 13;
+ UINT32 OperatingFreq : 3;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheckingEnable : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx68_SLAVE0_CONFIG;
+
+/// eSPIx70 eSPI Slave0 Interrupt Status
+#define ESPI_SLAVE0_INT_STS 0x70
+typedef union {
+ struct {
+ UINT32 BusErrInt : 1;
+ UINT32 WaitTimeoutInt : 1;
+ UINT32 CrcErrInt : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 NoRspInt : 1;
+ UINT32 FatalErrInt : 1;
+ UINT32 NonFatalErrInt : 1;
+ UINT32 UnknownRspInt : 1;
+ UINT32 UnknownCtInt : 1;
+ UINT32 UnsucssCplInt : 1;
+ UINT32 IllegalTagInt : 1;
+ UINT32 IllegalLenInt : 1;
+ UINT32 RxOobOverflowInt : 1;
+ UINT32 RxMsgOverflowInt : 1;
+ UINT32 RxFlashOverflowInt : 1;
+ UINT32 ProtocolErrInt : 1;
+ UINT32 Reserved_16 : 1;
+ UINT32 UpFifoWdgTo : 1;
+ UINT32 MstAbortInt : 1;
+ UINT32 WdgTimeoutInt : 1;
+ UINT32 Reserved_23_20 : 4;
+ UINT32 RxVwGrp0Int : 1;
+ UINT32 RxVwGrp1Int : 1;
+ UINT32 RxVwGrp2Int : 1;
+ UINT32 RxVwGrp3Int : 1;
+ UINT32 DnCmdInt : 1;
+ UINT32 RxMsgInt : 1;
+ UINT32 RxOobInt : 1;
+ UINT32 FlashReqInt : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx70_SLAVE0_INT_STS;
+
+///
+/// Slave Registers
+///
+#define SLAVE_REG_ID 0x04
+#define SLAVE_GENERAL_CAPCFG 0x08
+#define SLAVE_PC_CAPCFG 0x10
+#define SLAVE_VW_CAPCFG 0x20
+#define SLAVE_OOB_CAPCFG 0x30
+#define SLAVE_FA_CAPCFG 0x40
+#define SLAVE_FA_CAPCFG2 0x44
+
+/// Offset 04h: Device Identification
+typedef union {
+ struct {
+ UINT32 RO_VersionID : 8;
+ UINT32 Reserved_31_8 : 24;
+ } Field;
+ UINT32 Value;
+} ESPI_SL04_DEVICE_ID;
+
+// SLAVE offset 0x08 SLAVE_GENERAL_CAPCFG
+#define SLAVE_FA_SUPPORT BIT3
+#define SLAVE_OOB_SUPPORT BIT2
+#define SLAVE_VW_SUPPORT BIT1
+#define SLAVE_PERIPHERAL_SUPPORT BIT0
+/// Offset 08h: General Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 RO_PCSupported : 1;
+ UINT32 RO_VWSupported : 1;
+ UINT32 RO_OOBMsgSupported : 1;
+ UINT32 RO_FASupported : 1;
+ UINT32 Reserved_7_3 : 4;
+ UINT32 Reserved_11_8 : 4;
+ UINT32 RO_MaxWaitStateAllowed : 4;
+ UINT32 RO_MaxFreqSupported : 3;
+ UINT32 RO_OpenDrainAlertSupported : 1;
+ UINT32 OperatingFreq : 3;
+ UINT32 OpenDrainAlertSelect : 1;
+ UINT32 RO_IOModeSupported : 2;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 Reserved_29 : 1;
+ UINT32 ResponseModifierEn : 1;
+ UINT32 CRCCheckingEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPI_SL08_SLAVE_GENERAL_CAPCFG;
+
+/// Offset 10h: Channel 0 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 PCEn : 1;
+ UINT32 RO_PCReady : 1;
+ UINT32 BusMasterEn : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 RO_PCMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 PCMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_11 : 1;
+ UINT32 PCMaxReadRequestSize : 3;
+ UINT32 Reserved_31_15 : 17;
+ } Field;
+ UINT32 Value;
+} ESPI_SL10_SLAVE_PC_CAPCFG;
+
+/// Offset 20h: Channel 1 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 VWEn : 1;
+ UINT32 RO_VWReady : 1;
+ UINT32 Reserved_7_2 : 6;
+ UINT32 RO_MaxVWCntSupported : 6;
+ UINT32 Reserved_15_14 : 2;
+ UINT32 OpMaxVWCnt : 6;
+ UINT32 Reserved_31_22 : 10;
+ } Field;
+ UINT32 Value;
+} ESPI_SL20_SLAVE_VW_CAPCFG;
+
+/// Offset 30h: Channel 2 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 OOBEn : 1;
+ UINT32 RO_OOBReady : 1;
+ UINT32 Reserved_3_2 : 2;
+ UINT32 RO_MsgChMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 MsgChMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_31_11 : 21;
+ } Field;
+ UINT32 Value;
+} ESPI_SL30_SLAVE_OOB_CAPCFG;
+
+/// Offset 40h: Channel 3 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 FAEn : 1;
+ UINT32 RO_FAReady : 1;
+ UINT32 FlashBlockEraseSize : 3;
+ UINT32 RO_ChMaxPayloadSizeSupported : 3;
+ UINT32 ChMaxPayloadSizeSelected : 3;
+ UINT32 RO_FlashSharingMode : 1;
+ UINT32 ChMaxReadReqSize : 3;
+ UINT32 Reserved_15 : 1;
+ UINT32 RO_FlashSharingCapabilitySupported : 2;
+ UINT32 Reserved_19_18 : 2;
+ UINT32 RO_RPMCCounterOn1stDevice : 4;
+ UINT32 RO_RPMCOp1On1stDevice : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL40_SLAVE_FA_CAPCFG;
+
+/// Offset 44h: Channel 3 Capabilities and Configurations2
+typedef union {
+ struct {
+ UINT32 RO_TargetMaxReadReqSizeSupported : 3;
+ UINT32 Reserved_7_3 : 5;
+ UINT32 RO_TargetFlashEraseBlockSize : 8;
+ UINT32 RO_TargetRPMCSupported : 6;
+ UINT32 RO_NumOfRPMCdevices : 2;
+ UINT32 Reserved_31_24 : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL44_SLAVE_FA_CAPCFG2;
+
+//
+// eSPI Command functions
+//
+VOID
+FchEspiCmd_InBandRst (
+ IN UINT32 EspiBase
+ );
+
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ );
+
+VOID
+FchEspiCmd_SetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr,
+ IN UINT32 Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp1 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ IN UINT8 *Data
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp2 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
new file mode 100755
index 0000000000..19688e2548
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
@@ -0,0 +1,16 @@
+/** @file
+ GNB PCIe Library definition.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBPCIECONFIG_LIB_H_
+#define GNBPCIECONFIG_LIB_H_
+
+#include <GnbDxio.h>
+#include <Library/PcieConfigLib.h>
+
+#endif // GNBPCIECONFIG_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
new file mode 100644
index 0000000000..df88274530
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
@@ -0,0 +1,37 @@
+/** @file
+ Header file of AMD NBIO Common DXE library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOCOMMONLIBDXE_H_
+#define NBIOCOMMONLIBDXE_H_
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ );
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ );
+
+#endif // NBIOCOMMONLIBDXE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
new file mode 100755
index 0000000000..4fec578a9f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
@@ -0,0 +1,62 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOHANDLELIB_LIB_H_
+#define NBIOHANDLELIB_LIB_H_
+
+#include <GnbDxio.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ );
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ );
+
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define GnbGetSocketId(Handle) (Handle != NULL ? (Handle)->SocketId : 0)
+#define GnbGetDieNumber(Handle) (Handle != NULL ? (Handle)->DieNumber : 0)
+#define GnbGetRBIndex(Handle) (Handle != NULL ? (Handle)->RBIndex : 0)
+
+#endif // NBIOHANDLELIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
new file mode 100644
index 0000000000..9f53746814
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
@@ -0,0 +1,283 @@
+/** @file
+ Helper functions to access PCIe configuration data area.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PCIECONFIGLIB_LIB_H_
+#define PCIECONFIGLIB_LIB_H_
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_WRAPPER_CALLBACK) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK2) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+typedef VOID (*PCIE_RUN_ON_WRAPPER_CALLBACK2) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_DESCRIPTOR_CALLBACK) (
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ );
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ );
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ );
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ );
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ );
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ );
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ );
+
+#define PcieConfigGetParentWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetParent (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetParentSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetParentComplex(Descriptor) ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX, &((Descriptor)->Header)))
+#define PcieConfigGetPlatform(Descriptor) ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM, &((Descriptor)->Header)))
+#define PcieConfigGetChildWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetChildEngine(Descriptor) ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES, &((Descriptor)->Header)))
+#define PcieConfigGetChildSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetNextDescriptor(Descriptor) ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : ((Descriptor + 1))))
+#define PcieConfigIsPcieEngine(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_PCIE_ENGINE) != 0) : FALSE)
+#define PcieConfigIsSbPcieEngine(Engine) ((Engine != NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.SbLink)) : FALSE)
+#define PcieConfigIsEngineAllocated(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_ALLOCATED) != 0) : FALSE)
+#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) if (Descriptor != NULL) (Descriptor)->Header.DescriptorFlags |= SetDescriptorFlags
+#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) if (Descriptor != NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags &= (~(ResetDescriptorFlags))
+#define PcieInputParsetGetNextDescriptor(Descriptor) ((Descriptor == NULL) ? NULL : ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
+#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination) ((Descriptor == NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags & Termination) != 0) ? NULL : ((UINT8 *) Descriptor + ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Peer))
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define PcieConfigGetNextDataDescriptor(Descriptor) ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0 ? NULL : (Descriptor + 1))
+
+#endif // PCIECONFIGLIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
new file mode 100644
index 0000000000..f0c6d1ccbb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SMNACCESSLIB_H_
+#define _SMNACCESSLIB_H_
+
+VOID
+SmnRegisterReadS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ OUT VOID *Value
+ );
+
+VOID
+SmnRegisterRMWS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrValue,
+ IN UINT32 Flags
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
new file mode 100644
index 0000000000..0e08e64b24
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_PCIE_SERVICES_PROTOCOL_H_
+#define NBIO_PCIE_SERVICES_PROTOCOL_H_
+
+// Current PROTOCOL revision
+#define AMD_NBIO_PCIE_SERVICES_REVISION 0x00
+
+///
+/// Forward declaration for the NBIO_PCIE_SERVICES_PROTOCOL
+///
+typedef struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL;
+
+//
+// Protocol Definitions
+//
+
+/**
+ Returns the NBIO debug options configuration structure
+ This
+ A pointer to the DXE_AMD_NBIO_SMU_SERVICES_PROTOCOL instance.
+ DebugOptions
+ A pointer to a pointer to store the address of the PCIe topology structure
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT)(
+ IN DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL *This,
+ OUT UINT32 **DebugOptions
+ );
+
+///
+/// The Dxe of PCIE Services
+///
+struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL {
+ AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT PcieGetTopology; ///<
+};
+
+extern EFI_GUID gAmdNbioPcieServicesProtocolGuid;
+
+#endif /* NBIO_PCIE_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
new file mode 100644
index 0000000000..10d3b730a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
+#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
+
+extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
new file mode 100644
index 0000000000..a15995188b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
@@ -0,0 +1,155 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_NUMA_SERVICES2_H_
+#define FABRIC_NUMA_SERVICES2_H_
+#include "AMD.h"
+
+#pragma pack (push, 1)
+
+#define MAX_PXM_VALUES_PER_QUADRANT 16
+
+/// Domain type
+typedef enum {
+ NumaDram,
+ NumaSLink,
+ NumaCxl,
+ MaxNumaDomainType2
+} DOMAIN_TYPE2;
+
+/// Reported Domain Info
+typedef struct {
+ DOMAIN_TYPE2 Type; ///< Type
+ UINT32 SocketMap; ///< Bitmap indicating physical socket location
+ UINT32 PhysicalDomain; ///< Physical domain number
+} DOMAIN_INFO2;
+
+/// Physical Dram Info
+typedef struct {
+ UINT32 NormalizedCsMap; ///< Bitmap of CSs comprising this physical domain
+ UINT32 SharingEntityCount; ///< Number of virtual domains sharing this physical domain
+ UINT32 SharingEntityMap; ///< Bitmap of reported domains that share this physical domain
+ UINT32 Reserved; ///< Reserved
+} PHYS_DOMAIN_INFO;
+
+/// Proximity Domain Info
+typedef struct {
+ UINTN Count; ///< Entries in Domain array
+ UINTN Domain[MAX_PXM_VALUES_PER_QUADRANT]; ///< Domains in Quadrant
+} PXM_DOMAIN_INFO;
+
+///
+/// Forward declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL
+///
+typedef struct _FABRIC_NUMA_SERVICES2_PROTOCOL FABRIC_NUMA_SERVICES2_PROTOCOL;
+
+/**
+ * @brief Get the numa domain information.
+ *
+ * @details Get the numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfDomainsInSystem Number of unique NUMA domains
+ * @param[out] DomainInfo An array with information about each domain
+ * @param[out] CcxAsNumaDomain TRUE: each core complex is its own domain
+ * FALSE: physical mapping is employed
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfDomainsInSystem,
+ OUT DOMAIN_INFO2 **DomainInfo,
+ OUT BOOLEAN *CcxAsNumaDomain
+ );
+
+/**
+ * @brief Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @details Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] Socket Zero based socket that the core is attached to
+ * @param[in] Die DF die on socket that the core is attached to
+ * @param[in] Ccd Logical CCD the core is on
+ * @param[in] Ccx Logical core complex
+ * @param[out] Domain Domain the core belongs to
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_DOMAIN_XLAT)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Ccd,
+ IN UINTN Ccx,
+ OUT UINT32 *Domain
+ );
+
+/**
+ * @brief Get physical numa domain information.
+ *
+ * @details Get physical numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfPhysDomainsInSystem Number of valid domains in the system
+ * @param[out] PhysDomainInfo An array with information about each physical domain
+ * @param[out] PhysNodesPerSocket Actual NPS as determined by ABL (not including SLink)
+ * @param[out] NumberOfSystemSLinkDomains Number of domains describing SLink connected memory
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfPhysDomainsInSystem,
+ OUT PHYS_DOMAIN_INFO **PhysDomainInfo,
+ OUT UINT32 *PhysNodesPerSocket,
+ OUT UINT32 *NumberOfSystemSLinkDomains
+ );
+
+/**
+ * @brief Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @details Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] RootPortBDF BDF for root-port bridge in PCI_ADDR format.
+ * @param[out] PxmDomainInfo Pointer to a structure returning associated NUMA node(s).
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN PCI_ADDR RootPortBDF,
+ OUT PXM_DOMAIN_INFO *PxmDomainInfo
+ );
+
+///
+/// When installed, the Fabric NUMA Services 2 Protocol produces a collection of
+/// services that return various information associated with non-uniform memory
+/// architecture.
+///
+struct _FABRIC_NUMA_SERVICES2_PROTOCOL {
+ UINTN Revision; ///< Revision Number
+ FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO GetDomainInfo; ///< Get Domain Info
+ FABRIC_NUMA_SERVICES2_DOMAIN_XLAT DomainXlat; ///< Domain Translation
+ FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO GetPhysDomainInfo; ///< Get Physical Domain Info
+ FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO GetPxmDomainInfo; ///< Get Proximity Domain Info
+};
+
+///
+/// Guid declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL.
+///
+extern EFI_GUID gAmdFabricNumaServices2ProtocolGuid;
+
+#pragma pack (pop)
+#endif // _FABRIC_NUMA_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
new file mode 100644
index 0000000000..485240c0fb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_TOPOLOGY_SERVICES2_H_
+#define FABRIC_TOPOLOGY_SERVICES2_H_
+
+#include <Library/BaseFabricTopologyLib.h>
+
+#endif // FABRIC_TOPOLOGY_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
new file mode 100755
index 0000000000..44093e4097
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
@@ -0,0 +1,23 @@
+/** @file
+ SoC Logical ID Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SOC_LOGICAL_ID_H_
+#define SOC_LOGICAL_ID_H_
+#pragma pack (push, 1)
+
+///
+/// SOC logical ID structure
+///
+typedef struct _SOC_LOGICAL_ID {
+ IN OUT UINT32 Family; ///< Indicates logical ID Family
+ IN OUT UINT16 Revision; ///< Indicates logical ID Revision
+} SOC_LOGICAL_ID;
+
+#pragma pack (pop)
+#endif // SOC_LOGICAL_ID_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
new file mode 100644
index 0000000000..a60ae20d33
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _INTERNAL_AML_LIB_H_
+#define _INTERNAL_AML_LIB_H_
+
+#include <Uefi.h>
+#include <Library/AmlGenerationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <IndustryStandard/Acpi.h>
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
new file mode 100644
index 0000000000..b19b6fe867
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -0,0 +1,150 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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/AgesaPkg/Include/AmdPcieComplex.h b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
new file mode 100755
index 0000000000..3a628ed0b2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
@@ -0,0 +1,432 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCIE_COMPLEX_H_
+#define AMD_PCIE_COMPLEX_H_
+
+//
+// GNB PCIe configuration info
+//
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+
+//
+// Port parameter count
+//
+#define PCIE_PORT_PARAMETER_COUNT 64
+
+///
+/// PCIe link initialization
+/// DXIO endpoint status
+///
+typedef enum {
+ DxioEndpointDetect = 0, ///< Detect endpoint presence
+ DxioEndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} DXIO_ENDPOINT_STATUS;
+
+#pragma pack(push,1)
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific port parameter to set.
+ UINT16 ParamValue; ///< Specifies the value to be assigned to port parameter.
+} PORT_PARAM;
+
+typedef struct {
+ PORT_PARAM PhyParam[PCIE_PORT_PARAMETER_COUNT]; ///< PHY port parameter
+} PORT_PARAMS;
+
+///
+/// Ancillary data struct with table size and address
+///
+typedef struct {
+ IN UINT32 Count; ///< Total count in this Ancillary data table
+ IN UINT32 Ovrd; ///< Ancillary data table address point to ANC_DATA_PARAM[]
+} ANC_DATA;
+
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific PHY parameter
+ UINT16 ParamValue; ///< This specifies the value to be assigned to indicated PHY parameter
+} DXIO_PHY_PARAM;
+
+typedef struct {
+ DXIO_PHY_PARAM PhyParam[44]; ///< physical parameter
+} PHY_DATA;
+
+///
+/// PCIe specific data structures
+/// PCIe port misc extended controls
+///
+typedef struct {
+ UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ UINT8 LinkSafeMode : 1; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through DXIO_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertize muximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ UINT8 ChannelType : 3; ///< Channel Type
+ ///< 0 - Channel Type Not Specified
+ ///< - Channel Type Short Trace
+ ///< 2 - Channel Type Long Trace
+ UINT8 TurnOffUnusedLanes : 1; ///< Turn Off Unused Lanes
+ ///< 0 - Turn on
+ ///< 1 - Turn off
+} DXIO_PORT_MISC_CONTROL;
+
+///
+/// The IO APIC Interrupt Mapping Info
+///
+typedef struct {
+ UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< 0 - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< 1 - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< 2 - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< ...
+ ///< 8 - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< 0 - ABCD
+ ///< 1 - BCDA
+ ///< 2 - CDAB
+ ///< 3 - DABC
+ UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< 0 - Entry 0 of IO APIC redirection table
+ ///< 1 - Entry 1 of IO APIC redirection table
+ ///< ...
+ ///< 31 - Entry 31 of IO APIC redirection table
+} DXIO_APIC_DEVICE_INFO;
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ UINT8 PortPresent : 1; ///< Enable PCIe port for initialization.
+ UINT8 Reserved1 : 2; ///< Reserved
+ UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ UINT8 FunctionNumber : 3; ///< Reserved for future use
+ UINT8 LinkSpeedCapability : 3; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ ///< 4 - Gen4
+ ///< 5 - Gen5
+ UINT8 AutoSpdChng : 2; ///< Upstread Auto Speed Change Allowed/
+ ///< 0 - Use default implementation (Disabled for Gen1, Enabled for Gen2/3)
+ ///< 1 - Always Disabled
+ ///< 2 - Always Enabled
+ ///< 3 - Reserved
+ UINT8 EqPreset : 4; ///< Gen3 Equalization Preset */
+ UINT8 LinkAspm : 2; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ UINT8 LinkAspmL1_1 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 LinkAspmL1_2 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 ClkReq : 4; ///< ASPM Reserved Field
+ ///< 0 - NONE
+ ///< 1 - CLKREQ0 signal
+ ///< 2 - CLKREQ1 signal
+ ///< 3 - CLKREQ2 signal
+ ///< 4 - CLKREQ3 signal
+ ///< 5 - CLKREQG signal
+ UINT8 LinkHotplug : 4; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ UINT8 SlotPowerLimit; ///< PCIe slot power limit.
+ UINT8 SlotPowerLimitScale : 2; ///< PCIe slot power limit Scale.
+ ///< 00b = 1.0x
+ ///< 01b = 0.1x
+ ///< 10b = 0.01x
+ ///< 11b = 0.001x
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 Gen4Features : 5; ///< Unused bits
+ ///< BIT0(DLF_Exchange) 1 - Disable, 0 - Enable
+ ///< IT1(DLF_Capability) 1 - Disable, 0 - Enable
+ UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_NUM
+ UINT16 CsLink : 3; ///< Reserved
+ DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ DXIO_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 EsmControl : 1; ///< Enhanced speed mode control
+ UINT8 CcixControl : 1; ///< Ccix/Cxl control
+ UINT8 TxVetting : 1; ///< Tx Vetting
+ UINT8 RxVetting : 1; ///< Rx Vetting
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+ UINT8 NtbHotplug : 1; ///< NTB Hotplug flag
+ ///< 0b = Disabled
+ ///< 1b = Enabled
+ UINT8 Reserved2 : 1; ///< Reserved
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 Reserved3 : 5; ///< Reserved
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset
+ UINT8 Reserved4 : 4; ///< Reserved
+ UINT16 PsppPolicyDC; ///< Pspp DC control
+ UINT16 PsppPolicyAC; ///< PSPP AC control
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+ UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass phase2/3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 DXIO deemphasis default
+ UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemphasis setting
+ UINT8 Reserved5 : 3; ///< Reserved
+ struct {
+ UINT16 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT16 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT16 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT16 Reserved1 : 2; ///< Unused bits
+ UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downstream Tx Preset
+ UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downstream Rx Preset Hint
+ UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstream Tx Preset
+ UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstream Rx Preset Hint
+ UINT8 Reserved2 : 4; ///< Unused bits
+ } LaneEqualizationCntl; ///< Lane equalization control structure used for Gen3 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen4LaneEqualizationCntl; ///< Lane equalization control structure used for Gen4 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen5LaneEqualizationCntl; ///< Lane equalization control structure used for Gen5 values
+ struct {
+ UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT.
+ UINT32 PresetMask16Gt : 10; ///< Preset Mask 16GT.
+ UINT32 PresetMask32Gt : 10; ///< Preset Mask 32GT.
+ UINT32 Reserved1 : 2; ///< Unused bits
+ UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT Set
+ UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16GT Set
+ UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32GT Set
+ UINT8 Reserved2 : 5; ///< Unused bits
+ } PresetMaskCntl; ///< Preset Mask control structure used for Gen3/Gen4/Gen5 values
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equalization
+ UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equalization
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enable 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 IsBmcLocation : 1; ///< IsBmcLocation
+ UINT8 SetEsmControl : 1; ///< Set ESM Control
+ UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump for ESM
+ UINT8 Reserved6 : 1; ///< Unused bits
+ UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 Reserved7 : 1; ///< Unused bits
+ UINT16 NpemEnable : 12; ///< Controls NPEM Enable
+ UINT16 Reserved8 : 4; ///< Unused bits
+ UINT16 NpemCapability : 12; ///< Controls NPEM Capability
+ UINT8 SwingMode : 3; ///< PCIe Swing Mode
+ UINT16 Reserved9 : 1; ///< Unused bits
+ UINT16 MpioAncDataIdx; ///< Reserved for internal use only
+ UINT8 Reserved10; ///< Reserved bits
+} DXIO_PORT_DATA;
+
+///
+/// EtherNet specific data structures
+///
+typedef struct {
+ UINT32 PortNum : 8; ///< Port Number
+ UINT32 PlatConf : 4; ///< Platform Config
+ ///< 0 = Reserved
+ ///< 1 = 10G/1G BackPlane
+ ///< 2 = 2.5G BackPlane
+ ///< 3= Soldered down 1000Base-T
+ ///< 4 = Soldered down 1000Base-X
+ ///< 5 = Soldered down NBase-T
+ ///< 6 = Soldered down 10GBase-T
+ ///< 7 = Soldered down 10GBase-r
+ ///< 8 = SFP+ Connector
+ UINT32 Reserved1 : 4; ///< Unused 12-15
+ UINT32 MdioId : 5; ///< MDIO ID when MDIO Side band is used
+ UINT32 Reserved2 : 2; ///< Unused 21-22
+ UINT32 SuppSpeed : 4; ///< Supported Speeds by Platform
+ ///< 1 = 100M Supported
+ ///< 2 = 1G Supported
+ ///< 4 = 2.5G Supported
+ ///< 8 = 10G Supported
+ UINT32 Reserved3 : 1; ///< Unused 27
+ UINT32 ConnType : 3; ///< Supported Speeds by Platform
+ ///< 0 = Port not Used
+ ///< 1 = SFP+ Connection I2C interface
+ ///< 2 = MDIO PHY
+ ///< 4 = Backplane Connection
+ UINT32 Reserved4 : 1; ///< Unused 31
+} ETH_PORT_PROPERTY0;
+
+typedef struct {
+ UINT32 MdioReset : 2; ///< MDIO Reset Type
+ ///< 0 = None
+ ///< 1 = I2C GPIO
+ ///< 2 = Integrated GPIO
+ ///< 3 = Reserved
+ UINT32 Reserved1 : 2; ///< Unused 2-3
+ UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO number for reset
+ UINT32 Reserved2 : 2; ///< Unused 6-7
+ UINT32 SfpGpioAdd : 3; ///< Lower I2C address of GPIO Expander PCA9535
+ UINT32 Reserved3 : 1; ///< Unused 11
+ UINT32 TxFault : 4; ///< TX FAULT
+ UINT32 Rs : 4; ///< RS Signal
+ UINT32 ModAbs : 4; ///< MOD_ABS signal
+ UINT32 RxLoss : 4; ///< Rx_LOS signal
+ UINT32 SfpGpioMask : 4; ///< SFP+ sideband signals that are not supported by platform
+} ETH_PORT_PROPERTY3;
+
+typedef struct {
+ UINT32 SfpMux : 3; ///< Lower address of Mux PCA 9545
+ UINT32 Reserved1 : 1; ///< Unused 3
+ UINT32 SfpBusSeg : 3; ///< SFP BUS Segment. Downstream channels of PCA9545
+ UINT32 Reserved2 : 1; ///< Unused 7
+ UINT32 SfpMuxUpAdd : 5; ///< Upper address of Mux PCA 9545
+ UINT32 Reserved3 : 3; ///< Unused 13-15
+ UINT32 RedriverAddress : 7; ///< Address of ReDriver
+ UINT32 RedriverInterface : 1; ///< ReDriver Interface Descriptor
+ UINT32 RedriverLane : 3; ///< ReDriver Lane number
+ UINT32 Reserved4 : 1; ///< Unused 27
+ UINT32 RedriverModel : 3; ///< ReDriver Model
+ UINT32 RedriverPresent : 1; ///< Redriver Present
+} ETH_PORT_PROPERTY4;
+
+typedef struct {
+ UINT32 TxEqPre : 6; ///< TX EQ PRE
+ UINT32 Reserved1 : 2; ///< Unused 7-6
+ UINT32 TxEqMain : 6; ///< TX EQ MAIN
+ UINT32 Reserved2 : 2; ///< Unused 15-14
+ UINT32 TxEqPost : 6; ///< TX EQ POST
+ UINT32 Reserved3 : 10; ///< Unused 31-23
+} ETH_PORT_TXEQ;
+/// Ethernet PCIe port configuration data
+///
+typedef struct {
+ ETH_PORT_PROPERTY0 EthPortProp0; ///< XGBE_PORT_PROPERTY_0
+ ETH_PORT_PROPERTY3 EthPortProp3; ///< XGBE_PORT_PROPERTY_3
+ ETH_PORT_PROPERTY4 EthPortProp4; ///< XGBE_PORT_PROPERTY_4
+ UINT32 PadMux0; ///< PadMux0 Setting (8 bits)
+ UINT32 PadMux1; ///< PadMux1 Setting (8 bits)
+ UINT32 MacAddressLo; ///< Lower 32 bits of MAC Address
+ UINT32 MacAddressHi; ///< Upper 32 bits of MAC Address
+ ETH_PORT_TXEQ EthPortTxEq; ///< TX EQ Settings
+} ETHERNET_PORT_DATA;
+
+///
+/// High level data structures for passing topology from platform to AGESA
+///
+typedef struct {
+ UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ UINT8 HotPluggable : 1; ///< HotPluggable
+ ///< 0 - Link is NOT Hot-Switchable
+ ///< 1 - Link IS Hot-Switchable
+ UINT8 Reserved1 : 7; ///< Unused field, leave as 0
+ UINT8 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 GpioGroupId; ///< Unique identifier for the GPIO or GPIO group associated with
+ ///< this engine. GPIOs are used for hotplug notification and link
+ ///< type (e.g SATA Express or PCIe)
+ UINT8 DxioStartLane; ///< Internal coding of start lane
+ UINT8 DxioEndLane; ///< Internal coding of end lane
+ UINT8 SearchDepth; ///< SearchDepth only uses 1 bit - always initialize to 0 will be updated dynamically
+} DXIO_ENGINE_DATA;
+
+///
+/// PCIe port descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in complex
+ DXIO_ENGINE_DATA EngineData; ///< Engine data
+ DXIO_PORT_DATA Port; ///< PCIe port specific configuration info
+ ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for EtherNet
+ PHY_DATA Phy; ///< Ancillary data for PHY programming customization
+ PORT_PARAMS PortParams; ///< Extensible port parameter list for simplified topology structure
+ ANC_DATA AncData; ///< Ancillary data override
+} DXIO_PORT_DESCRIPTOR;
+
+#pragma pack(pop)
+
+///
+///
+/// PCIe Complex descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR *PciePortList; ///< Pointer to array of PCIe port descriptors or NULL (Last element of array must be terminated with DESCRIPTOR_TERMINATE_LIST).
+ VOID *Reserved2; ///< Reserved for future use
+ UINT8 BmcLinkLocation; ///< Identifies the socket/die location of a BMC link (Used by AGESA, input not required)
+ UINT8 BmcLinkLaneNum; ///< Identifies the socket/die location of a BMC Lane number
+ UINT8 Reserved3[2]; ///< Reserved for future
+} DXIO_COMPLEX_DESCRIPTOR;
+
+///
+/// Engine descriptor type
+///
+typedef enum {
+ DxioUnusedEngine = 0, ///< Unused descriptor Excluded from configuration
+ DxioPcieEngine = 1, ///< PCIe port
+ DxioUSBEngine = 2, ///< USB port
+ ///< __Deprecated__
+ DxioSATAEngine = 3, ///< SATA
+ DxioUSB_OVER_PCIE = 4, ///< USB4 PCIe (internal use only)
+ DxioUBMHFCEngine = 5, ///< New for Genoa UBM HFC Connector for auto-discovery
+ DxioOCP3Engine = 6, ///< New for Genoa OCP3 Bifurcatable Connector
+ DxioUdot3Engine = 7, ///< New for Genoa U.3 Multiprotocol Connector
+ DxioDPEngine = 8, ///< Digital Display __For APU display connector list__
+ DxioEthernetEngine = 0x10, ///< Ethernet (GBe, XGBe)
+ ///< __Deprecated__
+ DxioGOPEngine = 0x20, ///< GOP
+ ///< __Deprecated__
+ DxioNTBDevice = 0x60, ///< For NBIF NTB Enable (internal use only)
+ DxioHDaudioEngine, ///< For NBIF HDaudtio Enable (internal use only)
+ DxioACPEngine, ///< For NBIF ACP Enable (internal use only)
+ DxioMP2Engine, ///< For NBIF MP2 Enable (internal use only)
+ DxioMaxPcieEngine ///< Max engine type for boundary check.
+} DXIO_ENGINE_TYPE;
+
+///
+/// PCIe link speeds
+///
+typedef enum {
+ DxioGenMaxSupported, ///< Maximum supported
+ DxioGen1 = 1, ///< Gen1
+ DxioGen2, ///< Gen2
+ DxioGen3, ///< Gen3
+ DxioGen4, ///< Gen4
+ DxioGen5, ///< Gen5
+ MaxDxioGen ///< Max Gen for boundary check
+} DXIO_LINK_SPEEDS;
+#endif // AMD_PCIE_COMPLEX_H_
diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
new file mode 100644
index 0000000000..d62f260235
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
@@ -0,0 +1,17 @@
+/** @file
+
+ Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_SOC_H_
+#define _AMD_SOC_H_
+
+#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
+#endif // _AMD_SOC_H_
diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
new file mode 100644
index 0000000000..2291f7dc83
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
@@ -0,0 +1,42 @@
+/** @file
+ Fabric resource manager common definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_CMN_H_
+#define FABRIC_RESOURCE_MANAGER_CMN_H_
+#pragma pack (push, 1)
+
+#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets in system.
+#define MAX_RBS_PER_SOCKET 20 ///< Max number of root bridges per socket.
+
+/**
+ * @brief DF address aperture structure.
+ * @details This contains information used to define an MMIO region.
+ */
+typedef struct _FABRIC_ADDR_APERTURE {
+ UINT64 Base; ///< Aperture base Address.
+ UINT64 Size; ///< Aperture size.
+ UINT64 Alignment; ///< Alignment bit map. 0xFFFFF means 1MB align.
+} FABRIC_ADDR_APERTURE;
+
+/**
+ * @brief DF Resource for each RootBridge structure.
+ * @details This contains information used to define the MMIO region for each RootBridge.
+ */
+typedef struct _FABRIC_RESOURCE_FOR_EACH_RB {
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second nonprefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second prefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE IO[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< IO resource(s) @see FABRIC_ADDR_APERTURE
+ UINT16 PciBusNumber[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< PCI bus number(s).
+} FABRIC_RESOURCE_FOR_EACH_RB;
+#pragma pack (pop)
+#endif // FABRIC_RESOURCE_MANAGER_CMN_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
new file mode 100644
index 0000000000..9e58f299b4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
@@ -0,0 +1,96 @@
+/** @file
+ AMD Memory Info Hob Definition
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_MEMORY_INFO_HOB_H_
+#define AMD_MEMORY_INFO_HOB_H_
+
+/**
+ * @brief 128 bit Buffer containing UID Unique Identifier value for Memory Info HOB.
+ * EFI_GUID defined in UefiBaseType.h
+ */
+extern EFI_GUID gAmdMemoryInfoHobGuid;
+
+#pragma pack (push, 1)
+
+/**
+ * @brief Memory descriptor structure for each memory range
+ */
+typedef struct {
+ UINT64 Base; ///< Base address of memory rang
+ UINT64 Size; ///< Size of memory rang
+ UINT32 Attribute; ///< Attribute of memory rang
+ UINT32 Reserved; ///< For alignment purpose
+} AMD_MEMORY_RANGE_DESCRIPTOR;
+
+/**
+ * @brief Memory attribute in the memory range descriptor = AVAILABLE
+ */
+#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1
+
+/**
+ * @brief Memory attribute in the memory range descriptor = UMA
+ */
+#define AMD_MEMORY_ATTRIBUTE_UMA 0x2
+
+/**
+ * @brief Memory attribute in the memory range descriptor = MMIO
+ */
+#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPUMEM
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_SP
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED_TMR
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED_SMUFEATURES
+ */
+#define AMD_MEMORY_ATTRIBUTE_Reserved_SmuFeatures 0x9
+
+/// Memory info HOB structure
+typedef struct {
+ UINT32 Version; ///< Version of HOB structure
+ BOOLEAN AmdMemoryVddioValid; ///< This field determines if Vddio is valid
+ UINT16 AmdMemoryVddio; ///< Vddio Voltage
+ BOOLEAN AmdMemoryVddpVddrValid; ///< This field determines if VddpVddr is valid
+ UINT8 AmdMemoryVddpVddr; ///< VddpVddr voltage
+ BOOLEAN AmdMemoryFrequencyValid; ///< Memory Frequency Valid
+ UINT32 AmdMemoryFrequency; ///< Memory Frquency
+ UINT32 AmdMemoryDdrMaxRate; ///< Memory DdrMaxRate
+ UINT32 NumberOfDescriptor; ///< Number of memory range descriptor
+ AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory ranges array
+} AMD_MEMORY_INFO_HOB;
+
+#pragma pack (pop)
+
+/**
+ * @brief Macro that defines the Memory Info HOB version
+ */
+#define AMD_MEMORY_INFO_HOB_VERISION 0x00000110ul // Ver: 00.00.01.10
+
+#endif // AMD_MEMORY_INFO_HOB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
new file mode 100644
index 0000000000..d144a4ad20
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
@@ -0,0 +1,51 @@
+/** @file
+ AMD Psp Base Lib
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_BASELIB_V2_H_
+#define AMD_PSP_BASELIB_V2_H_
+
+#include <AmdPspDirectory.h>
+
+#define MAX_IMAGE_SLOT_COUNT 32
+
+#define ALIGNMENT_4K BASE_4KB
+#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1)) == 0)
+#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K)
+
+#define IS_VALID_ADDR32(addr) (((UINT32)(addr) != 0) && (UINT32)(addr) != 0xFFFFFFFF)
+
+#pragma pack (push, 1)
+
+#define FIRMWARE_TABLE_SIGNATURE 0x55AA55AAul
+
+/// Define the structure OEM signature table
+typedef struct _FIRMWARE_ENTRY_TABLEV2 {
+ UINT32 Signature; ///< 0x00 Signature should be 0x55AA55AAul
+ UINT32 ImcRomBase; ///< 0x04 Base Address for Imc Firmware
+ UINT32 GecRomBase; ///< 0x08 Base Address for Gmc Firmware
+ UINT32 XHCRomBase; ///< 0x0C Base Address for XHCI Firmware
+ UINT32 LegacyPspDirBase; ///< 0x10 Base Address of PSP directory
+ UINT32 PspDirBase; ///< 0x14 Base Address for PSP directory
+ UINT32 Reserved1; ///< 0x18 Base Address for Reserved BIOS directory
+ UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS directory
+ UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS directory
+ UINT32 Config; ///< 0x24 reserved for EFS Configuration
+ UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all program
+ UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for all programs
+} FIRMWARE_ENTRY_TABLEV2;
+
+/// It also used as structure to store ISH generic information across programs
+typedef struct {
+ UINT32 Priority;
+ UINT32 UpdateRetries;
+ UINT32 GlitchRetries;
+ UINT32 ImageSlotAddr;
+} IMAGE_SLOT_HEADER;
+
+#pragma pack (pop)
+
+#endif // AMD_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
new file mode 100644
index 0000000000..23c90b65c2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
@@ -0,0 +1,83 @@
+/** @file
+ AMD Psp Ftpm Library header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_LIB_H_
+#define PSP_FTPM_LIB_H_
+#include <IndustryStandard/Acpi30.h>
+
+/* SYSTEM_TPM_CONFIG_VAL
+ * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG
+ */
+typedef enum {
+ SYSTEM_TPM_CONFIG_DTPM = 0x00, ///< dTPM
+ SYSTEM_TPM_CONFIG_PSP_FTPM = 0x01, ///< PSP FTPM
+ SYSTEM_TPM_CONFIG_HSP_FTPM = 0x02, ///< HSP FTPM
+ SYSTEM_TPM_CONFIG_NONE = 0xFF, ///< None of TPM
+} SYSTEM_TPM_CONFIG_VAL;
+
+#pragma pack (push, 1)
+/// Define TPM_2_CONTROL_AREA
+typedef struct {
+ // Interface Identifier
+ volatile UINT64 InterfaceIdentifier; ///< Interface Identifier
+ // TPM2 Control Area Extension
+ volatile UINT32 Clear; ///< Clear
+ volatile UINT32 RemainingBytes; ///< RemainingBytes
+ volatile UINT32 StatusReserved; ///< StatusReserved
+ volatile UINT32 StatusError; ///< StatusError
+ volatile UINT32 StatusCancel; ///< StatusCancel
+ volatile UINT32 StatusStart; ///< StatusStart
+ UINT64 InterruptControl; ///< InterruptControl
+ UINT32 CommandSize; ///< CommandSize
+ EFI_PHYSICAL_ADDRESS CommandAddress; ///< CommandAddress
+ UINT32 ResponseSize; ///< ResponseSize
+ EFI_PHYSICAL_ADDRESS ResponseAddress; ///< ResponseAddress
+ // Memory Absent command/response buffer
+ volatile UINT32 CmdRespHWBuffer; ///< Cmd/Rsp HW Buffer
+} TPM2_CONTROL_AREA;
+
+#pragma pack (pop)
+
+/**
+ GET TPM related Info
+
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+EFI_STATUS
+FtpmGetInfo (
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Execute a TPM command
+
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+EFI_STATUS
+FtpmExecuteCommand (
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+#endif //PSP_FTPM_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
new file mode 100644
index 0000000000..4ad4020f95
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
@@ -0,0 +1,231 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PSP_ROM_ARMOR_LIB_H_
+#define _PSP_ROM_ARMOR_LIB_H_
+
+#include "Uefi.h"
+
+#define PSP_MAX_SPI_CMD_SUPPORT (4) ///< Max number of SPI command support
+#define PSP_MAX_SPI_DATA_BUFFER_SIZE (72) ///< Max SPI Command Data Buffer Size
+#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list allowed command array number support
+#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list allowed region array number support
+
+#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chip selects
+#define SPI_CHIP_SELECT_1 (1) ///< Chip Select 1
+#define SPI_CHIP_SELECT_2 (2) ///< Chip Select 2
+
+#define SPI_COMMAND_FREQUENCY_66_66MHZ (0) ///< 0=66.66MHz
+#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=33.33MHz
+#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=22.22MHz
+#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=16.66MHz
+#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=100MHz
+#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=800KHz
+
+#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 = Command not examined/processed
+#define SPI_COMMAND_COMPLETED (1) ///< 1 = Command completed successfully
+#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 = Execution Error (i.e. timeout)
+#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 = Command not allowed by Whitelist
+#define SPI_COMMAND_MALFORMED (4) ///< 4 = Command malformed
+
+#pragma pack (push, 1)
+
+typedef struct {
+ UINT8 ChipSelect; ///< 1 = CS1, 2 = CS2, all other values illegal
+
+ UINT8 Frequency; ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Does not include the
+ ///< SPI Opcode byte, but does include the address, dummy bytes, and
+ ///< data.
+
+ UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx + BytesToRx <= 72
+
+ UINT8 OpCode; ///< The SPI Command OpCode (the first byte sent by the SPI controller)
+
+ UINT8 Reserved[3]; ///< Reserved for future expansion
+
+ UINT8 Buffer[PSP_MAX_SPI_DATA_BUFFER_SIZE]; ///< The remaining 0-72 bytes sent/received by the SPI controller.
+ ///<
+ ///< The SPI Controller will
+ ///< 1. Assert the ChipSelect
+ ///< 2. Send the one byte OpCode
+ ///< 3. Send Buffer[0] to Buffer[BytesToTx-1] to the SPI device
+ ///< 4. Read BytesToRx bytes from the device into Buffer[BytesToTx] to
+ ///< Buffer[BytesToTx+BytesToRx-1]
+ ///< 5. Deassert the ChipSelect line
+ ///<
+ ///< SPI ROM Commands that include a target address send the address
+ ///< immediately after the OpCode (i.e. Buffer[0..2] or Buffer[0..3]
+ ///< depending if 24 or 32bit addresses are associated with the OpCode).
+ ///< See the SPI ROM Device's datasheet for full details on your
+ ///< devices commands and formats.
+} SPI_COMMAND; ///< The struct of Spi Command
+
+typedef union {
+ struct {
+ ///< SPI_COMMUNICATION_RESULT
+ UINT16 Command0Result : 4; ///< Result[ 3: 0] The result of Command[0]
+ UINT16 Command1Result : 4; ///< Result[ 7: 4] The result of Command[1]
+ UINT16 Command2Result : 4; ///< Result[11: 8] The result of Command[2]
+ UINT16 Command3Result : 4; ///< Result[15:12] The result of Command[3]
+ } Field; ///< the struct type of Command0 ~ Command4
+ UINT16 Value; ///< 16 bit value of Command0 ~ Command4
+} SPI_COMMUNICATION_RESULT; ///< The union struct type of Spi Communication Result
+
+typedef struct {
+ UINT8 ReadyToRun; ///< Set to FALSE by x86 while the buffer is being constructed. Set to
+ ///< TRUE by x86 as the last step in building the communication buffer,
+ ///< just before x86 rings the PSP doorbell.
+ ///<
+ ///< Set to FALSE by PSP after the PSP copies the buffer from DRAM to
+ ///< private SRAM.
+
+ UINT8 CommandCount; ///< Number of commands to execute, Valid Values 1-4
+
+ SPI_COMMUNICATION_RESULT SpiCommunicationResult; ///< Set to zero by x86 when the buffer is built. Atomically set to a
+ ///< non-zero value by the PSP to indicate the PSP has finished
+ ///< processing the requests in the communication buffer. The specific
+ ///< value written by the PSP provides per command results
+ ///<
+ ///< Result values with special meaning:
+ ///< 0x0000 = (written by x86) PSP has not finished handling the request
+ ///< 0x1000 = PSP determined the request is malformed (invalid
+ ///< CommandCount, chipselect, BytesToRx/Tx, etc)
+ ///< 0x2000, 0x3000, 0x4000, ... , 0xF000 = Reserved for future errors
+ ///<
+ ///< Generic Result values:
+ ///< SpiCommunicationResult[ 3: 0] The result of Command[0]
+ ///< SpiCommunicationResult[ 7: 4] The result of Command[1]
+ ///< SpiCommunicationResult[11: 8] The result of Command[2]
+ ///< SpiCommunicationResult[15:12] The result of Command[3]
+ ///< 0 = Command not examined/processed
+ ///< 1 = Command completed successfully
+ ///< 2 = Execution Error (i.e. timeout)
+ ///< 3 = Command not allowed by Whitelist
+ ///< 4 = Command malformed
+ ///< 5-15 = reserved for future use
+ ///<
+ ///< Examples of Generic Results:
+ ///< 0x0000 - PSP has not finished the request
+ ///< 0x0001 - PSP ran Command0 successfully, and is now idle
+ ///< 0x0111 - PSP ran Command0/1/2 successfully and is now idle
+ ///< 0x0031 - PSP ran Command0, but Command1 was blocked by whitelist
+
+ SPI_COMMAND SpiCommand[PSP_MAX_SPI_CMD_SUPPORT]; ///< Spi command array
+} SPI_COMMUNICATION_BUFFER; ///< The struct type of Spi Communication Buffer
+
+typedef struct {
+ UINT8 ChipSelect; ///< 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+
+ UINT8 Frequency; ///< The allowed frequency for the command
+ ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 OpCode; ///< The allowed commands opcode
+
+ UINT8 MinTx; ///< The minimum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+ UINT8 MaxTx; ///< The maximum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+
+ UINT8 MinRx; ///< The minimum range of allowed Rx byte counts
+ UINT8 MaxRx; ///< The maximum range of allowed Rx byte counts
+
+ UINT8 AddrChkMethod; ///< 0=No address verification performed
+ ///< 1=Treat Buffer[0-2] as a 24-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+ ///< 2=Treat Buffer[0-3] as a 32-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+
+ UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned power of two sized block
+ ///< of addresses that may be impacted by a given SPI Command. For
+ ///< example, a sector erase command targeted at an address within a
+ ///< 64K block will impact every byte within that 64K block. Likewise
+ ///< a page program SPI command (i.e. write) may impact many bytes
+ ///< within the targeted 256/512 byte page due to page wrap-around, but
+ ///< no bytes outside the page. The ImapctSize field specifies the power
+ ///< of two size of the ImpactZone for this command. If VerifyAddress is
+ ///< zero (no checking) this field must also be zero, otherwise this
+ ///< field must be a power of two between 256 and 64MB (256, 512, ...,
+ ///< 67108864). NOTE: When setting this field, carefully examine your
+ ///< device's datasheet.
+ ///<
+} WHITE_LIST_ALLOWED_COMMAND; ///< The struct type of White List Allowed Command
+
+typedef struct {
+ // 8 bytes
+ UINT32 StartAddress; ///< LSB must be 0x00, bit31 identifies a chipselect: 0=CS1, 1=CS2
+ UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be less than EndAddress
+} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed Region
+
+typedef struct {
+ UINT8 AllowedCmdCount; ///< Allow Command Count
+ UINT8 AllowedRegionCount; ///< Allow Region Count
+ WHITE_LIST_ALLOWED_COMMAND WhitelistAllowedCommands[PSP_MAX_WHITE_LIST_CMD_NUM]; ///< White List Allowed Command Table
+ WHITE_LIST_ALLOWED_REGION WhitelistAllowedRegions[PSP_MAX_WHITE_LIST_REGION_NUM]; ///< White List Allowed Region Table
+} SPI_WHITE_LIST; ///< The struct type of Spi White List
+
+#pragma pack (pop)
+
+/**
+ * @brief Request secures the SPI Controller
+ *
+ * @param[in,out] SpiCommunicationBuffer Spi Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN OUT SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ );
+
+/**
+ * @brief Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI white list structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ );
+
+/**
+ * @brief Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ );
+
+/**
+ * @brief Request PSP firmware switch SPI controller chip select.
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ );
+
+#endif //_PSP_ROM_ARMOR_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
new file mode 100644
index 0000000000..0189910bd1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
@@ -0,0 +1,2722 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AML_LIB_H_
+#define AML_LIB_H_
+
+#include <Uefi.h>
+#include <IndustryStandard/Acpi.h>
+
+typedef enum {
+ AmlStart,
+ AmlClose,
+ AmlInvalid
+} AML_FUNCTION_PHASE;
+
+#define AML_OBJECT_INSTANCE_SIGNATURE SIGNATURE_32 ('a', 'm', 'l', 'o')
+
+//
+// Device Status Bitmap (Section 6.3.7 ACPI version 6.3)
+// Bit [0] - Set if the device is present.
+// Bit [1] - Set if the device is enabled and decoding its resources.
+// Bit [2] - Set if the device should be shown in the UI.
+// Bit [3] - Set if the device is functioning properly (cleared if device
+// failed its diagnostics).
+// Bit [4] - Set if the battery is present.
+// Bits [31:5] - Reserved (must be cleared).
+//
+#define DEVICE_PRESENT_BIT 0x0001
+#define DEVICE_ENABLED_BIT 0x0002
+#define DEVICE_IN_UI_BIT 0x0004
+#define DEVICE_HEALTH_BIT 0x0008
+#define DEVICE_BATTERY_BIT 0x0010 // Control Method Battery Device Only
+
+typedef enum {
+ UnknownObj,
+ IntObj,
+ StrObj,
+ BuffObj,
+ PkgObj,
+ FieldUnitObj,
+ DeviceObj,
+ EventObj,
+ MethodObj,
+ MutexObj,
+ OpRegionObj,
+ PowerResObj,
+ ProcessorObj,
+ ThermalZoneObj,
+ BuffFieldObj,
+ DDBHandlObj,
+ InvalidObj
+} OBJECT_TYPE_KEYWORD;
+
+typedef struct {
+ UINT32 Signature;
+ BOOLEAN Completed;
+ UINTN DataSize;
+ UINT8 *Data;
+ LIST_ENTRY Link;
+} AML_OBJECT_INSTANCE;
+
+// ***************************************************************************
+// AML defines to be consistent with already existing
+// MdePkg/Include/IndustryStandard/Acpi*.h defines.
+// *** These could be upstreamed at some point.
+// ***************************************************************************
+// Limits of (DWord|Word|QWord)Space ResourceType
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MIN 0xC0
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MAX 0xFF
+
+// General Flags: Flags that are common to all resource types
+// Bits[7:4] Reserved(must be 0)
+// Bit[3] Max Address Fixed, _MAF:
+// 1 The specified maximum address is fixed
+// 0 The specified maximum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED (1 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED (0 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MAF EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+// Bit[2] Min Address Fixed, _MIF:
+// 1 The specified minimum address is fixed
+// 0 The specified minimum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED (1 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED (0 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MIF EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+// Bit[1] Decode Type, _DEC:
+// 1 This bridge subtractively decodes this address(top level bridges only)
+// 0 This bridge positively decodes this address
+#define EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE (1 << 1)
+#define EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE (0 << 1)
+#define EFI_ACPI_GENERAL_FLAG_MASK_DEC EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+// Bit[0] Consumer / Producer:
+// 1 This device consumes this resource
+// 0 This device produces and consumes this resource
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER (1 << 0)
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER (0 << 0)
+#define EFI_ACPI_GENERAL_FLAG_MASK_USAGE EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+
+// Memory Resource Flag (Resource Type = 0) DefinitionsBits
+// Memory Resource Flag Masks
+// Bits[7:6] Reserved(must be 0)
+// Bit[5] Memory to I/O Translation, _TTP:
+// 0 TypeStatic
+// 1 Type Translation
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_TTP (1 << 5)
+// Bit[4:3] Memory Attributes, _MTP:
+// 0 AddressRangeMemory
+// 1 AddressRangeReserved
+// 2 AddressRangeACPI
+// 3 AddressRangeNVS
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MTP (3 << 3)
+// Bit[2:1] Memory Attributes, _MEM:
+// 0 The memory is non-cacheable
+// 1 The memory is cacheable
+// 2 The memory is cacheable and supports write-combining
+// 3 The memory is cacheable and prefetchable
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM (3 << 1)
+// Bit[0] Write Status, _RW:
+// 0 This memory range is read-only
+// 1 This memory is read-write
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW (1 << 0)
+
+// I/O Resource Flag (Resource Type = 1) DefinitionsBits
+// I/O Resource Flags
+// Bit [7:6] Reserved (must be 0)
+// Bit [5] Sparse Translation, _TRS. This bit is only meaningful if Bit [4] is set.
+// 1 SparseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = (((port & 0xFFFc) << 10) || (port & 0xFFF)) + _TRA In the address
+// used to access the I/O port, bits[11:2] must be identical to bits[21:12],
+// this gives four bytes of I/O ports on each 4 KB page.
+// 0 DenseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = port + _TRA
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_SPARSE_TRANSLATION (1 << 5)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_DENSE_TRANSLATION (0 << 5)
+// Bit [4] I/O to Memory Translation, _TTP
+// 1 TypeTranslation: This resource, which is I/O on the secondary side of the
+// bridge, is memory on the primary side of the bridge.
+// 0 TypeStatic: This resource, which is I/O on the secondary side of the
+// bridge, is also I/O on the primary side of the bridge.
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION (1 << 4)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC (0 << 4)
+// Bit [3:2] Reserved (must be 0)
+// Bit [1:0] _RNG
+// 3 Memory window covers the entire range
+// 2 ISARangesOnly. This flag is for bridges on systems with multiple bridges.
+// Setting this bit means the memory window specified in this descriptor is
+// limited to the ISA I/O addresses that fall within the specified window. The
+// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. This bit can
+// only be set for bridges entirely configured throughACPI namespace.
+// 1 NonISARangesOnly. This flag is for bridges on systems with multiple
+// bridges. Setting this bit means the memory window specified in this
+// descriptor is limited to the non-ISA I/O addresses that fall within the
+// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7FF,
+// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entirely
+// configured through ACPI namespace.
+// 0 Reserved
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE (3 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY (2 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY (1 << 0)
+
+#define AML_OBJECT_INSTANCE_FROM_LINK(a) BASE_CR (a, AML_OBJECT_INSTANCE, Link)
+
+// Method Serialize Flag Values
+typedef enum {
+ NotSerialized,
+ Serialized,
+ FlagInvalid
+} METHOD_SERIALIZE_FLAG;
+// AccessField Access Attrib Flags.
+// Ref ACPI spec 6.3
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL 0x00
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK 0x02
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE 0x04
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE 0x06
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD 0x08
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK 0x0A
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES 0x0B
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL 0x0C
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL 0x0D
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES 0x0E
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES 0X0F
+
+// AccessField access types
+typedef enum {
+ AnyAcc,
+ ByteAcc,
+ WordAcc,
+ DWordAcc,
+ QWordAcc,
+ BufferAcc,
+} EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS;
+
+// Field lock rules
+typedef enum {
+ NoLock,
+ Lock
+} EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS;
+
+// Field update rules
+typedef enum {
+ Preserve,
+ WriteAsOnes,
+ WriteAsZeros
+} EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS;
+
+// Field access attributes. for AttribBytes, AttribRawBytes and AttribRawProcessBytes
+// the ExtendedAccessField definition is used, as this is what iASL compiles into, rather
+// than the AccessField that is specified in the ACPI spec.
+typedef enum {
+ AttribNormal = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL,
+ AttribQuick = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK,
+ AttribSendReceive = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE,
+ AttribByte = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE,
+ AttribWord = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD,
+ AttribBlock = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK,
+ AttribBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES,
+ AttribProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL,
+ AttribBlockProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL,
+ AttribRawBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES,
+ AttribRawProcessBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
+} EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS;
+
+//
+// Resource Type Specific Flags
+// Ref ACPI specification 6.4.3.5.5
+//
+//
+// DMA Information
+// Ref ACPI specification 6.4.2.2
+//
+// DmaType values
+typedef enum {
+ Compatibility = EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY,
+ TypeA = EFI_ACPI_DMA_SPEED_TYPE_A,
+ TypeB = EFI_ACPI_DMA_SPEED_TYPE_B,
+ TypeF = EFI_ACPI_DMA_SPEED_TYPE_F
+} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS;
+
+// IsBusMaster values
+typedef enum {
+ NotBusMaster = 0,
+ BusMaster = EFI_ACPI_DMA_BUS_MASTER
+} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS;
+
+// DmaTransferSize values
+typedef enum {
+ Transfer8 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT,
+ Transfer8_16 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT,
+ Transfer16 = EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT
+} EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS;
+
+//
+// Interrupt Resource Descriptor Information
+// Ref ACPI specification 6.4.2.1
+//
+// IRQ Information - Wake Capability
+//
+#define EFI_ACPI_IRQ_WAKE_CAPABLE_MASK 0x20
+#define EFI_ACPI_IRQ_NOT_WAKE_CAPABLE 0x0
+#define EFI_ACPI_IRQ_WAKE_CAPABLE 0x20
+
+typedef enum {
+ NotWakeCapable = EFI_ACPI_IRQ_NOT_WAKE_CAPABLE,
+ WakeCapable = EFI_ACPI_IRQ_WAKE_CAPABLE
+} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Sharing
+//
+#define EFI_ACPI_IRQ_EXCLUSIVE 0x0
+
+typedef enum {
+ Exclusive = EFI_ACPI_IRQ_EXCLUSIVE,
+ Shared = EFI_ACPI_IRQ_SHARABLE,
+ ExclusiveAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_EXCLUSIVE,
+ SharedAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_SHARABLE
+} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Polarity
+//
+typedef enum {
+ ActiveHigh = EFI_ACPI_IRQ_HIGH_TRUE,
+ ActiveLow = EFI_ACPI_IRQ_LOW_FALSE
+} EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Mode
+//
+#define EFI_ACPI_IRQ_MODE_MASK 0x1
+typedef enum {
+ LevelTriggered = EFI_ACPI_IRQ_LEVEL_TRIGGERED,
+ EdgeTriggered = EFI_ACPI_IRQ_EDGE_TRIGGERED
+} EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS;
+
+// IO Port Descriptor Information
+// Ref ACPI specification 6.4.2.5
+//
+typedef enum {
+ Decode16 = EFI_ACPI_IO_DECODE_16_BIT,
+ Decode10 = EFI_ACPI_IO_DECODE_10_BIT
+} EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION;
+
+//
+// Memory Resource Information
+// Ref ACPI specification 6.4.3.5
+//
+// Consumer/Producer Bit[0]
+typedef enum {
+ ResourceProducer = EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER,
+ ResourceConsumer = EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+} RESOURCE_USAGE_FLAG;
+
+// Decode Type (_DEC) Bit[1]
+typedef enum {
+ PosDecode = EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE,
+ SubDecode = EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+} MEM_DECODE_FLAG;
+
+// Min Address Fixed (_MIF) Bit[2]
+typedef enum {
+ MinNotFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED,
+ MinFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+} MIN_FIXED_FLAG;
+
+// Max Address Fixed (_MAF) Bit[3]
+typedef enum {
+ MaxNotFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED,
+ MaxFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+} MAX_FIXED_FLAG;
+
+// Memory Attributes (_MEM) Bits[2:1]
+typedef enum {
+ NonCacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE,
+ Cacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE,
+ WriteCombining = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING,
+ Prefetchable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+} CACHEABLE_FLAG;
+
+// Write Status (_RW) Bit[0]
+typedef enum {
+ ReadOnly = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY,
+ ReadWrite = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE
+} READ_WRITE_FLAG;
+
+// Memory Attributes (_MTP) Bits[4:3]
+typedef enum {
+ AddressRangeMemory = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY,
+ AddressRangeReserved = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED,
+ AddressRangeACPI = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI,
+ AddressRangeNVS = EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS
+} MEMORY_RANGE_TYPE;
+
+// Memory to IO Translation (_TTP) Bit[5]
+// Note: IO and Memory Resources use different bits for this.
+// Value must be handled at function level when implemented.
+typedef enum {
+ TypeStatic = 0,
+ TypeTranslation = 1
+} MEMORY_TRANSLATION_TYPE;
+
+// Memory Window Attributes (_RNG) Bits[1:0]
+typedef enum {
+ Reserved = 0,
+ NonISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY,
+ ISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY,
+ EntireRange = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE,
+ ISARangeMax
+} IO_ISA_RANGES;
+
+// Generic Address Space Address IDs
+typedef enum {
+ SystemMemory = EFI_ACPI_6_4_SYSTEM_MEMORY,
+ SystemIO = EFI_ACPI_6_4_SYSTEM_IO,
+ PCI_Config = EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE,
+ EmbeddedControl = EFI_ACPI_6_4_EMBEDDED_CONTROLLER,
+ SMBus = EFI_ACPI_6_4_SMBUS,
+ SystemCMOS = EFI_ACPI_6_4_SYSTEM_CMOS,
+ PciBarTarget = EFI_ACPI_6_4_PCI_BAR_TARGET,
+ IPMI = EFI_ACPI_6_4_IPMI,
+ GeneralPurposeIO = EFI_ACPI_6_4_GENERAL_PURPOSE_IO,
+ GenericSerialBus = EFI_ACPI_6_4_GENERIC_SERIAL_BUS,
+ PCC = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ PlatformCommChannel = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ FFixedHW = EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE
+} GENERIC_ADDRESS_SPACE_ID;
+
+typedef enum {
+ UndefinedSize = EFI_ACPI_6_4_UNDEFINED,
+ ByteSize = EFI_ACPI_6_4_BYTE,
+ WordSize = EFI_ACPI_6_4_WORD,
+ DWordSize = EFI_ACPI_6_4_DWORD,
+ QWordSize = EFI_ACPI_6_4_QWORD
+} ACPI_DATA_SIZE;
+
+typedef ACPI_DATA_SIZE GENERIC_ADDRESS_ACCESS_SIZE;
+
+// ***************************************************************************
+// AML Objects
+// ***************************************************************************
+
+// ---------------------------------------------------------------------------
+// Table and Table Header Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Name Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Namestring AML Object and inserts it into the linked list
+
+ Completes NameString in one call as "one phase"
+ LeadNameChar := 'A'-'Z' | '_'
+ DigitChar := '0'-'9'
+ NameChar := DigitChar | LeadNameChar
+ RootChar := '\'
+ ParentPrefixChar := '^'
+
+ 'A'-'Z' := 0x41 - 0x5A
+ '_' := 0x5F
+ '0'-'9' := 0x30 - 0x39
+ '\' := 0x5C
+ '^' := 0x5E
+
+ NameSeg := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Data Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates an optimized integer object
+
+ 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] Phase - Example: AmlStart, AmlClose
+ @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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a data string object
+
+ ComputationalData := String
+
+ String := StringPrefix AsciiCharList NullChar
+ StringPrefix := 0x0D
+ AsciiCharList := Nothing | <AsciiChar AsciiCharList>
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Package Length Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Package Length AML Object and inserts it into the linked list
+
+ PkgLength := PkgLeadByte |
+ <PkgLeadByte ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Term Objects Encoding
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Namespace Modifier Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ Creates a Name (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := NameOp NameString DataRefObject
+ NameOp := 0x08
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Named Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Field
+
+ Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be created 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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.
+
+ 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 that has completed AccessAs Object
+ after AmlClose.
+
+ @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
+ );
+
+/**
+ 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 since AML does not store
+ ArgTypes here.
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Type 1 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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 pkglength termlist>
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlReturn (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+// ---------------------------------------------------------------------------
+// Type 2 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 PackageElementList>
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] NumElements - Number of elements in the package
+ @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
+ );
+
+// ---------------------------------------------------------------------------
+// Resource Descriptor Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlDWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/*
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlQWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Expression Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Miscellaneous Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Shift Left expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Reult) => 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Assistance Functions
+// ***************************************************************************
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Debug Functions
+// ***************************************************************************
+
+/**
+ 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Buffer - Buffer containing buffer
+ @param[in] BufferSize - Number of bytes to print
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintBuffer (
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ );
+
+/**
+ DEBUG print a 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Object - AML_OBJECT_INSTANCE
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintObject (
+ IN AML_OBJECT_INSTANCE *Object
+ );
+
+/**
+ 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
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintLinkedObjects (
+ IN LIST_ENTRY *ListHead
+ );
+
+#endif // AML_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
new file mode 100644
index 0000000000..d48ca1a90a
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
@@ -0,0 +1,25 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AmdPspRomArmorLib.h>
+
+/*
+ * 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 couldn't be allocated
+ */
+EFI_STATUS
+EFIAPI
+GetPspRomArmorWhitelist (
+ IN SPI_WHITE_LIST **PlatformSpiWhitelist
+ );
diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
new file mode 100644
index 0000000000..6c854651cc
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
@@ -0,0 +1,134 @@
+/** @file
+ AMD Psp Ftpm Ppi Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_PPI_H_
+#define PSP_FTPM_PPI_H_
+#include <Uefi.h>
+
+typedef struct _PSP_FTPM_PPI PSP_FTPM_PPI;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Info
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+ **/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs.
+
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @retval EFI_STATUS 0: Success, Non-Zero Error
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ PSP_FTPM_PPI prototype
+
+ Defines PSP_FTPM_PPI. This PPI is used to get Ftpm info.
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PPI {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+} PSP_FTPM_PPI;
+
+extern EFI_GUID gAmdPspFtpmPpiGuid;
+extern EFI_GUID gAmdPspFtpmFactoryResetPpiGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
new file mode 100644
index 0000000000..715cbbcf78
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
@@ -0,0 +1,183 @@
+/** @file
+ CXL Configuration Services Protocol prototype definition
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_
+#define NBIO_CXL_SERVICES_PROTOCOL_H_
+
+#include "AMD.h"
+#include <Protocol/FabricTopologyServices2.h>
+#include <Protocol/FabricResourceManagerServicesProtocol.h>
+
+#define AMD_NBIO_CXL_SERVICES_REVISION 0x00
+
+/// Forward declaration for the AMD_NBIO_CXL_SERVICES_PROTOCOL
+typedef struct _AMD_NBIO_CXL_SERVICES_PROTOCOL AMD_NBIO_CXL_SERVICES_PROTOCOL;
+
+extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL services protocol calling
+
+#pragma pack (push, 1)
+/// Port Information Structure
+typedef struct _AMD_CXL_PORT_INFO_STRUCT {
+ PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root Port in PCI_ADDR format
+ UINT8 LogicalNbioInstance; ///< Logical Instance ID of NBIO
+ UINT8 PhysicalNbioInstance; ///< Physical Instance ID of NBIO where this port is located
+ UINT8 SocketID; ///< Socket ID for this port
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT8 PortId; ///< Physical port location
+ UINT8 PortWidth; ///< Lane width of the port
+ UINT32 CxlPortAddress; ///< CXL root port address (CXL 2.0 root port or CXL 1.1 RCiEP)
+ BOOLEAN IsSwitch; ///< CXL Switch flag
+} AMD_CXL_PORT_INFO_STRUCT;
+
+/// Port MMIO32 Resources Information Structure
+typedef struct _AMD_CXL_RESOURCES_INFO_STRUCT {
+ UINT32 Mmio32Base[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Size[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Gran;
+} AMD_CXL_RESOURCES_INFO_STRUCT;
+#pragma pack (pop)
+
+// Protocol Definitions
+
+/**
+ This function gets information about a specific PCIe root port.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortInformation
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_ROOT_PORT_INFORMATION)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr
+ IN UINTN PortIndex, ///< port index
+ OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port information ptr
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL capabilities.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port.
+ PortInformation OPTIONAL (can be NULL)
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_CONFIGURE_ROOT_PORT)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< this ptr
+ IN PCI_ADDR EndpointBDF ///< end pt bdf
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL presence
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port such as Socket id,rbindex,port id,segment,bus base,limit or presence.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_AVAILABLE)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT FABRIC_RESOURCE_FOR_EACH_RB *ResourceForEachRb ///<
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_PORT_RB_LOCATION)(
+ ///< get port rb location
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN UINT8 Segment, ///<
+ IN UINT8 BusBase, ///<
+ OUT UINT8 *SocketId, ///<
+ OUT UINT8 *RbIndex ///<
+ );
+
+/**
+ This function gets the CXL MMIO32 values to be used by the fabric resource manager
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ CxlMmio32ResourceForEachRb
+ A pointer to the structure that will hold the MMIO32 base and size values for each root bridge
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_INFORMATION)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT AMD_CXL_RESOURCES_INFO_STRUCT *CxlMmio32Resources ///<
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_REPORT_TO_MPIO)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This ///< ptr to protocol
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_FIND_2P0_DEVICES)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN UINTN PortIndex ///< port index
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+VOID
+(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN PCI_ADDR CxlPciAddress ///< PCI address
+ );
+
+/// The Protocol Definition for CXL Services
+struct _AMD_NBIO_CXL_SERVICES_PROTOCOL {
+ UINT32 Revision; ///< revision
+ UINTN CxlCount; ///< CXL count
+ AMD_CXL_GET_ROOT_PORT_INFORMATION CxlGetRootPortInformation; ///< CXL root port information
+ AMD_CXL_CONFIGURE_ROOT_PORT CxlConfigureRootPort; ///< configuring the root port
+ AMD_CXL_GET_PORT_RB_LOCATION GetCxlPortRBLocation; ///< CXL port RB location
+ AMD_CXL_RESOURCES_AVAILABLE GetCxlAvailableResources; ///< Get resources allocated for CXL RCiEP
+ AMD_CXL_RESOURCES_INFORMATION GetCxlMmio32Resources; ///< Get CXL MMIO resources for CXL RCiEP
+ AMD_CXL_REPORT_TO_MPIO CxlReportToMpio; ///< Sends the CXL info to MPIO
+ AMD_CXL_FIND_2P0_DEVICES CxlFind2p0Devices; ///< Finds CXL 2.0 devices after PCIe enumeration
+ AMD_CXL_ENABLE_SCM_PMEM CxlEnableScmForPersistentMemory; ///< Notifies SMU that CXL persistent memory is present
+};
+
+#endif /* NBIO_CXL_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
new file mode 100644
index 0000000000..7bcff65dc9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
@@ -0,0 +1,110 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCI_RESOURCES_PROTOCOL_H_
+#define AMD_PCI_RESOURCES_PROTOCOL_H_
+
+typedef struct {
+ UINTN Index;
+ UINT8 SocketId;
+ UINTN Segment;
+ UINTN BaseBusNumber;
+} PCI_ROOT_BRIDGE_OBJECT;
+
+typedef struct {
+ UINTN Index;
+ BOOLEAN Enabled;
+ UINT8 PortPresent;
+ UINTN Device;
+ UINTN Function;
+ UINTN SlotNum;
+ // Interrupts are relative to IOAPIC 0->n
+ UINTN BridgeInterrupt; // Redirection table entry for mapped bridge interrupt
+ UINTN EndpointInterruptArray[4]; // Redirection table entries for mapped INT A/B/C/D
+} PCI_ROOT_PORT_OBJECT;
+
+typedef enum {
+ IOMMU = 0,
+ IOAPIC
+} FIXED_RESOURCE_TYPE;
+
+typedef struct {
+ UINTN Index;
+ FIXED_RESOURCE_TYPE ResourceType;
+ UINTN Address;
+ UINTN Limit;
+} FIXED_RESOURCES_OBJECT;
+
+/// Forward declaration for the AMD_PCI_RESOURCES_PROTOCOL.
+typedef struct _AMD_PCI_RESOURCES_PROTOCOL AMD_PCI_RESOURCES_PROTOCOL;
+
+/**
+ * @brief System information through EFI call
+ * @details
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ OUT UINTN *NumberOfRootBridges
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT PCI_ROOT_BRIDGE_OBJECT **RootBridgeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfRootPorts
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN RootPortIndex,
+ OUT PCI_ROOT_PORT_OBJECT **RootPortInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfFixedResources
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN FixedResourceIndex,
+ OUT FIXED_RESOURCES_OBJECT **FixedResourceInfo
+ );
+
+struct _AMD_PCI_RESOURCES_PROTOCOL {
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES AmdPciResourcesGetNumberOfRootBridges;
+ AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO AmdPciResourcesGetRootBridgeInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS AmdPciResourcesGetNumberOfRootPorts;
+ AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO AmdPciResourcesGetRootPortInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES AmdPciResourcesGetNumberOfFixedResources;
+ AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO AmdPciResourcesGetFixedResourceInfo;
+};
+
+extern EFI_GUID gAmdPciResourceProtocolGuid; ///< Guid for calling
+
+#endif // AMD_PCI_RESOURCES_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
new file mode 100644
index 0000000000..ebc7812b18
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
@@ -0,0 +1,187 @@
+/** @file
+ AMD Psp Ftpm Protocol Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FTPM_PROTOCOL_H_
+#define FTPM_PROTOCOL_H_
+
+#include <Uefi.h>
+//
+// GUID definition
+//
+extern EFI_GUID gAmdPspFtpmProtocolGuid;
+
+/**
+ structure definition for HSP mailbox
+
+**/
+typedef struct {
+ // C2H_TPM_L0
+ UINT64 TPM_L0_Address; /// Mailbox address
+ UINT64 TPM_L0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L0(VLT0)
+ UINT64 VLT0_Address; /// Mailbox address
+ UINT64 VLT0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L1(VLT1)
+ UINT64 VLT1_Address; /// Mailbox address
+ UINT64 VLT1_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT1_HSC_MSG_Address; /// Doorbell address HSP->CPU
+
+ // Interrupt Information
+ UINT8 Gsi[4]; /// Gsi[0] is for HSP Channel 0 TPM
+ /// Gsi[1] is for HSP Channel 1 VTL0
+ /// Gsi[2] is for HSP Channel 2 VTL1
+ /// Gsi[3] is reserved
+} HSP_MAILBOX_ADDRESS, *PHSP_MAILBOX_ADDRESS;
+
+typedef union {
+ HSP_MAILBOX_ADDRESS HSP_info;
+} FTPM_INFO;
+
+typedef struct _PSP_FTPM_PROTOCOL PSP_FTPM_PROTOCOL;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Information
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Function prototype for GetHspfTPMInfo. Return Pluton mailbox base address to SBIOS.
+ SBIOS should call this procedure after PCI Enumeration Complete.
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmInfo Point to Pluton mailbox base address
+
+ @return EFI_SUCCESS - Success
+ @return EFI_INVALID_PARAMETER - Input parameter is invalid
+ @return EFI_NOT_READY - Pluton-fTPM device BAR0 MMIO is not ready.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TPM_INFO)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *FtpmInfo
+ );
+
+/**
+ PSP_FTPM_PROTOCOL prototype
+
+ Defines PSP_FTPM_PROTOCOL. This protocol is used to get Ftpm info
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PROTOCOL {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+ FTPM_GET_TPM_INFO GetInfo; ///< Get TPM info
+} PSP_FTPM_PROTOCOL;
+
+#endif //FTPM_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
new file mode 100644
index 0000000000..7f57facf88
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+ Fabric MMIO map manager Protocol prototype definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#include <FabricResourceManagerCmn.h>
+
+#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
new file mode 100644
index 0000000000..a7fef5a35c
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
@@ -0,0 +1,19 @@
+/** @file
+ AMD CPM Base Definitions.
+
+ Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_BASE_H_
+#define AMD_CPM_BASE_H_
+
+#include <Base.h>
+#include <Uefi.h>
+#include <PiPei.h>
+#include <AmdCpmCommon.h>
+#include <Library/DebugLib.h>
+
+#endif // AMD_CPM_BASE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
new file mode 100644
index 0000000000..af192fcf03
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
@@ -0,0 +1,78 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_COMMON_H_
+#define AMD_CPM_COMMON_H_
+
+#pragma pack(push)
+
+#include <AGESA.h>
+#include <AmdPcieComplex.h>
+#include <AmdCpmDefine.h>
+#include <AmdCpmFunction.h>
+
+/// The signatures of CPM table
+
+typedef enum {
+ CPM_SIGNATURE_DXIO_TOPOLOGY = SIGNATURE_32 ('$', 'A', '2', '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE
+ CPM_SIGNATURE_DXIO_TOPOLOGY_S1 = SIGNATURE_32 ('$', 'A', '2', '7') ///< The signature of Socket 1 AMD_CPM_DXIO_TOPOLOGY_TABLE
+} AMD_CPM_TABLE_SIGNATURE;
+
+/// CPM table header
+typedef struct {
+ UINT32 TableSignature; ///< Signature of CPM table
+ UINT16 TableSize; ///< Table size
+ UINT8 FormatRevision; ///< Revision of table format
+ UINT8 ContentRevision; ///< Revision of table content
+ UINT32 PlatformMask; ///< The mask of platform table supports
+ UINT32 Attribute; ///< Table attribute
+} AMD_CPM_TABLE_COMMON_HEADER;
+
+/// Table pointer
+typedef union {
+ VOID *Pointer; ///< Table pointer
+ UINT64 Raw; ///< Table pointer value
+} AMD_CPM_POINTER;
+
+/// DXIO Topology Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR Port[AMD_DXIO_PORT_DESCRIPTOR_SIZE]; ///< DXIO Port Descriptor List
+} AMD_CPM_DXIO_TOPOLOGY_TABLE;
+
+/// AMD CPM Main Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT8 PlatformName[32]; ///< Platform name
+ UINT8 BiosType; ///< BIOS type
+ UINT16 CurrentPlatformId; ///< Current Platform Id
+ UINT32 PcieMemIoBaseAddr; ///< PcieMemIoBaseAddr
+ UINT32 AcpiMemIoBaseAddr; ///< AcpiMemIoBaseAddr
+ AMD_CPM_POINTER Service; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRomList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRamList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInHobList; ///< Reserved for internal use
+ AMD_CPM_POINTER HobTablePtr; ///< Reserved for internal use
+
+ UINT8 ExtClkGen; ///< External ClkGen Config. 0x00~0x7F
+ UINT8 UnusedGppClkOffEn; ///< Config to turn off unused GPP clock
+ UINT8 LpcUartEn; ///< LpcUartEn
+ UINT64 AltAcpiMemIoBaseAddr; ///< Alternate AcpiMemIoBaseAddr for Slave FCH
+} AMD_CPM_MAIN_TABLE;
+
+/// Structure for Chip Id
+typedef struct {
+ UINT8 Cpu; ///< CPU/APU Chip Id
+ UINT8 Sb; ///< SB Chip Id
+ UINT8 Reserved[6];
+} AMD_CPM_CHIP_ID;
+#pragma pack (pop)
+
+#endif //AMD_CPM_COMMON_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
new file mode 100644
index 0000000000..4fc3f97a80
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
@@ -0,0 +1,17 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_DEFINE_H_
+#define AMD_CPM_DEFINE_H_
+
+#ifndef AMD_DXIO_PORT_DESCRIPTOR_SIZE
+#define AMD_DXIO_PORT_DESCRIPTOR_SIZE 0x30
+#endif
+
+#endif // AMD_CPM_DEFINE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
new file mode 100644
index 0000000000..7dce238135
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
@@ -0,0 +1,32 @@
+/** @file
+ AMD CPM Common Functions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_FUNCTION_H_
+#define AMD_CPM_FUNCTION_H_
+
+typedef VOID *(EFIAPI *AMD_CPM_GETTABLEPTR_FN)(
+ IN VOID *This,
+ IN UINT32 TableId
+ );
+
+typedef AGESA_STATUS (EFIAPI *AMD_CPM_GETPOSTEDVBIOSIMAGE_FN)(
+ IN GFX_VBIOS_IMAGE_INFO *VbiosImageInfo
+ );
+
+/// Common Functions for CPM Drivers
+typedef struct _AMD_CPM_COMMON_FUNCTION {
+ AMD_CPM_GETTABLEPTR_FN GetTablePtr2; ///< Get CPM Table Pointer. The table can be re-writable
+} AMD_CPM_COMMON_FUNCTION;
+
+/// CPM Public Functions for platform DXE Driver to use
+typedef struct _AMD_CPM_DXE_PUBLIC_FUNCTION {
+ AMD_CPM_GETPOSTEDVBIOSIMAGE_FN GetPostedVbiosImage; ///< Get posted VBIOS image
+} AMD_CPM_DXE_PUBLIC_FUNCTION;
+
+#endif //AMD_CPM_FUNCTION_H_
diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
new file mode 100644
index 0000000000..4a90aa3d8b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
@@ -0,0 +1,39 @@
+/** @file
+ AMD CPM Table Protocol.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_TABLE_PROTOCOL_H_
+#define AMD_CPM_TABLE_PROTOCOL_H_
+
+#include <AmdCpmBase.h>
+
+//
+// GUID definition
+//
+#define AMD_CPM_TABLE_PROTOCOL_GUID \
+ { 0x3724cf01, 0x00c2, 0x9762, 0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }
+
+#define AMD_CPM_TABLE_SMM_PROTOCOL_GUID \
+ { 0xaf6efacf, 0x7a13, 0x45a3, 0xb1, 0xa5, 0xaa, 0xfc, 0x06, 0x1c, 0x4b, 0x79 }
+
+extern EFI_GUID gAmdCpmTableProtocolGuid;
+extern EFI_GUID gAmdCpmTableSmmProtocolGuid;
+
+/// DXE Protocol Structure
+typedef struct _AMD_CPM_TABLE_PROTOCOL {
+ UINTN Revision; ///< Protocol Revision
+ AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Pointer to CPM Main Table
+ AMD_CPM_CHIP_ID ChipId; ///< Id of SB Chip
+ AMD_CPM_COMMON_FUNCTION CommonFunction; ///< Private Common Functions
+ AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///< Public Function of Protocol
+} AMD_CPM_TABLE_PROTOCOL;
+
+// Current Protocol Revision
+#define AMD_CPM_TABLE_PROTOCOL_REV 0x00
+
+#endif // AMD_CPM_TABLE_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
new file mode 100644
index 0000000000..fa83888e95
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
@@ -0,0 +1,31 @@
+/** @file
+ PSP Mailbox related functions
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
new file mode 100644
index 0000000000..0e9baad955
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
new file mode 100644
index 0000000000..a04bc1f992
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
@@ -0,0 +1,79 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/AmdPspRomArmorLib.h>
+
+/**
+ * Request secures the SPI Controller
+ *
+ * @param[in, out] SpiCommunicationBuffer SPI Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI White List structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @param[in] NONE
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request PSP firmware switch SPI controller chip select.
+ *
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
new file mode 100644
index 0000000000..fce82d75b0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
new file mode 100644
index 0000000000..f8b9eb0bcf
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Base.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
new file mode 100644
index 0000000000..cff678d76b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
@@ -0,0 +1,37 @@
+** @file
+ Fabric Topology Base Lib implementation
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ )
+{
+ return 0;
+}
+
+RETURN_STATUS
+EFIAPI
+BaseFabricTopologyLibConstructor (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
new file mode 100644
index 0000000000..f72cbe7dff
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
@@ -0,0 +1,8 @@
+/** @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.<BR>
+
+ 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
new file mode 100644
index 0000000000..a155978a5d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
@@ -0,0 +1,35 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+
+/** The constructor function determines the actual TSC frequency.
+
+ First, Get TSC frequency from system configuration table with TSC frequency GUID,
+ if the table is not found, install it.
+ This function will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeTscTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
new file mode 100644
index 0000000000..f70aa3de0e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
@@ -0,0 +1,11 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/HobLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
new file mode 100644
index 0000000000..7d14d62e60
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
@@ -0,0 +1,103 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/** Stalls the CPU for at least the specified number of MicroSeconds.
+
+ @param[in] MicroSeconds The minimum number of microseconds to delay.
+
+ @return The value of MicroSeconds input.
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ return 0;
+}
+
+/** Stalls the CPU for at least the specified number of NanoSeconds.
+
+ @param[in] NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return The value of NanoSeconds input.
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ return 0;
+}
+
+/** Retrieves the current value of the 64-bit free running Time-Stamp counter.
+
+ The properties of the counter can be retrieved by the
+ GetPerformanceCounterProperties() function.
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return 0;
+}
+
+/** Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
+ that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
+ EndValue.
+
+ The 64-bit frequency of the performance counter, in Hz, is always returned.
+
+ @param[out] StartValue Pointer to where the performance counter's starting value is saved, or NULL.
+ @param[out] EndValue Pointer to where the performance counter's ending value is saved, or NULL.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ OUT UINT64 *StartValue, OPTIONAL
+ OUT UINT64 *EndValue OPTIONAL
+ )
+{
+ return 0;
+}
+
+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ return 0;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
new file mode 100644
index 0000000000..44e23df62f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
@@ -0,0 +1,95 @@
+/** @file
+ AMD instance of the PCI Host Bridge Library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/PciHostBridgeResourceAllocation.h>
+
+/**
+ Sort all root bridges in bus ascending order and set DevicePath UIDs
+ continuous and ascending from zero
+
+ @param[in,out] RootBridgeList Array of root bridges.
+ @param[in] Count Count of root bridges in RootBridgeList
+
+ @return All the root bridge instances in an array are sorted in bus order.
+ DevicePath UID updated to continuous and ascending numbers starting
+ with 0.
+**/
+VOID
+EFIAPI
+PciHostBridgeSortRootBridges (
+ IN PCI_ROOT_BRIDGE *RootBridgeList,
+ IN UINTN Count
+ )
+{
+}
+
+/**
+ Return all the root bridge instances in an array.
+
+ @param Count Return the count of root bridge instances.
+
+ @return All the root bridge instances in an array.
+ The array should be passed into PciHostBridgeFreeRootBridges()
+ when it's not used.
+**/
+PCI_ROOT_BRIDGE *
+EFIAPI
+PciHostBridgeGetRootBridges (
+ UINTN *Count
+ )
+{
+ return (PCI_ROOT_BRIDGE *)NULL;
+}
+
+/**
+ Free the root bridge instances array returned from PciHostBridgeGetRootBridges().
+
+ @param Bridges The root bridge instances array.
+ @param Count The count of the array.
+**/
+VOID
+EFIAPI
+PciHostBridgeFreeRootBridges (
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
+ )
+{
+}
+
+/**
+ Inform the platform that the resource conflict happens.
+
+ @param HostBridgeHandle Handle of the Host Bridge.
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ for all the root bridges. The resource for each root
+ bridge is terminated with END descriptor and an
+ additional END is appended indicating the end of the
+ entire resources. The resource descriptor field
+ values follow the description in
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
+ .SubmitResources().
+**/
+VOID
+EFIAPI
+PciHostBridgeResourceConflict (
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
new file mode 100644
index 0000000000..318f8e5ad7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -0,0 +1,154 @@
+/** @file
+
+ Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE
+
+/*
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ ArgN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
new file mode 100644
index 0000000000..371537c9aa
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -0,0 +1,151 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLASSISTFUNCTIONS_FILECODE
+
+/**
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ListHead = AllocatePool (sizeof (LIST_ENTRY));
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlFreeObjectList (*ListHead);
+ FreePool (*ListHead);
+ *ListHead = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
new file mode 100644
index 0000000000..b7d4f4c9d7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -0,0 +1,640 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE
+
+/*
+ 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__, 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", __func__, "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", __func__, 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 AsciiCharList>
+ 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",
+ __func__,
+ Index,
+ String
+ ));
+ return Status;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, 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",
+ __func__,
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AsciiStrLen (String) != 0x7) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String' parameter.\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
new file mode 100644
index 0000000000..e8ea9d8e84
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -0,0 +1,1294 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECODE
+
+// ----------------------------------------------------------------------------
+// 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __func__));
+ goto Done;
+ }
+
+ // Start BufferSize
+ Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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",
+ __func__,
+ InternalBufferSize
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ InternalBufferSize,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
new file mode 100644
index 0000000000..21deb200e3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLLOCALOBJECTS_FILECODE
+
+/**
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ LocalN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
new file mode 100644
index 0000000000..0502547a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -0,0 +1,576 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESTRING_FILECODE
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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 := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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", __func__, 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",
+ __func__,
+ 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more than 1 RootChar.\n", __func__, String));
+ goto Done;
+ }
+
+ if (FoundParentPrefixChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
new file mode 100644
index 0000000000..37ae9319be
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -0,0 +1,2138 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMEDOBJECT_FILECODE
+
+#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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ InternalOffsetData = *(UINT64 *)OffsetObject->Data;
+
+ if (InternalOffsetData > BitCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataLength);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, BankName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, IndexName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Offset, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Length, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (BitIndex, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NumBits, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+ } else {
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ Status = AmlOPDataInteger (Index, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FixedFieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
new file mode 100644
index 0000000000..afe51cdcf2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -0,0 +1,360 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_FILECODE
+
+/**
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, AliasName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n", __func__));
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
new file mode 100644
index 0000000000..279bfc782d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -0,0 +1,144 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLOBJECTSDEBUG_FILECODE
+
+/**
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
new file mode 100644
index 0000000000..85d184b759
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -0,0 +1,267 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLPKGLENGTH_FILECODE
+
+#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",
+ __func__,
+ 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", __func__));
+ 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 ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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", __func__));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n", __func__));
+ 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", __func__, "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",
+ __func__,
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
new file mode 100644
index 0000000000..4ef746327b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -0,0 +1,1989 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECODE
+
+/**
+ 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", __func__, "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", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n", __func__, 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", __func__, AddressMaximum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressMaximum == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ 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", __func__, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __func__));
+ 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", __func__));
+ 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed = 0\n", __func__));
+ 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n", __func__, 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", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0, IsMinFixed = 1, and IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both be either 1 or 0\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, Shared));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__, "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", __func__, "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", __func__, Decode));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ 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", __func__, AddressMin));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, 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", __func__, AddressMax));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__, 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", __func__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AccessSize > EFI_ACPI_6_4_QWORD) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n", __func__, AccessSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__, ReadAndWrite));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
new file mode 100644
index 0000000000..03201d0109
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -0,0 +1,515 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLSTATEMENTOPCODES_FILECODE
+
+/**
+ 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 pkglength termlist>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NotifyValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
new file mode 100644
index 0000000000..c9a4399764
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -0,0 +1,213 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLTABLE_FILECODE
+
+// 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", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
new file mode 100644
index 0000000000..b1ad9b7037
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -0,0 +1,364 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE
+
+/**
+ 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 <all others> - 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 <all others> - 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 <all others> - 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", __func__));
+ 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 <all others> - 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 <all others> - 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", __func__, 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 <all others> - 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",
+ __func__,
+ 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 <all others> - 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;
+ UINT8 *TempBuffer;
+
+ 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", __func__));
+ 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
+ TempBuffer = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + ChildObject->DataSize,
+ Object->Data
+ );
+ if (TempBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ FreePool (Object->Data);
+ Object->Data = NULL;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __func__));
+ goto Done;
+ }
+
+ Object->Data = TempBuffer;
+ // 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/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
new file mode 100644
index 0000000000..2f4f676adb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
@@ -0,0 +1,13 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include <Filecode.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
new file mode 100644
index 0000000000..60305ee4a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
@@ -0,0 +1,90 @@
+/** @file
+ Library to support reset library, inheritted from Agesa Cf9Reset module.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+/**
+ This function causes a system-wide reset (cold reset), in which
+ all circuitry within the system returns to its initial state. This type of reset
+ is asynchronous to system operation and operates without regard to
+ cycle boundaries.
+
+ If this function returns, it means that the system does not support cold reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a system-wide initialization (warm reset), in which all processors
+ are set to their initial state. Pending cycles are not corrupted.
+
+ If this function returns, it means that the system does not support warm reset.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shutdown reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a systemwide reset. The exact type of the reset is
+ defined by the EFI_GUID that follows the Null-terminated Unicode string passed
+ into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+ the platform must pick a supported reset type to perform.The platform may
+ optionally log the parameters from any non-normal reset that occurs.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData The data buffer starts with a Null-terminated string,
+ followed by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
new file mode 100644
index 0000000000..d10e676668
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
@@ -0,0 +1,87 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Filecode.h>
+#include <Uefi.h>
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] RegAddr Slave register address
+ *
+ * @retval Register Value
+ */
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ )
+{
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to read
+ * @param[in] Length Length in byte to read
+ * @param[in] Buffer Pointer to the data read to
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to write
+ * @param[in] Length Length in byte to write
+ * @param[in] Value Pointer to the data to write
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to erase
+ * @param[in] Length Block Size to erase
+ *
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
new file mode 100755
index 0000000000..9044d3d497
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
@@ -0,0 +1,68 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/NbioHandleLib.h>
+#include <Library/AmdBaseLib.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ )
+{
+ return NULL;
+}
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ )
+{
+ PCI_ADDR PciAddr;
+
+ PciAddr.AddressValue = 0;
+ return PciAddr;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
new file mode 100755
index 0000000000..d5fbe98d22
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
@@ -0,0 +1,276 @@
+/** @file
+ GNB function to create/locate PCIe configuration data area
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/GnbPcieConfigLib.h>
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ )
+{
+ return FALSE;
+}
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ )
+{
+ return 0;
+}
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ )
+{
+}
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+}
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ )
+{
+ return FALSE;
+}
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+ return NULL;
+}
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ )
+{
+}
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ )
+{
+}
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
new file mode 100755
index 0000000000..5c6be22ee4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
@@ -0,0 +1,117 @@
+/** @file
+ Procedure to parse PCIe input configuration data
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <GnbDxio.h>
+
+/**
+ Get number of complexes in platform topology configuration
+
+ @param[in] ComplexList First complex configuration in complex configuration array
+ @retval Number of Complexes
+
+**/
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of PCIe engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfPcieEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of DDI engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfDdiEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of engines in given complex
+
+
+
+ @param[in] Complex Complex configuration header
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] Index Complex descriptor Index
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] SocketId Socket Id
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptorOfSocket (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINT32 SocketId
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Engine descriptor from given complex by index
+
+ @param[in] Complex Complex descriptor
+ @param[in] Index Engine descriptor index
+ @retval Pointer to Engine Descriptor
+**/
+PCIE_ENGINE_DESCRIPTOR *
+PcieInputParserGetEngineDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
new file mode 100644
index 0000000000..e6be32b071
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
@@ -0,0 +1,10 @@
+/** @file
+ SMN Register Access Methods
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/SmnAccessLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
new file mode 100644
index 0000000000..1dc13900c7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
@@ -0,0 +1,42 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/PcieConfigLib.h>
+#include <Library/NbioCommonLibDxe.h>
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
new file mode 100644
index 0000000000..fbd3ddcf37
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
@@ -0,0 +1,23 @@
+/** @file
+ APCB DXE Driver
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+EFI_STATUS
+EFIAPI
+AmdApcbV3DxeDriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
new file mode 100644
index 0000000000..23d1a8fee0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+
+/**
+ * @brief Amd Apcb V3 Pei Driver Entry
+ *
+ * @param[in] FileHandle File Handie
+ * @param[in] PeiServices Pei Services
+ *
+ * @retval EFI_SUCCESS Set APCB value successfully
+ * Non-EFI_SUCCESS Function Error
+ *
+ **/
+EFI_STATUS
+EFIAPI
+AmdApcbV3PeiDriverEntry (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
new file mode 100644
index 0000000000..74b129931b
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
@@ -0,0 +1,39 @@
+/** @file
+ Required OEM hooks for CCX initialization
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ Hook to store the vector that all APs should jump to out of reset to a non-volatile,
+ shared location.
+
+ @param[in] ApInitAddress Address of the code that AP should jump to
+ @param[in,out] ContentToRestore The current value in the non-volatile storage
+
+**/
+VOID
+SaveApInitVector (
+ IN UINT32 ApInitAddress,
+ IN OUT UINT32 *ContentToRestore
+ )
+{
+}
+
+/**
+ Hook to restore the initial content of the non-volatile storage location.
+
+ @param[in] ContentToRestore The value to restore
+
+**/
+VOID
+RestoreContentVector (
+ IN UINT32 ContentToRestore
+ )
+{
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
new file mode 100644
index 0000000000..54ce202cb1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
@@ -0,0 +1,33 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Ppi/PciCfg2.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+
+/**
+ Module's entry function.
+ This routine will install EFI_PEI_PCI_CFG2_PPI.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @return Whether success to install service.
+**/
+EFI_STATUS
+EFIAPI
+PeimInitializePciCfg (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
new file mode 100644
index 0000000000..643174d7b9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/PciSegmentInfoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+
+/**
+ Return an array of PCI_SEGMENT_INFO holding the segment information.
+
+ Note: The returned array/buffer is owned by callee.
+
+ @param Count Return the count of segments.
+
+ @retval A callee owned array holding the segment information.
+**/
+PCI_SEGMENT_INFO *
+EFIAPI
+GetPciSegmentInfo (
+ UINTN *Count
+ )
+{
+ return (PCI_SEGMENT_INFO *)NULL;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
new file mode 100644
index 0000000000..d83bb6c2d8
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
@@ -0,0 +1,15 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiSmm.h>
+#include <Register/Cpuid.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/SmmBase2.h>
+#include <Library/IoLib.h>
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
new file mode 100644
index 0000000000..a264eb9294
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
@@ -0,0 +1,12 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
new file mode 100644
index 0000000000..e379538e3a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
@@ -0,0 +1,36 @@
+/** @file
+ OEM OOB PPR DXE Driver.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciIo.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TimerLib.h>
+#include <IndustryStandard/Pci22.h>
+
+/**
+* This function installs a protocol used by platform BIOS to provide the hotplug descriptor.
+*
+* @param[in] ImageHandle Image handler
+* @param[in] SystemTable Pointer to the system table
+*
+* @retval EFI_SUCCESS The thread was successfully launched.
+*
+**/
+EFI_STATUS
+EFIAPI
+OobPprEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
new file mode 100644
index 0000000000..5242e6261a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -0,0 +1,20 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+EFI_STATUS
+EFIAPI
+PspPlatformEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
new file mode 100644
index 0000000000..530bd9d4b6
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+EFI_STATUS
+EFIAPI
+HotplugDescEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
new file mode 100644
index 0000000000..fbc372586b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
new file mode 100644
index 0000000000..0a5f4a7e81
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
@@ -0,0 +1,36 @@
+/** @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.<BR>
+
+ 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;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
new file mode 100644
index 0000000000..47eb700f8f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/IoLib.h>
+
+/**
+ Performs platform specific initialization required for the CPU to access
+ the hardware associated with a SerialPortLib instance. This function does
+ not intiailzie the serial port hardware itself. Instead, it initializes
+ hardware devices that are required for the CPU to access the serial port
+ hardware. This function may be called more than once.
+
+ @retval RETURN_SUCCESS The platform specific initialization succeeded.
+ @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
new file mode 100644
index 0000000000..72b9a87639
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
@@ -0,0 +1,9 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
new file mode 100644
index 0000000000..2dfb3190d4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
@@ -0,0 +1,13 @@
+; @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.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+%macro AMD_ENABLE_UEFI_STACK2 2-3
+
+%endmacro
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
index a731c7e369..937caee083 160000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
@@ -1 +1 @@
-Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490
+Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119163): https://edk2.groups.io/g/devel/message/119163
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages Chang, Abner via groups.io
@ 2024-05-23 16:27 ` Michael D Kinney
2024-05-24 2:00 ` Abdul Lateef Attar via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Michael D Kinney @ 2024-05-23 16:27 UTC (permalink / raw)
To: abner.chang@amd.com, devel@edk2.groups.io
Cc: Leif Lindholm, Kinney, Michael D
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> -----Original Message-----
> From: abner.chang@amd.com <abner.chang@amd.com>
> Sent: Wednesday, May 22, 2024 9:12 PM
> To: devel@edk2.groups.io
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries
> for AMD packages
>
> From: Abner Chang <abner.chang@amd.com>
>
> Signed-off-by: Abner Chang <abner.chang@amd.com>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
> Maintainers.txt | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/Maintainers.txt b/Maintainers.txt
> index 877620a1b0..af688c3813 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -86,8 +86,20 @@ M: Leif Lindholm <quic_llindhol@quicinc.com>
> AMD
> F: Platform/AMD
> M: Abner Chang <abner.chang@amd.com>
> -M: Abdul Lateef Attar <abdattar@amd.com>
> +M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> +M: Paul Grimes <paul.grimes@amd.com>
> +
> +F: Platform/AMD/AgesaModulePkg
> +F: Platform/AMD/AgesaPkg
> +F: Platform/AMD/AmdCbsPkg
> +M: Paul Grimes <paul.grimes@amd.com>
> +R: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> +R: Abner Chang <abner.chang@amd.com>
> +
> +F: Platform/AMD/AmdCpmPkg
> +M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> R: Paul Grimes <paul.grimes@amd.com>
> +R: Abner Chang <abner.chang@amd.com>
>
> AMD Seattle
> F: Platform/AMD/OverdriveBoard/
> --
> 2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119166): https://edk2.groups.io/g/devel/message/119166
Mute This Topic: https://groups.io/mt/106257081/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages
2024-05-23 16:27 ` Michael D Kinney
@ 2024-05-24 2:00 ` Abdul Lateef Attar via groups.io
2024-05-24 4:46 ` Paul via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-05-24 2:00 UTC (permalink / raw)
To: devel, michael.d.kinney, abner.chang@amd.com; +Cc: Leif Lindholm
[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]
Reviewed-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
On 23-05-2024 21:57, Michael D Kinney via groups.io wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> Reviewed-by: Michael D Kinney<michael.d.kinney@intel.com>
>
>> -----Original Message-----
>> From:abner.chang@amd.com <abner.chang@amd.com>
>> Sent: Wednesday, May 22, 2024 9:12 PM
>> To:devel@edk2.groups.io
>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>; Kinney, Michael D
>> <michael.d.kinney@intel.com>
>> Subject: [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries
>> for AMD packages
>>
>> From: Abner Chang<abner.chang@amd.com>
>>
>> Signed-off-by: Abner Chang<abner.chang@amd.com>
>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
>> Cc: Michael D Kinney<michael.d.kinney@intel.com>
>> ---
>> Maintainers.txt | 14 +++++++++++++-
>> 1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/Maintainers.txt b/Maintainers.txt
>> index 877620a1b0..af688c3813 100644
>> --- a/Maintainers.txt
>> +++ b/Maintainers.txt
>> @@ -86,8 +86,20 @@ M: Leif Lindholm<quic_llindhol@quicinc.com>
>> AMD
>> F: Platform/AMD
>> M: Abner Chang<abner.chang@amd.com>
>> -M: Abdul Lateef Attar<abdattar@amd.com>
>> +M: Abdul Lateef Attar<AbdulLateef.Attar@amd.com>
>> +M: Paul Grimes<paul.grimes@amd.com>
>> +
>> +F: Platform/AMD/AgesaModulePkg
>> +F: Platform/AMD/AgesaPkg
>> +F: Platform/AMD/AmdCbsPkg
>> +M: Paul Grimes<paul.grimes@amd.com>
>> +R: Abdul Lateef Attar<AbdulLateef.Attar@amd.com>
>> +R: Abner Chang<abner.chang@amd.com>
>> +
>> +F: Platform/AMD/AmdCpmPkg
>> +M: Abdul Lateef Attar<AbdulLateef.Attar@amd.com>
>> R: Paul Grimes<paul.grimes@amd.com>
>> +R: Abner Chang<abner.chang@amd.com>
>>
>> AMD Seattle
>> F: Platform/AMD/OverdriveBoard/
>> --
>> 2.37.1.windows.1
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119171): https://edk2.groups.io/g/devel/message/119171
Mute This Topic: https://groups.io/mt/106257081/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 6367 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
2024-05-23 8:31 ` Yao, Ken via groups.io
@ 2024-05-24 4:39 ` Paul via groups.io
2024-05-24 4:56 ` Abdul Lateef Attar via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Paul via groups.io @ 2024-05-24 4:39 UTC (permalink / raw)
To: Yao, Ken, Zhai, MingXin (Duke), Chang, Abner,
devel@edk2.groups.io
Cc: Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus, Xing, Eric
[-- Attachment #1: Type: text/plain, Size: 761694 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks for the up-stream, Abner.
Looks good to me.
Reviewed-by: Paul Grimes < paul.grimes@amd.com>
________________________________
From: Yao, Ken <Ken.Yao@amd.com>
Sent: Thursday, May 23, 2024 1:31:31 AM
To: Zhai, MingXin (Duke) <duke.zhai@amd.com>; Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Ken Yao <Ken.Yao@amd.com>
-----Original Message-----
From: Zhai, MingXin (Duke) <duke.zhai@amd.com>
Sent: Thursday, May 23, 2024 3:48 PM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
From: Abner Chang <abner.chang@amd.com>
BZ#: 4777
Initial commit of AMD cross platform/board generic
encapsulated software architecture. This provides
the basic definitions and protocols for the follow-up
AMD open board project.
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
.../AgesaModulePkg/AgesaCommonModulePkg.dec | 39 +
Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec | 18 +
.../AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec | 20 +
.../AMD/AgesaModulePkg/AgesaModuleDfPkg.dec | 25 +
.../AMD/AgesaModulePkg/AgesaModuleFchPkg.dec | 62 +
.../AMD/AgesaModulePkg/AgesaModuleMemPkg.dec | 26 +
.../AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec | 34 +
.../AMD/AgesaModulePkg/AgesaModulePspPkg.dec | 29 +
Platform/AMD/AgesaPkg/AgesaPkg.dec | 435 +++
Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec | 41 +
.../AgesaEdk2PlatformPkg.inc.dsc | 18 +
.../AgesaSp5RsModulePkg.inc.dsc | 48 +
.../CbsInstanceNull/CbsInstanceNull.inc.dsc | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.inc.dsc | 11 +
.../AgesaSp5RsModulePkg.dxe.inc.fdf | 11 +
.../AgesaSp5RsModulePkg.pei.inc.fdf | 9 +
.../CbsInstanceNull.dxe.inc.fdf | 7 +
.../CbsInstanceNull.pei.inc.fdf | 7 +
.../0x19/RS/External/CbsStones.dxe.inc.fdf | 8 +
.../0x19/RS/External/CbsStones.pei.inc.fdf | 8 +
.../Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf | 7 +
.../Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf | 10 +
.../Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf | 7 +
.../Library/AmdCalloutLib/AmdCalloutLib.inf | 29 +
.../AmdPspMboxLibV2/AmdPspMboxLibV2.inf | 30 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.inf | 27 +
.../AmdPspRomArmorLibNull.inf | 26 +
.../Library/ApcbLibV3/ApcbLibV3.inf | 37 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.inf | 32 +
.../BaseFabricTopologyRsLib.inf | 28 +
.../CcxTscTimerLib/BaseTscTimerLib.inf | 35 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.inf | 42 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.inf | 37 +
.../PciHostBridgeLib.inf | 42 +
.../DxeAmlGenerationLib/AmlGenerationLib.inf | 47 +
.../Library/FchBaseLib/FchBaseLib.inf | 26 +
.../FchBaseResetSystemLib.inf | 35 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.inf | 33 +
.../Library/NbioHandleLib/NbioHandleLib.inf | 24 +
.../Library/PcieConfigLib/PcieConfigLib.inf | 25 +
.../Library/SmnAccessLib/SmnAccessLib.inf | 33 +
.../Library/CommonDxe/NbioCommonDxeLib.inf | 29 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf | 45 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf | 33 +
.../OemAgesaCcxPlatformLibNull.inf | 27 +
.../PciExpressPciCfg2/PciExpressPciCfg2.inf | 61 +
.../PciExpressPciSegmentInfoLib.inf | 32 +
.../AmdPspFlashAccSpiNorLibSmm.inf | 45 +
.../PspRomArmorWhitelistLib.inf | 32 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.inf | 42 +
.../Dxe/PspPlatformDriver/PspPlatform.inf | 32 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.inf | 29 +
.../AmdAutoDynamicCommand.inf | 53 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.inf | 50 +
.../BasePlatformHookLibAmdFchUart.inf | 33 +
Platform/AMD/AgesaModulePkg/Include/AGESA.h | 158 +
Platform/AMD/AgesaModulePkg/Include/AMD.h | 91 +
.../Include/AmdEdk2/CpuRegisters.h | 15 +
.../AgesaModulePkg/Include/AmdPspDirectory.h | 61 +
.../AgesaModulePkg/Include/CpuRegistersDef.h | 156 +
.../Include/FchRegistersCommon.h | 85 +
.../AMD/AgesaModulePkg/Include/Filecode.h | 31 +
Platform/AMD/AgesaModulePkg/Include/Gnb.h | 14 +
Platform/AMD/AgesaModulePkg/Include/GnbDxio.h | 521 ++++
.../AgesaModulePkg/Include/GnbRegistersRS.h | 18 +
.../Include/GnbRegistersRS/IOHC.h | 22 +
.../Include/Guid/GnbPcieInfoHob.h | 31 +
.../Include/Library/AmdBaseLib.h | 16 +
.../Include/Library/AmdPspMboxLibV2.h | 43 +
.../Include/Library/BaseFabricTopologyLib.h | 22 +
.../Include/Library/FchBaseLib.h | 16 +
.../Include/Library/FchEspiCmdLib.h | 413 +++
.../Include/Library/GnbPcieConfigLib.h | 16 +
.../Include/Library/NbioCommonLibDxe.h | 37 +
.../Include/Library/NbioHandleLib.h | 62 +
.../Include/Library/PcieConfigLib.h | 283 ++
.../Include/Library/SmnAccessLib.h | 30 +
.../Protocol/AmdNbioPcieServicesProtocol.h | 47 +
.../Include/Protocol/AmdOemOobPprProtocol.h | 14 +
.../Include/Protocol/FabricNumaServices2.h | 155 +
.../Protocol/FabricTopologyServices2.h | 14 +
.../AMD/AgesaModulePkg/Include/SocLogicalId.h | 23 +
.../Library/DxeAmlGenerationLib/LocalAmlLib.h | 100 +
.../DxeAmlGenerationLib/LocalAmlObjects.h | 150 +
.../AMD/AgesaPkg/Include/AmdPcieComplex.h | 432 +++
Platform/AMD/AgesaPkg/Include/AmdSoc.h | 17 +
.../Include/FabricResourceManagerCmn.h | 42 +
.../AgesaPkg/Include/Guid/AmdMemoryInfoHob.h | 96 +
.../Include/Library/AmdPspBaseLibV2.h | 51 +
.../AgesaPkg/Include/Library/AmdPspFtpmLib.h | 83 +
.../Include/Library/AmdPspRomArmorLib.h | 231 ++
.../Include/Library/AmlGenerationLib.h | 2722 +++++++++++++++++
.../Library/PlatformPspRomArmorWhitelistLib.h | 25 +
.../AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h | 134 +
.../Include/Protocol/AmdCxlServicesProtocol.h | 183 ++
.../Protocol/AmdPciResourcesProtocol.h | 110 +
.../Include/Protocol/AmdPspFtpmProtocol.h | 187 ++
.../FabricResourceManagerServicesProtocol.h | 14 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h | 19 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h | 78 +
Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h | 17 +
.../AMD/AmdCpmPkg/Include/AmdCpmFunction.h | 32 +
.../AmdCpmTableProtocol/AmdCpmTableProtocol.h | 39 +
.../Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c | 31 +
.../AmdPspRomArmorLib/AmdPspRomArmorLib.c | 12 +
.../AmdPspRomArmorLibNull.c | 79 +
.../Library/ApcbLibV3/ApcbLibV3.c | 12 +
.../Library/ApcbLibV3Pei/ApcbLibV3Pei.c | 14 +
.../BaseFabricTopologyRsLib.c | 37 +
.../Library/CcxTscTimerLib/BaseTscTimerLib.c | 8 +
.../Library/CcxTscTimerLib/DxeTscTimerLib.c | 35 +
.../Library/CcxTscTimerLib/PeiTscTimerLib.c | 11 +
.../Library/CcxTscTimerLib/TscTimerLibShare.c | 103 +
.../DxeAmdPciHostBridgeLib/PciHostBridgeLib.c | 95 +
.../DxeAmlGenerationLib/AmlArgObjects.c | 154 +
.../DxeAmlGenerationLib/AmlAssistFunctions.c | 151 +
.../DxeAmlGenerationLib/AmlDataObjects.c | 640 ++++
.../AmlExpressionOpcodes.c | 1294 ++++++++
.../DxeAmlGenerationLib/AmlLocalObjects.c | 158 +
.../DxeAmlGenerationLib/AmlNameString.c | 576 ++++
.../DxeAmlGenerationLib/AmlNamedObject.c | 2138 +++++++++++++
.../AmlNamespaceModifierObjects.c | 360 +++
.../DxeAmlGenerationLib/AmlObjectsDebug.c | 144 +
.../DxeAmlGenerationLib/AmlPkgLength.c | 267 ++
.../AmlResourceDescriptor.c | 1989 ++++++++++++
.../DxeAmlGenerationLib/AmlStatementOpcodes.c | 515 ++++
.../Library/DxeAmlGenerationLib/AmlTable.c | 213 ++
.../DxeAmlGenerationLib/LocalAmlObjects.c | 364 +++
.../Library/FchBaseLib/FchStallLib.c | 13 +
.../FchBaseResetSystemLib.c | 90 +
.../Library/FchEspiCmdLib/FchEspiCmdLib.c | 87 +
.../Library/NbioHandleLib/NbioHandleLib.c | 68 +
.../Library/PcieConfigLib/PcieConfigLib.c | 276 ++
.../PcieConfigLib/PcieInputParserLib.c | 117 +
.../Library/SmnAccessLib/SmnAccessLib.c | 10 +
.../Nbio/Library/CommonDxe/DxeLibFunctions.c | 42 +
.../Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c | 23 +
.../Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c | 29 +
.../OemAgesaCcxPlatformLibNull.c | 39 +
.../PciExpressPciCfg2/PciExpressPciCfg2.c | 33 +
.../PciSegmentInfoLib.c | 30 +
.../AmdPspFlashAccSpiNorLibSmm.c | 15 +
.../PspRomArmorWhitelistLib.c | 12 +
.../Addendum/Oem/OobPprDxe/OobPprDxe.c | 36 +
.../Dxe/PspPlatformDriver/PspPlatformDriver.c | 20 +
.../Dxe/ServerHotplugDxe/ServerHotplugDxe.c | 22 +
.../AmdAutoDynamicCommand.c | 44 +
.../AmdAutoDynamicCommand/AmdAutoToolApp.c | 36 +
.../BasePlatformHookLibAmdFchUart.c | 29 +
.../FchSongshanDxe/FchSongshanI2C_I3C.asl | 9 +
.../AMD/AgesaPkg/Include/AmdUefiStackNasm.inc | 13 +
.../Library/RiscVOpensbiLib/opensbi | 2 +-
152 files changed, 19669 insertions(+), 1 deletion(-)
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
create mode 100755 Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
create mode 100644 Platform/AMD/AgesaPkg/AgesaPkg.dec
create mode 100755 Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
create mode 100755 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AGESA.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AMD.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Filecode.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Gnb.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
create mode 100755 Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
create mode 100755 Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdSoc.h
create mode 100644 Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
create mode 100644 Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
create mode 100644 Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
create mode 100644 Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
create mode 100644 Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
diff --git a/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
new file mode 100644
index 0000000000..d35a1f27b4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaCommonModulePkg.dec
@@ -0,0 +1,39 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCommonPkg
+ PACKAGE_GUID = 6CBE6566-0D3F-4E35-8358-9602354E9F09
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = {0x7788adf0, 0x9788, 0x4a3f, {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}}
+ gAgesaConfigDbPointerVariableGuid = {0x21229d24, 0xc71d, 0x4bc0, {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}}
+ gAmdMemoryInfoHobGuid = {0x1bce3d14, 0xa5fe, 0x4a0b, {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}}
+
+[Protocols]
+ ## Soc Protocols
+ gAmdSocLogicalIdProtocolGuid = {0x72f8e409, 0x0d2a, 0x4b91, {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}}
+ gAmdOemOobPprDxeProtocolGuid = {0x78031be3, 0x54a2, 0x4819, {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupportedV2|2|UINT8|0x00002002 # 2 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|1|UINT8|0x00002003 # 1 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2|8|UINT8|0x00002004 # 8 by default
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannelV2|2|UINT8|0x00002005 # 2 by default
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UINT64|0x00027003
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
new file mode 100644
index 0000000000..1637068432
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec
@@ -0,0 +1,18 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaEdk2Pkg
+ PACKAGE_GUID = E866104F-D458-41B1-AB26-FA5951618A8C
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/AmdEdk2
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
new file mode 100755
index 0000000000..b84fe5b738
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec
@@ -0,0 +1,20 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaCcxPkg
+ PACKAGE_GUID = df325429-029e-40f0-82db-0e69be7f6560
+ PACKAGE_VERSION = 0.1
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FALSE|BOOLEAN|0x000CC029
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
new file mode 100755
index 0000000000..57db15e663
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec
@@ -0,0 +1,25 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaDfPkg
+ PACKAGE_GUID = 81e51ee3-c347-4563-92fe-790ba953bf0f
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gAmdTotalNumberOfRootBridgesGuid = {0xfb5703f5, 0xf8a7, 0xf401, {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}}
+ gAmdResourceSizeForEachRbGuid = {0x542b8f2f, 0xbd52, 0x4233, {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}}
+
+[Protocols]
+ gAmdFabricNumaServices2ProtocolGuid = {0xa8ff2e64, 0xf319, 0x4af1, {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}}
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
new file mode 100644
index 0000000000..521957e809
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec
@@ -0,0 +1,62 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 1.5
+ PACKAGE_NAME = AgesaFchPkg
+ PACKAGE_GUID = e47c8ed9-3000-4e6e-b1c6-875b365b3849
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid = { 0x7788adf0, 0x9788, 0x4a3f, { 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } }
+
+[Protocols]
+ gFchInitDonePolicyProtocolGuid = { 0xc63c0c73, 0xf612, 0x4c02, { 0x84, 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } }
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|0x0003F001
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0x0003F002
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0x0003F003
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x0003F00D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BOOLEAN|0x0003F021
+
+ ### @brief This item allows the customer to change OC signal polarity to be active low. This is universal and applies to all OC pins.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)At present, this control applies to Family17h Model 00h-2Fh.
+ ### @li TRUE - OC pin is low when OC occurs.
+ ### @li FALSE - OC pin is high when OC occurs.
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciOcPolarityCfgLow|FALSE|BOOLEAN|0x0003F309
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFFFFFFFFFFFFF|UINT64|0x0003F340
+ #Die 0
+ #[7:0] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ #[23:0] MTS -- 6 USB 2.0 ports on XHCI controller 0
+ #Die 1
+ #[39:32] SSP -- 2 USB 2.0 ports on XHCI controller 0
+ #[47:40] SSP -- 2 USB 2.0 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb31OcPinSelect|0xFFFFFFFF|UINT32|0x0003F341
+ #Die 0
+ #[7:0] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[15:8] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ #[15:0] MTS -- 4 USB 3.1 ports on XHCI controller 0
+ #Die 1
+ #[23:16] SSP -- 2 USB 3.1 ports on XHCI controller 0
+ #[31:24] SSP -- 2 USB 3.1 ports on XHCI controller 1
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLpcEnable|TRUE|BOOLEAN|0x0003F400
+
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdUsbRSOemConfigurationTable|{0x0}|VOID*|0x0003F40A
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciSsid|0x00000000|UINT32|0x0003FF07
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x00000000|UINT32|0x0003FF81
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
new file mode 100644
index 0000000000..721d3ea73b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec
@@ -0,0 +1,26 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaMemPkg
+ PACKAGE_GUID = 445f7303-3171-428c-ad0b-32df4474a7ad
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include/
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries|64|UINT32|0x00029001
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
new file mode 100755
index 0000000000..0501774c9b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModuleNbioPkg.dec
@@ -0,0 +1,34 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaNbioPkg
+ PACKAGE_GUID = 1486f0fe-39ee-4856-a39f-222ff2404f26
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Protocols]
+ gAmdNbioPcieServicesProtocolGuid = {0x756db75c, 0xbb9d, 0x4289, {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}}
+
+[PcdsFixedAtBuild]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReservedEnable|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO reserved from GNB driver. 0:Disable
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE|BOOLEAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI phase
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0x00021103 #///< Base NBIO IOAPIC ID. ID assigned start from this value
+
+[PcdsDynamic]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x0004101D
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x0004101E
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|0x0|UINT32|0x00041200
diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
new file mode 100644
index 0000000000..41cf320c76
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec
@@ -0,0 +1,29 @@
+## @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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPspPkg
+ PACKAGE_GUID = 5c48f900-a98c-431f-8be5-19c09c65bb05
+ PACKAGE_VERSION = 0.1
+
+[Guids]
+ gApSyncFlagNvVariableGuid = { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb, 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } }
+ gAmdPspApobHobGuid = { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13, 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } }
+
+[Protocols]
+ gPspFlashAccSmmCommReadyProtocolGuid = { 0x9f373486, 0xda76, 0x4c9f, { 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } }
+ gAmdPspFtpmProtocolGuid = { 0xac234e04, 0xb036, 0x476c, { 0x91, 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } }
+
+[Ppis]
+ gAmdPspFtpmPpiGuid = { 0x91774185, 0xf72d, 0x467e, { 0x93, 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } }
+ gAmdPspFtpmFactoryResetPpiGuid = { 0x9c98130a, 0x8921, 0x45eb, { 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } }
diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/AgesaPkg.dec
new file mode 100644
index 0000000000..9377c64cc3
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/AgesaPkg.dec
@@ -0,0 +1,435 @@
+## @file
+# AMD Generic Encapsulated Software Architecture (AGESA) Package DEC
+# file.
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = AgesaPkg
+ PACKAGE_GUID = DABFEFC6-5A79-444b-862A-1F6FE9F561FE
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+
+[Guids]
+ gEfiAmdAgesaPkgTokenSpaceGuid = { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0, 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } }
+
+[Protocols]
+ gAmdNbioCxlServicesProtocolGuid = {0x125CCFCE, 0x34AF, 0x422C, {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}}
+ gAmdPciResourceProtocolGuid = {0x663d4897, 0xed94, 0x4f0f, {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}}
+ gAmdCapsuleSmmHookProtocolGuid = {0x4fc43bbe, 0x1433, 0x4951, {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}}
+ gAmdFspSetupTableInitDoneGuid = {0xef5394c6, 0x566d, 0x440f, {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}}
+
+[Ppis]
+ gAmdMemoryInfoHobPpiGuid = {0xba16e587, 0x1d66, 0x41b7, {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}}
+ gCapsuleUpdateDetectedPpiGuid = {0x745dfc73, 0xc401, 0x4ced, {0x8d, 0x3b, 0x1a, 0x82, 0xf3, 0xda, 0xdc, 0xf8}}
+
+[PcdsFixedAtBuild]
+
+ ### @brief Enable EDK-II Protocols
+ ### @details This item enables support for EDKII implementation of ACPI Protocols when set to TRUE
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCompliantEdkIIAcpiSdtProtocol|TRUE|BOOLEAN|0x00020006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize |0x1000|UINT32|0x00020007
+
+ ### @brief assign non volatile storage base address
+ ### @details This assigns the base address to map to flash deivce.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF000000|UINT32|0x00020017
+
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH.h"
+#----------------------------------------------------------------------------
+
+ ### @name General FCH Controls
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1 register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0400)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1EvtBlkAddr|0x400|UINT16|0x0002F004
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM1Cnt register blocks as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0404)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPm1CntBlkAddr|0x404|UINT16|0x0002F005
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI PM Timer as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0408)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiPmTmrBlkAddr|0x408|UINT16|0x0002F006
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI CPU Control block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0410)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgCpuControlBlkAddr|0x410|UINT16|0x0002F007
+
+ ### @brief Allows the host BIOS to specify the IO address for the ACPI GPE0 register block as defined by ACPI spec.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x0420)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|UINT16|0x0002F008
+
+ ### @brief This item defines the SMI command value sent by the host BIOS during the S3 resume sequence, to re-initialize the
+ ### FCH registers. This must be issued before the platform driver restore function is started.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD3)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemBeforePciRestoreSwSmi|0xD3|UINT8|0x0002F010
+
+ ### @brief This item defines the SMI command used by the host BIOS to signal the FCH driver that the platform driver has
+ ### completed its restore function. This allows the FCH driver to perform some final FCH settings.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xD4)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|UINT8|0x0002F011
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to activate ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemEnableAcpiSwSmi|0xA0|UINT8|0x0002F012
+
+ ### @brief Allows the host BIOS to set the SMI command value used by the OS to turn off ACPI mode.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xA1)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemDisableAcpiSwSmi|0xA1|UINT8|0x0002F013
+
+ ### @brief SMI command used for releasing the SPI controller lock mode. All devices on the SPI bus will be writable.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAA)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiUnlockSwSmi|0xAA|UINT8|0x0002F014
+
+ ### @brief SMI command for setting the lock mode in the SPI controller. This will effectively provide a write protection to the
+ ### SPI Flash ROM; however, write access to secondary SPI devices will also be blocked.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0xAB)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x0002F015
+#----------------------------------------------------------------------------
+#- FCH Fixed PCDs
+#-
+### Set Doxy_path: "PCD-FCH-IRQ.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart0Irq|0x03|UINT8|0x0002F01A
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart1Irq|0x0E|UINT8|0x0002F01B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart2Irq|0x05|UINT8|0x0002F01C
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart3Irq|0x0F|UINT8|0x0002F01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchUart4Irq|0x10|UINT8|0x0002F01E
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c0Irq|0x0A|UINT8|0x0002F01F
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c1Irq|0x0B|UINT8|0x0002F020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c2Irq|0x04|UINT8|0x0002F021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c3Irq|0x06|UINT8|0x0002F022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c4Irq|0x16|UINT8|0x0002F023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchI2c5Irq|0x17|UINT8|0x0002F024
+#- DF Fixed PCDs
+#-
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+ #Fabric
+
+ ### @name General DF Controls
+
+ ### @brief This item informs the SMBios generation code as to how many physical processor sockets exist in the system and
+ ### therefore how many Type 4 SMBios records to produce.
+ ### @brief Permitted Choices: (Type: Value)(Default: 0x01)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdNumberOfPhysicalSocket|1|UINT8|0x000CC103
+#----------------------------------------------------------------------------
+#- CCX Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-MTRR.h"
+#----------------------------------------------------------------------------
+
+
+ ### @brief The base address of temporary page table for accessing PCIE MMIO base address above 4G in PEI phase.
+ ### @brief Permitted Choices: 0x0 - 0xFFFFFFFF (Type: Value)(Default: 0)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPeiTempPageTableBaseAddress|0|UINT32|0x000CC11B
+
+#----------------------------------------------------------------------------
+#- CCX ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-ACPI.h"
+#----------------------------------------------------------------------------
+ #ACPI
+ # Cpu SSDT
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName0|0x43|UINT8|0x000AC001
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeName1|0x30|UINT8|0x000AC002
+ ### @brief This element specifies whether the ACPI _PSS objects are defined in the system bus or processor scope.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li TRUE - The objects will be under the \_SB scope.
+ ### @li FALSE - The objects will be under the \_PR scope
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorScopeInSb|FALSE|BOOLEAN|0x000AC003
+
+ ### @brief Set the OEM ID field in ACPI table outputs to this string. The string must conform to the ACPI rules for the OEM ID field.
+ ### @brief Permitted Choices: (Type: Value)(Default: "AMD")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|VOID*|0x000AC004
+
+#----------------------------------------------------------------------------
+#- CCX SMBIOS Fixed PCDs
+#-
+### Set Doxy_path: "PCD-CCX-SMBIOS.h"
+#----------------------------------------------------------------------------
+
+ ### @name CCX SMBIOS Controls
+
+ ### @brief When creating the SMBios table entry, use this as the label for the processor socket. This should match the
+ ### silkscreen label on the motherboard.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|"Unknown"|VOID*|0x00001001
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'serial number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket0|"Unknown"|VOID*|0x00001002
+
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Asset Tag' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket0|"Unknown"|VOID*|0x00001003
+
+ ### @brief When creating the SMBios table entry, use this as the value for the 'Part Number' field for each processor.
+ ### @brief Permitted Choices: (Type: Value)(Default: "Unknown")
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unknown"|VOID*|0x00001004
+
+ ### @brief SMBios socket 1 Label.
+ ### @details When creating the SMBios table entry, use this as the label for the
+ ### processor socket. This should match the silkscreen label on the motherboard.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|"Unknown"|VOID*|0x00001005
+
+ ### @brief SMBIOS socket 1 Serial Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'serial number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSerialNumberSocket1|"Unknown"|VOID*|0x00001006
+
+ ### @brief SMBios socket 1 Asset Tag.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Asset Tag' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosAssetTagSocket1|"Unknown"|VOID*|0x00001007
+
+ ### @brief Socket 1 Part Number.
+ ### @details When creating the SMBios table entry, use this as the value for
+ ### the 'Part Number' field for the processor in socket 1.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket1|"Unknown"|VOID*|0x00001008
+
+#----------------------------------------------------------------------------
+#- ACPI Fixed PCDs
+#-
+### Set Doxy_path: "PCD-ACPI.h"
+#----------------------------------------------------------------------------
+
+ ### @name General ACPI Controls
+
+ ### @brief PCD supporting maximum capacity for Type 16 table
+ ### @details This PCD represents maximum memory capacity in KB
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT16MaximumCapacity|0x04000000|UINT32|0x00001009 # 4G - 0x00400000
+ # 8G - 0x00800000
+ # 16G - 0x01000000
+ # 32G - 0x02000000
+ # 64G - 0x04000000
+ # 128G - 0x08000000
+ # 256G - 0x10000000
+ # 512G - 0x20000000
+[PcdsDynamic]
+#----------------------------------------------------------------------------
+# System level Dynamic PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCStateIoBaseAddress|0x413|UINT16|0x000CC002
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x000CC00B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC01D
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x000CC200
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerInSb|FALSE|BOOLEAN|0x000CC50B
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerName|"PLTF"|VOID*|0x000CC50C
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEAN|0x000CC601
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16|0x000CC900
+#----------------------------------------------------------------------------
+#- DF Dynamic PCDs
+### Set Doxy_path: "PCD-DF.h"
+#----------------------------------------------------------------------------
+
+
+ ### @cond (FF3||RN||BA||ZP||RMB||RPL||RS||SSP||MI3||BRH)
+ ### @brief Specifies the top address to be used for MMIO space allocations. No MMIO space will be used above this limit. Some devices have limits on the address space they
+ ### are able to access. For example a device with a 40-bit address limitation can not use MMIO space above 1TeraByte (1T). By setting this PCD to 0x10000000000 (1T), MMIO
+ ### space would not be allocated above 1T. The default is to use all of the space above the end of physical memory.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMmioAbove4GLimit|0xFFFFFFFFFFFFFFFF|UINT64|0x0003FFC2
+ ### @endcond
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFabricResourceDefaultSizePtr|0|UINT64|0x00DF0000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UINT16|0x0003FFC0
+
+ ### I2C-0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UINT32|0x000FC000
+ ### I2C-1
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UINT32|0x000FC001
+ ### I2C-2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UINT32|0x000FC002
+ ### I2C-3
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UINT32|0x000FC003
+ ### I2C-4
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UINT32|0x000FC004
+ ### I2C-5
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UINT32|0x000FC005
+ ### @} end of I2C hold times
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-UART.h"
+#----------------------------------------------------------------------------
+ ### @name UART Legacy IO Assignments
+ ### @{
+ ### @brief These controls allow the platform to specify the legacy IO ranges that are to be used by the UART ports in the processor. Permitted Choices: (Type: value)(Default: Disabled)
+ ### @li 0 - Disabled
+ ### @li 1 - IO range 0x02E8 - 0x02EF
+ ### @li 2 - IO range 0x02F8 - 0x02FF
+ ### @li 3 - IO range 0x03E8 - 0x03EF
+ ### @li 4 - IO range 0x03F8 - 0x03FF
+
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart0LegacyEnable|0x00|UINT8|0x000FC010
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart1LegacyEnable|0x00|UINT8|0x000FC011
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart2LegacyEnable|0x00|UINT8|0x000FC012
+ gEfiAmdAgesaPkgTokenSpaceGuid.FchUart3LegacyEnable|0x00|UINT8|0x000FC013
+ ### @} end UART Legacy IO assignments
+
+#----------------------------------------------------------------------------
+#- FCH Dynamic PCDs
+### Set Doxy_path: "PCD-FCH-USB.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci0Enable|TRUE|BOOLEAN|0x000FC020
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci1Enable|TRUE|BOOLEAN|0x000FC021
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci2Enable|TRUE|BOOLEAN|0x000FC022
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhci3Enable|TRUE|BOOLEAN|0x000FC023
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdXhciECCDedErrRptEn|FALSE|BOOLEAN|0x000FC024
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC030
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN|0x000FC039
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x000A6024
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO-BMC.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN|0x0004F004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x0004F005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkDie|0xFF|UINT8|0x0004F006
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkLaneNum|0|UINT8|0x0004F03E
+
+#----------------------------------------------------------------------------
+#- NBIO Dynamic PCDs
+### Set Doxy_path: "PCD-NBIO.h"
+#----------------------------------------------------------------------------
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgIommuSupport|TRUE|BOOLEAN|0x0004F027
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdIvInfoDmaReMap|FALSE|BOOLEAN|0x0004F028
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrVddfull_Scale_Current|0x00|UINT32|0x0004F0A0
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Current|0x00|UINT32|0x0004F0A2
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0x0004F210
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT32|0x0004F211
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT8|0x0004F362
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|UINT8|0x0004F363
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs DYNAMIC
+
+ ### @brief This feature selects the APCB recovery support on x86 side. If or when an instance of a writable APCB is determined to be invalid, the PSP driver will
+ ### attempt a 'recovery' by copying the recovery instance of the APCB (default values as indicated in the APCB descriptor files). Upon boot up, the ABL reads CMOS
+ ### bytes 06/07 at index/data port of 0x72/0x73. If the CMOS flag reads anything else other than 0xA55A or 0x5555, the system boots in APCB recovery mode, in which
+ ### ABL consumes the recovery instances of APCB. Otherwise it boots in normal/non-recovery mode.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE)
+ ### @brief This feature is affected by the platform CMOS power design. Please see Platform CMOS power .
+ ### @li TRUE - the AGESA PSP driver restores the APCB instances from the recovery instance, writes 0xA55A to the CMOS location and triggers a reset . The next time
+ ### the system powers up, ABL runs in normal/non-recovery mode.
+ ### @li FALSE - the AGESA PSP driver writes 0x5555 to the CMOS location without restoring the APCB instances or triggering a reset. In this mode the additional reset
+ ### is avoided at the potential risk of the writeable APCB instance being left corrupted forever.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|BOOLEAN|0x95940008
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE|BOOLEAN|0x95940018
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x00030004
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BOOLEAN|0x00030005
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BOOLEAN|0x00030006
+[PcdsDynamicEx]
+
+[PcdsFixedAtBuild, PcdsDynamic]
+#----------------------------------------------------------------------------
+#- System control PCDs
+### Set Doxy_path: "PCD-Sys.h"
+#----------------------------------------------------------------------------
+ ### @brief Switch for Debug Print function
+ ### @details Switch for Debug Print function to enable or not.
+ ### @li TRUE: Enable IdsDebugPrint output
+ ### @li FALSE: Disable IdsDebugPrint output
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEnable|FALSE|BOOLEAN|0x00020004
+ ### @brief Specify the filter for IdsDebugPrint
+ ### @details When the filter values are matched, the AmdIdsDebugPrint can start to print debug message.
+ ### Refer Library/IdsLib.h for details, and the Master token is PcdAmdIdsDebugPrintEnable.
+ ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ ### @li 0x100401008A300408: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC | CPU_TRACE | MEM_FLOW | FCH_TRACE | MAIN_FLOW| TEST_POINT | PSP_TRACE)
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintFilter|0x100401030A300408|UINT64|0x00020005
+ ### @brief Switch for Serial port support of AGESA debug print
+ ### @details Switch for Serial port support of AGESA debug print, NOTE, AGESA will not init the serial port,
+ ### serial port should be initialized before call AGESA debug print.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortEnable|FALSE|BOOLEAN|0x00020009
+ ### @brief The serial port used for debug output can be either 2-wire (Rx/Tx) or 4-wire (adding DSR/CTS). Waiting for CTS on a
+ ### 2-wire port would cause a hang. This control is added to check the cable connection.
+ ### @brief Permitted Choices: (Type: Boolean)(Default: FALSE)
+ ### @li FALSE - Presume a 2-wire port and do not wait for CTS.
+ ### @li TRUE - Wait for both DSR and CTS to be set. DSR is set if a cable is connected. CTS is set if it is ok to transmit data.
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCableConnection|FALSE|BOOLEAN|0x0002000A
+
+ ### @brief Selection of UART and UART Legacy IO Serial port for AGESA debug print
+ ### @details Selection of UART and UART Legacy IO Serial port for AGESA debug print and invisible in ACPI name space.
+ ### @li Bit[0]: Select UART0 for AGESA debug print
+ ### @li Bit[1]: Select UART1 for AGESA debug print
+ ### @li Bit[2]: Select UART2 for AGESA debug print
+ ### @li Bit[3]: Select UART3 for AGESA debug print
+ ### @li Bit[4]: Select UART4 for AGESA debug print
+ ### @li Bit[8]: Select UART0 Legacy IO for AGESA debug print
+ ### @li Bit[9]: Select UART1 Legacy IO for AGESA debug print
+ ### @li Bit[10]: Select UART2 Legacy IO for AGESA debug print
+ ### @li Bit[11]: Select UART3 Legacy IO for AGESA debug print
+ ### @li Bit[15]: Set debug print serial port to invisible in ACPI name space at OS runtime
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortSelect|0x0000|UINT16|0x0002718A
+
+ ### @brief Specify the IO port for serial out
+ ### @details ESPI or LPC COM1: 0x3F8, COM2: 0x2F8, COM3: 0x3E8, COM4: 0x2E8,
+ ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000, UART3: 0xFEDCF000, UART4: 0xFEDD1000.
+ ### @li If it's IO port: it must < 0x10000
+ ### @li If it's Memory: it must >= 0x10000
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UINT64|0x0002000B
+
+ ### @brief Debug Print Emulation Auto Detect
+ ### @details Auto detect emulation platform to instead of PcdAmdIdsDebugPrintRedirectIOEnable and
+ ### PcdAmdIdsDebugPrintSerialPortEnable.
+ ### @li TRUE: Enable
+ ### @li FALSE: Disable
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetect|FALSE|BOOLEAN|0x00020016
+
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdCfgPlatformPPT|0|UINT32|0x0004F111
+
+#----------------------------------------------------------------------------
+#- PSP Dynamic PCDs
+### Set Doxy_path: "PCD-PSP.h"
+#----------------------------------------------------------------------------
+ ### PSP PCDs
+
+ ### @brief Rom Armor selection
+ ### @details Rom Armor selection
+ ### @li 0: Rom Armor is disabled
+ ### @li 1: Rom Armor 1 is enabled (VMR/MTS/CPK)
+ ### @li 2: Rom Armor 2 is enabled (RN/CZN)
+ ### @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
+ ### @li 0x1: PSP fTPM
+ ### @li 0x2: HSP fTPM
+ ### @li 0xFF: no TPM
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8|0x95940024
+
+ ### @cond !BRH
+ ### @brief TPM SMx algorithm flag
+ ### @details TPM SMx algorithm flag, SBIOS needs to set the value in PEI phase.
+ ### @li 0: SM2, SM3 or SM4 crypto algorithms not supported
+ ### @li 1: SM2, SM3 or SM4 crypto algorithms supported
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmAlgSmx|0|UINT8|0x95940025
+ ### @endcond
diff --git a/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
new file mode 100755
index 0000000000..c8c474637f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/AmdCpmPkg.dec
@@ -0,0 +1,41 @@
+## @file
+# AMD Common Platform Module (CPM) Module Package DEC.
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x00010005
+ PACKAGE_NAME = CpmPkg
+ PACKAGE_GUID = ABE128BA-1061-4A53-A1B8-D07329AA7A67
+ PACKAGE_VERSION = 0.1
+
+[Includes]
+ Include
+ Library
+
+[Guids]
+ gAmdCpmPkgTokenSpaceGuid = {0x916e0ddd, 0x2bd2, 0x4704, {0x93, 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}}
+ gShellActHiiGuid = {0x340EBE97, 0x3C1C, 0x4272, {0x9C, 0xCE, 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}}
+ gAmdPbsSystemConfigurationGuid = {0xa339d746, 0xf678, 0x49b3, {0x9f, 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}}
+
+[Protocols]
+ gAmdCpmTableProtocolGuid = { 0x3724cf01, 0x00c2, 0x9762, {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }}
+ gAmdCpmAllPciIoProtocolsInstalledProtocolGuid = { 0x676D7012, 0x139B, 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }}
+
+[Ppis]
+ gAmdCpmTablePpiGuid = { 0xd71cf893, 0xa8b5, 0x49d3, { 0xa2, 0x1b, 0x31, 0xe2, 0xf5, 0xc4, 0xa7, 0x47 } }
+
+[PcdsFixedAtBuild]
+ gAmdCpmPkgTokenSpaceGuid.PcdFchUartPort|2|UINT8|0x00000052
+
+ #ACPI
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiHestTableHeaderOemTableId|"AMD HEST"|VOID*|0x000AC001
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiBertTableHeaderOemTableId|"AMD BERT"|VOID*|0x000AC002
+ gAmdCpmPkgTokenSpaceGuid.PcdAmdAcpiEinjTableHeaderOemTableId|"AMD EINJ"|VOID*|0x000AC003
+
+ gAmdCpmPkgTokenSpaceGuid.UsePciXAslName|FALSE|BOOLEAN|0x12000003
+ gAmdCpmPkgTokenSpaceGuid.AcpiRestoreSwSmi|0xE3|UINT8|0x00000040
diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
new file mode 100644
index 0000000000..37b8d15cb1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaEdk2PlatformPkg.inc.dsc
@@ -0,0 +1,18 @@
+## @file
+#
+# 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[LibraryClasses]
+ NbioCommonDxeLib|AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
+
+ ## Gnb Lib
+ NbioHandleLib|AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
+ PcieConfigLib|AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
+
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
new file mode 100644
index 0000000000..e7e05fd2d8
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc
@@ -0,0 +1,48 @@
+## @file
+# The AGESA DSC file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[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
+ AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
+
+ ## DF Lib
+ BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
+
+ ## Gnb Lib
+ 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
+
+ ## Fch Lib
+ FchBaseLib|AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
+
+[Components.IA32]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
+
+[Components.X64]
+ AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
new file mode 100644
index 0000000000..1f1e04c414
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.dsc
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..2916fecb26
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc
@@ -0,0 +1,11 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ DEFINE AGESA_PKG_PATH = AgesaModulePkg
+ DEFINE AGESA_PKG_DEC = AgesaCommonModulePkg
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
new file mode 100644
index 0000000000..9303d1fac4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.dxe.inc.fdf
@@ -0,0 +1,11 @@
+## @file
+# The AGESA DXE FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+## APCB V3 Dxe Drivers
+ INF AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
diff --git a/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
new file mode 100644
index 0000000000..0ef5a2a806
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.pei.inc.fdf
@@ -0,0 +1,9 @@
+## @file
+# The AGESA PEI FDF file for building AMD SP5 Genoa boards.
+#
+# Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
diff --git a/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.dxe.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..da3afe6e59
--- /dev/null
+++ b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsStones.pei.inc.fdf
@@ -0,0 +1,8 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..b790e4ead5
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.fdf
@@ -0,0 +1,10 @@
+## @file
+#
+# Platform Package Flash Description File
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100644
index 0000000000..4766ad0447
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGenoaQuartzPkg.pei.inc.fdf
@@ -0,0 +1,7 @@
+## @file
+#
+# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
new file mode 100755
index 0000000000..8d3357bf56
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdCalloutLib
+ FILE_GUID = A8FEA621-B381-4c06-9E9D-0897EF78BD78
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdCalloutLib
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
new file mode 100644
index 0000000000..1594a99265
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.inf
@@ -0,0 +1,30 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
new file mode 100644
index 0000000000..c685a26604
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLib
+ FILE_GUID = 55871F80-4658-6EF3-A8AC-15B34FF8C2CE
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLib
+
+[Sources.common]
+ AmdPspRomArmorLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
new file mode 100644
index 0000000000..a3906dc13e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspRomArmorLibNull
+ FILE_GUID = 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspRomArmorLibNull
+
+[Sources.common]
+ AmdPspRomArmorLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
new file mode 100644
index 0000000000..09d5bd38ac
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf
@@ -0,0 +1,37 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3
+ 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
+
+[Sources.common]
+ ApcbLibV3.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSmmReadyToLockProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntries
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
new file mode 100644
index 0000000000..c031d00d79
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = ApcbLibV3Pei
+ FILE_GUID = EEA4E007-E408-4daa-82BD-4C52E7058753
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = ApcbLibV3Pei|PEIM
+
+[Sources.common]
+ ApcbLibV3Pei.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleMemPkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseMemoryLib
+ PeiServicesLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
new file mode 100644
index 0000000000..38a72e26b7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.inf
@@ -0,0 +1,28 @@
+## @file
+#
+# For EDKII use Only
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseFabricTopologyRsLib
+ FILE_GUID = D0A070DD-630A-43F8-9D76-EAAABDDE5FB9
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseFabricTopologyLib
+ CONSTRUCTOR = BaseFabricTopologyLibConstructor
+
+[Sources]
+ BaseFabricTopologyRsLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+
+[LibraryClasses]
+ BaseLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
new file mode 100644
index 0000000000..d15d8169fe
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.inf
@@ -0,0 +1,35 @@
+## @file
+# Base Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseTscTimerLib
+ FILE_GUID = D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ BaseTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
new file mode 100644
index 0000000000..1e52768a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Dxe Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTscTimerLib
+ FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeTscTimerLibConstructor
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ DxeTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ UefiBootServicesTableLib
+ PcdLib
+ BaseLib
+ UefiLib
+ DebugLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
new file mode 100644
index 0000000000..b1eaefd282
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Pei Timer Library which uses the Time Stamp Counter in the processor.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTscTimerLib
+ FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|PEIM PEI_CORE
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ TscTimerLibShare.c
+ PeiTscTimerLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleCcxPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ PcdLib
+ BaseLib
+ HobLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644
index 0000000000..f60f97905a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.inf
@@ -0,0 +1,42 @@
+## @file
+# Library instance of PciHostBridgeLib library class for coreboot.
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciHostBridgeLib
+ FILE_GUID = 74967FD7-A9A4-4B16-8B41-B26BC3230D0A
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciHostBridgeLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ PciHostBridgeLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleDfPkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ PciHostBridgeLib
+ DevicePathLib
+ MemoryAllocationLib
+ DebugLib
+ UefiBootServicesTableLib
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
new file mode 100644
index 0000000000..2a72fa8117
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGenerationLib.inf
@@ -0,0 +1,47 @@
+## @file
+#
+# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseLib/FchBaseLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
new file mode 100644
index 0000000000..e63a70e849
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseLib.inf
@@ -0,0 +1,26 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/FchBaseResetSystemLib/FchBaseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
new file mode 100644
index 0000000000..e422cb69a4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.inf
@@ -0,0 +1,35 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = BaseResetSystemLib
+ FILE_GUID = e669c365-2df2-4540-a343-afec4e85b198
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = BaseResetSystemLib
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ FchBaseResetSystemLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PrintLib
+ IoLib
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
new file mode 100644
index 0000000000..d7f49c40de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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.inf b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
new file mode 100755
index 0000000000..f32bbc9ff2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.inf
@@ -0,0 +1,24 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioHandleLib
+ FILE_GUID = DC4639D3-DB75-486B-AC38-C84AA49601E3
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioHandleLib
+
+[Sources]
+ NbioHandleLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
new file mode 100755
index 0000000000..0d6ba605f5
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.inf
@@ -0,0 +1,25 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PcieConfigLib
+ FILE_GUID = C1205AD2-FE67-4502-A0A7-FB1704A3F9AE
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PcieConfigLib
+
+[Sources]
+ PcieConfigLib.c
+ PcieInputParserLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
new file mode 100644
index 0000000000..ae1dd6cd83
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SmnAccessLib
+ FILE_GUID = 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SmnAccessLib
+
+[Sources]
+ SmnAccessLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ PrintLib
+ BaseLib
+ DebugPrintErrorLevelLib
+
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
new file mode 100644
index 0000000000..da7f5c185d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = NbioCommonDxeLib
+ FILE_GUID = 1BF93335-5D55-46D9-99D9-5D962F039829
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NbioCommonDxeLib
+
+[Sources]
+ DxeLibFunctions.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModuleNbioPkg.dec
+
+[LibraryClasses]
+ BaseLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
new file mode 100644
index 0000000000..54c3514020
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbDxeV3
+ FILE_GUID = 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3DxeDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ BaseMemoryLib
+ UefiBootServicesTableLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ DxeServicesTableLib
+ MemoryAllocationLib
+ ApcbLibV3
+
+[Sources]
+ ApcbV3Dxe.c
+
+[Protocols]
+ gEfiDxeSmmReadyToLockProtocolGuid
+ gEfiSmmCommunicationProtocolGuid
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
new file mode 100644
index 0000000000..7f90aa6ea0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AmdApcbPeiV3
+ FILE_GUID = E1B8CF4A-FE7B-4676-B4F7-50C7228282A4
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = AmdApcbV3PeiDriverEntry
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PeimEntryPoint
+ ApcbLibV3Pei
+
+[sources]
+ ApcbV3Pei.c
+
+[Depex]
+ TRUE
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
new file mode 100755
index 0000000000..0f115c362e
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf
@@ -0,0 +1,27 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = OemAgesaCcxPlatformLibNull
+ FILE_GUID = B1F58B07-0146-4804-B701-A56CB5716529
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = OemAgesaCcxPlatformLib
+
+[Sources.common]
+ OemAgesaCcxPlatformLibNull.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Depex]
+ TRUE
+
+
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
new file mode 100644
index 0000000000..ba551e5c14
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.inf
@@ -0,0 +1,61 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciCfg2
+ FILE_GUID = 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ ENTRY_POINT = PeimInitializePciCfg
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
+#
+
+[Sources]
+ PciExpressPciCfg2.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+
+[LibraryClasses]
+ PeimEntryPoint
+ BaseLib
+ PcdLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ HobLib
+ IoLib
+
+[Ppis]
+ gEfiPciCfg2PpiGuid ## PRODUCES
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+
+[Pcd.IA32,Pcd.X64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdNullPointerDetectionPropertyMask ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ## SOMETIMES_CONSUMES
+
+[Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIMES_CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIMES_CONSUMES
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
new file mode 100644
index 0000000000..e712a80886
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PciExpressPciSegmentInfoLib
+ FILE_GUID = FA8B1082-88DF-4744-85A3-7F87A9EBF8DC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciSegmentInfoLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ PciSegmentInfoLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+
+[LibraryClasses]
+ DebugLib
+ BaseLib
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
new file mode 100644
index 0000000000..f4b9d0d789
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf
@@ -0,0 +1,45 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = AmdPspFlashAccLibSmm
+ FILE_GUID = 3BBDC3A5-A0E2-4E8A-8240-9E594920F040
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = AmdPspFlashAccLib | DXE_SMM_DRIVER
+
+[Sources.common]
+ AmdPspFlashAccSpiNorLibSmm.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaModulePkg/AgesaModulePspPkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+ AgesaPkg/AgesaPkg.dec
+
+[LibraryClasses]
+ AmdPspBaseLibV2
+ BaseLib
+ DebugLib
+ SmmServicesTableLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gEfiSmmBase2ProtocolGuid
+ gEfiSpiSmmNorFlashProtocolGuid
+
+[Pcd]
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize ## CONSUMES
+ gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ## CONSUMES
+
+[Depex]
+ gEfiSmmBase2ProtocolGuid AND
+ gEfiSpiSmmNorFlashProtocolGuid
+
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
new file mode 100644
index 0000000000..57bb0d9e25
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = PspRomArmorWhitelistLib
+ FILE_GUID = B6F8507A-C96B-4036-A8C0-26BAD6AC5F34
+ MODULE_TYPE = DXE_SMM_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformPspRomArmorWhitelistLib
+
+[Sources]
+ PspRomArmorWhitelistLib.c
+
+[Packages]
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AgesaPkg/AgesaPkg.dec
+ MdePkg/MdePkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ MemoryAllocationLib
+ PcdLib
+ DebugLib
+
+[Depex]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
new file mode 100644
index 0000000000..64fd2913ad
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.inf
@@ -0,0 +1,42 @@
+## @file
+#
+# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+
+
+
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
new file mode 100644
index 0000000000..f4d7638c1a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatform.inf
@@ -0,0 +1,32 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
new file mode 100644
index 0000000000..973ace8632
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.inf
@@ -0,0 +1,29 @@
+## @file
+#
+# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
new file mode 100644
index 0000000000..2d9dbeb715
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.inf
@@ -0,0 +1,53 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+ UNLOAD_IMAGE = ActLibraryUnregisterActCommand
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoDynamicCommand.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ UefiLib
+ FileHandleLib
+ HiiLib
+ DebugLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ UefiRuntimeServicesTableLib
+ UefiDriverEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+
+[Guids]
+ gShellActHiiGuid ## SOMETIMES_CONSUMES ## HII
+ gAgesaConfigDbPointerVariableGuid
+
+[Protocols]
+ gEfiShellDynamicCommandProtocolGuid
+ gEfiHiiPackageListProtocolGuid
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[DEPEX]
+ TRUE
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
new file mode 100644
index 0000000000..98c8755ab8
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.inf
@@ -0,0 +1,50 @@
+## @file
+#
+# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# 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
+#
+# This flag specifies whether HII resource section is generated into PE image.
+#
+ UEFI_HII_RESOURCE_SECTION = TRUE
+
+[Sources.common]
+ AmdAutoToolApp.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AgesaModulePkg/AgesaCommonModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
+ DebugLib
+ FileHandleLib
+ HiiLib
+ MemoryAllocationLib
+ UefiApplicationEntryPoint
+ UefiBootServicesTableLib
+ UefiHiiServicesLib
+ UefiLib
+ UefiRuntimeServicesTableLib
+
+[Protocols]
+ gEfiHiiPackageListProtocolGuid ## CONSUMES
+ gEfiShellParametersProtocolGuid
+ gEfiUnicodeCollation2ProtocolGuid
+
+[Guids]
+
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
new file mode 100644
index 0000000000..9c3c0dd0a9
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.inf
@@ -0,0 +1,33 @@
+## @file
+#
+# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BasePlatformHookLibAmdFchUart
+ FILE_GUID = BF2F3F3F-4BE6-4B97-850D-D5D4941D391C
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PlatformHookLib
+
+[Sources]
+ BasePlatformHookLibAmdFchUart.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ AmdCpmPkg/AmdCpmPkg.dec
+ AgesaModulePkg/AgesaModuleFchPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ IoLib
+ PlatformHookLib
+
+
+
diff --git a/Platform/AMD/AgesaModulePkg/Include/AGESA.h b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
new file mode 100644
index 0000000000..3ec03aafd3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AGESA.h
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AGESA_H_
+#define AGESA_H_
+
+#include "AMD.h"
+#include "SocLogicalId.h"
+
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+#define DESCRIPTOR_INITIALIZE_LIST 0x20000000ull
+
+/// PCIe link initialization
+typedef enum {
+ EndpointDetect = 0, ///< Detect endpoint presence
+ EndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} PCIE_ENDPOINT_STATUS;
+
+/// PCIe port misc extended controls
+typedef struct {
+ IN UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ IN UINT8 LinkSafeMode : 2; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through PCIe_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertise maximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 2; ///< Unused space
+} PCIE_PORT_MISC_CONTROL;
+
+/// The IO APIC Interrupt Mapping Info
+typedef struct {
+ IN UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ IN UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< - ABCD
+ ///< - BCDA
+ ///< - CDAB
+ ///< - DABC
+ IN UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< - Entry 0 of IO APIC redirection table
+ ///< - Entry 1 of IO APIC redirection table
+ ///< - Entry 31 of IO APIC redirection table
+} APIC_DEVICE_INFO;
+
+/// GEN3 RxAdaptMode Configuration Structure
+typedef struct {
+ IN BOOLEAN InitOffsetCancellation; ///< Initial Offset Cancellation Enable
+ IN UINT8 DFEControl; ///< DFE Control
+ IN UINT8 LEQControl; ///< LEQ Control
+ IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic Offset Calibration Enable
+ IN BOOLEAN FOMCalculation; ///< FOM Calculation Enable
+ IN BOOLEAN PIOffsetCalibration; ///< PI Offset Calibratino Enable
+} RX_ADAPT_MODE;
+
+/// PCIe port configuration data
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 ChannelType; ///< Channel type.
+ ///< 0 - "lowLoss",
+ ///< 1 - "highLoss",
+ ///< 2 - "mob0db",
+ ///< 3 - "mob3db",
+ ///< 4 - "extnd6db"
+ ///< 5 - "extnd8db"
+ IN UINT8 DeviceNumber; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 FunctionNumber; ///< Reserved for future use
+ IN UINT8 LinkSpeedCapability; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT8 ResetId; ///< Arbitrary number greater than 0 assigned by platform firmware for GPIO
+ ///< identification which control reset for given port.
+ ///< Each port with unique GPIO should have unique ResetId assigned.
+ ///< All ports use same GPIO to control reset should have same ResetId assigned.
+ ///< see AgesaPcieSlotResetContol.
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3 RxAdaptMode configuration
+} PCIE_PORT_DATA;
+
+/// PCIe Complex descriptor
+typedef struct {
+ IN UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ IN UINT32 SocketId; ///< Socket Id
+ IN VOID *Reserved; ///< Reserved for future use
+} PCIE_COMPLEX_DESCRIPTOR;
+
+/// VBIOS image info
+typedef struct {
+ IN AMD_CONFIG_PARAMS StdHeader; ///< Standard configuration header
+ OUT VOID *ImagePtr; ///< Pointer to VBIOS image
+ IN PCI_ADDR GfxPciAddress; ///< PCI address of integrated graphics controller
+ IN UINT32 Flags; ///< BIT[0] - special repost requred
+} GFX_VBIOS_IMAGE_INFO;
+
+//
+// CPU MSR Register definitions
+//
+#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture Programming manual.
+#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture Programming manual.
+#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture Programming manual.
+
+///
+/// VDDP_VDDR Voltage Info for Low Power DIMM
+///
+typedef struct _VDDP_VDDR_VOLTAGE {
+ IN BOOLEAN IsValid; ///< Indicates if daata is valid
+ IN UINT8 Voltage; ///< VDDP VDDR Voltage Value
+} VDDP_VDDR_VOLTAGE;
+
+// CPU Build Configuration structures and definitions
+
+#define AMD_AP_MTRR_FIX64k_00000 0x00000250ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to AMD64 Architecture Programming manual.
+#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to AMD64 Architecture Programming manual
+#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to AMD64 Architecture Programming manual
+
+#endif // AGESA_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/AgesaModulePkg/Include/AMD.h
new file mode 100755
index 0000000000..062d9e1e1a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AMD.h
@@ -0,0 +1,91 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_H_
+#define AMD_H_
+
+/// The return status for all AGESA public services.
+///
+/// Services return the most severe status of any logged event. Status other than SUCCESS, UNSUPPORTED, and BOUNDS_CHK
+/// will have log entries with more detail.
+///
+typedef enum {
+ AGESA_SUCCESS = 0, ///< 0 - The service completed normally. Info may be logged.
+ AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct had an unimplemented function requested.
+ ///< Not logged.
+ AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of range and the service was not provided.
+ ///< Example, memory address not installed, heap buffer handle not found.
+ ///< Not Logged.
+ AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP communications (used in ABL)
+ AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in ABL)
+
+ // AGESA_STATUS of greater severity (the ones below this line), always have a log entry available.
+ AGESA_ALERT, ///< 5 - An observed condition, but no loss of function. See Log.
+ AGESA_WARNING, ///< 6 - Possible or minor loss of function. See Log.
+ AGESA_ERROR, ///< 7 - Significant loss of function, boot may be possible. See Log.
+ AGESA_CRITICAL, ///< 8 - Continue boot only to notify user. See Log.
+ AGESA_FATAL, ///< 9 - Halt booting. See Log, however Fatal errors pertaining to heap problems
+ ///< may not be able to reliably produce log events.
+ AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory Overclock failure. (used in ABL)
+ AGESA_SKIP_ERROR, ///< 11 - Error, Skip init steps. (used in ABL)
+ AgesaStatusMax ///< Not a status, for limit checking.
+} AGESA_STATUS;
+
+/**
+ Callout method to the host environment.
+
+ Callout using a dispatch with appropriate thunk layer, which is determined by the host environment.
+
+ @param[in] Function The specific callout function being invoked.
+ @param[in] FcnData Function specific data item.
+ @param[in,out] ConfigPtr Reference to Callout params.
+**/
+typedef AGESA_STATUS (*CALLOUT_ENTRY) (
+ IN UINT32 Function,
+ IN UINTN FcnData,
+ IN OUT VOID *ConfigPtr
+ );
+
+/// AGESA Structures
+
+/// Extended PCI address format
+typedef struct {
+ IN OUT UINT32 Register : 12; ///< Register offset
+ IN OUT UINT32 Function : 3; ///< Function number
+ IN OUT UINT32 Device : 5; ///< Device number
+ IN OUT UINT32 Bus : 8; ///< Bus number
+ IN OUT UINT32 Segment : 4; ///< Segment
+} EXT_PCI_ADDR;
+
+/// Union type for PCI address
+typedef union _PCI_ADDR {
+ IN UINT32 AddressValue; ///< Formal address
+ IN EXT_PCI_ADDR Address; ///< Extended address
+} PCI_ADDR;
+
+///
+/// The standard header for all AGESA services.
+///
+typedef struct {
+ IN UINT32 ImageBasePtr; ///< The AGESA Image base address.
+ IN UINT32 Func; ///< The service desired
+ IN UINT32 AltImageBasePtr; ///< Alternate Image location
+ IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from AGESA
+ IN UINT8 HeapStatus; ///< For heap status from boot time slide.
+ IN UINT64 HeapBasePtr; ///< Location of the heap
+ IN OUT UINT8 Reserved[7]; ///< This space is reserved for future use.
+} AMD_CONFIG_PARAMS;
+
+/// CPUID data received registers format
+typedef struct {
+ OUT UINT32 EAX_Reg; ///< CPUID instruction result in EAX
+ OUT UINT32 EBX_Reg; ///< CPUID instruction result in EBX
+ OUT UINT32 ECX_Reg; ///< CPUID instruction result in ECX
+ OUT UINT32 EDX_Reg; ///< CPUID instruction result in EDX
+} CPUID_DATA;
+#endif // AMD_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
new file mode 100755
index 0000000000..534b03d4a7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h
@@ -0,0 +1,15 @@
+/** @file
+ AMD CPU Register Table Related Functions.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_H_
+#define CPU_REGISTERS_H_
+
+#include <CpuRegistersDef.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
new file mode 100644
index 0000000000..e086a4c9b1
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h
@@ -0,0 +1,61 @@
+/** @file
+ AMD Psp Directory header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_DIR_H_
+#define AMD_PSP_DIR_H_
+
+#pragma pack (push, 1)
+#define PSP_DIRECTORY_HEADER_SIGNATURE 0x50535024ul ///< $PSP
+#define PSP_LV2_DIRECTORY_HEADER_SIGNATURE 0x324C5024ul ///< $PL2
+
+/// Enum define various enum type for PSP entry type
+enum _PSP_DIRECTORY_ENTRY_TYPE {
+ PSP_REGION_A_DIR = 0x48, ///< PSP entry points to PSP DIR in Region A
+ PSP_REGION_B_DIR = 0x4A, ///< PSP entry points to PSP DIR in Region B
+};
+
+/// Define structure for PSP directory
+typedef struct {
+ UINT32 Cookie; ///< "$PSP"
+ UINT32 Checksum; ///< 32 bit CRC of header items below and the entire table
+ UINT32 TotalEntries; ///< Number of PSP Entries
+ UINT32 Reserved; ///< Unused
+} PSP_DIRECTORY_HEADER;
+
+/// Define structure for 32 bits Entry type field
+typedef struct {
+ UINT32 Type : 8; ///< Type of PSP Directory entry
+ UINT32 SubProgram : 8; ///< Specify the SubProgram
+ UINT32 RomId : 2; ///< Specify the ROM ID
+ UINT32 Reserved : 14; ///< Reserved
+} PSP_DIRECTORY_ENTRY_TYPE_FIELD;
+
+/// Define union type for 32 bits Entry type field
+typedef union {
+ PSP_DIRECTORY_ENTRY_TYPE_FIELD Field; ///< Definition of each filed
+ UINT32 Value; ///< Group it as 32bits Int
+} PSP_DIRECTORY_ENTRY_TYPE;
+
+/// Structure for PSP Entry
+typedef struct {
+ PSP_DIRECTORY_ENTRY_TYPE Type; ///< Type of PSP entry; 32 bit long
+ UINT32 Size; ///< Size of PSP Entry in bytes
+ UINT64 Location; ///< Location of PSP Entry (byte offset from start of SPI-ROM)
+} PSP_DIRECTORY_ENTRY;
+
+/// Structure for PSP directory
+typedef struct {
+ PSP_DIRECTORY_HEADER Header; ///< PSP directory header
+ PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PSP entries each pointing to a binary in SPI flash
+ ///< The actual size of this array comes from the
+ ///< header (PSP_DIRECTORY.Header.TotalEntries)
+} PSP_DIRECTORY;
+
+#pragma pack (pop)
+#endif //AMD_PSP_DIR_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
new file mode 100755
index 0000000000..faa8d35b1b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/CpuRegistersDef.h
@@ -0,0 +1,156 @@
+/** @file
+ AMD CPU Register Table Related Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CPU_REGISTERS_DEF_H_
+#define CPU_REGISTERS_DEF_H_
+
+#undef BIT0
+#undef BIT1
+#undef BIT2
+#undef BIT3
+#undef BIT4
+#undef BIT5
+#undef BIT6
+#undef BIT7
+#undef BIT8
+#undef BIT9
+#undef BIT10
+#undef BIT10
+#undef BIT11
+#undef BIT12
+#undef BIT13
+#undef BIT14
+#undef BIT15
+#undef BIT16
+#undef BIT17
+#undef BIT18
+#undef BIT19
+#undef BIT20
+#undef BIT21
+#undef BIT22
+#undef BIT23
+#undef BIT24
+#undef BIT25
+#undef BIT26
+#undef BIT27
+#undef BIT28
+#undef BIT29
+#undef BIT30
+#undef BIT31
+#undef BIT32
+#undef BIT33
+#undef BIT34
+#undef BIT35
+#undef BIT36
+#undef BIT37
+#undef BIT38
+#undef BIT39
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT40
+#undef BIT41
+#undef BIT42
+#undef BIT43
+#undef BIT44
+#undef BIT45
+#undef BIT46
+#undef BIT47
+#undef BIT48
+#undef BIT49
+#undef BIT50
+#undef BIT51
+#undef BIT52
+#undef BIT53
+#undef BIT54
+#undef BIT55
+#undef BIT56
+#undef BIT57
+#undef BIT58
+#undef BIT59
+#undef BIT60
+#undef BIT61
+#undef BIT62
+#undef BIT63
+
+#define BIT0 0x0000000000000001ull
+#define BIT1 0x0000000000000002ull
+#define BIT2 0x0000000000000004ull
+#define BIT3 0x0000000000000008ull
+#define BIT4 0x0000000000000010ull
+#define BIT5 0x0000000000000020ull
+#define BIT6 0x0000000000000040ull
+#define BIT7 0x0000000000000080ull
+#define BIT8 0x0000000000000100ull
+#define BIT9 0x0000000000000200ull
+#define BIT10 0x0000000000000400ull
+#define BIT11 0x0000000000000800ull
+#define BIT12 0x0000000000001000ull
+#define BIT13 0x0000000000002000ull
+#define BIT14 0x0000000000004000ull
+#define BIT15 0x0000000000008000ull
+#define BIT16 0x0000000000010000ull
+#define BIT17 0x0000000000020000ull
+#define BIT18 0x0000000000040000ull
+#define BIT19 0x0000000000080000ull
+#define BIT20 0x0000000000100000ull
+#define BIT21 0x0000000000200000ull
+#define BIT22 0x0000000000400000ull
+#define BIT23 0x0000000000800000ull
+#define BIT24 0x0000000001000000ull
+#define BIT25 0x0000000002000000ull
+#define BIT26 0x0000000004000000ull
+#define BIT27 0x0000000008000000ull
+#define BIT28 0x0000000010000000ull
+#define BIT29 0x0000000020000000ull
+#define BIT30 0x0000000040000000ull
+#define BIT31 0x0000000080000000ull
+#define BIT32 0x0000000100000000ull
+#define BIT33 0x0000000200000000ull
+#define BIT34 0x0000000400000000ull
+#define BIT35 0x0000000800000000ull
+#define BIT36 0x0000001000000000ull
+#define BIT37 0x0000002000000000ull
+#define BIT38 0x0000004000000000ull
+#define BIT39 0x0000008000000000ull
+#define BIT40 0x0000010000000000ull
+#define BIT41 0x0000020000000000ull
+#define BIT42 0x0000040000000000ull
+#define BIT43 0x0000080000000000ull
+#define BIT44 0x0000100000000000ull
+#define BIT45 0x0000200000000000ull
+#define BIT46 0x0000400000000000ull
+#define BIT47 0x0000800000000000ull
+#define BIT48 0x0001000000000000ull
+#define BIT49 0x0002000000000000ull
+#define BIT50 0x0004000000000000ull
+#define BIT51 0x0008000000000000ull
+#define BIT52 0x0010000000000000ull
+#define BIT53 0x0020000000000000ull
+#define BIT54 0x0040000000000000ull
+#define BIT55 0x0080000000000000ull
+#define BIT56 0x0100000000000000ull
+#define BIT57 0x0200000000000000ull
+#define BIT58 0x0400000000000000ull
+#define BIT59 0x0800000000000000ull
+#define BIT60 0x1000000000000000ull
+#define BIT61 0x2000000000000000ull
+#define BIT62 0x4000000000000000ull
+#define BIT63 0x8000000000000000ull
+
+#define MSR_MMIO_CFG_BASE 0xC0010058ul // MMIO Configuration Base Address Register
+
+#endif // CPU_REGISTERS_DEF_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
new file mode 100644
index 0000000000..8ede1be838
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/FchRegistersCommon.h
@@ -0,0 +1,85 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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_TXBYTECOUNT 0x48 //
+#define FCH_SPI_MMIO_REG4B_RXBYTECOUNT 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/AgesaModulePkg/Include/Filecode.h b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
new file mode 100644
index 0000000000..726479d79f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Filecode.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * Collectively assign unique filecodes for assert and debug to each source file.
+ *
+ * Publish values for decorated filenames, which can be used for
+ * ASSERT and debug support using a preprocessor define like:
+ * @n <tt> _#define FILECODE MY_C_FILENAME_FILECODE </tt> @n
+ * This file serves as a reference for debugging to associate the code and filename.
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: Include
+ * @e _$Revision: 312538 $ @e \$Date: 2015-02-09 16:53:54 +0800 (Mon, 09 Feb 2015) $
+ */
+
+#ifndef _FILECODE_H_
+#define _FILECODE_H_
+
+#define UNASSIGNED_FILE_FILECODE (0xFFFF)
+
+#endif // _FILECODE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Gnb.h b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
new file mode 100755
index 0000000000..ddc9309d3d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Gnb.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_H_
+#define GNB_H_
+
+#define PVOID UINT64
+
+#endif // GNB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
new file mode 100644
index 0000000000..192e0d6a8b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbDxio.h
@@ -0,0 +1,521 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBDXIO_H_
+#define GNBDXIO_H_
+
+#pragma pack (push, 1)
+
+#include <AGESA.h>
+#include <Gnb.h>
+
+#define MAX_NUMBER_OF_COMPLEXES 16
+
+#define DESCRIPTOR_TERMINATE_GNB 0x40000000ull
+#define DESCRIPTOR_TERMINATE_TOPOLOGY 0x20000000ull
+#define DESCRIPTOR_ALLOCATED 0x10000000ull
+#define DESCRIPTOR_PLATFORM 0x08000000ull
+#define DESCRIPTOR_COMPLEX 0x04000000ull
+#define DESCRIPTOR_SILICON 0x02000000ull
+#define DESCRIPTOR_PCIE_WRAPPER 0x01000000ull
+#define DESCRIPTOR_PCIE_ENGINE 0x00800000ull
+#define DESCRIPTOR_CXL_ENGINE 0x00200000ull
+
+#define SILICON_CXL_CAPABLE 0x00008000ull
+
+#define DESCRIPTOR_ALL_WRAPPERS (DESCRIPTOR_PCIE_WRAPPER)
+#define DESCRIPTOR_ALL_ENGINES (DESCRIPTOR_PCIE_ENGINE | DESCRIPTOR_CXL_ENGINE)
+
+#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))
+
+typedef UINT16 PCIE_ENGINE_INIT_STATUS;
+
+///
+/// Engine Configuration
+///
+typedef struct {
+ IN UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ IN UINT16 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ IN UINT16 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+} PCIE_ENGINE;
+
+///
+/// PCIe port misc extended controls
+///
+typedef struct {
+ IN UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ IN UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ IN UINT8 CsLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to chipset
+ IN UINT8 Reserved0 : 5; ///< Unused space
+} PORT_MISC_CONTROL;
+
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ IN UINT8 PortPresent; ///< Enable PCIe port for initialization.
+ IN UINT8 FunctionNumber : 3; ///< Reserved for future use
+ IN UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ IN UINT8 LinkSpeedCapability : 4; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ IN UINT8 LinkAspm : 4; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ IN UINT8 LinkHotplug; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ IN UINT16 SlotNum; ///< Physical Slot Number
+ IN PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ IN UINT8 Reserved1; ///< Reserved for future use
+} PORT_DATA;
+
+typedef struct {
+ UINT8 LinkSpeed;
+ UINT8 MaxPayloadSupport;
+ UINT8 AspmCapability;
+ UINT8 PciPmL1_1;
+ UINT8 PciPmL1_2;
+ UINT8 AspmL1_1;
+ UINT8 AspmL1_2;
+ UINT8 EsmSupport;
+ UINT8 LtrSupport;
+ UINT8 SurpriseDownErrorReport;
+ UINT8 TenBitTagSupport;
+ UINT8 AriForwarding;
+ UINT8 AcsSupport;
+ UINT8 AcsSourceValidation;
+ UINT8 AcsTranslationBlocking;
+ UINT8 AcsP2pRequestRedirect;
+ UINT8 AcsP2pCompletionRedirect;
+ UINT8 AcsUpstreamForwarding;
+ UINT8 AcsP2pEgressControl;
+ UINT8 AcsDirectTranslatedP2p;
+ UINT8 LaneMargining;
+ UINT8 DataLinkFeature;
+ UINT8 DownstreamPortContainment;
+ UINT8 AdvancedErrorReporting;
+ UINT8 ECRCSupport;
+ UINT8 MulticastEnable;
+ UINT8 NativePCIeEnclosureManagement;
+ UINT8 Capability1Address;
+ UINT8 Capability1Data;
+ UINT8 Capability2Address;
+ UINT8 Capability2Data;
+ UINT8 Capability3Address;
+ UINT8 Capability3Data;
+ UINT8 Capability4Address;
+ UINT8 Capability4Data;
+} PORT_CAPABILITIES;
+
+///
+/// PCIe PORT_FEATURES
+///
+typedef struct {
+ UINT8 LinkSpeedControl;
+ UINT8 MaxPayloadSizeControl;
+ UINT8 ESMControl;
+ UINT8 LTRControl;
+ UINT8 DataLinkFeatureExchangeControl;
+ UINT8 TenBitTagControl;
+ UINT8 ARIControl;
+ UINT8 ACSControl;
+ UINT8 RxLaneMarginingControl;
+ UINT8 DynLanesPwrState;
+ UINT8 L1PowerDown;
+ UINT8 L11PowerDown;
+ UINT8 L12PowerDown;
+ UINT8 AutoSpdChngEn;
+ UINT8 TurnOffUnusedLanes;
+} PORT_FEATURES;
+
+typedef struct {
+ UINT8 SpcGen1 : 1; ///< SPC Mode 2P5GT
+ UINT8 SpcGen2 : 1; ///< SPC Mode 5GT
+ UINT8 SpcGen3 : 2; ///< SPC Mode 8GT
+ UINT8 SpcGen4 : 2; ///< SPC Mode 16GT
+ UINT8 SpcGen5 : 2; ///< SPC Mode 32GT
+} SPC_MODE;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT32 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT32 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset Mask
+ UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnable
+ UINT32 UNUSED2 : 7; ///< Currently unassigned - for alignment
+} GEN3_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset Mask
+ UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEnable
+ UINT32 UNUSED3 : 13; ///< Currently unassigned - for alignment
+} GEN4_LANE_CNTL;
+
+typedef struct {
+ UINT32 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT32 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset Mask
+ UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnable
+ UINT32 PrecodeRequest : 1; ///< Precoding Request
+ UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ To High Rate Support
+ UINT32 UNUSED4 : 11; ///< Currently unassigned - for alignment
+} GEN5_LANE_CNTL;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor0 : 5; ///< PostCursor0
+ UINT32 LcFapeReqPreCursor0 : 4; ///< PreCursor0
+ UINT32 LcFapeReqPostCursor1 : 5; ///< PostCursor1
+ UINT32 LcFapeReqPreCursor1 : 4; ///< PreCursor1
+ UINT32 LcFapeReqPostCursor2 : 5; ///< PostCursor2
+ UINT32 LcFapeReqPreCursor2 : 4; ///< PreCursor2
+ UINT32 UNUSED6 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_0;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor3 : 5; ///< PostCursor3
+ UINT32 LcFapeReqPreCursor3 : 4; ///< PreCursor3
+ UINT32 LcFapeReqPostCursor4 : 5; ///< PostCursor4
+ UINT32 LcFapeReqPreCursor4 : 4; ///< PreCursor4
+ UINT32 LcFapeReqPostCursor5 : 5; ///< PostCursor5
+ UINT32 LcFapeReqPreCursor5 : 4; ///< PreCursor5
+ UINT32 UNUSED7 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_1;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor6 : 5; ///< PostCursor6
+ UINT32 LcFapeReqPreCursor6 : 4; ///< PreCursor6
+ UINT32 LcFapeReqPostCursor7 : 5; ///< PostCursor7
+ UINT32 LcFapeReqPreCursor7 : 4; ///< PreCursor7
+ UINT32 LcFapeReqPostCursor8 : 5; ///< PostCursor8
+ UINT32 LcFapeReqPreCursor8 : 4; ///< PreCursor8
+ UINT32 UNUSED8 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_2;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor9 : 5; ///< PostCursor9
+ UINT32 LcFapeReqPreCursor9 : 4; ///< PreCursor9
+ UINT32 LcFapeReqPostCursor10 : 5; ///< PostCursor10
+ UINT32 LcFapeReqPreCursor10 : 4; ///< PreCursor10
+ UINT32 LcFapeReqPostCursor11 : 5; ///< PostCursor11
+ UINT32 LcFapeReqPreCursor11 : 4; ///< PreCursor11
+ UINT32 UNUSED9 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_3;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor12 : 5; ///< PostCursor12
+ UINT32 LcFapeReqPreCursor12 : 4; ///< PreCursor12
+ UINT32 LcFapeReqPostCursor13 : 5; ///< PostCursor13
+ UINT32 LcFapeReqPreCursor13 : 4; ///< PreCursor13
+ UINT32 LcFapeReqPostCursor14 : 5; ///< PostCursor14
+ UINT32 LcFapeReqPreCursor14 : 4; ///< PreCursor14
+ UINT32 UNUSED10 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_4;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor15 : 5; ///< PostCursor15
+ UINT32 LcFapeReqPreCursor15 : 4; ///< PreCursor15
+ UINT32 LcFapeReqPostCursor16 : 5; ///< PostCursor16
+ UINT32 LcFapeReqPreCursor16 : 4; ///< PreCursor16
+ UINT32 LcFapeReqPostCursor17 : 5; ///< PostCursor17
+ UINT32 LcFapeReqPreCursor17 : 4; ///< PreCursor17
+ UINT32 UNUSED11 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_5;
+
+typedef struct {
+ UINT32 LcFapeReqPostCursor18 : 5; ///< PostCursor18
+ UINT32 LcFapeReqPreCursor18 : 4; ///< PreCursor18
+ UINT32 LcFapeReqPostCursor19 : 5; ///< PostCursor19
+ UINT32 LcFapeReqPreCursor19 : 4; ///< PreCursor19
+ UINT32 LcFapeReqPostCursor20 : 5; ///< PostCursor20
+ UINT32 LcFapeReqPreCursor20 : 4; ///< PreCursor20
+ UINT32 UNUSED12 : 5; ///< Currently unassigned - for alignment
+} LC_FAPE_GROUP_6;
+
+///
+/// PCIe port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 IsBmcLocation : 1; ///< Port Location of BMC
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 TXDeEmphasis : 4; ///< TX De-emphasis
+ UINT8 TXMargin : 3; ///< TX Margin
+ UINT8 UNUSED1 : 1; ///< Currently unassigned - for alignment
+
+ PORT_CAPABILITIES PortCapabilities; ///< Port Capabilities CBS
+
+ SPC_MODE SpcMode;
+
+ GEN3_LANE_CNTL LaneEqualizationCntl;
+ GEN4_LANE_CNTL Gen4LaneEqualizationCntl;
+ GEN5_LANE_CNTL Gen5LaneEqualizationCntl;
+
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 UNUSED4 : 1; ///< Currently unassigned - for alignment
+ UINT8 SRIS_SRNS : 1; ///< SRIS SRNS
+ UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SKP Support
+ UINT8 CcixControl : 1; ///< Bit to enable/disable ESM
+ UINT8 CxlControl : 1; ///< Bit to enable CXL Capability
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 SlotPowerLimitScale : 2; ///< Slot Power Limit Scale
+ UINT8 UNUSED5 : 1; ///< Currently unassigned - for alignment
+
+ UINT8 RxMarginPersistence : 1; ///< Bit to enable/disable Rx Margin persistence mode
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 TxVetting : 1; ///< Gen4 Tx Vetting
+ UINT8 RxVetting : 1; ///< Gen4 Rx Vetting
+ UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetting
+ UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetting
+
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 DlfCapDisable : 1; ///< DLF Capability 1:Disable 0:Enable
+ UINT8 DlfExchangeDisable : 1; ///< DLF Exchange 1:Disable 0:Enable
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+
+ UINT8 EqSearchMode : 2; ///< Equalization Search Mode
+ UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ
+ UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 EQ Phase2/3
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset value
+
+ UINT8 EqSearchModeGen4 : 2; ///< Equalization Search Mode for Gen4
+ UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass phase3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset value
+ UINT8 EqSearchModeGen5 : 2; ///< Equalization Search Mode for Gen5
+ UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass phase3 EQ
+ UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass phase2/3 EQ
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset value
+
+ UINT16 PsppPolicyDC; ///< Pspp Policy DC
+ UINT16 PsppPolicyAC; ///< Pspp Policy AC
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+
+ LC_FAPE_GROUP_0 LcFapeSettingsGroup0;
+ LC_FAPE_GROUP_1 LcFapeSettingsGroup1;
+ LC_FAPE_GROUP_2 LcFapeSettingsGroup2;
+ LC_FAPE_GROUP_3 LcFapeSettingsGroup3;
+ LC_FAPE_GROUP_4 LcFapeSettingsGroup4;
+ LC_FAPE_GROUP_5 LcFapeSettingsGroup5;
+ LC_FAPE_GROUP_6 LcFapeSettingsGroup6;
+
+ UINT8 ForceSteering : 1; ///< Steering is forced
+ UINT8 EsmUsTxPreset : 4; ///< ESM Upstream Tx Preset
+ UINT8 UNUSED13 : 3; ///< Currently unassigned - for alignment
+
+ // Used by DXE
+ PORT_FEATURES PortFeatures; ///< Port Features CBS
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 I2CMuxInfo; ///< First I2c Mux on Bus
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:SRIS 2:SRNS 3:SRNS in SRIS 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 ClkReq : 4; ///< ClkReq:[0:3]
+ UINT8 EqPreset : 4; ///< EqPreset:[4:7]
+ UINT8 LinkAspmL1_1 : 1; ///< Enable PM L1 SS L1.1
+ UINT8 LinkAspmL1_2 : 1; ///< Enable PM L1 SS L1.2
+ UINT8 EsmControl : 1; ///< Bit to enable/disable ESM
+ UINT8 EsmDsTxPreset : 4; ///< ESM Downstream Tx Preset
+ UINT8 ClkReqFilterEn : 1; ///< Controls filtering of CLKREQb signal in LC in order to avoid false L1 substate entries/exits.
+} PCIE_PORT_CONFIG;
+
+///
+/// CXL port configuration info
+///
+typedef struct {
+ PORT_DATA PortData; ///< Port data
+ UINT8 StartCoreLane; ///< Start Core Lane
+ UINT8 EndCoreLane; ///< End Core lane
+ UINT8 NativeDevNumber : 5; ///< Native PCI device number of the port
+ UINT8 NativeFunNumber : 3; ///< Native PCI function number of the port
+ UINT8 CoreId : 4; ///< PCIe core ID
+ UINT8 PortId : 4; ///< Port ID on wrapper
+ PCI_ADDR Address; ///< PCI address of the port
+ UINT8 PcieBridgeId : 7; ///< IOC PCIe bridge ID
+ UINT8 UNUSED0 : 1; ///< Currently unassigned - for alignment
+ UINT8 LogicalBridgeId; ///< Logical Bridge ID
+ UINT8 SlotPowerLimit; ///< Slot Power Limit
+ UINT8 MaxPayloadSize; ///< Max_Payload_Size
+
+ UINT8 CxlIndex;
+ UINT8 CxlDeviceType : 2; ///< Type of CXL device connected
+ UINT8 CxlVersion : 2; ///< Version of CXL device connected (1=CXL1.1, 2=CXL2.0)
+ UINT8 IsCxlScanned : 1; ///< Indicates if the CXL device has been scanned
+ UINT8 ReportToMpioinDxe : 1; ///< Indicates if the CXL info needs to be reported to MPIO in DXE
+ UINT8 UNUSED1 : 2; ///< Currently unassigned - for alignment
+
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT32 Mmio32Base;
+ UINT32 Mmio32Size;
+ UINT64 Mmio64Base;
+ UINT64 Mmio64Size;
+ UINT32 Mmio32Gran;
+} PCIE_CXL_CONFIG;
+
+///
+/// Descriptor header
+///
+typedef struct {
+ UINT32 DescriptorFlags; ///< Descriptor flags
+ UINT16 Parent; ///< Offset of parent descriptor
+ UINT16 Peer; ///< Offset of the peer descriptor
+ UINT16 Child; ///< Offset of the list of child descriptors
+} PCIE_DESCRIPTOR_HEADER;
+
+///
+/// Engine configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor header
+ PCIE_ENGINE EngineData; ///< Engine Data
+ PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initialization Status
+ UINT8 Scratch; ///< Scratch pad
+ union {
+ PCIE_PORT_CONFIG Port; ///< PCIe port configuration data
+ PCIE_CXL_CONFIG Cxl; ///< CXL Configuration data
+ } Type;
+} PCIE_ENGINE_CONFIG;
+
+///
+/// Wrapper configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 WrapId; ///< Wrapper ID
+ UINT8 CcixCoreConfig; ///< Ccix CORE Configuration
+ UINT8 StartPhyLane; ///< Start PHY Lane
+ UINT8 EndPhyLane; ///< End PHY Lane
+ UINT8 StartDxioLane; ///< Start Dxio Lane (Translated)
+ UINT8 EndDxioLane; ///< End Dxio Lane (Translated)
+ struct {
+ UINT8 PowerOffUnusedLanes : 1; ///< Power Off unused lanes
+ UINT8 PowerOffUnusedPlls : 1; ///< Power Off unused Plls
+ UINT8 ClkGating : 1; ///< TXCLK gating
+ UINT8 LclkGating : 1; ///< LCLK gating
+ UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock gating PLL power down
+ UINT8 PllOffInL1 : 1; ///< PLL off in L1
+ UINT8 AccessEncoding : 1; ///< Reg access encoding
+ UINT8 CoreReversed : 1; ///< Indicates lanes are reversed in package connection
+ } Features;
+ UINT8 MasterPll; ///< Bitmap of master PLL
+ UINT32 AcsSupport : 1; ///< Acs Support
+ UINT32 LtrSupport : 1; ///< LTR Support
+ UINT32 AriForwarding : 1; ///< ARI Forwarding
+ UINT32 LaneMargining : 1; ///< Lane Margining
+ UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM
+ UINT32 DownstreamPortContainment : 1; ///< Downstream port containment
+ UINT32 AdvancedErrorReporting : 1; ///< Advacned Error Reporting
+ UINT32 ECRCSupport : 2; ///< ECRC Capability
+ UINT32 Reserved : 23; ///< Reserved bits
+} PCIE_WRAPPER_CONFIG;
+
+///
+/// Silicon configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 SocketId; ///< Socket ID
+ UINT8 DieNumber; ///< Module ID
+ UINT8 RBIndex; ///< Physical Root Bridge
+ UINT8 InstanceId; ///< Logical Instance Identifier
+ PCI_ADDR Address; ///< PCI address of GNB host bridge
+ UINT16 StartLane; ///< Start Lane of this node
+ UINT16 EndLane; ///< End Lane of this node
+ UINT8 BusNumberLimit; ///< Last Bus Number assigned to this node
+ UINT8 SbPresent : 1; ///< Set to 1 if FCH connected to this NBIO
+ UINT8 SmuPresent : 1; ///< Set to 1 if SMU connected to this NBIO
+ UINT8 MP_Instance : 6; ///< MP Instance
+ UINT8 LogicalRBIndex; ///< Logical Root Bridge
+ UINT8 NumEngineDesc; ///< Total number of lane bifurcation descriptors
+} PCIE_SILICON_CONFIG;
+
+typedef PCIE_SILICON_CONFIG GNB_HANDLE;
+
+///
+/// Complex configuration data
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ UINT8 NodeId; ///< Processor Node ID
+ UINT8 Reserved; ///< For alignment
+} PCIE_COMPLEX_CONFIG;
+
+///
+/// PCIe platform configuration info
+///
+typedef struct {
+ PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor Header
+ PVOID Reserved1; ///< Reserved
+ UINT32 Reserved2; ///< Reserved
+ UINT32 PhyConfigData; ///< Phy Configuration Data
+ UINT32 Reserved3; ///< Reserved
+ UINT32 Reserved4; ///< Reserved
+ UINT32 PsppTuningParams; ///< Tuning parameters for PSPP
+ UINT32 PsppTuningParams2; ///< Tuning parameters 2 for PSPP
+ UINT8 Reserved5; ///< Reserved
+ UINT8 PsppPolicy; ///< PSPP policy
+ UINT8 Reserved6; ///< Reserved
+ UINT8 RootBridgesPerSocket; ///< Number of root bridges per socket
+ PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES]; ///< Complex
+} PCIE_PLATFORM_CONFIG;
+
+///
+/// PCIe Engine Description
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor on wrapper
+ ///< Bit30 - Descriptor allocated for PCIe port
+ PCIE_ENGINE EngineData; ///< Engine Data
+} PCIE_ENGINE_DESCRIPTOR;
+#pragma pack (pop)
+
+#endif // GNBDXIO_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
new file mode 100644
index 0000000000..90f52cca7b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS.h
@@ -0,0 +1,18 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _GNBREGISTERSRS_H_
+#define _GNBREGISTERSRS_H_
+
+#include "GnbRegistersRS/IOHC.h"
+
+#ifndef NBIO_SPACE
+#define NBIO_SPACE(HANDLE, ADDRESS) (ADDRESS + (HANDLE->RBIndex << 20))
+#endif
+
+#endif /*_GNBREGISTERSRS_H_*/
diff --git a/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
new file mode 100644
index 0000000000..b1a95237de
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/GnbRegistersRS/IOHC.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _IOHC_H_
+#define _IOHC_H_
+
+// Bitfield Description : DBG MMIO enable.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_EN_OFFSET 0
+
+// Bitfield Description : Locks the DBG MMIO address range and enable until the next warm reset.
+#define DBG_BASE_ADDR_LO_DBG_MMIO_LOCK_OFFSET 1
+
+#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 0x13c102f0UL
+
+#endif /* _IOHC_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
new file mode 100644
index 0000000000..f5cc5e2228
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Guid/GnbPcieInfoHob.h
@@ -0,0 +1,31 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNB_PCIE_HOB_INFO_H_
+#define GNB_PCIE_HOB_INFO_H_
+
+#define _GNB_PCIE_HOB_INFO_GUID \
+{ \
+ 0x3eb1d90, 0xce14, 0x40d8, 0xa6, 0xba, 0x10, 0x3a, 0x8d, 0x7b, 0xd3, 0x2d \
+}
+extern EFI_GUID gGnbPcieHobInfoGuid;
+
+#pragma pack (push, 1)
+#define MAX_NUMBER_OF_CORES_PER_COMPLEX 3
+#define MAX_NUMBER_OF_PORTS_PER_COMPLEX 22
+
+/// PCIe information HOB data
+typedef struct _GNB_PCIE_INFORMATION_DATA_HOB {
+ EFI_HOB_GUID_TYPE EfiHobGuidType; ///< GUID Hob type structure
+ PCIE_PLATFORM_CONFIG PciePlatformConfigHob; ///< Platform Config Structure
+ UINT32 ComplexConfigs; ///< Allocation for Max Complex Structure suported
+} GNB_PCIE_INFORMATION_DATA_HOB;
+
+#pragma pack (pop)
+
+#endif /* GNB_PCIE_HOB_INFO_H_ */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
new file mode 100644
index 0000000000..dc773737b9
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+ Contains interface to the AMD AGESA library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_BASE_LIB_H_
+#define AMD_BASE_LIB_H_
+
+#include "Uefi.h"
+#include "AMD.h"
+
+#endif // AMD_BASE_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
new file mode 100644
index 0000000000..9d9892aa30
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/AmdPspMboxLibV2.h
@@ -0,0 +1,43 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+/* $NoKeywords:$ */
+
+/**
+ * @file
+ *
+ * PSP Mailbox related functions Prototype definition
+ *
+ *
+ * @xrefitem bom "File Content Label" "Release Content"
+ * @e project: AGESA
+ * @e sub-project: PSP
+ * @e \$Revision: 312133 $ @e \$Date: 2015-02-03 02:47:45 +0800 (Tue, 03 Feb 2015) $
+ */
+
+#ifndef _PSP_MBOX_H_
+#define _PSP_MBOX_H_
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ );
+
+#endif //_PSP_MBOX_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
new file mode 100644
index 0000000000..51935f413a
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricTopologyLib.h
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BASE_FABRIC_TOPOLOGY_LIB_H_
+#define BASE_FABRIC_TOPOLOGY_LIB_H_
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ );
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ );
+
+#endif // BASE_FABRIC_TOPOLOGY_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
new file mode 100644
index 0000000000..cae3aff9b3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.h
@@ -0,0 +1,16 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_BASE_LIB_H_
+#define _FCH_BASE_LIB_H_
+
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/BaseLib.h>
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
new file mode 100644
index 0000000000..345e39adce
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdLib.h
@@ -0,0 +1,413 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FCH_ESPI_CMD_LIB_H_
+#define _FCH_ESPI_CMD_LIB_H_
+
+#include <Uefi/UefiBaseType.h>
+
+#define MAX_ESPI_RETRY 100000ul
+//
+// Cycle Type
+//
+#define CYCLE_TYPE_FLASH_READ 0
+#define CYCLE_TYPE_FLASH_WRITE 1
+#define CYCLE_TYPE_FLASH_ERASE 2
+#define CYCLE_TYPE_RPMC_OP1 3
+#define CYCLE_TYPE_RPMC_OP2 4
+
+// RPMC OP1/OP2 Command Payload Max Length (512 Bits)
+#define RPMC_CMD_PAYLOAD_MAX_LEN 0x40
+
+//
+// Master Registers
+//
+#define SET_CONFIGURATION 0
+#define GET_CONFIGURATION 1
+#define IN_BAND_RESET 2
+#define PC_MSG_DOWN_STREAM 4
+#define VM_DOWN_STREAM 5
+#define OOB_DOWN_STREAM 6
+#define FA_DOWN_STREAM 7
+
+// ESPIx00
+#define DNCMD_STATUS BIT3
+
+// ESPIx2C Master Capability
+#define MASTER_FA_SUPPORT BIT0
+#define MASTER_OOB_SUPPORT BIT1
+#define MASTER_VW_SUPPORT BIT2
+#define MASTER_PERIPHERAL_SUPPORT BIT3
+
+// ESPIx68 Slave0 Configuration
+#define SLAVE_FA_ENABLE BIT0
+#define SLAVE_OOB_ENABLE BIT1
+#define SLAVE_VW_ENABLE BIT2
+#define SLAVE_PC_ENABLE BIT3
+
+/// eSPIx00 eSPI Software Specific Register 0
+#define ESPI_DN_TXHDR_0 0x00
+typedef union {
+ struct {
+ UINT32 SWCommandType : 3;
+ UINT32 CommandStatus : 1;
+ UINT32 PutFlashNpTranActive : 1;
+ UINT32 Reserved : 3;
+ UINT32 DnCmdHdata0 : 8;
+ UINT32 DnCmdHdata1 : 8;
+ UINT32 DnCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx00_DN_TXHDR0;
+
+/// eSPIx04 eSPI Software Specific Register 1
+#define ESPI_DN_TXHDR_1 0x04
+typedef union {
+ struct {
+ UINT32 DnCmdHdata3 : 8;
+ UINT32 DnCmdHdata4 : 8;
+ UINT32 DnCmdHdata5 : 8;
+ UINT32 DnCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx04_DN_TXHDR1;
+
+#define ESPI_DN_TXHDR_2 0x08
+typedef union {
+ struct {
+ UINT32 DnCmdHdata7 : 8;
+ UINT32 Reserved : 24;
+ } Field;
+ UINT32 Value;
+} ESPIx08_DN_TXHDR2;
+
+#define ESPI_DN_TXDATA_PORT 0x0C
+typedef union {
+ struct {
+ UINT32 DnTxData0 : 8;
+ UINT32 DnTxData1 : 8;
+ UINT32 DnTxData2 : 8;
+ UINT32 DnTxData3 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx0C_DN_TXDATA_PORT;
+
+#define ESPI_UP_RXHDR_0 0x10
+typedef union {
+ struct {
+ UINT32 UpCommandType : 3;
+ UINT32 UpCommandStatus : 1;
+ UINT32 SlaveSel : 2;
+ UINT32 Reserved : 2;
+ UINT32 UpCmdHdata0 : 8;
+ UINT32 UpCmdHdata1 : 8;
+ UINT32 UpCmdHdata2 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx10_UP_RXHDR0;
+
+#define ESPI_UP_RXHDR_1 0x14
+typedef union {
+ struct {
+ UINT32 UpCmdHdata3 : 8;
+ UINT32 UpCmdHdata4 : 8;
+ UINT32 UpCmdHdata5 : 8;
+ UINT32 UpCmdHdata6 : 8;
+ } Field;
+ UINT32 Value;
+} ESPIx14_UP_RXHDR1;
+
+#define ESPI_UP_RXDATA_PORT 0x18
+
+/// eSPIx2C eSPI Master Capability
+#define ESPI_MASTER_CAP 0x2C
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelSupport : 1;
+ UINT32 OOBMessageChannelSupport : 1;
+ UINT32 VWChannelSupport : 1;
+ UINT32 PChannelSupport : 1;
+ UINT32 MasterVersion : 3;
+ UINT32 FlashAccessChannelMaxPayload : 3;
+ UINT32 OOBMessageChannelMaxPayload : 3;
+ UINT32 OperatingMaxVWCount : 6;
+ UINT32 PChannelMaxPayloadSize : 3;
+ UINT32 NumberOfSlave : 3;
+ UINT32 OperatingSupportFreq : 3;
+ UINT32 IOMode : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheck : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx2C_MASTER_CAP;
+
+/// eSPIx30 eSPI Global Control 0
+#define ESPI_GLOBAL_CTRL0 0x30
+typedef union {
+ struct {
+ UINT32 WdgEn : 1;
+ UINT32 WaitChkEn : 1;
+ UINT32 PrClkgatEn : 1;
+ UINT32 AlStopEn : 1;
+ UINT32 AlIdleTimer : 3;
+ UINT32 RgDbgclkGatingEn : 1;
+ UINT32 WdgCnt : 16;
+ UINT32 WaitCnt : 6;
+ UINT32 PrRstEnPltrst : 1;
+ UINT32 SafsClkGateEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx30_GLOBAL_CTRL0;
+
+/// eSPIx68 eSPI Slave0 Configuration
+#define ESPI_SLAVE0_CONFIG 0x68
+typedef union {
+ struct {
+ UINT32 FlashAccessChannelEnable : 1;
+ UINT32 OOBMessageChannelEnable : 1;
+ UINT32 VWChannelEnable : 1;
+ UINT32 PChannelEnable : 1;
+ UINT32 FlashSharingMode : 1;
+ UINT32 FlashMaxPayloadSize : 3;
+ UINT32 PutFlashNpHeaderDataEn : 1;
+ UINT32 PutFlashNpHeaderEn : 1;
+ UINT32 SafsDeferValidEn : 1;
+ UINT32 FlashModifierEn : 1;
+ UINT32 Reserved_24_12 : 13;
+ UINT32 OperatingFreq : 3;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 CRCCheckingEnable : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx68_SLAVE0_CONFIG;
+
+/// eSPIx70 eSPI Slave0 Interrupt Status
+#define ESPI_SLAVE0_INT_STS 0x70
+typedef union {
+ struct {
+ UINT32 BusErrInt : 1;
+ UINT32 WaitTimeoutInt : 1;
+ UINT32 CrcErrInt : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 NoRspInt : 1;
+ UINT32 FatalErrInt : 1;
+ UINT32 NonFatalErrInt : 1;
+ UINT32 UnknownRspInt : 1;
+ UINT32 UnknownCtInt : 1;
+ UINT32 UnsucssCplInt : 1;
+ UINT32 IllegalTagInt : 1;
+ UINT32 IllegalLenInt : 1;
+ UINT32 RxOobOverflowInt : 1;
+ UINT32 RxMsgOverflowInt : 1;
+ UINT32 RxFlashOverflowInt : 1;
+ UINT32 ProtocolErrInt : 1;
+ UINT32 Reserved_16 : 1;
+ UINT32 UpFifoWdgTo : 1;
+ UINT32 MstAbortInt : 1;
+ UINT32 WdgTimeoutInt : 1;
+ UINT32 Reserved_23_20 : 4;
+ UINT32 RxVwGrp0Int : 1;
+ UINT32 RxVwGrp1Int : 1;
+ UINT32 RxVwGrp2Int : 1;
+ UINT32 RxVwGrp3Int : 1;
+ UINT32 DnCmdInt : 1;
+ UINT32 RxMsgInt : 1;
+ UINT32 RxOobInt : 1;
+ UINT32 FlashReqInt : 1;
+ } Field;
+ UINT32 Value;
+} ESPIx70_SLAVE0_INT_STS;
+
+///
+/// Slave Registers
+///
+#define SLAVE_REG_ID 0x04
+#define SLAVE_GENERAL_CAPCFG 0x08
+#define SLAVE_PC_CAPCFG 0x10
+#define SLAVE_VW_CAPCFG 0x20
+#define SLAVE_OOB_CAPCFG 0x30
+#define SLAVE_FA_CAPCFG 0x40
+#define SLAVE_FA_CAPCFG2 0x44
+
+/// Offset 04h: Device Identification
+typedef union {
+ struct {
+ UINT32 RO_VersionID : 8;
+ UINT32 Reserved_31_8 : 24;
+ } Field;
+ UINT32 Value;
+} ESPI_SL04_DEVICE_ID;
+
+// SLAVE offset 0x08 SLAVE_GENERAL_CAPCFG
+#define SLAVE_FA_SUPPORT BIT3
+#define SLAVE_OOB_SUPPORT BIT2
+#define SLAVE_VW_SUPPORT BIT1
+#define SLAVE_PERIPHERAL_SUPPORT BIT0
+/// Offset 08h: General Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 RO_PCSupported : 1;
+ UINT32 RO_VWSupported : 1;
+ UINT32 RO_OOBMsgSupported : 1;
+ UINT32 RO_FASupported : 1;
+ UINT32 Reserved_7_3 : 4;
+ UINT32 Reserved_11_8 : 4;
+ UINT32 RO_MaxWaitStateAllowed : 4;
+ UINT32 RO_MaxFreqSupported : 3;
+ UINT32 RO_OpenDrainAlertSupported : 1;
+ UINT32 OperatingFreq : 3;
+ UINT32 OpenDrainAlertSelect : 1;
+ UINT32 RO_IOModeSupported : 2;
+ UINT32 IOModeSelect : 2;
+ UINT32 AlertMode : 1;
+ UINT32 Reserved_29 : 1;
+ UINT32 ResponseModifierEn : 1;
+ UINT32 CRCCheckingEn : 1;
+ } Field;
+ UINT32 Value;
+} ESPI_SL08_SLAVE_GENERAL_CAPCFG;
+
+/// Offset 10h: Channel 0 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 PCEn : 1;
+ UINT32 RO_PCReady : 1;
+ UINT32 BusMasterEn : 1;
+ UINT32 Reserved_3 : 1;
+ UINT32 RO_PCMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 PCMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_11 : 1;
+ UINT32 PCMaxReadRequestSize : 3;
+ UINT32 Reserved_31_15 : 17;
+ } Field;
+ UINT32 Value;
+} ESPI_SL10_SLAVE_PC_CAPCFG;
+
+/// Offset 20h: Channel 1 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 VWEn : 1;
+ UINT32 RO_VWReady : 1;
+ UINT32 Reserved_7_2 : 6;
+ UINT32 RO_MaxVWCntSupported : 6;
+ UINT32 Reserved_15_14 : 2;
+ UINT32 OpMaxVWCnt : 6;
+ UINT32 Reserved_31_22 : 10;
+ } Field;
+ UINT32 Value;
+} ESPI_SL20_SLAVE_VW_CAPCFG;
+
+/// Offset 30h: Channel 2 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 OOBEn : 1;
+ UINT32 RO_OOBReady : 1;
+ UINT32 Reserved_3_2 : 2;
+ UINT32 RO_MsgChMaxPayloadSizeSupported : 3;
+ UINT32 Reserved_7 : 1;
+ UINT32 MsgChMaxPayloadSizeSelected : 3;
+ UINT32 Reserved_31_11 : 21;
+ } Field;
+ UINT32 Value;
+} ESPI_SL30_SLAVE_OOB_CAPCFG;
+
+/// Offset 40h: Channel 3 Capabilities and Configurations
+typedef union {
+ struct {
+ UINT32 FAEn : 1;
+ UINT32 RO_FAReady : 1;
+ UINT32 FlashBlockEraseSize : 3;
+ UINT32 RO_ChMaxPayloadSizeSupported : 3;
+ UINT32 ChMaxPayloadSizeSelected : 3;
+ UINT32 RO_FlashSharingMode : 1;
+ UINT32 ChMaxReadReqSize : 3;
+ UINT32 Reserved_15 : 1;
+ UINT32 RO_FlashSharingCapabilitySupported : 2;
+ UINT32 Reserved_19_18 : 2;
+ UINT32 RO_RPMCCounterOn1stDevice : 4;
+ UINT32 RO_RPMCOp1On1stDevice : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL40_SLAVE_FA_CAPCFG;
+
+/// Offset 44h: Channel 3 Capabilities and Configurations2
+typedef union {
+ struct {
+ UINT32 RO_TargetMaxReadReqSizeSupported : 3;
+ UINT32 Reserved_7_3 : 5;
+ UINT32 RO_TargetFlashEraseBlockSize : 8;
+ UINT32 RO_TargetRPMCSupported : 6;
+ UINT32 RO_NumOfRPMCdevices : 2;
+ UINT32 Reserved_31_24 : 8;
+ } Field;
+ UINT32 Value;
+} ESPI_SL44_SLAVE_FA_CAPCFG2;
+
+//
+// eSPI Command functions
+//
+VOID
+FchEspiCmd_InBandRst (
+ IN UINT32 EspiBase
+ );
+
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ );
+
+VOID
+FchEspiCmd_SetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr,
+ IN UINT32 Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp1 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ IN UINT8 *Data
+ );
+
+EFI_STATUS
+FchEspiCmd_SafsRpmcOp2 (
+ IN UINT32 EspiBase,
+ IN UINT8 RpmcFlashDev,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
new file mode 100755
index 0000000000..19688e2548
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConfigLib.h
@@ -0,0 +1,16 @@
+/** @file
+ GNB PCIe Library definition.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GNBPCIECONFIG_LIB_H_
+#define GNBPCIECONFIG_LIB_H_
+
+#include <GnbDxio.h>
+#include <Library/PcieConfigLib.h>
+
+#endif // GNBPCIECONFIG_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
new file mode 100644
index 0000000000..df88274530
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonLibDxe.h
@@ -0,0 +1,37 @@
+/** @file
+ Header file of AMD NBIO Common DXE library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOCOMMONLIBDXE_H_
+#define NBIOCOMMONLIBDXE_H_
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ );
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ );
+
+#endif // NBIOCOMMONLIBDXE_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
new file mode 100755
index 0000000000..4fec578a9f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleLib.h
@@ -0,0 +1,62 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIOHANDLELIB_LIB_H_
+#define NBIOHANDLELIB_LIB_H_
+
+#include <GnbDxio.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ );
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ );
+
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define GnbGetSocketId(Handle) (Handle != NULL ? (Handle)->SocketId : 0)
+#define GnbGetDieNumber(Handle) (Handle != NULL ? (Handle)->DieNumber : 0)
+#define GnbGetRBIndex(Handle) (Handle != NULL ? (Handle)->RBIndex : 0)
+
+#endif // NBIOHANDLELIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
new file mode 100644
index 0000000000..9f53746814
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigLib.h
@@ -0,0 +1,283 @@
+/** @file
+ Helper functions to access PCIe configuration data area.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PCIECONFIGLIB_LIB_H_
+#define PCIECONFIGLIB_LIB_H_
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_WRAPPER_CALLBACK) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+typedef VOID (*PCIE_RUN_ON_ENGINE_CALLBACK2) (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+typedef VOID (*PCIE_RUN_ON_WRAPPER_CALLBACK2) (
+ IN PCIE_WRAPPER_CONFIG *Wrapper,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+typedef AGESA_STATUS (*PCIE_RUN_ON_DESCRIPTOR_CALLBACK) (
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ );
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ );
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ );
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ );
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ );
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ );
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ );
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ );
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ );
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ );
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ );
+
+#define PcieConfigGetParentWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetParent (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetParentSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetParentComplex(Descriptor) ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX, &((Descriptor)->Header)))
+#define PcieConfigGetPlatform(Descriptor) ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM, &((Descriptor)->Header)))
+#define PcieConfigGetChildWrapper(Descriptor) ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_WRAPPERS, &((Descriptor)->Header)))
+#define PcieConfigGetChildEngine(Descriptor) ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES, &((Descriptor)->Header)))
+#define PcieConfigGetChildSilicon(Descriptor) ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON, &((Descriptor)->Header)))
+#define PcieConfigGetNextDescriptor(Descriptor) ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : ((Descriptor + 1))))
+#define PcieConfigIsPcieEngine(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_PCIE_ENGINE) != 0) : FALSE)
+#define PcieConfigIsSbPcieEngine(Engine) ((Engine != NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.SbLink)) : FALSE)
+#define PcieConfigIsEngineAllocated(Descriptor) ((Descriptor != NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_ALLOCATED) != 0) : FALSE)
+#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) if (Descriptor != NULL) (Descriptor)->Header.DescriptorFlags |= SetDescriptorFlags
+#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) if (Descriptor != NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags &= (~(ResetDescriptorFlags))
+#define PcieInputParsetGetNextDescriptor(Descriptor) ((Descriptor == NULL) ? NULL : ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0) ? NULL : (Descriptor + 1))
+#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination) ((Descriptor == NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor)->DescriptorFlags & Termination) != 0) ? NULL : ((UINT8 *) Descriptor + ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Peer))
+#define GnbGetNextHandle(Descriptor) (GNB_HANDLE *) PcieConfigGetNextTopologyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY)
+#define PcieConfigGetNextDataDescriptor(Descriptor) ((Descriptor->Flags & DESCRIPTOR_TERMINATE_LIST) != 0 ? NULL : (Descriptor + 1))
+
+#endif // PCIECONFIGLIB_LIB_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
new file mode 100644
index 0000000000..f0c6d1ccbb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SMNACCESSLIB_H_
+#define _SMNACCESSLIB_H_
+
+VOID
+SmnRegisterReadS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ OUT VOID *Value
+ );
+
+VOID
+SmnRegisterRMWS (
+ IN UINT32 SegmentNumber,
+ IN UINT32 BusNumber,
+ IN UINT32 Address,
+ IN UINT32 AndMask,
+ IN UINT32 OrValue,
+ IN UINT32 Flags
+ );
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
new file mode 100644
index 0000000000..0e08e64b24
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProtocol.h
@@ -0,0 +1,47 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_PCIE_SERVICES_PROTOCOL_H_
+#define NBIO_PCIE_SERVICES_PROTOCOL_H_
+
+// Current PROTOCOL revision
+#define AMD_NBIO_PCIE_SERVICES_REVISION 0x00
+
+///
+/// Forward declaration for the NBIO_PCIE_SERVICES_PROTOCOL
+///
+typedef struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL;
+
+//
+// Protocol Definitions
+//
+
+/**
+ Returns the NBIO debug options configuration structure
+ This
+ A pointer to the DXE_AMD_NBIO_SMU_SERVICES_PROTOCOL instance.
+ DebugOptions
+ A pointer to a pointer to store the address of the PCIe topology structure
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT)(
+ IN DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL *This,
+ OUT UINT32 **DebugOptions
+ );
+
+///
+/// The Dxe of PCIE Services
+///
+struct _DXE_AMD_NBIO_PCIE_SERVICES_PROTOCOL {
+ AMD_NBIO_PCIE_GET_TOPOLOGY_STRUCT PcieGetTopology; ///<
+};
+
+extern EFI_GUID gAmdNbioPcieServicesProtocolGuid;
+
+#endif /* NBIO_PCIE_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
new file mode 100644
index 0000000000..10d3b730a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobPprProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_OEM_OOB_PPR_PROTOCOL_H_
+#define _AMD_OEM_OOB_PPR_PROTOCOL_H_
+
+extern EFI_GUID gAmdOemOobPprDxeProtocolGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
new file mode 100644
index 0000000000..a15995188b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNumaServices2.h
@@ -0,0 +1,155 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_NUMA_SERVICES2_H_
+#define FABRIC_NUMA_SERVICES2_H_
+#include "AMD.h"
+
+#pragma pack (push, 1)
+
+#define MAX_PXM_VALUES_PER_QUADRANT 16
+
+/// Domain type
+typedef enum {
+ NumaDram,
+ NumaSLink,
+ NumaCxl,
+ MaxNumaDomainType2
+} DOMAIN_TYPE2;
+
+/// Reported Domain Info
+typedef struct {
+ DOMAIN_TYPE2 Type; ///< Type
+ UINT32 SocketMap; ///< Bitmap indicating physical socket location
+ UINT32 PhysicalDomain; ///< Physical domain number
+} DOMAIN_INFO2;
+
+/// Physical Dram Info
+typedef struct {
+ UINT32 NormalizedCsMap; ///< Bitmap of CSs comprising this physical domain
+ UINT32 SharingEntityCount; ///< Number of virtual domains sharing this physical domain
+ UINT32 SharingEntityMap; ///< Bitmap of reported domains that share this physical domain
+ UINT32 Reserved; ///< Reserved
+} PHYS_DOMAIN_INFO;
+
+/// Proximity Domain Info
+typedef struct {
+ UINTN Count; ///< Entries in Domain array
+ UINTN Domain[MAX_PXM_VALUES_PER_QUADRANT]; ///< Domains in Quadrant
+} PXM_DOMAIN_INFO;
+
+///
+/// Forward declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL
+///
+typedef struct _FABRIC_NUMA_SERVICES2_PROTOCOL FABRIC_NUMA_SERVICES2_PROTOCOL;
+
+/**
+ * @brief Get the numa domain information.
+ *
+ * @details Get the numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfDomainsInSystem Number of unique NUMA domains
+ * @param[out] DomainInfo An array with information about each domain
+ * @param[out] CcxAsNumaDomain TRUE: each core complex is its own domain
+ * FALSE: physical mapping is employed
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfDomainsInSystem,
+ OUT DOMAIN_INFO2 **DomainInfo,
+ OUT BOOLEAN *CcxAsNumaDomain
+ );
+
+/**
+ * @brief Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @details Translates a core's physical location to the appropriate NUMA domain.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] Socket Zero based socket that the core is attached to
+ * @param[in] Die DF die on socket that the core is attached to
+ * @param[in] Ccd Logical CCD the core is on
+ * @param[in] Ccx Logical core complex
+ * @param[out] Domain Domain the core belongs to
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_DOMAIN_XLAT)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN UINTN Socket,
+ IN UINTN Die,
+ IN UINTN Ccd,
+ IN UINTN Ccx,
+ OUT UINT32 *Domain
+ );
+
+/**
+ * @brief Get physical numa domain information.
+ *
+ * @details Get physical numa domain information.
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[out] NumberOfPhysDomainsInSystem Number of valid domains in the system
+ * @param[out] PhysDomainInfo An array with information about each physical domain
+ * @param[out] PhysNodesPerSocket Actual NPS as determined by ABL (not including SLink)
+ * @param[out] NumberOfSystemSLinkDomains Number of domains describing SLink connected memory
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ OUT UINT32 *NumberOfPhysDomainsInSystem,
+ OUT PHYS_DOMAIN_INFO **PhysDomainInfo,
+ OUT UINT32 *PhysNodesPerSocket,
+ OUT UINT32 *NumberOfSystemSLinkDomains
+ );
+
+/**
+ * @brief Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @details Get the proximity domain information about a PCIe root-port bridge
+ *
+ * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_PROTOCOL instance.
+ * @param[in] RootPortBDF BDF for root-port bridge in PCI_ADDR format.
+ * @param[out] PxmDomainInfo Pointer to a structure returning associated NUMA node(s).
+ * @retval EFI_STATUS 0: Success, NonZero: Standard EFI Error.
+ */
+typedef
+EFI_STATUS
+(EFIAPI *FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO)(
+ IN FABRIC_NUMA_SERVICES2_PROTOCOL *This,
+ IN PCI_ADDR RootPortBDF,
+ OUT PXM_DOMAIN_INFO *PxmDomainInfo
+ );
+
+///
+/// When installed, the Fabric NUMA Services 2 Protocol produces a collection of
+/// services that return various information associated with non-uniform memory
+/// architecture.
+///
+struct _FABRIC_NUMA_SERVICES2_PROTOCOL {
+ UINTN Revision; ///< Revision Number
+ FABRIC_NUMA_SERVICES2_GET_DOMAIN_INFO GetDomainInfo; ///< Get Domain Info
+ FABRIC_NUMA_SERVICES2_DOMAIN_XLAT DomainXlat; ///< Domain Translation
+ FABRIC_NUMA_SERVICES2_GET_PHYSICAL_DOMAIN_INFO GetPhysDomainInfo; ///< Get Physical Domain Info
+ FABRIC_NUMA_SERVICES2_GET_PROXIMITY_DOMAIN_INFO GetPxmDomainInfo; ///< Get Proximity Domain Info
+};
+
+///
+/// Guid declaration for the FABRIC_NUMA_SERVICES2_PROTOCOL.
+///
+extern EFI_GUID gAmdFabricNumaServices2ProtocolGuid;
+
+#pragma pack (pop)
+#endif // _FABRIC_NUMA_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
new file mode 100644
index 0000000000..485240c0fb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServices2.h
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_TOPOLOGY_SERVICES2_H_
+#define FABRIC_TOPOLOGY_SERVICES2_H_
+
+#include <Library/BaseFabricTopologyLib.h>
+
+#endif // FABRIC_TOPOLOGY_SERVICES2_H_
diff --git a/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
new file mode 100755
index 0000000000..44093e4097
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Include/SocLogicalId.h
@@ -0,0 +1,23 @@
+/** @file
+ SoC Logical ID Definitions.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SOC_LOGICAL_ID_H_
+#define SOC_LOGICAL_ID_H_
+#pragma pack (push, 1)
+
+///
+/// SOC logical ID structure
+///
+typedef struct _SOC_LOGICAL_ID {
+ IN OUT UINT32 Family; ///< Indicates logical ID Family
+ IN OUT UINT16 Revision; ///< Indicates logical ID Revision
+} SOC_LOGICAL_ID;
+
+#pragma pack (pop)
+#endif // SOC_LOGICAL_ID_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
new file mode 100644
index 0000000000..a60ae20d33
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlLib.h
@@ -0,0 +1,100 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _INTERNAL_AML_LIB_H_
+#define _INTERNAL_AML_LIB_H_
+
+#include <Uefi.h>
+#include <Library/AmlGenerationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <IndustryStandard/Acpi.h>
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
new file mode 100644
index 0000000000..b19b6fe867
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.h
@@ -0,0 +1,150 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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 <all others> - 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/AgesaPkg/Include/AmdPcieComplex.h b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
new file mode 100755
index 0000000000..3a628ed0b2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdPcieComplex.h
@@ -0,0 +1,432 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCIE_COMPLEX_H_
+#define AMD_PCIE_COMPLEX_H_
+
+//
+// GNB PCIe configuration info
+//
+#define DESCRIPTOR_TERMINATE_LIST 0x80000000ull
+#define DESCRIPTOR_IGNORE 0x40000000ull
+
+//
+// Port parameter count
+//
+#define PCIE_PORT_PARAMETER_COUNT 64
+
+///
+/// PCIe link initialization
+/// DXIO endpoint status
+///
+typedef enum {
+ DxioEndpointDetect = 0, ///< Detect endpoint presence
+ DxioEndpointNotPresent ///< Endpoint not present (or connected). Used in case there is alternative way to determine
+ ///< if device present on board or in slot. For example GPIO can be used to determine device presence.
+} DXIO_ENDPOINT_STATUS;
+
+#pragma pack(push,1)
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific port parameter to set.
+ UINT16 ParamValue; ///< Specifies the value to be assigned to port parameter.
+} PORT_PARAM;
+
+typedef struct {
+ PORT_PARAM PhyParam[PCIE_PORT_PARAMETER_COUNT]; ///< PHY port parameter
+} PORT_PARAMS;
+
+///
+/// Ancillary data struct with table size and address
+///
+typedef struct {
+ IN UINT32 Count; ///< Total count in this Ancillary data table
+ IN UINT32 Ovrd; ///< Ancillary data table address point to ANC_DATA_PARAM[]
+} ANC_DATA;
+
+typedef struct {
+ UINT16 ParamType; ///< This identifies a specific PHY parameter
+ UINT16 ParamValue; ///< This specifies the value to be assigned to indicated PHY parameter
+} DXIO_PHY_PARAM;
+
+typedef struct {
+ DXIO_PHY_PARAM PhyParam[44]; ///< physical parameter
+} PHY_DATA;
+
+///
+/// PCIe specific data structures
+/// PCIe port misc extended controls
+///
+typedef struct {
+ UINT8 LinkComplianceMode : 1; ///< Force port into compliance mode (device will not be trained, port output compliance pattern)
+ UINT8 LinkSafeMode : 1; ///< Safe mode PCIe capability. (Parameter may limit PCIe speed requested through DXIO_PORT_DATA::LinkSpeedCapability)
+ ///< 0 - port can advertize muximum supported capability
+ ///< 1 - port limit advertized capability and speed to PCIe Gen1
+ UINT8 SbLink : 1; ///< PCIe link type
+ ///< 0 - General purpose port
+ ///< 1 - Port connected to SB
+ UINT8 ClkPmSupport : 1; ///< Clock Power Management Support
+ ///< 0 - Clock Power Management not configured
+ ///< 1 - Clock Power Management configured according to PCIe device capability
+ UINT8 ChannelType : 3; ///< Channel Type
+ ///< 0 - Channel Type Not Specified
+ ///< - Channel Type Short Trace
+ ///< 2 - Channel Type Long Trace
+ UINT8 TurnOffUnusedLanes : 1; ///< Turn Off Unused Lanes
+ ///< 0 - Turn on
+ ///< 1 - Turn off
+} DXIO_PORT_MISC_CONTROL;
+
+///
+/// The IO APIC Interrupt Mapping Info
+///
+typedef struct {
+ UINT8 GroupMap; ///< Group mapping for slot or endpoint device (connected to PCIE port) interrupts .
+ ///< 0 - IGNORE THIS STRUCTURE AND USE RECOMMENDED SETTINGS
+ ///< 1 - mapped to Grp 0 (Interrupts 0..3 of IO APIC redirection table)
+ ///< 2 - mapped to Grp 1 (Interrupts 4..7 of IO APIC redirection table)
+ ///< ...
+ ///< 8 - mapped to Grp 7 (Interrupts 28..31 of IO APIC redirection table)
+ UINT8 Swizzle; ///< Swizzle interrupt in the Group.
+ ///< 0 - ABCD
+ ///< 1 - BCDA
+ ///< 2 - CDAB
+ ///< 3 - DABC
+ UINT8 BridgeInt; ///< IOAPIC redirection table entry for PCIE bridge interrupt
+ ///< 0 - Entry 0 of IO APIC redirection table
+ ///< 1 - Entry 1 of IO APIC redirection table
+ ///< ...
+ ///< 31 - Entry 31 of IO APIC redirection table
+} DXIO_APIC_DEVICE_INFO;
+///
+/// PCIe port configuration data
+///
+typedef struct {
+ UINT8 PortPresent : 1; ///< Enable PCIe port for initialization.
+ UINT8 Reserved1 : 2; ///< Reserved
+ UINT8 DeviceNumber : 5; ///< PCI Device number for port.
+ ///< 0 - Native port device number
+ ///< N - Port device number (See available configurations in BKDG
+ UINT8 FunctionNumber : 3; ///< Reserved for future use
+ UINT8 LinkSpeedCapability : 3; ///< PCIe link speed/
+ ///< 0 - Maximum supported by silicon
+ ///< 1 - Gen1
+ ///< 2 - Gen2
+ ///< 3 - Gen3
+ ///< 4 - Gen4
+ ///< 5 - Gen5
+ UINT8 AutoSpdChng : 2; ///< Upstread Auto Speed Change Allowed/
+ ///< 0 - Use default implementation (Disabled for Gen1, Enabled for Gen2/3)
+ ///< 1 - Always Disabled
+ ///< 2 - Always Enabled
+ ///< 3 - Reserved
+ UINT8 EqPreset : 4; ///< Gen3 Equalization Preset */
+ UINT8 LinkAspm : 2; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - L0s only
+ ///< 2 - L1 only
+ ///< 3 - L0s and L1
+ UINT8 LinkAspmL1_1 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 LinkAspmL1_2 : 1; ///< ASPM control. (see AgesaPcieLinkAspm for additional option to control ASPM)
+ ///< 0 - Disabled
+ ///< 1 - Enabled
+ UINT8 ClkReq : 4; ///< ASPM Reserved Field
+ ///< 0 - NONE
+ ///< 1 - CLKREQ0 signal
+ ///< 2 - CLKREQ1 signal
+ ///< 3 - CLKREQ2 signal
+ ///< 4 - CLKREQ3 signal
+ ///< 5 - CLKREQG signal
+ UINT8 LinkHotplug : 4; ///< Hotplug control.
+ ///< 0 - Disabled
+ ///< 1 - Basic
+ ///< 2 - Server
+ ///< 3 - Enhanced
+ UINT8 SlotPowerLimit; ///< PCIe slot power limit.
+ UINT8 SlotPowerLimitScale : 2; ///< PCIe slot power limit Scale.
+ ///< 00b = 1.0x
+ ///< 01b = 0.1x
+ ///< 10b = 0.01x
+ ///< 11b = 0.001x
+ UINT8 IsMasterPLL : 1; ///< IsMasterPLL
+ UINT8 Gen4Features : 5; ///< Unused bits
+ ///< BIT0(DLF_Exchange) 1 - Disable, 0 - Enable
+ ///< IT1(DLF_Capability) 1 - Disable, 0 - Enable
+ UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_NUM
+ UINT16 CsLink : 3; ///< Reserved
+ DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended controls
+ DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device programming info
+ DXIO_ENDPOINT_STATUS EndpointStatus; ///< PCIe endpoint (device connected to PCIe port) status
+ UINT8 EsmSpeedBump; ///< Speed bump for ESM
+ UINT8 EsmControl : 1; ///< Enhanced speed mode control
+ UINT8 CcixControl : 1; ///< Ccix/Cxl control
+ UINT8 TxVetting : 1; ///< Tx Vetting
+ UINT8 RxVetting : 1; ///< Rx Vetting
+ UINT8 InvertPolarity : 1; ///< Invert RX Polarity
+ UINT8 InvertPolarity2 : 1; ///< Invert TX Polarity
+ UINT8 NtbHotplug : 1; ///< NTB Hotplug flag
+ ///< 0b = Disabled
+ ///< 1b = Enabled
+ UINT8 Reserved2 : 1; ///< Reserved
+ UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Preset Set
+ UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Preset Set
+ UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Preset Set
+ UINT8 Reserved3 : 5; ///< Reserved
+ UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Preset
+ UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Preset
+ UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Preset
+ UINT8 Reserved4 : 4; ///< Reserved
+ UINT16 PsppPolicyDC; ///< Pspp DC control
+ UINT16 PsppPolicyAC; ///< PSPP AC control
+ UINT8 PsppDeviceType; ///< Pspp Device Type
+ UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass phase2/3 EQ
+ UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass phase2/3 EQ
+ UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 DXIO deemphasis default
+ UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemphasis setting
+ UINT8 Reserved5 : 3; ///< Reserved
+ struct {
+ UINT16 DsTxPreset : 4; ///< Gen3 Downstream Tx Preset
+ UINT16 DsRxPresetHint : 3; ///< Gen3 Downstream Rx Preset Hint
+ UINT16 UsTxPreset : 4; ///< Gen3 Upstream Tx Preset
+ UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream Rx Preset Hint
+ UINT16 Reserved1 : 2; ///< Unused bits
+ UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downstream Tx Preset
+ UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downstream Rx Preset Hint
+ UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstream Tx Preset
+ UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstream Rx Preset Hint
+ UINT8 Reserved2 : 4; ///< Unused bits
+ } LaneEqualizationCntl; ///< Lane equalization control structure used for Gen3 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen4 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen4 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen4LaneEqualizationCntl; ///< Lane equalization control structure used for Gen4 values
+ struct {
+ UINT8 DsTxPreset : 4; ///< Gen5 Downstream Tx Preset
+ UINT8 UsTxPreset : 4; ///< Gen5 Upstream Tx Preset
+ UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downstream Tx Preset
+ UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstream Tx Preset
+ UINT8 Reserved1 : 6; ///< Unused bits
+ } Gen5LaneEqualizationCntl; ///< Lane equalization control structure used for Gen5 values
+ struct {
+ UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT.
+ UINT32 PresetMask16Gt : 10; ///< Preset Mask 16GT.
+ UINT32 PresetMask32Gt : 10; ///< Preset Mask 32GT.
+ UINT32 Reserved1 : 2; ///< Unused bits
+ UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT Set
+ UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16GT Set
+ UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32GT Set
+ UINT8 Reserved2 : 5; ///< Unused bits
+ } PresetMaskCntl; ///< Preset Mask control structure used for Gen3/Gen4/Gen5 values
+ UINT8 TargetLinkSpeed : 3; ///< Target Link Speed
+ UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equalization
+ UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equalization
+ UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP generation interval
+ UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enable 0xF:Auto
+ UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Autodetect mode 0:Disable 1:Enable 0xF:Auto
+ UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SKP_OS_GEN_SUPPORT
+ UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SKP_OS_RCV_SUPPORT
+ UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKIP Interval Selection Mode
+ UINT8 SrisAutodetectFactor : 2; ///< Controls the multiplier for SKP ordered set interval when generated based on elasticity buffer pointer slip feedback from PCS
+ UINT8 IsBmcLocation : 1; ///< IsBmcLocation
+ UINT8 SetEsmControl : 1; ///< Set ESM Control
+ UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump for ESM
+ UINT8 Reserved6 : 1; ///< Unused bits
+ UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch
+ UINT8 AlwaysExpose : 1; ///< Always expose unused PCIE port
+ UINT8 Reserved7 : 1; ///< Unused bits
+ UINT16 NpemEnable : 12; ///< Controls NPEM Enable
+ UINT16 Reserved8 : 4; ///< Unused bits
+ UINT16 NpemCapability : 12; ///< Controls NPEM Capability
+ UINT8 SwingMode : 3; ///< PCIe Swing Mode
+ UINT16 Reserved9 : 1; ///< Unused bits
+ UINT16 MpioAncDataIdx; ///< Reserved for internal use only
+ UINT8 Reserved10; ///< Reserved bits
+} DXIO_PORT_DATA;
+
+///
+/// EtherNet specific data structures
+///
+typedef struct {
+ UINT32 PortNum : 8; ///< Port Number
+ UINT32 PlatConf : 4; ///< Platform Config
+ ///< 0 = Reserved
+ ///< 1 = 10G/1G BackPlane
+ ///< 2 = 2.5G BackPlane
+ ///< 3= Soldered down 1000Base-T
+ ///< 4 = Soldered down 1000Base-X
+ ///< 5 = Soldered down NBase-T
+ ///< 6 = Soldered down 10GBase-T
+ ///< 7 = Soldered down 10GBase-r
+ ///< 8 = SFP+ Connector
+ UINT32 Reserved1 : 4; ///< Unused 12-15
+ UINT32 MdioId : 5; ///< MDIO ID when MDIO Side band is used
+ UINT32 Reserved2 : 2; ///< Unused 21-22
+ UINT32 SuppSpeed : 4; ///< Supported Speeds by Platform
+ ///< 1 = 100M Supported
+ ///< 2 = 1G Supported
+ ///< 4 = 2.5G Supported
+ ///< 8 = 10G Supported
+ UINT32 Reserved3 : 1; ///< Unused 27
+ UINT32 ConnType : 3; ///< Supported Speeds by Platform
+ ///< 0 = Port not Used
+ ///< 1 = SFP+ Connection I2C interface
+ ///< 2 = MDIO PHY
+ ///< 4 = Backplane Connection
+ UINT32 Reserved4 : 1; ///< Unused 31
+} ETH_PORT_PROPERTY0;
+
+typedef struct {
+ UINT32 MdioReset : 2; ///< MDIO Reset Type
+ ///< 0 = None
+ ///< 1 = I2C GPIO
+ ///< 2 = Integrated GPIO
+ ///< 3 = Reserved
+ UINT32 Reserved1 : 2; ///< Unused 2-3
+ UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO number for reset
+ UINT32 Reserved2 : 2; ///< Unused 6-7
+ UINT32 SfpGpioAdd : 3; ///< Lower I2C address of GPIO Expander PCA9535
+ UINT32 Reserved3 : 1; ///< Unused 11
+ UINT32 TxFault : 4; ///< TX FAULT
+ UINT32 Rs : 4; ///< RS Signal
+ UINT32 ModAbs : 4; ///< MOD_ABS signal
+ UINT32 RxLoss : 4; ///< Rx_LOS signal
+ UINT32 SfpGpioMask : 4; ///< SFP+ sideband signals that are not supported by platform
+} ETH_PORT_PROPERTY3;
+
+typedef struct {
+ UINT32 SfpMux : 3; ///< Lower address of Mux PCA 9545
+ UINT32 Reserved1 : 1; ///< Unused 3
+ UINT32 SfpBusSeg : 3; ///< SFP BUS Segment. Downstream channels of PCA9545
+ UINT32 Reserved2 : 1; ///< Unused 7
+ UINT32 SfpMuxUpAdd : 5; ///< Upper address of Mux PCA 9545
+ UINT32 Reserved3 : 3; ///< Unused 13-15
+ UINT32 RedriverAddress : 7; ///< Address of ReDriver
+ UINT32 RedriverInterface : 1; ///< ReDriver Interface Descriptor
+ UINT32 RedriverLane : 3; ///< ReDriver Lane number
+ UINT32 Reserved4 : 1; ///< Unused 27
+ UINT32 RedriverModel : 3; ///< ReDriver Model
+ UINT32 RedriverPresent : 1; ///< Redriver Present
+} ETH_PORT_PROPERTY4;
+
+typedef struct {
+ UINT32 TxEqPre : 6; ///< TX EQ PRE
+ UINT32 Reserved1 : 2; ///< Unused 7-6
+ UINT32 TxEqMain : 6; ///< TX EQ MAIN
+ UINT32 Reserved2 : 2; ///< Unused 15-14
+ UINT32 TxEqPost : 6; ///< TX EQ POST
+ UINT32 Reserved3 : 10; ///< Unused 31-23
+} ETH_PORT_TXEQ;
+/// Ethernet PCIe port configuration data
+///
+typedef struct {
+ ETH_PORT_PROPERTY0 EthPortProp0; ///< XGBE_PORT_PROPERTY_0
+ ETH_PORT_PROPERTY3 EthPortProp3; ///< XGBE_PORT_PROPERTY_3
+ ETH_PORT_PROPERTY4 EthPortProp4; ///< XGBE_PORT_PROPERTY_4
+ UINT32 PadMux0; ///< PadMux0 Setting (8 bits)
+ UINT32 PadMux1; ///< PadMux1 Setting (8 bits)
+ UINT32 MacAddressLo; ///< Lower 32 bits of MAC Address
+ UINT32 MacAddressHi; ///< Upper 32 bits of MAC Address
+ ETH_PORT_TXEQ EthPortTxEq; ///< TX EQ Settings
+} ETHERNET_PORT_DATA;
+
+///
+/// High level data structures for passing topology from platform to AGESA
+///
+typedef struct {
+ UINT8 EngineType; ///< Engine type
+ ///< 0 - Ignore engine configuration
+ ///< 1 - PCIe port
+ UINT8 HotPluggable : 1; ///< HotPluggable
+ ///< 0 - Link is NOT Hot-Switchable
+ ///< 1 - Link IS Hot-Switchable
+ UINT8 Reserved1 : 7; ///< Unused field, leave as 0
+ UINT8 StartLane; ///< Start Lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 EndLane; ///< End lane ID (in reversed configuration StartLane > EndLane)
+ ///< Refer to lane descriptions and supported configurations in BKDG
+ UINT8 GpioGroupId; ///< Unique identifier for the GPIO or GPIO group associated with
+ ///< this engine. GPIOs are used for hotplug notification and link
+ ///< type (e.g SATA Express or PCIe)
+ UINT8 DxioStartLane; ///< Internal coding of start lane
+ UINT8 DxioEndLane; ///< Internal coding of end lane
+ UINT8 SearchDepth; ///< SearchDepth only uses 1 bit - always initialize to 0 will be updated dynamically
+} DXIO_ENGINE_DATA;
+
+///
+/// PCIe port descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in complex
+ DXIO_ENGINE_DATA EngineData; ///< Engine data
+ DXIO_PORT_DATA Port; ///< PCIe port specific configuration info
+ ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for EtherNet
+ PHY_DATA Phy; ///< Ancillary data for PHY programming customization
+ PORT_PARAMS PortParams; ///< Extensible port parameter list for simplified topology structure
+ ANC_DATA AncData; ///< Ancillary data override
+} DXIO_PORT_DESCRIPTOR;
+
+#pragma pack(pop)
+
+///
+///
+/// PCIe Complex descriptor
+///
+typedef struct {
+ UINT32 Flags; ///< Descriptor flags
+ ///< Bit31 - last descriptor in topology
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR *PciePortList; ///< Pointer to array of PCIe port descriptors or NULL (Last element of array must be terminated with DESCRIPTOR_TERMINATE_LIST).
+ VOID *Reserved2; ///< Reserved for future use
+ UINT8 BmcLinkLocation; ///< Identifies the socket/die location of a BMC link (Used by AGESA, input not required)
+ UINT8 BmcLinkLaneNum; ///< Identifies the socket/die location of a BMC Lane number
+ UINT8 Reserved3[2]; ///< Reserved for future
+} DXIO_COMPLEX_DESCRIPTOR;
+
+///
+/// Engine descriptor type
+///
+typedef enum {
+ DxioUnusedEngine = 0, ///< Unused descriptor Excluded from configuration
+ DxioPcieEngine = 1, ///< PCIe port
+ DxioUSBEngine = 2, ///< USB port
+ ///< __Deprecated__
+ DxioSATAEngine = 3, ///< SATA
+ DxioUSB_OVER_PCIE = 4, ///< USB4 PCIe (internal use only)
+ DxioUBMHFCEngine = 5, ///< New for Genoa UBM HFC Connector for auto-discovery
+ DxioOCP3Engine = 6, ///< New for Genoa OCP3 Bifurcatable Connector
+ DxioUdot3Engine = 7, ///< New for Genoa U.3 Multiprotocol Connector
+ DxioDPEngine = 8, ///< Digital Display __For APU display connector list__
+ DxioEthernetEngine = 0x10, ///< Ethernet (GBe, XGBe)
+ ///< __Deprecated__
+ DxioGOPEngine = 0x20, ///< GOP
+ ///< __Deprecated__
+ DxioNTBDevice = 0x60, ///< For NBIF NTB Enable (internal use only)
+ DxioHDaudioEngine, ///< For NBIF HDaudtio Enable (internal use only)
+ DxioACPEngine, ///< For NBIF ACP Enable (internal use only)
+ DxioMP2Engine, ///< For NBIF MP2 Enable (internal use only)
+ DxioMaxPcieEngine ///< Max engine type for boundary check.
+} DXIO_ENGINE_TYPE;
+
+///
+/// PCIe link speeds
+///
+typedef enum {
+ DxioGenMaxSupported, ///< Maximum supported
+ DxioGen1 = 1, ///< Gen1
+ DxioGen2, ///< Gen2
+ DxioGen3, ///< Gen3
+ DxioGen4, ///< Gen4
+ DxioGen5, ///< Gen5
+ MaxDxioGen ///< Max Gen for boundary check
+} DXIO_LINK_SPEEDS;
+#endif // AMD_PCIE_COMPLEX_H_
diff --git a/Platform/AMD/AgesaPkg/Include/AmdSoc.h b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
new file mode 100644
index 0000000000..d62f260235
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdSoc.h
@@ -0,0 +1,17 @@
+/** @file
+
+ Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _AMD_SOC_H_
+#define _AMD_SOC_H_
+
+#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
+#endif // _AMD_SOC_H_
diff --git a/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
new file mode 100644
index 0000000000..2291f7dc83
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/FabricResourceManagerCmn.h
@@ -0,0 +1,42 @@
+/** @file
+ Fabric resource manager common definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_CMN_H_
+#define FABRIC_RESOURCE_MANAGER_CMN_H_
+#pragma pack (push, 1)
+
+#define MAX_SOCKETS_SUPPORTED 2 ///< Max number of sockets in system.
+#define MAX_RBS_PER_SOCKET 20 ///< Max number of root bridges per socket.
+
+/**
+ * @brief DF address aperture structure.
+ * @details This contains information used to define an MMIO region.
+ */
+typedef struct _FABRIC_ADDR_APERTURE {
+ UINT64 Base; ///< Aperture base Address.
+ UINT64 Size; ///< Aperture size.
+ UINT64 Alignment; ///< Alignment bit map. 0xFFFFF means 1MB align.
+} FABRIC_ADDR_APERTURE;
+
+/**
+ * @brief DF Resource for each RootBridge structure.
+ * @details This contains information used to define the MMIO region for each RootBridge.
+ */
+typedef struct _FABRIC_RESOURCE_FOR_EACH_RB {
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second nonprefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE PrimaryRbSecondPrefetchableMmioSizeBelow4G; ///< Primary RootBridge's second prefetchable MMIO size below 4G. @see FABRIC_ADDR_APERTURE
+ FABRIC_ADDR_APERTURE IO[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< IO resource(s) @see FABRIC_ADDR_APERTURE
+ UINT16 PciBusNumber[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET]; ///< PCI bus number(s).
+} FABRIC_RESOURCE_FOR_EACH_RB;
+#pragma pack (pop)
+#endif // FABRIC_RESOURCE_MANAGER_CMN_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
new file mode 100644
index 0000000000..9e58f299b4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Guid/AmdMemoryInfoHob.h
@@ -0,0 +1,96 @@
+/** @file
+ AMD Memory Info Hob Definition
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_MEMORY_INFO_HOB_H_
+#define AMD_MEMORY_INFO_HOB_H_
+
+/**
+ * @brief 128 bit Buffer containing UID Unique Identifier value for Memory Info HOB.
+ * EFI_GUID defined in UefiBaseType.h
+ */
+extern EFI_GUID gAmdMemoryInfoHobGuid;
+
+#pragma pack (push, 1)
+
+/**
+ * @brief Memory descriptor structure for each memory range
+ */
+typedef struct {
+ UINT64 Base; ///< Base address of memory rang
+ UINT64 Size; ///< Size of memory rang
+ UINT32 Attribute; ///< Attribute of memory rang
+ UINT32 Reserved; ///< For alignment purpose
+} AMD_MEMORY_RANGE_DESCRIPTOR;
+
+/**
+ * @brief Memory attribute in the memory range descriptor = AVAILABLE
+ */
+#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1
+
+/**
+ * @brief Memory attribute in the memory range descriptor = UMA
+ */
+#define AMD_MEMORY_ATTRIBUTE_UMA 0x2
+
+/**
+ * @brief Memory attribute in the memory range descriptor = MMIO
+ */
+#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPUMEM
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_SP
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7
+
+/**
+ * @brief Memory attribute in the memory range descriptor = GPU_RESERVED_TMR
+ */
+#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8
+
+/**
+ * @brief Memory attribute in the memory range descriptor = RESERVED_SMUFEATURES
+ */
+#define AMD_MEMORY_ATTRIBUTE_Reserved_SmuFeatures 0x9
+
+/// Memory info HOB structure
+typedef struct {
+ UINT32 Version; ///< Version of HOB structure
+ BOOLEAN AmdMemoryVddioValid; ///< This field determines if Vddio is valid
+ UINT16 AmdMemoryVddio; ///< Vddio Voltage
+ BOOLEAN AmdMemoryVddpVddrValid; ///< This field determines if VddpVddr is valid
+ UINT8 AmdMemoryVddpVddr; ///< VddpVddr voltage
+ BOOLEAN AmdMemoryFrequencyValid; ///< Memory Frequency Valid
+ UINT32 AmdMemoryFrequency; ///< Memory Frquency
+ UINT32 AmdMemoryDdrMaxRate; ///< Memory DdrMaxRate
+ UINT32 NumberOfDescriptor; ///< Number of memory range descriptor
+ AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory ranges array
+} AMD_MEMORY_INFO_HOB;
+
+#pragma pack (pop)
+
+/**
+ * @brief Macro that defines the Memory Info HOB version
+ */
+#define AMD_MEMORY_INFO_HOB_VERISION 0x00000110ul // Ver: 00.00.01.10
+
+#endif // AMD_MEMORY_INFO_HOB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
new file mode 100644
index 0000000000..d144a4ad20
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspBaseLibV2.h
@@ -0,0 +1,51 @@
+/** @file
+ AMD Psp Base Lib
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PSP_BASELIB_V2_H_
+#define AMD_PSP_BASELIB_V2_H_
+
+#include <AmdPspDirectory.h>
+
+#define MAX_IMAGE_SLOT_COUNT 32
+
+#define ALIGNMENT_4K BASE_4KB
+#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1)) == 0)
+#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K)
+
+#define IS_VALID_ADDR32(addr) (((UINT32)(addr) != 0) && (UINT32)(addr) != 0xFFFFFFFF)
+
+#pragma pack (push, 1)
+
+#define FIRMWARE_TABLE_SIGNATURE 0x55AA55AAul
+
+/// Define the structure OEM signature table
+typedef struct _FIRMWARE_ENTRY_TABLEV2 {
+ UINT32 Signature; ///< 0x00 Signature should be 0x55AA55AAul
+ UINT32 ImcRomBase; ///< 0x04 Base Address for Imc Firmware
+ UINT32 GecRomBase; ///< 0x08 Base Address for Gmc Firmware
+ UINT32 XHCRomBase; ///< 0x0C Base Address for XHCI Firmware
+ UINT32 LegacyPspDirBase; ///< 0x10 Base Address of PSP directory
+ UINT32 PspDirBase; ///< 0x14 Base Address for PSP directory
+ UINT32 Reserved1; ///< 0x18 Base Address for Reserved BIOS directory
+ UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS directory
+ UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS directory
+ UINT32 Config; ///< 0x24 reserved for EFS Configuration
+ UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all program
+ UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for all programs
+} FIRMWARE_ENTRY_TABLEV2;
+
+/// It also used as structure to store ISH generic information across programs
+typedef struct {
+ UINT32 Priority;
+ UINT32 UpdateRetries;
+ UINT32 GlitchRetries;
+ UINT32 ImageSlotAddr;
+} IMAGE_SLOT_HEADER;
+
+#pragma pack (pop)
+
+#endif // AMD_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
new file mode 100644
index 0000000000..23c90b65c2
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspFtpmLib.h
@@ -0,0 +1,83 @@
+/** @file
+ AMD Psp Ftpm Library header file
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_LIB_H_
+#define PSP_FTPM_LIB_H_
+#include <IndustryStandard/Acpi30.h>
+
+/* SYSTEM_TPM_CONFIG_VAL
+ * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG
+ */
+typedef enum {
+ SYSTEM_TPM_CONFIG_DTPM = 0x00, ///< dTPM
+ SYSTEM_TPM_CONFIG_PSP_FTPM = 0x01, ///< PSP FTPM
+ SYSTEM_TPM_CONFIG_HSP_FTPM = 0x02, ///< HSP FTPM
+ SYSTEM_TPM_CONFIG_NONE = 0xFF, ///< None of TPM
+} SYSTEM_TPM_CONFIG_VAL;
+
+#pragma pack (push, 1)
+/// Define TPM_2_CONTROL_AREA
+typedef struct {
+ // Interface Identifier
+ volatile UINT64 InterfaceIdentifier; ///< Interface Identifier
+ // TPM2 Control Area Extension
+ volatile UINT32 Clear; ///< Clear
+ volatile UINT32 RemainingBytes; ///< RemainingBytes
+ volatile UINT32 StatusReserved; ///< StatusReserved
+ volatile UINT32 StatusError; ///< StatusError
+ volatile UINT32 StatusCancel; ///< StatusCancel
+ volatile UINT32 StatusStart; ///< StatusStart
+ UINT64 InterruptControl; ///< InterruptControl
+ UINT32 CommandSize; ///< CommandSize
+ EFI_PHYSICAL_ADDRESS CommandAddress; ///< CommandAddress
+ UINT32 ResponseSize; ///< ResponseSize
+ EFI_PHYSICAL_ADDRESS ResponseAddress; ///< ResponseAddress
+ // Memory Absent command/response buffer
+ volatile UINT32 CmdRespHWBuffer; ///< Cmd/Rsp HW Buffer
+} TPM2_CONTROL_AREA;
+
+#pragma pack (pop)
+
+/**
+ GET TPM related Info
+
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+EFI_STATUS
+FtpmGetInfo (
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Execute a TPM command
+
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+EFI_STATUS
+FtpmExecuteCommand (
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+#endif //PSP_FTPM_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
new file mode 100644
index 0000000000..4ad4020f95
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmdPspRomArmorLib.h
@@ -0,0 +1,231 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _PSP_ROM_ARMOR_LIB_H_
+#define _PSP_ROM_ARMOR_LIB_H_
+
+#include "Uefi.h"
+
+#define PSP_MAX_SPI_CMD_SUPPORT (4) ///< Max number of SPI command support
+#define PSP_MAX_SPI_DATA_BUFFER_SIZE (72) ///< Max SPI Command Data Buffer Size
+#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list allowed command array number support
+#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list allowed region array number support
+
+#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chip selects
+#define SPI_CHIP_SELECT_1 (1) ///< Chip Select 1
+#define SPI_CHIP_SELECT_2 (2) ///< Chip Select 2
+
+#define SPI_COMMAND_FREQUENCY_66_66MHZ (0) ///< 0=66.66MHz
+#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=33.33MHz
+#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=22.22MHz
+#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=16.66MHz
+#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=100MHz
+#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=800KHz
+
+#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 = Command not examined/processed
+#define SPI_COMMAND_COMPLETED (1) ///< 1 = Command completed successfully
+#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 = Execution Error (i.e. timeout)
+#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 = Command not allowed by Whitelist
+#define SPI_COMMAND_MALFORMED (4) ///< 4 = Command malformed
+
+#pragma pack (push, 1)
+
+typedef struct {
+ UINT8 ChipSelect; ///< 1 = CS1, 2 = CS2, all other values illegal
+
+ UINT8 Frequency; ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Does not include the
+ ///< SPI Opcode byte, but does include the address, dummy bytes, and
+ ///< data.
+
+ UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx + BytesToRx <= 72
+
+ UINT8 OpCode; ///< The SPI Command OpCode (the first byte sent by the SPI controller)
+
+ UINT8 Reserved[3]; ///< Reserved for future expansion
+
+ UINT8 Buffer[PSP_MAX_SPI_DATA_BUFFER_SIZE]; ///< The remaining 0-72 bytes sent/received by the SPI controller.
+ ///<
+ ///< The SPI Controller will
+ ///< 1. Assert the ChipSelect
+ ///< 2. Send the one byte OpCode
+ ///< 3. Send Buffer[0] to Buffer[BytesToTx-1] to the SPI device
+ ///< 4. Read BytesToRx bytes from the device into Buffer[BytesToTx] to
+ ///< Buffer[BytesToTx+BytesToRx-1]
+ ///< 5. Deassert the ChipSelect line
+ ///<
+ ///< SPI ROM Commands that include a target address send the address
+ ///< immediately after the OpCode (i.e. Buffer[0..2] or Buffer[0..3]
+ ///< depending if 24 or 32bit addresses are associated with the OpCode).
+ ///< See the SPI ROM Device's datasheet for full details on your
+ ///< devices commands and formats.
+} SPI_COMMAND; ///< The struct of Spi Command
+
+typedef union {
+ struct {
+ ///< SPI_COMMUNICATION_RESULT
+ UINT16 Command0Result : 4; ///< Result[ 3: 0] The result of Command[0]
+ UINT16 Command1Result : 4; ///< Result[ 7: 4] The result of Command[1]
+ UINT16 Command2Result : 4; ///< Result[11: 8] The result of Command[2]
+ UINT16 Command3Result : 4; ///< Result[15:12] The result of Command[3]
+ } Field; ///< the struct type of Command0 ~ Command4
+ UINT16 Value; ///< 16 bit value of Command0 ~ Command4
+} SPI_COMMUNICATION_RESULT; ///< The union struct type of Spi Communication Result
+
+typedef struct {
+ UINT8 ReadyToRun; ///< Set to FALSE by x86 while the buffer is being constructed. Set to
+ ///< TRUE by x86 as the last step in building the communication buffer,
+ ///< just before x86 rings the PSP doorbell.
+ ///<
+ ///< Set to FALSE by PSP after the PSP copies the buffer from DRAM to
+ ///< private SRAM.
+
+ UINT8 CommandCount; ///< Number of commands to execute, Valid Values 1-4
+
+ SPI_COMMUNICATION_RESULT SpiCommunicationResult; ///< Set to zero by x86 when the buffer is built. Atomically set to a
+ ///< non-zero value by the PSP to indicate the PSP has finished
+ ///< processing the requests in the communication buffer. The specific
+ ///< value written by the PSP provides per command results
+ ///<
+ ///< Result values with special meaning:
+ ///< 0x0000 = (written by x86) PSP has not finished handling the request
+ ///< 0x1000 = PSP determined the request is malformed (invalid
+ ///< CommandCount, chipselect, BytesToRx/Tx, etc)
+ ///< 0x2000, 0x3000, 0x4000, ... , 0xF000 = Reserved for future errors
+ ///<
+ ///< Generic Result values:
+ ///< SpiCommunicationResult[ 3: 0] The result of Command[0]
+ ///< SpiCommunicationResult[ 7: 4] The result of Command[1]
+ ///< SpiCommunicationResult[11: 8] The result of Command[2]
+ ///< SpiCommunicationResult[15:12] The result of Command[3]
+ ///< 0 = Command not examined/processed
+ ///< 1 = Command completed successfully
+ ///< 2 = Execution Error (i.e. timeout)
+ ///< 3 = Command not allowed by Whitelist
+ ///< 4 = Command malformed
+ ///< 5-15 = reserved for future use
+ ///<
+ ///< Examples of Generic Results:
+ ///< 0x0000 - PSP has not finished the request
+ ///< 0x0001 - PSP ran Command0 successfully, and is now idle
+ ///< 0x0111 - PSP ran Command0/1/2 successfully and is now idle
+ ///< 0x0031 - PSP ran Command0, but Command1 was blocked by whitelist
+
+ SPI_COMMAND SpiCommand[PSP_MAX_SPI_CMD_SUPPORT]; ///< Spi command array
+} SPI_COMMUNICATION_BUFFER; ///< The struct type of Spi Communication Buffer
+
+typedef struct {
+ UINT8 ChipSelect; ///< 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+
+ UINT8 Frequency; ///< The allowed frequency for the command
+ ///< 0=66.66MHz, 1=33.33MHz, 2=22.22MHz,
+ ///< 3=16.66MHz, 4=100Mhz, 5=800KHz, all others illegal
+
+ UINT8 OpCode; ///< The allowed commands opcode
+
+ UINT8 MinTx; ///< The minimum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+ UINT8 MaxTx; ///< The maximum range of allowed transmit byte counts for this command
+ ///< (does not include opcode)
+
+ UINT8 MinRx; ///< The minimum range of allowed Rx byte counts
+ UINT8 MaxRx; ///< The maximum range of allowed Rx byte counts
+
+ UINT8 AddrChkMethod; ///< 0=No address verification performed
+ ///< 1=Treat Buffer[0-2] as a 24-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+ ///< 2=Treat Buffer[0-3] as a 32-bit address, and verify the entire
+ ///< ImpactZone of the command falls within one of the allowed regions
+
+ UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned power of two sized block
+ ///< of addresses that may be impacted by a given SPI Command. For
+ ///< example, a sector erase command targeted at an address within a
+ ///< 64K block will impact every byte within that 64K block. Likewise
+ ///< a page program SPI command (i.e. write) may impact many bytes
+ ///< within the targeted 256/512 byte page due to page wrap-around, but
+ ///< no bytes outside the page. The ImapctSize field specifies the power
+ ///< of two size of the ImpactZone for this command. If VerifyAddress is
+ ///< zero (no checking) this field must also be zero, otherwise this
+ ///< field must be a power of two between 256 and 64MB (256, 512, ...,
+ ///< 67108864). NOTE: When setting this field, carefully examine your
+ ///< device's datasheet.
+ ///<
+} WHITE_LIST_ALLOWED_COMMAND; ///< The struct type of White List Allowed Command
+
+typedef struct {
+ // 8 bytes
+ UINT32 StartAddress; ///< LSB must be 0x00, bit31 identifies a chipselect: 0=CS1, 1=CS2
+ UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be less than EndAddress
+} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed Region
+
+typedef struct {
+ UINT8 AllowedCmdCount; ///< Allow Command Count
+ UINT8 AllowedRegionCount; ///< Allow Region Count
+ WHITE_LIST_ALLOWED_COMMAND WhitelistAllowedCommands[PSP_MAX_WHITE_LIST_CMD_NUM]; ///< White List Allowed Command Table
+ WHITE_LIST_ALLOWED_REGION WhitelistAllowedRegions[PSP_MAX_WHITE_LIST_REGION_NUM]; ///< White List Allowed Region Table
+} SPI_WHITE_LIST; ///< The struct type of Spi White List
+
+#pragma pack (pop)
+
+/**
+ * @brief Request secures the SPI Controller
+ *
+ * @param[in,out] SpiCommunicationBuffer Spi Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN OUT SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ );
+
+/**
+ * @brief Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI white list structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ );
+
+/**
+ * @brief Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ );
+
+/**
+ * @brief Request PSP firmware switch SPI controller chip select.
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ );
+
+#endif //_PSP_ROM_ARMOR_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
new file mode 100644
index 0000000000..0189910bd1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/AmlGenerationLib.h
@@ -0,0 +1,2722 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AML_LIB_H_
+#define AML_LIB_H_
+
+#include <Uefi.h>
+#include <IndustryStandard/Acpi.h>
+
+typedef enum {
+ AmlStart,
+ AmlClose,
+ AmlInvalid
+} AML_FUNCTION_PHASE;
+
+#define AML_OBJECT_INSTANCE_SIGNATURE SIGNATURE_32 ('a', 'm', 'l', 'o')
+
+//
+// Device Status Bitmap (Section 6.3.7 ACPI version 6.3)
+// Bit [0] - Set if the device is present.
+// Bit [1] - Set if the device is enabled and decoding its resources.
+// Bit [2] - Set if the device should be shown in the UI.
+// Bit [3] - Set if the device is functioning properly (cleared if device
+// failed its diagnostics).
+// Bit [4] - Set if the battery is present.
+// Bits [31:5] - Reserved (must be cleared).
+//
+#define DEVICE_PRESENT_BIT 0x0001
+#define DEVICE_ENABLED_BIT 0x0002
+#define DEVICE_IN_UI_BIT 0x0004
+#define DEVICE_HEALTH_BIT 0x0008
+#define DEVICE_BATTERY_BIT 0x0010 // Control Method Battery Device Only
+
+typedef enum {
+ UnknownObj,
+ IntObj,
+ StrObj,
+ BuffObj,
+ PkgObj,
+ FieldUnitObj,
+ DeviceObj,
+ EventObj,
+ MethodObj,
+ MutexObj,
+ OpRegionObj,
+ PowerResObj,
+ ProcessorObj,
+ ThermalZoneObj,
+ BuffFieldObj,
+ DDBHandlObj,
+ InvalidObj
+} OBJECT_TYPE_KEYWORD;
+
+typedef struct {
+ UINT32 Signature;
+ BOOLEAN Completed;
+ UINTN DataSize;
+ UINT8 *Data;
+ LIST_ENTRY Link;
+} AML_OBJECT_INSTANCE;
+
+// ***************************************************************************
+// AML defines to be consistent with already existing
+// MdePkg/Include/IndustryStandard/Acpi*.h defines.
+// *** These could be upstreamed at some point.
+// ***************************************************************************
+// Limits of (DWord|Word|QWord)Space ResourceType
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MIN 0xC0
+#define EFI_ACPI_SPACE_RESOURCE_TYPE_MAX 0xFF
+
+// General Flags: Flags that are common to all resource types
+// Bits[7:4] Reserved(must be 0)
+// Bit[3] Max Address Fixed, _MAF:
+// 1 The specified maximum address is fixed
+// 0 The specified maximum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED (1 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED (0 << 3)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MAF EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+// Bit[2] Min Address Fixed, _MIF:
+// 1 The specified minimum address is fixed
+// 0 The specified minimum address is not fixed and can be changed
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED (1 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED (0 << 2)
+#define EFI_ACPI_GENERAL_FLAG_MASK_MIF EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+// Bit[1] Decode Type, _DEC:
+// 1 This bridge subtractively decodes this address(top level bridges only)
+// 0 This bridge positively decodes this address
+#define EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE (1 << 1)
+#define EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE (0 << 1)
+#define EFI_ACPI_GENERAL_FLAG_MASK_DEC EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+// Bit[0] Consumer / Producer:
+// 1 This device consumes this resource
+// 0 This device produces and consumes this resource
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER (1 << 0)
+#define EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER (0 << 0)
+#define EFI_ACPI_GENERAL_FLAG_MASK_USAGE EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+
+// Memory Resource Flag (Resource Type = 0) DefinitionsBits
+// Memory Resource Flag Masks
+// Bits[7:6] Reserved(must be 0)
+// Bit[5] Memory to I/O Translation, _TTP:
+// 0 TypeStatic
+// 1 Type Translation
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_TTP (1 << 5)
+// Bit[4:3] Memory Attributes, _MTP:
+// 0 AddressRangeMemory
+// 1 AddressRangeReserved
+// 2 AddressRangeACPI
+// 3 AddressRangeNVS
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MTP (3 << 3)
+// Bit[2:1] Memory Attributes, _MEM:
+// 0 The memory is non-cacheable
+// 1 The memory is cacheable
+// 2 The memory is cacheable and supports write-combining
+// 3 The memory is cacheable and prefetchable
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_MEM (3 << 1)
+// Bit[0] Write Status, _RW:
+// 0 This memory range is read-only
+// 1 This memory is read-write
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_MASK_RW (1 << 0)
+
+// I/O Resource Flag (Resource Type = 1) DefinitionsBits
+// I/O Resource Flags
+// Bit [7:6] Reserved (must be 0)
+// Bit [5] Sparse Translation, _TRS. This bit is only meaningful if Bit [4] is set.
+// 1 SparseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = (((port & 0xFFFc) << 10) || (port & 0xFFF)) + _TRA In the address
+// used to access the I/O port, bits[11:2] must be identical to bits[21:12],
+// this gives four bytes of I/O ports on each 4 KB page.
+// 0 DenseTranslation: The primary-side memory address of any specific I/O port
+// within the secondary-side range can be found using the following function.
+// address = port + _TRA
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_SPARSE_TRANSLATION (1 << 5)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_DENSE_TRANSLATION (0 << 5)
+// Bit [4] I/O to Memory Translation, _TTP
+// 1 TypeTranslation: This resource, which is I/O on the secondary side of the
+// bridge, is memory on the primary side of the bridge.
+// 0 TypeStatic: This resource, which is I/O on the secondary side of the
+// bridge, is also I/O on the primary side of the bridge.
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_TRANSLATION (1 << 4)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_STATIC (0 << 4)
+// Bit [3:2] Reserved (must be 0)
+// Bit [1:0] _RNG
+// 3 Memory window covers the entire range
+// 2 ISARangesOnly. This flag is for bridges on systems with multiple bridges.
+// Setting this bit means the memory window specified in this descriptor is
+// limited to the ISA I/O addresses that fall within the specified window. The
+// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. This bit can
+// only be set for bridges entirely configured throughACPI namespace.
+// 1 NonISARangesOnly. This flag is for bridges on systems with multiple
+// bridges. Setting this bit means the memory window specified in this
+// descriptor is limited to the non-ISA I/O addresses that fall within the
+// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7FF,
+// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entirely
+// configured through ACPI namespace.
+// 0 Reserved
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE (3 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY (2 << 0)
+#define EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY (1 << 0)
+
+#define AML_OBJECT_INSTANCE_FROM_LINK(a) BASE_CR (a, AML_OBJECT_INSTANCE, Link)
+
+// Method Serialize Flag Values
+typedef enum {
+ NotSerialized,
+ Serialized,
+ FlagInvalid
+} METHOD_SERIALIZE_FLAG;
+// AccessField Access Attrib Flags.
+// Ref ACPI spec 6.3
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL 0x00
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK 0x02
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE 0x04
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE 0x06
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD 0x08
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK 0x0A
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES 0x0B
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL 0x0C
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL 0x0D
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES 0x0E
+#define EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES 0X0F
+
+// AccessField access types
+typedef enum {
+ AnyAcc,
+ ByteAcc,
+ WordAcc,
+ DWordAcc,
+ QWordAcc,
+ BufferAcc,
+} EFI_ACPI_FIELD_ACCESS_TYPE_KEYWORDS;
+
+// Field lock rules
+typedef enum {
+ NoLock,
+ Lock
+} EFI_ACPI_FIELD_LOCK_RULE_KEYWORDS;
+
+// Field update rules
+typedef enum {
+ Preserve,
+ WriteAsOnes,
+ WriteAsZeros
+} EFI_ACPI_FIELD_UPDATE_RULE_KEYWORDS;
+
+// Field access attributes. for AttribBytes, AttribRawBytes and AttribRawProcessBytes
+// the ExtendedAccessField definition is used, as this is what iASL compiles into, rather
+// than the AccessField that is specified in the ACPI spec.
+typedef enum {
+ AttribNormal = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NORMAL,
+ AttribQuick = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUICK,
+ AttribSendReceive = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEND_RECEIVE,
+ AttribByte = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTE,
+ AttribWord = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WORD,
+ AttribBlock = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK,
+ AttribBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYTES,
+ AttribProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PROCESS_CALL,
+ AttribBlockProcessCall = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLOCK_PROCESS_CALL,
+ AttribRawBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_BYTES,
+ AttribRawProcessBytes = EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW_PROCESS_BYTES
+} EFI_ACPI_FIELD_ACCESS_ATTRIBUTE_KEYWORDS;
+
+//
+// Resource Type Specific Flags
+// Ref ACPI specification 6.4.3.5.5
+//
+//
+// DMA Information
+// Ref ACPI specification 6.4.2.2
+//
+// DmaType values
+typedef enum {
+ Compatibility = EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY,
+ TypeA = EFI_ACPI_DMA_SPEED_TYPE_A,
+ TypeB = EFI_ACPI_DMA_SPEED_TYPE_B,
+ TypeF = EFI_ACPI_DMA_SPEED_TYPE_F
+} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS;
+
+// IsBusMaster values
+typedef enum {
+ NotBusMaster = 0,
+ BusMaster = EFI_ACPI_DMA_BUS_MASTER
+} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS;
+
+// DmaTransferSize values
+typedef enum {
+ Transfer8 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT,
+ Transfer8_16 = EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT,
+ Transfer16 = EFI_ACPI_DMA_TRANSFER_TYPE_16_BIT
+} EFI_ACPI_DMA_TRANSFER_TYPE_KEYWORDS;
+
+//
+// Interrupt Resource Descriptor Information
+// Ref ACPI specification 6.4.2.1
+//
+// IRQ Information - Wake Capability
+//
+#define EFI_ACPI_IRQ_WAKE_CAPABLE_MASK 0x20
+#define EFI_ACPI_IRQ_NOT_WAKE_CAPABLE 0x0
+#define EFI_ACPI_IRQ_WAKE_CAPABLE 0x20
+
+typedef enum {
+ NotWakeCapable = EFI_ACPI_IRQ_NOT_WAKE_CAPABLE,
+ WakeCapable = EFI_ACPI_IRQ_WAKE_CAPABLE
+} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Sharing
+//
+#define EFI_ACPI_IRQ_EXCLUSIVE 0x0
+
+typedef enum {
+ Exclusive = EFI_ACPI_IRQ_EXCLUSIVE,
+ Shared = EFI_ACPI_IRQ_SHARABLE,
+ ExclusiveAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_EXCLUSIVE,
+ SharedAndWake = EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_SHARABLE
+} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Polarity
+//
+typedef enum {
+ ActiveHigh = EFI_ACPI_IRQ_HIGH_TRUE,
+ ActiveLow = EFI_ACPI_IRQ_LOW_FALSE
+} EFI_ACPI_IRQ_INTERRUPT_POLARITY_KEYWORDS;
+
+//
+// IRQ Information - Interrupt Mode
+//
+#define EFI_ACPI_IRQ_MODE_MASK 0x1
+typedef enum {
+ LevelTriggered = EFI_ACPI_IRQ_LEVEL_TRIGGERED,
+ EdgeTriggered = EFI_ACPI_IRQ_EDGE_TRIGGERED
+} EFI_ACPI_IRQ_INTERRUPT_MODE_KEYWORDS;
+
+// IO Port Descriptor Information
+// Ref ACPI specification 6.4.2.5
+//
+typedef enum {
+ Decode16 = EFI_ACPI_IO_DECODE_16_BIT,
+ Decode10 = EFI_ACPI_IO_DECODE_10_BIT
+} EFI_ACPI_IO_PORT_DESCRIPTOR_INFORMATION;
+
+//
+// Memory Resource Information
+// Ref ACPI specification 6.4.3.5
+//
+// Consumer/Producer Bit[0]
+typedef enum {
+ ResourceProducer = EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER,
+ ResourceConsumer = EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER
+} RESOURCE_USAGE_FLAG;
+
+// Decode Type (_DEC) Bit[1]
+typedef enum {
+ PosDecode = EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE,
+ SubDecode = EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE
+} MEM_DECODE_FLAG;
+
+// Min Address Fixed (_MIF) Bit[2]
+typedef enum {
+ MinNotFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED,
+ MinFixed = EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED
+} MIN_FIXED_FLAG;
+
+// Max Address Fixed (_MAF) Bit[3]
+typedef enum {
+ MaxNotFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED,
+ MaxFixed = EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED
+} MAX_FIXED_FLAG;
+
+// Memory Attributes (_MEM) Bits[2:1]
+typedef enum {
+ NonCacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE,
+ Cacheable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE,
+ WriteCombining = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRITE_COMBINING,
+ Prefetchable = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+} CACHEABLE_FLAG;
+
+// Write Status (_RW) Bit[0]
+typedef enum {
+ ReadOnly = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY,
+ ReadWrite = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE
+} READ_WRITE_FLAG;
+
+// Memory Attributes (_MTP) Bits[4:3]
+typedef enum {
+ AddressRangeMemory = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY,
+ AddressRangeReserved = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED,
+ AddressRangeACPI = EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI,
+ AddressRangeNVS = EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS
+} MEMORY_RANGE_TYPE;
+
+// Memory to IO Translation (_TTP) Bit[5]
+// Note: IO and Memory Resources use different bits for this.
+// Value must be handled at function level when implemented.
+typedef enum {
+ TypeStatic = 0,
+ TypeTranslation = 1
+} MEMORY_TRANSLATION_TYPE;
+
+// Memory Window Attributes (_RNG) Bits[1:0]
+typedef enum {
+ Reserved = 0,
+ NonISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ONLY,
+ ISAOnly = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY,
+ EntireRange = EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE,
+ ISARangeMax
+} IO_ISA_RANGES;
+
+// Generic Address Space Address IDs
+typedef enum {
+ SystemMemory = EFI_ACPI_6_4_SYSTEM_MEMORY,
+ SystemIO = EFI_ACPI_6_4_SYSTEM_IO,
+ PCI_Config = EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE,
+ EmbeddedControl = EFI_ACPI_6_4_EMBEDDED_CONTROLLER,
+ SMBus = EFI_ACPI_6_4_SMBUS,
+ SystemCMOS = EFI_ACPI_6_4_SYSTEM_CMOS,
+ PciBarTarget = EFI_ACPI_6_4_PCI_BAR_TARGET,
+ IPMI = EFI_ACPI_6_4_IPMI,
+ GeneralPurposeIO = EFI_ACPI_6_4_GENERAL_PURPOSE_IO,
+ GenericSerialBus = EFI_ACPI_6_4_GENERIC_SERIAL_BUS,
+ PCC = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ PlatformCommChannel = EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL,
+ FFixedHW = EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE
+} GENERIC_ADDRESS_SPACE_ID;
+
+typedef enum {
+ UndefinedSize = EFI_ACPI_6_4_UNDEFINED,
+ ByteSize = EFI_ACPI_6_4_BYTE,
+ WordSize = EFI_ACPI_6_4_WORD,
+ DWordSize = EFI_ACPI_6_4_DWORD,
+ QWordSize = EFI_ACPI_6_4_QWORD
+} ACPI_DATA_SIZE;
+
+typedef ACPI_DATA_SIZE GENERIC_ADDRESS_ACCESS_SIZE;
+
+// ***************************************************************************
+// AML Objects
+// ***************************************************************************
+
+// ---------------------------------------------------------------------------
+// Table and Table Header Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Name Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Namestring AML Object and inserts it into the linked list
+
+ Completes NameString in one call as "one phase"
+ LeadNameChar := 'A'-'Z' | '_'
+ DigitChar := '0'-'9'
+ NameChar := DigitChar | LeadNameChar
+ RootChar := '\'
+ ParentPrefixChar := '^'
+
+ 'A'-'Z' := 0x41 - 0x5A
+ '_' := 0x5F
+ '0'-'9' := 0x30 - 0x39
+ '\' := 0x5C
+ '^' := 0x5E
+
+ NameSeg := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Data Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates an optimized integer object
+
+ 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] Phase - Example: AmlStart, AmlClose
+ @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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a data string object
+
+ ComputationalData := String
+
+ String := StringPrefix AsciiCharList NullChar
+ StringPrefix := 0x0D
+ AsciiCharList := Nothing | <AsciiChar AsciiCharList>
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Package Length Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ Creates a Package Length AML Object and inserts it into the linked list
+
+ PkgLength := PkgLeadByte |
+ <PkgLeadByte ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Term Objects Encoding
+// ---------------------------------------------------------------------------
+
+// ---------------------------------------------------------------------------
+// Namespace Modifier Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ Creates a Name (ObjectName, Object)
+
+ Object must be created between AmlStart and AmlClose Phase
+
+ DefName := NameOp NameString DataRefObject
+ NameOp := 0x08
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Named Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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] Name - Named Object name
+ @param[in,out] ListHead - Linked list has completed Name 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Field
+
+ Field (RegionName, AccessType, LockRule, UpdateRule) {FieldUnitList}
+
+ FieldUnitList must be created 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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.
+
+ 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 that has completed AccessAs Object
+ after AmlClose.
+
+ @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
+ );
+
+/**
+ 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 since AML does not store
+ ArgTypes here.
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Type 1 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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 pkglength termlist>
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 - Head of linked list of Objects
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlReturn (
+ IN AML_FUNCTION_PHASE Phase,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+// ---------------------------------------------------------------------------
+// Type 2 Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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 PackageElementList>
+ PackageElement := DataRefObject | NameString
+
+ @param[in] Phase - Either AmlStart or AmlClose
+ @param[in] NumElements - Number of elements in the package
+ @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
+ );
+
+// ---------------------------------------------------------------------------
+// Resource Descriptor Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlDWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/*
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ AmlQWordSpace ()
+
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 19.6.152 WordSpace (Word Space Resource Descriptor Macro) )
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Expression Opcodes Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+// ---------------------------------------------------------------------------
+// Miscellaneous Objects Encoding
+// ---------------------------------------------------------------------------
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ Creates a Shift Left expression
+
+ Syntax:
+ ShiftLeft (Source, ShiftCount, Reult) => 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Assistance Functions
+// ***************************************************************************
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+/**
+ 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
+ );
+
+// ***************************************************************************
+// AML Debug Functions
+// ***************************************************************************
+
+/**
+ 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Buffer - Buffer containing buffer
+ @param[in] BufferSize - Number of bytes to print
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintBuffer (
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ );
+
+/**
+ DEBUG print a 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
+ Completed=(TRUE|FALSE)
+
+ @param[in] Object - AML_OBJECT_INSTANCE
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintObject (
+ IN AML_OBJECT_INSTANCE *Object
+ );
+
+/**
+ 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
+
+ @retval EFI_SUCCESS
+ @retval Error status
+**/
+EFI_STATUS
+EFIAPI
+AmlDebugPrintLinkedObjects (
+ IN LIST_ENTRY *ListHead
+ );
+
+#endif // AML_LIB_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
new file mode 100644
index 0000000000..d48ca1a90a
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitelistLib.h
@@ -0,0 +1,25 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/AmdPspRomArmorLib.h>
+
+/*
+ * 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 couldn't be allocated
+ */
+EFI_STATUS
+EFIAPI
+GetPspRomArmorWhitelist (
+ IN SPI_WHITE_LIST **PlatformSpiWhitelist
+ );
diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
new file mode 100644
index 0000000000..6c854651cc
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h
@@ -0,0 +1,134 @@
+/** @file
+ AMD Psp Ftpm Ppi Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PSP_FTPM_PPI_H_
+#define PSP_FTPM_PPI_H_
+#include <Uefi.h>
+
+typedef struct _PSP_FTPM_PPI PSP_FTPM_PPI;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Info
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PPI *This,
+ IN VOID *CommandBuffer,
+ IN UINTN CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+ **/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs.
+
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PPI itself
+ @param[in,out] ResponseBuffer Point to the TPM response buffer
+ @param[in,out] ResponseSize Size of the TPM response buffer
+
+ @retval EFI_STATUS 0: Success, Non-Zero Error
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PPI *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ PSP_FTPM_PPI prototype
+
+ Defines PSP_FTPM_PPI. This PPI is used to get Ftpm info.
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PPI {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+} PSP_FTPM_PPI;
+
+extern EFI_GUID gAmdPspFtpmPpiGuid;
+extern EFI_GUID gAmdPspFtpmFactoryResetPpiGuid;
+
+#endif
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
new file mode 100644
index 0000000000..715cbbcf78
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesProtocol.h
@@ -0,0 +1,183 @@
+/** @file
+ CXL Configuration Services Protocol prototype definition
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_
+#define NBIO_CXL_SERVICES_PROTOCOL_H_
+
+#include "AMD.h"
+#include <Protocol/FabricTopologyServices2.h>
+#include <Protocol/FabricResourceManagerServicesProtocol.h>
+
+#define AMD_NBIO_CXL_SERVICES_REVISION 0x00
+
+/// Forward declaration for the AMD_NBIO_CXL_SERVICES_PROTOCOL
+typedef struct _AMD_NBIO_CXL_SERVICES_PROTOCOL AMD_NBIO_CXL_SERVICES_PROTOCOL;
+
+extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL services protocol calling
+
+#pragma pack (push, 1)
+/// Port Information Structure
+typedef struct _AMD_CXL_PORT_INFO_STRUCT {
+ PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root Port in PCI_ADDR format
+ UINT8 LogicalNbioInstance; ///< Logical Instance ID of NBIO
+ UINT8 PhysicalNbioInstance; ///< Physical Instance ID of NBIO where this port is located
+ UINT8 SocketID; ///< Socket ID for this port
+ UINT32 UsRcrb; ///< Upstream Port RCRB address
+ UINT32 DsRcrb; ///< Downstream Port RCRB address
+ UINT32 UsMemBar0; ///< Upstream port MEMBAR0
+ UINT32 DsMemBar0; ///< Downstream port MEMBAR0
+ UINT8 PortId; ///< Physical port location
+ UINT8 PortWidth; ///< Lane width of the port
+ UINT32 CxlPortAddress; ///< CXL root port address (CXL 2.0 root port or CXL 1.1 RCiEP)
+ BOOLEAN IsSwitch; ///< CXL Switch flag
+} AMD_CXL_PORT_INFO_STRUCT;
+
+/// Port MMIO32 Resources Information Structure
+typedef struct _AMD_CXL_RESOURCES_INFO_STRUCT {
+ UINT32 Mmio32Base[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Size[MAX_SOCKETS_SUPPORTED][MAX_RBS_PER_SOCKET];
+ UINT32 Mmio32Gran;
+} AMD_CXL_RESOURCES_INFO_STRUCT;
+#pragma pack (pop)
+
+// Protocol Definitions
+
+/**
+ This function gets information about a specific PCIe root port.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortInformation
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_ROOT_PORT_INFORMATION)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr
+ IN UINTN PortIndex, ///< port index
+ OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port information ptr
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL capabilities.
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port.
+ PortInformation OPTIONAL (can be NULL)
+ A pointer to an information structure to be populated by this function to
+ identify the location of the CXL port.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_CONFIGURE_ROOT_PORT)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< this ptr
+ IN PCI_ADDR EndpointBDF ///< end pt bdf
+ );
+
+/**
+ This function configures a specific PCIe root port for CXL presence
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ EndpointBDF
+ Bus/Device/Function of Endpoint in PCI_ADDR format.
+ PortConfiguration
+ A pointer to a configuration structure that contains the information necessary
+ to configurare the CXL port such as Socket id,rbindex,port id,segment,bus base,limit or presence.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_AVAILABLE)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT FABRIC_RESOURCE_FOR_EACH_RB *ResourceForEachRb ///<
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_GET_PORT_RB_LOCATION)(
+ ///< get port rb location
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN UINT8 Segment, ///<
+ IN UINT8 BusBase, ///<
+ OUT UINT8 *SocketId, ///<
+ OUT UINT8 *RbIndex ///<
+ );
+
+/**
+ This function gets the CXL MMIO32 values to be used by the fabric resource manager
+
+ This
+ A pointer to the AMD_NBIO_CXL_SERVICES_PROTOCOL instance.
+ CxlMmio32ResourceForEachRb
+ A pointer to the structure that will hold the MMIO32 base and size values for each root bridge
+**/
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_RESOURCES_INFORMATION)(
+ ///< cxl port presence info
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///<
+ IN OUT AMD_CXL_RESOURCES_INFO_STRUCT *CxlMmio32Resources ///<
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_REPORT_TO_MPIO)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This ///< ptr to protocol
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_CXL_FIND_2P0_DEVICES)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN UINTN PortIndex ///< port index
+ );
+
+/**
+ * @brief
+ *
+ */
+typedef
+VOID
+(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)(
+ IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< ptr to protocol
+ IN PCI_ADDR CxlPciAddress ///< PCI address
+ );
+
+/// The Protocol Definition for CXL Services
+struct _AMD_NBIO_CXL_SERVICES_PROTOCOL {
+ UINT32 Revision; ///< revision
+ UINTN CxlCount; ///< CXL count
+ AMD_CXL_GET_ROOT_PORT_INFORMATION CxlGetRootPortInformation; ///< CXL root port information
+ AMD_CXL_CONFIGURE_ROOT_PORT CxlConfigureRootPort; ///< configuring the root port
+ AMD_CXL_GET_PORT_RB_LOCATION GetCxlPortRBLocation; ///< CXL port RB location
+ AMD_CXL_RESOURCES_AVAILABLE GetCxlAvailableResources; ///< Get resources allocated for CXL RCiEP
+ AMD_CXL_RESOURCES_INFORMATION GetCxlMmio32Resources; ///< Get CXL MMIO resources for CXL RCiEP
+ AMD_CXL_REPORT_TO_MPIO CxlReportToMpio; ///< Sends the CXL info to MPIO
+ AMD_CXL_FIND_2P0_DEVICES CxlFind2p0Devices; ///< Finds CXL 2.0 devices after PCIe enumeration
+ AMD_CXL_ENABLE_SCM_PMEM CxlEnableScmForPersistentMemory; ///< Notifies SMU that CXL persistent memory is present
+};
+
+#endif /* NBIO_CXL_SERVICES_PROTOCOL_H */
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
new file mode 100644
index 0000000000..7bcff65dc9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesProtocol.h
@@ -0,0 +1,110 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_PCI_RESOURCES_PROTOCOL_H_
+#define AMD_PCI_RESOURCES_PROTOCOL_H_
+
+typedef struct {
+ UINTN Index;
+ UINT8 SocketId;
+ UINTN Segment;
+ UINTN BaseBusNumber;
+} PCI_ROOT_BRIDGE_OBJECT;
+
+typedef struct {
+ UINTN Index;
+ BOOLEAN Enabled;
+ UINT8 PortPresent;
+ UINTN Device;
+ UINTN Function;
+ UINTN SlotNum;
+ // Interrupts are relative to IOAPIC 0->n
+ UINTN BridgeInterrupt; // Redirection table entry for mapped bridge interrupt
+ UINTN EndpointInterruptArray[4]; // Redirection table entries for mapped INT A/B/C/D
+} PCI_ROOT_PORT_OBJECT;
+
+typedef enum {
+ IOMMU = 0,
+ IOAPIC
+} FIXED_RESOURCE_TYPE;
+
+typedef struct {
+ UINTN Index;
+ FIXED_RESOURCE_TYPE ResourceType;
+ UINTN Address;
+ UINTN Limit;
+} FIXED_RESOURCES_OBJECT;
+
+/// Forward declaration for the AMD_PCI_RESOURCES_PROTOCOL.
+typedef struct _AMD_PCI_RESOURCES_PROTOCOL AMD_PCI_RESOURCES_PROTOCOL;
+
+/**
+ * @brief System information through EFI call
+ * @details
+ */
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ OUT UINTN *NumberOfRootBridges
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT PCI_ROOT_BRIDGE_OBJECT **RootBridgeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfRootPorts
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN RootPortIndex,
+ OUT PCI_ROOT_PORT_OBJECT **RootPortInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ OUT UINTN *NumberOfFixedResources
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO)(
+ IN AMD_PCI_RESOURCES_PROTOCOL *This,
+ IN UINTN RootBridgeIndex,
+ IN UINTN FixedResourceIndex,
+ OUT FIXED_RESOURCES_OBJECT **FixedResourceInfo
+ );
+
+struct _AMD_PCI_RESOURCES_PROTOCOL {
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTBRIDGES AmdPciResourcesGetNumberOfRootBridges;
+ AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO AmdPciResourcesGetRootBridgeInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS AmdPciResourcesGetNumberOfRootPorts;
+ AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO AmdPciResourcesGetRootPortInfo;
+ AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES AmdPciResourcesGetNumberOfFixedResources;
+ AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO AmdPciResourcesGetFixedResourceInfo;
+};
+
+extern EFI_GUID gAmdPciResourceProtocolGuid; ///< Guid for calling
+
+#endif // AMD_PCI_RESOURCES_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
new file mode 100644
index 0000000000..ebc7812b18
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtocol.h
@@ -0,0 +1,187 @@
+/** @file
+ AMD Psp Ftpm Protocol Header
+
+ Copyright (C) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FTPM_PROTOCOL_H_
+#define FTPM_PROTOCOL_H_
+
+#include <Uefi.h>
+//
+// GUID definition
+//
+extern EFI_GUID gAmdPspFtpmProtocolGuid;
+
+/**
+ structure definition for HSP mailbox
+
+**/
+typedef struct {
+ // C2H_TPM_L0
+ UINT64 TPM_L0_Address; /// Mailbox address
+ UINT64 TPM_L0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L0(VLT0)
+ UINT64 VLT0_Address; /// Mailbox address
+ UINT64 VLT0_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT0_H2C_MSG_Address; /// Doorbell address HSP->CPU
+
+ // C2H_HSP_L1(VLT1)
+ UINT64 VLT1_Address; /// Mailbox address
+ UINT64 VLT1_C2H_MSG_Address; /// Doorbell address CPU->HSP
+ UINT64 VLT1_HSC_MSG_Address; /// Doorbell address HSP->CPU
+
+ // Interrupt Information
+ UINT8 Gsi[4]; /// Gsi[0] is for HSP Channel 0 TPM
+ /// Gsi[1] is for HSP Channel 1 VTL0
+ /// Gsi[2] is for HSP Channel 2 VTL1
+ /// Gsi[3] is reserved
+} HSP_MAILBOX_ADDRESS, *PHSP_MAILBOX_ADDRESS;
+
+typedef union {
+ HSP_MAILBOX_ADDRESS HSP_info;
+} FTPM_INFO;
+
+typedef struct _PSP_FTPM_PROTOCOL PSP_FTPM_PROTOCOL;
+
+/**
+ Define function prototype: Execute a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_EXECUTE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: GET TPM related Information
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmStatus Used to hold more detail info (Unused Currently)
+
+ @return EFI_SUCCESS Ftpm function supported
+ @return EFI_UNSUPPORTED Ftpm function unsupported
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_CHECK_STATUS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT UINTN *FtpmStatus
+ );
+
+/**
+ Define function prototype: Send a TPM command
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in] CommandBuffer Point to the TPM command buffer
+ @param[in] CommandSize Size of the TPM command buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_SEND_COMMAND)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN VOID *CommandBuffer,
+ IN UINT32 CommandSize
+ );
+
+/**
+ Define function prototype: Get a TPM command's response
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+
+ @return EFI_SUCCESS Command executed successfully
+ @return EFI_UNSUPPORTED Device unsupported
+ @return EFI_TIMEOUT Command fail due the time out
+ @return EFI_DEVICE_ERROR Command fail due the error status set
+ @return EFI_BUFFER_TOO_SMALL Response buffer too small to hold the response
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_RESPONSE)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINT32 *ResponseSize
+ );
+
+/**
+ Define function prototype: Get TCG Logs
+ This function only implemented on Pluton-fTPM
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in, out] ResponseBuffer Point to the TPM response buffer
+ @param[in, out] ResponseSize Size of the TPM response buffer
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TCG_LOGS)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *ResponseBuffer,
+ IN OUT UINTN *ResponseSize
+ );
+
+/**
+ Function prototype for GetHspfTPMInfo. Return Pluton mailbox base address to SBIOS.
+ SBIOS should call this procedure after PCI Enumeration Complete.
+
+ @param[in] This Point to PSP_FTPM_PROTOCOL itself
+ @param[in,out] FtpmInfo Point to Pluton mailbox base address
+
+ @return EFI_SUCCESS - Success
+ @return EFI_INVALID_PARAMETER - Input parameter is invalid
+ @return EFI_NOT_READY - Pluton-fTPM device BAR0 MMIO is not ready.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *FTPM_GET_TPM_INFO)(
+ IN PSP_FTPM_PROTOCOL *This,
+ IN OUT VOID *FtpmInfo
+ );
+
+/**
+ PSP_FTPM_PROTOCOL prototype
+
+ Defines PSP_FTPM_PROTOCOL. This protocol is used to get Ftpm info
+ Send TPM command, Get TPM command's response, Execute TPM command(Include send & get response)
+**/
+typedef struct _PSP_FTPM_PROTOCOL {
+ FTPM_EXECUTE Execute; ///< Execute TPM command, include send & get response
+ FTPM_CHECK_STATUS CheckStatus; ///< Check TPM Status
+ FTPM_SEND_COMMAND SendCommand; ///< Send TPM command
+ FTPM_GET_RESPONSE GetResponse; ///< Get Last TPM command response
+ FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Logs
+ FTPM_GET_TPM_INFO GetInfo; ///< Get TPM info
+} PSP_FTPM_PROTOCOL;
+
+#endif //FTPM_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
new file mode 100644
index 0000000000..7f57facf88
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesProtocol.h
@@ -0,0 +1,14 @@
+/** @file
+ Fabric MMIO map manager Protocol prototype definition
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
+#include <FabricResourceManagerCmn.h>
+
+#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
new file mode 100644
index 0000000000..a7fef5a35c
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h
@@ -0,0 +1,19 @@
+/** @file
+ AMD CPM Base Definitions.
+
+ Copyright (C) 2014-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_BASE_H_
+#define AMD_CPM_BASE_H_
+
+#include <Base.h>
+#include <Uefi.h>
+#include <PiPei.h>
+#include <AmdCpmCommon.h>
+#include <Library/DebugLib.h>
+
+#endif // AMD_CPM_BASE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
new file mode 100644
index 0000000000..af192fcf03
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h
@@ -0,0 +1,78 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_COMMON_H_
+#define AMD_CPM_COMMON_H_
+
+#pragma pack(push)
+
+#include <AGESA.h>
+#include <AmdPcieComplex.h>
+#include <AmdCpmDefine.h>
+#include <AmdCpmFunction.h>
+
+/// The signatures of CPM table
+
+typedef enum {
+ CPM_SIGNATURE_DXIO_TOPOLOGY = SIGNATURE_32 ('$', 'A', '2', '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE
+ CPM_SIGNATURE_DXIO_TOPOLOGY_S1 = SIGNATURE_32 ('$', 'A', '2', '7') ///< The signature of Socket 1 AMD_CPM_DXIO_TOPOLOGY_TABLE
+} AMD_CPM_TABLE_SIGNATURE;
+
+/// CPM table header
+typedef struct {
+ UINT32 TableSignature; ///< Signature of CPM table
+ UINT16 TableSize; ///< Table size
+ UINT8 FormatRevision; ///< Revision of table format
+ UINT8 ContentRevision; ///< Revision of table content
+ UINT32 PlatformMask; ///< The mask of platform table supports
+ UINT32 Attribute; ///< Table attribute
+} AMD_CPM_TABLE_COMMON_HEADER;
+
+/// Table pointer
+typedef union {
+ VOID *Pointer; ///< Table pointer
+ UINT64 Raw; ///< Table pointer value
+} AMD_CPM_POINTER;
+
+/// DXIO Topology Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT32 SocketId; ///< Socket Id
+ DXIO_PORT_DESCRIPTOR Port[AMD_DXIO_PORT_DESCRIPTOR_SIZE]; ///< DXIO Port Descriptor List
+} AMD_CPM_DXIO_TOPOLOGY_TABLE;
+
+/// AMD CPM Main Table
+typedef struct {
+ AMD_CPM_TABLE_COMMON_HEADER Header; ///< Table header
+ UINT8 PlatformName[32]; ///< Platform name
+ UINT8 BiosType; ///< BIOS type
+ UINT16 CurrentPlatformId; ///< Current Platform Id
+ UINT32 PcieMemIoBaseAddr; ///< PcieMemIoBaseAddr
+ UINT32 AcpiMemIoBaseAddr; ///< AcpiMemIoBaseAddr
+ AMD_CPM_POINTER Service; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRomList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInRamList; ///< Reserved for internal use
+ AMD_CPM_POINTER TableInHobList; ///< Reserved for internal use
+ AMD_CPM_POINTER HobTablePtr; ///< Reserved for internal use
+
+ UINT8 ExtClkGen; ///< External ClkGen Config. 0x00~0x7F
+ UINT8 UnusedGppClkOffEn; ///< Config to turn off unused GPP clock
+ UINT8 LpcUartEn; ///< LpcUartEn
+ UINT64 AltAcpiMemIoBaseAddr; ///< Alternate AcpiMemIoBaseAddr for Slave FCH
+} AMD_CPM_MAIN_TABLE;
+
+/// Structure for Chip Id
+typedef struct {
+ UINT8 Cpu; ///< CPU/APU Chip Id
+ UINT8 Sb; ///< SB Chip Id
+ UINT8 Reserved[6];
+} AMD_CPM_CHIP_ID;
+#pragma pack (pop)
+
+#endif //AMD_CPM_COMMON_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
new file mode 100644
index 0000000000..4fc3f97a80
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmDefine.h
@@ -0,0 +1,17 @@
+/** @file
+ AMD CPM Common Definitions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_DEFINE_H_
+#define AMD_CPM_DEFINE_H_
+
+#ifndef AMD_DXIO_PORT_DESCRIPTOR_SIZE
+#define AMD_DXIO_PORT_DESCRIPTOR_SIZE 0x30
+#endif
+
+#endif // AMD_CPM_DEFINE_H_
diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
new file mode 100644
index 0000000000..7dce238135
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Include/AmdCpmFunction.h
@@ -0,0 +1,32 @@
+/** @file
+ AMD CPM Common Functions.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_FUNCTION_H_
+#define AMD_CPM_FUNCTION_H_
+
+typedef VOID *(EFIAPI *AMD_CPM_GETTABLEPTR_FN)(
+ IN VOID *This,
+ IN UINT32 TableId
+ );
+
+typedef AGESA_STATUS (EFIAPI *AMD_CPM_GETPOSTEDVBIOSIMAGE_FN)(
+ IN GFX_VBIOS_IMAGE_INFO *VbiosImageInfo
+ );
+
+/// Common Functions for CPM Drivers
+typedef struct _AMD_CPM_COMMON_FUNCTION {
+ AMD_CPM_GETTABLEPTR_FN GetTablePtr2; ///< Get CPM Table Pointer. The table can be re-writable
+} AMD_CPM_COMMON_FUNCTION;
+
+/// CPM Public Functions for platform DXE Driver to use
+typedef struct _AMD_CPM_DXE_PUBLIC_FUNCTION {
+ AMD_CPM_GETPOSTEDVBIOSIMAGE_FN GetPostedVbiosImage; ///< Get posted VBIOS image
+} AMD_CPM_DXE_PUBLIC_FUNCTION;
+
+#endif //AMD_CPM_FUNCTION_H_
diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
new file mode 100644
index 0000000000..4a90aa3d8b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTableProtocol.h
@@ -0,0 +1,39 @@
+/** @file
+ AMD CPM Table Protocol.
+
+ Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_CPM_TABLE_PROTOCOL_H_
+#define AMD_CPM_TABLE_PROTOCOL_H_
+
+#include <AmdCpmBase.h>
+
+//
+// GUID definition
+//
+#define AMD_CPM_TABLE_PROTOCOL_GUID \
+ { 0x3724cf01, 0x00c2, 0x9762, 0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }
+
+#define AMD_CPM_TABLE_SMM_PROTOCOL_GUID \
+ { 0xaf6efacf, 0x7a13, 0x45a3, 0xb1, 0xa5, 0xaa, 0xfc, 0x06, 0x1c, 0x4b, 0x79 }
+
+extern EFI_GUID gAmdCpmTableProtocolGuid;
+extern EFI_GUID gAmdCpmTableSmmProtocolGuid;
+
+/// DXE Protocol Structure
+typedef struct _AMD_CPM_TABLE_PROTOCOL {
+ UINTN Revision; ///< Protocol Revision
+ AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Pointer to CPM Main Table
+ AMD_CPM_CHIP_ID ChipId; ///< Id of SB Chip
+ AMD_CPM_COMMON_FUNCTION CommonFunction; ///< Private Common Functions
+ AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///< Public Function of Protocol
+} AMD_CPM_TABLE_PROTOCOL;
+
+// Current Protocol Revision
+#define AMD_CPM_TABLE_PROTOCOL_REV 0x00
+
+#endif // AMD_CPM_TABLE_PROTOCOL_H_
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
new file mode 100644
index 0000000000..fa83888e95
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.c
@@ -0,0 +1,31 @@
+/** @file
+ PSP Mailbox related functions
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ * @brief Bios send these commands to PSP to grant dTPM status and event log
+ *
+ * @param[out] DesiredConfig dTPM configuration requested
+ * @param[out] ConfigStatus 0 - success. non-zero failure.
+ * @param[in,out] LogDataSize Size of LogData buffer
+ * @param[out] LogData Point to allocated event log buffer
+ *
+ * @retval EFI_STATUS 0: Success, NonZero Error
+ */
+EFI_STATUS
+PspMboxGetDTPMData (
+ OUT UINT32 *DesiredConfig,
+ OUT UINT32 *ConfigStatus,
+ IN OUT UINT32 *LogDataSize,
+ OUT VOID *LogData
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
new file mode 100644
index 0000000000..0e9baad955
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorLib.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
new file mode 100644
index 0000000000..a04bc1f992
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomArmorLibNull.c
@@ -0,0 +1,79 @@
+/** @file
+
+ Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/AmdPspRomArmorLib.h>
+
+/**
+ * Request secures the SPI Controller
+ *
+ * @param[in, out] SpiCommunicationBuffer SPI Communication Structure Buffer pointer
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnterSmmOnlyMode (
+ IN SPI_COMMUNICATION_BUFFER *SpiCommunicationBuffer
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Loads the whitelist into the PSP.
+ *
+ * @param[in] SpiWhitelist SPI White List structure buffer pointer.
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspEnforceWhitelist (
+ IN SPI_WHITE_LIST *SpiWhitelist
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request execute SPI command provide in TSEG comm buffer.
+ *
+ * @param[in] NONE
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspExecuteSpiCommand (
+ VOID
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ * Request PSP firmware switch SPI controller chip select.
+ *
+ *
+ * @param[in] Chipset SPI controller chip select, 0= Allowed on all chip selects, 1= CS1, 2= CS2, all else invalid
+ *
+ * @retval EFI_SUCCESS Initial success
+ * @retval Others Error happens during initialize
+ */
+EFI_STATUS
+EFIAPI
+PspSwitchChipSelect (
+ IN UINT8 ChipSelect
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
new file mode 100644
index 0000000000..fce82d75b0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.c
@@ -0,0 +1,12 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/PcdLib.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Protocol/SmmBase2.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
new file mode 100644
index 0000000000..f8b9eb0bcf
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLibV3Pei.c
@@ -0,0 +1,14 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <PiPei.h>
+#include <Base.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
new file mode 100644
index 0000000000..cff678d76b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabricTopologyRsLib.c
@@ -0,0 +1,37 @@
+** @file
+ Fabric Topology Base Lib implementation
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+
+UINTN
+FabricTopologyGetNumberOfProcessorsPresent (
+ VOID
+ )
+{
+ return 0;
+}
+
+UINTN
+FabricTopologyGetNumberOfRootBridgesOnSocket (
+ IN UINTN Socket
+ )
+{
+ return 0;
+}
+
+RETURN_STATUS
+EFIAPI
+BaseFabricTopologyLibConstructor (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
new file mode 100644
index 0000000000..f72cbe7dff
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.c
@@ -0,0 +1,8 @@
+/** @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.<BR>
+
+ 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
new file mode 100644
index 0000000000..a155978a5d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimerLib.c
@@ -0,0 +1,35 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+
+/** The constructor function determines the actual TSC frequency.
+
+ First, Get TSC frequency from system configuration table with TSC frequency GUID,
+ if the table is not found, install it.
+ This function will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeTscTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
new file mode 100644
index 0000000000..f70aa3de0e
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiTscTimerLib.c
@@ -0,0 +1,11 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/HobLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
new file mode 100644
index 0000000000..7d14d62e60
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibShare.c
@@ -0,0 +1,103 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/** Stalls the CPU for at least the specified number of MicroSeconds.
+
+ @param[in] MicroSeconds The minimum number of microseconds to delay.
+
+ @return The value of MicroSeconds input.
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ return 0;
+}
+
+/** Stalls the CPU for at least the specified number of NanoSeconds.
+
+ @param[in] NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return The value of NanoSeconds input.
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ return 0;
+}
+
+/** Retrieves the current value of the 64-bit free running Time-Stamp counter.
+
+ The properties of the counter can be retrieved by the
+ GetPerformanceCounterProperties() function.
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return 0;
+}
+
+/** Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
+ that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
+ EndValue.
+
+ The 64-bit frequency of the performance counter, in Hz, is always returned.
+
+ @param[out] StartValue Pointer to where the performance counter's starting value is saved, or NULL.
+ @param[out] EndValue Pointer to where the performance counter's ending value is saved, or NULL.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ OUT UINT64 *StartValue, OPTIONAL
+ OUT UINT64 *EndValue OPTIONAL
+ )
+{
+ return 0;
+}
+
+/**
+ Converts elapsed ticks of performance counter to time in nanoseconds.
+
+ This function converts the elapsed ticks of running performance counter to
+ time value in unit of nanoseconds.
+
+ @param Ticks The number of elapsed ticks of running performance counter.
+
+ @return The elapsed time in nanoseconds.
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSecond (
+ IN UINT64 Ticks
+ )
+{
+ return 0;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
new file mode 100644
index 0000000000..44e23df62f
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBridgeLib.c
@@ -0,0 +1,95 @@
+/** @file
+ AMD instance of the PCI Host Bridge Library.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciRootBridgeIo.h>
+#include <Protocol/PciHostBridgeResourceAllocation.h>
+
+/**
+ Sort all root bridges in bus ascending order and set DevicePath UIDs
+ continuous and ascending from zero
+
+ @param[in,out] RootBridgeList Array of root bridges.
+ @param[in] Count Count of root bridges in RootBridgeList
+
+ @return All the root bridge instances in an array are sorted in bus order.
+ DevicePath UID updated to continuous and ascending numbers starting
+ with 0.
+**/
+VOID
+EFIAPI
+PciHostBridgeSortRootBridges (
+ IN PCI_ROOT_BRIDGE *RootBridgeList,
+ IN UINTN Count
+ )
+{
+}
+
+/**
+ Return all the root bridge instances in an array.
+
+ @param Count Return the count of root bridge instances.
+
+ @return All the root bridge instances in an array.
+ The array should be passed into PciHostBridgeFreeRootBridges()
+ when it's not used.
+**/
+PCI_ROOT_BRIDGE *
+EFIAPI
+PciHostBridgeGetRootBridges (
+ UINTN *Count
+ )
+{
+ return (PCI_ROOT_BRIDGE *)NULL;
+}
+
+/**
+ Free the root bridge instances array returned from PciHostBridgeGetRootBridges().
+
+ @param Bridges The root bridge instances array.
+ @param Count The count of the array.
+**/
+VOID
+EFIAPI
+PciHostBridgeFreeRootBridges (
+ PCI_ROOT_BRIDGE *Bridges,
+ UINTN Count
+ )
+{
+}
+
+/**
+ Inform the platform that the resource conflict happens.
+
+ @param HostBridgeHandle Handle of the Host Bridge.
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ for all the root bridges. The resource for each root
+ bridge is terminated with END descriptor and an
+ additional END is appended indicating the end of the
+ entire resources. The resource descriptor field
+ values follow the description in
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
+ .SubmitResources().
+**/
+VOID
+EFIAPI
+PciHostBridgeResourceConflict (
+ EFI_HANDLE HostBridgeHandle,
+ VOID *Configuration
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
new file mode 100644
index 0000000000..318f8e5ad7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgObjects.c
@@ -0,0 +1,154 @@
+/** @file
+
+ Copyright (C) 2021-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE
+
+/*
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ ArgN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
new file mode 100644
index 0000000000..371537c9aa
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunctions.c
@@ -0,0 +1,151 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLASSISTFUNCTIONS_FILECODE
+
+/**
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ListHead = AllocatePool (sizeof (LIST_ENTRY));
+ if (*ListHead == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to allocate Table List Head\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlFreeObjectList (*ListHead);
+ FreePool (*ListHead);
+ *ListHead = NULL;
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
new file mode 100644
index 0000000000..b7d4f4c9d7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObjects.c
@@ -0,0 +1,640 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE
+
+/*
+ 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__, 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", __func__, "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", __func__, 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 AsciiCharList>
+ 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",
+ __func__,
+ Index,
+ String
+ ));
+ return Status;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, 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",
+ __func__,
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AsciiStrLen (String) != 0x7) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid length for 'String' parameter.\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
new file mode 100644
index 0000000000..e8ea9d8e84
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpressionOpcodes.c
@@ -0,0 +1,1294 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECODE
+
+// ----------------------------------------------------------------------------
+// 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __func__));
+ goto Done;
+ }
+
+ // Start BufferSize
+ Status = InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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",
+ __func__,
+ InternalBufferSize
+ ));
+ goto Done;
+ }
+
+ Status = InternalAmlDataIntegerBuffer (
+ InternalBufferSize,
+ (VOID **)&Object->Data,
+ &Object->DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: calc BufferSize\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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 PackageElementList>
+ 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", __func__));
+ goto Done;
+ }
+
+ // Start required PkgLength
+ Status = AmlPkgLength (AmlStart, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
new file mode 100644
index 0000000000..21deb200e3
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjects.c
@@ -0,0 +1,158 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLLOCALOBJECTS_FILECODE
+
+/**
+ 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",
+ __func__
+ ));
+ 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",
+ __func__,
+ "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",
+ __func__,
+ LocalN
+ ));
+ goto Done;
+ }
+
+ Object->Completed = TRUE;
+
+ Status = EFI_SUCCESS;
+
+Done:
+ if (EFI_ERROR (Status)) {
+ InternalFreeAmlObject (&Object, ListHead);
+ }
+
+ return Status;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
new file mode 100644
index 0000000000..0502547a01
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNameString.c
@@ -0,0 +1,576 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESTRING_FILECODE
+
+#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 := <leadnamechar namechar namechar namechar>
+
+ 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 := <LeadNameChar NameChar NameChar NameChar>
+ // Notice that NameSegs shorter than 4 characters are filled with
+ // trailing underscores ('_'s).
+ NameString := <RootChar NamePath> | <PrefixPath NamePath>
+ 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", __func__, 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",
+ __func__,
+ 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains more than 1 RootChar.\n", __func__, String));
+ goto Done;
+ }
+
+ if (FoundParentPrefixChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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", __func__, StringIndex, String));
+ goto Done;
+ }
+
+ if (FoundRootChar) {
+ Status = EFI_INVALID_PARAMETER;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=%a contains RootChar and ParentPrefixChar.\n", __func__, 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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",
+ __func__,
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
new file mode 100644
index 0000000000..37ae9319be
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObject.c
@@ -0,0 +1,2138 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMEDOBJECT_FILECODE
+
+#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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, Name));
+ goto Done;
+ }
+
+ // Insert required NameString
+ Status = AmlOPNameString (Name, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__));
+ goto Done;
+ }
+
+ InternalOffsetData = *(UINT64 *)OffsetObject->Data;
+
+ if (InternalOffsetData > BitCount) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataLength);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, BankName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, IndexName));
+ goto Done;
+ }
+
+ Status = InternalFreeAmlObject (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: removing offset term%a\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (RegionName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __func__, 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", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Offset, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (Length, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n", __func__, RegionName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (BitIndex, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NumBits, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+ } else {
+ Status = AmlOPNameString (SourceBuffer, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+ }
+
+ Status = AmlOPDataInteger (Index, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = AmlOPNameString (FixedFieldName, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__, FixedFieldName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedField", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, Name));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "Method", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
new file mode 100644
index 0000000000..afe51cdcf2
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceModifierObjects.c
@@ -0,0 +1,360 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_FILECODE
+
+/**
+ 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", __func__, 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", __func__, 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", __func__, 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", __func__, String));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, String, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__, 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", __func__));
+ 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", __func__, 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", __func__, AliasName));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot locate ALIAS object\n", __func__));
+ 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
new file mode 100644
index 0000000000..279bfc782d
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDebug.c
@@ -0,0 +1,144 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLOBJECTSDEBUG_FILECODE
+
+/**
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
new file mode 100644
index 0000000000..85d184b759
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLength.c
@@ -0,0 +1,267 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLPKGLENGTH_FILECODE
+
+#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",
+ __func__,
+ 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", __func__));
+ 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 ByteData> |
+ <PkgLeadByte ByteData ByteData> |
+ <PkgLeadByte ByteData ByteData ByteData>
+
+ PkgLeadByte := <bit 7-6: ByteData count that follows (0-3)>
+ <bit 5-4: Only used if PkgLength < 63>
+ <bit 3-0: Least significant package length nybble>
+
+ 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", __func__));
+ goto Done;
+ }
+
+ break;
+ case AmlClose:
+ Status = InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locate Length object\n", __func__));
+ 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", __func__, "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",
+ __func__,
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
new file mode 100644
index 0000000000..4ef746327b
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDescriptor.c
@@ -0,0 +1,1989 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECODE
+
+/**
+ 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", __func__, "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", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__, "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", __func__));
+ 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", __func__));
+ 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", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX\n", __func__, 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", __func__, AddressMaximum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AddressMaximum == 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed = 1\n", __func__));
+ 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", __func__, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 1\n", __func__));
+ 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", __func__));
+ 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=0x%lX + 1)\n", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed = 0, IsMaxFixed = 0\n", __func__));
+ 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 0, IsMaxFixed = 0\n", __func__, 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", __func__, AddressGranularity));
+ DEBUG ((DEBUG_ERROR, "%a: When RangeLength=0x%lX > 0, IsMinFixed = 1, and IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength, AddressMaximum, AddressMinimum));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed = 1, IsMaxFixed = 1\n", __func__, 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", __func__, RangeLength));
+ DEBUG ((DEBUG_ERROR, "%a: IsMinFixed and IsMaxFixed must both be either 1 or 0\n", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, DmaType));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__, 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", __func__, 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", __func__, Shared));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__, "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", __func__, "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", __func__, Decode));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ 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", __func__, AddressMin));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, 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", __func__, AddressMax));
+ DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=0x%X\n", __func__, AddressAlignment));
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__, 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", __func__, AddressSpaceKeyword));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (AccessSize > EFI_ACPI_6_4_QWORD) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=0x%02X\n", __func__, AccessSize));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ 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", __func__, ReadAndWrite));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ListHead == NULL) {
+ // Invalid
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot == NULL.\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func__, "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", __func__, "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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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", __func__, (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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n", __func__));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) != 0) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n", __func__));
+ 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", __func__));
+ return Status;
+ }
+
+ Status = InternalAppendNewAmlObjectNoData (&Object, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "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", __func__, "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", __func__));
+ 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", __func__));
+ return EFI_INVALID_PARAMETER;
+ } else if (ISARanges > 3) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
new file mode 100644
index 0000000000..03201d0109
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementOpcodes.c
@@ -0,0 +1,515 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLSTATEMENTOPCODES_FILECODE
+
+/**
+ 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 pkglength termlist>
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ goto Done;
+ }
+
+ Status = AmlOPDataInteger (NotifyValue, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n", __func__));
+ goto Done;
+ }
+
+ Status = InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, ListHead);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: locating Return Object\n", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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", __func__));
+ 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/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
new file mode 100644
index 0000000000..c9a4399764
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlTable.c
@@ -0,0 +1,213 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLTABLE_FILECODE
+
+// 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", __func__, 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", __func__, 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", __func__, 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/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
new file mode 100644
index 0000000000..b1ad9b7037
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjects.c
@@ -0,0 +1,364 @@
+/** @file
+
+ Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "LocalAmlLib.h"
+#include <Filecode.h>
+
+#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE
+
+/**
+ 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 <all others> - 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 <all others> - 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 <all others> - 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", __func__));
+ 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 <all others> - 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 <all others> - 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", __func__, 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 <all others> - 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",
+ __func__,
+ 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 <all others> - 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;
+ UINT8 *TempBuffer;
+
+ 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", __func__));
+ 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
+ TempBuffer = ReallocatePool (
+ Object->DataSize,
+ Object->DataSize + ChildObject->DataSize,
+ Object->Data
+ );
+ if (TempBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ FreePool (Object->Data);
+ Object->Data = NULL;
+ DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __func__));
+ goto Done;
+ }
+
+ Object->Data = TempBuffer;
+ // 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/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
new file mode 100644
index 0000000000..2f4f676adb
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchStallLib.c
@@ -0,0 +1,13 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+/*----------------------------------------------------------------------------------------
+ * M O D U L E S U S E D
+ *----------------------------------------------------------------------------------------
+ */
+#include <Filecode.h>
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
new file mode 100644
index 0000000000..60305ee4a6
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseResetSystemLib.c
@@ -0,0 +1,90 @@
+/** @file
+ Library to support reset library, inheritted from Agesa Cf9Reset module.
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+#include <Library/IoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+/**
+ This function causes a system-wide reset (cold reset), in which
+ all circuitry within the system returns to its initial state. This type of reset
+ is asynchronous to system operation and operates without regard to
+ cycle boundaries.
+
+ If this function returns, it means that the system does not support cold reset.
+**/
+VOID
+EFIAPI
+ResetCold (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a system-wide initialization (warm reset), in which all processors
+ are set to their initial state. Pending cycles are not corrupted.
+
+ If this function returns, it means that the system does not support warm reset.
+**/
+VOID
+EFIAPI
+ResetWarm (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ If this function returns, it means that the system does not support shutdown reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes the system to enter S3 and then wake up immediately.
+
+ If this function returns, it means that the system does not support S3 feature.
+**/
+VOID
+EFIAPI
+EnterS3WithImmediateWake (
+ VOID
+ )
+{
+}
+
+/**
+ This function causes a systemwide reset. The exact type of the reset is
+ defined by the EFI_GUID that follows the Null-terminated Unicode string passed
+ into ResetData. If the platform does not recognize the EFI_GUID in ResetData
+ the platform must pick a supported reset type to perform.The platform may
+ optionally log the parameters from any non-normal reset that occurs.
+
+ @param[in] DataSize The size, in bytes, of ResetData.
+ @param[in] ResetData The data buffer starts with a Null-terminated string,
+ followed by the EFI_GUID.
+**/
+VOID
+EFIAPI
+ResetPlatformSpecific (
+ IN UINTN DataSize,
+ IN VOID *ResetData
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
new file mode 100644
index 0000000000..d10e676668
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLib.c
@@ -0,0 +1,87 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Filecode.h>
+#include <Uefi.h>
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] RegAddr Slave register address
+ *
+ * @retval Register Value
+ */
+UINT32
+FchEspiCmd_GetConfiguration (
+ IN UINT32 EspiBase,
+ IN UINT32 RegAddr
+ )
+{
+ return 0;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to read
+ * @param[in] Length Length in byte to read
+ * @param[in] Buffer Pointer to the data read to
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashRead (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ OUT UINT8 *Buffer
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to write
+ * @param[in] Length Length in byte to write
+ * @param[in] Value Pointer to the data to write
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashWrite (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length,
+ IN UINT8 *Value
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/*----------------------------------------------------------------------------------------*/
+
+/**
+ *
+ * @param[in] EspiBase Espi MMIO base
+ * @param[in] Address Address to erase
+ * @param[in] Length Block Size to erase
+ *
+ *
+ */
+EFI_STATUS
+FchEspiCmd_SafsFlashErase (
+ IN UINT32 EspiBase,
+ IN UINT32 Address,
+ IN UINT32 Length
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
new file mode 100755
index 0000000000..9044d3d497
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLib.c
@@ -0,0 +1,68 @@
+/** @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.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/NbioHandleLib.h>
+#include <Library/AmdBaseLib.h>
+
+/**
+ Get GNB handle
+
+ @param[in] Pcie Pointer to global PCIe configuration
+
+**/
+GNB_HANDLE *
+NbioGetHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of alternate host bridge (e.g. MI200)
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+GNB_HANDLE *
+NbioGetAltHandle (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return NULL;
+}
+
+/**
+ Get GNB handle of next socket
+
+ @param[in] NbioHandle Pointer to current GnbHandle
+**/
+GNB_HANDLE *
+NbioGetNextSocket (
+ IN GNB_HANDLE *NbioHandle
+ )
+{
+ return NULL;
+}
+
+/**
+ Get PCI_ADDR of GNB
+
+ @param[in] Handle Pointer to GNB_HANDLE
+**/
+PCI_ADDR
+NbioGetHostPciAddress (
+ IN GNB_HANDLE *Handle
+ )
+{
+ PCI_ADDR PciAddr;
+
+ PciAddr.AddressValue = 0;
+ return PciAddr;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
new file mode 100755
index 0000000000..d5fbe98d22
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLib.c
@@ -0,0 +1,276 @@
+/** @file
+ GNB function to create/locate PCIe configuration data area
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/GnbPcieConfigLib.h>
+
+/**
+ Check Port Status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] PortStatus Check if status asserted for port
+ @retval TRUE if status asserted
+**/
+BOOLEAN
+PcieConfigCheckPortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN UINT32 PortStatus
+ )
+{
+ return FALSE;
+}
+
+/**
+ Set/Reset port status
+
+ @param[in] Engine Pointer to engine config descriptor
+ @param[in] SetStatus SetStatus
+ @param[in] ResetStatus ResetStatus
+
+**/
+UINT16
+PcieConfigUpdatePortStatus (
+ IN PCIE_ENGINE_CONFIG *Engine,
+ IN PCIE_ENGINE_INIT_STATUS SetStatus,
+ IN PCIE_ENGINE_INIT_STATUS ResetStatus
+ )
+{
+ return 0;
+}
+
+/**
+ Execute callback on all descriptor of specific type
+
+ @param[in] InDescriptorFlags Include descriptor flags
+ @param[in] OutDescriptorFlags Exclude descriptor flags
+ @param[in] TerminationFlags Termination flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllDescriptors (
+ IN UINT32 InDescriptorFlags,
+ IN UINT32 OutDescriptorFlags,
+ IN UINT32 TerminationFlags,
+ IN PCIE_RUN_ON_DESCRIPTOR_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in topology
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+AGESA_STATUS
+PcieConfigRunProcForAllWrappers (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+ return AGESA_UNSUPPORTED;
+}
+
+/**
+ Execute callback on all wrappers in NBIO
+
+
+ @param[in] DescriptorFlags Wrapper Flags
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllWrappersInNbio (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_WRAPPER_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN GNB_HANDLE *GnbHandle
+ )
+{
+}
+
+/**
+ Execute callback on all engine in topology
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEngines (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Execute callback on all engine in wrapper
+
+ @param[in] DescriptorFlags Engine flags.
+ @param[in] Callback Pointer to callback function
+ @param[in, out] Buffer Pointer to buffer to pass information to callback
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigRunProcForAllEnginesInWrapper (
+ IN UINT32 DescriptorFlags,
+ IN PCIE_RUN_ON_ENGINE_CALLBACK2 Callback,
+ IN OUT VOID *Buffer,
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+}
+
+/**
+ Get parent descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetParent (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get child descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetChild (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Get peer descriptor of specific type
+
+ @param[in] Type Descriptor type
+ @param[in] Descriptor Pointer to buffer to pass information to callback
+**/
+PCIE_DESCRIPTOR_HEADER *
+PcieConfigGetPeer (
+ IN UINT32 Type,
+ IN PCIE_DESCRIPTOR_HEADER *Descriptor
+ )
+{
+ return NULL;
+}
+
+/**
+ Check is engine is active or potentially active
+
+ @param[in] Engine Pointer to engine descriptor
+ @retval TRUE - engine active
+ @retval FALSE - engine not active
+**/
+BOOLEAN
+PcieConfigIsActivePcieEngine (
+ IN PCIE_ENGINE_CONFIG *Engine
+ )
+{
+ return FALSE;
+}
+
+/**
+ Locate SB engine on wrapper
+
+ @param[in] Wrapper Pointer to wrapper config descriptor
+ @retval SB engine pointer or NULL
+**/
+PCIE_ENGINE_CONFIG *
+PcieConfigLocateSbEngine (
+ IN PCIE_WRAPPER_CONFIG *Wrapper
+ )
+{
+ return NULL;
+}
+
+/**
+ Helper function to dump engine configuration
+
+ @param[in] EngineList Engine Configuration
+**/
+VOID
+PcieConfigEngineDebugDump (
+ IN PCIE_ENGINE_CONFIG *EngineList
+ )
+{
+}
+
+/**
+ Helper function to dump wrapper configuration
+
+ @param[in] WrapperList Wrapper Configuration
+**/
+VOID
+PcieConfigWrapperDebugDump (
+ IN PCIE_WRAPPER_CONFIG *WrapperList
+ )
+{
+}
+
+/**
+ Helper function to dump configuration to debug out
+
+ @param[in] Pcie Pointer to global PCIe configuration
+**/
+VOID
+PcieConfigDebugDump (
+ IN PCIE_PLATFORM_CONFIG *Pcie
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to user engine descriptor
+
+ @param[in] EngineDescriptor Pointer to engine descriptor
+**/
+VOID
+PcieUserDescriptorConfigDump (
+ IN PCIE_ENGINE_DESCRIPTOR *EngineDescriptor
+ )
+{
+}
+
+/**
+ Helper function to dump input configuration to debug out
+
+ @param[in] ComplexDescriptor Pointer to user defined complex descriptor
+**/
+VOID
+PcieUserConfigConfigDump (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor
+ )
+{
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
new file mode 100755
index 0000000000..5c6be22ee4
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParserLib.c
@@ -0,0 +1,117 @@
+/** @file
+ Procedure to parse PCIe input configuration data
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <GnbDxio.h>
+
+/**
+ Get number of complexes in platform topology configuration
+
+ @param[in] ComplexList First complex configuration in complex configuration array
+ @retval Number of Complexes
+
+**/
+UINTN
+PcieInputParserGetNumberOfComplexes (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of PCIe engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfPcieEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of DDI engines in given complex
+
+ @param[in] Complex Complex configuration
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetLengthOfDdiEnginesList (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get number of engines in given complex
+
+
+
+ @param[in] Complex Complex configuration header
+ @retval Number of Engines
+**/
+UINTN
+PcieInputParserGetNumberOfEngines (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex
+ )
+{
+ return 0;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] Index Complex descriptor Index
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Complex descriptor by index from given Platform configuration
+
+ @param[in] ComplexList Platform topology configuration
+ @param[in] SocketId Socket Id
+ @retval Pointer to Complex Descriptor
+**/
+PCIE_COMPLEX_DESCRIPTOR *
+PcieInputParserGetComplexDescriptorOfSocket (
+ IN PCIE_COMPLEX_DESCRIPTOR *ComplexList,
+ IN UINT32 SocketId
+ )
+{
+ return NULL;
+}
+
+/**
+ Get Engine descriptor from given complex by index
+
+ @param[in] Complex Complex descriptor
+ @param[in] Index Engine descriptor index
+ @retval Pointer to Engine Descriptor
+**/
+PCIE_ENGINE_DESCRIPTOR *
+PcieInputParserGetEngineDescriptor (
+ IN PCIE_COMPLEX_DESCRIPTOR *Complex,
+ IN UINTN Index
+ )
+{
+ return NULL;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
new file mode 100644
index 0000000000..e6be32b071
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAccessLib.c
@@ -0,0 +1,10 @@
+/** @file
+ SMN Register Access Methods
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/SmnAccessLib.h>
diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
new file mode 100644
index 0000000000..1dc13900c7
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunctions.c
@@ -0,0 +1,42 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <GnbDxio.h>
+#include <Library/AmdBaseLib.h>
+#include <Library/PcieConfigLib.h>
+#include <Library/NbioCommonLibDxe.h>
+
+/**
+ Function to retrieve SOC_LOGICAL_ID
+
+ @param[out] LogicalId Pointer to SOC_LOGICAL_ID
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetLogicalId (
+ OUT SOC_LOGICAL_ID *LogicalId
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Function to retrieve PCIE_PLATFORM_CONFIG
+
+ @param[out] Pcie Pointer to PCIE_PLATFORM_CONFIG Pointer
+ @retval EFI_UNSUPPORTED
+
+**/
+EFI_STATUS
+PcieGetPcieDxe (
+ OUT PCIE_PLATFORM_CONFIG **Pcie
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
new file mode 100644
index 0000000000..fbd3ddcf37
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV3Dxe.c
@@ -0,0 +1,23 @@
+/** @file
+ APCB DXE Driver
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PcdLib.h>
+
+EFI_STATUS
+EFIAPI
+AmdApcbV3DxeDriverEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
new file mode 100644
index 0000000000..23d1a8fee0
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV3Pei.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+
+/**
+ * @brief Amd Apcb V3 Pei Driver Entry
+ *
+ * @param[in] FileHandle File Handie
+ * @param[in] PeiServices Pei Services
+ *
+ * @retval EFI_SUCCESS Set APCB value successfully
+ * Non-EFI_SUCCESS Function Error
+ *
+ **/
+EFI_STATUS
+EFIAPI
+AmdApcbV3PeiDriverEntry (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
new file mode 100644
index 0000000000..74b129931b
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.c
@@ -0,0 +1,39 @@
+/** @file
+ Required OEM hooks for CCX initialization
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Uefi.h>
+
+/**
+ Hook to store the vector that all APs should jump to out of reset to a non-volatile,
+ shared location.
+
+ @param[in] ApInitAddress Address of the code that AP should jump to
+ @param[in,out] ContentToRestore The current value in the non-volatile storage
+
+**/
+VOID
+SaveApInitVector (
+ IN UINT32 ApInitAddress,
+ IN OUT UINT32 *ContentToRestore
+ )
+{
+}
+
+/**
+ Hook to restore the initial content of the non-volatile storage location.
+
+ @param[in] ContentToRestore The value to restore
+
+**/
+VOID
+RestoreContentVector (
+ IN UINT32 ContentToRestore
+ )
+{
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
new file mode 100644
index 0000000000..54ce202cb1
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpressPciCfg2.c
@@ -0,0 +1,33 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Ppi/PciCfg2.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
+#include <Library/IoLib.h>
+
+/**
+ Module's entry function.
+ This routine will install EFI_PEI_PCI_CFG2_PPI.
+
+ @param FileHandle Handle of the file being invoked.
+ @param PeiServices Describes the list of possible PEI Services.
+
+ @return Whether success to install service.
+**/
+EFI_STATUS
+EFIAPI
+PeimInitializePciCfg (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN CONST EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
new file mode 100644
index 0000000000..643174d7b9
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLib/PciSegmentInfoLib.c
@@ -0,0 +1,30 @@
+/** @file
+
+ Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/PciSegmentInfoLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseLib.h>
+
+/**
+ Return an array of PCI_SEGMENT_INFO holding the segment information.
+
+ Note: The returned array/buffer is owned by callee.
+
+ @param Count Return the count of segments.
+
+ @retval A callee owned array holding the segment information.
+**/
+PCI_SEGMENT_INFO *
+EFIAPI
+GetPciSegmentInfo (
+ UINTN *Count
+ )
+{
+ return (PCI_SEGMENT_INFO *)NULL;
+}
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
new file mode 100644
index 0000000000..d83bb6c2d8
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c
@@ -0,0 +1,15 @@
+/** @file
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiSmm.h>
+#include <Register/Cpuid.h>
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmServicesTableLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/SmmBase2.h>
+#include <Library/IoLib.h>
diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
new file mode 100644
index 0000000000..a264eb9294
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmorWhitelistLib.c
@@ -0,0 +1,12 @@
+/** @file
+ Platform ROM Armor Whitelist table
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
new file mode 100644
index 0000000000..e379538e3a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c
@@ -0,0 +1,36 @@
+/** @file
+ OEM OOB PPR DXE Driver.
+
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiDxe.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Protocol/PciIo.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TimerLib.h>
+#include <IndustryStandard/Pci22.h>
+
+/**
+* This function installs a protocol used by platform BIOS to provide the hotplug descriptor.
+*
+* @param[in] ImageHandle Image handler
+* @param[in] SystemTable Pointer to the system table
+*
+* @retval EFI_SUCCESS The thread was successfully launched.
+*
+**/
+EFI_STATUS
+EFIAPI
+OobPprEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
new file mode 100644
index 0000000000..5242e6261a
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspPlatformDriver.c
@@ -0,0 +1,20 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <Library/BaseLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+EFI_STATUS
+EFIAPI
+PspPlatformEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
new file mode 100644
index 0000000000..530bd9d4b6
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/ServerHotplugDxe.c
@@ -0,0 +1,22 @@
+/** @file
+
+ Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+EFI_STATUS
+EFIAPI
+HotplugDescEntry (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return EFI_SUCCESS;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
new file mode 100644
index 0000000000..fbc372586b
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCommand.c
@@ -0,0 +1,44 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ 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/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
new file mode 100644
index 0000000000..0a5f4a7e81
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.c
@@ -0,0 +1,36 @@
+/** @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.<BR>
+
+ 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;
+}
diff --git a/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
new file mode 100644
index 0000000000..47eb700f8f
--- /dev/null
+++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c
@@ -0,0 +1,29 @@
+/** @file
+
+ Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/IoLib.h>
+
+/**
+ Performs platform specific initialization required for the CPU to access
+ the hardware associated with a SerialPortLib instance. This function does
+ not intiailzie the serial port hardware itself. Instead, it initializes
+ hardware devices that are required for the CPU to access the serial port
+ hardware. This function may be called more than once.
+
+ @retval RETURN_SUCCESS The platform specific initialization succeeded.
+ @retval RETURN_DEVICE_ERROR The platform specific initialization could not be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
diff --git a/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
new file mode 100644
index 0000000000..72b9a87639
--- /dev/null
+++ b/Platform/AMD/AgesaModulePkg/Fch/Songshan/FchSongshanDxe/FchSongshanI2C_I3C.asl
@@ -0,0 +1,9 @@
+/** @file
+
+ Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
diff --git a/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
new file mode 100644
index 0000000000..2dfb3190d4
--- /dev/null
+++ b/Platform/AMD/AgesaPkg/Include/AmdUefiStackNasm.inc
@@ -0,0 +1,13 @@
+; @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.<BR>
+;
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+%macro AMD_ENABLE_UEFI_STACK2 2-3
+
+%endmacro
diff --git a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
index a731c7e369..937caee083 160000
--- a/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
+++ b/Silicon/RISC-V/ProcessorPkg/Library/RiscVOpensbiLib/opensbi
@@ -1 +1 @@
-Subproject commit a731c7e36988c3308e1978ecde491f2f6182d490
+Subproject commit 937caee0833115f69d697ca190001ba0aa5c7368
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119201): https://edk2.groups.io/g/devel/message/119201
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 1428813 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-23 8:30 ` Yao, Ken via groups.io
@ 2024-05-24 4:40 ` Paul via groups.io
2024-05-24 5:02 ` Abdul Lateef Attar via groups.io
0 siblings, 1 reply; 16+ messages in thread
From: Paul via groups.io @ 2024-05-24 4:40 UTC (permalink / raw)
To: Yao, Ken, Zhai, MingXin (Duke), Chang, Abner,
devel@edk2.groups.io
Cc: Attar, AbdulLateef (Abdul Lateef), Fu, Igniculus, Xing, Eric
[-- Attachment #1: Type: text/plain, Size: 7668 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks for the up-stream, Abner.
Looks good to me.
Reviewed-by: Paul Grimes <paul.grimes@amd.com>
________________________________
From: Yao, Ken <Ken.Yao@amd.com>
Sent: Thursday, May 23, 2024 1:30:48 AM
To: Zhai, MingXin (Duke) <duke.zhai@amd.com>; Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
[AMD Official Use Only - AMD Internal Distribution Only]
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
Reviewed-by: Ken Yao <Ken.Yao@amd.com>
-----Original Message-----
From: Zhai, MingXin (Duke) <duke.zhai@amd.com>
Sent: Thursday, May 23, 2024 3:47 PM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>
Subject: RE: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
[AMD Official Use Only - AMD Internal Distribution Only]
Thanks Abner for the up-stream.
Looks good to me.
-----Original Message-----
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Thursday, May 23, 2024 12:12 PM
To: devel@edk2.groups.io
Cc: Grimes, Paul <Paul.Grimes@amd.com>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Fu, Igniculus <Igniculus.Fu@amd.com>; Yao, Ken <Ken.Yao@amd.com>; Xing, Eric <Eric.Xing@amd.com>; Zhai, MingXin (Duke) <duke.zhai@amd.com>
Subject: [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
From: Abner Chang <abner.chang@amd.com>
Cc: Paul Grimes <paul.grimes@amd.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Cc: Igniculus Fu <igniculus.fu@amd.com>
Cc: Ken Yao <ken.yao@amd.com>
Cc: Eric Xing <eric.xing@amd.com>
Cc: Duke Zhai <Duke.Zhai@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com>
---
Platform/AMD/Readme.md | 64 ++++++++++++++++++++++++++++++++----------
1 file changed, 49 insertions(+), 15 deletions(-)
diff --git a/Platform/AMD/Readme.md b/Platform/AMD/Readme.md index 99d2b990c7..3297c6ba59 100644
--- a/Platform/AMD/Readme.md
+++ b/Platform/AMD/Readme.md
@@ -7,18 +7,25 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Term and Definitions
+* **AGESA**
+
+ AMD Generic Encapsulated Software Architecture that are executed as
+ part of a host platform BIOS.
+
* **AMD Platform** (platform in short)
- AMD platform refers to a platform that supports the particular AMD SoC (processor), such as AMD EPYC Milan and Genoa processors.
+ AMD platform refers to a platform that supports the particular AMD
+ SoC (processor), such as AMD EPYC Milan and Genoa processors.
* **AMD Board** (board in short)
AMD board is a generic terminology refers to a board that is designed based on a
specific AMD SoC architecture (also referred as AMD platform). More than one boards
- are possibly designed to support an AMD platform with different configuration, such as 1-processor socket or 2-processor sockets board.
+ are possibly designed to support an AMD platform with different
+ configuration, such as 1-processor socket or 2-processor sockets board.
* **AMD edk2 Platform Package** (platform package in short)
-
+
The folder has the AMD edk2 platform common modules.
* **AMD edk2 Board Package** (board package in short) @@ -28,29 +35,52 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
## Package Definition
+* **AgesaModulePkg**
+
+ This package contains all of the private interfaces and build
+ configuration files for the AGESA support.
+
+* **AgesaPkg**
+
+ This package contains all of the public interfaces and build
+ configuration files for the AGESA support.
+
+* **AmdCbsPkg**
+
+ AMD Configurable BIOS Setting. Provides the edk2 formset following
+ the UEFI HII spec to configure BIOS settings.
+
+* **AmdCpmPkg**
+
+ AMD Common Platform Module software is a BIOS procedure library
+ designed to aid AMD customers to quickly implement AMD platform technology into their products.
+
* **AmdPlatformPkg**
- AMD platform edk2 package under this folder provides the common edk2 modules those
- are leverage by platforms. Usually those modules have no dependencies with
- particular platforms. The module under this scope can provides a common implementation
- for all platforms, or it may just provide a framework but the differences of implementation could be configured through the PCDs declared in AmdPlatformPkg.dec, or
- the board level library provided in the \<Board name\>Pkg.
+ AMD platform edk2 package under this folder provides the common edk2
+ modules that are leveraged by platforms. Usually those modules have no
+ dependencies with particular platforms. Modules under this scope can
+ provide a common implementation for all platforms, or may just
+ provide a framework but the differences of implementation could be
+ configured through the PCDs declared in AmdPlatformPkg.dec, or the board level library provided in the \<Board name\>Pkg.
* **AmdMinBoardPkg**
- This package provides the common edk2 modules those can be leverage across AMD boards those use MinPlatformPkg framework.
+ This package provides the common edk2 modules that can be leveraged
+ across AMD boards using the MinPlatform framework.
* **\<SoC name\>Board**
- This is the folder named by SoC and accommodate one or multiple board packages those
- are designed base on the same SoC platform. <SoC name>Board folder may contain edk2
- package meta files directly or the sub-folders named by \<Board name\>Pkg for a
- variety configurations of a platform.
+ This is the folder named by SoC and accommodates one or multiple
+ board packages that are designed based on the same SoC platform. <SoC
+ name>Board folder may contain edk2 package meta files directly or the
+ sub-folders named by \<Board name\>Pkg for a variety configurations of a platform.
* **<Board name\>Pkg**
- This is the folder that contains edk2 package meta files for a board which is designed base on a platform. Besides the edk2 meta files, <Board name\>Pkg may also provides
- edk2 modules which are specifically to a board.
+ This is the folder that contains edk2 package meta files for a board
+ which is designed base on a platform. Besides the edk2 meta files,
+ <Board name\>Pkg may also provides edk2 modules which are specifically to a board.
```
e.g. OverdriveBoard
@@ -63,6 +93,10 @@ booting certain AMD platforms. The definition of sub-folders is described in bel
```
Platform/AMD
+ |----AgesaModulePkg
+ |----AgesaPkg
+ |----AmdCbsPkg
+ |----AmdCpmPkg
|----AmdPlatformPkg
|----AmdMinBoardPkg
|----OverdriveBoard
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119202): https://edk2.groups.io/g/devel/message/119202
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 11614 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages
2024-05-24 2:00 ` Abdul Lateef Attar via groups.io
@ 2024-05-24 4:46 ` Paul via groups.io
0 siblings, 0 replies; 16+ messages in thread
From: Paul via groups.io @ 2024-05-24 4:46 UTC (permalink / raw)
To: devel@edk2.groups.io, Attar, AbdulLateef (Abdul Lateef),
michael.d.kinney@intel.com, Chang, Abner
Cc: Leif Lindholm
[-- Attachment #1: Type: text/plain, Size: 3650 bytes --]
[AMD Official Use Only - AMD Internal Distribution Only]
Reviewed-by: Paul Grimes <paul.grimes@amd.com<mailto:paul.grimes@amd.com>>
________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Abdul Lateef Attar via groups.io <AbdulLateef.Attar=amd.com@groups.io>
Sent: Thursday, May 23, 2024 7:00:03 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; michael.d.kinney@intel.com <michael.d.kinney@intel.com>; Chang, Abner <Abner.Chang@amd.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Subject: Re: [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Reviewed-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto:AbdulLateef.Attar@amd.com>
On 23-05-2024 21:57, Michael D Kinney via groups.io wrote:
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com><mailto:michael.d.kinney@intel.com>
-----Original Message-----
From: abner.chang@amd.com<mailto:abner.chang@amd.com> <abner.chang@amd.com><mailto:abner.chang@amd.com>
Sent: Wednesday, May 22, 2024 9:12 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Leif Lindholm <quic_llindhol@quicinc.com><mailto:quic_llindhol@quicinc.com>; Kinney, Michael D
<michael.d.kinney@intel.com><mailto:michael.d.kinney@intel.com>
Subject: [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries
for AMD packages
From: Abner Chang <abner.chang@amd.com><mailto:abner.chang@amd.com>
Signed-off-by: Abner Chang <abner.chang@amd.com><mailto:abner.chang@amd.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com><mailto:quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com><mailto:michael.d.kinney@intel.com>
---
Maintainers.txt | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/Maintainers.txt b/Maintainers.txt
index 877620a1b0..af688c3813 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -86,8 +86,20 @@ M: Leif Lindholm <quic_llindhol@quicinc.com><mailto:quic_llindhol@quicinc.com>
AMD
F: Platform/AMD
M: Abner Chang <abner.chang@amd.com><mailto:abner.chang@amd.com>
-M: Abdul Lateef Attar <abdattar@amd.com><mailto:abdattar@amd.com>
+M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto:AbdulLateef.Attar@amd.com>
+M: Paul Grimes <paul.grimes@amd.com><mailto:paul.grimes@amd.com>
+
+F: Platform/AMD/AgesaModulePkg
+F: Platform/AMD/AgesaPkg
+F: Platform/AMD/AmdCbsPkg
+M: Paul Grimes <paul.grimes@amd.com><mailto:paul.grimes@amd.com>
+R: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto:AbdulLateef.Attar@amd.com>
+R: Abner Chang <abner.chang@amd.com><mailto:abner.chang@amd.com>
+
+F: Platform/AMD/AmdCpmPkg
+M: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto:AbdulLateef.Attar@amd.com>
R: Paul Grimes <paul.grimes@amd.com><mailto:paul.grimes@amd.com>
+R: Abner Chang <abner.chang@amd.com><mailto:abner.chang@amd.com>
AMD Seattle
F: Platform/AMD/OverdriveBoard/
--
2.37.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119203): https://edk2.groups.io/g/devel/message/119203
Mute This Topic: https://groups.io/mt/106257081/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 8328 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces
2024-05-24 4:39 ` Paul via groups.io
@ 2024-05-24 4:56 ` Abdul Lateef Attar via groups.io
0 siblings, 0 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-05-24 4:56 UTC (permalink / raw)
To: Paul, devel
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
Reviewed-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com> ( AbdulLateef.Attar@amd.com )
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119204): https://edk2.groups.io/g/devel/message/119204
Mute This Topic: https://groups.io/mt/106257082/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 2969 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md
2024-05-24 4:40 ` Paul via groups.io
@ 2024-05-24 5:02 ` Abdul Lateef Attar via groups.io
0 siblings, 0 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2024-05-24 5:02 UTC (permalink / raw)
To: Paul, devel
[-- Attachment #1: Type: text/plain, Size: 427 bytes --]
Reviewed-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119205): https://edk2.groups.io/g/devel/message/119205
Mute This Topic: https://groups.io/mt/106257080/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 845 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2024-05-24 5:02 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-23 4:12 [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Chang, Abner via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/AMD: Update Readme.md Chang, Abner via groups.io
2024-05-23 7:25 ` Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
2024-05-23 8:30 ` Yao, Ken via groups.io
2024-05-24 4:40 ` Paul via groups.io
2024-05-24 5:02 ` Abdul Lateef Attar via groups.io
2024-05-23 4:12 ` [edk2-devel] [edk2-platforms][PATCH 3/3] edk2-platform/Maintainer: Add entries for AMD packages Chang, Abner via groups.io
2024-05-23 16:27 ` Michael D Kinney
2024-05-24 2:00 ` Abdul Lateef Attar via groups.io
2024-05-24 4:46 ` Paul via groups.io
2024-05-23 7:26 ` [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Xing, Eric via groups.io
2024-05-23 7:47 ` Zhai, MingXin (Duke) via groups.io
2024-05-23 8:31 ` Yao, Ken via groups.io
2024-05-24 4:39 ` Paul via groups.io
2024-05-24 4:56 ` Abdul Lateef Attar via groups.io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox