From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.45]) by mx.groups.io with SMTP id smtpd.web10.12179.1679026349312761972 for ; Thu, 16 Mar 2023 21:12:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=ASUqElk8; 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.102.45, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FE4Nt7bsfruKNP0Ju9Bi1OMy15dqxQaqAsEu3zHWi4I8MiZPJDFa0egSH0Jcx6n9CVZYMSkLgmYqiw4/EJqL5ZRnTCsKS4pwheY1S8f7Hs7p1AKm1fTtpYNwrhFEDZHXc/jj6yyho6DJ6ZGFpbO3/GDdJ2L9o/AaEvsAvNSHKIWFSksociy4405/tqHJShiu0UL5pXiFPcVgYHBsDiYtkTrNNIDNR2HhQNEak5GDd08gbOm5mvTCaego+EIdL0d6pEk+sNYq3Z1x+Z2pvRX/+Oglexnn7Ii0XCU5ZyTRtQSHUMmRlkOsy5ndp1O3eWTs2eeu9vclMMxY/bInZLK9FA== 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=xcZB2G3swvffgtWrYTxhu0x9x7nPCXrmx/cOUb7B36E=; b=Xu4LbcE0512KsSBGevQc3fijHIIhfG1xNznMGIzcdcBMuVtTkjtgiYhHExP5PMBVgNo2hRLH1S/lY/aFM6WZkx96xQO/6Y31EefV3FmPCDr/SDCwDctb86u+ePiftpwfmmJLTrxJUekpx8A7Pa1+SSYUGXBrU4XVOAfRJIkw1Vox6NPx8yaR3yuLrw5i6U/UEb2Lo0HpnL1mqNTGrIHUiIwz27IjAKt17upNJF0e/RXsbtTNIMbcFUM7shQiDCTn7CqfBVc/ssYaope3lCPif4xqAcwsV1f15Q4qWeqQgjRSffLXyQ1/++edGy/+AsuF4QNnKr6lmrWzyhPdmzVuPA== 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=xcZB2G3swvffgtWrYTxhu0x9x7nPCXrmx/cOUb7B36E=; b=ASUqElk8rRqE2WFtowhRlhLw413kASnSRXB+h5ghTpgjRXN3lPXhp8AYyGc5w1Pt7UFu72/v+sh8xkRGM+OXAU1om67SnOmubY4+KE1yQC1hX45f1V78PNAt2oWe9FcFZpjtbCiLq8JHWdHXM4le56/o0P7t2S8GWnbtuL4oLPo= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by BN9PR12MB5321.namprd12.prod.outlook.com (2603:10b6:408:102::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Fri, 17 Mar 2023 04:12:25 +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 04:12:24 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "Attar, AbdulLateef (Abdul Lateef)" CC: Ard Biesheuvel , Leif Lindholm Subject: Re: [edk2-devel] [PATCH v1 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Topic: [edk2-devel] [PATCH v1 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Thread-Index: AQHZVw1qLYQoQpV4ZUa+wqMk7gV12a7+Xt2w Date: Fri, 17 Mar 2023 04:12:24 +0000 Message-ID: References: In-Reply-To: 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-17T04:12:21Z; 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=a76313a3-412a-4157-8974-bfaa2ecba073; 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_|BN9PR12MB5321:EE_ x-ms-office365-filtering-correlation-id: 76125739-50dc-435f-202b-08db269dd02d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: weMnSEqd8xKNQ1x3htSzUcejAOjk9J7IPxNhayq8B1ep9xfJvpn1pC8Cqit8oSgV4Iq997av9LPbxczcb4qDq/2ipTk37mrFKI2uVjBZUkcnHhoLy9kLBXkLu4NRSczMazoc/u4kQ/vmG+MH2nqvO+vsL5hxd2exbv/v0G/v5cecjGj1Ab/Qx7soISd1p5k6NdtIOZSr4GQktSAGbfYwNHUoGMP5QAXMD+H6XWvJNnw2Jr0/nDHDWRcgKfV54YJ7DhJzkPwjKyVeaqD8ipGSJxQmvzCNxgnPowioldgDza3gES00n3XrLXyRIjCMCrBj4NlUkKZtb/IfkFzXM52Mx2qOkLueg051O9bRJANL6OjUTw9f1kWB6Nd6QBsH4mF+GPhZZXlZiAkiqZgd/dy8sjyltgKtezrLIUw0xA7IbkRRdjDdeeT0jbrERR0bHyRIbxFjtZgiD+nqjPLcTFE6MoWtXa0sG7RJZKOUc5+IM8IF9jjkos57dcmBBTodnMAvmokax5OKHyPQXfKgejx2Ysq+ug/a+kSwibKwnQwmbH7nwgQ/pC39B4d+squrJT5O4f2UOg6gkY5M6TeOV4Pni4swP/WpmvoXoJ0xe3lw0+bO8xsGENVpuwO12Xu0xXWymWan3wdgLmWe4d/y4i3qwZ7eoOA7ZVIXUyhikSs8Hu9zFUWNjg0PPz7ZMa7rARUjrLHFGmZWxy8yN/SXhOx1xg== 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)(396003)(366004)(376002)(39860400002)(346002)(136003)(451199018)(76116006)(38100700002)(2906002)(122000001)(4326008)(71200400001)(64756008)(110136005)(66946007)(41300700001)(316002)(66446008)(8676002)(33656002)(54906003)(478600001)(6636002)(86362001)(7696005)(66556008)(30864003)(5660300002)(55016003)(66476007)(38070700005)(966005)(26005)(6506007)(53546011)(186003)(9686003)(52536014)(66899018)(83380400001)(8936002)(579004)(44824005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?3RH753ysJ23nyHd7lJ+JKkqUSGxeM7/3sEWnKAVCY8b1Ho9ATRT0ks9qk23F?= =?us-ascii?Q?yrVUiFwLOips4cKY4Z9khBjdNN2iUfoef4au5/eSjHvV55QUriqKGTcZFSAi?= =?us-ascii?Q?VrEA/VdlYcoZxrbiNuEzJ9/adjfafVnIn+vhT14XER9EeVne3Sk4d+ZqpJvM?= =?us-ascii?Q?tH5kWIDG59n2eZ+vBB0SROWMVfXmfVFVezNIiD0W/UYheMNRF5+MhTo5EnUo?= =?us-ascii?Q?uCmE1q4+o8lqHryRp2M/J6jqYyrQmGKxU/difNwdD+kPJaBGeZlwEjrDqCsX?= =?us-ascii?Q?pydRr3ceGeedmS5KO8qaRPO/Qa+kmiCVi85mWIAEb7Ge64BV4ZN3CD0JCWoE?= =?us-ascii?Q?49fqMO6nXo4WTYRyAS9O1xQbxoaBvu+LiD1TWDYqVOG8E202gL2YPQIO5c5R?= =?us-ascii?Q?wnU8p2gL6vwBum1K7IMFjPkLWkn1QDEMdcelUHRZa/h150kHell2xMvCj5uw?= =?us-ascii?Q?YcQM8Zmdqy1yNFM24oV8BAwd75vxBsDY5LG1CwgkIzExpbM1+BM8onM9yEL9?= =?us-ascii?Q?NrO8fCOR+MUcmCTDfo3RKJ4wQt4lb1BxYvN2NxjdCQIVNWbyDgM6LxxAhmv5?= =?us-ascii?Q?x/N1PnmZ8gBYHBej67j+z52XDCX9lNLfUwfzfqr21WH1gNaxz40Nrg6AZ+xi?= =?us-ascii?Q?OhT8HmYKuPHvbEWm/l+d0HQw2QIu1Owc/cDiVX6lK1XMnhLV3hqG1QoPSd3C?= =?us-ascii?Q?09P4kT/say/E/zZ3E3WmJQUqCace3gUMzZaM/spi+OE+7rEpzhex9GY4jHNJ?= =?us-ascii?Q?xxnt3yPAZmsC+QLBEsbHlDuYou/6rFMWkwMS53oIhEqat69LsEdlyjuZY3kp?= =?us-ascii?Q?FsEfPZ+NINtVjb7g/u+zXljWaA0mavm4xNFGVUpOicXNkg/ewsrbn1+Qd3kY?= =?us-ascii?Q?8NdamkKGZVtHiKFVoMzV8J8b44+cx/ra6VAiqTA+/jUYFfVkAiw87fXQ8/1l?= =?us-ascii?Q?fphcyptzdBnpXAwGCtBuuDkjsftw9IUVnbqCoh9ZUtOXDXdQmx146MBJGrGG?= =?us-ascii?Q?bD582KmqAdikceG8engDrUSsMfBnG/RzlTHMHiueL5sUffOQwy5pMDX7ff8M?= =?us-ascii?Q?Pssq9Ze8elkllHbaG7ysBGZASBPyiIWcS2auknIZI2mP7wZgjyzaVzZUzjVC?= =?us-ascii?Q?+ctwRy/T5sxLApUsd+HdPuUYjLINzi5/RY4kUbdPulk4kdtCIDMEHWQ1OX/Z?= =?us-ascii?Q?3Trk+7lW7/uFFZj57A59fvv2+XPA82o9T3verElgJoKEg5sQng0KYIiz0MMd?= =?us-ascii?Q?+WxNfFterKdzfOyBSDCe4eycz5GsofRx4kywiqnCEgBas6nljsTcnr+bizx0?= =?us-ascii?Q?yfMzFt4HxDqQ3cHIAh6rkWiAjtQWfaOOu31duUMAc24+qIeFfIrKYHJMfdDS?= =?us-ascii?Q?kQlXlUTdka56UiuB/+nDFItUtvjiZIDScEN7G6loldVufyuY5wHuLDjUyrVu?= =?us-ascii?Q?W1XpL78+FfBsS/8TmzQdWoiCKOoojmqKikNomJ2plUT/bafqALYgNeaI8k6z?= =?us-ascii?Q?QTREXS1CA344/ZcqGC/MMYOOAYj0zfTejs46pKovZ7Dl72wa8LCth6GjVBfB?= =?us-ascii?Q?fewrNu92wy9L55z8pII7NO0dICLlnUFVlA/yAY0k?= 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: 76125739-50dc-435f-202b-08db269dd02d X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Mar 2023 04:12:24.7083 (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: TA/zfRRcqtrNWLkWQ8Nv3SDXTDeqnqVIlb+56nt80B63QXHkhv+FdglXe9vDhIPnh+7oTQ7cG/0HsU/pE3BSag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5321 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Abdul, one comment below, > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Abdul > Lateef Attar via groups.io > Sent: Wednesday, March 15, 2023 3:11 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard > Biesheuvel ; Leif Lindholm > > Subject: [edk2-devel] [PATCH v1 2/4] Platform/AMD/PlatformPkg: Adds > PciHotPlug init protocol implementation >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=20 > Adds PCI hotplug init protocol implementation. >=20 > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Abner Chang Signed-off-by: Abdul Lateef Attar > --- > 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..7a3c8e024e4d > --- /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[in] HpcState The state of the HPC hardware. This should be [out] Abner > + @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 >=20 >=20 >=20 >=20 >=20