From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.68]) by mx.groups.io with SMTP id smtpd.web11.6795.1685064719604337282 for ; Thu, 25 May 2023 18:31:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=1kAo8PZX; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.244.68, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mghgqyq5ILIqCXueOLH8/GiQ6GmNPa2SA+cfL/tOSdZBeSGj0IfkvPeugp/Xhz+FcDAU5Wqkh34ymAJA87SEhf2cvBzL6Zfax9sWkL36i5PH7tYJykxOnZzUUvV3fvL0bdFYAR6NOkdvl1WWl6Zoa0irBUc+zbn4xj89QgzNCVaaIFdqalQvcQdP1uu6pYDH2Qe2RXkid9zlH0zTWdrj7uGEvG9SmPvsFtDtWe5l1I4qnTk4bZtPCRB018WuQT7mE08pnauudmyjDIQnvTevTV8K/MW9D5KqOfcyzh1DmpPJ2e+HB1UQ0vkCcYd2FIw2+046l3RgvJnkGxjI1bwxYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q1DA0+UPT/2pnL6QWEFfCwcC7RRAMQs8bPzH1jIc0h8=; b=TNOcYbfvE1L9vfvBn6vR+3OrZrKxLx+urUM43qNdBwvhm9nCtQxObkam7sTEcnYsy81BOkroKMSE7qrN+yw6j/LQiJHL54ZX4gB4YbOQj4qiy1K24smk4dAzUOmGw965hXHJif4e4U2Sla7q/0wkz8zinsV3Gz5nEoknrVL2qCF9KmdHBhmLbGtD3d3nSr4oDbG14iPClHd9hSdbOP4rkJwJHxZ2wh/UQXiyflkGViehIJptd4ssXQFK5shzlJrKrJrg+2A2ShwFVwoJh7uL+95u0XxG0RGsbCz/DnT0PlKCo0c19Kt0O0Xi30tprjXH3b3QK3C+tHHZn3mtcZLLVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q1DA0+UPT/2pnL6QWEFfCwcC7RRAMQs8bPzH1jIc0h8=; b=1kAo8PZXyexvWZThB79FMNFb2PmiAeBnY1YZnoQvEbdfhmW5MqJTiXXkqa0EOz8c0NAndNdcvsSaeZm50Lz5a349HKsmOhQpkdBXRz+ltrNoMHZRSbYkveTWiUruEW4IxPmyNDwjycr7EyfAf+CScXFVSKeYpsgHq6eRf1HoaMs= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by DS7PR12MB8229.namprd12.prod.outlook.com (2603:10b6:8:ea::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.16; Fri, 26 May 2023 01:31:56 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::edb0:bed8:c650:5040%6]) with mapi id 15.20.6433.017; Fri, 26 May 2023 01:31:56 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "Attar, AbdulLateef (Abdul Lateef)" Subject: Re: [edk2-devel] [PATCH 1/1] AMD/AmdMinBoardPkg: Implements PCI hotplug init protocol Thread-Topic: [edk2-devel] [PATCH 1/1] AMD/AmdMinBoardPkg: Implements PCI hotplug init protocol Thread-Index: AQHZjGES2y7i/pvsSkWcamG8NeSLVq9rycbA Date: Fri, 26 May 2023 01:31:56 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=306834b1-b0a8-474c-9889-60bed940e2e0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-05-26T01:27:42Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|DS7PR12MB8229:EE_ x-ms-office365-filtering-correlation-id: c9cada11-c0a5-4808-ffd6-08db5d88fe45 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: znLtV5m85/UakikP02T/2Bb6E5ue939Axbp+iVvGz7/eOnXa8YjgtOhy7M/OdBesOV/68e/ipZGXh1PBHn6hAHlKknmiMqMyeJK9gIJsyhf9ukKgITe1fa66VXF7sKEzgTfAv2nBRK7L/QXJTti1//e4T5+/rfqQl8hrK0wEOoL/aKYjnOJM1MLln4LRqqZAg3792CbXRA6De2IZKXURmVYIaEPmOiK4Q0Ao7VCLsdVrbrZH8BTJ6wjAnN8QQ5vAl0H4vVlJuWLsCbMfMBWlNMt4uX4b7LRxew6ISUluijlQnHIxXIs3w3SCzMeUdmcskXUq8oY4l1T24Lt/6J2bt6V3PLlxvPduElKBqwuCbUowzmb137hTD8ySFvSURhK6kje3a184ByqDVVwUJOZqUMhT96FlYA5Y1IjvvDdK2zaqCoG/nOg5vOXRuorWk9JLTfr3BWJttJwpSygBTI1eK66oFfZzHIAXDPoMEO1lFQ0yNzWLvzv4htZAsNjbZKShyECMHHWjsY69birqG3+7XRgrw8WreSQ+o81fsEAERkg1kTn5XXy0gLWjXjZK50I1JphOKAC5cMert7+h/74huPV8mRQeEIT9p9EluvG6kVEv5lPyw4V4UIPE7OhcODNb x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(376002)(39860400002)(136003)(346002)(451199021)(66899021)(966005)(66476007)(66946007)(66556008)(66446008)(64756008)(76116006)(478600001)(6636002)(110136005)(316002)(33656002)(86362001)(55016003)(38070700005)(83380400001)(9686003)(6506007)(186003)(53546011)(26005)(41300700001)(5660300002)(8676002)(8936002)(52536014)(2906002)(30864003)(71200400001)(7696005)(38100700002)(122000001)(579004)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Mye0++cgXM14D9psQv7m0vujZ1TbYaJranVZv3QrAvRQXzRmaXuPG42YSwwB?= =?us-ascii?Q?/rcGV2DuOeBmEvAxU3xb2w47SnB/utbVA1R4G85iC0o+Ynk65ZaS9MqEVn7A?= =?us-ascii?Q?IIH+IYBRAM8rlY6G2YjR7lxBaVgwgEJi5Ltgs8nH1lrB4YmwTyCt7/EKHjPV?= =?us-ascii?Q?bZTCicljFLJXIsPtFEg2azpBwUWk411LgMNbh69/aRHtpLVO7cV9L9EtqwrZ?= =?us-ascii?Q?/PCVn6cSJuIMa5jQ7E8oEimeJq917vskCrB+fpSQKh7e5RmDo7QHtwmKAwqC?= =?us-ascii?Q?rf9iWyoiUPZnq+x2qannE2/fSLks8C+k96/ViYgWlQvd7+eFCGDf+meJXeI+?= =?us-ascii?Q?n1ex207O7InxWifR+ElUWzf9LghxbelYnsXKESs6blyUtsppIm2+0o/ESG8k?= =?us-ascii?Q?fj750Cf1a/89LInWKktcKG5Twfa1f18qXVa5/Q9EK5w0TjOIZClFwKYDLQqx?= =?us-ascii?Q?6FTmt5gEXjup3pks8wQpLpVZd8z1XV+WYfBbJ+fHrFlIl7bw6umermW+qFv+?= =?us-ascii?Q?YlcTc74qNwn7cyo3xKbhxMZEAwEFWTD8pXMgumiC0mOyjpWaSbdzkrgQukxK?= =?us-ascii?Q?7Xxm8mzYTQikT5rs7ezouf0VoIBVN/AM285zwCqjxrJaXNW2p4egwwRRNOHY?= =?us-ascii?Q?bgfUycE6wVCdfNH0BEBEBPxYS7rlbejnOs/U0U7Pzd4S1+iDU/R7t7lHKfCq?= =?us-ascii?Q?AS8lVZuQ96hsYzK7mmNGtgFNVCThLXlw+VXyXYIaLikoNeTZogKccjiCFSqc?= =?us-ascii?Q?sb9yTJEKKjhh2Jq1pjzeqkJH/hai78EdbyDla7LlG4SW87xCGir+vOc+umiI?= =?us-ascii?Q?9flTepekBly6/lyyhB2b3FWOL9rE123lKXxtN79hw9o4W3ifPh8CtuywAtqP?= =?us-ascii?Q?yfqdTRjgLAQk6E1kJw8g6j2xBk3ORVyRkNWl26+rd0up9ashg8/Zi7DOW/G3?= =?us-ascii?Q?GDn2mtsf9rTTbT825nfQ23uSdXkQE7AKs6oAlFhr6J7tdYb89iu7BBIQKhCV?= =?us-ascii?Q?lp76M3gInszkEd6ZioUcHonPkgrA5sYibGj/IPjScmPNoyl/NLW5mcPp3yjO?= =?us-ascii?Q?aBgThJrXjbM8mJgNB95OuVAwv8NV9fh98wsI5bdgKnUQ6TtCBkDyuAhXaN1+?= =?us-ascii?Q?9K/5y2JAEhCYW6ih9FeBIho8UF3evWUGY//RvxToA+5/UnGhlmTvB5yDcOHk?= =?us-ascii?Q?a/HhVl+oZAjBDjmvINjRuZsmYjYM9p5pdzypT1tJyDMHQYHp6mBwwp5n7g37?= =?us-ascii?Q?euqSZqbtyObFsaPdeVMOvVN2IEzkgp0Z0vmAA1uIx2IMwyLAK/6Ngdx/cni4?= =?us-ascii?Q?e7yKSRQtoCVldLkp0jR3TwSjM2JK0nWtY65mF9SGN0GQmPTzRiucwveUz/iJ?= =?us-ascii?Q?LsG1vwcLRhx0yBkajiRZ+Oz4wZ61Ty8c0Afkg+c8/SJtLXeUAAJeFIkYbgkf?= =?us-ascii?Q?S11ifQeUNQ3AiibmZGp4KGhPcLfUeZSBI/1OhIctG1c16Lob5XtULKZOgHEz?= =?us-ascii?Q?avDRUI0YSiKTJ8HzgTCsm5BYIcS3rYt9NI41YcLKJgeuCTr9JcWlO2Bnl+At?= =?us-ascii?Q?++xg2o4y+ub0FlU6e/8=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9cada11-c0a5-4808-ffd6-08db5d88fe45 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2023 01:31:56.5693 (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: RUGg/uyTUa5+OREvCOPPPjGRxv2wCGtTvptPHS4j+pkWlW4hcxohZHhFGU1y0k8VcWwY/dbN5+as6Rz9DkG9hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8229 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Abdul, Is this change just a initial patch that clone PciHotPlugInit.c to under Am= dMIniBordPkg? Do we have AMD modification on this file? Because I don't see= AMD license in the file header. Just curious about why do we change the GUID of DSC file? Thanks Abner > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Abdul > Lateef Attar via groups.io > Sent: Monday, May 22, 2023 11:54 AM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Chang, > Abner > Subject: [edk2-devel] [PATCH 1/1] AMD/AmdMinBoardPkg: Implements PCI > hotplug init protocol > > Caution: This message originated from an External Source. Use proper caut= ion > when opening attachments, clicking links, or responding. > > > From: Abdul Lateef Attar > > Implements PCI hotplug init protocol. > Adds resources padding based on PCD values. > > Cc: Abner Chang > > Signed-off-by: Abdul Lateef Attar > --- > .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec | 16 + > .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc | 14 +- > .../PciHotPlug/PciHotPlugInit.inf | 39 +++ > .../PciHotPlug/PciHotPlugInit.c | 331 ++++++++++++++++++ > 4 files changed, 399 insertions(+), 1 deletion(-) > create mode 100755 > Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf > create mode 100755 > Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c > > diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec > b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec > index e37b02c4cf5a..65ba08545021 100644 > --- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec > +++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dec > @@ -17,3 +17,19 @@ [Defines] > PACKAGE_GUID =3D 44F9D761-9ECB-43DD-A5AC-177E5048701= B > PACKAGE_VERSION =3D 0.1 > > +[Guids] > + gAmdMinBoardPkgTokenSpaceGuid =3D {0xd4d23d79, 0x73bf, 0x460a, > {0xa1, 0xc7, 0x85, 0xa3, 0xca, 0x71, 0xb9, 0x4c}} > + > +[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx] > + # > + # PCI HotPlug Resource Padding > + # > + # PCI bus padding, number of bus to reserve, default 2 bus > + > gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus|2|UINT8 > |0x10000003 > + # IO Resource padding in bytes, default 4KB > + > gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadIo|0x000010 > 00|UINT32|0x10000000 > + # Non-PreFetch Memory padding in bytes, default 1MB > + > gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem|0x0010 > 0000|UINT32|0x10000002 > + # PreFetch Memory padding in bytes, default 2MB > + > gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem|0x002 > 00000|UINT32|0x10000001 > + > diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > index 273cd74f7842..1a8407250c56 100644 > --- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > +++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > @@ -9,7 +9,7 @@ > > [Defines] > DSC_SPECIFICATION =3D 1.30 > - PLATFORM_GUID =3D 88F8A9AE-2FA0-4D58-A6F9-05F635C05F4E > + PLATFORM_GUID =3D 939B559B-269B-4B8F-9637-44DF6575C1E2 > PLATFORM_NAME =3D AmdMinBoardPkg > PLATFORM_VERSION =3D 0.1 > OUTPUT_DIRECTORY =3D Build/$(PLATFORM_NAME) > @@ -25,6 +25,16 @@ [Packages] > [LibraryClasses] > SpcrDeviceLib|AmdMinBoardPkg/Library/SpcrDeviceLib/SpcrDeviceLib.inf > > +[LibraryClasses.common] > + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf > + > BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRe > pStr.inf > + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf > + > MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemor > yAllocationLib.inf > + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf > + > RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibN= ull.inf > + > UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo > tServicesTableLib.inf > + > UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryP > oint.inf > + > [LibraryClasses.common.PEIM] > > SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLi > b.inf > > @@ -34,3 +44,5 @@ [Components] > [Components.IA32] > AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf > > +[Components.X64] > + AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf > diff --git a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf > b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf > new file mode 100755 > index 000000000000..44564df38718 > --- /dev/null > +++ b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf > @@ -0,0 +1,39 @@ > +## @file > +# This driver implements EFI_PCI_HOT_PLUG_INIT_PROTOCOL. > +# Adds resource padding information, for PCIe hotplug purposes. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved > +# SPDX-License-Identifier: BSD-2-Clause-Patent ## > + > +[Defines] > + INF_VERSION =3D 1.29 > + BASE_NAME =3D PciHotPlugInit > + FILE_GUID =3D 85F78A6D-6438-4BCC-B796-759A48D00C7= 2 > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 0.1 > + ENTRY_POINT =3D PciHotPlugInitialize > + > +[Sources] > + PciHotPlugInit.c > + > +[Packages] > + AmdMinBoardPkg/AmdMinBoardPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + MemoryAllocationLib > + UefiBootServicesTableLib > + UefiDriverEntryPoint > + > +[Protocols] > + gEfiPciHotPlugInitProtocolGuid > + > +[Pcd] > + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus > + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadIo > + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem > + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem > + > +[Depex] > + TRUE > diff --git a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c > b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c > new file mode 100755 > index 000000000000..a26ca16741b8 > --- /dev/null > +++ b/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.c > @@ -0,0 +1,331 @@ > +/** @file > + This file declares EFI PCI Hot Plug Init Protocol. > + > + This protocol provides the necessary functionality to initialize the H= ot Plug > + Controllers (HPCs) and the buses that they control. This protocol also > provides > + information regarding resource padding. > + > + @par Note: > + This source has the reference of OVMF PciHotPluginit.c and Intel pla= tform > PciHotPlug.c. > + > + This protocol is required only on platforms that support one or more= PCI > Hot > + Plug* slots or CardBus sockets. > + > + The EFI_PCI_HOT_PLUG_INIT_PROTOCOL provides a mechanism for the PCI > bus enumerator > + to properly initialize the HPCs and CardBus sockets that require initi= alization. > + The HPC initialization takes place before the PCI enumeration process = is > complete. > + There cannot be more than one instance of this protocol in a system. T= his > protocol > + is installed on its own separate handle. > + > + Because the system may include multiple HPCs, one instance of this pro= tocol > + should represent all of them. The protocol functions use the device pa= th of > + the HPC to identify the HPC. When the PCI bus enumerator finds a root = HPC, > it > + will call EFI_PCI_HOT_PLUG_INIT_PROTOCOL.InitializeRootHpc(). If > InitializeRootHpc() > + is unable to initialize a root HPC, the PCI enumerator will ignore tha= t root > HPC > + and continue the enumeration process. If the HPC is not initialized, t= he > devices > + that it controls may not be initialized, and no resource padding will = be > provided. > + > + From the standpoint of the PCI bus enumerator, HPCs are divided into t= he > following > + two classes: > + > + - Root HPC: > + These HPCs must be initialized by calling InitializeRootHpc() du= ring the > + enumeration process. These HPCs will also require resource paddi= ng. The > + platform code must have a priori knowledge of these devices and = must > know > + how to initialize them. There may not be any way to access their= PCI > + configuration space before the PCI enumerator programs all the > upstream > + bridges and thus enables the path to these devices. The PCI bus > enumerator > + is responsible for determining the PCI bus address of the HPC be= fore it > + calls InitializeRootHpc(). > + - Nonroot HPC: > + These HPCs will not need explicit initialization during enumerat= ion > process. > + These HPCs will require resource padding. The platform code does= not > have > + to have a priori knowledge of these devices. > + > + Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> + Copyright (C) 2016, Red Hat, Inc.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > + > + @par Revision Reference: > + This Protocol is defined in UEFI Platform Initialization Specification= 1.2 > + Volume 5: Standards > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > + > +// > +// The protocol interface this driver produces. > +// > +STATIC EFI_PCI_HOT_PLUG_INIT_PROTOCOL mPciHotPlugInit; > + > +/** > + Returns a list of root Hot Plug Controllers (HPCs) that require initia= lization > + during the boot process. > + > + This procedure returns a list of root HPCs. The PCI bus driver must in= itialize > + these controllers during the boot process. The PCI bus driver may or m= ay > not be > + able to detect these HPCs. If the platform includes a PCI-to-CardBus b= ridge, > it > + can be included in this list if it requires initialization. The HpcLi= st must be > + self consistent. An HPC cannot control any of its parent buses. Only o= ne HPC > can > + control a PCI bus. Because this list includes only root HPCs, no HPC i= n the list > + can be a child of another HPC. This policy must be enforced by the > + EFI_PCI_HOT_PLUG_INIT_PROTOCOL. The PCI bus driver may not check for > such > + invalid conditions. The callee allocates the buffer HpcList > + > + @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL > instance. > + @param[out] HpcCount The number of root HPCs that were returned. > + @param[out] HpcList The list of root HPCs. HpcCount defines the num= ber > of > + elements in this list. > + > + @retval EFI_SUCCESS HpcList was returned. > + @retval EFI_INVALID_PARAMETER HpcCount is NULL or HpcList is NULL. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetRootHpcList ( > + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, > + OUT UINTN *HpcCount, > + OUT EFI_HPC_LOCATION **HpcList > + ) > +{ > + if ((HpcCount =3D=3D NULL) || (HpcList =3D=3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Platform BIOS not doing any extra/special HPC initialization > + // Hence returning the HpcCount as zero and HpcList as NULL > + // > + *HpcCount =3D 0; > + *HpcList =3D NULL; > + > + return EFI_SUCCESS; > +} > + > +/** > + Initializes one root Hot Plug Controller (HPC). This process may cause= s > + initialization of its subordinate buses. > + > + This function initializes the specified HPC. At the end of initializat= ion, > + the hot-plug slots or sockets (controlled by this HPC) are powered and= are > + connected to the bus. All the necessary registers in the HPC are set u= p. For > + a Standard (PCI) Hot Plug Controller (SHPC), the registers that must b= e set > + up are defined in the PCI Standard Hot Plug Controller and Subsystem > + Specification. > + > + @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTO= COL > instance. > + @param[in] HpcDevicePath The device path to the HPC that is being > initialized. > + @param[in] HpcPciAddress The address of the HPC function on the PCI > bus. > + @param[in] Event The event that should be signaled when the= HPC > + initialization is complete. Set to NULL i= f the > + caller wants to wait until the entire init= ialization > + process is complete. > + @param[out] HpcState The state of the HPC hardware. The state i= s > + EFI_HPC_STATE_INITIALIZED or EFI_HPC_STATE= _ENABLED. > + > + @retval EFI_UNSUPPORTED This instance of > EFI_PCI_HOT_PLUG_INIT_PROTOCOL > + does not support the specified HPC. > + @retval EFI_INVALID_PARAMETER HpcState is NULL. > + > +**/ > +EFI_STATUS > +EFIAPI > +InitializeRootHpc ( > + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, > + IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, > + IN UINT64 HpcPciAddress, > + IN EFI_EVENT Event, OPTIONAL > + OUT EFI_HPC_STATE *HpcState > + ) > +{ > + if (HpcState =3D=3D NULL) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // HPC is initialized by respective platform PI modules. > + // Hence no extra initialization required. > + // > + return EFI_UNSUPPORTED; > +} > + > +/** > + Returns the resource padding that is required by the PCI bus that is > controlled > + by the specified Hot Plug Controller (HPC). > + > + This function returns the resource padding that is required by the PCI= bus > that > + is controlled by the specified HPC. This member function is called for= all the > + root HPCs and nonroot HPCs that are detected by the PCI bus enumerator= . > This > + function will be called before PCI resource allocation is completed. T= his > function > + must be called after all the root HPCs, with the possible exception of= a > + PCI-to-CardBus bridge, have completed initialization. > + > + @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTO= COL > instance. > + @param[in] HpcDevicePath The device path to the HPC. > + @param[in] HpcPciAddress The address of the HPC function on the PCI > bus. > + @param[in] HpcState The state of the HPC hardware. > + @param[out] Padding The amount of resource padding that is req= uired > by the > + PCI bus under the control of the specified= HPC. > + @param[out] Attributes Describes how padding is accounted for. Th= e > padding > + is returned in the form of ACPI 2.0 resour= ce descriptors. > + > + @retval EFI_SUCCESS The resource padding was successfully > returned. > + @retval EFI_INVALID_PARAMETER HpcState or Padding or Attributes is > NULL. > + @retval EFI_OUT_OF_RESOURCES ACPI 2.0 resource descriptors for > Padding > + cannot be allocated due to insufficien= t resources. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetResourcePadding ( > + IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This, > + IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath, > + IN UINT64 HpcPciAddress, > + OUT EFI_HPC_STATE *HpcState, > + OUT VOID **Padding, > + OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes > + ) > +{ > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *PaddingResource; > + > + if ((HpcState =3D=3D NULL) || (Padding =3D=3D NULL) || (Attributes =3D= =3D NULL)) { > + return EFI_INVALID_PARAMETER; > + } > + > + // > + // Need total 5 resources > + // 1 - IO resource > + // 2 - Mem resource > + // 3 - PMem resource > + // 4 - Bus resource > + // 5 - end tag resource > + PaddingResource =3D AllocateZeroPool (4 * sizeof > (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) + sizeof > (EFI_ACPI_END_TAG_DESCRIPTOR)); > + if (PaddingResource =3D=3D NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + *Padding =3D (VOID *)PaddingResource; > + > + // > + // Padding for bus > + // > + *Attributes =3D EfiPaddingPciBus; > + > + PaddingResource->Desc =3D ACPI_ADDRESS_SPACE_DESCRIPTOR; > + PaddingResource->Len =3D (UINT16)( > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRI= PTOR) - > + OFFSET_OF ( > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, > + ResType > + ) > + ); > + PaddingResource->ResType =3D ACPI_ADDRESS_SPACE_TYPE_BUS; > + PaddingResource->GenFlag =3D 0x0; > + PaddingResource->SpecificFlag =3D 0; > + PaddingResource->AddrRangeMin =3D 0; > + PaddingResource->AddrRangeMax =3D 0; > + PaddingResource->AddrLen =3D PcdGet8 (PcdPciHotPlugResourcePadBus= ); > + > + // > + // Padding for non-prefetchable memory > + // > + PaddingResource++; > + PaddingResource->Desc =3D ACPI_ADDRESS_SPACE_DESCRIPTOR; > + PaddingResource->Len =3D (UINT16)( > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRI= PTOR) - > + OFFSET_OF ( > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, > + ResType > + ) > + ); > + PaddingResource->ResType =3D ACPI_ADDRESS_SPACE_TYPE_MEM; > + PaddingResource->GenFlag =3D 0x0; > + PaddingResource->AddrSpaceGranularity =3D 32; > + PaddingResource->SpecificFlag =3D > EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_NON_CACHEABLE; > + PaddingResource->AddrRangeMin =3D 0; > + PaddingResource->AddrLen =3D (UINT64)PcdGet32 > (PcdPciHotPlugResourcePadMem); > + PaddingResource->AddrRangeMax =3D PaddingResource->AddrLen - 1= ; > + > + // > + // Padding for prefetchable memory > + // > + PaddingResource++; > + PaddingResource->Desc =3D ACPI_ADDRESS_SPACE_DESCRIPTOR; > + PaddingResource->Len =3D (UINT16)( > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRI= PTOR) - > + OFFSET_OF ( > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, > + ResType > + ) > + ); > + PaddingResource->ResType =3D ACPI_ADDRESS_SPACE_TYPE_MEM; > + PaddingResource->GenFlag =3D 0x0; > + PaddingResource->AddrSpaceGranularity =3D 32; > + PaddingResource->SpecificFlag =3D > EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE; > + PaddingResource->AddrLen =3D (UINT64)PcdGet32 > (PcdPciHotPlugResourcePadPMem); > + PaddingResource->AddrRangeMax =3D PaddingResource->AddrLen - 1= ; > + > + // > + // Padding for I/O > + // > + PaddingResource++; > + PaddingResource->Desc =3D ACPI_ADDRESS_SPACE_DESCRIPTOR; > + PaddingResource->Len =3D (UINT16)( > + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRI= PTOR) - > + OFFSET_OF ( > + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, > + ResType > + ) > + ); > + PaddingResource->ResType =3D ACPI_ADDRESS_SPACE_TYPE_IO; > + PaddingResource->GenFlag =3D 0x0; > + PaddingResource->SpecificFlag =3D 0; > + PaddingResource->AddrRangeMin =3D 0; > + PaddingResource->AddrLen =3D (UINT64)PcdGet32 > (PcdPciHotPlugResourcePadIo); > + PaddingResource->AddrRangeMax =3D PaddingResource->AddrLen - 1; > + > + // > + // Terminate the entries. > + // > + PaddingResource++; > + ((EFI_ACPI_END_TAG_DESCRIPTOR *)PaddingResource)->Desc =3D > ACPI_END_TAG_DESCRIPTOR; > + ((EFI_ACPI_END_TAG_DESCRIPTOR *)PaddingResource)->Checksum =3D 0x0; > + > + *HpcState =3D EFI_HPC_STATE_INITIALIZED | EFI_HPC_STATE_ENABLED; > + > + return EFI_SUCCESS; > +} > + > +/** > + Entry point for this driver. > + > + @param[in] ImageHandle Image handle of this driver. > + @param[in] SystemTable Pointer to SystemTable. > + > + @retval EFI_SUCCESS Driver has loaded successfully. > + @return Error codes from lower level functions. > + > +**/ > +EFI_STATUS > +EFIAPI > +PciHotPlugInitialize ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + mPciHotPlugInit.GetRootHpcList =3D GetRootHpcList; > + mPciHotPlugInit.InitializeRootHpc =3D InitializeRootHpc; > + mPciHotPlugInit.GetResourcePadding =3D GetResourcePadding; > + return gBS->InstallMultipleProtocolInterfaces ( > + &ImageHandle, > + &gEfiPciHotPlugInitProtocolGuid, > + &mPciHotPlugInit, > + NULL > + ); > +} > -- > 2.25.1 > > > >=20 >