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.82]) by mx.groups.io with SMTP id smtpd.web10.6739.1685065015448545240 for ; Thu, 25 May 2023 18:36:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=D/sRdrys; 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.82, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9SKggLCQhVA6PRGeTLMFUDqrntboIYIlum03HC/msHsOa0kQnACxvOCPTt6MJ0z7S8i9C3V3GAvSyUqgLzQYbyvfBN2mxCvAPlk3UY+O3RLzNr3yAiAYWLGaLkhWbENdF3n7gRrTJiZbvLeOAmRXaK/ftgA9Ihp+MNsMbeuDxQIPRsE4Bj55uDRRG2UkZv/nRXuQY2/G4Btr8Xq6bM6AHTawFkc4VL0b5Eddryq7UTt36Dt5/dvNdII782d45FMuAqJjxSWZZWEDTJOFujTM1/F0BJXCgU9AQEQSibK4oE2K1AoHLwaL8dQLFQjqAnLtaUz05b4hspWzH2QXegTRg== 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=78TU5l/2hvNpXf1/gPdJBIy7v5la0tn7R0OF00J3ESE=; b=Xv2Mlrz1vh4vir1eREb1uovwt9hMxsRLYDxusMHDuMPk9JwxjeZLVw5bKXFQx/Ye2tj30/oKZTIirTG+ldsVOYPC0qHPIW+Vt24MbmgBvX1jL7rp6TYQoPRzB3MnekHLTVqF8Kbwp0rdBVWZ0HoLHAcrG1F8YTl1INGZanmm4Uz5GGudBbG+tcFfcjaxjpyWb4D4Ehk4kXPLHsfrZNjP46XOxxkwtFT0s6s4Ge1uLKZSHL1moUMzS6KQCME80ojllVn+ke+ns6rHBtYTSJ7zY76h9vu++MOeNsHu4W2SdshpB0nsld6juZfvOLT0IY3wEx+Jrfeea+o4OZcWyGmn6g== 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=78TU5l/2hvNpXf1/gPdJBIy7v5la0tn7R0OF00J3ESE=; b=D/sRdrysfrHRd4dDeW79P21saHD6LYMPt7CSsceOdq7yO4jtN2nU+ylfp3t7BzE7t69oldQujyw6DRcmjP4n/sT6nriUQYpTTpXADx8Ks88E33uR1p71+xiRB/NheyY505ie1ijUvPOwvZTbyhSjYvz4P1hXZwE+wM49m+plS0w= 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:36:53 +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:36:53 +0000 From: "Chang, Abner" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" Subject: Re: [PATCH v2 1/2] AMD/AmdMinBoardPkg: Implements PCI hotplug init protocol Thread-Topic: [PATCH v2 1/2] AMD/AmdMinBoardPkg: Implements PCI hotplug init protocol Thread-Index: AQHZjI/fIAnvWNKHEkiZTZRNa3K7YK9ry1PA Date: Fri, 26 May 2023 01:36:53 +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=3612b655-adb3-4fa7-8636-7c726197e78b;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:34:33Z;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: c6952d13-0596-48bb-fbec-08db5d89af01 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: otPeL1NjL+mtjxzBZRFPG6bUwgsNMBKrJInmutZhB/pR3fvBB28MW8NHhNnh219Q0EhtUtdoMaj1AUGIwvYlLlPY0HNYb4AnUfOGO63OertvacLk5DrEpkHbI/E/yCqidX/d2RbYpBnW+UUnYYKn+veUM6r1ouKAPjIPKLvfyYfODnM+1t8LG0bWgKxATSVYBXO9Xfc8bzagUAjFoN6QJp58+m9ga2f2wfYBrMcnaSxYE+0Yzn5yZr1/clfY6MII4BnwNwBUf0Qac+A5lkxUjeqGvIapTA9vbiBLHfFj1OZOduY3rx1mfR1/h1GWlvur62EGmg0gF1iBUQk6VQ0wLkMCYxRnv4J0OHKtmadMlgIrvJ/HjsAz1Ue9nN26ieZjvaOyUy09ChV7aS4r0/695cNXHFxu55tzw0EsfE8IhVlOSpvwpKgHmzjrhqvqEjR1i75nOD+HJxe6qcISroMgi2NWA4tx+pQA4E1GIstRdqt6DAbT2nd3qCe4kQ79mHPJS2n0fzPOEqKwUNWbKx32KrR7eODzgew7cUfh6m4J99kCZ96NDNqzvMi4URIOva11R1uwxyE3OL9oIHh0OA7oyK0Lfv4ADBVwQxgYjdqL3m6hPxkGGozFC5vOFLoBPryHh0m4oz7ohktX7HN79MexAg== 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)(66476007)(66946007)(66556008)(66446008)(64756008)(76116006)(478600001)(4326008)(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?1LcKi5Urj7RrPQfh4A+dONaDvQ1uZI6s6p4dfqc7ngfSOUmnQ9qzFgTLc8Pu?= =?us-ascii?Q?dENVkXupaNmDTUo1eivantMuqG7Au+dgK3mxY7/RCz/y5aSxt4llTd6UqBYI?= =?us-ascii?Q?A19w6z7hwVfHPO22g2kO+CCprFDzmrZMBDVnsDJBN9aBSGJ+MpVVIUdIJ8d6?= =?us-ascii?Q?rNp2XI65qQvnqXK/awjkeCpv/yA0LbfKX0PpgWnRtIxhTZ1Ljzpdh/+6LxfI?= =?us-ascii?Q?2NSBv+Y7/m7jYqD/Iv0149keS/7/UhaSBs19ncy40FR4AxEAzw8X1kyt2Xgs?= =?us-ascii?Q?zwZCW/HSexUQW/yqlp5bU//CST5fhmsv7hYSf5/7v8gxzXb82RKqDM9fzEjd?= =?us-ascii?Q?HTKqEYqSIskEmzYISbr2TuhdWxzsTVrl/CRFpSpivG8SJvpEYnx728UX7lLe?= =?us-ascii?Q?kkYjyTpyJricS4xARno/3C7/xpxMChXR6Q5AW40ysDRPzS1EFf2nxyh+SOpX?= =?us-ascii?Q?/XFusud97TzCd/bVyENtpaDufdaz5ViPWMf7oAk7M+DZl6rrq+HjtjSHBLKy?= =?us-ascii?Q?E4nIPpF4k4TyC6y5N3LGqR2QcGBCHZuku+m++ThPphlb6rywLId19r1SH9pS?= =?us-ascii?Q?ZLq0S/Sv6RC65i8gvFCHdgDz96/FX/fd1RevAU1kqPSzIbYonl66pheIXq9Z?= =?us-ascii?Q?0gcn2oUBzshYJfRhxCl0JyWMDWP0WcD2CTZcoDplDNyQ13fIxKrGePNhjFlJ?= =?us-ascii?Q?D9JucR5MXs82e+nQ29SgQQLhpj4kiS2dIdjzSrIfHk24NtF5IgilhZcK0N6/?= =?us-ascii?Q?aw7exG5bGQaiauwQ9PQe53JCWY7Wh4mcJxpV+8aUjT6eJkhQ71OhmBD2k31G?= =?us-ascii?Q?nIAyaWzbYBmEaLOi7JH5gB/8ZEKKGG9qMli+qnAth7Flhz/saskP2NP5OCli?= =?us-ascii?Q?3MJgUYadqEMqslhbTz1lXSV2JE2Cp7hWw8s7jewFhYzUi32GfAZfGbql9wm7?= =?us-ascii?Q?s0jZOTXi6w9H1qZKJFSB2df59qlUImdeK2ocViBOz4TxGSpzXbFoVSY9OoL0?= =?us-ascii?Q?yBof5G2oz4JcjeTjGywQOrBmDEmcjWLL1TtHCeKJl9I6oDS9IzdGQGTg6VFn?= =?us-ascii?Q?AQnPNbmxhicEZ69TazQ+O3lary0rvt4FGVo0WKKNQJw1TJ4X3q2YyejpYsNg?= =?us-ascii?Q?23gpr4JPz4DCZMz9sf2Bj28IznMJ0m56Klgzkn0gzRC2JijF7kiNDErn8ful?= =?us-ascii?Q?2vzlQyFd+4dQwoNqW2l08o618zVXkRXBmWzG55I3evPCzsPtKpuNTKGc+q37?= =?us-ascii?Q?wrhhhUIbyNQJP9V6QznnBkJRh4Kka9V7uwkUbxxNY8X/L0bymqNZRX/RtUsO?= =?us-ascii?Q?k3TR7oZIeFS+/1gSD+h7hXzSEndzvgw5oyF2JlxQyQwmOdZ8cYST92U2gQhH?= =?us-ascii?Q?AwARyJQfXu8T99TEpW0+66Y04EnJ3SmiYNnr2hsvAWhHd5buL6buv0AtIrU3?= =?us-ascii?Q?dp4TXWUGAhsGPkzDLnYtXWhoERJ9wfrCm+Gjhje4RFvCT2BSgMZ2nmoU3ElH?= =?us-ascii?Q?PUAy/r6MruvbYGsOrPzjoyAVJCuI9Qvg8RBfg1b5ixUV7frMXfdRZZ9uxJ0q?= =?us-ascii?Q?aYd7jfVhB+lzTJdI/r0=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: c6952d13-0596-48bb-fbec-08db5d89af01 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2023 01:36:53.0845 (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: j6rAjCFF4q53bSDFZf73JUeyrPW+KeLjbYaOZHHQYkZ33x2bEPh7G0cYOjj2yMiEKUo7K7lSDOwJ9MuASP04jg== 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 a duplicate patch? There was a patch you sent: [edk2-devel] [PATCH 1/1] AMD/AmdMinBoardPkg: I= mplements PCI hotplug init protocol, they both create PciHotPlug.c and PciH= otPlug.inf. Thanks Abner > -----Original Message----- > From: Abdul Lateef Attar > Sent: Monday, May 22, 2023 5:29 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Chang, > Abner > Subject: [PATCH v2 1/2] AMD/AmdMinBoardPkg: Implements PCI hotplug init > protocol > > 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