From nobody Tue Apr 16 22:33:37 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101304+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679034542413900.494944669411; Thu, 16 Mar 2023 23:29:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tvnIYY1788612xlN6Fz8yxrN; Thu, 16 Mar 2023 23:29:02 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.13425.1679034541325218692 for ; Thu, 16 Mar 2023 23:29:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Brwh+pKyZ67TCvT1iuLH/YiNXCx3DcgzEGCodhl0ioCHIZcrgAUJJSPeq4ZwzNOBg1ev418M0U2W5QrR7wKN/u4vG+JGoDoNE3mk4ckgYiGhEh3aTAnYqAcx6lsGs0t0QB7EvKcLEL4ZwML4r9DGAQOKTd2DeoOXRLsryO5N+C418GXJP7wtlUBcSpdtGXItP5HF5NvBzQbYPLDuvvxHHabP7biUcosSklKZ8cZZsDhT+AvjYc9cLG8PbQGnKWBiLF/8sDVQYPQzwkufZccPlsKpOVXNyLs3AOe9pi9+i5xChiXRnrF9cf0kKviuy34rSZFOLqOQLYaSpKWtktHN/A== 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=g7PlSISi4Ty1tC6eYd4XAXvYIeSo9JXZvUU39vPSeBg=; b=HO7L0JmG33tcfJaXEXpfjRXkhQZeJfUPdvakERkKdXxWeZYjnA+tufOm6Y07mh19t0ZBz+2cmkyMLTLjR51dF793FpeSrWU3JT6UOUSz1G3pkzidHpbxUP7OWVTWbaIMAIQKw0sofm7y3i8u3WDBC2EtclOiVi+Ov9vXwsHVCeZxbuWvcbbthii1xJq4VgKPs6r7AQpuG1kSrVTOwr1CBbETDNO4Yu2wRdthNzC0EBKy0aU6SKQsBnTkuDfy4jU0lbRe8ugF0Xmaxuij8mnyo6N99KmxIXjAcfKEPj3GDxFoEJ4xKh7YzAHDZFEk6dyFg4nbCULxj3H9OfbTQwzUiA== 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 X-Received: from DM6PR10CA0002.namprd10.prod.outlook.com (2603:10b6:5:60::15) by SA0PR12MB7092.namprd12.prod.outlook.com (2603:10b6:806:2d5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.35; Fri, 17 Mar 2023 06:28:58 +0000 X-Received: from DS1PEPF0000E640.namprd02.prod.outlook.com (2603:10b6:5:60:cafe::e5) by DM6PR10CA0002.outlook.office365.com (2603:10b6:5:60::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.31 via Frontend Transport; Fri, 17 Mar 2023 06:28:58 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101304+1787277+3901457@groups.io; helo=mail02.groups.io; 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 X-Received: from SATLEXMB03.amd.com (165.204.84.17) by DS1PEPF0000E640.mail.protection.outlook.com (10.167.17.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.30 via Frontend Transport; Fri, 17 Mar 2023 06:28:58 +0000 X-Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Fri, 17 Mar 2023 01:28:57 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 17 Mar 2023 01:28:56 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Ard Biesheuvel , Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH v2 2/4] Platform/AMD/PlatformPkg: Adds PciHotPlug init protocol implementation Date: Fri, 17 Mar 2023 11:58:46 +0530 Message-ID: <24db6fa295d16423257c47bdb6af6c25b9134ac5.1679034315.git.abdattar@amd.com> In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E640:EE_|SA0PR12MB7092:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f35ef2d-49fd-4de1-2c51-08db26b0e3f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: wuwgbabnu/rIhZK5obB196W6BbBqQGnNVkGNF1c52eT3AddzO/acI7ze7gxvNt9oSs1wGnN1X2ZZQNeI8WZfSlYaRlBUM+lvS5ljqmJIf8tbRz3+67dA7PDQjqcsm5xfZ6puXJ1WtuYQB5FB4Ioyy5WWB9gDBdP/5dZ84lSzkzjn+FKvGVPZz4oEQeAFhNcdSEPu1BH1neJxmSqqIdestpwjqEIWDmZQgRjIrHtG9grBlJDzb947m03EKYXNG1Twsdzb60RBTeDoz/9kjHtBnW/FNsCoGiy/QF9J6TAvPktVRJp92UJWtgwBhUo5GkSAcXZfJ8TTQfuuVQa5ykhBYVrrwCylRNHFwARCAWqCoFYkzcNlbG3SMB8MQWcU6Lo8znMqXRQcm2K0D56T1GK0KKvaxNglx8UjFVLKgJXIDjipQvP5C3xs8rFk9Riym6f/Ls0UBGXgWfgI33kW8D5p0RMm5vHx71D3GDBMZbQKwpFSm494L17b48DeZu1JhubNz/52GhEEROcw1ss8RT5xhZe7/VTtZnBxMPMBLb3vC74cExSZcY/tZkCOJDYu6sbmC6+ij5dyb8P9tTKS5AWIGmmSjrQThWUyMKndm8dHgxoqsdd2BoCydQO1R8pz6f4JF94SaJrWatcbKgnxAkKpGN/vpqRpGXv1i1AJr+CnoYI26Mm+2e/P699VoTWXqcirbunrny2KfTTvq98eb16aBiudkaYGpPProbGeYffQEC/f9PL1UeZdlXQoVb+260Qurs22raffOEW0XnH8rqH6Xw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2023 06:28:58.2740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f35ef2d-49fd-4de1-2c51-08db26b0e3f3 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: DS1PEPF0000E640.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7092 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abdattar@amd.com X-Gm-Message-State: hLss4cneUkbJ8Td7WEHiWcAvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679034542; bh=Q4Oen4Cbs3sIDniw4pXR8HjAsmgHbxtbfhHHnw4g3DE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=gRoMbHg9Agfy0bmiJQ091bNfOW82LmG12C9z3rP+6Oy20T+lQz3RBnCXkRgN+l6vAVu Tr96L9sxVgI1Sf1EJ7TfLLXVP5n0IYNLg7Zb2K5/mn1/xNZqMyxUXV4UtTnQTwfE4AdZg 1vQ8EygOto03iu1NGfPR+JKPxwzboRzkNR8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679034544127100011 Content-Type: text/plain; charset="utf-8" Adds PCI hotplug init protocol implementation. Signed-off-by: Abdul Lateef Attar Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Abner Chang --- 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/Platfo= rmPkg/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-9A23753D1878 PACKAGE_VERSION =3D 0.1 + +[Guids] + gPlatformPkgTokenSpaceGuid =3D { 0x95ECA58D, 0x09B6, 0x4420, { 0xB4,= 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|0x00200000|UINT6= 4|0x10000001 + # Non-PreFetch Memory padding in bytes, default 1MB + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadMem|0x00100000|UINT64= |0x10000002 + # PCI bus padding, number of bus to reserve, default 2 bus + gPlatformPkgTokenSpaceGuid.PcdPciHotPlugResourcePadBus|2|UINT8|0x10000003 diff --git a/Platform/AMD/PlatformPkg/PlatformPkg.dsc b/Platform/AMD/Platfo= rmPkg/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/UefiDriverEntry= Point.inf + UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf + BaseLib|MdePkg/Library/BaseLib/BaseLib.inf + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf + RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLib= Null.inf + SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf + PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf + DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf + IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf + PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatfor= mHookLibNull.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/Platf= orm/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-5F22AB388B0C + 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/Platfor= m/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 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.
+ 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 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_OUT_OF_RESOURCES HpcList was not returned due to insuffic= ient + 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 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_SUCCESS If Event is NULL, the specific HPC was s= uccessfully + initialized. If Event is not NULL, Event= will be + signaled at a later time when initializa= tion is complete. + @retval EFI_UNSUPPORTED This instance of EFI_PCI_HOT_PLUG_INIT_P= ROTOCOL + does not support the specified HPC. + @retval EFI_OUT_OF_RESOURCES Initialization failed due to insufficient + 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 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[out] 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_UNSUPPORTED This instance of the EFI_PCI_HOT_PLUG_IN= IT_PROTOCOL + does not support the specified HPC. + @retval EFI_NOT_READY This function was called before HPC init= ialization + is complete. + @retval EFI_INVALID_PARAMETER HpcState or Padding or Attributes is NUL= L. + @retval EFI_OUT_OF_RESOURCES ACPI 2.0 resource descriptors for Padding + 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; + + // + // 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 PcdGet64 (PcdPciHotPlugResourc= ePadMem); + 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 PcdGet64 (PcdPciHotPlugResourc= ePadPMem); + 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 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 + ); +} --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101304): https://edk2.groups.io/g/devel/message/101304 Mute This Topic: https://groups.io/mt/97667843/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-