From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1FB9EAC0CE5 for ; Thu, 23 May 2024 07:48:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=LKxiaNdYeGPLvDpuxuPP1w69i9kf8EX/AfLJBj/mGas=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1716450480; v=1; b=yDqn9axBoEEiorpLPqU8w4XuTy/P6RBlKqiECvWqTC/PFB9+s3b/tPuV+toLImBeqVq6u6En NftML+mBRqBQgn7ghqjIBeWpzA7V2QqJnSDu5Vxb923N53kQSqN8sCrvDqHmv98ewVZbQ90+qDk lXpnXPkosF3r4aGxTY34FhmLGTblWBFOHRrb1Rwm+MLTtWyNoIUhy2kgBoEikcJeRoxS1G0mACD vHgi6XXJ4f0erIX0jV6P3yufmQb0mvEsvMn2dP+iaXTWwTgfzKQ/CKm2azCoxG2jJ0V+E+0Ptkq ic1TtzT3sXAV2ErugUhqVTyCUNvRnj1Z9/LTDYsl5Ykdg== X-Received: by 127.0.0.2 with SMTP id bbJiYY7687511xfQF040nyWE; Thu, 23 May 2024 00:48:00 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.49]) by mx.groups.io with SMTP id smtpd.web10.10126.1716450476865618134 for ; Thu, 23 May 2024 00:47:57 -0700 X-Received: from DS0PR12MB9445.namprd12.prod.outlook.com (2603:10b6:8:1a1::19) by CH3PR12MB8073.namprd12.prod.outlook.com (2603:10b6:610:126::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.36; Thu, 23 May 2024 07:47:44 +0000 X-Received: from DS0PR12MB9445.namprd12.prod.outlook.com ([fe80::a499:b8c8:dccb:9bfc]) by DS0PR12MB9445.namprd12.prod.outlook.com ([fe80::a499:b8c8:dccb:9bfc%5]) with mapi id 15.20.7611.016; Thu, 23 May 2024 07:47:44 +0000 From: "Zhai, MingXin (Duke) via groups.io" To: "Chang, Abner" , "devel@edk2.groups.io" CC: "Grimes, Paul" , "Attar, AbdulLateef (Abdul Lateef)" , "Fu, Igniculus" , "Yao, Ken" , "Xing, Eric" Subject: Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Thread-Topic: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross platform/board interfaces Thread-Index: AQHarMeEkw/oxtscbUGeZjeuCeS8l7GkcWCw Date: Thu, 23 May 2024 07:47:43 +0000 Message-ID: References: <20240523041209.1661-1-abner.chang@amd.com> In-Reply-To: <20240523041209.1661-1-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ActionId=cbf6458e-2e33-44c8-813e-c797c1f00a84;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ContentBits=0;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Enabled=true;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Method=Standard;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Name=AMD Internal Distribution Only;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SetDate=2024-05-23T07:47:31Z;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR12MB9445:EE_|CH3PR12MB8073:EE_ x-ms-office365-filtering-correlation-id: 893a6bc8-9d19-4c65-ec77-08dc7afca12c x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?/z+NOp2cioaBFpbnbdI7Mc8D182kn0x41Zxh0Sm04HohzLUEHgR17W1GMbTa?= =?us-ascii?Q?akZGAXUlS1swghc2yQ+CbRrzG/b3G7utKK7136jNl7PYU023J0hY+coh5oso?= =?us-ascii?Q?6xFV3gYKHiN6MfaeCuaLl07YRS99CpB6XtPfcAHXOrnLZhN7kctVyH+CaqFA?= =?us-ascii?Q?FCtMF1z/qvqQdN08+zILEfWpzu9UzWSAK1AYwc1453hddiY9sixe8xUcyPC5?= =?us-ascii?Q?6Va1olGi5P2PodjsjDtgHn2oY9wXsesh/niiGmytQMrM4LXrbqfPlXNF2dcW?= =?us-ascii?Q?1vjjm6xTprzS2g+1zRK9XuE4CC4g7vwU4VwBth2H6D8uHsMsJumEsEuhI6hf?= =?us-ascii?Q?Z5WnwwmK2SetY6GH0QSw/F98hrIKg5yrEtgvtyQB7TmL7tavehWuKg0aranO?= =?us-ascii?Q?40krYgy5j0kWKTEu7zoaghxa4wAKR12WmQvUjZSNpn/Z3xXE0a2BOQMEEG9O?= =?us-ascii?Q?z+XG9HUguKbSn0AdqlHncV8WLwI4Q+UOMJBsxA3uu+mGWRQ1PV5TRqUrBB6B?= =?us-ascii?Q?ioYEc+qvmY0IejMR4+1u05UDMp/qTQ3E0RpDHIAm3NkN30oVY/ogPH/3hNmu?= =?us-ascii?Q?4v5xAGhPgHW6LYdnps14guKkVBnq5eFspNAoQb8RJVDiemCUGhAMV4C1K06S?= =?us-ascii?Q?Wds8Xmi0XbNhFgvnId5MRhNhwrBglTENMkzVIC+ZimQIEXqiRjZXfhW1GjTB?= =?us-ascii?Q?JcnUc4TBskEOtBACp4FLT5xUJxn4i4O1yCAgOpu8G3Yomy5ohT0H2qcOkfcI?= =?us-ascii?Q?ktpzZ0epgeuue0bWySnlp/TuQ6eGOvzasXzm5iqDLMcNyTMfU0Zo9/5wQyXw?= =?us-ascii?Q?QzQBPIgCZ0vQK8YYlTbBDwLepgL74g8AaoajZhixZ3szBTHopx0bjO960GgX?= =?us-ascii?Q?+8narX5ivhgpLu2ajN4VB7AFR8bRmOm3qLLE9HhRAPtpcy4X3qAnnEUzcWLY?= =?us-ascii?Q?hbDAXDqV1oDnuy4LX8j4VjoEbQXcIcAzQeutMK2zx7xYe3nB3jOSJ3Wmq0UZ?= =?us-ascii?Q?1KRPhHPZHQORqEVWOKZ1QCA4WyNpQjDwiPQJ0PI4YudR2EF0mvuwU1z+ft13?= =?us-ascii?Q?eY4emvqByjHDzTzyVNIyKAkwKpPCXGTGBtkSZlsD589KaQbKkFpVu3kmf9Ol?= =?us-ascii?Q?4MBXw6PI7nurJG6yGLMIWsnsZca36hjgwyLQVUIWmPVtw6DPT93pFoWsuKHa?= =?us-ascii?Q?xC/vcRho4Ldw6Rv0qnM5UqVCu5f0JkOHuwxbQFJk76c64dst+k8Ekr3CdOlI?= =?us-ascii?Q?PEdA3jDx/133Qo2jTr55iAw2xF8xrruqjnEvu9VTfiYWPyUx5Glv8UGOYbE8?= =?us-ascii?Q?lHH0ozssmWhuZhNQzIqMz3B1ye0ZvdvHBwIwrRgmEVSmHQ=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?mqkrdUVn21L/Cf7Chh+KVc5/fXui3jZfU3og1w9n5cEzMebuNSoqH527gQHg?= =?us-ascii?Q?gabrtgl94pXMAjeX4Sj331kd0ED6SYaSCgfAStNKkRbNu9Q5d/Es9m9A0Vax?= =?us-ascii?Q?MG3at32BGxi3YKIiiHjnklmT0gZQceq7trzd6R3fkE86kemKp0UFD1MYENbg?= =?us-ascii?Q?6AFCan2ie/Tg7So67JQbdRUYSipkC1bCPjLY/2F2g2xG+I8+ffOM6YN5OYyI?= =?us-ascii?Q?wSWZSWBIs+rwnapF8plhjdQj2c5Weq9EoMTXHmsMyKBAnMnMBkF+xbLCuKK9?= =?us-ascii?Q?H/BjcfZ37M7I3Ou4i/IFDJmGSoDtGA/orFptcg+hFETu8+uthnQxyGWtH5t4?= =?us-ascii?Q?VqKuk9y9YD9h78DBoGlthwv4OY6aOCsozRtnsH5THcap4YeoyzBGodHVx3ax?= =?us-ascii?Q?CtgHX7ht+/058w4xMlCpSZK/dCLINcvgDtqbeLLKaIFzxU/E9PuEpk3ju/RT?= =?us-ascii?Q?rU3HSecAjiCWSNT98g8M0+bb7I332g+kkdYAQjl0UDsrFUzcz9Eg2rqiiROe?= =?us-ascii?Q?ZKjHNhXqsVW0R0DZs5oyNQH07jNIZeZUYiWf7q1u21wM6phcwM3dw+hdRESf?= =?us-ascii?Q?EwespxulVCik2RH0bAxWORbBwO8ZW94c2GcH41o7YkIIAwOpwrFxyTVlcNbu?= =?us-ascii?Q?bNf48HUS55/LpRR5tB5mL9C0FSyCtCzCGQ4ZiZWo8JMhn+nz9bNPnxdrwyfM?= =?us-ascii?Q?ISvQCGEcRnIddvD2gPh+rRtEOTnwpex9vk+pvLdH0viL4mNP9xEjmqi33Awr?= =?us-ascii?Q?fk1zsvF1yFcrWTQegO3n1aEXRNG5cD4xEuauKeQJ/RRRqhtoY6jVpFvJv/Z3?= =?us-ascii?Q?zoFeh8I+Bj98s4i+uMt9g+nK6ijXA2Rs02T9OIM+kUoqmiGZPe+OeEP3/Kwj?= =?us-ascii?Q?DlslwQ31e6t9Eub4mbjFEDJA/G+dwh91zz6Ug/qVlpi687KDFlWUz3Zowbb6?= =?us-ascii?Q?53AtHkNp0WITLpbbcsNrqU7sfEr5kFg0Nuken1CWVcvKN+bwjQwe/oNyEehb?= =?us-ascii?Q?qW/boFg4WcLwDOO2o6EixwKFH4lJ52/sYUtPjCJzaBXJLgmk7Giv4dU2jDXU?= =?us-ascii?Q?5ft7tgfN+Qc5FeARcZPqxEwI4fx1Jh4YApBo+W4KfddC4mjhgsNFm2ooGqSP?= =?us-ascii?Q?ULoK+UEZUiaA4hya8hLmeZfQ5+3HGJ+94vBvs4/KApAMNVdlXqIRqDBRe0kO?= =?us-ascii?Q?uTFRygWRDzT9Cii0mtD2THf69QXfoGRhB+U8MU2VDggy1fepZesZ1F9uN7X5?= =?us-ascii?Q?oEXRsgxb2ynbMa+Dmk63BIVm9O7l/5gi7uEtS2e4RzzoSAGZXD4RFrjqvmUb?= =?us-ascii?Q?MJUkV2DH14XQ/IJcFuqnRnzZLbWt2eXv4rHQPYQXF4w74vhUlS4lGUZMpMOl?= =?us-ascii?Q?zR0QgwGAgsHxhF5hyQ9hwugknEzbX+nYQmHbkcxoFcUN37vE2hGP2+WEaEvJ?= =?us-ascii?Q?C5anSXq+yMl/vIIPWZ3SNc+pZ2drDZCUr6Rd9fyNVW8WV41iGt/3ajP0QbQB?= =?us-ascii?Q?O7u98LuXmh0Ek3rinpN40lJDRlH9rJ3Vbmg1XwaWOmxrS5Y/Dj+yiOP8Iuz/?= =?us-ascii?Q?9FjoGbWBhctZoTrVx1k=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB9445.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 893a6bc8-9d19-4c65-ec77-08dc7afca12c X-MS-Exchange-CrossTenant-originalarrivaltime: 23 May 2024 07:47:43.3707 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uaE+i3Yn4ll7i0WFk02spM274HX7tuLtt9LOG65asmhx9SEh8u/+vqxW985yGC6CEcQd5Hq0wZIDqtPTR3IeLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8073 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 23 May 2024 00:47:57 -0700 Resent-From: duke.zhai@amd.com Reply-To: devel@edk2.groups.io,duke.zhai@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZEmyqesCs3GEEHjm5jyTn5njx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=yDqn9axB; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io [AMD Official Use Only - AMD Internal Distribution Only] Thanks Abner for the up-stream. Looks good to me. -----Original Message----- From: Chang, Abner Sent: Thursday, May 23, 2024 12:12 PM To: devel@edk2.groups.io Cc: Grimes, Paul ; Attar, AbdulLateef (Abdul Lateef) <= AbdulLateef.Attar@amd.com>; Fu, Igniculus ; Yao, Ken = ; Xing, Eric ; Zhai, MingXin (Duke) Subject: [edk2-platforms][PATCH 1/3] Platform/AMD: Initial commit of cross = platform/board interfaces From: Abner Chang 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 Cc: Abdul Lateef Attar Cc: Igniculus Fu Cc: Ken Yao Cc: Eric Xing Cc: Duke Zhai Signed-off-by: Abner Chang --- .../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.ds= c create mode 100644 Platform/AMD/AgesaModulePkg/AgesaSp5RsModulePkg.inc.dsc create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInsta= nceNull.inc.dsc create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Ge= noa/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/CbsInsta= nceNull.dxe.inc.fdf create mode 100644 Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInsta= nceNull.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/Ge= noa/AmdCpmGenoaQuartzPkg.dxe.inc.fdf create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Ge= noa/AmdCpmGenoaQuartzPkg.fdf create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Ge= noa/AmdCpmGenoaQuartzPkg.pei.inc.fdf create mode 100755 Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCa= lloutLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/Amd= PspMboxLibV2.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/A= mdPspRomArmorLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNu= ll/AmdPspRomArmorLibNull.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3= .inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLi= bV3Pei.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyR= sLib/BaseFabricTopologyRsLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/Base= TscTimerLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeT= scTimerLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiT= scTimerLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridge= Lib/PciHostBridgeLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib= /AmlGenerationLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseLib/FchBaseL= ib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemL= ib/FchBaseResetSystemLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEs= piCmdLib.inf create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioH= andleLib.inf create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieC= onfigLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAcc= essLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/Nbio= CommonDxeLib.inf create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV= 3Dxe.inf create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV= 3Pei.inf create mode 100755 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformL= ibNull/OemAgesaCcxPlatformLibNull.inf create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPc= iCfg2/PciExpressPciCfg2.inf create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPc= iSegmentInfoLib/PciExpressPciSegmentInfoLib.inf create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNor= LibSmm/AmdPspFlashAccSpiNorLibSmm.inf create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelist= Lib/PspRomArmorWhitelistLib.inf create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe= .inf create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatf= ormDriver/PspPlatform.inf create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHo= tplugDxe/ServerHotplugDxe.inf create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/Am= dAutoDynamicCommand.inf create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/Am= dAutoToolApp.inf create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHo= okLibAmdFchUart/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/CpuRegister= s.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/AmdPspMboxL= ibV2.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/BaseFabricT= opologyLib.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchBaseLib.= h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/FchEspiCmdL= ib.h create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/GnbPcieConf= igLib.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/NbioCommonL= ibDxe.h create mode 100755 Platform/AMD/AgesaModulePkg/Include/Library/NbioHandleL= ib.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/PcieConfigL= ib.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLi= b.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPci= eServicesProtocol.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/AmdOemOobP= prProtocol.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricNuma= Services2.h create mode 100644 Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopo= logyServices2.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/PlatformPspRomArm= orWhitelistLib.h create mode 100644 Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdCxlServicesPr= otocol.h create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPciResourcesP= rotocol.h create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/AmdPspFtpmProtoc= ol.h create mode 100644 Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceMa= nagerServicesProtocol.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/AmdCpmTableProt= ocol/AmdCpmTableProtocol.h create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/Amd= PspMboxLibV2.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/A= mdPspRomArmorLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNu= ll/AmdPspRomArmorLibNull.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3= .c create mode 100644 Platform/AMD/AgesaModulePkg/Library/ApcbLibV3Pei/ApcbLi= bV3Pei.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyR= sLib/BaseFabricTopologyRsLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/Base= TscTimerLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeT= scTimerLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/PeiT= scTimerLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscT= imerLibShare.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridge= Lib/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/FchStall= Lib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemL= ib/FchBaseResetSystemLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEs= piCmdLib.c create mode 100755 Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioH= andleLib.c create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieC= onfigLib.c create mode 100755 Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieI= nputParserLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Library/SmnAccessLib/SmnAcc= essLib.c create mode 100644 Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeL= ibFunctions.c create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Dxe/ApcbV= 3Dxe.c create mode 100644 Platform/AMD/AgesaModulePkg/Psp/ApcbDrv/ApcbV3Pei/ApcbV= 3Pei.c create mode 100644 Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformL= ibNull/OemAgesaCcxPlatformLibNull.c create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPc= iCfg2/PciExpressPciCfg2.c create mode 100644 Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPc= iSegmentInfoLib/PciSegmentInfoLib.c create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNor= LibSmm/AmdPspFlashAccSpiNorLibSmm.c create mode 100644 Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelist= Lib/PspRomArmorWhitelistLib.c create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe= .c create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatf= ormDriver/PspPlatformDriver.c create mode 100644 Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHo= tplugDxe/ServerHotplugDxe.c create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/Am= dAutoDynamicCommand.c create mode 100644 Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/Am= dAutoToolApp.c create mode 100644 Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHo= okLibAmdFchUart/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/Platfor= m/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 Pac= kage DEC +# file. +# This file provides the minimum AMD SoC/Mircoporcessor definitions for bu= ilding +# AMD edk2 modules. +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaCommonPkg + PACKAGE_GUID =3D 6CBE6566-0D3F-4E35-8358-9602354E9F09 + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + +[Guids] + gEfiAmdAgesaModulePkgTokenSpaceGuid =3D {0x7788adf0, 0x9788, 0x4a3f= , {0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd}} + gAgesaConfigDbPointerVariableGuid =3D {0x21229d24, 0xc71d, 0x4bc0= , {0xb6, 0x3e, 0x67, 0x2f, 0x6d, 0xbf, 0x5f, 0xf7}} + gAmdMemoryInfoHobGuid =3D {0x1bce3d14, 0xa5fe, 0x4a0b= , {0x9a, 0x8d, 0x69, 0xca, 0x5d, 0x98, 0x38, 0xd3}} + +[Protocols] + ## Soc Protocols + gAmdSocLogicalIdProtocolGuid =3D {0x72f8e409, 0x0d2a, 0x4b91= , {0x88, 0x6f, 0xba, 0x13, 0x44, 0x9f, 0xd7, 0x78}} + gAmdOemOobPprDxeProtocolGuid =3D {0x78031be3, 0x54a2, 0x4819= , {0xb5, 0xba, 0x32, 0x79, 0x04, 0xf3, 0xa8, 0x41}} + +[PcdsFixedAtBuild] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxSocketSupportedV2|2|UINT= 8|0x00002002 # 2 by default + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDiePerSocketV2|1|UINT8|0= x00002003 # 1 by default + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxChannelPerDieV2|8|UINT8|= 0x00002004 # 8 by default + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemMaxDimmPerChannelV2|2|UINT8= |0x00002005 # 2 by default + +[PcdsDynamic] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdS3LibTableSize|0x4000|UINT64|0= x00027003 + diff --git a/Platform/AMD/AgesaModulePkg/AgesaEdk2Pkg.dec b/Platform/AMD/Ag= esaModulePkg/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. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaEdk2Pkg + PACKAGE_GUID =3D E866104F-D458-41B1-AB26-FA5951618A8C + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include/AmdEdk2 + + diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleCcxPkg.dec b/Platform/A= MD/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 Packag= e 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaCcxPkg + PACKAGE_GUID =3D df325429-029e-40f0-82db-0e69be7f6560 + PACKAGE_VERSION =3D 0.1 + +[PcdsDynamic] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdCcxSingleBitErrLogging|FALSE|B= OOLEAN|0x000CC029 diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleDfPkg.dec b/Platform/AM= D/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 Packag= e DEC +# file. +# This file provides the minimum AMD Data Fabric package definitions for b= uilding AMD +# edk2 modules. +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaDfPkg + PACKAGE_GUID =3D 81e51ee3-c347-4563-92fe-790ba953bf0f + PACKAGE_VERSION =3D 0.1 + +[Guids] + gAmdTotalNumberOfRootBridgesGuid =3D {0xfb5703f5, 0xf8a7, 0xf401= , {0x18, 0xb4, 0x3f, 0x10, 0x8d, 0xeb, 0x26, 0x12}} + gAmdResourceSizeForEachRbGuid =3D {0x542b8f2f, 0xbd52, 0x4233= , {0x8c, 0x3d, 0x66, 0x53, 0x0d, 0xe8, 0xa3, 0x69}} + +[Protocols] + gAmdFabricNumaServices2ProtocolGuid =3D {0xa8ff2e64, 0xf319, 0x4af1= , {0x9e, 0xc8, 0x18, 0x89, 0x89, 0xc3, 0x1e, 0x4a}} + diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleFchPkg.dec b/Platform/A= MD/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 Packag= e DEC +# file. +# This file provides the minimum AMD Fusion Control Hub package definition= s for building AMD +# edk2 modules. +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 1.5 + PACKAGE_NAME =3D AgesaFchPkg + PACKAGE_GUID =3D e47c8ed9-3000-4e6e-b1c6-875b365b3849 + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + +[Guids] + gEfiAmdAgesaModulePkgTokenSpaceGuid =3D { 0x7788adf0, 0x9788, 0x4a3f, { = 0x83, 0xfa, 0xcb, 0x51, 0x2e, 0x7c, 0xf8, 0xdd } } + +[Protocols] + gFchInitDonePolicyProtocolGuid =3D { 0xc63c0c73, 0xf612, 0x4c02, { = 0x84, 0xa3, 0xc6, 0x40, 0xad, 0x0b, 0xa6, 0x22 } } + +[PcdsDynamic] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdLegacyFree|FALSE|BOOLEAN|0x0003F0= 01 + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetEnable|TRUE|BOOLEAN|0x0003F00= 2 + + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdHpetMsiDis|TRUE|BOOLEAN|0x0003F00= 3 + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdResetMode|0x00|UINT8|0x0003F00D + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdNoneSioKbcSupport|FALSE|BOOLEAN|0= x0003F021 + + ### @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|BOOLEA= N|0x0003F309 + + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdXhciUsb20OcPinSelect|0xFFFFFFFFFF= FFFFFF|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|U= INT32|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|0x0003= FF07 + gEfiAmdAgesaModulePkgTokenSpaceGuid.FchRTDeviceEnableMap|0x00000000|UINT= 32|0x0003FF81 diff --git a/Platform/AMD/AgesaModulePkg/AgesaModuleMemPkg.dec b/Platform/A= MD/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 Packa= ge DEC +# file. +# This file provides the minimum AMD Memory package definitions for buildi= ng AMD +# edk2 modules. +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaMemPkg + PACKAGE_GUID =3D 445f7303-3171-428c-ad0b-32df4474a7ad + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include/ + +[PcdsFixedAtBuild] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdAmdMemCfgMaxPostPackageRepairEntr= ies|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 Packa= ge 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaNbioPkg + PACKAGE_GUID =3D 1486f0fe-39ee-4856-a39f-222ff2404f26 + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + +[Protocols] + gAmdNbioPcieServicesProtocolGuid =3D {0x756db75c, 0xbb9d, 0x428= 9, {0x81, 0x3a, 0xdf, 0x21, 0x5, 0xc4, 0xf8, 0xe}} + +[PcdsFixedAtBuild] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIommuMMIOAddressReservedEnable= |FALSE|BOOLEAN|0x00021100 #///< 1: Enable Iommu MMIO reserved from GNB driv= er. 0:Disable + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicMMIOAddressReservedEnabl= e|FALSE|BOOLEAN|0x00021101 #///< 1: Enable Ioapic MMIO reserved from GNB dr= iver. 0:Disable + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdPreDefineEn|FALSE|BOOL= EAN|0x00021102 #///< TRUE: Enable assign IOAPIC ID at PEI phase + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgIoApicIdBase|0xF1|UINT8|0x0002= 1103 #///< Base NBIO IOAPIC ID. ID assigned start from= this value + +[PcdsDynamic] + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgGnbIoapicId|0|UINT8|0x0004101D + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdCfgFchIoapicId|0|UINT8|0x0004101E + gEfiAmdAgesaModulePkgTokenSpaceGuid.PcdSmuFeatureControlDefinesExt|0x0|U= INT32|0x00041200 diff --git a/Platform/AMD/AgesaModulePkg/AgesaModulePspPkg.dec b/Platform/A= MD/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 Packa= ge DEC +# file. +# This file provides the minimum AMD Platform Security Processor package d= efinitions +# for building AMD edk2 modules. +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaPspPkg + PACKAGE_GUID =3D 5c48f900-a98c-431f-8be5-19c09c65bb05 + PACKAGE_VERSION =3D 0.1 + +[Guids] + gApSyncFlagNvVariableGuid =3D { 0xad3f6761, 0xf0a3, 0x46c8, { 0xa4, 0xcb,= 0x19, 0xb7, 0x0f, 0xfd, 0xb3, 0x05 } } + gAmdPspApobHobGuid =3D { 0x30b174f3, 0x7712, 0x4cca, { 0xbd, 0x13,= 0xd0, 0xb8, 0xa8, 0x80, 0x19, 0x97 } } + +[Protocols] + gPspFlashAccSmmCommReadyProtocolGuid =3D { 0x9f373486, 0xda76, 0x4c9f, { = 0x81, 0x55, 0x6c, 0xcd, 0xdb, 0x0b, 0x0b, 0x04 } } + gAmdPspFtpmProtocolGuid =3D { 0xac234e04, 0xb036, 0x476c, { = 0x91, 0x66, 0xbe, 0x47, 0x52, 0xa0, 0x95, 0x09 } } + +[Ppis] + gAmdPspFtpmPpiGuid =3D { 0x91774185, 0xf72d, 0x467e, { = 0x93, 0x39, 0xe0, 0x08, 0xdb, 0xae, 0x0e, 0x14 } } + gAmdPspFtpmFactoryResetPpiGuid =3D { 0x9c98130a, 0x8921, 0x45eb, { = 0x86, 0xf3, 0x16, 0x04, 0x35, 0xc7, 0xc6, 0x40 } } diff --git a/Platform/AMD/AgesaPkg/AgesaPkg.dec b/Platform/AMD/AgesaPkg/Age= saPkg.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D AgesaPkg + PACKAGE_GUID =3D DABFEFC6-5A79-444b-862A-1F6FE9F561FE + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + +[Guids] + gEfiAmdAgesaPkgTokenSpaceGuid =3D { 0xd4d8435f, 0xfffb, 0x4acb, { 0xa0, = 0x4d, 0xff, 0x0f, 0xad, 0x67, 0x7f, 0xe9 } } + +[Protocols] + gAmdNbioCxlServicesProtocolGuid =3D {0x125CCFCE, 0x34AF, 0x422C, = {0xB3, 0xB3, 0x71, 0x23, 0xA3, 0x1E, 0xC8, 0x61}} + gAmdPciResourceProtocolGuid =3D {0x663d4897, 0xed94, 0x4f0f, = {0x86, 0x64, 0xfe, 0xdc, 0x70, 0x30, 0x7f, 0x19}} + gAmdCapsuleSmmHookProtocolGuid =3D {0x4fc43bbe, 0x1433, 0x4951, = {0xac, 0x2d, 0x0d, 0x01, 0xfe, 0xc0, 0x0e, 0xb1}} + gAmdFspSetupTableInitDoneGuid =3D {0xef5394c6, 0x566d, 0x440f, = {0x9d, 0x05, 0xc0, 0xa3, 0x2c, 0xb9, 0x33, 0x58}} + +[Ppis] + gAmdMemoryInfoHobPpiGuid =3D {0xba16e587, 0x1d66, 0x41b7, = {0x9b, 0x52, 0xca, 0x4f, 0x2c, 0xad, 0x0d, 0xc8}} + gCapsuleUpdateDetectedPpiGuid =3D {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|BOOL= EAN|0x00020006 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashNvStorageBlockSize |0x1000|UI= NT32|0x00020007 + + ### @brief assign non volatile storage base address + ### @details This assigns the base address to map to flash deivce. + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress|0xFF000000|UI= NT32|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 P= M1 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 P= M 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 C= PU 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 G= PE0 register block as defined by ACPI spec. + ### @brief Permitted Choices: (Type: Value)(Default: 0x0420) + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgAcpiGpe0BlkAddr|0x420|UINT16|0= x0002F008 + + ### @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 restor= e 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 si= gnal the FCH driver that the platform driver has + ### completed its restore function. This allows the FCH driver to perfor= m some final FCH settings. + ### @brief Permitted Choices: (Type: Value)(Default: 0xD4) + gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemAfterPciRestoreSwSmi|0xD4|UINT8|0= x0002F011 + + ### @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|0x0002= F012 + + ### @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|0x000= 2F013 + + ### @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|0x0002F= 014 + + ### @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 a= lso be blocked. + ### @brief Permitted Choices: (Type: Value)(Default: 0xAB) + gEfiAmdAgesaPkgTokenSpaceGuid.PcdFchOemSpiLockSwSmi|0xAB|UINT8|0x0002F01= 5 +#-------------------------------------------------------------------------= --- +#- 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 p= hysical 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|0x000= CC103 +#-------------------------------------------------------------------------= --- +#- CCX Fixed PCDs +#- +### Set Doxy_path: "PCD-CCX-MTRR.h" +#-------------------------------------------------------------------------= --- + + + ### @brief The base address of temporary page table for accessing PCIE M= MIO 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 defi= ned 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. Th= e string must conform to the ACPI rules for the OEM ID field. + ### @brief Permitted Choices: (Type: Value)(Default: "AMD") + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiTableHeaderOemId|"AMD"|VOID*|0x0= 00AC004 + +#-------------------------------------------------------------------------= --- +#- 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 f= or the processor socket. This should match the + ### silkscreen label on the motherboard. + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown") + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket0|"Unkn= own"|VOID*|0x00001001 + + ### @brief When creating the SMBios table entry, use this as the value f= or 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 f= or 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 f= or the 'Part Number' field for each processor. + ### @brief Permitted Choices: (Type: Value)(Default: "Unknown") + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosPartNumberSocket0|"Unknown"|VO= ID*|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 moth= erboard. + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosSocketDesignationSocket1|"Unkn= own"|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"|VO= ID*|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|0x0= 00CC002 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdt|TRUE|BOOLEAN|0x000CC00B + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdApicMode|0xFF|UINT8|0x000CC01D + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCpuWdtEn|TRUE|BOOLEAN|0x000CC200 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerInSb|FA= LSE|BOOLEAN|0x000CC50B + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdAcpiCpuSsdtProcessorContainerName|"P= LTF"|VOID*|0x000CC50C + + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCcxCfgPFEHEnable|FALSE|BOOLEAN|0x000= CC601 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdSmbiosT4CpuMaxSpeed|0|UINT16|0x000CC= 900 +#-------------------------------------------------------------------------= --- +#- 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 allocatio= ns. No MMIO space will be used above this limit. Some devices have limits o= n the address space they + ### are able to access. For example a device with a 40-bit address limit= ation can not use MMIO space above 1TeraByte (1T). By setting this PCD to 0= x10000000000 (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|UINT6= 4|0x00DF0000 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchCfgSmiCmdPortAddr|0xB0|UINT16|0x0= 003FFC0 + + ### I2C-0 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c0SdaHold|0x00000035|UINT32|0x0= 00FC000 + ### I2C-1 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c1SdaHold|0x00000035|UINT32|0x0= 00FC001 + ### I2C-2 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c2SdaHold|0x00000035|UINT32|0x0= 00FC002 + ### I2C-3 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c3SdaHold|0x00000035|UINT32|0x0= 00FC003 + ### I2C-4 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c4SdaHold|0x00000035|UINT32|0x0= 00FC004 + ### I2C-5 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdFchI2c5SdaHold|0x00000035|UINT32|0x0= 00FC005 + ### @} 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 ra= nges that are to be used by the UART ports in the processor. Permitted Choi= ces: (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|0x000F= C024 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataEnable|TRUE|BOOLEAN|0x000FC030 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdSataStaggeredSpinup|FALSE|BOOLEAN|0x000= FC039 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdNvdimmEnable|FALSE|BOOLEAN|0x000A6024 + +#-------------------------------------------------------------------------= --- +#- NBIO Dynamic PCDs +### Set Doxy_path: "PCD-NBIO-BMC.h" +#-------------------------------------------------------------------------= --- + + gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkTraining|FALSE|BOOLEAN|0x00= 04F004 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdEarlyBmcLinkSocket|0xFF|UINT8|0x0004F00= 5 + 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|0x= 00|UINT32|0x0004F0A0 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdTelemetry_VddcrSocfull_Scale_Current|0x= 00|UINT32|0x0004F0A2 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityLo|0x4|UINT32|0x000= 4F210 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdEgressPoisonSeverityHi|0x30011|UINT32|0= x0004F211 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlProtocolErrorReporting|0|UINT8|0x= 0004F362 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdCxlComponentErrorReporting|0|UINT8|0= x0004F363 + +#-------------------------------------------------------------------------= --- +#- PSP Dynamic PCDs +### Set Doxy_path: "PCD-PSP.h" +#-------------------------------------------------------------------------= --- + ### PSP PCDs DYNAMIC + + ### @brief This feature selects the APCB recovery support on x86 side. I= f or when an instance of a writable APCB is determined to be invalid, the P= SP driver will + ### attempt a 'recovery' by copying the recovery instance of the APCB (d= efault 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 recover= y mode, in which + ### ABL consumes the recovery instances of APCB. Otherwise it boots in n= ormal/non-recovery mode. + ### @brief Permitted Choices: (Type: Boolean)(Default: TRUE) + ### @brief This feature is affected by the platform CMOS power design. P= lease 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 th= e additional reset + ### is avoided at the potential risk of the writeable APCB instance bein= g left corrupted forever. + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspApcbRecoveryEnable|TRUE|BOOLEAN|0= x95940008 + + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspAntiRollbackLateSplFuse|FALSE|BOO= LEAN|0x95940018 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemPostPackageRepair|TRUE|BOOLEAN|0x= 00030004 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemBootTimePostPackageRepair|TRUE|BO= OLEAN|0x00030005 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdMemRuntimePostPackageRepair|FALSE|BO= OLEAN|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|0x= 00020004 + ### @brief Specify the filter for IdsDebugPrint + ### @details When the filter values are matched, the AmdIdsDebugPrint ca= n start to print debug message. + ### Refer Library/IdsLib.h for details, and the Master token is PcdAmdId= sDebugPrintEnable. + ### @li 0x100401008A30042C: (GNB_TRACE | PCIE_MISC | NB_MISC | GFX_MISC = | CPU_TRACE | MEM_FLOW | MEM_STATUS | MEM_PMU | FCH_TRACE | MAIN_FLOW| TES= T_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|0x100401030A3004= 08|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 (R= x/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 c= able 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 cabl= e is connected. CTS is set if it is ok to transmit data. + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPortDetectCableCo= nnection|FALSE|BOOLEAN|0x0002000A + + ### @brief Selection of UART and UART Legacy IO Serial port for AGESA de= bug 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 s= pace 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: 0x= 2E8, + ### UART0: 0xFEDC9000, UART1: 0xFEDCA000, UART2: 0xFEDCE000, UART3: 0xFE= DCF000, UART4: 0xFEDD1000. + ### @li If it's IO port: it must < 0x10000 + ### @li If it's Memory: it must >=3D 0x10000 + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintSerialPort|0x3F8|UINT64= |0x0002000B + + ### @brief Debug Print Emulation Auto Detect + ### @details Auto detect emulation platform to instead of PcdAmdIdsDebug= PrintRedirectIOEnable and + ### PcdAmdIdsDebugPrintSerialPortEnable. + ### @li TRUE: Enable + ### @li FALSE: Disable + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdIdsDebugPrintEmulationAutoDetect|FAL= SE|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|0x95940= 054 + + + + ### @brief System TPM config Value + ### @details System TPM config Value, SBIOS needs to set the value in PE= I phase. + ### @li 0x0: dTPM + ### @li 0x1: PSP fTPM + ### @li 0x2: HSP fTPM + ### @li 0xFF: no TPM + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAmdPspSystemTpmConfig|0xFF|UINT8|0x9594= 0024 + + ### @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|0x9594002= 5 + ### @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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEC_SPECIFICATION =3D 0x00010005 + PACKAGE_NAME =3D CpmPkg + PACKAGE_GUID =3D ABE128BA-1061-4A53-A1B8-D07329AA7A67 + PACKAGE_VERSION =3D 0.1 + +[Includes] + Include + Library + +[Guids] + gAmdCpmPkgTokenSpaceGuid =3D {0x916e0ddd, 0x2bd2, 0x4704, {0x93, = 0xb9, 0x59, 0x4b, 0x01, 0xa5, 0xfa, 0x9f}} + gShellActHiiGuid =3D {0x340EBE97, 0x3C1C, 0x4272, {0x9C, = 0xCE, 0xC1, 0xFF, 0x86, 0x6F, 0x73, 0x3C}} + gAmdPbsSystemConfigurationGuid =3D {0xa339d746, 0xf678, 0x49b3, {0x9f, = 0xc7, 0x54, 0xce, 0x0f, 0x9d, 0xf2, 0x26}} + +[Protocols] + gAmdCpmTableProtocolGuid =3D { 0x3724cf01, 0x00c2, = 0x9762, {0x11, 0xb3, 0x0e, 0xa8, 0xaa, 0x89, 0x72, 0x00 }} + gAmdCpmAllPciIoProtocolsInstalledProtocolGuid =3D { 0x676D7012, 0x139B, = 0x485A, {0x96, 0xF1, 0x98, 0x6F, 0xC4, 0x8A, 0x86, 0x4B }} + +[Ppis] + gAmdCpmTablePpiGuid =3D { 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/Pla= tform/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 mo= dules +# into build process. +# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +# +# 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/Plat= form/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 reserve= d.
+# +# 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/AmdPspRom= ArmorLibNull.inf + ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf + +[LibraryClasses.Common.DXE_SMM_DRIVER] + AmdPspRomArmorLib|AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRom= ArmorLibNull.inf + ApcbLibV3|AgesaModulePkg/Library/ApcbLibV3/ApcbLibV3.inf + +[LibraryClasses] + # + # Agesa specific common libraries + # + + ## PSP Libs + AmdPspMboxLibV2|AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.i= nf + + ## DF Lib + BaseFabricTopologyLib|AgesaModulePkg/Library/BaseFabricTopologyRsLib/Bas= eFabricTopologyRsLib.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.i= nc.dsc new file mode 100644 index 0000000000..1f1e04c414 --- /dev/null +++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.inc.ds= c @@ -0,0 +1,8 @@ +## @file +# +# Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd= CpmGenoaQuartzPkg.inc.dsc b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Proc= essor/Genoa/AmdCpmGenoaQuartzPkg.inc.dsc new file mode 100644 index 0000000000..2916fecb26 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGeno= aQuartzPkg.inc.dsc @@ -0,0 +1,11 @@ +## @file +# +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + DEFINE AGESA_PKG_PATH =3D AgesaModulePkg + DEFINE AGESA_PKG_DEC =3D 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 reserve= d.
+# +# 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 reserve= d.
+# +# 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/CbsInstanceNu= ll.dxe.inc.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 reserve= d.
+# +# 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/CbsInstanceNu= ll.pei.inc.fdf new file mode 100644 index 0000000000..4766ad0447 --- /dev/null +++ b/Platform/AMD/AmdCbsPkg/Library/CbsInstanceNull/CbsInstanceNull.pei.in= c.fdf @@ -0,0 +1,7 @@ +## @file +# +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsSton= es.dxe.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/Cbs= Stones.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + diff --git a/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/CbsSton= es.pei.inc.fdf b/Platform/AMD/AmdCbsPkg/Library/Family/0x19/RS/External/Cbs= Stones.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd= CpmGenoaQuartzPkg.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/AmdCpmGeno= aQuartzPkg.dxe.inc.fdf @@ -0,0 +1,7 @@ +## @file +# +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd= CpmGenoaQuartzPkg.fdf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processo= r/Genoa/AmdCpmGenoaQuartzPkg.fdf new file mode 100644 index 0000000000..b790e4ead5 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/AmdCpmGeno= aQuartzPkg.fdf @@ -0,0 +1,10 @@ +## @file +# +# Platform Package Flash Description File +# +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Processor/Genoa/Amd= CpmGenoaQuartzPkg.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/AmdCpmGeno= aQuartzPkg.pei.inc.fdf @@ -0,0 +1,7 @@ +## @file +# +# Copyright (C) 2015-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdCalloutLib/AmdCalloutLi= b.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D AmdCalloutLib + FILE_GUID =3D A8FEA621-B381-4c06-9E9D-0897EF78BD78 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/AmdPspMboxL= ibV2.inf new file mode 100644 index 0000000000..1594a99265 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspMboxLibV2/AmdPspMboxLibV2.i= nf @@ -0,0 +1,30 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdPspMboxLibV2 + FILE_GUID =3D B9E57A31-CAB0-4CEE-9D50-9D43E2EEAA44 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/AmdPs= pRomArmorLib.inf new file mode 100644 index 0000000000..c685a26604 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorL= ib.inf @@ -0,0 +1,27 @@ +## @file +# +# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdPspRomArmorLib + FILE_GUID =3D 55871F80-4658-6EF3-A8AC-15B34FF8C2CE + MODULE_TYPE =3D DXE_SMM_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/AmdP= spRomArmorLibNull.inf b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorL= ibNull/AmdPspRomArmorLibNull.inf new file mode 100644 index 0000000000..a3906dc13e --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomAr= morLibNull.inf @@ -0,0 +1,26 @@ +## @file +# +# Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdPspRomArmorLibNull + FILE_GUID =3D 7351EAC0-4587-FED8-2788-BF9DA2ADCA6E + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D ApcbLibV3 + FILE_GUID =3D C7932467-DF16-4C7A-A32A-3E6F50213E68 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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.PcdAmdMemCfgMaxPostPackageRepairEntr= ies + + + + 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. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D ApcbLibV3Pei + FILE_GUID =3D EEA4E007-E408-4daa-82BD-4C52E7058753 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/Ba= seFabricTopologyRsLib.inf b/Platform/AMD/AgesaModulePkg/Library/BaseFabricT= opologyRsLib/BaseFabricTopologyRsLib.inf new file mode 100644 index 0000000000..38a72e26b7 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabri= cTopologyRsLib.inf @@ -0,0 +1,28 @@ +## @file +# +# For EDKII use Only +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseFabricTopologyRsLib + FILE_GUID =3D D0A070DD-630A-43F8-9D76-EAAABDDE5FB9 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D BaseFabricTopologyLib + CONSTRUCTOR =3D BaseFabricTopologyLibConstructor + +[Sources] + BaseFabricTopologyRsLib.c + +[Packages] + MdePkg/MdePkg.dec + AgesaModulePkg/AgesaCommonModulePkg.dec + AgesaModulePkg/AgesaModuleDfPkg.dec + +[LibraryClasses] + BaseLib diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTime= rLib.inf b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerL= ib.inf new file mode 100644 index 0000000000..d15d8169fe --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTimerLib.in= f @@ -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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BaseTscTimerLib + FILE_GUID =3D D29338B9-50FE-4e4f-B7D4-A150A2C1F4FB + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TimerLib + +# +# VALID_ARCHITECTURES =3D 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/DxeTscTimer= Lib.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeTscTimerLib + FILE_GUID =3D 95ab030f-b4fd-4ee4-92a5-9e04e87634d9 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TimerLib|DXE_CORE DXE_DRIVER DXE_RUNT= IME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE + + CONSTRUCTOR =3D DxeTscTimerLibConstructor + +# +# VALID_ARCHITECTURES =3D 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/PeiTscTimer= Lib.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiTscTimerLib + FILE_GUID =3D 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TimerLib|PEIM PEI_CORE + +# +# VALID_ARCHITECTURES =3D 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/Pci= HostBridgeLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridge= Lib/PciHostBridgeLib.inf new file mode 100644 index 0000000000..f60f97905a --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBri= dgeLib.inf @@ -0,0 +1,42 @@ +## @file +# Library instance of PciHostBridgeLib library class for coreboot. +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PciHostBridgeLib + FILE_GUID =3D 74967FD7-A9A4-4B16-8B41-B26BC3230D0A + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PciHostBridgeLib + +# +# The following information is for reference only and not required by the = build +# tools. +# +# VALID_ARCHITECTURES =3D 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/AmlGen= erationLib.inf b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/Am= lGenerationLib.inf new file mode 100644 index 0000000000..2a72fa8117 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlGeneration= Lib.inf @@ -0,0 +1,47 @@ +## @file +# +# Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D AmlGenerationLib + FILE_GUID =3D 8F62C8D1-B67F-4AFB-9179-54384F1A6163 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D AmlGenerationLib | DXE_DRIVER UEFI_DRI= VER 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D FchBaseLib + FILE_GUID =3D 4108287a-c864-4427-b2c3-bd0e91a83abd + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FchBaseLib + +[Sources.common] + FchStallLib.c + +[Packages] + AgesaModulePkg/AgesaModuleFchPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + PciSegmentLib + diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchB= aseResetSystemLib.inf b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSys= temLib/FchBaseResetSystemLib.inf new file mode 100644 index 0000000000..e422cb69a4 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseRese= tSystemLib.inf @@ -0,0 +1,35 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D BaseResetSystemLib + FILE_GUID =3D e669c365-2df2-4540-a343-afec4e85b198 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D BaseResetSystemLib + +# +# VALID_ARCHITECTURES =3D 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/FchEspiCmdLi= b.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D FchEspiCmdLib + FILE_GUID =3D 89671327-a620-43e9-93b1-d1da79a50392 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FchEspiCmdLib + +[Sources.common] + FchEspiCmdLib.c + +[Packages] + AgesaModulePkg/AgesaModuleFchPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + IoLib + FchBaseLib + + + + + + + diff --git a/Platform/AMD/AgesaModulePkg/Library/NbioHandleLib/NbioHandleLi= b.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D NbioHandleLib + FILE_GUID =3D DC4639D3-DB75-486B-AC38-C84AA49601E3 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/PcieConfigLi= b.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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PcieConfigLib + FILE_GUID =3D C1205AD2-FE67-4502-A0A7-FB1704A3F9AE + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D SmnAccessLib + FILE_GUID =3D 9B7FF4FA-9DB5-4fec-BF71-B13D8A14A51E + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/NbioCommonDx= eLib.inf new file mode 100644 index 0000000000..da7f5c185d --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/NbioCommonDxeLib.i= nf @@ -0,0 +1,29 @@ +## @file +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D NbioCommonDxeLib + FILE_GUID =3D 1BF93335-5D55-46D9-99D9-5D962F039829 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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.in= f 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 reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D AmdApcbDxeV3 + FILE_GUID =3D 4D3708A0-6D9B-47D3-AD87-E80C781BC0A7 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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.in= f 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. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D AmdApcbPeiV3 + FILE_GUID =3D E1B8CF4A-FE7B-4676-B4F7-50C7228282A4 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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/OemAges= aCcxPlatformLibNull/OemAgesaCcxPlatformLibNull.inf new file mode 100755 index 0000000000..0f115c362e --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAges= aCcxPlatformLibNull.inf @@ -0,0 +1,27 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D OemAgesaCcxPlatformLibNull + FILE_GUID =3D B1F58B07-0146-4804-B701-A56CB5716529 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D OemAgesaCcxPlatformLib + +[Sources.common] + OemAgesaCcxPlatformLibNull.c + +[Packages] + MdePkg/MdePkg.dec + +[Depex] + TRUE + + + diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/P= ciExpressPciCfg2.inf b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpres= sPciCfg2/PciExpressPciCfg2.inf new file mode 100644 index 0000000000..ba551e5c14 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpre= ssPciCfg2.inf @@ -0,0 +1,61 @@ +## @file +# +# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PciExpressPciCfg2 + FILE_GUID =3D 7A6DF3DB-1C0A-45C2-8251-AFE794D7D6B3 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PeimInitializePciCfg + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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 ## SOMETIM= ES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy ## SOMETIM= ES_CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy ## SOMETIM= ES_CONSUMES + +[Depex] + TRUE diff --git a/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmen= tInfoLib/PciExpressPciSegmentInfoLib.inf b/Platform/AMD/AgesaPkg/Addendum/P= ciSegments/PciExpressPciSegmentInfoLib/PciExpressPciSegmentInfoLib.inf new file mode 100644 index 0000000000..e712a80886 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLi= b/PciExpressPciSegmentInfoLib.inf @@ -0,0 +1,32 @@ +## @file +# +# Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PciExpressPciSegmentInfoLib + FILE_GUID =3D FA8B1082-88DF-4744-85A3-7F87A9EBF8DC + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PciSegmentInfoLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D 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/AmdPspF= lashAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.inf new file mode 100644 index 0000000000..f4b9d0d789 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspF= lashAccSpiNorLibSmm.inf @@ -0,0 +1,45 @@ +## @file +# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdPspFlashAccLibSmm + FILE_GUID =3D 3BBDC3A5-A0E2-4E8A-8240-9E594920F040 + MODULE_TYPE =3D DXE_SMM_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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 ## CONSUM= ES + gEfiAmdAgesaPkgTokenSpaceGuid.PcdAgesaFlashAreaBaseAddress ## CONSUM= ES + +[Depex] + gEfiSmmBase2ProtocolGuid AND + gEfiSpiSmmNorFlashProtocolGuid + diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/Psp= RomArmorWhitelistLib.inf b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWh= itelistLib/PspRomArmorWhitelistLib.inf new file mode 100644 index 0000000000..57bb0d9e25 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmo= rWhitelistLib.inf @@ -0,0 +1,32 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D PspRomArmorWhitelistLib + FILE_GUID =3D B6F8507A-C96B-4036-A8C0-26BAD6AC5F34 + MODULE_TYPE =3D DXE_SMM_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D OobPprDxe + FILE_GUID =3D F91DCAB4-3639-11EE-BE56-0242AC120002 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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/PspPlat= formDriver/PspPlatform.inf new file mode 100644 index 0000000000..f4d7638c1a --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspP= latform.inf @@ -0,0 +1,32 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PspPlatform + FILE_GUID =3D 28374747-76FF-41B3-9740-381EFAEF13BC + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D 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/ServerHotplugDx= e/ServerHotplugDxe.inf b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/Ser= verHotplugDxe/ServerHotplugDxe.inf new file mode 100644 index 0000000000..973ace8632 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/Serve= rHotplugDxe.inf @@ -0,0 +1,29 @@ +## @file +# +# Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D ServerHotplugDxe + FILE_GUID =3D FAFF8CA9-E515-44ed-B5F9-E2F6E5D902E3 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + + ENTRY_POINT =3D 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/AmdAutoDy= namicCommand.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/Amd= AutoDynamicCommand.inf new file mode 100644 index 0000000000..2d9dbeb715 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCo= mmand.inf @@ -0,0 +1,53 @@ +## @file +# +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdAutoDynamicCommand + FILE_GUID =3D CCD8FEC8-1E30-45BD-8632-DB83A255FAC3 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.1 + ENTRY_POINT =3D ActCommandInitialize + UNLOAD_IMAGE =3D ActLibraryUnregisterActCommand + UEFI_HII_RESOURCE_SECTION =3D 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/AmdAutoTo= olApp.inf b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToo= lApp.inf new file mode 100644 index 0000000000..98c8755ab8 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolApp.i= nf @@ -0,0 +1,50 @@ +## @file +# +# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010006 + BASE_NAME =3D AmdAutoToolApp + FILE_GUID =3D 470E1741-2DFE-43EF-861E-505CB3226DC0 + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D ActCommandInitialize +# +# This flag specifies whether HII resource section is generated into PE i= mage. +# + UEFI_HII_RESOURCE_SECTION =3D 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/BasePlatformHookLibAm= dFchUart/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/BasePlatformHookLibAmdFchUar= t/BasePlatformHookLibAmdFchUart.inf @@ -0,0 +1,33 @@ +## @file +# +# Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserve= d.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D BasePlatformHookLibAmdFchUart + FILE_GUID =3D BF2F3F3F-4BE6-4B97-850D-D5D4941D391C + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D 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/Age= saModulePkg/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= .
+ + 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 =3D 0, ///< Detect en= dpoint presence + EndpointNotPresent ///< Endpoint no= t present (or connected). Used in case there is alternative way to determin= e + ///< if device p= resent on board or in slot. For example GPIO can be used to determine devic= e presence. +} PCIE_ENDPOINT_STATUS; + +/// PCIe port misc extended controls +typedef struct { + IN UINT8 LinkComplianceMode : 1; ///< Force por= t 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_PO= RT_DATA::LinkSpeedCapability) + ///< 0 - por= t can advertise maximum supported capability + ///< 1 - por= t limit advertized capability and speed to PCIe Gen1 + IN UINT8 SbLink : 1; ///< PCIe link= type + ///< 0 - Gene= ral purpose port + ///< 1 - Port= connected to SB + IN UINT8 ClkPmSupport : 1; ///< Clock Pow= er Management Support + ///< 0 - Clo= ck Power Management not configured + ///< 1 - Clo= ck Power Management configured according to PCIe device capability + IN UINT8 CsLink : 1; ///< PCIe link= type + ///< 0 - Gen= eral purpose port + ///< 1 - Por= t connected to chipset + IN UINT8 Reserved0 : 2; ///< Unused sp= ace +} PCIE_PORT_MISC_CONTROL; + +/// The IO APIC Interrupt Mapping Info +typedef struct { + IN UINT8 GroupMap; ///< Group mappi= ng 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 int= errupt in the Group. + ///< - ABCD + ///< - BCDA + ///< - CDAB + ///< - DABC + IN UINT8 BridgeInt; ///< IOAPIC redi= rection table entry for PCIE bridge interrupt + ///< - Entry 0= of IO APIC redirection table + ///< - Entry 1= of IO APIC redirection table + ///< - Entry 3= 1 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 Cont= rol + IN UINT8 LEQControl; ///< LEQ Cont= rol + IN BOOLEAN DynamicOffsetCalibration; ///< Dynamic = Offset Calibration Enable + IN BOOLEAN FOMCalculation; ///< FOM Calc= ulation Enable + IN BOOLEAN PIOffsetCalibration; ///< PI Offse= t Calibratino Enable +} RX_ADAPT_MODE; + +/// PCIe port configuration data +typedef struct { + IN UINT8 PortPresent; ///< Enable P= CIe port for initialization. + IN UINT8 ChannelType; ///< Channel = type. + ///< 0 - "l= owLoss", + ///< 1 - "h= ighLoss", + ///< 2 - "m= ob0db", + ///< 3 - "m= ob3db", + ///< 4 - "e= xtnd6db" + ///< 5 - "e= xtnd8db" + IN UINT8 DeviceNumber; ///< PCI Devi= ce number for port. + ///< 0 - Na= tive port device number + ///< N - Po= rt device number (See available configurations in BKDG + IN UINT8 FunctionNumber; ///< Reserved= for future use + IN UINT8 LinkSpeedCapability; ///< PCIe lin= k speed/ + ///< 0 - Ma= ximum supported by silicon + ///< 1 - Ge= n1 + ///< 2 - Ge= n2 + ///< 3 - Ge= n3 + IN UINT8 LinkAspm; ///< ASPM con= trol. (see AgesaPcieLinkAspm for additional option to control ASPM) + ///< 0 - Di= sabled + ///< 1 - L0= s only + ///< 2 - L1= only + ///< 3 - L0= s and L1 + IN UINT8 LinkHotplug; ///< Hotplug = control. + ///< 0 - Di= sabled + ///< 1 - Ba= sic + ///< 2 - Se= rver + ///< 3 - En= hanced + IN UINT8 ResetId; ///< Arbitra= ry number greater than 0 assigned by platform firmware for GPIO + ///< identif= ication which control reset for given port. + ///< Each po= rt with unique GPIO should have unique ResetId assigned. + ///< All por= ts use same GPIO to control reset should have same ResetId assigned. + ///< see Age= saPcieSlotResetContol. + IN UINT16 SlotNum; ///< Physical= Slot Number + IN PCIE_PORT_MISC_CONTROL MiscControls; ///< Misc ext= ended controls + IN APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC d= evice programming info + IN PCIE_ENDPOINT_STATUS EndpointStatus; ///< PCIe end= point (device connected to PCIe port) status + IN RX_ADAPT_MODE RxAdaptMode; ///< Gen3 RxA= daptMode configuration +} PCIE_PORT_DATA; + +/// PCIe Complex descriptor +typedef struct { + IN UINT32 Flags; ///< Descriptor = flags + ///< Bit31 - l= ast descriptor in topology + IN UINT32 SocketId; ///< Socket Id + IN VOID *Reserved; ///< Reserved fo= r future use +} PCIE_COMPLEX_DESCRIPTOR; + +/// VBIOS image info +typedef struct { + IN AMD_CONFIG_PARAMS StdHeader; ///< Standard co= nfiguration header + OUT VOID *ImagePtr; ///< Pointer to = VBIOS image + IN PCI_ADDR GfxPciAddress; ///< PCI address= of integrated graphics controller + IN UINT32 Flags; ///< BIT[0] - sp= ecial repost requred +} GFX_VBIOS_IMAGE_INFO; + +// +// CPU MSR Register definitions +// +#define SYS_CFG 0xC0010010ul ///< Refer to AMD64 Architecture Program= ming manual. +#define TOP_MEM 0xC001001Aul ///< Refer to AMD64 Architecture Program= ming manual. +#define HWCR 0xC0010015ul ///< Refer to AMD64 Architecture Program= ming 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 Arch= itecture Programming manual. +#define AMD_AP_MTRR_FIX16k_80000 0x00000258ul ///< Refer to AMD64 Arch= itecture Programming manual. +#define AMD_AP_MTRR_FIX16k_A0000 0x00000259ul ///< Refer to AMD64 Arch= itecture Programming manual. +#define AMD_AP_MTRR_FIX4k_C0000 0x00000268ul ///< Refer to AMD64 Arch= itecture Programming manual. +#define AMD_AP_MTRR_FIX4k_C8000 0x00000269ul ///< Refer to AMD64 Arch= itecture Programming manual. +#define AMD_AP_MTRR_FIX4k_D0000 0x0000026Aul ///< Refer to AMD64 Arch= itecture Programming manual +#define AMD_AP_MTRR_FIX4k_D8000 0x0000026Bul ///< Refer to AMD64 Arch= itecture Programming manual +#define AMD_AP_MTRR_FIX4k_E0000 0x0000026Cul ///< Refer to AMD64 Arch= itecture Programming manual +#define AMD_AP_MTRR_FIX4k_E8000 0x0000026Dul ///< Refer to AMD64 Arch= itecture Programming manual +#define AMD_AP_MTRR_FIX4k_F0000 0x0000026Eul ///< Refer to AMD64 Arch= itecture Programming manual +#define AMD_AP_MTRR_FIX4k_F8000 0x0000026Ful ///< Refer to AMD64 Arch= itecture Programming manual + +#endif // AGESA_H_ diff --git a/Platform/AMD/AgesaModulePkg/Include/AMD.h b/Platform/AMD/Agesa= ModulePkg/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= .
+ + 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 ot= her than SUCCESS, UNSUPPORTED, and BOUNDS_CHK +/// will have log entries with more detail. +/// +typedef enum { + AGESA_SUCCESS =3D 0, ///< 0 - The service completed normally. = Info may be logged. + AGESA_UNSUPPORTED, ///< 1 - The dispatcher or create struct h= ad an unimplemented function requested. + ///< Not logged. + AGESA_BOUNDS_CHK, ///< 2 - A dynamic parameter was out of ra= nge and the service was not provided. + ///< Example, memory address not insta= lled, heap buffer handle not found. + ///< Not Logged. + AGESA_SYNC_MORE_DATA, ///< 3 - More data is available from PSP c= ommunications (used in ABL) + AGESA_SYNC_SLAVE_ASSERT, ///< 4 - Slave is at an ASSERT (used in AB= L) + + // AGESA_STATUS of greater severity (the ones below this line), always h= ave a log entry available. + AGESA_ALERT, ///< 5 - An observed condition, but no los= s of function. See Log. + AGESA_WARNING, ///< 6 - Possible or minor loss of functio= n. See Log. + AGESA_ERROR, ///< 7 - Significant loss of function, boo= t may be possible. See Log. + AGESA_CRITICAL, ///< 8 - Continue boot only to notify user= . See Log. + AGESA_FATAL, ///< 9 - Halt booting. See Log, however F= atal errors pertaining to heap problems + ///< may not be able to reliably produ= ce log events. + AGESA_OC_FATAL, ///< 10 - Halt booting. Critical Memory Ov= erclock 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 determin= ed by the host environment. + + @param[in] Function The specific callout function being invo= ked. + @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 b= ase address. + IN UINT32 Func; ///< The service desir= ed + IN UINT32 AltImageBasePtr; ///< Alternate Image l= ocation + IN CALLOUT_ENTRY CalloutPtr; ///< For Callout from = AGESA + IN UINT8 HeapStatus; ///< For heap status f= rom boot time slide. + IN UINT64 HeapBasePtr; ///< Location of the h= eap + IN OUT UINT8 Reserved[7]; ///< This space is res= erved for future use. +} AMD_CONFIG_PARAMS; + +/// CPUID data received registers format +typedef struct { + OUT UINT32 EAX_Reg; ///< CPUID instruction r= esult in EAX + OUT UINT32 EBX_Reg; ///< CPUID instruction r= esult in EBX + OUT UINT32 ECX_Reg; ///< CPUID instruction r= esult in ECX + OUT UINT32 EDX_Reg; ///< CPUID instruction r= esult in EDX +} CPUID_DATA; +#endif // AMD_H_ diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdEdk2/CpuRegisters.h b/P= latform/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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CPU_REGISTERS_H_ +#define CPU_REGISTERS_H_ + +#include + +#endif diff --git a/Platform/AMD/AgesaModulePkg/Include/AmdPspDirectory.h b/Platfo= rm/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= .
+ + 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 =3D 0x48, ///< PSP entry= points to PSP DIR in Region A + PSP_REGION_B_DIR =3D 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 P= SP 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 directo= ry header + PSP_DIRECTORY_ENTRY PspEntry[1]; ///< Array of PS= P 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/Platfo= rm/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= .
+ + 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/Pla= tform/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= .
+ + 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 Regis= ter 5- RW +#define FCH_LPC_REG74 0x74 // Alternative Wide IO Range Enabl= e- 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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +/* $NoKeywords:$ */ + +/** + * @file + * + * Collectively assign unique filecodes for assert and debug to each sourc= e file. + * + * Publish values for decorated filenames, which can be used for + * ASSERT and debug support using a preprocessor define like: + * @n _#define FILECODE MY_C_FILENAME_FILECODE @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/Agesa= ModulePkg/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= .
+ + 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/A= gesaModulePkg/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef GNBDXIO_H_ +#define GNBDXIO_H_ + +#pragma pack (push, 1) + +#include +#include + +#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_EN= GINES | DESCRIPTOR_SILICON | DESCRIPTOR_PLATFORM) +#define PcieLibGetNextDescriptor(Descriptor) ((Descriptor =3D=3D NULL) ? = NULL : ((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) != =3D 0) ? NULL : (Descriptor + 1)) + +typedef UINT16 PCIE_ENGINE_INIT_STATUS; + +/// +/// Engine Configuration +/// +typedef struct { + IN UINT8 EngineType; ///< Engine type + ///< 0 - Igno= re engine configuration + ///< 1 - PCIe= port + IN UINT16 StartLane; ///< Start Lane = ID (in reversed configuration StartLane > EndLane) + ///< Refer to la= ne descriptions and supported configurations in BKDG + IN UINT16 EndLane; ///< End lane ID= (in reversed configuration StartLane > EndLane) + ///< Refer to la= ne descriptions and supported configurations in BKDG +} PCIE_ENGINE; + +/// +/// PCIe port misc extended controls +/// +typedef struct { + IN UINT8 SbLink : 1; ///< PCIe link= type + ///< 0 - Gen= eral purpose port + ///< 1 - Por= t connected to SB + IN UINT8 ClkPmSupport : 1; ///< Clock Pow= er Management Support + ///< 0 - Clo= ck Power Management not configured + ///< 1 - Clo= ck Power Management configured according to PCIe device capability + IN UINT8 CsLink : 1; ///< PCIe link= type + ///< 0 - Gen= eral purpose port + ///< 1 - Por= t connected to chipset + IN UINT8 Reserved0 : 5; ///< Unused sp= ace +} PORT_MISC_CONTROL; + +/// +/// PCIe port configuration data +/// +typedef struct { + IN UINT8 PortPresent; ///< Enable P= CIe port for initialization. + IN UINT8 FunctionNumber : 3; ///< Reserved= for future use + IN UINT8 DeviceNumber : 5; ///< PCI Devi= ce number for port. + ///< 0 - Na= tive port device number + ///< N - Po= rt device number (See available configurations in BKDG + IN UINT8 LinkSpeedCapability : 4; ///< PCIe lin= k speed/ + ///< 0 - Ma= ximum supported by silicon + ///< 1 - Ge= n1 + ///< 2 - Ge= n2 + ///< 3 - Ge= n3 + IN UINT8 LinkAspm : 4; ///< ASPM con= trol. (see AgesaPcieLinkAspm for additional option to control ASPM) + ///< 0 - Di= sabled + ///< 1 - L0= s only + ///< 2 - L1= only + ///< 3 - L0= s and L1 + IN UINT8 LinkHotplug; ///< Hotplug = control. + ///< 0 - Di= sabled + ///< 1 - Ba= sic + ///< 2 - Se= rver + ///< 3 - En= hanced + IN UINT16 SlotNum; ///< Physical= Slot Number + IN PORT_MISC_CONTROL MiscControls; ///< Misc ext= ended 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 2P5G= T + 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 Downstre= am Tx Preset + UINT32 DsRxPresetHint : 3; ///< Gen3 Downstre= am Rx Preset Hint + UINT32 UsTxPreset : 4; ///< Gen3 Upstream= Tx Preset + UINT32 UsRxPresetHint : 3; ///< Gen3 Upstream= Rx Preset Hint + UINT32 LcPresetMask8Gt : 10; ///< Gen3 Preset M= ask + UINT32 LcFapeEnable8GT : 1; ///< Gen3 FapeEnab= le + UINT32 UNUSED2 : 7; ///< Currently una= ssigned - for alignment +} GEN3_LANE_CNTL; + +typedef struct { + UINT32 DsTxPreset : 4; ///< Gen4 Downstr= eam Tx Preset + UINT32 UsTxPreset : 4; ///< Gen4 Upstrea= m Tx Preset + UINT32 LcPresetMask16Gt : 10; ///< Gen4 Preset = Mask + UINT32 LcFapeEnable16GT : 1; ///< Gen4 FapeEna= ble + UINT32 UNUSED3 : 13; ///< Currently un= assigned - for alignment +} GEN4_LANE_CNTL; + +typedef struct { + UINT32 DsTxPreset : 4; ///< Gen5 Downstre= am Tx Preset + UINT32 UsTxPreset : 4; ///< Gen5 Upstream= Tx Preset + UINT32 LcPresetMask32Gt : 10; ///< Gen5 Preset M= ask + UINT32 LcFapeEnable32GT : 1; ///< Gen5 FapeEnab= le + UINT32 PrecodeRequest : 1; ///< Precoding Req= uest + UINT32 AdvertiseEqToHiRate : 1; ///< Advertise EQ = To High Rate Support + UINT32 UNUSED4 : 11; ///< Currently una= ssigned - 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 una= ssigned - 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 una= ssigned - 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 una= ssigned - 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 una= ssigned - 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 una= ssigned - 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 una= ssigned - 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 una= ssigned - for alignment +} LC_FAPE_GROUP_6; + +/// +/// PCIe port configuration info +/// +typedef struct { + PORT_DATA PortData; ///< Port data + UINT8 StartCoreLane; ///< Start Core La= ne + UINT8 EndCoreLane; ///< End Core lane + UINT8 NativeDevNumber : 5; ///< Native PCI de= vice number of the port + UINT8 NativeFunNumber : 3; ///< Native PCI fu= nction number of the port + UINT8 CoreId : 4; ///< PCIe core ID + UINT8 PortId : 4; ///< Port ID on wr= apper + PCI_ADDR Address; ///< PCI address o= f the port + UINT8 PcieBridgeId : 7; ///< IOC PCIe brid= ge ID + UINT8 IsBmcLocation : 1; ///< Port Location= of BMC + UINT8 LogicalBridgeId; ///< Logical Bridg= e ID + UINT8 SlotPowerLimit; ///< Slot Power Li= mit + UINT8 MaxPayloadSize; ///< Max_Payload_S= ize + + UINT8 TXDeEmphasis : 4; ///< TX De-emphasi= s + UINT8 TXMargin : 3; ///< TX Margin + UINT8 UNUSED1 : 1; ///< Currently una= ssigned - for alignment + + PORT_CAPABILITIES PortCapabilities; ///< Port Capabili= ties CBS + + SPC_MODE SpcMode; + + GEN3_LANE_CNTL LaneEqualizationCntl; + GEN4_LANE_CNTL Gen4LaneEqualizationCntl; + GEN5_LANE_CNTL Gen5LaneEqualizationCntl; + + UINT8 LowerSkpOsGenSup; ///< Controls LOWE= R_SKP_OS_GEN_SUPPORT + UINT8 LowerSkpOsRcvSup; ///< Controls LOWE= R_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 una= ssigned - for alignment + UINT8 SRIS_SRNS : 1; ///< SRIS SRNS + UINT8 SRIS_LowerSKPSupport : 1; ///< SRIS Lower SK= P 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 Li= mit Scale + UINT8 UNUSED5 : 1; ///< Currently una= ssigned - for alignment + + UINT8 RxMarginPersistence : 1; ///< Bit to enable= /disable Rx Margin persistence mode + UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Pr= eset Set + UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Pr= eset Set + UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Pr= eset Set + UINT8 TxVetting : 1; ///< Gen4 Tx Vetti= ng + UINT8 RxVetting : 1; ///< Gen4 Rx Vetti= ng + UINT8 TxVettingGen5 : 1; ///< Gen5 Tx Vetti= ng + UINT8 RxVettingGen5 : 1; ///< Gen5 Rx Vetti= ng + + UINT8 IsMasterPLL : 1; ///< IsMasterPLL + UINT8 TargetLinkSpeed : 3; ///< Target Link S= peed + UINT8 DlfCapDisable : 1; ///< DLF Capabilit= y 1:Disable 0:Enable + UINT8 DlfExchangeDisable : 1; ///< DLF Exchange = 1:Disable 0:Enable + UINT8 InvertPolarity : 1; ///< Invert RX Pol= arity + UINT8 InvertPolarity2 : 1; ///< Invert TX Pol= arity + + UINT8 EqSearchMode : 2; ///< Equalization = Search Mode + UINT8 BypassGen3EQ : 1; ///< BypassGen3EQ + UINT8 DisGen3EQPhase : 1; ///< Disable Gen3 = EQ Phase2/3 + UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Pr= eset value + + UINT8 EqSearchModeGen4 : 2; ///< Equalization = Search Mode for Gen4 + UINT8 BypassGen4EQ : 1; ///< Gen4 Bypass p= hase3 EQ + UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass p= hase2/3 EQ + UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Pr= eset value + UINT8 EqSearchModeGen5 : 2; ///< Equalization = Search Mode for Gen5 + UINT8 BypassGen5EQ : 1; ///< Gen5 Bypass p= hase3 EQ + UINT8 DisGen5EQPhase : 1; ///< Gen5 Bypass p= hase2/3 EQ + UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Pr= eset value + + UINT16 PsppPolicyDC; ///< Pspp Policy D= C + UINT16 PsppPolicyAC; ///< Pspp Policy A= C + UINT8 PsppDeviceType; ///< Pspp Device T= ype + + 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 f= orced + UINT8 EsmUsTxPreset : 4; ///< ESM Upstream = Tx Preset + UINT8 UNUSED13 : 3; ///< Currently una= ssigned - for alignment + + // Used by DXE + PORT_FEATURES PortFeatures; ///< Port Features= CBS + UINT8 EsmSpeedBump; ///< Speed bump fo= r ESM + UINT8 I2CMuxInfo; ///< First I2c Mux= on Bus + UINT8 SrisEnableMode : 4; ///< 0:Disable 1:S= RIS 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 Downstrea= m Tx Preset + UINT8 ClkReqFilterEn : 1; ///< Controls filt= ering of CLKREQb signal in LC in order to avoid false L1 substate entries/e= xits. +} PCIE_PORT_CONFIG; + +/// +/// CXL port configuration info +/// +typedef struct { + PORT_DATA PortData; ///< Port data + UINT8 StartCoreLane; ///< Start Core La= ne + UINT8 EndCoreLane; ///< End Core lane + UINT8 NativeDevNumber : 5; ///< Native PCI de= vice number of the port + UINT8 NativeFunNumber : 3; ///< Native PCI fu= nction number of the port + UINT8 CoreId : 4; ///< PCIe core ID + UINT8 PortId : 4; ///< Port ID on wr= apper + PCI_ADDR Address; ///< PCI address o= f the port + UINT8 PcieBridgeId : 7; ///< IOC PCIe brid= ge ID + UINT8 UNUSED0 : 1; ///< Currently una= ssigned - for alignment + UINT8 LogicalBridgeId; ///< Logical Bridg= e ID + UINT8 SlotPowerLimit; ///< Slot Power Li= mit + UINT8 MaxPayloadSize; ///< Max_Payload_S= ize + + UINT8 CxlIndex; + UINT8 CxlDeviceType : 2; ///< Type of CXL d= evice connected + UINT8 CxlVersion : 2; ///< Version of CX= L device connected (1=3DCXL1.1, 2=3DCXL2.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 una= ssigned - for alignment + + UINT32 UsRcrb; ///< Upstream Port= RCRB address + UINT32 DsRcrb; ///< Downstream Po= rt RCRB address + UINT32 UsMemBar0; ///< Upstream port= MEMBAR0 + UINT32 DsMemBar0; ///< Downstream po= rt MEMBAR0 + UINT32 Mmio32Base; + UINT32 Mmio32Size; + UINT64 Mmio64Base; + UINT64 Mmio64Size; + UINT32 Mmio32Gran; +} PCIE_CXL_CONFIG; + +/// +/// Descriptor header +/// +typedef struct { + UINT32 DescriptorFlags; ///< Descriptor fl= ags + UINT16 Parent; ///< Offset of par= ent 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 he= ader + PCIE_ENGINE EngineData; ///< Engine Data + PCIE_ENGINE_INIT_STATUS InitStatus; ///< Initializatio= n Status + UINT8 Scratch; ///< Scratch pad + union { + PCIE_PORT_CONFIG Port; ///< PCIe port con= figuration data + PCIE_CXL_CONFIG Cxl; ///< CXL Configura= tion data + } Type; +} PCIE_ENGINE_CONFIG; + +/// +/// Wrapper configuration data +/// +typedef struct { + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor He= ader + UINT8 WrapId; ///< Wrapper ID + UINT8 CcixCoreConfig; ///< Ccix CORE Con= figuration + UINT8 StartPhyLane; ///< Start PHY Lan= e + UINT8 EndPhyLane; ///< End PHY Lane + UINT8 StartDxioLane; ///< Start Dxio La= ne (Translated) + UINT8 EndDxioLane; ///< End Dxio Lane= (Translated) + struct { + UINT8 PowerOffUnusedLanes : 1; ///< Power Off unu= sed lanes + UINT8 PowerOffUnusedPlls : 1; ///< Power Off unu= sed Plls + UINT8 ClkGating : 1; ///< TXCLK gating + UINT8 LclkGating : 1; ///< LCLK gating + UINT8 TxclkGatingPllPowerDown : 1; ///< TXCLK clock g= ating PLL power down + UINT8 PllOffInL1 : 1; ///< PLL off in L1 + UINT8 AccessEncoding : 1; ///< Reg access en= coding + UINT8 CoreReversed : 1; ///< Indicates lan= es are reversed in package connection + } Features; + UINT8 MasterPll; ///< Bitmap of mas= ter PLL + UINT32 AcsSupport : 1; ///< Acs Support + UINT32 LtrSupport : 1; ///< LTR Support + UINT32 AriForwarding : 1; ///< ARI Forwardin= g + UINT32 LaneMargining : 1; ///< Lane Marginin= g + UINT32 NativePCIeEnclosureManagement : 1; ///< NPEM + UINT32 DownstreamPortContainment : 1; ///< Downstream po= rt containment + UINT32 AdvancedErrorReporting : 1; ///< Advacned Erro= r Reporting + UINT32 ECRCSupport : 2; ///< ECRC Capabili= ty + UINT32 Reserved : 23; ///< Reserved bits +} PCIE_WRAPPER_CONFIG; + +/// +/// Silicon configuration data +/// +typedef struct { + PCIE_DESCRIPTOR_HEADER Header; ///< Descriptor He= ader + UINT8 SocketId; ///< Socket ID + UINT8 DieNumber; ///< Module ID + UINT8 RBIndex; ///< Physical Root= Bridge + UINT8 InstanceId; ///< Logical Insta= nce Identifier + PCI_ADDR Address; ///< PCI address o= f GNB host bridge + UINT16 StartLane; ///< Start Lane of= this node + UINT16 EndLane; ///< End Lane of t= his node + UINT8 BusNumberLimit; ///< Last Bus Numb= er assigned to this node + UINT8 SbPresent : 1; ///< Set to 1 if F= CH connected to this NBIO + UINT8 SmuPresent : 1; ///< Set to 1 if S= MU 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 He= ader + UINT8 NodeId; ///< Processor Nod= e ID + UINT8 Reserved; ///< For alignment +} PCIE_COMPLEX_CONFIG; + +/// +/// PCIe platform configuration info +/// +typedef struct { + PCIE_DESCRIPTOR_HEADER Header; ///< Des= criptor Header + PVOID Reserved1; ///< Res= erved + UINT32 Reserved2; ///< Res= erved + UINT32 PhyConfigData; ///< Phy= Configuration Data + UINT32 Reserved3; ///< Res= erved + UINT32 Reserved4; ///< Res= erved + UINT32 PsppTuningParams; ///< Tun= ing parameters for PSPP + UINT32 PsppTuningParams2; ///< Tun= ing parameters 2 for PSPP + UINT8 Reserved5; ///< Res= erved + UINT8 PsppPolicy; ///< PSP= P policy + UINT8 Reserved6; ///< Res= erved + UINT8 RootBridgesPerSocket; ///< Num= ber of root bridges per socket + PCIE_COMPLEX_CONFIG ComplexList[MAX_NUMBER_OF_COMPLEXES]; ///< Com= plex +} PCIE_PLATFORM_CONFIG; + +/// +/// PCIe Engine Description +/// +typedef struct { + UINT32 Flags; ///< Descriptor fl= ags + ///< Bit31 - las= t descriptor on wrapper + ///< Bit30 - Des= criptor 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/Platfor= m/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.
+ + 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/Pl= atform/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= .
+ + 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 unti= l 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/Pl= atform/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= .
+ + 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, 0x2= d \ +} +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 s= tructure + 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/Pla= tform/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= .
+ + 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= .
+ + 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 l= og + * + * @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 buffe= r + * + * @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/BaseFabricTopology= Lib.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= .
+ + 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/Pla= tform/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _FCH_BASE_LIB_H_ +#define _FCH_BASE_LIB_H_ + +#include +#include +#include + +#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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _FCH_ESPI_CMD_LIB_H_ +#define _FCH_ESPI_CMD_LIB_H_ + +#include + +#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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef GNBPCIECONFIG_LIB_H_ +#define GNBPCIECONFIG_LIB_H_ + +#include +#include + +#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= .
+ + 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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef NBIOHANDLELIB_LIB_H_ +#define NBIOHANDLELIB_LIB_H_ + +#include + +/** + 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 *) PcieConfigGetNextTopo= logyDescriptor (Descriptor, DESCRIPTOR_TERMINATE_TOPOLOGY) +#define GnbGetSocketId(Handle) (Handle !=3D NULL ? (Handle)->Socket= Id : 0) +#define GnbGetDieNumber(Handle) (Handle !=3D NULL ? (Handle)->DieNum= ber : 0) +#define GnbGetRBIndex(Handle) (Handle !=3D NULL ? (Handle)->RBInde= x : 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= .
+ + 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 t= o 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 t= o 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 informat= ion to callback + @param[in] Pcie Pointer to global PCIe configurati= on +**/ +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 t= o 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 t= o 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 t= o 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 descript= or +**/ +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, &((D= escriptor)->Header))) +#define PcieConfigGetParentSilicon(Descriptor) = ((PCIE_SILICON_CONFIG *) PcieConfigGetParent (DESCRIPTOR_SILICON, &((Descri= ptor)->Header))) +#define PcieConfigGetParentComplex(Descriptor) = ((PCIE_COMPLEX_CONFIG *) PcieConfigGetParent (DESCRIPTOR_COMPLEX, &((Descri= ptor)->Header))) +#define PcieConfigGetPlatform(Descriptor) = ((PCIE_PLATFORM_CONFIG *) PcieConfigGetParent (DESCRIPTOR_PLATFORM, &((Desc= riptor)->Header))) +#define PcieConfigGetChildWrapper(Descriptor) = ((PCIE_WRAPPER_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_WRAPPERS, &((De= scriptor)->Header))) +#define PcieConfigGetChildEngine(Descriptor) = ((PCIE_ENGINE_CONFIG *) PcieConfigGetChild (DESCRIPTOR_ALL_ENGINES, &((Desc= riptor)->Header))) +#define PcieConfigGetChildSilicon(Descriptor) = ((PCIE_SILICON_CONFIG *) PcieConfigGetChild (DESCRIPTOR_SILICON, &((Descrip= tor)->Header))) +#define PcieConfigGetNextDescriptor(Descriptor) = ((((Descriptor->Header.DescriptorFlags & DESCRIPTOR_TERMINATE_LIST) !=3D 0)= ? NULL : ((Descriptor + 1)))) +#define PcieConfigIsPcieEngine(Descriptor) = ((Descriptor !=3D NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR= _PCIE_ENGINE) !=3D 0) : FALSE) +#define PcieConfigIsSbPcieEngine(Engine) = ((Engine !=3D NULL) ? ((BOOLEAN) (Engine->Type.Port.PortData.MiscControls.S= bLink)) : FALSE) +#define PcieConfigIsEngineAllocated(Descriptor) = ((Descriptor !=3D NULL) ? ((Descriptor->Header.DescriptorFlags & DESCRIPTOR= _ALLOCATED) !=3D 0) : FALSE) +#define PcieConfigSetDescriptorFlags(Descriptor, SetDescriptorFlags) = if (Descriptor !=3D NULL) (Descriptor)->Header.DescriptorFlags |=3D SetDesc= riptorFlags +#define PcieConfigResetDescriptorFlags(Descriptor, ResetDescriptorFlags) = if (Descriptor !=3D NULL) ((PCIE_DESCRIPTOR_HEADER *) Descriptor)->Descript= orFlags &=3D (~(ResetDescriptorFlags)) +#define PcieInputParsetGetNextDescriptor(Descriptor) = ((Descriptor =3D=3D NULL) ? NULL : ((Descriptor->Flags & DESCRIPTOR_TERMINA= TE_LIST) !=3D 0) ? NULL : (Descriptor + 1)) +#define PcieConfigGetNextTopologyDescriptor(Descriptor, Termination) = ((Descriptor =3D=3D NULL) ? NULL : ((((PCIE_DESCRIPTOR_HEADER *) Descriptor= )->DescriptorFlags & Termination) !=3D 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) !=3D 0 ? NULL : (Descripto= r + 1)) + +#endif // PCIECONFIGLIB_LIB_H_ diff --git a/Platform/AMD/AgesaModulePkg/Include/Library/SmnAccessLib.h b/P= latform/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= .
+ + 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/AmdNbioPcieServic= esProtocol.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServ= icesProtocol.h new file mode 100644 index 0000000000..0e08e64b24 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Include/Protocol/AmdNbioPcieServicesProto= col.h @@ -0,0 +1,47 @@ +/** @file + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + 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_SERV= ICES_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 struc= ture +**/ +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/AmdOemOobPprProto= col.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.
+ + 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/FabricNumaService= s2.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= .
+ + 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 l= ocation + UINT32 PhysicalDomain; ///< Physical domain number +} DOMAIN_INFO2; + +/// Physical Dram Info +typedef struct { + UINT32 NormalizedCsMap; ///< Bitmap of CSs comprisin= g this physical domain + UINT32 SharingEntityCount; ///< Number of virtual domai= ns sharing this physical domain + UINT32 SharingEntityMap; ///< Bitmap of reported doma= ins that share this physical domain + UINT32 Reserved; ///< Reserved +} PHYS_DOMAIN_INFO; + +/// Proximity Domain Info +typedef struct { + UINTN Count; ///< Entries in Domain arr= ay + 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_PROTO= COL; + +/** + * @brief Get the numa domain information. + * + * @details Get the numa domain information. + * + * @param[in] This A pointer to the FABRIC_NUMA_SE= RVICES2_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 empl= oyed + * @retval EFI_STATUS 0: Success, NonZero: Standard E= FI 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 do= main. + * + * @details Translates a core's physical location to the appropriate NUMA = domain. + * + * @param[in] This A pointer to the FABRIC_NUMA_SERVICES2_P= ROTOCOL instance. + * @param[in] Socket Zero based socket that the core is attac= hed to + * @param[in] Die DF die on socket that the core is attach= ed 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 t= he system + * @param[out] PhysDomainInfo An array with information ab= out 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: Standar= d 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 brid= ge + * + * @details Get the proximity domain information about a PCIe root-port br= idge + * + * @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 retur= ning associated NUMA node(s). + * @retval EFI_STATUS 0: Success, NonZero: Standar= d 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 collect= ion of +/// services that return various information associated with non-uniform m= emory +/// 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/FabricTopologySer= vices2.h b/Platform/AMD/AgesaModulePkg/Include/Protocol/FabricTopologyServi= ces2.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FABRIC_TOPOLOGY_SERVICES2_H_ +#define FABRIC_TOPOLOGY_SERVICES2_H_ + +#include + +#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= .
+ + 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/LocalA= mlLib.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlL= ib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _INTERNAL_AML_LIB_H_ +#define _INTERNAL_AML_LIB_H_ + +#include +#include +#include +#include +#include +#include +#include + +#include "LocalAmlObjects.h" + +// EDK2 open source MdePkg/Include/IndustryStandard/AcpiAml.h does not hav= e +// 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 =3D 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) >=3D AML_NAME_CHAR_A) && ((c) <=3D= AML_NAME_CHAR_Z) ) +#define IS_ASCII_HEX_DIGIT(c) ( (((c) >=3D AML_DIGIT_CHAR_0) && ((c) <= =3D AML_DIGIT_CHAR_9)) ||\ + (((c) >=3D AML_NAME_CHAR_A) && ((c) <=3D= 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 intege= r + @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 encod= ing + @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 :=3D + + 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/LocalA= mlObjects.h b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/Local= AmlObjects.h new file mode 100644 index 0000000000..b19b6fe867 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjec= ts.h @@ -0,0 +1,150 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _INTERNAL_AML_OBJECTS_H_ +#define _INTERNAL_AML_OBJECTS_H_ + +// #include "LocalAmlLib.h" + +/** + Free Object->Data + + Frees Object->Data, Nulls pointer, zeros size and marks + Object->Completed =3D FALSE + + @param [in] Object - Pointer to Object to have Data freed + + @return EFI_SUCCESS - Object Freed + @return - Object free failed +**/ +EFI_STATUS +EFIAPI +InternalFreeAmlObjectData ( + IN AML_OBJECT_INSTANCE *Object + ); + +/** + Free an Object + + Removes Object from it's linked list. + Frees Object->Data + Frees Object + + @param [in] Object - Pointer to Object to be freed + @param [in,out] ListHead - Head of AML Object linked list + + @return EFI_SUCCESS - Object Freed + @return - Object free failed +**/ +EFI_STATUS +EFIAPI +InternalFreeAmlObject ( + IN AML_OBJECT_INSTANCE **Object, + IN OUT LIST_ENTRY *ListHead + ); + +/** + Creates a new AML_OBJECT_INSTANCE. Object->Data will be NULL and + Object->DataSize will be 0 + + Allocates AML_OBJECT_INSTANCE which must be freed by caller + + @param [out] ReturnObject - Pointer to an Object + + @return EFI_SUCCESS - Object created and appended to linked li= st + @return - Object creation failed, Object =3D 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 li= st + @return - Object creation failed, Object =3D 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 li= st + @return - Object creation failed, Object =3D NULL +**/ +EFI_STATUS +EFIAPI +InternalAppendNewAmlObject ( + OUT AML_OBJECT_INSTANCE **ReturnObject, + IN CHAR8 *Identifier, + IN OUT LIST_ENTRY *ListHead + ); + +/** + Finds AML_OBJECT_INSTANCE given a string Identifier looking backwards in= the + AML_OBJECT_INSTANCE linked list + + @param [out] ReturnObject - Pointer to an Object + @param [in] Identifier - String Identifier to create object with + @param [in] ListHead - Head of AML Object linked list + + @return EFI_SUCCESS - Object located and returned + @return - Object creation failed, Object =3D 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 chil= dren + @param [in,out] ListHead - Head of Object Linked List + + @return EFI_SUCCESS - ChildObject created and returned + @return - Object creation failed, Object =3D 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= .
+ + 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 =3D 0, ///< Detect= endpoint presence + DxioEndpointNotPresent ///< Endpoint= not present (or connected). Used in case there is alternative way to deter= mine + ///< if devic= e present on board or in slot. For example GPIO can be used to determine de= vice presence. +} DXIO_ENDPOINT_STATUS; + +#pragma pack(push,1) +typedef struct { + UINT16 ParamType; ///< This identifies a sp= ecific 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]; ///< PH= Y port parameter +} PORT_PARAMS; + +/// +/// Ancillary data struct with table size and address +/// +typedef struct { + IN UINT32 Count; ///< Total count in t= his Ancillary data table + IN UINT32 Ovrd; ///< Ancillary data t= able 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 in= to compliance mode (device will not be trained, port output compliance patt= ern) + UINT8 LinkSafeMode : 1; ///< Safe mode PCI= e capability. (Parameter may limit PCIe speed requested through DXIO_PORT_D= ATA::LinkSpeedCapability) + ///< 0 - port ca= n advertize muximum supported capability + ///< 1 - port li= mit advertized capability and speed to PCIe Gen1 + UINT8 SbLink : 1; ///< PCIe link typ= e + ///< 0 - General= purpose port + ///< 1 - Port co= nnected to SB + UINT8 ClkPmSupport : 1; ///< Clock Power M= anagement Support + ///< 0 - Clock P= ower Management not configured + ///< 1 - Clock P= ower 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 Unus= ed Lanes + ///< 0 - Turn on + ///< 1 - Turn of= f +} 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 G= rp 0 (Interrupts 0..3 of IO APIC redirection table) + ///< 2 - mapped to G= rp 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 redirectio= n 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 o= f IO APIC redirection table +} DXIO_APIC_DEVICE_INFO; +/// +/// PCIe port configuration data +/// +typedef struct { + UINT8 PortPresent : 1; ///< Enable PCIe por= t for initialization. + UINT8 Reserved1 : 2; ///< Reserved + UINT8 DeviceNumber : 5; ///< PCI Device numb= er for port. + ///< 0 - Native po= rt device number + ///< N - Port devi= ce number (See available configurations in BKDG + UINT8 FunctionNumber : 3; ///< Reserved for fu= ture use + UINT8 LinkSpeedCapability : 3; ///< PCIe link speed= / + ///< 0 - Maximum s= upported by silicon + ///< 1 - Gen1 + ///< 2 - Gen2 + ///< 3 - Gen3 + ///< 4 - Gen4 + ///< 5 - Gen5 + UINT8 AutoSpdChng : 2; ///< Upstread Auto S= peed Change Allowed/ + ///< 0 - Use defau= lt implementation (Disabled for Gen1, Enabled for Gen2/3) + ///< 1 - Always Di= sabled + ///< 2 - Always En= abled + ///< 3 - Reserved + UINT8 EqPreset : 4; ///< Gen3 Equalizati= on 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 L= 1 + 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 F= ield + ///< 0 - NONE + ///< 1 - CLKREQ0 s= ignal + ///< 2 - CLKREQ1 s= ignal + ///< 3 - CLKREQ2 s= ignal + ///< 4 - CLKREQ3 s= ignal + ///< 5 - CLKREQG s= ignal + 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 =3D 1.0x + ///< 01b =3D 0.1x + ///< 10b =3D 0.01x + ///< 11b =3D 0.001= x + UINT8 IsMasterPLL : 1; ///< IsMasterPLL + UINT8 Gen4Features : 5; ///< Unused bits + ///< BIT0(DLF_Exch= ange) 1 - Disable, 0 - Enable + ///< IT1(DLF_Capab= ility) 1 - Disable, 0 - Enable + UINT16 SlotNum : 13; ///< PHYSICAL_SLOT_N= UM + UINT16 CsLink : 3; ///< Reserved + DXIO_PORT_MISC_CONTROL MiscControls; ///< Misc extended c= ontrols + DXIO_APIC_DEVICE_INFO ApicDeviceInfo; ///< IOAPIC device p= rogramming 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 contro= l + UINT8 TxVetting : 1; ///< Tx Vetting + UINT8 RxVetting : 1; ///< Rx Vetting + UINT8 InvertPolarity : 1; ///< Invert RX Polar= ity + UINT8 InvertPolarity2 : 1; ///< Invert TX Polar= ity + UINT8 NtbHotplug : 1; ///< NTB Hotplug fla= g + ///< 0b =3D Disabl= ed + ///< 1b =3D Enable= d + UINT8 Reserved2 : 1; ///< Reserved + UINT8 SetGen3FixedPreset : 1; ///< Gen3 Fixed Pres= et Set + UINT8 SetGen4FixedPreset : 1; ///< Gen4 Fixed Pres= et Set + UINT8 SetGen5FixedPreset : 1; ///< Gen5 Fixed Pres= et Set + UINT8 Reserved3 : 5; ///< Reserved + UINT8 Gen3FixedPreset : 4; ///< Gen3 Fixed Pres= et + UINT8 Gen4FixedPreset : 4; ///< Gen4 Fixed Pres= et + UINT8 Gen5FixedPreset : 4; ///< Gen5 Fixed Pres= et + UINT8 Reserved4 : 4; ///< Reserved + UINT16 PsppPolicyDC; ///< Pspp DC control + UINT16 PsppPolicyAC; ///< PSPP AC control + UINT8 PsppDeviceType; ///< Pspp Device Typ= e + UINT8 DisGen3EQPhase : 1; ///< Gen3 Bypass pha= se2/3 EQ + UINT8 DisGen4EQPhase : 1; ///< Gen4 Bypass pha= se2/3 EQ + UINT8 TXDeEmphasisOride : 1; ///< Override Gen2 D= XIO deemphasis default + UINT8 TXDeEmphasis : 2; ///< Gen2 DXIO deemp= hasis 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 T= x Preset + UINT16 UsRxPresetHint : 3; ///< Gen3 Upstream R= x Preset Hint + UINT16 Reserved1 : 2; ///< Unused bits + UINT8 SetDsTxPreset : 1; ///< Gen3 Set Downst= ream Tx Preset + UINT8 SetDsRxPresetHint : 1; ///< Gen3 Set Downst= ream Rx Preset Hint + UINT8 SetUsTxPreset : 1; ///< Gen3 Set Upstre= am Tx Preset + UINT8 SetUsRxPresetHint : 1; ///< Gen3 Set Upstre= am Rx Preset Hint + UINT8 Reserved2 : 4; ///< Unused bits + } LaneEqualizationCntl; ///< Lane equalizati= on control structure used for Gen3 values + struct { + UINT8 DsTxPreset : 4; ///< Gen4 Downstream= Tx Preset + UINT8 UsTxPreset : 4; ///< Gen4 Upstream T= x Preset + UINT8 SetDsTxPreset : 1; ///< Gen4 Set Downst= ream Tx Preset + UINT8 SetUsTxPreset : 1; ///< Gen4 Set Upstre= am Tx Preset + UINT8 Reserved1 : 6; ///< Unused bits + } Gen4LaneEqualizationCntl; ///< Lane equ= alization control structure used for Gen4 values + struct { + UINT8 DsTxPreset : 4; ///< Gen5 Downstream= Tx Preset + UINT8 UsTxPreset : 4; ///< Gen5 Upstream T= x Preset + UINT8 SetDsTxPreset : 1; ///< Gen5 Set Downst= ream Tx Preset + UINT8 SetUsTxPreset : 1; ///< Gen5 Set Upstre= am Tx Preset + UINT8 Reserved1 : 6; ///< Unused bits + } Gen5LaneEqualizationCntl; ///< Lane equalizati= on control structure used for Gen5 values + struct { + UINT32 PresetMask8Gt : 10; ///< Preset Mask 8GT= . + UINT32 PresetMask16Gt : 10; ///< Preset Mask 16G= T. + UINT32 PresetMask32Gt : 10; ///< Preset Mask 32G= T. + UINT32 Reserved1 : 2; ///< Unused bits + UINT8 SetPresetMask8Gt : 1; ///< Preset Mask 8GT= Set + UINT8 SetPresetMask16Gt : 1; ///< Preset Mask 16G= T Set + UINT8 SetPresetMask32Gt : 1; ///< Preset Mask 32G= T Set + UINT8 Reserved2 : 5; ///< Unused bits + } PresetMaskCntl; ///< Preset Mask contr= ol structure used for Gen3/Gen4/Gen5 values + UINT8 TargetLinkSpeed : 3; ///< Target Link Speed + UINT8 BypassGen3EQ : 1; ///< Bypass Gen3 equal= ization + UINT8 BypassGen4EQ : 1; ///< Bypass Gen4 equal= ization + UINT8 SrisSkipInterval : 3; ///< Controls SRIS SKP= generation interval + UINT8 SrisEnableMode : 4; ///< 0:Disable 1:Enabl= e 0xF:Auto + UINT8 SrisAutoDetectMode : 4; ///< Controls SRIS Aut= odetect mode 0:Disable 1:Enable 0xF:Auto + UINT8 LowerSkpOsGenSup; ///< Controls LOWER_SK= P_OS_GEN_SUPPORT + UINT8 LowerSkpOsRcvSup; ///< Controls LOWER_SK= P_OS_RCV_SUPPORT + UINT8 SrisSkpIntervalSel : 2; ///< Controls SRIS SKI= P Interval Selection Mode + UINT8 SrisAutodetectFactor : 2; ///< Controls the mult= iplier for SKP ordered set interval when generated based on elasticity buff= er pointer slip feedback from PCS + UINT8 IsBmcLocation : 1; ///< IsBmcLocation + UINT8 SetEsmControl : 1; ///< Set ESM Control + UINT8 SetEsmSpeedBump : 1; ///< Set Speed bump fo= r ESM + UINT8 Reserved6 : 1; ///< Unused bits + UINT8 I2CMuxInfo : 6; ///< Legacy I2c switch + UINT8 AlwaysExpose : 1; ///< Always expose unu= sed PCIE port + UINT8 Reserved7 : 1; ///< Unused bits + UINT16 NpemEnable : 12; ///< Controls NPEM Ena= ble + UINT16 Reserved8 : 4; ///< Unused bits + UINT16 NpemCapability : 12; ///< Controls NPEM Cap= ability + UINT8 SwingMode : 3; ///< PCIe Swing Mode + UINT16 Reserved9 : 1; ///< Unused bits + UINT16 MpioAncDataIdx; ///< Reserved for inte= rnal 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 =3D Reserved + ///< 1 =3D 10G/1G BackP= lane + ///< 2 =3D 2.5G BackPla= ne + ///< 3=3D Soldered down= 1000Base-T + ///< 4 =3D Soldered dow= n 1000Base-X + ///< 5 =3D Soldered dow= n NBase-T + ///< 6 =3D Soldered dow= n 10GBase-T + ///< 7 =3D Soldered dow= n 10GBase-r + ///< 8 =3D SFP+ Connect= or + UINT32 Reserved1 : 4; ///< Unused 12-15 + UINT32 MdioId : 5; ///< MDIO ID when MDIO Si= de band is used + UINT32 Reserved2 : 2; ///< Unused 21-22 + UINT32 SuppSpeed : 4; ///< Supported Speeds by = Platform + ///< 1 =3D 100M Support= ed + ///< 2 =3D 1G Supported + ///< 4 =3D 2.5G Support= ed + ///< 8 =3D 10G Supporte= d + UINT32 Reserved3 : 1; ///< Unused 27 + UINT32 ConnType : 3; ///< Supported Speeds by = Platform + ///< 0 =3D Port not Use= d + ///< 1 =3D SFP+ Connect= ion I2C interface + ///< 2 =3D MDIO PHY + ///< 4 =3D Backplane Co= nnection + UINT32 Reserved4 : 1; ///< Unused 31 +} ETH_PORT_PROPERTY0; + +typedef struct { + UINT32 MdioReset : 2; ///< MDIO Reset Type + ///< 0 =3D None + ///< 1 =3D I2C GPIO + ///< 2 =3D Integrated G= PIO + ///< 3 =3D Reserved + UINT32 Reserved1 : 2; ///< Unused 2-3 + UINT32 MdioGpioResetNum : 2; ///< Integrated GPIO numb= er 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 signal= s 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. Dow= nstream 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 D= escriptor + 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 b= its) + UINT32 PadMux1; ///< PadMux1 Setting (8 b= its) + 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 Ho= t-Switchable + ///< 1 - Link IS Hot-Sw= itchable + UINT8 Reserved1 : 7; ///< Unused field, leave = as 0 + UINT8 StartLane; ///< Start Lane ID (in re= versed configuration StartLane > EndLane) + ///< Refer to lane descri= ptions and supported configurations in BKDG + UINT8 EndLane; ///< End lane ID (in reve= rsed configuration StartLane > EndLane) + ///< Refer to lane descri= ptions and supported configurations in BKDG + UINT8 GpioGroupId; ///< Unique identifier fo= r the GPIO or GPIO group associated with + ///< this engine. GPIOs = are used for hotplug notification and link + ///< type (e.g SATA Expre= ss or PCIe) + UINT8 DxioStartLane; ///< Internal coding of s= tart lane + UINT8 DxioEndLane; ///< Internal coding of e= nd lane + UINT8 SearchDepth; ///< SearchDepth only use= s 1 bit - always initialize to 0 will be updated dynamically +} DXIO_ENGINE_DATA; + +/// +/// PCIe port descriptor +/// +typedef struct { + UINT32 Flags; ///< Descriptor flags + ///< Bit31 - last descr= iptor in complex + DXIO_ENGINE_DATA EngineData; ///< Engine data + DXIO_PORT_DATA Port; ///< PCIe port specific c= onfiguration info + ETHERNET_PORT_DATA EtherNet; ///< Ancillary data for E= therNet + PHY_DATA Phy; ///< Ancillary data for P= HY programming customization + PORT_PARAMS PortParams; ///< Extensible port para= meter list for simplified topology structure + ANC_DATA AncData; ///< Ancillary data overr= ide +} DXIO_PORT_DESCRIPTOR; + +#pragma pack(pop) + +/// +/// +/// PCIe Complex descriptor +/// +typedef struct { + UINT32 Flags; ///< Descriptor flags + ///< Bit31 - last descr= iptor 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 wit= h DESCRIPTOR_TERMINATE_LIST). + VOID *Reserved2; ///< Reserved for future = use + UINT8 BmcLinkLocation; ///< Identifies the socke= t/die location of a BMC link (Used by AGESA, input not required) + UINT8 BmcLinkLaneNum; ///< Identifies the socke= t/die location of a BMC Lane number + UINT8 Reserved3[2]; ///< Reserved for future +} DXIO_COMPLEX_DESCRIPTOR; + +/// +/// Engine descriptor type +/// +typedef enum { + DxioUnusedEngine =3D 0, ///< Unused de= scriptor Excluded from configuration + DxioPcieEngine =3D 1, ///< PCIe port + DxioUSBEngine =3D 2, ///< USB port + ///< __Deprecate= d__ + DxioSATAEngine =3D 3, ///< SATA + DxioUSB_OVER_PCIE =3D 4, ///< USB4 PCIe= (internal use only) + DxioUBMHFCEngine =3D 5, ///< New for G= enoa UBM HFC Connector for auto-discovery + DxioOCP3Engine =3D 6, ///< New for G= enoa OCP3 Bifurcatable Connector + DxioUdot3Engine =3D 7, ///< New for G= enoa U.3 Multiprotocol Connector + DxioDPEngine =3D 8, ///< Digital D= isplay __For APU display connector list__ + DxioEthernetEngine =3D 0x10, ///< Ethernet = (GBe, XGBe) + ///< __Deprecate= d__ + DxioGOPEngine =3D 0x20, ///< GOP + ///< __Deprecate= d__ + DxioNTBDevice =3D 0x60, ///< For NBIF = NTB Enable (internal use only) + DxioHDaudioEngine, ///< For NBIF HD= audtio Enable (internal use only) + DxioACPEngine, ///< For NBIF AC= P Enable (internal use only) + DxioMP2Engine, ///< For NBIF MP= 2 Enable (internal use only) + DxioMaxPcieEngine ///< Max engine = type for boundary check. +} DXIO_ENGINE_TYPE; + +/// +/// PCIe link speeds +/// +typedef enum { + DxioGenMaxSupported, ///< Maximum sup= ported + DxioGen1 =3D 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= .
+ + 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/Pla= tform/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= .
+ + 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 br= idges 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 me= ans 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_SUPPO= RTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) above 4G.= @see FABRIC_ADDR_APERTURE + FABRIC_ADDR_APERTURE PrefetchableMmioSizeAbove4G[MAX_SOCKETS_SUPPORTE= D][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) above 4G. @s= ee FABRIC_ADDR_APERTURE + FABRIC_ADDR_APERTURE NonPrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPO= RTED][MAX_RBS_PER_SOCKET]; ///< Nonprefetchable MMIO resource(s) below 4G.= @see FABRIC_ADDR_APERTURE + FABRIC_ADDR_APERTURE PrefetchableMmioSizeBelow4G[MAX_SOCKETS_SUPPORTE= D][MAX_RBS_PER_SOCKET]; ///< Prefetchable MMIO resource(s) below 4G. @s= ee FABRIC_ADDR_APERTURE + FABRIC_ADDR_APERTURE PrimaryRbSecondNonPrefetchableMmioSizeBelow4G; = ///< Primary RootBridge's second nonprefetchabl= e MMIO size below 4G. @see FABRIC_ADDR_APERTURE + FABRIC_ADDR_APERTURE PrimaryRbSecondPrefetchableMmioSizeBelow4G; = ///< Primary RootBridge's second prefetchable M= MIO 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/Platfo= rm/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= .
+ 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 addres= s of memory rang + UINT64 Size; ///< Size of mem= ory rang + UINT32 Attribute; ///< Attribute o= f memory rang + UINT32 Reserved; ///< For alignme= nt purpose +} AMD_MEMORY_RANGE_DESCRIPTOR; + +/** + * @brief Memory attribute in the memory range descriptor =3D AVAILABLE + */ +#define AMD_MEMORY_ATTRIBUTE_AVAILABLE 0x1 + +/** + * @brief Memory attribute in the memory range descriptor =3D UMA + */ +#define AMD_MEMORY_ATTRIBUTE_UMA 0x2 + +/** + * @brief Memory attribute in the memory range descriptor =3D MMIO + */ +#define AMD_MEMORY_ATTRIBUTE_MMIO 0x3 + +/** + * @brief Memory attribute in the memory range descriptor =3D RESERVED + */ +#define AMD_MEMORY_ATTRIBUTE_RESERVED 0x4 + +/** + * @brief Memory attribute in the memory range descriptor =3D GPUMEM + */ +#define AMD_MEMORY_ATTRIBUTE_GPUMEM 0x5 + +/** + * @brief Memory attribute in the memory range descriptor =3D GPU_SP + */ +#define AMD_MEMORY_ATTRIBUTE_GPU_SP 0x6 + +/** + * @brief Memory attribute in the memory range descriptor =3D GPU_RESERVED + */ +#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED 0x7 + +/** + * @brief Memory attribute in the memory range descriptor =3D GPU_RESERVED= _TMR + */ +#define AMD_MEMORY_ATTRIBUTE_GPU_RESERVED_TMR 0x8 + +/** + * @brief Memory attribute in the memory range descriptor =3D RESERVED_SMU= FEATURES + */ +#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 Volta= ge + BOOLEAN AmdMemoryVddpVddrValid; ///< This field = determines if VddpVddr is valid + UINT8 AmdMemoryVddpVddr; ///< VddpVddr vo= ltage + BOOLEAN AmdMemoryFrequencyValid; ///< Memory Freq= uency Valid + UINT32 AmdMemoryFrequency; ///< Memory Frqu= ency + UINT32 AmdMemoryDdrMaxRate; ///< Memory DdrM= axRate + UINT32 NumberOfDescriptor; ///< Number of m= emory range descriptor + AMD_MEMORY_RANGE_DESCRIPTOR Ranges[1]; ///< Memory rang= es 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/Plat= form/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.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AMD_PSP_BASELIB_V2_H_ +#define AMD_PSP_BASELIB_V2_H_ + +#include + +#define MAX_IMAGE_SLOT_COUNT 32 + +#define ALIGNMENT_4K BASE_4KB +#define ALIGN_CHECK(addr, alignment) ((((UINTN)(addr)) & ((alignment) - 1= )) =3D=3D 0) +#define ALIGN_4K_CHECK(addr) ALIGN_CHECK((addr), ALIGNMENT_4K) + +#define IS_VALID_ADDR32(addr) (((UINT32)(addr) !=3D 0) && (UINT32)(addr) = !=3D 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 d= irectory + UINT32 Reserved2; ///< 0x1C Base Address for Reserved BIOS d= irectory + UINT32 Reserved3; ///< 0x20 Base Address for Reserved BIOS d= irectory + UINT32 Config; ///< 0x24 reserved for EFS Configuration + UINT32 NewBiosDirBase; ///< 0x28 Generic Base address for all pro= gram + UINT32 PspDirBackupBase; ///< 0x2C Backup PSP directory address for= all programs +} FIRMWARE_ENTRY_TABLEV2; + +/// It also used as structure to store ISH generic information across prog= rams +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/Platfo= rm/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= .
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PSP_FTPM_LIB_H_ +#define PSP_FTPM_LIB_H_ +#include + +/* SYSTEM_TPM_CONFIG_VAL + * Value range for APCB_TOKEN_UID_PSP_SYSTEM_TPM_CONFIG + */ +typedef enum { + SYSTEM_TPM_CONFIG_DTPM =3D 0x00, ///< dTPM + SYSTEM_TPM_CONFIG_PSP_FTPM =3D 0x01, ///< PSP FTPM + SYSTEM_TPM_CONFIG_HSP_FTPM =3D 0x02, ///< HSP FTPM + SYSTEM_TPM_CONFIG_NONE =3D 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 Identifie= r + // 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 (Un= used 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 b= uffer + + @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 stat= us set + @return EFI_BUFFER_TOO_SMALL Response buffer too small to ho= ld 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/Pl= atform/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= .
+ + 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 Da= ta Buffer Size +#define PSP_MAX_WHITE_LIST_CMD_NUM (32) ///< Max White list all= owed command array number support +#define PSP_MAX_WHITE_LIST_REGION_NUM (16) ///< Max White list all= owed region array number support + +#define SPI_CHIP_SELECT_ALL (0) ///< Allowed on all chi= p 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=3D66.66MHz +#define SPI_COMMAND_FREQUENCY_33_33MHZ (1) ///< 1=3D33.33MHz +#define SPI_COMMAND_FREQUENCY_22_22MHZ (2) ///< 2=3D22.22MHz +#define SPI_COMMAND_FREQUENCY_16_66MHZ (3) ///< 3=3D16.66MHz +#define SPI_COMMAND_FREQUENCY_100MHZ (4) ///< 4=3D100MHz +#define SPI_COMMAND_FREQUENCY_800KHZ (5) ///< 5=3D800KHz + +#define SPI_COMMAND_NOT_PROCEDDED (0) ///< 0 =3D Command not = examined/processed +#define SPI_COMMAND_COMPLETED (1) ///< 1 =3D Command comp= leted successfully +#define SPI_COMMAND_EXECUTION_ERROR (2) ///< 2 =3D Execution Er= ror (i.e. timeout) +#define SPI_COMMAND_NOT_ALLOWED (3) ///< 3 =3D Command not = allowed by Whitelist +#define SPI_COMMAND_MALFORMED (4) ///< 4 =3D Command malf= ormed + +#pragma pack (push, 1) + +typedef struct { + UINT8 ChipSelect; ///< 1 =3D CS1, 2 =3D CS2, all other values ill= egal + + UINT8 Frequency; ///< 0=3D66.66MHz, 1=3D33.33MHz, 2=3D22.22MHz, + ///< 3=3D16.66MHz, 4=3D100Mhz, 5=3D800KHz, all = others illegal + + UINT8 BytesToTx; ///< Bytes to Transmit, valid range is 0-72. Do= es not include the + ///< SPI Opcode byte, but does include the addr= ess, dummy bytes, and + ///< data. + + UINT8 BytesToRx; ///< Bytes to Receive from device, BytesToTx + = BytesToRx <=3D 72 + + UINT8 OpCode; ///< The SPI Command OpCode (the first byte sen= t 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 Controll= er will + ///< 1. Assert the = ChipSelect + ///< 2. Send the on= e byte OpCode + ///< 3. Send Buffer= [0] to Buffer[BytesToTx-1] to the SPI device + ///< 4. Read BytesT= oRx bytes from the device into Buffer[BytesToTx] to + ///< Buffer[Byte= sToTx+BytesToRx-1] + ///< 5. Deassert th= e ChipSelect line + ///< + ///< SPI ROM Commands= that include a target address send the address + ///< immediately afte= r 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 Sp= i 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 Comman= d0 ~ 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 t= he buffer is being constructed. Set to + ///< TRUE by x86 as the last ste= p in building the communication buffer, + ///< just before x86 rings the P= SP doorbell. + ///< + ///< Set to FALSE by PSP after t= he PSP copies the buffer from DRAM to + ///< private SRAM. + + UINT8 CommandCount; ///< Number of commands to exe= cute, 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 b= y the PSP provides per command results + ///< + ///< Result values w= ith special meaning: + ///< 0x0000 =3D (wri= tten by x86) PSP has not finished handling the request + ///< 0x1000 =3D PSP = determined the request is malformed (invalid + ///< Comman= dCount, chipselect, BytesToRx/Tx, etc) + ///< 0x2000, 0x3000,= 0x4000, ... , 0xF000 =3D Reserved for future errors + ///< + ///< Generic Result = values: + ///< SpiCommunicat= ionResult[ 3: 0] The result of Command[0] + ///< SpiCommunicat= ionResult[ 7: 4] The result of Command[1] + ///< SpiCommunicat= ionResult[11: 8] The result of Command[2] + ///< SpiCommunicat= ionResult[15:12] The result of Command[3] + ///< 0 =3D Comm= and not examined/processed + ///< 1 =3D Comm= and completed successfully + ///< 2 =3D Exec= ution Error (i.e. timeout) + ///< 3 =3D Comm= and not allowed by Whitelist + ///< 4 =3D Comm= and malformed + ///< 5-15 =3D r= eserved for future use + ///< + ///< Examples of Gen= eric 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 arr= ay +} SPI_COMMUNICATION_BUFFER; ///< The struct type= of Spi Communication Buffer + +typedef struct { + UINT8 ChipSelect; ///< 0=3D Allowed on all chip selects, 1=3D CS1= , 2=3D CS2, all else invalid + + UINT8 Frequency; ///< The allowed frequency for the command + ///< 0=3D66.66MHz, 1=3D33.33MHz, 2=3D22.22MHz, + ///< 3=3D16.66MHz, 4=3D100Mhz, 5=3D800KHz, 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 count= s + UINT8 MaxRx; ///< The maximum range of allowed Rx byte count= s + + UINT8 AddrChkMethod; ///< 0=3DNo address verification performed + ///< 1=3DTreat Buffer[0-2] as a 24-bit address,= and verify the entire + ///< ImpactZone of the command falls within o= ne of the allowed regions + ///< 2=3DTreat Buffer[0-3] as a 32-bit address,= and verify the entire + ///< ImpactZone of the command falls within o= ne of the allowed regions + + UINT32 ImpactSize; ///< The Impact Zone is the naturally aligned p= ower of two sized block + ///< of addresses that may be impacted by a giv= en SPI Command. For + ///< example, a sector erase command targeted a= t an address within a + ///< 64K block will impact every byte within th= at 64K block. Likewise + ///< a page program SPI command (i.e. write) ma= y 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 com= mand. If VerifyAddress is + ///< zero (no checking) this field must also be= zero, otherwise this + ///< field must be a power of two between 256 a= nd 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 ch= ipselect: 0=3DCS1, 1=3DCS2 + UINT32 EndAddress; ///< LSB must be 0xFF, StartAddress must be = less than EndAddress +} WHITE_LIST_ALLOWED_REGION; ///< The struct type of White List Allowed R= egion + +typedef struct { + UINT8 AllowedCmdCount; = ///< Allow Command Count + UINT8 AllowedRegionCount; = ///< Allow Region Count + WHITE_LIST_ALLOWED_COMMAND WhitelistAllowedCommands[PSP_MAX_WHITE_LIS= T_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 B= uffer 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=3D Allowed on all = chip selects, 1=3D CS1, 2=3D 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/Pla= tform/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AML_LIB_H_ +#define AML_LIB_H_ + +#include +#include + +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 devi= ce +// 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_DE= CODE_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_RES= OURCE_CONSUMER + +// Memory Resource Flag (Resource Type =3D 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 =3D 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 specifi= c I/O port +// within the secondary-side range can be found using the following = function. +// address =3D (((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 =3D 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 sid= e 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 descri= ptor is +// limited to the ISA I/O addresses that fall within the specified w= indow. The +// ISA I/O ranges are: n000-n0FF, n400-n4FF, n800-n8FF, nC00-nCFF. T= his bit can +// only be set for bridges entirely configured throughACPI namespace= . +// 1 NonISARangesOnly. This flag is for bridges on systems with multip= le +// bridges. Setting this bit means the memory window specified in th= is +// descriptor is limited to the non-ISA I/O addresses that fall with= in the +// specified window. The non-ISA I/O ranges are: n100-n3FF, n500-n7F= F, +// n900-nBFF, nD00-nFFF. This bit can only be set for bridges entire= ly +// 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 AttribRawP= rocessBytes +// the ExtendedAccessField definition is used, as this is what iASL compil= es into, rather +// than the AccessField that is specified in the ACPI spec. +typedef enum { + AttribNormal =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_NOR= MAL, + AttribQuick =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_QUI= CK, + AttribSendReceive =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_SEN= D_RECEIVE, + AttribByte =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYT= E, + AttribWord =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_WOR= D, + AttribBlock =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLO= CK, + AttribBytes =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BYT= ES, + AttribProcessCall =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_PRO= CESS_CALL, + AttribBlockProcessCall =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_BLO= CK_PROCESS_CALL, + AttribRawBytes =3D EFI_ACPI_FIELD_FLAGS_ACCESS_ATTRIB_ATTRIB_RAW= _BYTES, + AttribRawProcessBytes =3D 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 =3D EFI_ACPI_DMA_SPEED_TYPE_COMPATIBILITY, + TypeA =3D EFI_ACPI_DMA_SPEED_TYPE_A, + TypeB =3D EFI_ACPI_DMA_SPEED_TYPE_B, + TypeF =3D EFI_ACPI_DMA_SPEED_TYPE_F +} EFI_ACPI_DMA_SPEED_TYPE_KEYWORDS; + +// IsBusMaster values +typedef enum { + NotBusMaster =3D 0, + BusMaster =3D EFI_ACPI_DMA_BUS_MASTER +} EFI_ACPI_DMA_BUS_MASTER_KEYWORDS; + +// DmaTransferSize values +typedef enum { + Transfer8 =3D EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT, + Transfer8_16 =3D EFI_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT, + Transfer16 =3D 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 =3D EFI_ACPI_IRQ_NOT_WAKE_CAPABLE, + WakeCapable =3D EFI_ACPI_IRQ_WAKE_CAPABLE +} EFI_ACPI_IRQ_WAKE_CAPABILITY_KEYWORDS; + +// +// IRQ Information - Interrupt Sharing +// +#define EFI_ACPI_IRQ_EXCLUSIVE 0x0 + +typedef enum { + Exclusive =3D EFI_ACPI_IRQ_EXCLUSIVE, + Shared =3D EFI_ACPI_IRQ_SHARABLE, + ExclusiveAndWake =3D EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_EXCLUSIVE, + SharedAndWake =3D EFI_ACPI_IRQ_WAKE_CAPABLE | EFI_ACPI_IRQ_SHARABLE +} EFI_ACPI_IRQ_INTERRUPT_SHARING_KEYWORDS; + +// +// IRQ Information - Interrupt Polarity +// +typedef enum { + ActiveHigh =3D EFI_ACPI_IRQ_HIGH_TRUE, + ActiveLow =3D 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 =3D EFI_ACPI_IRQ_LEVEL_TRIGGERED, + EdgeTriggered =3D 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 =3D EFI_ACPI_IO_DECODE_16_BIT, + Decode10 =3D 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 =3D EFI_ACPI_GENERAL_FLAG_RESOURCE_PRODUCER, + ResourceConsumer =3D EFI_ACPI_GENERAL_FLAG_RESOURCE_CONSUMER +} RESOURCE_USAGE_FLAG; + +// Decode Type (_DEC) Bit[1] +typedef enum { + PosDecode =3D EFI_ACPI_GENERAL_FLAG_DECODE_POSITIVE, + SubDecode =3D EFI_ACPI_GENERAL_FLAG_DECODE_SUBTRACTIVE +} MEM_DECODE_FLAG; + +// Min Address Fixed (_MIF) Bit[2] +typedef enum { + MinNotFixed =3D EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED, + MinFixed =3D EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED +} MIN_FIXED_FLAG; + +// Max Address Fixed (_MAF) Bit[3] +typedef enum { + MaxNotFixed =3D EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED, + MaxFixed =3D EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED +} MAX_FIXED_FLAG; + +// Memory Attributes (_MEM) Bits[2:1] +typedef enum { + NonCacheable =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE, + Cacheable =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE, + WriteCombining =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_WRIT= E_COMBINING, + Prefetchable =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREF= ETCHABLE +} CACHEABLE_FLAG; + +// Write Status (_RW) Bit[0] +typedef enum { + ReadOnly =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_ONLY, + ReadWrite =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_READ_WRITE +} READ_WRITE_FLAG; + +// Memory Attributes (_MTP) Bits[4:3] +typedef enum { + AddressRangeMemory =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_= RANGE_MEMORY, + AddressRangeReserved =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_= RANGE_RESERVED, + AddressRangeACPI =3D EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_= RANGE_ACPI, + AddressRangeNVS =3D 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 =3D 0, + TypeTranslation =3D 1 +} MEMORY_TRANSLATION_TYPE; + +// Memory Window Attributes (_RNG) Bits[1:0] +typedef enum { + Reserved =3D 0, + NonISAOnly =3D EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_NON_ISA_ON= LY, + ISAOnly =3D EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ISA_ONLY, + EntireRange =3D EFI_ACPI_IO_RESOURCE_SPECIFIC_FLAG_TYPE_RANGE_ENTIRE, + ISARangeMax +} IO_ISA_RANGES; + +// Generic Address Space Address IDs +typedef enum { + SystemMemory =3D EFI_ACPI_6_4_SYSTEM_MEMORY, + SystemIO =3D EFI_ACPI_6_4_SYSTEM_IO, + PCI_Config =3D EFI_ACPI_6_4_PCI_CONFIGURATION_SPACE, + EmbeddedControl =3D EFI_ACPI_6_4_EMBEDDED_CONTROLLER, + SMBus =3D EFI_ACPI_6_4_SMBUS, + SystemCMOS =3D EFI_ACPI_6_4_SYSTEM_CMOS, + PciBarTarget =3D EFI_ACPI_6_4_PCI_BAR_TARGET, + IPMI =3D EFI_ACPI_6_4_IPMI, + GeneralPurposeIO =3D EFI_ACPI_6_4_GENERAL_PURPOSE_IO, + GenericSerialBus =3D EFI_ACPI_6_4_GENERIC_SERIAL_BUS, + PCC =3D EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL, + PlatformCommChannel =3D EFI_ACPI_6_4_PLATFORM_COMMUNICATION_CHANNEL, + FFixedHW =3D EFI_ACPI_6_4_FUNCTIONAL_FIXED_HARDWARE +} GENERIC_ADDRESS_SPACE_ID; + +typedef enum { + UndefinedSize =3D EFI_ACPI_6_4_UNDEFINED, + ByteSize =3D EFI_ACPI_6_4_BYTE, + WordSize =3D EFI_ACPI_6_4_WORD, + DWordSize =3D EFI_ACPI_6_4_DWORD, + QWordSize =3D 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 :=3D TableSignature TableLength SpecCompliance CheckSum = OemID + OemTableID OemRevision CreatorID CreatorRevision + + TableSignature :=3D DWordData // As defined in section 5.2.3. + TableLength :=3D DWordData // Length of the table in bytes incl= uding the + // block header + SpecCompliance :=3D ByteData // The revision of the structure. + CheckSum :=3D ByteData // Byte checksum of the entire table= . + OemID :=3D ByteData(6) // OEM ID of up to 6 characters. + // If the OEM ID is shorter than 6 + // characters, it can be terminated wi= th a + // NULL character. + OemTableID :=3D ByteData(8) // OEM Table ID of up to 8 character= s. + // If the OEM Table ID is shorter than + // 8 characters, it can be terminated = with + // a NULL character. + OemRevision :=3D DWordData // OEM Table Revision. + CreatorID :=3D DWordData // Vendor ID of the ASL compiler. + CreatorRevision :=3D 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 Objec= t 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 :=3D 'A'-'Z' | '_' + DigitChar :=3D '0'-'9' + NameChar :=3D DigitChar | LeadNameChar + RootChar :=3D '\' + ParentPrefixChar :=3D '^' + + 'A'-'Z' :=3D 0x41 - 0x5A + '_' :=3D 0x5F + '0'-'9' :=3D 0x30 - 0x39 + '\' :=3D 0x5C + '^' :=3D 0x5E + + NameSeg :=3D + // Notice that NameSegs shorter than 4 characters ar= e filled with + // trailing underscores ('_'s). + NameString :=3D | + PrefixPath :=3D Nothing | <'^' PrefixPath> + NamePath :=3D NameSeg | DualNamePath | MultiNamePath | NullName + + DualNamePath :=3D DualNamePrefix NameSeg NameSeg + DualNamePrefix :=3D 0x2E + MultiNamePath :=3D MultiNamePrefix SegCount NameSeg(SegCount) + MultiNamePrefix :=3D 0x2F + + SegCount :=3D 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 enco= ding + length will be 1 + 1 + 35*4 =3D 142. Notice that: DualNamePrefix Nam= eSeg + NameSeg has a smaller encoding than the encoding of: MultiNamePrefix= (2) + NameSeg NameSeg + + SimpleName :=3D NameString | ArgObj | LocalObj + SuperName :=3D SimpleName | DebugObj | Type6Opcode + NullName :=3D 0x00 + Target :=3D 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 :=3D ByteConst | WordConst | DWordConst | QWordConst |= String | + ConstObj | RevisionOp | DefBuffer + DataObject :=3D ComputationalData | DefPackage | DefVarPackage + DataRefObject :=3D DataObject | ObjectReference | DDBHandle + ByteConst :=3D BytePrefix ByteData + BytePrefix :=3D 0x0A + WordConst :=3D WordPrefix WordData + WordPrefix :=3D 0x0B + DWordConst :=3D DWordPrefix DWordData + DWordPrefix :=3D 0x0C + QWordConst :=3D QWordPrefix QWordData + QWordPrefix :=3D 0x0E + ConstObj :=3D ZeroOp | OneOp | OnesOp + ByteData :=3D 0x00 - 0xFF + WordData :=3D ByteData[0:7] ByteData[8:15] + // 0x0000-0xFFFF + DWordData :=3D WordData[0:15] WordData[16:31] + // 0x00000000-0xFFFFFFFF + QWordData :=3D DWordData[0:31] DWordData[32:63] + // 0x0000000000000000-0xFFFFFFFFFFFFFFFF + ZeroOp :=3D 0x00 + OneOp :=3D 0x01 + OnesOp :=3D 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 :=3D 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 :=3D 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 :=3D 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 :=3D 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 :=3D String + + String :=3D StringPrefix AsciiCharList NullChar + StringPrefix :=3D 0x0D + AsciiCharList :=3D Nothing | + AsciiChar :=3D 0x01 - 0x7F + NullChar :=3D 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 :=3D PkgLeadByte | + | + | + + + PkgLeadByte :=3D + + + + 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 u= sed + to encode the package length (in other words, values 0-63). If the packa= ge + length value is more than 63, more than one byte must be used for the en= coding + in which case bit 4 and 5 of the PkgLeadByte are reserved and must be ze= ro. + + If the multiple bytes encoding is used, bits 0-3 of the PkgLeadByte beco= me + 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 :=3D ScopeOp PkgLength NameString TermList + ScopeOp :=3D 0x10 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] String - Location + @param[in,out] ListHead - Linked list has completed String Object afte= r + 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 :=3D NameOp NameString DataRefObject + NameOp :=3D 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 :=3D AliasOp NameString NameString + AliasOp :=3D 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 :=3D DeviceOp PkgLength NameString TermList + NameOp :=3D ExtOpPrefix 0x82 + ExtOpPrefix :=3D 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 :=3D NameSeg PkgLength + ReservedField :=3D 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 :=3D FieldOp PkgLength NameString FieldFlags FieldList + FieldOp :=3D 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 a= fter + 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, Update= Rule) {FieldUnitList} + FieldUnitList must be added between AmlStart and AmlClose phase + + DefBankField :=3D BankFieldOp PkgLength NameString NameString BankValue= FieldFlags FieldList + BankFieldOp :=3D ExtOpPrefix 0x87 + BankValue :=3D TermArg =3D> 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 Obje= ct + + @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) {Fiel= dUnitList} + + FieldUnitList must be added between AmlStart and AmlClose phase + + DefIndexField :=3D IndexFieldOp PkgLength NameString NameString FieldFla= gs FieldList + IndexFieldOp :=3D 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 Obj= ect + + @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 AmlOPFieldListI= tem, + or another Offset call. All offsets are defined starting from zero, base= d at + the starting address of the parent Operation Region. + + ReservedField :=3D 0x00 PkgLength + + @param[in] ByteLength -Byte offset of the next defined field wit= hin + 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 :=3D OpRegionOp NameString RegionSpace RegionOffset RegionLe= n + OpRegionOp :=3D ExtOpPrefix 0x80 + RegionSpace :=3D + 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 :=3D TermArg =3D> Integer + RegionLen :=3D TermArg =3D> 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 :=3D 0x01 AccessType AccessAttrib + AccessType :=3D ByteData // Bits 0:3 - Same as AccessType bits of Field= Flags. + // Bits 4:5 - Reserved + // Bits 7:6 - 0 =3D AccessAttrib =3D Normal Acce= ss Attributes + // 1 =3D AccessAttrib =3D AttribBytes (x) + // 2 =3D AccessAttrib =3D AttribRawBytes (x) + // 3 =3D AccessAttrib =3D AttribRawProcessBytes = (x) + // + // x' is encoded as bits 0:7 of the AccessAttrib= byte. + + AccessAttrib :=3D 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 Attr= ibBytes, + AttribRawBytes, or AttribRawProcessB= ytes. + Specifies the access length for the = field member + Otherwise, ignored. + @param[in,out] ListHead - Linked list that has completed Acces= sAs 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 passe= d 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 :=3D ExternalOp NameString ObjectType ArgumentCount + ExternalOp :=3D 0x15 + ObjectType :=3D ByteData + ArgumentCount :=3D 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 f= or + that MethodObj since AML does not store + ArgTypes here. + Otherwise, ignored. + @param[in,out] ListHead - Linked list that has completed External Ob= ject + 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 :=3D CreateFieldOp SourceBuff BitIndex NumBits NameString + CreateFieldOp :=3D ExtOpPrefix 0x13 + ExtOpPrefix :=3D 0x5B + SourceBuff :=3D TermArg =3D> Buffer + BitIndex :=3D TermArg =3D> Integer + NumBits :=3D TermArg -> Integer + + @param[in] SourceBuffer, - Buffer to house the new buffer field o= bject + @param[in] BitIndex, - Starting bit index place the new buffe= r + @param[in] NumBits, - Number of bits to reserve + @param[in] FieldName, - The new buffer field object to be crea= ted 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 :=3D CreateBitFieldOp SourceBuff BitIndex NameString + CreateBitFieldOp :=3D 0x8D + SourceBuff :=3D TermArg =3D> Buffer + BitIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer bit fi= eld object + @param[in] BitIndex, - Starting bit index to place the new bu= ffer + @param[in] BitFieldName, - Name of the BitField + @param[in,out] ListHead - Linked list has completed CreateBitFie= ld 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 :=3D CreateByteFieldOp SourceBuff ByteIndex NameStri= ng + CreateByteFieldOp :=3D 0x8C + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer byte f= ield object + @param[in] ByteIndex, - Starting byte index to place the new b= uffer + @param[in] ByteFieldName, - Name of the ByteField + @param[in,out] ListHead - Linked list has completed CreateByteFi= eld 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 lis= t + + Syntax: + CreateDWordField ( SourceBuffer, ByteIndex, DWordFieldName ) + + DefCreateDWordField :=3D CreateDWordFieldOp SourceBuff ByteIndex NameStr= ing + CreateDWordFieldOp :=3D 0x8A + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer DWor= d 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 CreateDWor= dField 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 lis= t + + Syntax: + CreateQWordField ( SourceBuffer, ByteIndex, QWordFieldName ) + + DefCreateQWordField :=3D CreateQWordFieldOp SourceBuff ByteIndex NameStr= ing + CreateQWordFieldOp :=3D 0x8F + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer QWor= d 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 CreateQWor= dField 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 :=3D CreateWordFieldOp SourceBuff ByteIndex NameStri= ng + CreateWordFieldOp :=3D 0x8B + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to house the new buffer word fi= eld object + @param[in] ByteIndex, - Starting byte index to place the new b= uffer + @param[in] WordFieldName, - Name of the WordField + @param[in,out] ListHead - Linked list has completed CreateWordFi= eld 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 :=3D MethodOp PkgLength NameString MethodFlags TermList + MethodOp :=3D 0x14 + MethodFlags :=3D 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 serial= ized + 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 b= e + supported and must be created with Else and If. + + DefElse :=3D Nothing | + ElseOp :=3D 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 aft= er + 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 Pha= se + + Since ElseIf (...) is created with Else {( If (){})}. ElseIf will not b= e + supported and must be created with Else and If. + + DefIfElse :=3D IfOp PkgLength Predicate TermList DefElse + IfOp :=3D 0xA0 + Predicate :=3D TermArg =3D> 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 :=3D NotifyOp NotifyObject NotifyValue + NotifyOp :=3D 0x86 + NotifyObject :=3D SuperName =3D> ThermalZone | Processor | Device + NotifyValue :=3D TermArg =3D> 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 :=3D ReturnOp ArgObject + ReturnOp :=3D 0xA4 + ArgObject :=3D TermArg =3D> 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} =3D> Buffer Object + + Initializers must be created between AmlStart and AmlClose Phase + + DefBuffer :=3D BufferOp PkgLength BufferSize ByteList + BufferOp :=3D 0x11 + BufferSize :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] BufferSize - Requested BufferSize, Encoded value will b= e + MAX (BufferSize OR Child->DataSize) + @param[in,out] ListHead - Linked list has completed Buffer Object af= ter + 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) =3D> Boolean + + Source1 and Source2 operands must be created between AmlStart and AmlClo= se Phase + + DefLEqual :=3D LequalOp Operand Operand + LequalOp :=3D 0x93 + Operand :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed LEqual Object af= ter + 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} =3D> Package + + Initializers must be created between AmlStart and AmlClose Phase + + DefPackage :=3D PackageOp PkgLength NumElements PackageElementLi= st + PackageOp :=3D 0x12 + DefVarPackage :=3D VarPackageOp PkgLength VarNumElements PackageEle= mentList + VarPackageOp :=3D 0x13 + NumElements :=3D ByteData + VarNumElements :=3D TermArg =3D> Integer + PackageElementList :=3D Nothing | + PackageElement :=3D 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 a= fter + 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} =3D> Buffer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed ResourceTemplate O= bject + 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) {DmaChannelL= ist} =3D> 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, 1= 6-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 IMPLEME= NTED + 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, AddressMa= ximum, + AddressTranslation, RangeLength, ResourceSourceIndex, + ResourceSource, DescriptorName, MemoryRangeType, Translatio= nType) + + 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) =3D> 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 dec= laring + 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 =3D 'A' 0b11010 = =3D '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 t= o 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 add= ress + of the memory range. The 32-bit field DescriptorName. _BAS is automati= cally + created to refer to this portion of the resource descriptor. RangeLen= gth + 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 automati= cally + created to refer to this portion of the resource descriptor. + + DescriptorName: Is an optional argument that specifies a name for an i= nteger + constant that will be created in the current scope that contains the o= ffset + of this resource descriptor within the current resource template buffe= r. The + predefined descriptor field names may be appended to this name to acce= ss + 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 for= mat 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 ResourceTempl= ate. + + 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 wit= hin 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 de= scriptor + + @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, Des= criptorName) =3D> 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 De= code16 + 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 AddressAli= gnment. + The field DescriptorName._MIN is automatically created to refer to t= his + 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 AddressAli= gnment. + The field DescriptorName._MAX is automatically created to refer to t= his + portion of the resource descriptor. + + AddressAlignment: + Evaluates to an 8-bit integer that specifies the alignment granulari= ty + for the I/O address assigned. The field DescriptorName. _ALN is auto= matically + 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 t= o refer + to this portion of the resource descriptor. + + DescriptorName: + An optional argument that specifies a name for an integer constant t= hat + will be created in the current scope that contains the offset of thi= s + resource descriptor within the current resource template buffer. The + predefined descriptor field names may be appended to this name to ac= cess + individual fields within the descriptor via the Buffer Field operato= rs. + + Description: + The IO macro evaluates to a buffer which contains an IO resource descr= iptor. + 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 R= esourceTemplate. + + Generates: + 6.4.2.5 I/O Port Descriptor + Type 0, Small Item Name 0x8, Length =3D 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 IM= PLEMENTED + 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 Regi= ster + 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, AddressMa= ximum, + AddressTranslation, RangeLength, ResourceSourceIndex, + ResourceSource, DescriptorName, MemoryRangeType, Translatio= nType) + + 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} = =3D> Buffer + + Arguments: + EdgeLevel: + Describes whether the interrupt is edge triggered (Edge) or level tr= iggered + (Level). The field DescriptorName. _HE is automatically created to r= efer to + this portion of the resource descriptor, where '1' is Edge and Activ= eHigh + and '0' is Level and ActiveLow. + + ActiveLevel: + Describes whether the interrupt is active-high (ActiveHigh) or activ= e-low + (ActiveLow). The field DescriptorName. _LL is automatically created = to refer + to this portion of the resource descriptor, where '1' is Edge and Ac= tiveHigh + and '0' is Level and ActiveLow. + + Shared: + Describes whether the interrupt can be shared with other devices (Sh= ared) or + not (Exclusive), and whether it is capable of waking the system from= a + low-power idle or system sleep state (SharedAndWake or ExclusiveAndW= ake). + 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 constan= t that + will be created in the current scope that contains the offset of thi= s resource + descriptor within the current resource template buffer. The predefin= ed + descriptor field names may be appended to this name to access indivi= dual + fields within the descriptor via the Buffer Field operators. + + Description: + The IRQ macro evaluates to a buffer that contains an IRQ resource de= scriptor. + The format of the IRQ descriptor can be found in "IRQ Descriptor". T= he macro + produces the three-byte form of the descriptor. The macro is designe= d 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 I= MPLEMENTED + 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, TranslationDens= ity) + + 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 Descript= or + + @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) =3D> DataRefObject Destination =3D Source = =3D> DataRefObject + + Store expression must be created between AmlStart and AmlClose Phase. + + DefStore :=3D StoreOp TermArg SuperName + StoreOp :=3D 0x70 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 :=3D Arg0Op | Arg1Op | Arg2Op | Arg3Op | Arg4Op |Arg5Op | Arg6O= p + Arg0Op :=3D 0x68 + Arg1Op :=3D 0x69 + Arg2Op :=3D 0x6A + Arg3Op :=3D 0x6B + Arg4Op :=3D 0x6C + Arg5Op :=3D 0x6D + Arg6Op :=3D 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 :=3D Local0Op | Local1Op | Local2Op | Local3Op | Local4Op | L= ocal5Op | Local6Op | Local7Op + Local0Op :=3D 0x60 + Local1Op :=3D 0x61 + Local2Op :=3D 0x62 + Local3Op :=3D 0x63 + Local4Op :=3D 0x64 + Local5Op :=3D 0x65 + Local6Op :=3D 0x66 + Local7Op :=3D 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) =3D> Integer + Result =3D Source << ShiftCount =3D> Integer + Result <<=3D ShiftCount =3D> Integer + + Shift expression must be created between AmlStart and AmlClose Phase. + + DefShiftLeft :=3D ShiftLeftOp Operand ShiftCount Target + ShiftLeftOp :=3D 0x79 + ShiftCount :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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) =3D> Integer + Result =3D Source >> ShiftCount =3D> Integer + Result >>=3D ShiftCount =3D> Integer + + Shift expression must be created between AmlStart and AmlClose Phase. + + DefShiftRight :=3D ShiftRightOp Operand ShiftCount Target + ShiftRightOp :=3D 0x7A + ShiftCount :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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) =3D> Integer + + FindSetLeftBit expression must be created between + AmlStart and AmlClose Phase. + + DefFindSetLeftBit :=3D FindSetLeftBitOp Operand Target + FindSetLeftBitOp :=3D 0x81 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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) =3D> Integer + + FindSetRightBit expression must be created between + AmlStart and AmlClose Phase. + + DefFindSetRightBit :=3D FindSetRightBit Operand Target + FindSetRightBit :=3D 0x82 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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) =3D> Integer + Minuend-- =3D> Integer + + Creates object to decrement Minuend. + + DefDecrement :=3D DecrementOp SuperName + DecrementOp :=3D 0x76 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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=3D(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=3D(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/PlatformPspRomArmorWhite= listLib.h b/Platform/AMD/AgesaPkg/Include/Library/PlatformPspRomArmorWhitel= istLib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/* + * Return allocated and filled AMD PSP ROM Armor White list Table + * + * + * @param[in] PlatformSpiWhitelist Pointer to white list table + * + * @return EFI_SUCCESS + * @return EFI_OUT_OF_RESOURCES Buffer to return couldn't be alloc= ated + */ +EFI_STATUS +EFIAPI +GetPspRomArmorWhitelist ( + IN SPI_WHITE_LIST **PlatformSpiWhitelist + ); diff --git a/Platform/AMD/AgesaPkg/Include/Ppi/AmdPspFtpmPpi.h b/Platform/A= MD/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= .
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef PSP_FTPM_PPI_H_ +#define PSP_FTPM_PPI_H_ +#include + +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 buf= fer + @param[in] CommandSize Size of the TPM command buff= er + @param[in,out] ResponseBuffer Point to the TPM response bu= ffer + @param[in,out] ResponseSize Size of the TPM response buf= fer + + @return EFI_SUCCESS Command executed successfull= y + @return EFI_UNSUPPORTED Device unsupported + @return EFI_TIMEOUT Command fail due the time ou= t + @return EFI_DEVICE_ERROR Command fail due the error s= tatus 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 stat= us set + @return EFI_BUFFER_TOO_SMALL Response buffer too small to ho= ld 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 bu= ffer + @param[in,out] ResponseSize Size of the TPM response buf= fer + + @return EFI_SUCCESS Command executed successfull= y + @return EFI_UNSUPPORTED Device unsupported + @return EFI_TIMEOUT Command fail due the time ou= t + @return EFI_DEVICE_ERROR Command fail due the error s= tatus 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 buff= er + @param[in,out] ResponseSize Size of the TPM response buffe= r + + @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(Includ= e send & get response) +**/ +typedef struct _PSP_FTPM_PPI { + FTPM_EXECUTE Execute; ///< Execute TPM= command, include send & get response + FTPM_CHECK_STATUS CheckStatus; ///< Check TPM S= tatus + FTPM_SEND_COMMAND SendCommand; ///< Send TPM co= mmand + FTPM_GET_RESPONSE GetResponse; ///< Get Last TP= M command response + FTPM_GET_TCG_LOGS GetTcgLogs; ///< Get TCG Log= s +} 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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef NBIO_CXL_SERVICES_PROTOCOL_H_ +#define NBIO_CXL_SERVICES_PROTOCOL_H_ + +#include "AMD.h" +#include +#include + +#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_PROTO= COL; + +extern EFI_GUID gAmdNbioCxlServicesProtocolGuid; ///< CXL service= s protocol calling + +#pragma pack (push, 1) +/// Port Information Structure +typedef struct _AMD_CXL_PORT_INFO_STRUCT { + PCI_ADDR EndPointBDF; ///< Bus/Device/Function of Root P= ort 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 inde= x + OUT AMD_CXL_PORT_INFO_STRUCT *PortInformation ///< port info= rmation 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 n= ecessary + 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 n= ecessary + 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 resour= ce 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 val= ues 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, ///< p= tr to protocol + IN UINTN PortIndex ///< p= ort index + ); + +/** + * @brief + * + */ +typedef +VOID +(EFIAPI *AMD_CXL_ENABLE_SCM_PMEM)( + IN AMD_NBIO_CXL_SERVICES_PROTOCOL *This, ///< p= tr to protocol + IN PCI_ADDR CxlPciAddress ///< P= CI 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= .
+ + 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 map= ped bridge interrupt + UINTN EndpointInterruptArray[4]; // Redirection table entries for m= apped INT A/B/C/D +} PCI_ROOT_PORT_OBJECT; + +typedef enum { + IOMMU =3D 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 AmdPciResourcesGetNumb= erOfRootBridges; + AMD_PCI_RESOURCES_GET_ROOT_BRIDGE_INFO AmdPciResourcesGetRoot= BridgeInfo; + AMD_PCI_RESOURCES_GET_NUMBER_OF_ROOTPORTS AmdPciResourcesGetNumb= erOfRootPorts; + AMD_PCI_RESOURCES_GET_ROOT_PORT_INFO AmdPciResourcesGetRoot= PortInfo; + AMD_PCI_RESOURCES_GET_NUMBER_OF_FIXEDRESOURCES AmdPciResourcesGetNumb= erOfFixedResources; + AMD_PCI_RESOURCES_GET_FIXED_RESOURCE_INFO AmdPciResourcesGetFixe= dResourceInfo; +}; + +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= .
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FTPM_PROTOCOL_H_ +#define FTPM_PROTOCOL_H_ + +#include +// +// 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 C= PU->HSP + UINT64 TPM_L0_H2C_MSG_Address; /// Doorbell address H= SP->CPU + + // C2H_HSP_L0(VLT0) + UINT64 VLT0_Address; /// Mailbox address + UINT64 VLT0_C2H_MSG_Address; /// Doorbell address C= PU->HSP + UINT64 VLT0_H2C_MSG_Address; /// Doorbell address H= SP->CPU + + // C2H_HSP_L1(VLT1) + UINT64 VLT1_Address; /// Mailbox address + UINT64 VLT1_C2H_MSG_Address; /// Doorbell address C= PU->HSP + UINT64 VLT1_HSC_MSG_Address; /// Doorbell address H= SP->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 b= uffer + @param[in] CommandSize Size of the TPM command bu= ffer + @param[in, out] ResponseBuffer Point to the TPM response = buffer + @param[in, out] ResponseSize Size of the TPM response b= uffer + + @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 stat= us set + @return EFI_BUFFER_TOO_SMALL Response buffer too small to ho= ld 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 (Un= used 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 itse= lf + @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 stat= us set + @return EFI_BUFFER_TOO_SMALL Response buffer too small to ho= ld 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 b= uffer + + @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 stat= us set + @return EFI_BUFFER_TOO_SMALL Response buffer too small to ho= ld 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 b= uffer +**/ +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 addres= s 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 n= ot 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(Includ= e send & get response) +**/ +typedef struct _PSP_FTPM_PROTOCOL { + FTPM_EXECUTE Execute; ///< Execute TPM comma= nd, 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 comm= and 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/FabricResourceManagerSe= rvicesProtocol.h b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceMan= agerServicesProtocol.h new file mode 100644 index 0000000000..7f57facf88 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Include/Protocol/FabricResourceManagerServicesP= rotocol.h @@ -0,0 +1,14 @@ +/** @file + Fabric MMIO map manager Protocol prototype definition + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_ +#define FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_ +#include + +#endif // FABRIC_RESOURCE_MANAGER_SERVICES_PROTOCOL_H_ diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmBase.h b/Platform/AMD/Amd= CpmPkg/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AMD_CPM_BASE_H_ +#define AMD_CPM_BASE_H_ + +#include +#include +#include +#include +#include + +#endif // AMD_CPM_BASE_H_ diff --git a/Platform/AMD/AmdCpmPkg/Include/AmdCpmCommon.h b/Platform/AMD/A= mdCpmPkg/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AMD_CPM_COMMON_H_ +#define AMD_CPM_COMMON_H_ + +#pragma pack(push) + +#include +#include +#include +#include + +/// The signatures of CPM table + +typedef enum { + CPM_SIGNATURE_DXIO_TOPOLOGY =3D SIGNATURE_32 ('$', 'A', '2= ', '6'), ///< The signature of Socket 0 AMD_CPM_DXIO_TOPOLOGY_TABLE + CPM_SIGNATURE_DXIO_TOPOLOGY_S1 =3D 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; ///< Signatu= re of CPM table + UINT16 TableSize; ///< Table s= ize + UINT8 FormatRevision; ///< Revisio= n of table format + UINT8 ContentRevision; ///< Revisio= n of table content + UINT32 PlatformMask; ///< The mas= k of platform table supports + UINT32 Attribute; ///< Table a= ttribute +} AMD_CPM_TABLE_COMMON_HEADER; + +/// Table pointer +typedef union { + VOID *Pointer; ///< Table p= ointer + UINT64 Raw; ///< Table p= ointer 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; ///< Tab= le header + UINT8 PlatformName[32]; ///< Pla= tform name + UINT8 BiosType; ///< BIO= S type + UINT16 CurrentPlatformId; ///< Cur= rent Platform Id + UINT32 PcieMemIoBaseAddr; ///< Pci= eMemIoBaseAddr + UINT32 AcpiMemIoBaseAddr; ///< Acp= iMemIoBaseAddr + AMD_CPM_POINTER Service; ///< Res= erved for internal use + AMD_CPM_POINTER TableInRomList; ///< Res= erved for internal use + AMD_CPM_POINTER TableInRamList; ///< Res= erved for internal use + AMD_CPM_POINTER TableInHobList; ///< Res= erved for internal use + AMD_CPM_POINTER HobTablePtr; ///< Res= erved for internal use + + UINT8 ExtClkGen; ///< Ext= ernal ClkGen Config. 0x00~0x7F + UINT8 UnusedGppClkOffEn; ///< Con= fig to turn off unused GPP clock + UINT8 LpcUartEn; ///< Lpc= UartEn + UINT64 AltAcpiMemIoBaseAddr; ///< Alt= ernate 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/A= mdCpmPkg/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= .
+ + 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= .
+ + 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 T= able 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 p= osted VBIOS image +} AMD_CPM_DXE_PUBLIC_FUNCTION; + +#endif //AMD_CPM_FUNCTION_H_ diff --git a/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/Am= dCpmTableProtocol.h b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTablePr= otocol/AmdCpmTableProtocol.h new file mode 100644 index 0000000000..4a90aa3d8b --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Library/Protocol/AmdCpmTableProtocol/AmdCpmTab= leProtocol.h @@ -0,0 +1,39 @@ +/** @file + AMD CPM Table Protocol. + + Copyright (C) 2012-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef AMD_CPM_TABLE_PROTOCOL_H_ +#define AMD_CPM_TABLE_PROTOCOL_H_ + +#include + +// +// 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; ///< Pro= tocol Revision + AMD_CPM_MAIN_TABLE *MainTablePtr; ///< Poi= nter to CPM Main Table + AMD_CPM_CHIP_ID ChipId; ///< Id = of SB Chip + AMD_CPM_COMMON_FUNCTION CommonFunction; ///< Pri= vate Common Functions + AMD_CPM_DXE_PUBLIC_FUNCTION DxePublicFunction; ///< Pub= lic 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/AmdPspMboxLib= V2.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + * @brief Bios send these commands to PSP to grant dTPM status and event l= og + * + * @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 buffe= r + * + * @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/AmdPspR= omArmorLib.c new file mode 100644 index 0000000000..0e9baad955 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib/AmdPspRomArmorL= ib.c @@ -0,0 +1,12 @@ +/** @file + + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include diff --git a/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdP= spRomArmorLibNull.c b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLib= Null/AmdPspRomArmorLibNull.c new file mode 100644 index 0000000000..a04bc1f992 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/AmdPspRomArmorLibNull/AmdPspRomAr= morLibNull.c @@ -0,0 +1,79 @@ +/** @file + + Copyright (C) 2019-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include + +/** + * 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 buf= fer 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=3D Allowed on all chip selects, 1=3D CS1, 2=3D 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/Pl= atform/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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include 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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include diff --git a/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/Ba= seFabricTopologyRsLib.c b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTop= ologyRsLib/BaseFabricTopologyRsLib.c new file mode 100644 index 0000000000..cff678d76b --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/BaseFabricTopologyRsLib/BaseFabri= cTopologyRsLib.c @@ -0,0 +1,37 @@ +** @file + Fabric Topology Base Lib implementation + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +UINTN +FabricTopologyGetNumberOfProcessorsPresent ( + VOID + ) +{ + return 0; +} + +UINTN +FabricTopologyGetNumberOfRootBridgesOnSocket ( + IN UINTN Socket + ) +{ + return 0; +} + +RETURN_STATUS +EFIAPI +BaseFabricTopologyLibConstructor ( + VOID + ) +{ + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/BaseTscTime= rLib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/DxeTscTimer= Lib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** The constructor function determines the actual TSC frequency. + + First, Get TSC frequency from system configuration table with TSC freque= ncy 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 imag= e. + @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/PeiTscTimer= Lib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include diff --git a/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLib= Share.c b/Platform/AMD/AgesaModulePkg/Library/CcxTscTimerLib/TscTimerLibSha= re.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 th= e processor. + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + 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 cou= nter. + + 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 cou= nter + values. + + If StartValue is not NULL, then the value that the performance counter s= tarts + with, 0x0, is returned in StartValue. If EndValue is not NULL, then the = value + that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned i= n + EndValue. + + The 64-bit frequency of the performance counter, in Hz, is always return= ed. + + @param[out] StartValue Pointer to where the performance counter's sta= rting value is saved, or NULL. + @param[out] EndValue Pointer to where the performance counter's end= ing 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 cou= nter. + + @return The elapsed time in nanoseconds. + +**/ +UINT64 +EFIAPI +GetTimeInNanoSecond ( + IN UINT64 Ticks + ) +{ + return 0; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/Pci= HostBridgeLib.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLi= b/PciHostBridgeLib.c new file mode 100644 index 0000000000..44e23df62f --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmdPciHostBridgeLib/PciHostBri= dgeLib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + 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 orde= r. + DevicePath UID updated to continuous and ascending numbers start= ing + 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 PciHostBridgeGetRootB= ridges(). + + @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 reso= urces + 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/AmlArg= Objects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlArgO= bjects.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLARGOBJECTS_FILECODE + +/* + Fill the DataBuffer with correct Arg Opcode based on provided argument n= umber + 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 intege= r + @param[out] ReturnDataSize - Size of ReturnData + + @return EFI_SUCCESS - Successful completion + @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffe= r + @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 =3D AllocateZeroPool (sizeof (UINT8)); + if (Data =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Failed to create Data Buffer.\n", + __func__ + )); + return EFI_OUT_OF_RESOURCES; + } + + DataSize =3D 1; + switch (ArgN) { + case 0: + Data[0] =3D AML_ARG0; + break; + case 1: + Data[0] =3D AML_ARG1; + break; + case 2: + Data[0] =3D AML_ARG2; + break; + case 3: + Data[0] =3D AML_ARG3; + break; + case 4: + Data[0] =3D AML_ARG4; + break; + case 5: + Data[0] =3D AML_ARG5; + break; + case 6: + Data[0] =3D AML_ARG6; + break; + default: + FreePool (Data); + return EFI_INVALID_PARAMETER; + } + + *ReturnData =3D (VOID *)Data; + *ReturnDataSize =3D DataSize; + + return EFI_SUCCESS; +} + +/** + Creates an ArgN Opcode object + + Arg Objects Encoding + ArgObj :=3D Arg0Op | Arg1Op | Arg2Op | Arg3Op | Arg4Op | Arg5Op | Arg6= Op + Arg0Op :=3D 0x68 + Arg1Op :=3D 0x69 + Arg2Op :=3D 0x6A + Arg3Op :=3D 0x6B + Arg4Op :=3D 0x6C + Arg5Op :=3D 0x6D + Arg6Op :=3D 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Start %a object\n", + __func__, + "ARGN_OPCODE" + )); + goto Done; + } + + Status =3D 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 =3D TRUE; + + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAss= istFunctions.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/Am= lAssistFunctions.c new file mode 100644 index 0000000000..371537c9aa --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlAssistFunc= tions.c @@ -0,0 +1,151 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 =3D GetNextNode (ListHead, ListHead); + while (Node !=3D ListHead) { + Object =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + // Get next node before freeing current Object + Node =3D 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 =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ListHead cannot be NULL\n", __func__)= ); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + *TableSize =3D 0; + Node =3D 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 =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + if (!Object->Completed) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Final node not completed: Likely mi= ssed an 'AmlCLose' call\n", __func__)); + return EFI_DEVICE_ERROR; + } + + *Table =3D Object->Data; + *TableSize =3D 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 =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ListHead =3D NULL\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + *ListHead =3D AllocatePool (sizeof (LIST_ENTRY)); + if (*ListHead =3D=3D 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 =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NULL ListHead passed in\n", __func__)= ); + return EFI_INVALID_PARAMETER; + } + + AmlFreeObjectList (*ListHead); + FreePool (*ListHead); + *ListHead =3D NULL; + + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDat= aObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDat= aObjects.c new file mode 100644 index 0000000000..b7d4f4c9d7 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlDataObject= s.c @@ -0,0 +1,640 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLDATAOBJECTS_FILECODE + +/* + Creates an allocated buffer with sized data and no Op Code + + ByteData :=3D 0x00 - 0xFF + WordData :=3D ByteData[0:7] ByteData[8:15] // 0x0000-0xFFFF + DWordData :=3D WordData[0:15] WordData[16:31] // 0x00000000-0xFFFFFFFF + QWordData :=3D DWordData[0:31] DWordData[32:63] // 0x0000000000000000- 0= xFFFFFFFFFFFFFFFF + + 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 intege= r + @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 !=3D sizeof (UINT8)) && + (IntegerSize !=3D sizeof (UINT16)) && + (IntegerSize !=3D sizeof (UINT32)) && + (IntegerSize !=3D sizeof (UINT64))) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Incorrect integer size=3D%d requested= .\n", __func__, IntegerSize)); + return EFI_INVALID_PARAMETER; + } + + if ((IntegerSize < sizeof (UINT64)) && (Integer >=3D LShiftU64 (1, Integ= erSize * 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 =3D AllocateZeroPool (sizeof (UINT64)); + if (Data =3D=3D 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 =3D (UINT8)Integer; + break; + case sizeof (UINT16): + *(UINT16 *)Data =3D (UINT16)Integer; + break; + case sizeof (UINT32): + *(UINT32 *)Data =3D (UINT32)Integer; + break; + case sizeof (UINT64): + *(UINT64 *)Data =3D (UINT64)Integer; + break; + } + + *ReturnData =3D (VOID *)Data; + return EFI_SUCCESS; +} + +/* + Calculates the optimized integer value used by AmlOPDataInteger and othe= rs + + Forces max integer size UINT64 + + @param[in] Integer - Integer value to encode + @param[out] ReturnData - Allocated DataBuffer with encoded intege= r + @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 =3D NULL; + UINTN DataSize; + + // Max Data Size is 64 bit. Plus one Opcode byte + IntegerData =3D AllocateZeroPool (sizeof (UINT64) + 1); + if (IntegerData =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Integer Space Alloc Failed\n", __func= __)); + return EFI_OUT_OF_RESOURCES; + } + + if (Integer =3D=3D 0) { + // ZeroOp + IntegerDataSize =3D 1; + IntegerData[0] =3D AML_ZERO_OP; + } else if (Integer =3D=3D 1) { + // OneOp + IntegerDataSize =3D 1; + IntegerData[0] =3D AML_ONE_OP; + } else if (Integer =3D=3D (UINT64) ~0x0) { + // OnesOp + IntegerDataSize =3D 1; + IntegerData[0] =3D AML_ONES_OP; + } else { + if (Integer >=3D 0x100000000) { + // QWordConst + IntegerDataSize =3D sizeof (UINT64) + 1; + IntegerData[0] =3D AML_QWORD_PREFIX; + } else if (Integer >=3D 0x10000) { + // DWordConst + IntegerDataSize =3D sizeof (UINT32) + 1; + IntegerData[0] =3D AML_DWORD_PREFIX; + } else if (Integer >=3D 0x100) { + // WordConst + IntegerDataSize =3D sizeof (UINT16) + 1; + IntegerData[0] =3D AML_WORD_PREFIX; + } else { + // ByteConst + IntegerDataSize =3D sizeof (UINT8) + 1; + IntegerData[0] =3D AML_BYTE_PREFIX; + } + + DataSize =3D IntegerDataSize - 1; + InternalAmlSizedDataBuffer (Integer, DataSize, (VOID **)&Data); + if (Data =3D=3D 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 =3D (VOID *)IntegerData; + *ReturnDataSize =3D IntegerDataSize; + + return EFI_SUCCESS; +} + +/** + Creates an optimized integer object + + Forces max integer size UINT64 + + ComputationalData :=3D ByteConst | WordConst | DWordConst | QWordConst |= String | + ConstObj | RevisionOp | DefBuffer + DataObject :=3D ComputationalData | DefPackage | DefVarPackage + DataRefObject :=3D DataObject | ObjectReference | DDBHandle + ByteConst :=3D BytePrefix ByteData + BytePrefix :=3D 0x0A + WordConst :=3D WordPrefix WordData + WordPrefix :=3D 0x0B + DWordConst :=3D DWordPrefix DWordData + DWordPrefix :=3D 0x0C + QWordConst :=3D QWordPrefix QWordData + QWordPrefix :=3D 0x0E + ConstObj :=3D ZeroOp | OneOp | OnesOp + ByteData :=3D 0x00 - 0xFF + WordData :=3D ByteData[0:7] ByteData[8:15] + // 0x0000-0xFFFF + DWordData :=3D WordData[0:15] WordData[16:31] + // 0x00000000-0xFFFFFFFF + QWordData :=3D DWordData[0:31] DWordData[32:63] + // 0x0000000000000000-0xFFFFFFFFFFFFFFFF + ZeroOp :=3D 0x00 + OneOp :=3D 0x01 + OnesOp :=3D 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "DATA_I= NTEGER")); + goto Done; + } + + Status =3D 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 =3D TRUE; + + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/** + Creates an Sized Data integer object for use in Buffer objects. Does no= t + include opcode. + + ByteData :=3D 0x00 - 0xFF + WordData :=3D ByteData[0:7] ByteData[8:15] + // 0x0000-0xFFFF + DWordData :=3D WordData[0:15] WordData[16:31] + // 0x00000000-0xFFFFFFFF + QWordData :=3D 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "SIZED_= DATA_INTEGER")); + goto Done; + } + + Object->DataSize =3D IntegerSize; + Status =3D 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 =3D TRUE; + + Status =3D 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 :=3D 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 :=3D 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 :=3D 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 :=3D 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 :=3D String + + String :=3D StringPrefix AsciiCharList NullChar + StringPrefix :=3D 0x0D + AsciiCharList :=3D Nothing | + AsciiChar :=3D 0x01 - 0x7F + NullChar :=3D 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 =3D=3D NULL) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + // Validate all characters + DataSize =3D AsciiStrLen (String); + for (Index =3D 0; Index < DataSize; Index++) { + if (String[Index] < 0x01) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Invalid character String[%d] : %a\n", + __func__, + Index, + String + )); + return Status; + } + } + + Status =3D 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 +=3D 2; + Data =3D AllocatePool (DataSize); + if (Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: String Space Allocation %a\n", + __func__, + String + )); + goto Done; + } + + Data[0] =3D AML_STRING_PREFIX; + CopyMem (&Data[1], String, DataSize - 1); + + // DataString Complete, Put into Object + Object->Data =3D Data; + Object->DataSize =3D DataSize; + Object->Completed =3D TRUE; + + Status =3D 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 =3D=3D NULL) || (BufferSize =3D=3D 0) || (ListHead =3D=3D NU= LL)) { + return EFI_INVALID_PARAMETER; + } + + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Data Buffer object\n", __func__= )); + goto Done; + } + + Object->Data =3D AllocatePool (BufferSize); + Object->DataSize =3D BufferSize; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: Data Buffer allocate failed\n", __fun= c__)); + goto Done; + } + + CopyMem (Object->Data, Buffer, BufferSize); + Object->Completed =3D TRUE; + + Status =3D 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) =3D> 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 dec= laring + 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 =3D 'A' 0b11010 = =3D '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 =3D 0; + + if ((String =3D=3D NULL) || (ListHead =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, inputs cannot =3D= =3D NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if (AsciiStrLen (String) !=3D 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 =3D 0; i <=3D 0x6; i++) { + // + // If first 3 characters are not uppercase alpha or last 4 characters = are not hexadecimal + // + if (((i <=3D 0x2) && (!IS_ASCII_UPPER_ALPHA (String[i]))) || + ((i >=3D 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 =3D ((((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 endi= an-ness. + // + EncodedEisaId =3D Swap4Bytes (EncodedEisaId); + + // + // Insert DWordPrefix into list. + // Note: EncodedEisaId will always be 32-bits, resulting in DWordConst= . + // + Status =3D 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/AmlExp= ressionOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/= AmlExpressionOpcodes.c new file mode 100644 index 0000000000..e8ea9d8e84 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlExpression= Opcodes.c @@ -0,0 +1,1294 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLEXPRESSIONOPCODES_FILECOD= E + +// -----------------------------------------------------------------------= ----- +// Expression Opcodes Encoding +// -----------------------------------------------------------------------= ----- +// ExpressionOpcode :=3D DefAcquire | DefAdd | DefAnd | DefBuffer | DefC= oncat | +// 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 | DefShiftRigh= t | +// DefSizeOf | DefStore | DefSubtract | DefTimer | DefToBCD | DefToBuf= fer | +// DefToDecimalString | DefToHexString | DefToInteger | DefToString | +// DefWait | DefXOr | MethodInvocation +// -----------------------------------------------------------------------= ----- + +/** + Creates a Buffer (BufferSize) {Initializer} =3D> Buffer Object + + Initializers must be created between AmlStart and AmlClose Phase + + DefBuffer :=3D BufferOp PkgLength BufferSize ByteList + BufferOp :=3D 0x11 + BufferSize :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] BufferSize - Requested BufferSize, Encoded value will b= e + MAX (BufferSize OR Child->DataSize) + @param[in,out] ListHead - Linked list has completed Buffer Object af= ter + 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + // iASL compiler 20200110 only keeps lower 32 bits of size. We'll error= if + // someone requests something >=3D 4GB size. Have a message with this t= o be + // very specific + if (BufferSize >=3D SIZE_4GB) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: BufferSize=3D0x%X >=3D 4GB\n", __func= __, BufferSize)); + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start the Buffer Object + Status =3D InternalAppendNewAmlObject (&Object, "BUFFER", ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFER object\n", __func__)= ); + goto Done; + } + + // Start required PkgLength + Status =3D AmlPkgLength (AmlStart, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer PkgLength object\n", __fun= c__)); + goto Done; + } + + // Start BufferSize + Status =3D InternalAppendNewAmlObject (&Object, "BUFFERSIZE", ListHe= ad); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BUFFERSIZE object\n", __fun= c__)); + goto Done; + } + + // ByteList is too complicated and must be added outside + break; + + case AmlClose: + // ByteList items should be closed already + + // Close BufferSize + Status =3D 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 =3D 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 requeste= d + // BufferSize or size required for ChildObject->Data. + InternalBufferSize =3D MAX (BufferSize, ChildObject->DataSize); + // iASL compiler 20200110 only keeps lower 32 bits of size. We'll e= rror if + // someone requests something >=3D 4GB size. + if (InternalBufferSize >=3D SIZE_4GB) { + Status =3D EFI_BAD_BUFFER_SIZE; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: BufferSize 0x%X >=3D 4GB\n", + __func__, + InternalBufferSize + )); + goto Done; + } + + Status =3D 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 !=3D 0) && (ChildObject->Data !=3D NULL))= { + // Make room for ChildObject->Data + Object->Data =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + + ChildObject->DataSize, + Object->Data + ); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: to reallocate BufferSize\n", __= func__)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + CopyMem ( + &Object->Data[Object->DataSize], + ChildObject->Data, + ChildObject->DataSize + ); + Object->DataSize +=3D ChildObject->DataSize; + } + + // Free Child Object since it has been consumed + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + // Close required PkgLength before finishing Object + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, "BUFFER", L= istHead); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + + // Buffer must have at least PkgLength BufferSize + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: No Buffer Data\n", __func__)); + goto Done; + } + + // BufferOp is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer allocate failed\n", __func= __)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Object->Data[0] =3D AML_BUFFER_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + // Free Child Object since it has been consumed + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&ChildObject, ListHead); + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/** + Creates a LEqual (Source1, Source2) =3D> Boolean + + Source1 and Source2 operands must be created between AmlStart and AmlClo= se Phase + + DefLEqual :=3D LequalOp Operand Operand + LequalOp :=3D 0x93 + Operand :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed LEqual Object af= ter + 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start the LEqual Object + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier ( + &Object, + "LEQUAL", + ListHead + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Fail locate LEqual object\n", __f= unc__)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + + // LEqual must have at least two operands + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: No LEqual Args\n", __func__)); + goto Done; + } + + // LequalOp is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Buffer allocate failed\n", __func= __)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Object->Data[0] =3D AML_LEQUAL_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + // Free Child Object since it has been consumed + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&ChildObject, ListHead); + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/* + Creates (NumElements) section of a Package: {PackageList} =3D> Package + + Initializers must be created between AmlStart and AmlClose Phase + Internal only function no public reference or documentation needed. + + NumElements :=3D ByteData + VarNumElements :=3D TermArg =3D> Integer + PackageElementList :=3D Nothing | + PackageElement :=3D DataRefObject | NameString + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] NumElements - Number of elements in the package. If 0, s= ize + is calculated from the PackageList. + @param[in,out] ListHead - Linked list has completed Package Object a= fter + 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + ChildCount =3D 0; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start Number of Elements Object + Status =3D InternalAppendNewAmlObject (&Object, "NUM_ELEMENTS", List= Head); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NUM_ELEMENTS object\n", __f= unc__)); + 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 =3D 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 =3D 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 >=3D Child Coun= t + if (*NumElements =3D=3D 0) { + *NumElements =3D ChildCount; + } else if (*NumElements < ChildCount) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NumElements < ChildCount.\n", __f= unc__)); + Status =3D EFI_INVALID_PARAMETER; + goto Done; + } + + if (*NumElements <=3D MAX_UINT8) { + Object->DataSize =3D 1; + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NumElements allocate failed\n",= __func__)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Object->Data[0] =3D (UINT8)*NumElements; + } else { + Status =3D 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 !=3D 0) && (ChildObject->Data !=3D NULL))= { + // Make room for ChildObject->Data + Object->Data =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + + ChildObject->DataSize, + Object->Data + ); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: to reallocate NumElements\n", _= _func__)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + CopyMem ( + &Object->Data[Object->DataSize], + ChildObject->Data, + ChildObject->DataSize + ); + Object->DataSize +=3D ChildObject->DataSize; + } + + // Free Child Object since it has been consumed + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&ChildObject, ListHead); + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/** + Creates a Package (NumElements) {PackageList} =3D> Package + + Initializers must be created between AmlStart and AmlClose Phase + + DefPackage :=3D PackageOp PkgLength NumElements PackageElementLi= st + PackageOp :=3D 0x12 + DefVarPackage :=3D VarPackageOp PkgLength VarNumElements PackageEle= mentList + VarPackageOp :=3D 0x13 + NumElements :=3D ByteData + VarNumElements :=3D TermArg =3D> Integer + PackageElementList :=3D Nothing | + PackageElement :=3D DataRefObject | NameString + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] NumElements - Number of elements in the package. If 0, s= ize + is calculated from the PackageList. + @param[in,out] ListHead - Linked list has completed Package Object a= fter + 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start the Package Object + Status =3D InternalAppendNewAmlObject (&Object, "PACKAGE", ListHead)= ; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start PACKAGE object\n", __func__= )); + goto Done; + } + + // Start required PkgLength + Status =3D AmlPkgLength (AmlStart, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Package PkgLength object\n", __fu= nc__)); + goto Done; + } + + // Start Number of Elements Object + Status =3D InternalAmlNumElements (AmlStart, &NumElements, ListHead)= ; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start NUM_ELEMENTS object\n", __f= unc__)); + 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 =3D InternalAmlNumElements (AmlClose, &NumElements, ListHead)= ; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Close NUM_ELEMENTS object\n", __f= unc__)); + goto Done; + } + + if (NumElements <=3D MAX_UINT8) { + OpCode =3D AML_PACKAGE_OP; + } else { + OpCode =3D AML_VAR_PACKAGE_OP; + } + + // Close required PkgLength before finishing Object + Status =3D 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 =3D 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + // Package must have at least PkgLength NumElements + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: No Package Data\n", __func__)); + goto Done; + } + + // PackageOp and VarPackageOp are both one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Package allocate failed\n", __fun= c__)); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Object->Data[0] =3D OpCode; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + // Free Child Object since it has been consumed + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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) =3D> DataRefObject Destination =3D Source = =3D> DataRefObject + + Store expression must be created between AmlStart and AmlClose Phase. + + DefStore :=3D StoreOp TermArg SuperName + StoreOp :=3D 0x70 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + // Start Store expression + Status =3D 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(AmlSta= rt,..) and + // AmlStore(AmlClose,...) - when creating the Store expression. + break; + + case AmlClose: + // TermArg and SuperName must have been created and closed by now. + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "STORE", Li= stHead); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __= func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 1); + if (Object->Data =3D=3D NULL) { + Status =3D 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 =3D ChildObject->DataSize + 1; + + // Fill out Store object + Object->Data[0] =3D AML_STORE_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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) =3D> Integer + Result =3D Source << ShiftCount =3D> Integer + Result <<=3D ShiftCount =3D> Integer + + ShiftRight (Source, ShiftCount, Reult) =3D> Integer + Result =3D Source >> ShiftCount =3D> Integer + Result >>=3D ShiftCount =3D> Integer + + Shift expression must be created between AmlStart and AmlClose Phase. + + DefShiftLeft :=3D ShiftOp Operand ShiftCount Target + ShiftOp :=3D 0x79 or 0x7A + ShiftCount :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] ShiftOp - Specifies whether to shift left or shi= ft + right. + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start Store expression + Status =3D 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 obj= ect. They must be + // defined as part of a multi-tier call - in between AmlShift(AmlSta= rt,..) and + // AmlShift(AmlClose,...) - when creating the Shift expression. + + break; + + case AmlClose: + // Operand, ShiftCount, and Target must have been created and closed= by now. + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "SHIFT", Li= stHead); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __= func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 1); + if (Object->Data =3D=3D NULL) { + Status =3D 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 =3D ChildObject->DataSize + 1; + + // Fill out Store object + Object->Data[0] =3D ShiftOp; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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) =3D> Integer + Result =3D Source << ShiftCount =3D> Integer + Result <<=3D ShiftCount =3D> Integer + + Shift expression must be created between AmlStart and AmlClose Phase. + + DefShiftLeft :=3D ShiftLeftOp Operand ShiftCount Target + ShiftLeftOp :=3D 0x79 + ShiftCount :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D InternalAmlShift (Phase, AML_SHIFT_LEFT_OP, ListHead); + return Status; +} + +/** + Creates a Shift Right expression + + Syntax: + ShiftRight (Source, ShiftCount, Reult) =3D> Integer + Result =3D Source >> ShiftCount =3D> Integer + Result >>=3D ShiftCount =3D> Integer + + Shift expression must be created between AmlStart and AmlClose Phase. + + DefShiftRight :=3D ShiftRightOp Operand ShiftCount Target + ShiftRightOp :=3D 0x7A + ShiftCount :=3D TermArg =3D> Integer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D 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) =3D> Integer + + FindSetRightBit (Source, Result) =3D> Integer + + Bit Fields must be created between AmlStart and AmlClose Phase. + + DefFindSetLeftBit :=3D FindSetLeftBitOp Operand Target + FindSetLeftBitOp :=3D 0x81 + + DefFindSetRightBit :=3D FindSetRightBitOp Operand Target + FindSetRightBitOp :=3D 0x82 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] FindSetOp - Specifies whether to search left or se= arch + right. + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start Store expression + Status =3D 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 mus= t be + // defined as part of a multi-tier call - in between AmlFindSet(AmlS= tart,..) and + // AmlFindSet(AmlClose,...) - when creating the FindSetBit expressio= n. + + break; + + case AmlClose: + // Source and Result must have been created and closed by now. + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "FINDSET", = ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: locating FIND_SET Object\n", __fu= nc__)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __= func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 1); + if (Object->Data =3D=3D NULL) { + Status =3D 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 =3D ChildObject->DataSize + 1; + + // Fill out Store object + Object->Data[0] =3D FindSetOp; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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) =3D> Integer + + FindSetLeftBit expression must be created between + AmlStart and AmlClose Phase. + + DefFindSetLeftBit :=3D FindSetLeftBitOp Operand Target + FindSetLeftBitOp :=3D 0x81 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D InternalAmlFindSetBit (Phase, AML_FIND_SET_LEFT_BIT_OP, ListH= ead); + return Status; +} + +/** + Creates a FindSetRightBit AML Object + + Syntax: + FindSetRightBit (Source, Result) =3D> Integer + + FindSetRightBit expression must be created between + AmlStart and AmlClose Phase. + + DefFindSetRightBit :=3D FindSetRightBit Operand Target + FindSetRightBit :=3D 0x82 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D InternalAmlFindSetBit (Phase, AML_FIND_SET_RIGHT_BIT_OP, List= Head); + return Status; +} + +/** + Creates a Decrement expression + + Syntax: + Decrement (Minuend) =3D> Integer + Minuend-- =3D> Integer + + Creates object to decrement Minuend. + + DefDecrement :=3D DecrementOp SuperName + DecrementOp :=3D 0x76 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Objec= t 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + if ((Phase >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + switch (Phase) { + case AmlStart: + // Start decrement expression + Status =3D InternalAppendNewAmlObject (&Object, "DECREMENT", ListHea= d); + 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(Am= lStart,..) and + // AmlDecrement(AmlClose,...) - when creating the Decrement expressi= on. + + break; + + case AmlClose: + // Minuend must created and closed by now. + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "DECREMENT"= , ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: locating DECREMENT Object\n", __f= unc__)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Store() has no child data.\n", __= func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 1); + if (Object->Data =3D=3D NULL) { + Status =3D 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 =3D ChildObject->DataSize + 1; + + // Fill out Decrement object + Object->Data[0] =3D AML_DECREMENT_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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/AmlLoc= alObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLo= calObjects.c new file mode 100644 index 0000000000..21deb200e3 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlLocalObjec= ts.c @@ -0,0 +1,158 @@ +/** @file + + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 intege= r + @param[out] ReturnDataSize - Size of ReturnData + + @return EFI_SUCCESS - Successful completion + @return EFI_OUT_OF_RESOURCES - Failed to allocate ReturnDataBuffe= r + @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 =3D AllocateZeroPool (sizeof (UINT8)); + if (Data =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Failed to create Data Buffer.\n", + __func__ + )); + return EFI_OUT_OF_RESOURCES; + } + + DataSize =3D 1; + switch (LocalN) { + case 0: + Data[0] =3D AML_LOCAL0; + break; + case 1: + Data[0] =3D AML_LOCAL1; + break; + case 2: + Data[0] =3D AML_LOCAL2; + break; + case 3: + Data[0] =3D AML_LOCAL3; + break; + case 4: + Data[0] =3D AML_LOCAL4; + break; + case 5: + Data[0] =3D AML_LOCAL5; + break; + case 6: + Data[0] =3D AML_LOCAL6; + break; + case 7: + Data[0] =3D AML_LOCAL7; + break; + default: + FreePool (Data); + return EFI_INVALID_PARAMETER; + } + + *ReturnData =3D (VOID *)Data; + *ReturnDataSize =3D DataSize; + + return EFI_SUCCESS; +} + +/** + Creates an LocalN Opcode object + + Local Objects Encoding + LocalObj :=3D Local0Op | Local1Op | Local2Op | Local3Op | Local4Op | L= ocal5Op | Local6Op | Local7Op + Local0Op :=3D 0x60 + Local1Op :=3D 0x61 + Local2Op :=3D 0x62 + Local3Op :=3D 0x63 + Local4Op :=3D 0x64 + Local5Op :=3D 0x65 + Local6Op :=3D 0x66 + Local7Op :=3D 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Start %a object\n", + __func__, + "LOCALN_OPCODE" + )); + goto Done; + } + + Status =3D 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 =3D TRUE; + + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNam= eString.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlName= String.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 =3D=3D 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 =3D=3D AML_PARENT_PREFIX_CHAR) { + return TRUE; + } + + return FALSE; +} + +/* + Is character a LeadNameChar =3D '_', '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 =3D=3D AML_NAME_CHAR__) || + ((TestChar >=3D AML_NAME_CHAR_A) && + (TestChar <=3D AML_NAME_CHAR_Z)) + ) + { + return TRUE; + } + + return FALSE; +} + +/* + Is character a DigitChar =3D '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 >=3D AML_DIGIT_CHAR_0) && + (TestChar <=3D AML_DIGIT_CHAR_9) + ) + { + return TRUE; + } + + return FALSE; +} + +/* + Is character a NameChar =3D 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 =3D=3D '.') { + return TRUE; + } + + return FALSE; +} + +/** + Creates a NameSeg AML object and inserts it into the List + + NameSeg :=3D + + 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + NameLen =3D AsciiStrLen (Name); + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + NameSeg =3D NULL; + // parameter validation + if ((NameLen =3D=3D 0) || (NameLen > 4)) { + return EFI_INVALID_PARAMETER; + } + + if (!InternalIsLeadNameChar (Name[0])) { + return EFI_INVALID_PARAMETER; + } + + for (UINT8 i =3D 1; NameLen > 1 && i < NameLen; i++) { + if (!InternalIsNameChar (Name[i])) { + return EFI_INVALID_PARAMETER; + } + } + + NameSeg =3D AllocateZeroPool (4); + if (NameSeg =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + CopyMem (NameSeg, Name, NameLen); + + if (NameLen < 4) { + SetMem (&NameSeg[NameLen], 4 - NameLen, '_'); + } + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (Object !=3D NULL) { + if (!EFI_ERROR (Status)) { + Object->Data =3D NameSeg; + Object->DataSize =3D 4; + Object->Completed =3D TRUE; + } else { + InternalFreeAmlObject (&Object, ListHead); + FreePool (NameSeg); + } + } + + return Status; +} + +/** + Creates a Namestring AML Object and inserts it into the linked list + + LeadNameChar :=3D 'A'-'Z' | '_' + DigitChar :=3D '0'-'9' + NameChar :=3D DigitChar | LeadNameChar + RootChar :=3D '\' + ParentPrefixChar :=3D '^' + + 'A'-'Z' :=3D 0x41 - 0x5A + '_' :=3D 0x5F + '0'-'9' :=3D 0x30 - 0x39 + '\' :=3D 0x5C + '^' :=3D 0x5E + + NameSeg :=3D + // Notice that NameSegs shorter than 4 characters ar= e filled with + // trailing underscores ('_'s). + NameString :=3D | + PrefixPath :=3D Nothing | <'^' PrefixPath> + NamePath :=3D NameSeg | DualNamePath | MultiNamePath | NullName + + DualNamePath :=3D DualNamePrefix NameSeg NameSeg + DualNamePrefix :=3D 0x2E + MultiNamePath :=3D MultiNamePrefix SegCount NameSeg(SegCount) + MultiNamePrefix :=3D 0x2F + + SegCount :=3D 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 enco= ding + length will be 1 + 1 + 35*4 =3D 142. Notice that: DualNamePrefix Nam= eSeg + NameSeg has a smaller encoding than the encoding of: MultiNamePrefix= (2) + NameSeg NameSeg + + SimpleName :=3D NameString | ArgObj | LocalObj + SuperName :=3D SimpleName | DebugObj | Type6Opcode + NullName :=3D 0x00 + Target :=3D 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 =3D=3D NULL) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + NameString =3D NULL; + FoundRootChar =3D FALSE; + FoundParentPrefixChar =3D FALSE; + NameStringBufferSize =3D 0; + FoundParenthesisOpenChar =3D FALSE; + FoundParenthesisCloseChar =3D FALSE; + + Status =3D 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 =3D 4 * MAX_NAME_SEG_COUNT; + NameString =3D AllocateZeroPool (NameStringBufferSize); + // Create arbitrarily large RootChar\ParentPrefixChar buffer + NameStringPrefix =3D AllocateZeroPool (NameStringBufferSize); + + // Calculate length of required space + StringLength =3D AsciiStrLen (String); + NameStringSize =3D 0; + NameStringPrefixSize =3D 0; + NameSegIndex =3D 0; + NameSegCount =3D 0; + for (StringIndex =3D 0; StringIndex < StringLength; StringIndex++) { + if (NameStringPrefixSize >=3D NameStringBufferSize) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Exceeded ParentPrefixChar support at offset=3D%d of St= ring=3D%a\n", + __func__, + StringIndex, + String + )); + goto Done; + } + + if (InternalIsRootChar (String[StringIndex])) { + if (NameSegCount !=3D 0) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: RootChar at offset=3D%d of String= =3D%a\n", __func__, StringIndex, String)); + goto Done; + } + + if (FoundRootChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=3D%a contains more tha= n 1 RootChar.\n", __func__, String)); + goto Done; + } + + if (FoundParentPrefixChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=3D%a contains RootChar= and ParentPrefixChar.\n", __func__, String)); + goto Done; + } + + // RootChar; increment NameStringSize + NameStringPrefix[NameStringPrefixSize] =3D String[StringIndex]; + NameStringPrefixSize++; + FoundRootChar =3D TRUE; + } else if (InternalIsParentPrefixChar (String[StringIndex])) { + if (NameSegCount !=3D 0) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: ParentPrefixChar at offset=3D%d o= f String=3D%a\n", __func__, StringIndex, String)); + goto Done; + } + + if (FoundRootChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString=3D%a contains RootChar= and ParentPrefixChar.\n", __func__, String)); + goto Done; + } + + // ParentPrefixChar; increment NameStringSize + NameStringPrefix[NameStringPrefixSize] =3D String[StringIndex]; + NameStringPrefixSize++; + FoundParentPrefixChar =3D TRUE; + } else if (!InternalIsNameChar (String[StringIndex])) { + if (InternalIsNameSegSeparator (String[StringIndex])) { + if (NameSegIndex =3D=3D 0) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Invalid NameSeg separator at offset=3D%d of String= =3D%a\n", + __func__, + StringIndex, + String + )); + goto Done; + } else { + NameSegIndex =3D 0; + } + } else if (String[StringIndex] =3D=3D '(') { + if (FoundParenthesisOpenChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Invalid Parenthesis at offset=3D%d of String=3D%a\= n", + __func__, + StringIndex, + String + )); + goto Done; + } + + FoundParenthesisOpenChar =3D TRUE; + } else if (String[StringIndex] =3D=3D ')') { + if (FoundParenthesisCloseChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Invalid Parenthesis at offset=3D%d of String=3D%a\= n", + __func__, + StringIndex, + String + )); + goto Done; + } else if (!FoundParenthesisOpenChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: No Open Parenthesis before offset=3D%d of String= =3D%a\n", + __func__, + StringIndex, + String + )); + goto Done; + } + + FoundParenthesisCloseChar =3D TRUE; + } else { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Unsupported character at offset=3D%d of String=3D%a\= n", + __func__, + StringIndex, + String + )); + goto Done; + } + } else { + // Must be NameChar + if (FoundParenthesisOpenChar || FoundParenthesisCloseChar) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: NameChar after Parenthesis at offset=3D%d of String= =3D%a\n", + __func__, + StringIndex, + String + )); + goto Done; + } else if ((NameSegIndex =3D=3D 0) && InternalIsDigitChar (String[St= ringIndex])) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: must be LeadNameChar at offset=3D%d of String=3D%a'\= n", + __func__, + StringIndex, + String + )); + goto Done; + } + + if (NameSegIndex >=3D 4) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: NameSeg > 4 characters at offset=3D%d of String=3D%a= '\n", + __func__, + StringIndex, + String + )); + goto Done; + } else { + if (NameSegIndex =3D=3D 0) { + NameSegCount++; + if (NameSegCount > MAX_NAME_SEG_COUNT) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: Max NameSegCount=3D%d reached at offset=3D%d of = String=3D%a'\n", + __func__, + MAX_NAME_SEG_COUNT, + StringIndex, + String + )); + goto Done; + } + } + + NameString[NameStringSize] =3D String[StringIndex]; + NameStringSize++; + NameSegIndex++; + if ((StringIndex + 1 >=3D StringLength) || + !InternalIsNameChar (String[StringIndex + 1])) + { + // Extend in progress NameSeg with '_'s + if (NameSegIndex < 4) { + SetMem (&NameString[NameStringSize], 4 - NameSegIndex, '_'); + NameStringSize +=3D 4 - NameSegIndex; + } + } + } + } + } + + // Create AML Record with NameString contents from above + // Copy in RootChar or ParentPrefixChar(s) + if (NameStringPrefixSize !=3D 0) { + Object->Data =3D ReallocatePool ( + Object->DataSize, + NameStringPrefixSize, + Object->Data + ); + CopyMem ( + &Object->Data[Object->DataSize], + NameStringPrefix, + NameStringPrefixSize + ); + Object->DataSize +=3D NameStringPrefixSize; + FreePool (NameStringPrefix); + } + + // Set up for Dual/MultiName Prefix + if (NameSegCount > MAX_NAME_SEG_COUNT) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: Exceeded MaxNameSegCount in NameStrin= g=3D%a\n", __func__, String)); + goto Done; + } else if (NameSegCount =3D=3D 0) { + Status =3D EFI_INVALID_PARAMETER; + DEBUG ((DEBUG_ERROR, "%a: ERROR: Must be at least one NameSeg in NameS= tring=3D%a\n", __func__, String)); + goto Done; + } else if (NameSegCount =3D=3D 1) { + // Single NameSeg + Object->Data =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + NameStringSize, + Object->Data + ); + } else if (NameSegCount =3D=3D 2) { + Object->Data =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + NameStringSize + 1, + Object->Data + ); + Object->Data[Object->DataSize] =3D AML_DUAL_NAME_PREFIX; + Object->DataSize +=3D 1; + } else { + Object->Data =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + NameStringSize + 2, + Object->Data + ); + Object->Data[Object->DataSize] =3D AML_MULTI_NAME_PREFIX; + Object->Data[Object->DataSize + 1] =3D NameSegCount & 0xFF; + Object->DataSize +=3D 2; + } + + // Copy NameString data over. From above must be at least one NameSeg + CopyMem (&Object->Data[Object->DataSize], NameString, NameStringSize); + Object->DataSize +=3D NameStringSize; + FreePool (NameString); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + if (NameString !=3D NULL) { + FreePool (NameString); + } + } + + return Status; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNam= edObject.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNam= edObject.c new file mode 100644 index 0000000000..37ae9319be --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamedObjec= t.c @@ -0,0 +1,2138 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 :=3D DeviceOp PkgLength NameString TermList + NameOp :=3D ExtOpPrefix 0x82 + ExtOpPrefix :=3D 0x5B + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] String - Object name + @param[in,out] ListHead - Linked list has completed String Object afte= r + 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 >=3D AmlInvalid) || (String =3D=3D NULL) || (ListHead =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D 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 =3D 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 =3D 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 =3D AmlPkgLength (AmlClose, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n",= __func__, String)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, String, Lis= tHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, St= ring)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __f= unc__, String)); + goto Done; + } + + // Device Op is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, String)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_DEVICE_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + InternalFreeAmlObject (&ChildObject, ListHead); + } + + return Status; +} + +/** + Creates an AccessField + + AccessField :=3D 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + // Start new AML object + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start ACCESSFIELD object\n", __func__= )); + goto Done; + } + + Object->Data =3D AllocateZeroPool (3); + // AML_ACCESSFIELD_OP + AccessType + AccessAttrib + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for ACCESSFIELD= \n", __func__)); + goto Done; + } + + Object->Data[0] =3D AML_FIELD_ACCESS_OP; + Object->Data[1] =3D (UINT8)AccessType; + Object->Data[2] =3D (UINT8)AccessAttribute; + Object->DataSize =3D 3; + + Object->Completed =3D TRUE; + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/** + Creates an ExtendedAccessField + + ExtendedAccessField :=3D 0x03 AccessType ExtendedAccessAttrib AccessLeng= th + + @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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + + // Start new AML object + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start EXTENDEDACCESSFIELD object\n", = __func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (4); + // AML_EXTACCESSFIELD_OP + AccessType + AccessAttrib + AccessLength + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for EXTENDEDACC= ESSFIELD\n", __func__)); + goto Done; + } + + Object->Data[0] =3D AML_FIELD_EXT_ACCESS_OP; + Object->Data[1] =3D (UINT8)AccessType; + Object->Data[2] =3D (UINT8)AccessAttribute; + Object->Data[3] =3D AccessLength; + Object->DataSize =3D 4; + + Object->Completed =3D TRUE; + Status =3D 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 :=3D 0x01 AccessType AccessAttrib + AccessType :=3D ByteData // Bits 0:3 - Same as AccessType bits of Field= Flags. + // Bits 4:5 - Reserved + // Bits 7:6 - 0 =3D AccessAttrib =3D Normal Acce= ss Attributes + // 1 =3D AccessAttrib =3D AttribBytes (x) + // 2 =3D AccessAttrib =3D AttribRawBytes (x) + // 3 =3D AccessAttrib =3D 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 use= d here, an + ExtendedAccessField is used with the following d= efinitions + ExtendedAccessField :=3D 0x03 AccessType ExtendedAccessAttrib AccessLeng= th + ExtendedAccessAttrib :=3D ByteData // 0x0B AttribBytes + // 0x0E AttribRawBytes + // 0x0F AttribRawProcess + + AccessAttrib :=3D 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 Attr= ibBytes, + AttribRawBytes, or AttribRawProcessB= ytes. + 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 >=3D AttribNormal) && (AccessAttribute <=3D AttribB= lock)) { + if ((AccessAttribute & 1) =3D=3D 1) { + return EFI_INVALID_PARAMETER; + } + } else if (AccessAttribute > AttribRawProcessBytes) { + return EFI_INVALID_PARAMETER; + } + + // if AccessAttrib requires a length parameter, then an ExtendedAccessFi= eld is used + switch (AccessAttribute) { + case AttribBytes: + case AttribRawBytes: + case AttribRawProcessBytes: + Status =3D InternalAmlExtendedAccessField (AccessType, AccessAttribu= te, AccessLength, ListHead); + break; + default: + Status =3D InternalAmlAccessField (AccessType, AccessAttribute, List= Head); + break; + } + + return Status; +} + +/** + Creates an External Object + + External (ObjectName, ObjectType, ReturnType, ParameterTypes) + + Note: ReturnType is not used for AML encoding and is therefore not passe= d 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 :=3D ExternalOp NameString ObjectType ArgumentCount + ExternalOp :=3D 0x15 + ObjectType :=3D ByteData + ArgumentCount :=3D 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 f= or + that MethodObj. + Otherwise, ignored. + @param[in,out] ListHead - Linked list that has completed External Ob= ject + 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 =3D=3D NULL) || + (NumArgs > METHOD_ARGS_MAX) || + (ObjectType >=3D InvalidObj) || + (ListHead =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + // Start EXTERNAL object + Status =3D 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 =3D AmlOPNameString (Name, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a NameString object\n", __func= __, Name)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "EXTERNAL", Lis= tHead); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func__, N= ame)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 3); + // AML_EXTERNAL_OP + Name + ObjectType + ArgumentCount + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __fu= nc__, Name)); + goto Done; + } + + Object->DataSize =3D 0; + Object->Data[0] =3D AML_EXTERNAL_OP; + Object->DataSize++; + CopyMem ( + &Object->Data[Object->DataSize], + ChildObject->Data, + ChildObject->DataSize + ); + Object->DataSize +=3D ChildObject->DataSize; + Object->Data[Object->DataSize] =3D ObjectType; + Object->DataSize++; + Object->Data[Object->DataSize] =3D NumArgs; + Object->DataSize++; + + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D 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_FI= ELD_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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Object =3D NULL; + *ReturnObject =3D NULL; + Identifier =3D GENERIC_FIELD_IDENTIFIER; + IdentifierSize =3D AsciiStrLen (Identifier) + 1; + // Look Backwards and find Node for this Object + Node =3D ListHead; + do { + Node =3D GetPreviousNode (ListHead, Node); + Object =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + if ((Object->DataSize !=3D 0) && + (Object->DataSize =3D=3D IdentifierSize) && + (CompareMem ( + Object->Data, + Identifier, + MAX (Object->DataSize, IdentifierSize) + ) =3D=3D 0)) + { + break; + } + } while (Node !=3D ListHead); + + // Check to make sure FIELD is found, otherwise error + if ((Object->DataSize =3D=3D 0) || + (Object->DataSize !=3D IdentifierSize) || + CompareMem ( + Object->Data, + Identifier, + (MAX (Object->DataSize, IdentifierSize) !=3D 0) + )) + { + return EFI_DEVICE_ERROR; + } + + // Have found FIELD + Node =3D GetNextNode (ListHead, Node); + Object =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + *ReturnObject =3D 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 AmlOPFieldListI= tem, + or another Offset call. All offsets are defined starting from zero, base= d at + the starting address of the parent Operation Region. + + ReservedField :=3D 0x00 PkgLength + + @param[in] ByteLength -Byte offset of the next defined field wit= hin + 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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + InternalOffsetData =3D 0; + BitCount =3D LShiftU64 (ByteOffset, 3); + Object =3D NULL; + OffsetObject =3D NULL; + PkgLength =3D NULL; + + // Find and read internal offset data + Status =3D InternalAmlLocateOffsetTerm (&OffsetObject, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term\n", __f= unc__)); + goto Done; + } + + InternalOffsetData =3D *(UINT64 *)OffsetObject->Data; + + if (InternalOffsetData > BitCount) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid backwards offset\n", __func__= )); + Status =3D EFI_INVALID_PARAMETER; + goto Done; + } else if (InternalOffsetData =3D=3D BitCount) { + // Do not need to append any reserved fields + Status =3D EFI_SUCCESS; + goto Done; + } + + // update internal offset value to new offset + *(UINT64 *)OffsetObject->Data =3D BitCount; + + // take difference to find how many bits to reserve + BitCount =3D BitCount - InternalOffsetData; + + // Create new object for the offset data, add pkglength encoding + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: appending new AML object\n", __func__= )); + goto Done; + } + + Status =3D InternalAmlBitPkgLength ((UINT32)BitCount, &PkgLength, &DataL= ength); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: internal AML PkgLength\n", __func__))= ; + goto Done; + } + + Object->DataSize =3D DataLength + 1; // add one for Reserved Field Indic= ator + Object->Data =3D AllocateZeroPool (Object->DataSize); + + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for Offset\n", = __func__)); + goto Done; + } + + Object->Data[0] =3D 0; + CopyMem (&Object->Data[1], PkgLength, DataLength); // read internal offs= et data + Object->Completed =3D 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 :=3D NameSeg PkgLength + ReservedField :=3D 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 =3D=3D NULL) || (Name =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + OffsetObject =3D NULL; + + if (AsciiStrLen (Name) =3D=3D 0) { + if (BitLength > 0) { + // Prepend a 0 to the list + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to append AML object.\n", = __func__)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (1); + Object->DataSize =3D 1; + Object->Completed =3D TRUE; + } else { + Status =3D EFI_SUCCESS; + goto Done; + } + } else { + // add NameSeg to List + Status =3D InternalAmlNameSeg (Name, ListHead); + } + + if (EFI_ERROR (Status)) { + goto Done; + } + + // Locate and update internal Offset term + Status =3D 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 +=3D BitLength; // write + + // Add BitLength as a PkgLength term + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Appending BitLength for %a object\n",= __func__, Name)); + goto Done; + } + + Status =3D InternalAmlBitPkgLength (BitLength, &Object->Data, &Object->D= ataSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Appending BitLength for %a object\n",= __func__, Name)); + goto Done; + } + + Object->Completed =3D 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 :=3D FieldOp PkgLength NameString FieldFlags FieldList + FieldOp :=3D 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 a= fter + 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 =3D=3D NULL) || (Name =3D=3D NULL) || (AsciiStrLen (Name) = =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + + // parameter validation + if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) = || (UpdateRule > WriteAsZeros)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTI= FIER, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Field for %a object\n", __f= unc__, Name)); + goto Done; + } + + // Insert internal offset counter + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Unable to append AML object.\n", = __func__)); + goto Done; + } + + Object->DataSize =3D sizeof (UINT64); + Object->Data =3D AllocateZeroPool (Object->DataSize); + Object->Completed =3D TRUE; + if (EFI_ERROR (Status) || (Object->Data =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Field internal offset %a ob= ject\n", __func__, Name)); + goto Done; + } + + // Start required PkgLength + Status =3D 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 =3D 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 =3D 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 =3D 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, Name)); + goto Done; + } + + FieldFlags =3D (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessT= ype); + + Object->Data[0] =3D FieldFlags; + Object->Completed =3D 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 =3D 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 =3D InternalAmlLocateOffsetTerm (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n= ", __func__, Name)); + goto Done; + } + + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIE= LD_IDENTIFIER, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, Na= me)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __f= unc__, Name)); + goto Done; + } + + // Field Op is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, Name)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_FIELD_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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, Update= Rule) {FieldUnitList} + FieldUnitList must be added between AmlStart and AmlClose phase + + DefBankField :=3D BankFieldOp PkgLength NameString NameString BankValue= FieldFlags FieldList + BankFieldOp :=3D ExtOpPrefix 0x87 + BankValue :=3D TermArg =3D> 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 Obje= ct + + @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 =3D=3D NULL) || (RegionName =3D=3D NULL) || (AsciiStrLen (= RegionName) =3D=3D 0) || + (BankName =3D=3D NULL) || (AsciiStrLen (BankName) =3D=3D 0)) + { + return EFI_INVALID_PARAMETER; + } + + // parameter validation + if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) = || (UpdateRule > WriteAsZeros)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTI= FIER, 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 =3D InternalAppendNewAmlObjectNoData (&Object, Lis= tHead); + Object->DataSize =3D sizeof (UINT64); + Object->Data =3D AllocateZeroPool (Object->DataSize); + Object->Completed =3D TRUE; + if (EFI_ERROR (Status) || (Object->Data =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start BankField internal offset %= a object\n", __func__, BankName)); + goto Done; + } + + // Start required PkgLength + Status =3D 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 =3D 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 =3D 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 =3D AmlOPDataInteger (BankValue, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Adding BankValue Integer for %a o= bject\n", __func__, BankName)); + goto Done; + } + + // Add Field Flags + Status =3D 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 =3D 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, BankName)); + goto Done; + } + + FieldFlags =3D (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessT= ype); + + Object->Data[0] =3D FieldFlags; + Object->Completed =3D 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 =3D 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 =3D InternalAmlLocateOffsetTerm (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n= ", __func__, BankName)); + goto Done; + } + + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIE= LD_IDENTIFIER, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, Ba= nkName)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __f= unc__, BankName)); + goto Done; + } + + // Field Op is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, BankName)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_BANK_FIELD_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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) {Fiel= dUnitList} + + FieldUnitList must be added between AmlStart and AmlClose phase + + DefIndexField :=3D IndexFieldOp PkgLength NameString NameString FieldFla= gs FieldList + IndexFieldOp :=3D 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 Obj= ect + + @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 =3D=3D NULL) || (IndexName =3D=3D NULL) || (AsciiStrLen (I= ndexName) =3D=3D 0) || + (DataName =3D=3D NULL) || (AsciiStrLen (DataName) =3D=3D 0)) + { + return EFI_INVALID_PARAMETER; + } + + // parameter validation + if ((Phase > AmlClose) || (AccessType > BufferAcc) || (LockRule > Lock) = || (UpdateRule > WriteAsZeros)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, GENERIC_FIELD_IDENTI= FIER, 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 =3D InternalAppendNewAmlObjectNoData (&Object, Lis= tHead); + Object->DataSize =3D sizeof (UINT64); + Object->Data =3D AllocateZeroPool (Object->DataSize); + Object->Completed =3D TRUE; + if (EFI_ERROR (Status) || (Object->Data =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start IndexField internal offset = %a object\n", __func__, IndexName)); + goto Done; + } + + // Start required PkgLength + Status =3D 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 =3D 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 =3D 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 =3D 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 =3D 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, IndexName)); + goto Done; + } + + FieldFlags =3D (UINT8)((UpdateRule << 5) | (LockRule << 4) | AccessT= ype); + + Object->Data[0] =3D FieldFlags; + Object->Completed =3D 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 =3D 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 =3D InternalAmlLocateOffsetTerm (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locating internal offset term%a\n= ", __func__, IndexName)); + goto Done; + } + + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, GENERIC_FIE= LD_IDENTIFIER, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, In= dexName)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __f= unc__, IndexName)); + goto Done; + } + + // Field Op is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, IndexName)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_INDEX_FIELD_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&ChildObject, ListHead); + InternalFreeAmlObject (&Object, ListHead); + } + + return Status; +} + +/** + OperationRegion (RegionName, RegionSpace, Offset, Length) + + DefOpRegion :=3D OpRegionOp NameString RegionSpace RegionOffset RegionLe= n + OpRegionOp :=3D ExtOpPrefix 0x80 + RegionSpace :=3D + 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 :=3D TermArg =3D> Integer + RegionLen :=3D TermArg =3D> 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 =3D=3D NULL) || (AsciiStrLen (RegionName) =3D=3D 0) || (= ListHead =3D=3D NULL) || + ((RegionSpace > PCC) && (RegionSpace < 0x80)) || (RegionSpace > 0xFF= )) + { + return EFI_INVALID_PARAMETER; + } + + Object =3D NULL; + ChildObject =3D NULL; + Status =3D EFI_DEVICE_ERROR; + + Status =3D InternalAppendNewAmlObject (&Object, "OPREGION", ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start OpRegion for %a object\n", __fu= nc__, RegionName)); + goto Done; + } + + Status =3D AmlOPNameString (RegionName, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Name String for %a object\n", __func_= _, RegionName)); + goto Done; + } + + Status =3D 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 =3D AmlOPDataInteger (Offset, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Offset data integer for %a object\n",= __func__, RegionName)); + goto Done; + } + + Status =3D AmlOPDataInteger (Length, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Length data integer for %a object\n",= __func__, RegionName)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "OPREGION", Lis= tHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, Region= Name)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __func_= _, RegionName)); + goto Done; + } + + // OpRegion Opcode is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __fu= nc__, RegionName)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_REGION_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D 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 :=3D CreateFieldOp SourceBuff BitIndex NumBits NameString + CreateFieldOp :=3D ExtOpPrefix 0x13 + ExtOpPrefix :=3D 0x5B + SourceBuff :=3D TermArg =3D> Buffer + BitIndex :=3D TermArg =3D> Integer + NumBits :=3D TermArg -> Integer + + @param[in] SourceBuffer, - Buffer to house the new buffer field o= bject + @param[in] BitIndex, - Starting bit index place the new buffe= r + @param[in] NumBits, - Number of bits to reserve + @param[in] FieldName, - The new buffer field object to be crea= ted 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 =3D NULL; + Object =3D NULL; + + if ((SourceBuffer =3D=3D NULL) || (FieldName =3D=3D NULL) || (ListHead = =3D=3D NULL) || + (AsciiStrLen (SourceBuffer) =3D=3D 0) || (AsciiStrLen (FieldName) = =3D=3D 0)) + { + return EFI_INVALID_PARAMETER; + } + + ChildObject =3D NULL; + Status =3D InternalAppendNewAmlObject (&Object, "CreateField", List= Head); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: CreateField for %a object\n", __func_= _, FieldName)); + goto Done; + } + + Status =3D AmlOPNameString (SourceBuffer, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func__= , FieldName)); + goto Done; + } + + Status =3D AmlOPDataInteger (BitIndex, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: BitIndex for %a object\n", __func__, = FieldName)); + goto Done; + } + + Status =3D AmlOPDataInteger (NumBits, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NumBits for %a object\n", __func__, F= ieldName)); + goto Done; + } + + Status =3D AmlOPNameString (FieldName, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__,= FieldName)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "CreateField", = ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, FieldN= ame)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __func_= _, FieldName)); + goto Done; + } + + // CreateFieldOp is two bytes + Object->DataSize =3D ChildObject->DataSize + 2; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __fu= nc__, FieldName)); + goto Done; + } + + Object->Data[0] =3D AML_EXT_OP; + Object->Data[1] =3D AML_EXT_CREATE_FIELD_OP; + CopyMem ( + &Object->Data[2], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D 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 fixe= d field object + @param[in] Index, - Starting index to place the new buff= er + @param[in] FixedFieldName, - Name of the FixedField + @param[in] OpCode, - AML opcode for the Create_Field enco= ding + @param[in,out] ListHead - Linked list has completed CreateFixe= dField 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 =3D NULL; + + if ((SourceBuffer =3D=3D NULL) || (FixedFieldName =3D=3D NULL) || (ListH= ead =3D=3D NULL) || + (AsciiStrLen (SourceBuffer) =3D=3D 0) || (AsciiStrLen (FixedFieldNam= e) =3D=3D 0)) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D InternalAppendNewAmlObject (&Object, "CreateFixedField", List= Head); + 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) =3D=3D 0) { + if ((SourceBuffer[5] >=3D '0') && (SourceBuffer[5] <=3D '9')) { + Status =3D 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) =3D=3D 0) { + if ((SourceBuffer[3] >=3D '0') && (SourceBuffer[3] <=3D '9')) { + Status =3D 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 =3D AmlOPNameString (SourceBuffer, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: NameString for %a object\n", __func= __, FixedFieldName)); + goto Done; + } + } + + Status =3D AmlOPDataInteger (Index, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Index for %a object\n", __func__, Fix= edFieldName)); + goto Done; + } + + Status =3D AmlOPNameString (FixedFieldName, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: FieldName for %a object\n", __func__,= FixedFieldName)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "CreateFixedFie= ld", ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, FixedF= ieldName)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __func_= _, FixedFieldName)); + goto Done; + } + + // CreateWordFieldOp is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __fu= nc__, FixedFieldName)); + goto Done; + } + + Object->Data[0] =3D OpCode; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D 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 :=3D CreateBitFieldOp SourceBuff BitIndex NameString + CreateBitFieldOp :=3D 0x8D + SourceBuff :=3D TermArg =3D> Buffer + BitIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer bit fi= eld object + @param[in] BitIndex, - Starting bit index to place the new bu= ffer + @param[in] BitFieldName, - Name of the BitField + @param[in,out] ListHead - Linked list has completed CreateBitFie= ld 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 =3D InternalAmlCreateFixedField (SourceBuffer, BitIndex, BitField= Name, 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 :=3D CreateByteFieldOp SourceBuff ByteIndex NameStri= ng + CreateByteFieldOp :=3D 0x8C + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer byte f= ield object + @param[in] ByteIndex, - Starting byte index to place the new b= uffer + @param[in] ByteFieldName, - Name of the ByteField + @param[in,out] ListHead - Linked list has completed CreateByteFi= eld 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 =3D InternalAmlCreateFixedField (SourceBuffer, ByteIndex, ByteFie= ldName, AML_CREATE_BYTE_FIELD_OP, ListHead); + return Status; +} + +/** + Creates a CreateDWordField AML Object and inserts it into the linked lis= t + + Syntax: + CreateDWordField ( SourceBuffer, ByteIndex, DWordFieldName ) + + DefCreateDWordField :=3D CreateDWordFieldOp SourceBuff ByteIndex NameStr= ing + CreateDWordFieldOp :=3D 0x8A + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer DWor= d 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 CreateDWor= dField 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 =3D InternalAmlCreateFixedField (SourceBuffer, ByteIndex, DWordFi= eldName, AML_CREATE_DWORD_FIELD_OP, ListHead); + return Status; +} + +/** + Creates a CreateQWordField AML Object and inserts it into the linked lis= t + + Syntax: + CreateQWordField ( SourceBuffer, ByteIndex, QWordFieldName ) + + DefCreateQWordField :=3D CreateQWordFieldOp SourceBuff ByteIndex NameStr= ing + CreateQWordFieldOp :=3D 0x8F + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to insert the new buffer QWor= d 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 CreateQWor= dField 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 =3D InternalAmlCreateFixedField (SourceBuffer, ByteIndex, QWordFi= eldName, 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 :=3D CreateWordFieldOp SourceBuff ByteIndex NameStri= ng + CreateWordFieldOp :=3D 0x8B + SourceBuff :=3D TermArg =3D> Buffer + ByteIndex :=3D TermArg =3D> Integer + + @param[in] SourceBuffer, - Buffer to house the new buffer word fi= eld object + @param[in] ByteIndex, - Starting byte index to place the new b= uffer + @param[in] WordFieldName, - Name of the WordField + @param[in,out] ListHead - Linked list has completed CreateWordFi= eld 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 =3D InternalAmlCreateFixedField (SourceBuffer, ByteIndex, WordFie= ldName, 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 :=3D MethodOp PkgLength NameString MethodFlags TermList + MethodOp :=3D 0x14 + MethodFlags :=3D 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 serial= ized + 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 >=3D AmlInvalid) || + (Name =3D=3D NULL) || + (NumArgs > METHOD_ARGS_MAX) || + (SyncLevel > MAX_SYNC_LEVEL) || + (SerializeRule >=3D FlagInvalid) || + (ListHead =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D 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 =3D 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 =3D 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 =3D InternalAppendNewAmlObject (&Object, "METHOD_FLAGS", List= Head); + 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 =3D InternalAmlLocateObjectByIdentifier (&Object, "METHOD_FLA= GS", 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a METHOD_FLAGS child data collec= tion.\n", __func__, Name)); + goto Done; + } + + // Method Flags is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, Name)); + goto Done; + } + + MethodFlags =3D NumArgs & 0x07; + if (SerializeRule) { + MethodFlags |=3D BIT3; + } + + MethodFlags |=3D (SyncLevel & 0x0F) << 4; + Object->Data[0] =3D MethodFlags; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + // Required NameString completed in one phase call + + // Close required PkgLength before finishing Object + Status =3D AmlPkgLength (AmlClose, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n",= __func__, Name)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "Method", L= istHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, Na= me)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a child data collection.\n", __f= unc__, Name)); + goto Done; + } + + // Method Op is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, Name)); + goto Done; + } + + Object->Data[0] =3D AML_METHOD_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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/AmlNam= espaceModifierObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerat= ionLib/AmlNamespaceModifierObjects.c new file mode 100644 index 0000000000..afe51cdcf2 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlNamespaceM= odifierObjects.c @@ -0,0 +1,360 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLNAMESPACEMODIFIEROBJECTS_= FILECODE + +/** + Creates a Scope (ObjectName, Object) + + Object must be created between AmlStart and AmlClose Phase + + DefScope :=3D ScopeOp PkgLength NameString TermList + ScopeOp :=3D 0x10 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] String - Location + @param[in,out] ListHead - Linked list has completed String Object afte= r + 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 >=3D AmlInvalid) || (String =3D=3D NULL) || (ListHead =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, String, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, Str= ing)); + goto Done; + } + + // Start required PkgLength + Status =3D 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 =3D 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 =3D AmlPkgLength (AmlClose, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Close PkgLength for %a object\n",= __func__, String)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, String, Lis= tHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, St= ring)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func_= _, String)); + goto Done; + } + + // Scope Op is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, String)); + goto Done; + } + + Object->Data[0] =3D AML_SCOPE_OP; + CopyMem (&Object->Data[1], ChildObject->Data, ChildObject->DataSize)= ; + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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 :=3D NameOp NameString ChildObjectData + NameOp :=3D 0x08 + + @param[in] Phase - Either AmlStart or AmlClose + @param[in] String - Object name + @param[in,out] ListHead - Linked list has completed String Object afte= r + 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 >=3D AmlInvalid) || (String =3D=3D NULL) || (ListHead =3D=3D = NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, String, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, Str= ing)); + goto Done; + } + + // Insert required NameString + Status =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, String, Lis= tHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, St= ring)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func_= _, String)); + goto Done; + } + + Object->Data =3D AllocatePool (ChildObject->DataSize + 1); + // Name Op is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", = __func__, String)); + goto Done; + } + + Object->Data[0] =3D AML_NAME_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + InternalFreeAmlObject (&ChildObject, ListHead); + } + + return Status; +} + +/** + Creates an Alias (SourceObject, AliasObject) + + DefAlias :=3D AliasOp NameString NameString + AliasOp :=3D 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 =3D=3D NULL) || (AliasName =3D=3D NULL) || (ListHead =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + // Start ALIAS object + Status =3D 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 =3D AmlOPNameString (SourceName, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create NameString: %a \n", __f= unc__, SourceName)); + goto Done; + } + + // Insert required Alias NameString + Status =3D AmlOPNameString (AliasName, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create NameString: %a \n", __f= unc__, AliasName)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "ALIAS", ListHe= ad); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func__, S= ourceName)); + goto Done; + } + + Object->Data =3D AllocateZeroPool (ChildObject->DataSize + 1); + // Alias Op is one byte + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object->Data for %a\n", __fu= nc__, SourceName)); + goto Done; + } + + Object->Data[0] =3D AML_ALIAS_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D EFI_SUCCESS; + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + InternalFreeAmlObject (&ChildObject, ListHead); + } + + return Status; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObj= ectsDebug.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlOb= jectsDebug.c new file mode 100644 index 0000000000..279bfc782d --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlObjectsDeb= ug.c @@ -0,0 +1,144 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 =3D Buffer; + NumberOfColumns =3D 16; + // Header + DEBUG ((DEBUG_VERBOSE, " 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D = 0E 0F\n")); + for (Index =3D 0; Index < BufferSize;) { + // Row Counter + DEBUG ((DEBUG_VERBOSE, "%4X ", Index)); + + // Hex ouput + for (Column =3D 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 =3D 0; Column < NumberOfColumns; Column++) { + if (Index + Column < BufferSize) { + // Only print ACPI acceptable characters + if (((Data[Index + Column] >=3D 0x30) && // '0' - '9' + (Data[Index + Column] <=3D 0x39)) || + ((Data[Index + Column] >=3D 0x41) && // 'A' - 'Z' + (Data[Index + Column] <=3D 0x5A)) || + (Data[Index + Column] =3D=3D 0x5C) || // '\' + (Data[Index + Column] =3D=3D 0x5F) || // '_' + (Data[Index + Column] =3D=3D 0x5E) // '^' + ) + { + DEBUG ((DEBUG_VERBOSE, "%c", Data[Index + Column])); + } else { + DEBUG ((DEBUG_VERBOSE, ".")); + } + } + } + + Index +=3D 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=3D(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 =3D=3D NULL) || (Object->Signature !=3D AML_OBJECT_INSTANCE_= SIGNATURE)) { + return EFI_INVALID_PARAMETER; + } + + DEBUG (( + DEBUG_VERBOSE, + "Object=3D0x%X, Size=3D0x%d\n", + (UINTN)Object, + Object->DataSize + )); + AmlDebugPrintBuffer (Object->Data, Object->DataSize); + DEBUG ((DEBUG_VERBOSE, "Completed=3D%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 =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((DEBUG_VERBOSE, "Printing AML_OBJECT_INSTANCE Linked List\n")); + Node =3D GetNextNode (ListHead, ListHead); + while (Node !=3D ListHead) { + Object =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + AmlDebugPrintObject (Object); + Node =3D GetNextNode (ListHead, Node); + } + + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkg= Length.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlPkgLe= ngth.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 encod= ing + @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 =3D EFI_INVALID_PARAMETER; + DataLength =3D 0; + // Calculate Length of PkgLength Data and fill out least + // significant nibble + if ((DataSize + 1) <=3D MAX_ONE_BYTE_PKG_LENGTH) { + DataLength =3D 1; + PkgLeadByte =3D ONE_BYTE_PKG_LENGTH_ENCODING; + PkgLeadByte |=3D ((DataSize) & ONE_BYTE_NIBBLE_MASK); + } else { + if ((DataSize + 2) <=3D MAX_TWO_BYTE_PKG_LENGTH) { + DataLength =3D 2; + PkgLeadByte =3D TWO_BYTE_PKG_LENGTH_ENCODING; + } else if ((DataSize + 3) <=3D MAX_THREE_BYTE_PKG_LENGTH) { + DataLength =3D 3; + PkgLeadByte =3D THREE_BYTE_PKG_LENGTH_ENCODING; + } else if ((DataSize + 4) <=3D MAX_FOUR_BYTE_PKG_LENGTH) { + DataLength =3D 4; + PkgLeadByte =3D FOUR_BYTE_PKG_LENGTH_ENCODING; + } else { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: PkgLength data size > 0x%X\n", + __func__, + MAX_FOUR_BYTE_PKG_LENGTH - 4 + )); + goto Done; + } + + PkgLeadByte |=3D ((DataSize) & PKG_LENGTH_NIBBLE_MASK); + } + + // Allocate new data buffer + // DataSize =3D DataLength + DataSize; + *PkgLengthEncoding =3D AllocatePool (DataLength); + if (*PkgLengthEncoding =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocation failed Object=3DPkgLength\= n", __func__)); + goto Done; + } + + // Populate PkgLeadByte + *PkgLengthEncoding[0] =3D PkgLeadByte; + + // Populate remainder of PkgLength bytes + PkgLengthRemainder =3D (DataSize) >> 4; + if (PkgLengthRemainder !=3D 0) { + CopyMem (&PkgLengthEncoding[0][1], &PkgLengthRemainder, DataLength - 1= ); + } + + *ReturnDataLength =3D DataLength; + +Done: + return Status; +} + +/** + Creates a Package Length AML Object and inserts it into the linked list + + PkgLength :=3D PkgLeadByte | + | + | + + + PkgLeadByte :=3D + + + + 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 u= sed + to encode the package length (in other words, values 0-63). If the packa= ge + length value is more than 63, more than one byte must be used for the en= coding + in which case bit 4 and 5 of the PkgLeadByte are reserved and must be ze= ro. + + If the multiple bytes encoding is used, bits 0-3 of the PkgLeadByte beco= me + 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, "LENGTH", ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start Length object\n", __func__)= ); + goto Done; + } + + break; + case AmlClose: + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "LENGTH", L= istHead); + 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 =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func_= _, "Length")); + goto Done; + } + + DataLength =3D 0; + // Calculate Length of PkgLength Data and fill out least + // significant nibble + if ((ChildObject->DataSize + 1) <=3D MAX_ONE_BYTE_PKG_LENGTH) { + DataLength =3D 1; + PkgLeadByte =3D ONE_BYTE_PKG_LENGTH_ENCODING; + PkgLeadByte |=3D ((ChildObject->DataSize + DataLength) & ONE_BYTE_= NIBBLE_MASK); + } else { + if ((ChildObject->DataSize + 2) <=3D MAX_TWO_BYTE_PKG_LENGTH) { + DataLength =3D 2; + PkgLeadByte =3D TWO_BYTE_PKG_LENGTH_ENCODING; + } else if ((ChildObject->DataSize + 3) <=3D MAX_THREE_BYTE_PKG_LEN= GTH) { + DataLength =3D 3; + PkgLeadByte =3D THREE_BYTE_PKG_LENGTH_ENCODING; + } else if ((ChildObject->DataSize + 4) <=3D MAX_FOUR_BYTE_PKG_LENG= TH) { + DataLength =3D 4; + PkgLeadByte =3D FOUR_BYTE_PKG_LENGTH_ENCODING; + } else { + Status =3D EFI_DEVICE_ERROR; + DEBUG (( + DEBUG_ERROR, + "%a: ERROR: PkgLength data size > 0x%X\n", + __func__, + MAX_FOUR_BYTE_PKG_LENGTH - 4 + )); + goto Done; + } + + PkgLeadByte |=3D ((ChildObject->DataSize + DataLength) & PKG_LENGT= H_NIBBLE_MASK); + } + + // Allocate new data buffer + Object->DataSize =3D DataLength + ChildObject->DataSize; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocation failed Object=3DPkgLen= gth\n", __func__)); + goto Done; + } + + // Populate PkgLeadByte + Object->Data[0] =3D PkgLeadByte; + + // Populate remainder of PkgLength bytes + PkgLengthRemainder =3D (ChildObject->DataSize + DataLength) >> 4; + if (PkgLengthRemainder !=3D 0) { + CopyMem (&Object->Data[1], &PkgLengthRemainder, DataLength - 1); + } + + CopyMem ( + &Object->Data[DataLength], + ChildObject->Data, + ChildObject->DataSize + ); + + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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/AmlRes= ourceDescriptor.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib= /AmlResourceDescriptor.c new file mode 100644 index 0000000000..4ef746327b --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlResourceDe= scriptor.c @@ -0,0 +1,1989 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_AMLRESOURCEDESCRIPTOR_FILECO= DE + +/** + ResourceTemplate (Resource To Buffer Conversion Macro) + + Syntax: + ResourceTemplate () {ResourceMacroList} =3D> Buffer + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed ResourceTemplate O= bject + 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D AmlBuffer (AmlStart, 0, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "Re= sourceTemplate")); + goto Done; + } + + // Start EndTag object to be completed in Close + // ACPI 6.3: 6.4.2.9 End Tag: ...The End Tag is automatically genera= ted by + // the ASL compiler at the end of the ResourceTemplate statement. + Status =3D InternalAppendNewAmlObject (&Object, "END_TAG", ListHead)= ; + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "EN= D_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 =3D InternalAmlLocateObjectByIdentifier (&Object, "END_TAG", = ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Locate %a object\n", __func__, "E= ND_TAG")); + goto Done; + } + + // Release Object->Data Identifier + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: collecting Child data\n", __func_= _)); + goto Done; + } + + Object->DataSize =3D ChildObject->DataSize + sizeof (EFI_ACPI_END_TA= G_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: EndTag Alloc Failed\n", __func__)= ); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + // ChildObject Data goes before End Tag + if ((ChildObject->Data !=3D NULL) && (ChildObject->DataSize > 0)) { + CopyMem (Object->Data, ChildObject->Data, ChildObject->DataSize); + } + + EndTag =3D (EFI_ACPI_END_TAG_DESCRIPTOR *)&Object->Data[ChildO= bject->DataSize]; + EndTag->Desc =3D ACPI_END_TAG_DESCRIPTOR; + // Spec says the byte is a checksum, but I have never seen a value o= ther + // than zero in the field compiled from ASL. + // EndTag->Checksum already =3D 0; + + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + + Status =3D AmlBuffer (AmlClose, 0, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Close %a object\n", __func__, "Re= sourceTemplate")); + goto Done; + } + + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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 s= pace + 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 AddressMa= ximum\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + // Address Granularity must be (2^n)-1 + if (((AddressGranularity + 1) & AddressGranularity) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressGranularity must be (a power o= f 2)-1\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if (RangeLength =3D=3D 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 _M= AF + // is set, _MAX must be (a multiple of (_GRA+1))-1. + // OS can pick the resource range that satisfies following co= nditions: + // If _MIF is not set, start address is a multiple of (_GRA+1= ) + // and greater or equal to _MIN. Otherwise, start address i= s _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 _MA= X. + // 0 1 1 (Invalid combination) + if ((IsMinFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) && + (IsMaxFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED)) + { + // 0 1 1 (Invalid combination) + DEBUG ((DEBUG_ERROR, "%a: ERROR: IsMinFixed and IsMaxFixed cannot bo= th be set\n", __func__)); + DEBUG ((DEBUG_ERROR, "%a: When RangeLength=3D0x%lX\n", __func= __, RangeLength)); + return EFI_INVALID_PARAMETER; + } else if (IsMaxFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED) { + // 0 0 1 + if ((AddressMaximum & AddressGranularity) !=3D AddressGranularity) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMaximum=3D0x%lX + 1) is n= ot a multiple of\n", __func__, AddressMaximum)); + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=3D0x%lX + 1)\= n", __func__, AddressGranularity)); + DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed =3D 1\n", __func_= _)); + return EFI_INVALID_PARAMETER; + } + + if (AddressMaximum =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMaximum can not be 0\n", _= _func__)); + DEBUG ((DEBUG_ERROR, "%a: When IsMaxFixed =3D 1\n", __func_= _)); + return EFI_INVALID_PARAMETER; + } + } else if (IsMinFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) { + // 0 1 0 + if ((AddressMinimum & AddressGranularity) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressMinimum=3D0x%lX is not a m= ultiple of\n", __func__, AddressMinimum)); + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=3D0x%lX + 1)\= n", __func__, AddressGranularity)); + DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed =3D 1\n", __func_= _)); + return EFI_INVALID_PARAMETER; + } + } else if ((IsMinFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED) = && + (IsMaxFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED) = && + (AddressMinimum =3D=3D 0) && + (AddressMaximum =3D=3D 0) && + (AddressGranularity =3D=3D 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 fo= r _PRS. + // _LEN must be a multiple of (_GRA+1). + // OS can pick the resource range that satisfies follow= ing 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 eq= ual 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 =3D=3D EFI_ACPI_GENERAL_FLAG_MIN_IS_NOT_FIXED) && + (IsMaxFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MAX_IS_NOT_FIXED)) + { + // >0 0 0 + if ((RangeLength & AddressGranularity) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=3D0x%lX is not a mult= iple of\n", __func__, RangeLength)); + DEBUG ((DEBUG_ERROR, "%a: (AddressGranularity=3D0x%lX + 1)\= n", __func__, AddressGranularity)); + DEBUG ((DEBUG_ERROR, "%a: When IsMinFixed =3D 0, IsMaxFixed= =3D 0\n", __func__)); + return EFI_INVALID_PARAMETER; + } else if (RangeLength > (AddressMaximum - AddressMinimum + 1)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=3D0x%lX > (AddrRangeM= ax=3D0x%lX - AddrRangeMin=3D0x%lX + 1)\n", __func__, RangeLength, AddressMa= ximum, AddressMinimum)); + DEBUG ((DEBUG_ERROR, "%a: IsMinFixed =3D 0, IsMaxFixed =3D = 0\n", __func__, RangeLength)); + return EFI_INVALID_PARAMETER; + } + } else if ((IsMinFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MIN_IS_FIXED) && + (IsMaxFixed =3D=3D EFI_ACPI_GENERAL_FLAG_MAX_IS_FIXED)) + { + // >0 1 1 + if (AddressGranularity !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: AddressGranularity=3D0x%lX !=3D 0= \n", __func__, AddressGranularity)); + DEBUG ((DEBUG_ERROR, "%a: When RangeLength=3D0x%lX > 0, IsM= inFixed =3D 1, and IsMaxFixed =3D 1\n", __func__, RangeLength)); + return EFI_INVALID_PARAMETER; + } else if (RangeLength !=3D (AddressMaximum - AddressMinimum + 1)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: RangeLength=3D0x%lX !=3D (AddrRan= geMax=3D0x%lX - AddrRangeMin=3D0x%lX + 1)\n", __func__, RangeLength, Addres= sMaximum, AddressMinimum)); + DEBUG ((DEBUG_ERROR, "%a: IsMinFixed =3D 1, IsMaxFixed =3D = 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=3D0x%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) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid ResourceUsage Parameter= \n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid Decode Parameter\n", __= func__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMinFixed Parameter\n"= , __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Dword Invalid IsMaxFixed Parameter\n"= , __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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 =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "DWORD_= ADDRESS")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "DWORD_= ADDRESS")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIP= TOR *)Object->Data; + Descriptor->Header.Header.Byte =3D ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR; + Descriptor->Header.Length =3D sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_= DESCRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + Descriptor->ResType =3D ResourceType; + Descriptor->GenFlag =3D IsMinFixed | IsMaxFixed | Decode; + Descriptor->SpecificFlag =3D TypeSpecificFlags; + Descriptor->AddrSpaceGranularity =3D AddressGranularity; + Descriptor->AddrRangeMin =3D AddressMinimum; + Descriptor->AddrRangeMax =3D AddressMaximum; + Descriptor->AddrTranslationOffset =3D AddressTranslation; + Descriptor->AddrLen =3D RangeLength; + Object->Completed =3D 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) {DmaChannelL= ist} =3D> 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, 1= 6-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 IMPLEME= NTED + 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) !=3D 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) !=3D 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) !=3D 0) || + (DmaTransferSize =3D=3D 0x3)) + { + // Invalid DmaTransferSize value + DEBUG ((DEBUG_ERROR, "%a: ERROR: DmaTransferSize '%x' is not valid.\n"= , __func__, DmaType)); + return EFI_INVALID_PARAMETER; + } + + if (ListHead =3D=3D NULL) { + // Invalid + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot = =3D=3D NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func_= _, "DMA_RESOURCE")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_DMA_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "DMA_RE= SOURCE")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_DMA_DESCRIPTOR *)Object->Data; + Descriptor->Header.Byte =3D ACPI_DMA_DESCRIPTOR; + Descriptor->ChannelMask =3D 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 =3D (UINT8)(DmaType + + IsBusMaster + + DmaTransferSize); + Object->Completed =3D 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 =3D 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 =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges =3D 0 =3D Reserved\n", __fu= nc__)); + return EFI_INVALID_PARAMETER; + } else if (ISARanges > 3) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 are Invalid\n", __func_= _)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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, AddressMa= ximum, + AddressTranslation, RangeLength, ResourceSourceIndex, + ResourceSource, DescriptorName, MemoryRangeType, Translatio= nType) + + 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) !=3D 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) !=3D 0) = { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ReadAndWrite Parameter\n", __= func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid ResourceUsage Parameter= \n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid Decode Parameter\n", __= func__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMinFixed Parameter\n"= , __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Qword Invalid IsMaxFixed Parameter\n"= , __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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 =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "QWORD_= ADDRESS")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "QWORD_= ADDRESS")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIP= TOR *)Object->Data; + Descriptor->Header.Header.Byte =3D ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR; + Descriptor->Header.Length =3D sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_= DESCRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + Descriptor->ResType =3D ResourceType; + Descriptor->GenFlag =3D IsMinFixed | IsMaxFixed | Decode; + Descriptor->SpecificFlag =3D TypeSpecificFlags; + Descriptor->AddrSpaceGranularity =3D AddressGranularity; + Descriptor->AddrRangeMin =3D AddressMinimum; + Descriptor->AddrRangeMax =3D AddressMaximum; + Descriptor->AddrTranslationOffset =3D AddressTranslation; + Descriptor->AddrLen =3D RangeLength; + Object->Completed =3D 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} = =3D> Buffer + + Arguments: + EdgeLevel: + Describes whether the interrupt is edge triggered (Edge) or level tr= iggered + (Level). The field DescriptorName. _HE is automatically created to r= efer to + this portion of the resource descriptor, where '1' is Edge and Activ= eHigh + and '0' is Level and ActiveLow. + + ActiveLevel: + Describes whether the interrupt is active-high (ActiveHigh) or activ= e-low + (ActiveLow). The field DescriptorName. _LL is automatically created = to refer + to this portion of the resource descriptor, where '1' is Edge and Ac= tiveHigh + and '0' is Level and ActiveLow. + + Shared: + Describes whether the interrupt can be shared with other devices (Sh= ared) or + not (Exclusive), and whether it is capable of waking the system from= a + low-power idle or system sleep state (SharedAndWake or ExclusiveAndW= ake). + 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 constan= t that + will be created in the current scope that contains the offset of thi= s resource + descriptor within the current resource template buffer. The predefin= ed + descriptor field names may be appended to this name to access indivi= dual + fields within the descriptor via the Buffer Field operators. + + Description: + The IRQ macro evaluates to a buffer that contains an IRQ resource de= scriptor. + The format of the IRQ descriptor can be found in "IRQ Descriptor". T= he macro + produces the three-byte form of the descriptor. The macro is designe= d 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 I= MPLEMENTED + 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) !=3D 0) { + // Invalid Decode value + DEBUG ((DEBUG_ERROR, "%a: ERROR: EdgeLevel '%x' is not valid.\n", __fu= nc__, EdgeLevel)); + return EFI_INVALID_PARAMETER; + } + + if ((ActiveLevel & (UINT8) ~EFI_ACPI_IRQ_POLARITY_MASK) !=3D 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_SH= ARABLE_MASK)) !=3D 0) { + // Invalid Decode value + DEBUG ((DEBUG_ERROR, "%a: ERROR: Shared '%x' is not valid.\n", __func_= _, Shared)); + return EFI_INVALID_PARAMETER; + } + + if (ListHead =3D=3D NULL) { + // Invalid + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot = =3D=3D NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Cannot create %a object.", __func__, = "IRQ_RESOURCE")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_IRQ_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Alloc for %a failed\n", __func__, "IR= Q_RESOURCE")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_IRQ_DESCRIPTOR *)Object->Data; + Descriptor->Header.Byte =3D ACPI_IRQ_DESCRIPTOR; + Descriptor->Mask =3D InterruptList; + // + // Ref 6.4.2.1 IRQ Descriptor - IRQ Information + // Descriptor->Information bit mask: + // IRQ Information. Each bit, when set, indicates this device is capabl= e of + // driving a certain type of interrupt. (Optional-if not included then= assume + // edge sensitive, high true interrupts.) These bits can be used both f= or + // reporting and setting IRQ resources. + // Note: This descriptor is meant for describing interrupts that are co= nnected + // to PIC-compatible interrupt controllers, which can only be program= med + // for Active-High-Edge-Triggered or Active-Low-LevelTriggered interr= upts. + // Any other combination is invalid. The Extended Interrupt Descripto= r can + // be used to describe other combinations. + // + // Bit [7:6] Reserved (must be 0) + // Bit [5] Wake Capability, _WKC + // 0x0 =3D Not Wake Capable: This interrupt is not capable of waking t= he system. + // 0x1 =3D Wake Capable: This interrupt is capable of waking the syste= m from a + // low-power idle state or a system sleep state. + // Bit [4] Interrupt Sharing, _SHR + // 0x0 =3D Exclusive: This interrupt is not shared with other devices. + // 0x1 =3D 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 i= n signal state from + // low to high. + // + Descriptor->Information =3D (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 =3D 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, Des= criptorName) =3D> 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 De= code16 + 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 AddressAli= gnment. + The field DescriptorName._MIN is automatically created to refer to t= his + 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 AddressAli= gnment. + The field DescriptorName._MAX is automatically created to refer to t= his + portion of the resource descriptor. + + AddressAlignment: + Evaluates to an 8-bit integer that specifies the alignment granulari= ty + for the I/O address assigned. The field DescriptorName. _ALN is auto= matically + 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 t= o refer + to this portion of the resource descriptor. + + DescriptorName: + An optional argument that specifies a name for an integer constant t= hat + will be created in the current scope that contains the offset of thi= s + resource descriptor within the current resource template buffer. The + predefined descriptor field names may be appended to this name to ac= cess + individual fields within the descriptor via the Buffer Field operato= rs. + + Description: + The IO macro evaluates to a buffer which contains an IO resource descr= iptor. + 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 R= esourceTemplate. + + Generates: + 6.4.2.5 I/O Port Descriptor + Type 0, Small Item Name 0x8, Length =3D 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 IM= PLEMENTED + 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) !=3D 0) { + // Invalid Decode value + DEBUG ((DEBUG_ERROR, "%a: ERROR: Decode '%x' is not valid.\n", __func_= _, Decode)); + return EFI_INVALID_PARAMETER; + } + + if (ListHead =3D=3D NULL) { + // Invalid + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot = =3D=3D NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if (AddressAlignment !=3D 0) { + DivU64x64Remainder (AddressMin, AddressAlignment, &Remainder); + if (Remainder !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMin=3D0x%X) is not a multip= le of\n", __func__, AddressMin)); + DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=3D0x%X\n", __fun= c__, AddressAlignment)); + return EFI_INVALID_PARAMETER; + } + + DivU64x64Remainder (AddressMax, AddressAlignment, &Remainder); + if (Remainder !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: (AddressMax=3D0x%X) is not a multip= le of\n", __func__, AddressMax)); + DEBUG ((DEBUG_ERROR, "%a: (AddressAlignment)=3D0x%X\n", __fun= c__, AddressAlignment)); + return EFI_INVALID_PARAMETER; + } + } + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func_= _, "IO_RESOURCE")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_IO_PORT_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "IO_RES= OURCE")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_IO_PORT_DESCRIPTOR *)Object->Data; + + /* + * According to ACPI spec for + * ACPI_IO_PORT_DESCRIPTOR =3D 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 =3D 0x47 (01000111B) - Type =3D 0, S= mall item name =3D + * 0x8, Length =3D 7 + */ + Descriptor->Header.Byte =3D 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 =3D (UINT8)(EFI_ACPI_IO_DECODE_MASK & Decode)= ; + Descriptor->BaseAddressMin =3D AddressMin; + Descriptor->BaseAddressMax =3D AddressMax; + Descriptor->Alignment =3D AddressAlignment; + Descriptor->Length =3D RangeLength; + Object->Completed =3D 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 Regi= ster + 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=3D0x%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=3D0x%02X\= n", __func__, AddressSpaceKeyword)); + return EFI_INVALID_PARAMETER; + } + + if (AccessSize > EFI_ACPI_6_4_QWORD) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid AccessSize=3D0x%02X\n", __fun= c__, AccessSize)); + return EFI_INVALID_PARAMETER; + } + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a cannot create %a object.", __func_= _, "IO_RESOURCE")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "IO_RES= OURCE")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR *)Object->Data; + + Descriptor->Header.Header.Byte =3D ACPI_GENERIC_REGISTER_DESCRIPTOR; + Descriptor->Header.Length =3D sizeof (EFI_ACPI_GENERIC_REGISTER_DES= CRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + Descriptor->AddressSpaceId =3D AddressSpaceKeyword; + Descriptor->RegisterBitWidth =3D RegisterBitWidth; + Descriptor->RegisterBitOffset =3D RegisterBitOffset; + Descriptor->AddressSize =3D AccessSize; + Descriptor->RegisterAddress =3D RegisterAddress; + Object->Completed =3D 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 =3D 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 t= o 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 add= ress + of the memory range. The 32-bit field DescriptorName. _BAS is automati= cally + created to refer to this portion of the resource descriptor. + + RangeLength: Evaluates to a 32-bit integer that specifies the total nu= mber of + bytes decoded in the memory range. The 32-bit field DescriptorName. _L= EN is + automatically created to refer to this portion of the resource descrip= tor. + + DescriptorName: Is an optional argument that specifies a name for an i= nteger + constant that will be created in the current scope that contains the o= ffset + of this resource descriptor within the current resource template buffe= r. The + predefined descriptor field names may be appended to this name to acce= ss + 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 for= mat 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 ResourceTempl= ate. + + 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 wit= hin 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 de= scriptor + + @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) !=3D 0) = { + // Invalid ReadAndWrite value + DEBUG ((DEBUG_ERROR, "%a: ERROR: ReadAndWrite '%x' is not valid.\n", _= _func__, ReadAndWrite)); + return EFI_INVALID_PARAMETER; + } + + if (ListHead =3D=3D NULL) { + // Invalid + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid parameter, ListHead cannot = =3D=3D NULL.\n", __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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 =3D sizeof (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRIPT= OR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "MEMORY= _32_FIXED_RESOURCE")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_32_BIT_FIXED_MEMORY_RANGE_D= ESCRIPTOR *)Object->Data; + Descriptor->Header.Header.Byte =3D ACPI_32_BIT_FIXED_MEMORY_RANGE_DESCRI= PTOR; + Descriptor->Header.Length =3D sizeof (EFI_ACPI_32_BIT_FIXED_MEMORY_= RANGE_DESCRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + Descriptor->Information =3D ReadAndWrite; + Descriptor->BaseAddress =3D AddressBase; + Descriptor->Length =3D RangeLength; + Object->Completed =3D 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 =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges =3D 0 =3D Reserved\n", __fu= nc__)); + return EFI_INVALID_PARAMETER; + } else if (ISARanges > 3) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__= )); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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, AddressMa= ximum, + AddressTranslation, RangeLength, ResourceSourceIndex, + ResourceSource, DescriptorName, MemoryRangeType, Translatio= nType) + + 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) !=3D 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) !=3D 0) = { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Invalid ReadAndWrite Parameter\n", __= func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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 Descript= or + + @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) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid ResourceUsage Parameter\= n", __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((Decode & ~EFI_ACPI_GENERAL_FLAG_MASK_DEC) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid Decode Parameter\n", __f= unc__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMinFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MIF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMinFixed Parameter\n",= __func__)); + return EFI_INVALID_PARAMETER; + } + + if ((IsMaxFixed & ~EFI_ACPI_GENERAL_FLAG_MASK_MAF) !=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Word Invalid IsMaxFixed Parameter\n",= __func__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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 =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Start %a object\n", __func__, "WORD_A= DDRESS")); + goto Done; + } + + Object->DataSize =3D sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a Alloc Failed\n", __func__, "DWORD_= ADDRESS")); + Status =3D EFI_OUT_OF_RESOURCES; + goto Done; + } + + Descriptor =3D (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPT= OR *)Object->Data; + Descriptor->Header.Header.Byte =3D ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR; + Descriptor->Header.Length =3D sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_D= ESCRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + Descriptor->ResType =3D ResourceType; + Descriptor->GenFlag =3D IsMinFixed | IsMaxFixed | Decode; + Descriptor->SpecificFlag =3D TypeSpecificFlags; + Descriptor->AddrSpaceGranularity =3D AddressGranularity; + Descriptor->AddrRangeMin =3D AddressMinimum; + Descriptor->AddrRangeMax =3D AddressMaximum; + Descriptor->AddrTranslationOffset =3D AddressTranslation; + Descriptor->AddrLen =3D RangeLength; + Object->Completed =3D 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 Descript= or + + @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 =3D 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 =3D 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, TranslationDens= ity) + + 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 =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges =3D 0 =3D Reserved\n", __fu= nc__)); + return EFI_INVALID_PARAMETER; + } else if (ISARanges > 3) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: ISARanges > 3 is Invalid\n", __func__= )); + return EFI_INVALID_PARAMETER; + } + + Status =3D 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/AmlSta= tementOpcodes.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/A= mlStatementOpcodes.c new file mode 100644 index 0000000000..03201d0109 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/AmlStatementO= pcodes.c @@ -0,0 +1,515 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 b= e + supported and must be created with Else and If. + + DefElse :=3D Nothing | + ElseOp :=3D 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 aft= er + 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, "Else", ListHead); + + // Start required PkgLength + Status =3D 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 =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, "Else", Lis= tHead); + 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 =3D 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 =3D=3D NULL) || (ChildObject->DataSize =3D=3D= 0)) { + Status =3D 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 =3D AllocatePool (ChildObject->DataSize + 1); + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=3DReturn\n", __fu= nc__)); + goto Done; + } + + // Fill out Return object + Object->Data[0] =3D AML_ELSE_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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 Pha= se + + Since ElseIf (...) is created with Else {( If (){})}. ElseIf will not b= e + supported and must be created with Else and If. + + DefIfElse :=3D IfOp PkgLength Predicate TermList DefElse + IfOp :=3D 0xA0 + Predicate :=3D TermArg =3D> 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, "If", ListHead); + + // Start required PkgLength + Status =3D 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 =3D 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 =3D InternalAmlLocateObjectByIdentifier (&Object, "If", ListH= ead); + 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 =3D 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 =3D=3D NULL) || (ChildObject->DataSize =3D=3D= 0)) { + Status =3D 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 =3D AllocatePool (ChildObject->DataSize + 1); + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=3DReturn\n", __fu= nc__)); + goto Done; + } + + // Fill out Return object + Object->Data[0] =3D AML_IF_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D EFI_DEVICE_ERROR; + break; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + InternalFreeAmlObject (&ChildObject, ListHead); + } + + return Status; +} + +/** + Creates a Notify object + + DefNotify :=3D NotifyOp NotifyObject NotifyValue + NotifyOp :=3D 0x86 + NotifyObject :=3D SuperName =3D> ThermalZone | Processor | Device + NotifyValue :=3D TermArg =3D> 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 =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + Status =3D InternalAppendNewAmlObject (&Object, NotifyObject, ListHead); + Status =3D AmlOPNameString (NotifyObject, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyObject NameStri= ng\n", __func__)); + goto Done; + } + + Status =3D AmlOPDataInteger (NotifyValue, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Failed creating NotifyValue Integer\n= ", __func__)); + goto Done; + } + + Status =3D InternalAmlLocateObjectByIdentifier (&Object, NotifyObject, L= istHead); + 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 =3D 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 =3D AllocatePool (ChildObject->DataSize + 1); + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=3DReturn\n", __func__= )); + goto Done; + } + + // Fill out Return object + Object->Data[0] =3D AML_NOTIFY_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D 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 :=3D ReturnOp ArgObject + ReturnOp :=3D 0xA4 + ArgObject :=3D TermArg =3D> DataRefObject + + @param[in] Phase - Either AmlStart or AmlClose + @param[in,out] ListHead - Linked list has completed String Object afte= r + 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 >=3D AmlInvalid) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, "Return", ListHead); + // DataRefObject is outside the scope of this object + break; + case AmlClose: + // DataRefObject should be closed already + Status =3D InternalAmlLocateObjectByIdentifier (&Object, "Return", L= istHead); + 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 =3D 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 =3D=3D NULL) || (ChildObject->DataSize =3D=3D= 0)) { + // Return without arguments is treated like Return(0) + // Zeroed byte =3D ZeroOp + ChildObject->Data =3D AllocateZeroPool (sizeof (UINT8)); + if (ChildObject->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Zero Child for Return\= n", __func__)); + goto Done; + } + + ChildObject->DataSize =3D 1; + } + + // Allocate buffer for Return object + Object->Data =3D AllocatePool (ChildObject->DataSize + 1); + Object->DataSize =3D ChildObject->DataSize + 1; + if (Object->Data =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocate Object=3DReturn\n", __fu= nc__)); + goto Done; + } + + // Fill out Return object + Object->Data[0] =3D AML_RETURN_OP; + CopyMem ( + &Object->Data[1], + ChildObject->Data, + ChildObject->DataSize + ); + InternalFreeAmlObject (&ChildObject, ListHead); + Object->Completed =3D TRUE; + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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/AmlTab= le.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#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 :=3D TableSignature TableLength SpecCompliance CheckSum = OemID + OemTableID OemRevision CreatorID CreatorRevision + + TableSignature :=3D DWordData // As defined in section 5.2.3. + TableLength :=3D DWordData // Length of the table in bytes incl= uding the + // block header + SpecCompliance :=3D ByteData // The revision of the structure. + CheckSum :=3D ByteData // Byte checksum of the entire table= . + OemID :=3D ByteData(6) // OEM ID of up to 6 characters. + // If the OEM ID is shorter than 6 + // characters, it can be terminated wi= th a + // NULL character. + OemTableID :=3D ByteData(8) // OEM Table ID of up to 8 character= s. + // If the OEM Table ID is shorter than + // 8 characters, it can be terminated = with + // a NULL character. + OemRevision :=3D DWordData // OEM Table Revision. + CreatorID :=3D DWordData // Vendor ID of the ASL compiler. + CreatorRevision :=3D 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 Objec= t 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 >=3D AmlInvalid) || + (ListHead =3D=3D NULL) || + (TableNameString =3D=3D NULL) || + (OemId =3D=3D NULL) || + (OemTableId =3D=3D NULL) || + (CreatorId =3D=3D NULL) || + (AsciiStrLen (TableNameString) !=3D SIGNATURE_LENGTH) || + (AsciiStrLen (OemId) > OEM_ID_LENGTH) || + (AsciiStrLen (OemTableId) > OEM_TABLE_ID_LENGTH) || + (AsciiStrLen (CreatorId) !=3D CREATOR_ID_LENGTH)) + { + return EFI_INVALID_PARAMETER; + } + + Status =3D EFI_DEVICE_ERROR; + Object =3D NULL; + ChildObject =3D NULL; + + switch (Phase) { + case AmlStart: + Status =3D InternalAppendNewAmlObject (&Object, TableNameString, Lis= tHead); + // TermList is too complicated and must be added outside + break; + + case AmlClose: + // TermList should be closed already + Status =3D InternalAmlLocateObjectByIdentifier (&Object, TableNameSt= ring, ListHead); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: locate %a object\n", __func__, Ta= bleNameString)); + goto Done; + } + + // Get rid of original Identifier data + InternalFreeAmlObjectData (Object); + + // Collect child data and delete children + Status =3D InternalAmlCollapseAndReleaseChildren ( + &ChildObject, + &ChildCount, + &Object->Link, + ListHead + ); + if (EFI_ERROR (Status) || + (ChildObject->Data =3D=3D NULL) || + (ChildObject->DataSize =3D=3D 0)) + { + DEBUG ((DEBUG_ERROR, "%a: ERROR: %a has no child data.\n", __func_= _, TableNameString)); + goto Done; + } + + Object->DataSize =3D ChildObject->DataSize + sizeof (EFI_ACPI_DESCRI= PTION_HEADER); + Object->Data =3D AllocateZeroPool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + Status =3D 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)] =3D = 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, CreatorRevis= ion)], + (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 =3D TRUE; + Status =3D EFI_SUCCESS; + break; + + default: + Status =3D 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/LocalA= mlObjects.c b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/Local= AmlObjects.c new file mode 100644 index 0000000000..b1ad9b7037 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/DxeAmlGenerationLib/LocalAmlObjec= ts.c @@ -0,0 +1,364 @@ +/** @file + + Copyright (C) 2020-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "LocalAmlLib.h" +#include + +#define FILECODE LIBRARY_DXEAMLGENERATIONLIB_LOCALAMLOBJECTS_FILECODE + +/** + Free Object->Data + + Frees Object->Data, Nulls pointer, zeros size and marks + Object->Completed =3D FALSE + + @param [in] Object - Pointer to Object to have Data freed + + @return EFI_SUCCESS - Object Freed + @return - Object free failed +**/ +EFI_STATUS +EFIAPI +InternalFreeAmlObjectData ( + IN AML_OBJECT_INSTANCE *Object + ) +{ + if (Object =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Object->Data !=3D NULL) { + FreePool (Object->Data); + Object->Data =3D NULL; + Object->DataSize =3D 0; + Object->Completed =3D FALSE; + } + + return EFI_SUCCESS; +} + +/** + Free an Object + + Removes Object from it's linked list. + Frees Object->Data + Frees Object + + @param [in] Object - Pointer to Object to be freed + @param [in,out] ListHead - Head of AML Object linked list + + @return EFI_SUCCESS - Object Freed + @return - Object free failed +**/ +EFI_STATUS +EFIAPI +InternalFreeAmlObject ( + IN AML_OBJECT_INSTANCE **FreeObject, + IN OUT LIST_ENTRY *ListHead + ) +{ + AML_OBJECT_INSTANCE *Object; + + if ((FreeObject =3D=3D NULL) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Object =3D *FreeObject; + if (Object !=3D NULL) { + InternalFreeAmlObjectData (Object); + if (IsNodeInList (ListHead, &Object->Link)) { + RemoveEntryList (&Object->Link); + } + + FreePool (Object); + } + + *FreeObject =3D 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 li= st + @return - Object creation failed, Object =3D NULL +**/ +EFI_STATUS +EFIAPI +InternalNewAmlObjectNoData ( + OUT AML_OBJECT_INSTANCE **ReturnObject + ) +{ + AML_OBJECT_INSTANCE *Object; + + if (ReturnObject =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + *ReturnObject =3D NULL; + + // Allocate AML Object + Object =3D AllocateZeroPool (sizeof (AML_OBJECT_INSTANCE)); + if (Object =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Allocate Object Failed\n", __func__))= ; + return EFI_OUT_OF_RESOURCES; + } + + Object->DataSize =3D 0; + Object->Data =3D NULL; + Object->Signature =3D AML_OBJECT_INSTANCE_SIGNATURE; + + *ReturnObject =3D 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 li= st + @return - Object creation failed, Object =3D NULL +**/ +EFI_STATUS +EFIAPI +InternalAppendNewAmlObjectNoData ( + OUT AML_OBJECT_INSTANCE **ReturnObject, + IN OUT LIST_ENTRY *ListHead + ) +{ + EFI_STATUS Status; + AML_OBJECT_INSTANCE *Object; + + if ((ListHead =3D=3D NULL) || (ReturnObject =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D InternalNewAmlObjectNoData (&Object); + if (!EFI_ERROR (Status)) { + InsertTailList (ListHead, &Object->Link); + *ReturnObject =3D 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 li= st + @return - Object creation failed, Object =3D 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 =3D=3D NULL) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Object =3D NULL; + + Status =3D InternalAppendNewAmlObjectNoData (&Object, ListHead); + if (EFI_ERROR (Status)) { + return EFI_OUT_OF_RESOURCES; + } + + // Allocate Identifier Data + NULL termination + Object->DataSize =3D AsciiStrLen (Identifier) + 1; + Object->Data =3D AllocatePool (Object->DataSize); + if (Object->Data =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: Allocate Data Identifier=3D%a\n", __f= unc__, Identifier)); + InternalFreeAmlObject (&Object, ListHead); + return EFI_OUT_OF_RESOURCES; + } + + CopyMem (Object->Data, Identifier, Object->DataSize); + + *ReturnObject =3D Object; + return EFI_SUCCESS; +} + +/** + Finds AML_OBJECT_INSTANCE given a string Identifier looking backwards in= the + AML_OBJECT_INSTANCE linked list + + @param [out] ReturnObject - Pointer to an Object + @param [in] Identifier - String Identifier to create object with + @param [in] ListHead - Head of AML Object linked list + + @return EFI_SUCCESS - Object located and returned + @return - Object creation failed, Object =3D 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 =3D=3D NULL) || (ListHead =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Object =3D NULL; + *ReturnObject =3D NULL; + + IdentifierSize =3D AsciiStrLen (Identifier) + 1; + // Look Backwards and find Node for this Object + Node =3D ListHead; + do { + Node =3D GetPreviousNode (ListHead, Node); + Object =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + + if (Object->Completed) { + // Object to be found cannot be completed yet + continue; + } else { + if ((Object->DataSize !=3D 0) && + (Object->DataSize =3D=3D IdentifierSize) && + (CompareMem ( + Object->Data, + Identifier, + MAX (Object->DataSize, IdentifierSize) + ) =3D=3D 0)) + { + *ReturnObject =3D 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 !=3D ListHead); + + *ReturnObject =3D 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 chil= dren + @param [in,out] ListHead - Head of Object Linked List + + @return EFI_SUCCESS - ChildObject created and returned + @return - Object creation failed, Object =3D 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 =3D EFI_SUCCESS; + if ((ReturnObject =3D=3D NULL) || + (ChildCount =3D=3D NULL) || + (Link =3D=3D NULL) || + (ListHead =3D=3D NULL)) + { + return EFI_INVALID_PARAMETER; + } + + *ChildCount =3D 0; + + Status =3D InternalNewAmlObjectNoData (&Object); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: ERROR: allocating Object Data\n", __func__))= ; + goto Done; + } + + // Get first Child Node + Node =3D GetNextNode (ListHead, Link); + while (Node !=3D ListHead) { + ChildObject =3D AML_OBJECT_INSTANCE_FROM_LINK (Node); + // Expand data buffer to fit existing data + new data + TempBuffer =3D ReallocatePool ( + Object->DataSize, + Object->DataSize + ChildObject->DataSize, + Object->Data + ); + if (TempBuffer =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + FreePool (Object->Data); + Object->Data =3D NULL; + DEBUG ((DEBUG_ERROR, "%a: ERROR: reallocating Object Data\n", __func= __)); + goto Done; + } + + Object->Data =3D TempBuffer; + // Copy new data at end of buffer + CopyMem ( + &Object->Data[Object->DataSize], + ChildObject->Data, + ChildObject->DataSize + ); + Object->DataSize +=3D ChildObject->DataSize; + // Get Next ChildObject Node, then free ChildObject from list + Node =3D GetNextNode (ListHead, Node); + InternalFreeAmlObject (&ChildObject, ListHead); + *ChildCount =3D *ChildCount + 1; + } + +Done: + if (EFI_ERROR (Status)) { + InternalFreeAmlObject (&Object, ListHead); + Object =3D NULL; + } + + *ReturnObject =3D 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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +/*------------------------------------------------------------------------= ---------------- + * M O D U L E S U S E D + *------------------------------------------------------------------------= ---------------- + */ +#include diff --git a/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchB= aseResetSystemLib.c b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSyste= mLib/FchBaseResetSystemLib.c new file mode 100644 index 0000000000..60305ee4a6 --- /dev/null +++ b/Platform/AMD/AgesaModulePkg/Library/FchBaseResetSystemLib/FchBaseRese= tSystemLib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** + 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 shut= down 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 f= eature. +**/ +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 Reset= Data + the platform must pick a supported reset type to perform.The platform ma= y + 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 str= ing, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData + ) +{ +} diff --git a/Platform/AMD/AgesaModulePkg/Library/FchEspiCmdLib/FchEspiCmdLi= b.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +/*------------------------------------------------------------------------= ----------------*/ + +/** + * @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/NbioHandleLi= b.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include + +/** + 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 =3D 0; + return PciAddr; +} diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieConfigLi= b.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include + +/** + 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 informat= ion to callback + @param[in] Pcie Pointer to global PCIe configurati= on +**/ +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 t= o 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 t= o 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 t= o 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 t= o 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 t= o 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 descript= or +**/ +VOID +PcieUserConfigConfigDump ( + IN PCIE_COMPLEX_DESCRIPTOR *ComplexDescriptor + ) +{ +} diff --git a/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputPar= serLib.c b/Platform/AMD/AgesaModulePkg/Library/PcieConfigLib/PcieInputParse= rLib.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Get number of complexes in platform topology configuration + + @param[in] ComplexList First complex configuration in complex configura= tion 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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include diff --git a/Platform/AMD/AgesaModulePkg/Nbio/Library/CommonDxe/DxeLibFunct= ions.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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include + +/** + 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= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + * @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/OemAgesaC= cxPlatformLibNull/OemAgesaCcxPlatformLibNull.c new file mode 100644 index 0000000000..74b129931b --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Ccx/OemAgesaCcxPlatformLibNull/OemAges= aCcxPlatformLibNull.c @@ -0,0 +1,39 @@ +/** @file + Required OEM hooks for CCX initialization + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Hook to store the vector that all APs should jump to out of reset to a n= on-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 s= torage + +**/ +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/P= ciExpressPciCfg2.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressP= ciCfg2/PciExpressPciCfg2.c new file mode 100644 index 0000000000..54ce202cb1 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciCfg2/PciExpre= ssPciCfg2.c @@ -0,0 +1,33 @@ +/** @file + + Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +/** + 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/PciExpressPciSegmen= tInfoLib/PciSegmentInfoLib.c b/Platform/AMD/AgesaPkg/Addendum/PciSegments/P= ciExpressPciSegmentInfoLib/PciSegmentInfoLib.c new file mode 100644 index 0000000000..643174d7b9 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/PciSegments/PciExpressPciSegmentInfoLi= b/PciSegmentInfoLib.c @@ -0,0 +1,30 @@ +/** @file + + Copyright (C) 2018-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** + 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/AmdPspFla= shAccSpiNorLibSmm/AmdPspFlashAccSpiNorLibSmm.c new file mode 100644 index 0000000000..d83bb6c2d8 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Psp/AmdPspFlashAccSpiNorLibSmm/AmdPspF= lashAccSpiNorLibSmm.c @@ -0,0 +1,15 @@ +/** @file + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/Psp= RomArmorWhitelistLib.c b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhit= elistLib/PspRomArmorWhitelistLib.c new file mode 100644 index 0000000000..a264eb9294 --- /dev/null +++ b/Platform/AMD/AgesaPkg/Addendum/Psp/PspRomArmorWhitelistLib/PspRomArmo= rWhitelistLib.c @@ -0,0 +1,12 @@ +/** @file + Platform ROM Armor Whitelist table + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/OobPprDxe/OobPprDxe.c b/Pl= atform/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.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** +* This function installs a protocol used by platform BIOS to provide the h= otplug 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/Psp= PlatformDriver/PspPlatformDriver.c new file mode 100644 index 0000000000..5242e6261a --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/PspPlatformDriver/PspP= latformDriver.c @@ -0,0 +1,20 @@ +/** @file + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include + +EFI_STATUS +EFIAPI +PspPlatformEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDx= e/ServerHotplugDxe.c b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/Serve= rHotplugDxe/ServerHotplugDxe.c new file mode 100644 index 0000000000..530bd9d4b6 --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Addendum/Oem/Quartz/Dxe/ServerHotplugDxe/Serve= rHotplugDxe.c @@ -0,0 +1,22 @@ +/** @file + + Copyright (C) 2008-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include + +EFI_STATUS +EFIAPI +HotplugDescEntry ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDy= namicCommand.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAu= toDynamicCommand.c new file mode 100644 index 0000000000..fbc372586b --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoDynamicCo= mmand.c @@ -0,0 +1,44 @@ +/** @file + + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +/** + Entry point of Act Dynamic Command. + + Produce the DynamicCommand protocol to handle "act" command. + + @param ImageHandle The image handle of the process. + @param SystemTable The EFI System Table pointer. + + @retval EFI_SUCCESS Act command is executed sucessfully. + @retval EFI_ABORTED HII package was failed to initialize. + @retval others Other errors when executing act command. +**/ +EFI_STATUS +EFIAPI +ActCommandInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_SUCCESS; +} + +/** + Destructor for the library. free any resources. + + @param ImageHandle The image handle of the process. + @param SystemTable The EFI System Table pointer. +**/ +EFI_STATUS +EFIAPI +ActLibraryUnregisterActCommand ( + IN EFI_HANDLE ImageHandle + ) +{ + return EFI_SUCCESS; +} diff --git a/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoTo= olApp.c b/Platform/AMD/AmdCpmPkg/Library/AmdAutoDynamicCommand/AmdAutoToolA= pp.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= .
+ + 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/BasePlatformHookLibAm= dFchUart/BasePlatformHookLibAmdFchUart.c b/Platform/AMD/AmdCpmPkg/Library/C= ommonLib/BasePlatformHookLibAmdFchUart/BasePlatformHookLibAmdFchUart.c new file mode 100644 index 0000000000..47eb700f8f --- /dev/null +++ b/Platform/AMD/AmdCpmPkg/Library/CommonLib/BasePlatformHookLibAmdFchUar= t/BasePlatformHookLibAmdFchUart.c @@ -0,0 +1,29 @@ +/** @file + + Copyright (C) 2016-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +/** + Performs platform specific initialization required for the CPU to access + the hardware associated with a SerialPortLib instance. This function do= es + 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 succee= ded. + @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/FchSon= gshanI2C_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/FchSongshanI2= C_I3C.asl @@ -0,0 +1,9 @@ +/** @file + + Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved= .
+ + 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 reserve= d.
+; +; 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 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-