From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.51]) by mx.groups.io with SMTP id smtpd.web11.17900.1684747748205651152 for ; Mon, 22 May 2023 02:29:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amd.com header.s=selector1 header.b=SiFuPpPa; 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.223.51, mailfrom: abdullateef.attar@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dawJhWtmBwBqtaqhfwNoJpJSYwcEfcg1uMHCHDALCSp1A9rNwMJt7VHktg7FENGU7byPkitfa+Fu4W5AYsil2Hq5ltKOsy8WUxqPPgtjzhBq3b3LotBiIUWSPMRxMFA1+uCx4wBK9ym0zaYhaIC6JRlF9hUVDgEoyrO00T0mgswN07mvMARAa+pTZv1lLp539ohkRMFRa4WK7qwACg3Krwd+xLEgN2c34d1GESek4Rrbfu1uShvxPXBx44sAGvnH5yiP9ZcLp8T8ypLmhhsHZkILS3j8AYaXZaEN2C0CVwcAIWW8SF4YRH9xqVdzTUNVB0a6cvAeJHR8ErumsAi58A== 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=n60xcaViFxpUe6PGy4HVZX83PSZ2NGAEdPvLkEF3vfU=; b=ZaLWjgUdRUUGfGyc4TDDpXsPmveRKcsiAAppweMFxZUMPrpRhkMdjwcmTL0wnoUrS7eddfsncAaBW+7vh1hBKqYs2EFprQWs3tJ92CgQYDdLAKN6d/XJYIRX5OLDqHydVW30j18vBqWP96y2ER66LfUoHtz/CGn1e+inrB1LNxdH81NxEGZu1qhgy9Bzvd+KhyKSqZIge/5hX1fbLsSVjBCx4uNtZ92Q65Xu0xVPMKCrbPoOtNKNRC+mJu9iHBI6qNFtRPEjTLAPzANoLM1kwdH1kkt/gXZ2eHQQeIXcRoD76EYRsGGt5S1hkzqnZp2OBOsPG+f2NV6hH9GVph3I0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=n60xcaViFxpUe6PGy4HVZX83PSZ2NGAEdPvLkEF3vfU=; b=SiFuPpPaqE6gRxCbRWrdmp8ff8Mvsz03O+MrhO2ij4KXeGXphNm8aRnFftMJFI6dc2qC/uydwsJ2/EVrcfh2B/WQAfQgdd5aHRBfB8JWxkaTO0bjF6Xb+XwtpuXxUzafJtMZHCdUB9XvXaQuG5/tsXE46kLYfZ4hDwcdeWjuRac= Received: from MW4PR03CA0052.namprd03.prod.outlook.com (2603:10b6:303:8e::27) by BL0PR12MB5009.namprd12.prod.outlook.com (2603:10b6:208:1c2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28; Mon, 22 May 2023 09:29:05 +0000 Received: from CO1NAM11FT088.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::57) by MW4PR03CA0052.outlook.office365.com (2603:10b6:303:8e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.28 via Frontend Transport; Mon, 22 May 2023 09:29:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1NAM11FT088.mail.protection.outlook.com (10.13.175.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6411.28 via Frontend Transport; Mon, 22 May 2023 09:29:03 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 22 May 2023 04:29:02 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 22 May 2023 02:29:02 -0700 Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Mon, 22 May 2023 04:29:01 -0500 From: "Abdul Lateef Attar" To: CC: Abdul Lateef Attar , Abner Chang Subject: [PATCH v2 1/2] AMD/AmdMinBoardPkg: Implements PCI hotplug init protocol Date: Mon, 22 May 2023 14:58:50 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Return-Path: AbdulLateef.Attar@amd.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT088:EE_|BL0PR12MB5009:EE_ X-MS-Office365-Filtering-Correlation-Id: f5f14596-4377-449a-5f5e-08db5aa6fbbd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NPTenKe5xBcL7oTNArAdhRnZDZzQGiYi2Hr2QPRuehT0IVAFtlDYec0TA0hyyYz5XUSgBFwD3IxO//6Xdy8Cri8M1Arql7cywbsi+7d7szGP90VitaRFD0oX2eilHIgMS67QgrsW5oXjrgcuS/pvSperV13BNeY/16d6S028JWq/ffgGATeao+afCyz7U+UsrExg3BulgGEfWb6/8wqeAg+vGlVV3iXKS5FC79I6OsfogG3tFadtKiLbdN9u0s5YYD/FE+AZks8uz/cqWPnAVeeWX3meNzq2doGGUqM0OxoSCuSUjYFkC1VtT0Cygx/fGqOIPogKPHl2fsK1psgoiQfUE6tCWblv4JcWyLVxUzLomQaMp3XjVts9aKuP0KXF3rkdHtWOFrSCi+KDxIZYEAUvHuT0bS7Fv+iZQ3NXymT8ByDlaihjVqjoV4dNnn8ylFbiJxUUAiE115fLZT3dd6kqsN68hOxGl1djkgYiYNaefOI5yK/HMiKJ6NeKU/G69e1ZGwRgGyTIg6AwZq6LacceXSgmY6pTvuVhGS4uNWdp/Kh5KqISlmzkQfTJj5P1O75OS+fzSeH4Cii0MbzyrO4MEcvn/nKU6iCBEM6X89Fzw/LnsDnEEiAqFQfAIdylvi6yQrgMr2SR0mOiuab30gjUa4ulrdli1N0u+Aqs76WeeAIr45fhdwaxghz6dwpxEjwDA2PbSfuvHXZAbyxEkY6+EtaJpJ+NLCPMt/ysk2IXYXZyaxgwtoKapRalQ9msy7b2hD+LW1Q6l7aRoHP3apzH1CtpSq2O1wFrwTF/guo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(346002)(376002)(136003)(451199021)(36840700001)(46966006)(40470700004)(81166007)(356005)(8676002)(8936002)(82740400003)(40460700003)(5660300002)(47076005)(40480700001)(26005)(186003)(2906002)(30864003)(2616005)(36756003)(336012)(426003)(83380400001)(82310400005)(36860700001)(54906003)(316002)(6666004)(478600001)(6916009)(4326008)(70206006)(70586007)(41300700001)(7696005)(36900700001)(44824005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 May 2023 09:29:03.6213 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f5f14596-4377-449a-5f5e-08db5aa6fbbd X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT088.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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.i= nf 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-177E5048701B PACKAGE_VERSION =3D 0.1 =20 +[Guids] + gAmdMinBoardPkgTokenSpaceGuid =3D {0xd4d23d79, 0x73bf, 0x460a, {0xa1, 0= xc7, 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|0x1000= 0003 + # IO Resource padding in bytes, default 4KB + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadIo|0x00001000|UINT= 32|0x10000000 + # Non-PreFetch Memory padding in bytes, default 1MB + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem|0x00100000|UIN= T32|0x10000002 + # PreFetch Memory padding in bytes, default 2MB + gAmdMinBoardPkgTokenSpaceGuid.PcdPciHotPlugResourcePadPMem|0x00200000|UI= NT32|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 @@ =20 [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 =20 +[LibraryClasses.common] + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf + DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf + RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLib= Null.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf + UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf + [LibraryClasses.common.PEIM] SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.i= nf =20 @@ -34,3 +44,5 @@ [Components] [Components.IA32] AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf =20 +[Components.X64] + AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf diff --git a/Platform/AMD/AmdMinBoardPkg/PciHotPlug/PciHotPlugInit.inf b/Pl= atform/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-759A48D00C72 + 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/Plat= form/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 Hot= Plug + Controllers (HPCs) and the buses that they control. This protocol also p= rovides + information regarding resource padding. + + @par Note: + This source has the reference of OVMF PciHotPluginit.c and Intel platf= orm PciHotPlug.c. + + This protocol is required only on platforms that support one or more P= CI 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 initial= ization. + 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. Thi= s protocol + is installed on its own separate handle. + + Because the system may include multiple HPCs, one instance of this proto= col + 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 HP= C, it + will call EFI_PCI_HOT_PLUG_INIT_PROTOCOL.InitializeRootHpc(). If Initial= izeRootHpc() + 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() duri= ng the + enumeration process. These HPCs will also require resource padding= . The + platform code must have a priori knowledge of these devices and mu= st know + how to initialize them. There may not be any way to access their P= CI + configuration space before the PCI enumerator programs all the ups= tream + bridges and thus enables the path to these devices. The PCI bus en= umerator + is responsible for determining the PCI bus address of the HPC befo= re it + calls InitializeRootHpc(). + - Nonroot HPC: + These HPCs will not need explicit initialization during enumeratio= n process. + These HPCs will require resource padding. The platform code does n= ot 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 initiali= zation + during the boot process. + + This procedure returns a list of root HPCs. The PCI bus driver must init= ialize + 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 bri= dge, 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 enforced by the + EFI_PCI_HOT_PLUG_INIT_PROTOCOL. The PCI bus driver may not check for s= uch + invalid conditions. The callee allocates the buffer HpcList + + @param[in] This Pointer to the EFI_PCI_HOT_PLUG_INIT_PROTOCOL ins= tance. + @param[out] HpcCount The number of root HPCs that were returned. + @param[out] HpcList The list of root HPCs. HpcCount defines the numbe= r 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 causes + initialization of its subordinate buses. + + This function initializes the specified HPC. At the end of initializatio= n, + the hot-plug slots or sockets (controlled by this HPC) are powered and a= re + 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_PROTOCO= L instance. + @param[in] HpcDevicePath The device path to the HPC that is being ini= tialized. + @param[in] HpcPciAddress The address of the HPC function on the PCI b= us. + @param[in] Event The event that should be signaled when the H= PC + initialization is complete. Set to NULL if = the + caller wants to wait until the entire initia= lization + process is complete. + @param[out] HpcState The state of the HPC hardware. The state is + EFI_HPC_STATE_INITIALIZED or EFI_HPC_STATE_E= NABLED. + + @retval EFI_UNSUPPORTED This instance of EFI_PCI_HOT_PLUG_INIT_P= ROTOCOL + 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 con= trolled + by the specified Hot Plug Controller (HPC). + + This function returns the resource padding that is required by the PCI b= us that + is controlled by the specified HPC. This member function is called for a= ll 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. Thi= s 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_PROTOCO= L instance. + @param[in] HpcDevicePath The device path to the HPC. + @param[in] HpcPciAddress The address of the HPC function on the PCI b= us. + @param[in] HpcState The state of the HPC hardware. + @param[out] Padding The amount of resource padding that is requi= red by the + PCI bus under the control of the specified H= PC. + @param[out] Attributes Describes how padding is accounted for. The = padding + is returned in the form of ACPI 2.0 resource= descriptors. + + @retval EFI_SUCCESS The resource padding was successfully re= turned. + @retval EFI_INVALID_PARAMETER HpcState or Padding or Attributes is NUL= L. + @retval EFI_OUT_OF_RESOURCES ACPI 2.0 resource descriptors for Paddin= g + cannot be allocated due to insufficient = 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_DESCRIPT= OR) - + 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_DESCRIPT= OR) - + 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_SPECI= FIC_FLAG_NON_CACHEABLE; + PaddingResource->AddrRangeMin =3D 0; + PaddingResource->AddrLen =3D (UINT64)PcdGet32 (PcdPciHotPlu= gResourcePadMem); + 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_DESCRIPT= OR) - + 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_SPECI= FIC_FLAG_CACHEABLE_PREFETCHABLE; + PaddingResource->AddrLen =3D (UINT64)PcdGet32 (PcdPciHotPlu= gResourcePadPMem); + 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_DESCRIPT= OR) - + 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 (PcdPciHotPlugResourc= ePadIo); + 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 + ); +} --=20 2.25.1