From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.72]) by mx.groups.io with SMTP id smtpd.web11.13529.1679035938582885546 for ; Thu, 16 Mar 2023 23:52:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=JbhsCv2w; 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.93.72, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z/vOAhHHsd97h5nCbCcNL75IR1AbteJhnD8oCHuMNkLY+XqVLj+2eAIt6UKDkjcz4OPr6aKu/4z3VYZe15Yx2FceN507lNgnLK5X6KpBhhBbdxbtB/zlt1sILFFcoQSpmObbwcqr0wSvTlAInf7aD7sf/9ocKg8f3UDddbSj5u1n1JIJl8xuDI0iDS0vgIHvFvOPnZYy13Dl2oyGZFf3Rmc7sCNwznKIWBOvJiIQsXlOoaSN7IzI4mYoVz7Q6gjRzgLXiwyTWj1v5oNQsD/96MV1OqWnO/5v43nL5XAUiX3mwsPrO3JSifI7HRzyhoUiPkc1xp4EVwkrDN1Ofw10xg== 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=twitlrjQQfb21fuOXL6TTQER0/Ute1J+kkuJaFw8EYY=; b=AStRsu9+ObobnESXNQEoIEnYkHKjPtqklU15VyfuuOZ1MMlQJ9UfUd14w0g9QpzOKijY+PaVTmLc/+1Bp9hfAP0n2eQr+QyHS8VOE9Cj47AC783txFO/a6QCc4k3VrDNe24F0E7ESXrJEyN5Ot23rN3hLT0lGdHZaTT6YBtkZ8BBcZt6J492ZE7RI49MfLrGL7k8nyL1wR8J3gAQ8nYVRCPp9GRQ3M4AymZ2SacNmzInLumnnac9uaHUUVREDDkkt5xAitwM8zemH7iMKP/EoNJfe+pdXUQgWTHTFOwzzuIJTIxbnx8dNzYDcM0CvezRdPEmgs3Qs0Zz9yhH0nuPKg== 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=twitlrjQQfb21fuOXL6TTQER0/Ute1J+kkuJaFw8EYY=; b=JbhsCv2wy6WgLA75vJdoF0h1y+CisTOJnZU+SBB4mj93H6bn/wo99M1ZAFEXPao31tEGrxE+G77ul5ZD7By7mLetXpyzobiB135UFtJV+9WNEQ6z3iG7pWXIGfD4Eq/iOTUQsMddhvmbvWFIZj/k7FKZgREU+XPgk3cEVSWiZzs= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by PH7PR12MB5757.namprd12.prod.outlook.com (2603:10b6:510:1d0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31; Fri, 17 Mar 2023 06:52:14 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::8136:1f56:53e5:6fe]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::8136:1f56:53e5:6fe%3]) with mapi id 15.20.6178.024; Fri, 17 Mar 2023 06:52:14 +0000 From: "Chang, Abner" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" , Ard Biesheuvel , Leif Lindholm , Michael D Kinney Subject: Re: [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Topic: [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Index: AQHZWJzAr7uEGaz9BkaKx3PxqnZQ4a7+iLEA Date: Fri, 17 Mar 2023 06:52:13 +0000 Message-ID: References: <3eb1b035c0ffc64045065beae4c0adebf88a38cf.1679035605.git.abdattar@amd.com> In-Reply-To: <3eb1b035c0ffc64045065beae4c0adebf88a38cf.1679035605.git.abdattar@amd.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-03-17T06:52:12Z; 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_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=2889e8a7-9b1c-4c4b-baa6-07c61f94eee3; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 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_|PH7PR12MB5757:EE_ x-ms-office365-filtering-correlation-id: ffbd4511-2336-4ac8-bb1f-08db26b423d7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ZPHd5VxJZ3YFGAbovsDNpWfIzznvmgzPCH2YjcY3i/uYpVY8TBwU3REehs1UpaZ6IZP/lrcAEe9cv/QyVnnXzZQI1tE1wNG1EiU9CFVbL8/15dSyCB5jxqquXgD1mCitniemeDrzxjWRshE4N0cs6aBEKubZD2xUxLffIihIaznLsflJ+IeNc/J+pxqd0byyACOy8sInVpCx8RUARv5anxQSDY9fZiq90DHV61S6AZnoMLhrCrvVSDEsIObByOfhcibmjaBo7m5UPwLtcovtkuqFIWPsjD3auGSeUXr+cYm2M7AQt4JCAgPxRNeRp716CALXHBf2wpXfBETun5HU4FsmYYRhd5KNDSobxAropQV6YGY7iFnkjNbzU+8Rph+8//GtsEEJ7yV8UoyqiVgC+JXQtOY30qHK8RU45NsTfQ4/7Y06mt4GYu04sM0aULX71pI9lhFXBKbPeSwN9VQjURZRQ6Ub+oa2H1jfjG/6mcM310gjPSUCVKXn22ua9kSS9P7f5InysFOoChIWeqe/PvWRtoxZ8YGuJklfRJi7jzjlvwD3FMdED6adfvFKxv1oRdxfxTeaJEhFEz+otAzaO3C4TUj8sTXAXMPu298UZFfhgGZg04iO8g8D8KZJ/uPBT96SignzNgfDi4s2PJyeGqe/uIBegaJRl2n4EpnyS00ljDexDfqWhuOzOh3YSSeFN1JaBCJSqdHw5AGRPbzpqUwrqNP3evQhbeQHOoXcOVs= 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:(13230025)(4636009)(366004)(39860400002)(376002)(136003)(396003)(346002)(451199018)(38100700002)(38070700005)(86362001)(33656002)(122000001)(5660300002)(2906002)(52536014)(41300700001)(8936002)(30864003)(71200400001)(55016003)(83380400001)(66946007)(4326008)(6506007)(26005)(186003)(9686003)(53546011)(54906003)(110136005)(316002)(66446008)(7696005)(76116006)(66556008)(478600001)(66476007)(64756008)(8676002)(579004)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Cb8byOXGiymorSq9y+uXeukgTgAbxmLV12xVlXnLzXE6xYAFKYKfwW7Ol9Kp?= =?us-ascii?Q?qAZ6elM9yhxidl5+Nbl62EEZ0Uzd9B8PUf9cYX1JdOXYBlb4jYSPMbV8YI+M?= =?us-ascii?Q?U9JVBdhX8kmD9o2BM2MAr2PFo6PE0Syc07jsul7SG3uqjyeHqoN7OZm/7Au7?= =?us-ascii?Q?yGfBWpX/nnJ/Lts6GDc+S6N2jW6iqIV+/i+14kNBx6WoaX77wl8n9L2oN1uk?= =?us-ascii?Q?h0OltBLqK6Egu+DUHf5zHQtbxXTMP1KBeUKZ7OWM5KRPc+r6ZB7hPdjX73X1?= =?us-ascii?Q?NEgLAKKca/sLNiqdYsmtFihrqtaynVYzj4UyRMQeuyqQ3VSEWiZuPHhB06Xx?= =?us-ascii?Q?J8r2OIdwQMaG3X1m7Oe1o+/rqaB9UV9GcT0wkWWwr1LDEzBHw0yOHfTcmcVb?= =?us-ascii?Q?wFrabRTWzpraFMyOwEVgkOrWuhTXUs61CkAnKV9STWqSW2swfNU0oWbME/re?= =?us-ascii?Q?dsYTGlThF2FPNrHoZjqYc+2OMzI7Z43PWGlxMEK0XVQTZXIVujDsE2oAx5T+?= =?us-ascii?Q?3Wn0x8QzuutMmrGhBxreoBm9Jsi9JU1xwzLiKI6MDGi5cpa9vKSv3dIGtaFp?= =?us-ascii?Q?7fJRfZtdfMp1fmBdye/f3OPEtCRqv95AISRN0rJR6llL8WR57pMWCGb+PXuh?= =?us-ascii?Q?ktfsJ3803o8dpm7unFmJp+xCw9w6dFwkiIOb07Q44GPacum4gmbs1Os+D49d?= =?us-ascii?Q?2pnWg1SjPxLTG+lgvzRQndHhscreO0+BqhmqIrqoPuWkytZUBNGjt0BIAF1Z?= =?us-ascii?Q?S7et+Zk/uuxZO4gk4k7rjhTcCJmEXpGCOOebqoySMrH5rgIQPdVwUGY4NZmW?= =?us-ascii?Q?gUbJYroTbm9PxI2KMYkMs5kFCQlxcwK8urmfUqiZvCdKOzt0SJWoSKKqgk9I?= =?us-ascii?Q?AhpClM2J8c3kDZrulsSvLPE3IVpIk8Xk+7AutqH9hUqH1nbo2EiROwqDAHJO?= =?us-ascii?Q?RIPgj+/N26w9aNhPiaSg4bh3XVxcHibeIZaNXGVZnSzC0XIaZoev7jcy/VU4?= =?us-ascii?Q?fx07GgvSgwIV+QZ3YRQN6/2sdeW58+Wv7/aU2OvAdnleNU+ZefU2U486K7LB?= =?us-ascii?Q?Jvx67nazoGw2WNMoUEorckQe4F5Rlh7NX2R7o+pbj/0J08dJ2L9MzcsbqmYZ?= =?us-ascii?Q?4pDeuUcJUNqeQLfhN5j7DELM70U6HGJF55/wJLhqAc6YtILsOOzVbMHEFbLl?= =?us-ascii?Q?tdVVUZRvucZA2h+Iaf0PW/5A9+sgYm+HVsGOSBiSaaHY4qXivjDvWG0YG3wu?= =?us-ascii?Q?8GdgVZHruzoiXzTmJcaDGhJ4P0qBx+wWzuNLnqPGxc6ZxjjYUii5DbV4v51x?= =?us-ascii?Q?5MFcu/vq/pK1Tl2QO+vzWZUv6kGYVp4NVAnxnIWrAbqTPD1SboBnENCLG1YJ?= =?us-ascii?Q?ZRVuaQjt7/3l86UR7+rjaVbQUZMVTaKjI0y3MariFALm5Kf8HFjzsj7IELuy?= =?us-ascii?Q?OdyHnE3icvbDybgAgS3CzxW7fCNp30yQ+zPXDgIKtK7eeRd2tUjUzWurPMgn?= =?us-ascii?Q?jQMRiVErK2Qrz8OOvjbqdKWpp20aHKsnElFRNgwONfMDooIMbUPm5bsO5pZ0?= =?us-ascii?Q?WMRE4PA4i+Lm7VlwE0Y55Fu/YwCyTrHWDd4TYmU/?= 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: ffbd4511-2336-4ac8-bb1f-08db26b423d7 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Mar 2023 06:52:13.9897 (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: KhHtZCpK9u8ZyoleVQV4p0U//+M92DxhPDj0krOUT/u75FhD1D+fb/Ky/EZ7VS5aprQDDVcBLg6fnjT5HJsz3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5757 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Abdul Lateef Attar > Sent: Friday, March 17, 2023 2:50 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard > Biesheuvel ; Leif Lindholm > ; Chang, Abner ; > Michael D Kinney > Subject: [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: Adds > PciHotPlug init protocol implementation >=20 > Adds PCI hotplug init protocol implementation. >=20 > Signed-off-by: Abdul Lateef Attar > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Abner Chang > Cc: Michael D Kinney > --- > Platform/AMD/PlatformPkg/PlatformPkg.dec | 16 + > Platform/AMD/PlatformPkg/PlatformPkg.dsc | 23 ++ > .../PlatformPkg/PciHotPlug/PciHotPlugInit.inf | 41 +++ > .../PlatformPkg/PciHotPlug/PciHotPlugInit.c | 340 ++++++++++++++++++ > 4 files changed, 420 insertions(+) > create mode 100644 > Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.inf > create mode 100644 > Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.c >=20 > diff --git a/Platform/AMD/PlatformPkg/PlatformPkg.dec > b/Platform/AMD/PlatformPkg/PlatformPkg.dec > index 6155860979cb..1bc38d6025c3 100644 > --- a/Platform/AMD/PlatformPkg/PlatformPkg.dec > +++ b/Platform/AMD/PlatformPkg/PlatformPkg.dec > @@ -13,3 +13,19 @@ [Defines] > PACKAGE_NAME =3D PlatformPkg > PACKAGE_GUID =3D 38FBA311-E2AA-4620-9A90-9A23753D187= 8 > PACKAGE_VERSION =3D 0.1 > + > +[Guids] > + gPlatformPkgTokenSpaceGuid =3D { 0x95ECA58D, 0x09B6, 0x4420, { 0xB= 4, > 0xE7, 0x01, 0x7F, 0x6A, 0x5B, 0x26, 0x0F }} > + > +[PcdsDynamic, PcdsDynamicEx] > + # > + # PCI HotPlug Resource Padding > + # > + # IO Resource padding in bytes, default 4KB > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadIO|0x00001000| > UINT64 > +|0x10000000 > + # PreFetch Memory padding in bytes, default 2MB > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem|0x002000 > 00|UINT > +64|0x10000001 > + # Non-PreFetch Memory padding in bytes, default 1MB > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem|0x0010000 > 0|UINT6 > +4|0x10000002 > + # PCI bus padding, number of bus to reserve, default 2 bus > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus|2|UINT8|0x > 100000 > +03 > diff --git a/Platform/AMD/PlatformPkg/PlatformPkg.dsc > b/Platform/AMD/PlatformPkg/PlatformPkg.dsc > index 704566b9ea73..9a693070ab3f 100644 > --- a/Platform/AMD/PlatformPkg/PlatformPkg.dsc > +++ b/Platform/AMD/PlatformPkg/PlatformPkg.dsc > @@ -16,5 +16,28 @@ [Defines] > BUILD_TARGETS =3D DEBUG | RELEASE | NOOPT > SUPPORTED_ARCHITECTURES =3D IA32 | X64 >=20 > + > [Packages] > PlatformPkg/PlatformPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + > +[LibraryClasses.Common] > + > +UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntr > +yPoint.inf > + > +UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiB > o > +otServicesTableLib.inf > + > +DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPor > t.i > +nf > + > +MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMem > oryAl > +locationLib.inf > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf > + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf > + > +RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLi > +bNull.inf > + > +SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo > r > +tLib16550.inf > + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf > + > +DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Ba > se > +DebugPrintErrorLevelLib.inf > + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > + > +PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePl > atfo > +rmHookLibNull.inf > + PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf > + PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf > + > +[Components.X64] > + PlatformPkg/PciHotPlug/PciHotPlugInit.inf > diff --git a/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.inf > b/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.inf > new file mode 100644 > index 000000000000..0079c4acf14e > --- /dev/null > +++ b/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.inf > @@ -0,0 +1,41 @@ > +## @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 8B67D95F-78B7-484F-8F16-5F22AB388B0= C > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 0.1 > + ENTRY_POINT =3D PciHotPlugInitialize > + > +[Sources] > + PciHotPlugInit.c > + > +[Packages] > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + PlatformPkg/PlatformPkg.dec > + > +[LibraryClasses] > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + DebugLib > + MemoryAllocationLib > + > +[Protocols] > + gEfiPciHotPlugInitProtocolGuid > + > +[Pcd] > + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadIO > + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem > + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem > + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus > + > +[Depex] > + TRUE > diff --git a/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.c > b/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.c > new file mode 100644 > index 000000000000..b977406bbcae > --- /dev/null > +++ b/Platform/AMD/PlatformPkg/PciHotPlug/PciHotPlugInit.c > @@ -0,0 +1,340 @@ > +/** @file > + This file declares EFI PCI Hot Plug Init Protocol. > + > + This protocol provides the necessary functionality to initialize the > + Hot 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 tha= t > require initialization. > + 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. > + This protocol is installed on its own separate handle. > + > + Because the system may include multiple HPCs, one instance of this > + protocol should represent all of them. The protocol functions use the > + device path 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 that root HPC and continue the enumeration > process. If the HPC is not initialized, the 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 > + the 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.
Copyright (C) > + 2023 Advanced Micro Devices, Inc. All rights reserved.
> + 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 #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 > +initialization > + during the boot process. > + > + This procedure returns a list of root HPCs. The PCI bus driver must > + initialize these controllers during the boot process. The PCI bus > + driver may or may not be able to detect these HPCs. If the platform > + includes a PCI-to-CardBus bridge, it can be included in this list if > + it requires initialization. The HpcList must be self consistent. An > + HPC cannot control any of its parent buses. Only one HPC can control > + a PCI bus. Because this list includes only root HPCs, no HPC in the lis= t 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_OUT_OF_RESOURCES HpcList was not returned due to > insufficient > + resources. > + @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 > +causes > + initialization of its subordinate buses. > + > + This function initializes the specified HPC. At the end of > + initialization, 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 up. For a Standard (PCI) Hot Plug > + Controller (SHPC), the registers that must be 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_PROTOCOL 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_SUCCESS If Event is NULL, the specific HPC was > successfully > + initialized. If Event is not NULL, Eve= nt will be > + signaled at a later time when initiali= zation is complete. > + @retval EFI_UNSUPPORTED This instance of > EFI_PCI_HOT_PLUG_INIT_PROTOCOL > + does not support the specified HPC. > + @retval EFI_OUT_OF_RESOURCES Initialization failed due to insuffici= ent > + resources. > + @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; > + } > + > + // > + // This Platform doesnt have any non-enumerated HPC. > + // Hence no extra initialization required from Platform BIOS. > + // > + 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. This function must be called after > + all the root HPCs, with the possible exception of a PCI-to-CardBus bri= dge, > have completed initialization. > + > + @param[in] This Pointer to the > EFI_PCI_HOT_PLUG_INIT_PROTOCOL instance. > + @param[in] HpcDevicePath The device path to the HPC. > + @param[in] HpcPciAddress The address of the HPC function on the PCI > bus. > + @param[out] HpcState The state of the HPC hardware. > + @param[out] Padding The amount of resource padding that is > required 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_UNSUPPORTED This instance of the > EFI_PCI_HOT_PLUG_INIT_PROTOCOL > + does not support the specified HPC. > + @retval EFI_NOT_READY This function was called before HPC > initialization > + is complete. > + @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; > + > + // > + // 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 PcdGet64 > (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_PREFETCHABL > E; > + PaddingResource->AddrLen =3D PcdGet64 > (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 PcdGet64 (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_SUCESS 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