From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.44]) by mx.groups.io with SMTP id smtpd.web10.10098.1679306498234472451 for ; Mon, 20 Mar 2023 03:01:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=NROwCXYx; 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.220.44, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PCBoFxT12ep4l2wOqTMELm9cUJ6hMHVkOkkDypHxEzIvrhhaiUvkicK2IrzVq+7zSdugr2Gg5EqT89p9KjHz1Ccl3ms1C18uBsC2mHcBKrCiNPEnkyLOWKXQEk3XlsgvPHktmtGSdkG49NE9aNChwYeHZHhAyIlGH6Q988aE02HmDxh9i0yUjxIi5RbIapB1FftWltcnsR9ZNlF9ZHcphusxq8s24mQHX3mhLaQQ51gfUAYo7rlDU0gpsmCn58M67SwKo0k5sLuxGP1uJRLfi3dhp0A4bkolxPG8iOH6QA/yfAQbOTyX0sEsVdy3eaq2zy0Q83M0vjfJnxqOzSzLzg== 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=CjxlquGYhJ8ISfcd0wwderNLSVTHgjbgdAuPnViV96g=; b=TWYSSRhgY3FQY96BCqKfWK8LimQFsMfFuKVFrWBVf1U0zTvzxwmGKIDj2G6IcaCyd/g0PxukZ+OZqjuJ6LWRqq29a/51MN1ZK6DL/hm9G8Fyu+gGkuEbPdJhYDDcmslB0O4XnUYKDu6Sv9OkaC8PS0+4yO4yrPOautwH7d9E6BB+26ht9OH+YQ4aQ3rAVEtq3FEPboXm8ZZxITRHfxhRso/d2X1tu8UNKLaLEYjuTS1FkQq3pG0GIYqb+hIteMqzPK38b1XQBoKFRliCR6GmYFiHsxXM0jaDU+WLQnQLADheM61kECa10gm6Qa4WNK0hOawkzP+UI8yGNybhkNJt/g== 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=CjxlquGYhJ8ISfcd0wwderNLSVTHgjbgdAuPnViV96g=; b=NROwCXYxpO7FHuJBYYrsc3j3HLbCpHOus8ZJVRx1LadE5ydlGsFsTC7Qz+qGwc64nAwD+MMSMRnPJffo3SMwu/4wJK64+IwYTrH/9lupU2VvLlgicB/8PKFsOUao0agGlFOPcx0nQ5tWm6NMbRllBXNYwAa7xNtE2xIWpRfKBHM= Received: from PH7PR12MB6466.namprd12.prod.outlook.com (2603:10b6:510:1f6::22) by CY8PR12MB7707.namprd12.prod.outlook.com (2603:10b6:930:86::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Mon, 20 Mar 2023 10:01:35 +0000 Received: from PH7PR12MB6466.namprd12.prod.outlook.com ([fe80::127d:946f:b238:1151]) by PH7PR12MB6466.namprd12.prod.outlook.com ([fe80::127d:946f:b238:1151%2]) with mapi id 15.20.6156.027; Mon, 20 Mar 2023 10:01:34 +0000 From: "Attar, AbdulLateef (Abdul Lateef)" To: Leif Lindholm , "devel@edk2.groups.io" CC: Ard Biesheuvel , "Chang, Abner" , Michael D Kinney Subject: Re: [edk2-devel] [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Topic: [edk2-devel] [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Index: AQHZWJzAzbeZyVgqVUycN68HndAGXa7/IIWAgARRz/A= Date: Mon, 20 Mar 2023 10:01:34 +0000 Message-ID: References: <3eb1b035c0ffc64045065beae4c0adebf88a38cf.1679035605.git.abdattar@amd.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=866461c2-bccd-446c-b9e3-e4ec1db48755;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-03-20T09:53:09Z;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: PH7PR12MB6466:EE_|CY8PR12MB7707:EE_ x-ms-office365-filtering-correlation-id: dc80ec94-d461-4696-3b74-08db292a1678 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ztE8CRgDIMJGD/f0n7NIFawyRLOlCbd/V9aqImpsEP5O+6kd711ar841YLWF2YcxFGaJRt3Kk2n2X0QgtwmYuBpspUda/fufh4e1243DHLkL2vNvtUvJBV0YMvelZGsVbskst6oGF8zE8ElZgm/rFZLXgAAQQ6Iorj/efeezHEcUFQIW71/CE2E5a5WIHcjqcWo25pYXB76m2BvSMCnxz2lZJzDrCaGTMtZ3oLmK5U+b/1XCBKtMwdcK6EzMcJqGvw1R1KQy+C7DnWVX22X1tN77a0UYLcwK7ge0eMN552g/iWmF7ISn1UlMS7CfQA3PiPe6jWWk45s7gAM/gVfbKBPzsRlnp2hEFpyBF4Z89v5zQlNaRLObE2wpnn32tO1fTklxGqsRMd5laInn35Q2DpIDFwxTsGSzdjmQUCQsuAhH1kpsYt3aEXZfhJpA7JfRSjd9x4yfIM1/aqt4ECbyKP2zfYTzBvy+lAc2CzQCNwIcVVtI/DV8WJYX95cTFxx78vce8q7jHqBJSjFmWXj69lrIlk3t/iEbEsxxSllMrbAf6zsZC//F2/6xEqRhi5PDOFlun1Q8BCghfjoNkZb7mrsZtY6E69iMEFdcW8vuBIUBJj8X5W6kd6rr2SqpA4HT8Lc8JRso1nWTS7m6xxFFEM80ahSh7Cl0l3MQKWPamgOat448T6TkhZcS3Z8Q0bpaQ2cIw5uZloK148J542sPBg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR12MB6466.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(346002)(136003)(396003)(39860400002)(366004)(376002)(451199018)(122000001)(86362001)(55016003)(33656002)(38100700002)(38070700005)(30864003)(8936002)(5660300002)(966005)(2906002)(71200400001)(7696005)(4326008)(64756008)(8676002)(66446008)(76116006)(66946007)(66556008)(66476007)(478600001)(110136005)(52536014)(316002)(41300700001)(54906003)(83380400001)(66899018)(6506007)(53546011)(9686003)(26005)(186003)(579004)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gfzC6l2il0f37lCTobt7F0BwdE6DT5UgjYAJUZ6z4dWO0ZMYt0UG3opOeOAo?= =?us-ascii?Q?XPAl7geTbR5IWdswkY0sVxSaXcctBLWayFL3D0Cw7fZmY2VrQhkhWzPJiOoS?= =?us-ascii?Q?V3UUwaBoWu/2GCG1v7QAwo/1AZzAgxTSrFnI1w3qKDFCPM6QHvxwQSefFcvG?= =?us-ascii?Q?Hq9R9rbeQZXvSq6NRLhoaeQHA1DmodZ0rVGdIy0QYTvDYUEMFSAIOVoyAivc?= =?us-ascii?Q?e/YUjmihcD3xakZPd4fyRlzyevkqa7VcsZ0XYNsBtyhInp44gDza/iUX7iSH?= =?us-ascii?Q?yOrp1Fm3Dlt+Tb1H/QuXlLQ3uf3K9LiFFnOs0t8gE+WB9BatFGVXi02t7NOY?= =?us-ascii?Q?bHEucSid+0VsZ9xd8Nn0176cx2Vz5EHVL/YCQXr+gXpsPm/bZqUVE6bH+YzZ?= =?us-ascii?Q?YNtcIn+ANGB1wfUj2iti1V8esPHl9SRWhQonlB5qme2xl62oGrQo1RKzh9lM?= =?us-ascii?Q?UTukZDA7hXVO8Ki8G7XwgihKzjuyPcUDzqlu498enpU8DfJj2iHOKyMa+cQv?= =?us-ascii?Q?LTMSpGtNIwjfOyKMbJ4772oXE0L57DQIh3AGloqx2uR1pOB+taN1WGE2scRK?= =?us-ascii?Q?ZAxVk6KhC+TNTS5v8Bn2mXF0129uuSpZvEmmTO9sd1Wz7kjGjy2ynnKRrMFN?= =?us-ascii?Q?jHLNAtX7eSA3TVthRZH4mVrEMQS/FA7PlRwaStTOy9ndfUCSahRU5bKA0l0b?= =?us-ascii?Q?z4paTd3JKi1XPGzScYC1mFoX7VxWO1vIhoiMfjJXuO+5I38ZV3W95srHrDEL?= =?us-ascii?Q?ztZHT+47v6s01qAJXtqjeLAVl0uwGSGSxcabPQXHS2kMjRL6/I09kXkD8GCz?= =?us-ascii?Q?51uxM7e9uhPDunm/jwRufhzAlh9k5D22XNOijEXWoGNy22QHFO+q5b6WiZ+c?= =?us-ascii?Q?iEEZB2nbDPAlToJyaWouXraSES5hL2Ojcg4QcbBCqMam3S0+IXxnG3cEFPC0?= =?us-ascii?Q?lSeUZDBNUyMphfYprdj7R2ZWHKzEPgN1GDqFHo4nAw6ru2StfcjI7osyuy1K?= =?us-ascii?Q?dRD9/BGj0qQOLUj59IxoAdtyMGYET5ewNZiJpcCfzUK8Lg7V7RJQpdKZvH1l?= =?us-ascii?Q?KUN8ftWuHm/8i75dEsetiS0k2eUAfE5AG9ibs0Nawl96GkJAaDPAR9XGD0pc?= =?us-ascii?Q?UcjVHALSVAdocQFjpNQMJSNNS1jPXLkS/ysUQ2CsZ5uG4n3ewqyPRmBaBLEn?= =?us-ascii?Q?Z2WZbPGvq6x2a6lRwrDEBJjNAdT0FlSOen31LcsHR4V4Er41N0IVzm22GK82?= =?us-ascii?Q?zdt6NsvQVQiUBtlVFH+uRNHCyc4Q9lb8EGQ8i/FOSC1fNHx1nla9JKXcdEIb?= =?us-ascii?Q?Azp3naHVVyGhd8GmGUj9DLBpZeW5sYghqZf2Xgr8Sef2+UH3vtyh1ZkWYXFy?= =?us-ascii?Q?sbY0H5i4I/JsOXtYnQM0Uyc8tvj2sv7A+qui6kh/0Iqfk+LaShSe/sMNwipY?= =?us-ascii?Q?LxrrPwXVvVI5m9tUtpuv9uNFc/gO2fW27ryPPZYxQT+BV3g/xBDS5N92SmBV?= =?us-ascii?Q?iwZIBkng6th5Z5Fowkb5NyvZj1QTlkqolVu/xKNrLQfnGimLep9Lsox1O4HD?= =?us-ascii?Q?ya5n/WJ+KE+pjkE/ncEyO8XJNtMEbhWZRtynMtq2?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB6466.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc80ec94-d461-4696-3b74-08db292a1678 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Mar 2023 10:01:34.5088 (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: cLV46x41ljHcMxUmXK0wc5fpbvwUDjUwS7FHlDoVEm/+CC6rjK1VUHg9oLq6+LpGBJWDcommA6oUUTQipTXdmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7707 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Leif, Please see inline my reply [Abdul] I'll address the remaining review comments and submit V3 version. Thanks AbduL -----Original Message----- From: Leif Lindholm Sent: 17 March 2023 21:25 To: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) Cc: Ard Biesheuvel ; Chang, Abner ; Michael D Kinney Subject: Re: [edk2-devel] [PATCH v2 RESEND 2/4] Platform/AMD/PlatformPkg: A= dds PciHotPlug init protocol implementation Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. On Fri, Mar 17, 2023 at 12:20:05 +0530, Abdul Lateef Attar via groups.io wr= ote: > Adds PCI hotplug init protocol implementation. What are some notable aspects of this initial implementation? [Abdul] AMD/BoardPkg and AMD/PlatformPkg will contains module/drive= rs to support MinPlatformPkg framework. In initial implementation we will be adding modules which need different im= plementation from Intel based platforms to adapt MinPlatformPkg, e.g. SetCacheMtrrLib library etc., as we progress = more we will add more modules. What groups of platforms is it intended to cover? [Abdul] Its generic for all AMD processor based platforms based on latest(a= s of 2023) MinPlatformPkg framework. > 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 > > 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|UINT > +64|0x10000000 > + # PreFetch Memory padding in bytes, default 2MB > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem|0x00200000|UI > +NT64|0x10000001 > + # Non-PreFetch Memory padding in bytes, default 1MB > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem|0x00100000|UIN > +T64|0x10000002 > + # PCI bus padding, number of bus to reserve, default 2 bus > + > +gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus|2|UINT8|0x1000 > +0003 > 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 > > + Please don't add spurious whitespaces. > [Packages] > PlatformPkg/PlatformPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec I won't be maintaining this code, but I generally advocate sorting these ty= pes of enumerations alphabetically in order to speed up reading. (That's not really possible for the block below.) > + > +[LibraryClasses.Common] > + > +UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEn > +tryPoint.inf > + > +UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/Uefi > +BootServicesTableLib.inf > + > +DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort > +.inf > + > +MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemory > +AllocationLib.inf > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf > + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf > + > +RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilter > +LibNull.inf > + > +SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialP > +ortLib16550.inf > + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf > + > +DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Ba > +seDebugPrintErrorLevelLib.inf > + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > + > +PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlat > +formHookLibNull.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 But these would benefit from sorting > + > +[LibraryClasses] > + UefiDriverEntryPoint > + UefiBootServicesTableLib > + DebugLib > + MemoryAllocationLib And these > + > +[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 proc= ess. If the HPC is not initialized, the devices that it controls may not b= e 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 u= pstream > + 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 I know you say above that this is based on existing code, but 1.2 is ancien= t. Latest version is 1.7 - is there anything missing from being compliant w= ith that version? > + Volume 5: Standards > + > +**/ > + > +#include > +#include > +#include > +#include > +#include I (personally) also like to sort include files within each Uefi/Library/Pro= tocol group alphabetically. / Leif > +#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 list can be a child of another HPC. This policy must be enfo= rced 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 i= nstance. > + @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 insuff= icient > + 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_PROTO= COL instance. > + @param[in] HpcDevicePath The device path to the HPC that is being i= nitialized. > + @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-t= o-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[out] 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_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 in= itialization > + is complete. > + @retval EFI_INVALID_PARAMETER HpcState or Padding or Attributes is N= ULL. > + @retval EFI_OUT_OF_RESOURCES ACPI 2.0 resource descriptors for Padd= ing > + 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_DESCRIPT= OR)); 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_SPE= CIFIC_FLAG_NON_CACHEABLE; > + PaddingResource->AddrRangeMin =3D 0; > + PaddingResource->AddrLen =3D PcdGet64 (PcdPciHotPlugResou= rcePadMem); > + 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_SPE= CIFIC_FLAG_CACHEABLE_PREFETCHABLE; > + PaddingResource->AddrLen =3D PcdGet64 (PcdPciHotPlugResou= rcePadPMem); > + 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_EN= D_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 > > > >=20 > >