From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70520+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70520+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018899; cv=none; d=zohomail.com; s=zohoarc; b=n9+otLJcn9uhQZZoueGGgW5uW373ZlOyvmwYOHpg669FwOYQ2wtNA66LOHDvEFSxb79eUtys6WO29VJrN5sfiptz8/6PyBFYtNqksrizSZasbcWzJKlZwv2SqSQ/0jDz2eiIUH/tztaXzSpo5UeMsiTOrJG9tVWWGzmeR9t3WBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018899; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ZKCZYrlFKtZlibz5mSMKJCKzWlMaTDrOSdzN5Nc0O+s=; b=kyW9XbFaVTx20NKUy87t+1zu9+CzJowTdhYWA4Vy3KqqZW7YIf7rv1C9JdXGpxeDacSd4fiViFQaulS9HzIuE9dDpxawL/uRH8yq3mDW+yjbur9mfBh5t+k+LRsaZgdouiA7HA5q3q/IrCXKM0SGM/iCcHbvngdaGxOgK9cyZNE= ARC-Authentication-Results: i=1; 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+70520+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018899830368.16096521536963; Mon, 18 Jan 2021 17:14:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id MFjkYY1788612xwqdpIIhFus; Mon, 18 Jan 2021 17:14:59 -0800 X-Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web10.5399.1611018898567736552 for ; Mon, 18 Jan 2021 17:14:59 -0800 X-Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DKVzZ2YQZzj8Gl; Tue, 19 Jan 2021 09:14:02 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:45 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 01/11] OvmfPkg: Introduce PciHostBridgeUtilityLib class Date: Tue, 19 Jan 2021 09:12:52 +0800 Message-ID: <20210119011302.10908-2-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: 7H8AggeGtJodXSd4gMekRRzbx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018899; bh=zK2diG14GzeFRF0Kr9Pa8PLO1NBJJQf0WCMx1iKtLME=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=pXONPS6XjUl6OfAmk7AyqzYj9OvZZl6i4ICe/fC7C9hlgCOTEBGRSPlzlY8sxEbqmnb QAi7OzOa84kGfAI5xcKsXrHAzcTRpuNBuVXEApJM9Dr64h0stmsPNRLouwjwsM7RaKxFF aQc1Lw7TD/t/ih8bTqlWJiRgtLpR7X/VFe4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce a new PciHostBridgeUtilityLib class to share duplicate code between OvmfPkg and ArmVirtPkg. Extract function PciHostBridgeUtilityResourceConflict from PciHostBridgeResourceConflict in OvmfPkg/PciHostBridgeLib. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Rebecca Cran Cc: Peter Grehan Cc: Anthony Perard Cc: Julien Grall Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- OvmfPkg/OvmfPkg.dec | 4 + OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfXen.dsc | 1 + OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 + OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 37 += +++++++++ OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 38 += +++++++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 41 += --------- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 78 += +++++++++++++++++++ 12 files changed, 166 insertions(+), 39 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 54804962ec02..4348bb45c64a 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -49,6 +49,10 @@ [LibraryClasses] # access. PciCapPciSegmentLib|Include/Library/PciCapPciSegmentLib.h =20 + ## @libraryclass Provide common utility functions to PciHostBridgeLib + # instances in ArmVirtPkg and OvmfPkg. + PciHostBridgeUtilityLib|Include/Library/PciHostBridgeUtilityLib.h + ## @libraryclass Register a status code handler for printing the Boot # Manager's LoadImage() and StartImage() preparations, = and # return codes, to the UEFI console. diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index dad8635c3388..62e97dbe320a 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -669,6 +669,7 @@ [Components] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index 33edf3d2d6b5..9547523018e9 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -662,6 +662,7 @@ [Components] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 75c5f46a7786..3555bd1691f2 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -747,6 +747,7 @@ [Components] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 8693248b4ea0..d668c5c8eda8 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -761,6 +761,7 @@ [Components.X64] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 70ff2bcf2342..ff32efb5ba8b 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -759,6 +759,7 @@ [Components] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 7d31e88907ca..ed34efe8ce47 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -552,6 +552,7 @@ [Components] MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf { PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciH= ostBridgeUtilityLib.inf NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf } MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf { diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPk= g/Library/PciHostBridgeLib/PciHostBridgeLib.inf index 6ec9ec751478..4c56f3c90b3b 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -39,6 +39,7 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib + PciHostBridgeUtilityLib PciLib QemuFwCfgLib =20 diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf new file mode 100644 index 000000000000..1ba8ec3e03c7 --- /dev/null +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -0,0 +1,37 @@ +## @file +# Provide common utility functions to PciHostBridgeLib instances in +# ArmVirtPkg and OvmfPkg. +# +# Copyright (C) 2016, Red Hat, Inc. +# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2020, Huawei Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 1.29 + BASE_NAME =3D PciHostBridgeUtilityLib + FILE_GUID =3D e3aa5932-527a-42e7-86f5-81b144c7e5f1 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PciHostBridgeUtilityLib + +# +# The following information is for reference only and not required by the = build +# tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 ARM +# + +[Sources] + PciHostBridgeUtilityLib.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + DebugLib diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h new file mode 100644 index 000000000000..5ea25ed2f4f4 --- /dev/null +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -0,0 +1,38 @@ +/** @file + Provide common utility functions to PciHostBridgeLib instances in + ArmVirtPkg and OvmfPkg. + + Copyright (C) 2016, Red Hat, Inc. + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__ +#define __PCI_HOST_BRIDGE_UTILITY_LIB_H__ + + +/** + Utility function to inform the platform that the resource conflict happe= ns. + + @param[in] Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the + resources for all the root bridges. The resour= ce + for each root bridge is terminated with END + descriptor and an additional END is appended + indicating the end of the entire resources. The + resource descriptor field values follow the + description in + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOC= OL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeUtilityResourceConflict ( + IN VOID *Configuration + ); + + +#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__ diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index e850f7d183ee..4a176347fd49 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include "PciHostBridge.h" @@ -33,12 +34,6 @@ typedef struct { #pragma pack () =20 =20 -GLOBAL_REMOVE_IF_UNREFERENCED -CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] =3D { - L"Mem", L"I/O", L"Bus" -}; - - STATIC CONST OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate =3D { @@ -407,37 +402,5 @@ PciHostBridgeResourceConflict ( VOID *Configuration ) { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; - UINTN RootBridgeIndex; - DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n")); - - RootBridgeIndex =3D 0; - Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; - while (Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR) { - DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); - for (; Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR; Descript= or++) { - ASSERT (Descriptor->ResType < - ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr) - ); - DEBUG ((DEBUG_ERROR, " %s: Length/Alignment =3D 0x%lx / 0x%lx\n", - mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType= ], - Descriptor->AddrLen, Descriptor->AddrRangeMax - )); - if (Descriptor->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) { - DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag =3D %ld / %02x= %s\n", - Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, - ((Descriptor->SpecificFlag & - EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETC= HABLE - ) !=3D 0) ? L" (Prefetchable)" : L"" - )); - } - } - // - // Skip the END descriptor for root bridge - // - ASSERT (Descriptor->Desc =3D=3D ACPI_END_TAG_DESCRIPTOR); - Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( - (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 - ); - } + PciHostBridgeUtilityResourceConflict (Configuration); } diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c new file mode 100644 index 000000000000..ac94e62612be --- /dev/null +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -0,0 +1,78 @@ +/** @file + Provide common utility functions to PciHostBridgeLib instances in + ArmVirtPkg and OvmfPkg. + + Copyright (C) 2016, Red Hat, Inc. + Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + + +GLOBAL_REMOVE_IF_UNREFERENCED +CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] =3D { + L"Mem", L"I/O", L"Bus" +}; + + +/** + Utility function to inform the platform that the resource conflict happe= ns. + + @param[in] Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the + resources for all the root bridges. The resour= ce + for each root bridge is terminated with END + descriptor and an additional END is appended + indicating the end of the entire resources. The + resource descriptor field values follow the + description in + EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOC= OL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeUtilityResourceConflict ( + IN VOID *Configuration + ) +{ + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; + UINTN RootBridgeIndex; + DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n")); + + RootBridgeIndex =3D 0; + Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; + while (Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR) { + DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); + for (; Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR; Descript= or++) { + ASSERT (Descriptor->ResType < + ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr) + ); + DEBUG ((DEBUG_ERROR, " %s: Length/Alignment =3D 0x%lx / 0x%lx\n", + mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->= ResType], + Descriptor->AddrLen, Descriptor->AddrRangeMax + )); + if (Descriptor->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) { + DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag =3D %ld / %02x= %s\n", + Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, + ((Descriptor->SpecificFlag & + EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETC= HABLE + ) !=3D 0) ? L" (Prefetchable)" : L"" + )); + } + } + // + // Skip the END descriptor for root bridge + // + ASSERT (Descriptor->Desc =3D=3D ACPI_END_TAG_DESCRIPTOR); + Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( + (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 + ); + } +} + --=20 2.29.2 -=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 (#70520): https://edk2.groups.io/g/devel/message/70520 Mute This Topic: https://groups.io/mt/79941624/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70519+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70519+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018898; cv=none; d=zohomail.com; s=zohoarc; b=RdLrV/c469yW5/ZaSomhoKvr4IYtA4PSUTZWnvaoes7a9f3fpuXj2gUCPfTJO6Yw6leT/YKBOKF2Zq7hUJLuA5o83yM7u7WW+7+Pd4YQhu5/tSoumYZuSSUaRBbTBK6xHiA95/6iWazHiy2cOUheec6HVSsmC5hsOmnOdPX7Z5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Af0wxo0Do0vJ+eJ2IUws1Ok9/QTQOq9WRaCzhxROO88=; b=FhO1qwyk5ZxVCN0D7A2NofNKfpMTR0PFfigsDTJl0w8SIYEQgAfuHfKOc2/vuk/OvjG7vKcjZDN1xTHS1fRcT33fkyR0fuYoz/A6OCq+lw8pSw2uftbncegTAUY9DjR542e1zhaL+ZtROFpJvuUhuIwQSHwzLDgEBxju+2eL/RI= ARC-Authentication-Results: i=1; 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+70519+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018898923278.2355881882619; Mon, 18 Jan 2021 17:14:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 85eiYY1788612xphnjTYtbcv; Mon, 18 Jan 2021 17:14:58 -0800 X-Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mx.groups.io with SMTP id smtpd.web11.5330.1611018896705807756 for ; Mon, 18 Jan 2021 17:14:57 -0800 X-Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DKVzH1h4Kz7Wy3; Tue, 19 Jan 2021 09:13:47 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:45 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 02/11] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Date: Tue, 19 Jan 2021 09:12:53 +0800 Message-ID: <20210119011302.10908-3-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: jMStWev8Hlc0sE7xyoMGEl2Tx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018898; bh=rwwu58+u+Ano9qWnk3k//knfsxUEo5MkM+/Z/WKRL2Q=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Pb8gZuP884cmGZq98jTOXNJiTTpchQDU7252IJJJ7O57rrU5Rl2e4PywOPUH6f2DiV1 61urMeC19dcGKqoV5Re7hmGFeaxsLHCbTr9qgT42g9m6uRy1f8KQJ4UqRWufA5oRuGsFi YNQkGOZnj0BNL4CmDxaJNZq9v6YpZFeDwRc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Eliminate currently duplicated code in ArmVirtPkg with the common utility class PciHostBridgeUtilityLib. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- ArmVirtPkg/ArmVirtKvmTool.dsc | 1 + ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf | 2 + ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 44 ++----= -------------- 5 files changed, 8 insertions(+), 41 deletions(-) diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index bf008be50fcb..e027b17bec1b 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -58,6 +58,7 @@ [LibraryClasses.common] PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProdu= cerLib.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.i= nf PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridge= Lib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostB= ridgeUtilityLib.inf =20 TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLib= Null.inf diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index ef5d6dbeaddc..a11ffd9ba553 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -78,6 +78,7 @@ [LibraryClasses.common] PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProdu= cerLib.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.i= nf PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridge= Lib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostB= ridgeUtilityLib.inf =20 !if $(TPM2_ENABLE) =3D=3D TRUE Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index f8f5f7f4b94b..c27752b4d5e5 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -76,6 +76,7 @@ [LibraryClasses.common] PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProdu= cerLib.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.i= nf PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridge= Lib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostB= ridgeUtilityLib.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf =20 [LibraryClasses.common.DXE_DRIVER] diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf= b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf index 277ccfd24546..01d39626d14c 100644 --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf @@ -31,12 +31,14 @@ [Packages] ArmVirtPkg/ArmVirtPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] DebugLib DevicePathLib DxeServicesTableLib MemoryAllocationLib + PciHostBridgeUtilityLib PciPcdProducerLib =20 [FixedPcd] diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b= /ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c index 496b192d2291..d554479bf0de 100644 --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c @@ -7,12 +7,13 @@ =20 **/ #include -#include #include #include #include #include #include +#include +#include #include =20 #include @@ -50,11 +51,6 @@ STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridge= DevicePath =3D { } }; =20 -GLOBAL_REMOVE_IF_UNREFERENCED -CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] =3D { - L"Mem", L"I/O", L"Bus" -}; - // // We expect the "ranges" property of "pci-host-ecam-generic" to consist of // records like this. @@ -435,39 +431,5 @@ PciHostBridgeResourceConflict ( VOID *Configuration ) { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor; - UINTN RootBridgeIndex; - DEBUG ((EFI_D_ERROR, "PciHostBridge: Resource conflict happens!\n")); - - RootBridgeIndex =3D 0; - Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration; - while (Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR) { - DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++)); - for (; Descriptor->Desc =3D=3D ACPI_ADDRESS_SPACE_DESCRIPTOR; Descript= or++) { - ASSERT (Descriptor->ResType < - (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) / - sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0]) - ) - ); - DEBUG ((EFI_D_ERROR, " %s: Length/Alignment =3D 0x%lx / 0x%lx\n", - mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType= ], - Descriptor->AddrLen, Descriptor->AddrRangeMax - )); - if (Descriptor->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) { - DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag =3D %ld / %02x= %s\n", - Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag, - ((Descriptor->SpecificFlag & - EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETC= HABLE - ) !=3D 0) ? L" (Prefetchable)" : L"" - )); - } - } - // - // Skip the END descriptor for root bridge - // - ASSERT (Descriptor->Desc =3D=3D ACPI_END_TAG_DESCRIPTOR); - Descriptor =3D (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)( - (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1 - ); - } + PciHostBridgeUtilityResourceConflict (Configuration); } --=20 2.29.2 -=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 (#70519): https://edk2.groups.io/g/devel/message/70519 Mute This Topic: https://groups.io/mt/79941623/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70516+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70516+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018911; cv=none; d=zohomail.com; s=zohoarc; b=havOR/r+mPVyPoQmJszj1uoVEiZ5IaDC94bbrcEMXnwACnoldwLvtyFi2t6n00REslxjMWAAr90xCpIcHubDtuaoxJu3gy1jp6bfIp4bBIMg/BtGHQW015xmZHQX4NSdUukH9yy45zrkQAUVXMI7tAqt+Fr+NXHra2O3qVZeFMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Pr9eEATsDRt1I1RPh1hvCoohA2qbuSnTGvR96R5zoys=; b=EX33a9Dfl4wZf7LwiskS6NzzVnTbjm5JzpOXaFZcf7euKqBdlrn2rZE634sGqTDWkGK2PyB43KKzuPMPQ3uPOCOd3be4MGmYuyZB6hQmf6reg66keG568j/aeYctOmBJUhytcfzqn7wqr+77z4cTD04E+x4sAzdFDZfyPblugR8= ARC-Authentication-Results: i=1; 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+70516+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018911870586.290115339396; Mon, 18 Jan 2021 17:15:11 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zzkEYY1788612x2yeSh8PUSP; Mon, 18 Jan 2021 17:15:11 -0800 X-Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web10.5397.1611018895126861854 for ; Mon, 18 Jan 2021 17:14:55 -0800 X-Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DKVzH0tMMzj9R0; Tue, 19 Jan 2021 09:13:47 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:46 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen Subject: [edk2-devel] [PATCH v6 03/11] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency Date: Tue, 19 Jan 2021 09:12:54 +0800 Message-ID: <20210119011302.10908-4-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: MesylKwMD3XxETv4RsYmYxH1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018911; bh=HlIS1fJjiZUExmoxENU8p5nsamamks5p3px6iiw4JSQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=TgtCp4jAshF6l8nri+pc5lZjMAoDBhFqtTH8h2PvxLCn02Rb3vRyj4GWKRz7OQElS7U P+0NZK0eBh/qJDiR3nQttM8hYIEENM4zWS81RalmJb+6xWmoYHcyQPk6/JM5uYGXqQ4Ef GGCvPwFFltpmK3n20fu7yhf+PUP/r+eN0hE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" OvmfPkg/PciHostBridgeLib instance fails to list its PcdLib dependency, both between the #include directives, and in the INF file. So let's list the dependency. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Signed-off-by: Jiahui Cen Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 + OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 1 + OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 1 + 3 files changed, 3 insertions(+) diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPk= g/Library/PciHostBridgeLib/PciHostBridgeLib.inf index 4c56f3c90b3b..cec3f1631a72 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -39,6 +39,7 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib + PcdLib PciHostBridgeUtilityLib PciLib QemuFwCfgLib diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 4a176347fd49..bf32455b9f0d 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Librar= y/PciHostBridgeLib/XenSupport.c index e161f14375ca..95ed0a280b9b 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c +++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include "PciHostBridge.h" --=20 2.29.2 -=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 (#70516): https://edk2.groups.io/g/devel/message/70516 Mute This Topic: https://groups.io/mt/79941619/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70514+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70514+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018896; cv=none; d=zohomail.com; s=zohoarc; b=MSFBIjNG+zADr0M+iItMb6I7MdupY2wskcJNCeYKgz/P+Xjnvo8P5zuUo+u2KbhLCigA2TlZ/oh6rtCSluvVDWK664oz2ny5HwGFbnP7G2j1TBQDN+GuBtUKyxeYP6wmKh+k5Tjugo0RbIaItBGbPC8H1Ap5yJXiSX+DMVSD9VA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018896; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=fBvMqghhXQYznjv+lS61g3zWk1ATF3iMWYuBOLMnhFA=; b=AGsddRSYPti51dEF3PeLvy5Hfu55W/QHNuLCR6GaLyuFweAy23RTZYkSJIjuHQuvnO7wKL53yunBH5KNoXvpJ7SCj6WIQMzJJZTXGblJWO/Opbb6tLIXC9RWOQmfd/GR+BtIDc+aODTrIn8khOknfdNbQPe3S/LB3J/DNjAeHZA= ARC-Authentication-Results: i=1; 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+70514+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018896933872.7275954504154; Mon, 18 Jan 2021 17:14:56 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id IO5pYY1788612x29i7IiddwH; Mon, 18 Jan 2021 17:14:56 -0800 X-Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web10.5396.1611018895125494969 for ; Mon, 18 Jan 2021 17:14:55 -0800 X-Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DKVzH32x7zj9Qy; Tue, 19 Jan 2021 09:13:47 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:47 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 04/11] OvmfPkg/PciHostBridgeLib: Extract InitRootBridge() / UninitRootBridge() Date: Tue, 19 Jan 2021 09:12:55 +0800 Message-ID: <20210119011302.10908-5-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: fVEzyLZNP8qS723E72BiEBokx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018896; bh=0LKhTul49TOLWGZVEXzTahhSFYfpqxSrzJFi3/LqP+Y=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Q8TaqsBPIwV2lYxtFjIdiOlpT3WHqbadDImJbUUekzuvUpgMVAZa1P5tVSTtfu1BR8P khj78eOclxuEMQdZh+8rDuo5rRTW5E+gsr5XgNQqCxGjQIlrTgpVCTlo5xmYA3exb5omj 8mZERhQzaq9b5obwQqU+rwefG7fGwBIXQIU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extract InitRootBridge() / UninitRootBridge() to PciHostBridgeUtilityLib as common utility functions. No change of functionality. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 2 - OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 8 + OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 77 = ++++++++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h | 56 = ------- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 158 = +------------------- OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 3 = +- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 158 = ++++++++++++++++++++ 7 files changed, 249 insertions(+), 213 deletions(-) diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPk= g/Library/PciHostBridgeLib/PciHostBridgeLib.inf index cec3f1631a72..7944f94b7743 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -37,7 +37,6 @@ [Packages] [LibraryClasses] BaseMemoryLib DebugLib - DevicePathLib MemoryAllocationLib PcdLib PciHostBridgeUtilityLib @@ -51,5 +50,4 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf index 1ba8ec3e03c7..e3d0a3740952 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -30,8 +30,16 @@ [Sources] PciHostBridgeUtilityLib.c =20 [Packages] + MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + BaseMemoryLib DebugLib + DevicePathLib + MemoryAllocationLib + PcdLib + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h index 5ea25ed2f4f4..8a1ddc2f5e02 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -14,6 +14,83 @@ #define __PCI_HOST_BRIDGE_UTILITY_LIB_H__ =20 =20 +#include + + +/** + Utility function to initialize a PCI_ROOT_BRIDGE structure. + + @param[in] Supports Supported attributes. + + @param[in] Attributes Initial attributes. + + @param[in] AllocAttributes Allocation attributes. + + @param[in] RootBusNumber The bus number to store in RootBus. + + @param[in] MaxSubBusNumber The inclusive maximum bus number that can be + assigned to any subordinate bus found behin= d any + PCI bridge hanging off this root bus. + + The caller is repsonsible for ensuring that + RootBusNumber <=3D MaxSubBusNumber. If + RootBusNumber equals MaxSubBusNumber, then = the + root bus has no room for subordinate buses. + + @param[in] Io IO aperture. + + @param[in] Mem MMIO aperture. + + @param[in] MemAbove4G MMIO aperture above 4G. + + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the + caller) that should be filled in by this + function. + + @retval EFI_SUCCESS Initialization successful. A device path + consisting of an ACPI device path node, wi= th + UID =3D RootBusNumber, has been allocated = and + linked into RootBus. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. +**/ +EFI_STATUS +EFIAPI +PciHostBridgeUtilityInitRootBridge ( + IN UINT64 Supports, + IN UINT64 Attributes, + IN UINT64 AllocAttributes, + IN UINT8 RootBusNumber, + IN UINT8 MaxSubBusNumber, + IN PCI_ROOT_BRIDGE_APERTURE *Io, + IN PCI_ROOT_BRIDGE_APERTURE *Mem, + IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, + IN PCI_ROOT_BRIDGE_APERTURE *PMem, + IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, + OUT PCI_ROOT_BRIDGE *RootBus + ); + + +/** + Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with + PciHostBridgeUtilityInitRootBridge(). + + @param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the call= er and + initialized with PciHostBridgeUtilityInitRootBridge(= ), + that should be uninitialized. This function doesn't = free + RootBus. +**/ +VOID +EFIAPI +PciHostBridgeUtilityUninitRootBridge ( + IN PCI_ROOT_BRIDGE *RootBus + ); + + /** Utility function to inform the platform that the resource conflict happe= ns. =20 diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h b/OvmfPkg/Lib= rary/PciHostBridgeLib/PciHostBridge.h index 134d7411214d..a2e4d8696281 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h @@ -11,59 +11,3 @@ PCI_ROOT_BRIDGE * ScanForRootBridges ( UINTN *NumberOfRootBridges ); - -/** - Initialize a PCI_ROOT_BRIDGE structure. - - @param[in] Supports Supported attributes. - - @param[in] Attributes Initial attributes. - - @param[in] AllocAttributes Allocation attributes. - - @param[in] RootBusNumber The bus number to store in RootBus. - - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behin= d any - PCI bridge hanging off this root bus. - - The caller is repsonsible for ensuring that - RootBusNumber <=3D MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then = the - root bus has no room for subordinate buses. - - @param[in] Io IO aperture. - - @param[in] Mem MMIO aperture. - - @param[in] MemAbove4G MMIO aperture above 4G. - - @param[in] PMem Prefetchable MMIO aperture. - - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. - - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the - caller) that should be filled in by this - function. - - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, wi= th - UID =3D RootBusNumber, has been allocated = and - linked into RootBus. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. -**/ -EFI_STATUS -InitRootBridge ( - IN UINT64 Supports, - IN UINT64 Attributes, - IN UINT64 AllocAttributes, - IN UINT8 RootBusNumber, - IN UINT8 MaxSubBusNumber, - IN PCI_ROOT_BRIDGE_APERTURE *Io, - IN PCI_ROOT_BRIDGE_APERTURE *Mem, - IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, - IN PCI_ROOT_BRIDGE_APERTURE *PMem, - IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, - OUT PCI_ROOT_BRIDGE *RootBus - ); diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index bf32455b9f0d..07fa98110e98 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -10,14 +10,12 @@ #include =20 #include -#include =20 #include #include =20 #include #include -#include #include #include #include @@ -27,156 +25,8 @@ #include "PciHostBridge.h" =20 =20 -#pragma pack(1) -typedef struct { - ACPI_HID_DEVICE_PATH AcpiDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH; -#pragma pack () - - -STATIC -CONST -OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate =3D { - { - { - ACPI_DEVICE_PATH, - ACPI_DP, - { - (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), - (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) - } - }, - EISA_PNP_ID(0x0A03), // HID - 0 // UID - }, - - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture =3D { MAX_UINT64, 0 }; =20 -/** - Initialize a PCI_ROOT_BRIDGE structure. - - @param[in] Supports Supported attributes. - - @param[in] Attributes Initial attributes. - - @param[in] AllocAttributes Allocation attributes. - - @param[in] RootBusNumber The bus number to store in RootBus. - - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behin= d any - PCI bridge hanging off this root bus. - - The caller is repsonsible for ensuring that - RootBusNumber <=3D MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then = the - root bus has no room for subordinate buses. - - @param[in] Io IO aperture. - - @param[in] Mem MMIO aperture. - - @param[in] MemAbove4G MMIO aperture above 4G. - - @param[in] PMem Prefetchable MMIO aperture. - - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. - - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the - caller) that should be filled in by this - function. - - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, wi= th - UID =3D RootBusNumber, has been allocated = and - linked into RootBus. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. -**/ -EFI_STATUS -InitRootBridge ( - IN UINT64 Supports, - IN UINT64 Attributes, - IN UINT64 AllocAttributes, - IN UINT8 RootBusNumber, - IN UINT8 MaxSubBusNumber, - IN PCI_ROOT_BRIDGE_APERTURE *Io, - IN PCI_ROOT_BRIDGE_APERTURE *Mem, - IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, - IN PCI_ROOT_BRIDGE_APERTURE *PMem, - IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, - OUT PCI_ROOT_BRIDGE *RootBus - ) -{ - OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; - - // - // Be safe if other fields are added to PCI_ROOT_BRIDGE later. - // - ZeroMem (RootBus, sizeof *RootBus); - - RootBus->Segment =3D 0; - - RootBus->Supports =3D Supports; - RootBus->Attributes =3D Attributes; - - RootBus->DmaAbove4G =3D FALSE; - - RootBus->AllocationAttributes =3D AllocAttributes; - RootBus->Bus.Base =3D RootBusNumber; - RootBus->Bus.Limit =3D MaxSubBusNumber; - CopyMem (&RootBus->Io, Io, sizeof (*Io)); - CopyMem (&RootBus->Mem, Mem, sizeof (*Mem)); - CopyMem (&RootBus->MemAbove4G, MemAbove4G, sizeof (*MemAbove4G)); - CopyMem (&RootBus->PMem, PMem, sizeof (*PMem)); - CopyMem (&RootBus->PMemAbove4G, PMemAbove4G, sizeof (*PMemAbove4G)); - - RootBus->NoExtendedConfigSpace =3D (PcdGet16 (PcdOvmfHostBridgePciDevId)= !=3D - INTEL_Q35_MCH_DEVICE_ID); - - DevicePath =3D AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate, - &mRootBridgeDevicePathTemplate); - if (DevicePath =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); - return EFI_OUT_OF_RESOURCES; - } - DevicePath->AcpiDevicePath.UID =3D RootBusNumber; - RootBus->DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; - - DEBUG ((DEBUG_INFO, - "%a: populated root bus %d, with room for %d subordinate bus(es)\n", - __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber)); - return EFI_SUCCESS; -} - - -/** - Uninitialize a PCI_ROOT_BRIDGE structure set up with InitRootBridge(). - - param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the calle= r and - initialized with InitRootBridge(), that should be - uninitialized. This function doesn't free RootBus. -**/ -STATIC -VOID -UninitRootBridge ( - IN PCI_ROOT_BRIDGE *RootBus - ) -{ - FreePool (RootBus->DevicePath); -} - =20 /** Return all the root bridge instances in an array. @@ -297,7 +147,7 @@ PciHostBridgeGetRootBridges ( // because now we know how big a bus number range *that* one has, fo= r any // subordinate buses that might exist behind PCI bridges hanging off= it. // - Status =3D InitRootBridge ( + Status =3D PciHostBridgeUtilityInitRootBridge ( Attributes, Attributes, AllocationAttributes, @@ -322,7 +172,7 @@ PciHostBridgeGetRootBridges ( // Install the last root bus (which might be the only, ie. main, root bu= s, if // we've found no extra root buses). // - Status =3D InitRootBridge ( + Status =3D PciHostBridgeUtilityInitRootBridge ( Attributes, Attributes, AllocationAttributes, @@ -346,7 +196,7 @@ PciHostBridgeGetRootBridges ( FreeBridges: while (Initialized > 0) { --Initialized; - UninitRootBridge (&Bridges[Initialized]); + PciHostBridgeUtilityUninitRootBridge (&Bridges[Initialized]); } =20 FreePool (Bridges); @@ -375,7 +225,7 @@ PciHostBridgeFreeRootBridges ( =20 do { --Count; - UninitRootBridge (&Bridges[Count]); + PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]); } while (Count > 0); =20 FreePool (Bridges); diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Librar= y/PciHostBridgeLib/XenSupport.c index 95ed0a280b9b..5dfeba0e6e23 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c +++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "PciHostBridge.h" =20 @@ -453,7 +454,7 @@ ScanForRootBridges ( RootBridges ); ASSERT (RootBridges !=3D NULL); - InitRootBridge ( + PciHostBridgeUtilityInitRootBridge ( Attributes, Attributes, 0, (UINT8) PrimaryBus, (UINT8) SubBus, &Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture, diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index ac94e62612be..92b42566e5f8 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -11,16 +11,174 @@ **/ =20 #include +#include +#include #include +#include +#include +#include #include =20 =20 +#pragma pack(1) +typedef struct { + ACPI_HID_DEVICE_PATH AcpiDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH; +#pragma pack () + + GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] =3D { L"Mem", L"I/O", L"Bus" }; =20 =20 +STATIC +CONST +OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate =3D { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), + (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) + } + }, + EISA_PNP_ID(0x0A03), // HID + 0 // UID + }, + + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } +}; + + +/** + Utility function to initialize a PCI_ROOT_BRIDGE structure. + + @param[in] Supports Supported attributes. + + @param[in] Attributes Initial attributes. + + @param[in] AllocAttributes Allocation attributes. + + @param[in] RootBusNumber The bus number to store in RootBus. + + @param[in] MaxSubBusNumber The inclusive maximum bus number that can be + assigned to any subordinate bus found behin= d any + PCI bridge hanging off this root bus. + + The caller is repsonsible for ensuring that + RootBusNumber <=3D MaxSubBusNumber. If + RootBusNumber equals MaxSubBusNumber, then = the + root bus has no room for subordinate buses. + + @param[in] Io IO aperture. + + @param[in] Mem MMIO aperture. + + @param[in] MemAbove4G MMIO aperture above 4G. + + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the + caller) that should be filled in by this + function. + + @retval EFI_SUCCESS Initialization successful. A device path + consisting of an ACPI device path node, wi= th + UID =3D RootBusNumber, has been allocated = and + linked into RootBus. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. +**/ +EFI_STATUS +EFIAPI +PciHostBridgeUtilityInitRootBridge ( + IN UINT64 Supports, + IN UINT64 Attributes, + IN UINT64 AllocAttributes, + IN UINT8 RootBusNumber, + IN UINT8 MaxSubBusNumber, + IN PCI_ROOT_BRIDGE_APERTURE *Io, + IN PCI_ROOT_BRIDGE_APERTURE *Mem, + IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, + IN PCI_ROOT_BRIDGE_APERTURE *PMem, + IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, + OUT PCI_ROOT_BRIDGE *RootBus + ) +{ + OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; + + // + // Be safe if other fields are added to PCI_ROOT_BRIDGE later. + // + ZeroMem (RootBus, sizeof *RootBus); + + RootBus->Segment =3D 0; + + RootBus->Supports =3D Supports; + RootBus->Attributes =3D Attributes; + + RootBus->DmaAbove4G =3D FALSE; + + RootBus->AllocationAttributes =3D AllocAttributes; + RootBus->Bus.Base =3D RootBusNumber; + RootBus->Bus.Limit =3D MaxSubBusNumber; + CopyMem (&RootBus->Io, Io, sizeof (*Io)); + CopyMem (&RootBus->Mem, Mem, sizeof (*Mem)); + CopyMem (&RootBus->MemAbove4G, MemAbove4G, sizeof (*MemAbove4G)); + CopyMem (&RootBus->PMem, PMem, sizeof (*PMem)); + CopyMem (&RootBus->PMemAbove4G, PMemAbove4G, sizeof (*PMemAbove4G)); + + RootBus->NoExtendedConfigSpace =3D (PcdGet16 (PcdOvmfHostBridgePciDevId)= !=3D + INTEL_Q35_MCH_DEVICE_ID); + + DevicePath =3D AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate, + &mRootBridgeDevicePathTemplate); + if (DevicePath =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); + return EFI_OUT_OF_RESOURCES; + } + DevicePath->AcpiDevicePath.UID =3D RootBusNumber; + RootBus->DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; + + DEBUG ((DEBUG_INFO, + "%a: populated root bus %d, with room for %d subordinate bus(es)\n", + __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber)); + return EFI_SUCCESS; +} + + +/** + Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with + PciHostBridgeUtilityInitRootBridge(). + + @param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the call= er and + initialized with PciHostBridgeUtilityInitRootBridge(= ), + that should be uninitialized. This function doesn't = free + RootBus. +**/ +VOID +EFIAPI +PciHostBridgeUtilityUninitRootBridge ( + IN PCI_ROOT_BRIDGE *RootBus + ) +{ + FreePool (RootBus->DevicePath); +} + + /** Utility function to inform the platform that the resource conflict happe= ns. =20 --=20 2.29.2 -=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 (#70514): https://edk2.groups.io/g/devel/message/70514 Mute This Topic: https://groups.io/mt/79941617/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70517+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70517+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018903; cv=none; d=zohomail.com; s=zohoarc; b=C2emlbFbiouWQFzqMQaEujgRSRk4Zy5wzjLqG27z5pCgzC4t1WD0qtXDClm1dA8XPY2k/H/QxVqG9MyEKJbTgvwonQId7sxo8eYUI7DsR641pWki4FP9/uGN8Js1CDt7jYL2dG81+iJGqFX8Nczcj+SV3zcFaBPVYY4Fk/FMci4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018903; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NYa5lom4PNqUzvvYMgwUyfcCprpPvzD5KxdnfHSnwOc=; b=R44pUOEx6TJjUKsgtdswskBeyZTirFoMUMAzo1erHdKY/KHH7Z+VxAhqXEdUXQeN9F9t474t5PiRcIZYBf99a+99Ej2sPGH48vjgBAaQJNN1r1J+EkvA9UZhRmUkCPBlAtr4Zt3yoc4/wJQUwxS5o5eNRk/J3/Wzl15owq3oA8s= ARC-Authentication-Results: i=1; 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+70517+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 161101890325583.65544001905823; Mon, 18 Jan 2021 17:15:03 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id eNgDYY1788612x0GsNlsJ6Pv; Mon, 18 Jan 2021 17:15:02 -0800 X-Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mx.groups.io with SMTP id smtpd.web11.5328.1611018896462274118 for ; Mon, 18 Jan 2021 17:14:57 -0800 X-Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DKVzK13hFz7Wxc; Tue, 19 Jan 2021 09:13:49 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:47 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 05/11] OvmfPkg/PciHostBridgeUtilityLib: Extend parameters of InitRootBridge() Date: Tue, 19 Jan 2021 09:12:56 +0800 Message-ID: <20210119011302.10908-6-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: nyeeCcFNcI1zspQ89oykjD2Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018902; bh=K76bJWy0ALlqUqsNmtU5dc2/EszIvRTxovCjKw4QwuY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=PfqJr2Qh6G+Sy8KYx8D1YTkOuzEi3YISj5bleLminHp5Rrd3oZoZRGU/sZU4q+jHf8v 68oehRFYCHdx0duaj+XMYzWbBbgfU2yKrHtLhqtBibpwikzwPJwTFm6/Yac5ORkE9mTJH oWIFgRvnPP3mTG0DmhaIyl3zj0VvEDXLLmE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extend parameter list of PciHostBridgeUtilityInitRootBridge() with DmaAbove4G and NoExtendedConfigSpace to prepare for sharing with ArmVirtPkg. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 + OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 4 -- OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 56 += ++++++++-------- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 5 ++ OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 1 + OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 63 += ++++++++++--------- 6 files changed, 73 insertions(+), 57 deletions(-) diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPk= g/Library/PciHostBridgeLib/PciHostBridgeLib.inf index 7944f94b7743..72458262cb42 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -50,4 +50,5 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf index e3d0a3740952..4d6764b702f4 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -39,7 +39,3 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib - PcdLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h index 8a1ddc2f5e02..a44ad5034520 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -20,43 +20,49 @@ /** Utility function to initialize a PCI_ROOT_BRIDGE structure. =20 - @param[in] Supports Supported attributes. + @param[in] Supports Supported attributes. =20 - @param[in] Attributes Initial attributes. + @param[in] Attributes Initial attributes. =20 - @param[in] AllocAttributes Allocation attributes. + @param[in] AllocAttributes Allocation attributes. =20 - @param[in] RootBusNumber The bus number to store in RootBus. + @param[in] DmaAbove4G DMA above 4GB memory. =20 - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behin= d any - PCI bridge hanging off this root bus. + @param[in] NoExtendedConfigSpace No Extended Config Space. =20 - The caller is repsonsible for ensuring that - RootBusNumber <=3D MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then = the - root bus has no room for subordinate buses. + @param[in] RootBusNumber The bus number to store in RootBus. =20 - @param[in] Io IO aperture. + @param[in] MaxSubBusNumber The inclusive maximum bus number that= can + be assigned to any subordinate bus fo= und + behind any PCI bridge hanging off this + root bus. =20 - @param[in] Mem MMIO aperture. + The caller is repsonsible for ensuring + that RootBusNumber <=3D MaxSubBusNumb= er. If + RootBusNumber equals MaxSubBusNumber,= then + the root bus has no room for subordin= ate + buses. =20 - @param[in] MemAbove4G MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] Mem MMIO aperture. =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] MemAbove4G MMIO aperture above 4G. =20 - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the - caller) that should be filled in by this - function. + @param[in] PMem Prefetchable MMIO aperture. =20 - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, wi= th - UID =3D RootBusNumber, has been allocated = and - linked into RootBus. + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. =20 - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @param[out] RootBus The PCI_ROOT_BRIDGE structure (alloca= ted + by the caller) that should be filled = in by + this function. + + @retval EFI_SUCCESS Initialization successful. A device p= ath + consisting of an ACPI device path nod= e, + with UID =3D RootBusNumber, has been + allocated and linked into RootBus. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. **/ EFI_STATUS EFIAPI @@ -64,6 +70,8 @@ PciHostBridgeUtilityInitRootBridge ( IN UINT64 Supports, IN UINT64 Attributes, IN UINT64 AllocAttributes, + IN BOOLEAN DmaAbove4G, + IN BOOLEAN NoExtendedConfigSpace, IN UINT8 RootBusNumber, IN UINT8 MaxSubBusNumber, IN PCI_ROOT_BRIDGE_APERTURE *Io, diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 07fa98110e98..8758d7c12bf0 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -10,6 +10,7 @@ #include =20 #include +#include =20 #include #include @@ -151,6 +152,8 @@ PciHostBridgeGetRootBridges ( Attributes, Attributes, AllocationAttributes, + FALSE, + PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, (UINT8) LastRootBridgeNumber, (UINT8) (RootBridgeNumber - 1), &Io, @@ -176,6 +179,8 @@ PciHostBridgeGetRootBridges ( Attributes, Attributes, AllocationAttributes, + FALSE, + PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, (UINT8) LastRootBridgeNumber, PCI_MAX_BUS, &Io, diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Librar= y/PciHostBridgeLib/XenSupport.c index 5dfeba0e6e23..9ef39f01821b 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c +++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c @@ -456,6 +456,7 @@ ScanForRootBridges ( ASSERT (RootBridges !=3D NULL); PciHostBridgeUtilityInitRootBridge ( Attributes, Attributes, 0, + FALSE, PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEV= ICE_ID, (UINT8) PrimaryBus, (UINT8) SubBus, &Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture, &RootBridges[*NumberOfRootBridges] diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index 92b42566e5f8..bed2d87ea89c 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -11,12 +11,10 @@ **/ =20 #include -#include #include #include #include #include -#include #include =20 =20 @@ -64,43 +62,49 @@ OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathT= emplate =3D { /** Utility function to initialize a PCI_ROOT_BRIDGE structure. =20 - @param[in] Supports Supported attributes. + @param[in] Supports Supported attributes. =20 - @param[in] Attributes Initial attributes. + @param[in] Attributes Initial attributes. =20 - @param[in] AllocAttributes Allocation attributes. + @param[in] AllocAttributes Allocation attributes. =20 - @param[in] RootBusNumber The bus number to store in RootBus. + @param[in] DmaAbove4G DMA above 4GB memory. =20 - @param[in] MaxSubBusNumber The inclusive maximum bus number that can be - assigned to any subordinate bus found behin= d any - PCI bridge hanging off this root bus. + @param[in] NoExtendedConfigSpace No Extended Config Space. =20 - The caller is repsonsible for ensuring that - RootBusNumber <=3D MaxSubBusNumber. If - RootBusNumber equals MaxSubBusNumber, then = the - root bus has no room for subordinate buses. + @param[in] RootBusNumber The bus number to store in RootBus. =20 - @param[in] Io IO aperture. + @param[in] MaxSubBusNumber The inclusive maximum bus number that= can + be assigned to any subordinate bus fo= und + behind any PCI bridge hanging off this + root bus. =20 - @param[in] Mem MMIO aperture. + The caller is repsonsible for ensuring + that RootBusNumber <=3D MaxSubBusNumb= er. If + RootBusNumber equals MaxSubBusNumber,= then + the root bus has no room for subordin= ate + buses. =20 - @param[in] MemAbove4G MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] Mem MMIO aperture. =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] MemAbove4G MMIO aperture above 4G. =20 - @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated by= the - caller) that should be filled in by this - function. + @param[in] PMem Prefetchable MMIO aperture. =20 - @retval EFI_SUCCESS Initialization successful. A device path - consisting of an ACPI device path node, wi= th - UID =3D RootBusNumber, has been allocated = and - linked into RootBus. + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. =20 - @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @param[out] RootBus The PCI_ROOT_BRIDGE structure (alloca= ted + by the caller) that should be filled = in by + this function. + + @retval EFI_SUCCESS Initialization successful. A device p= ath + consisting of an ACPI device path nod= e, + with UID =3D RootBusNumber, has been + allocated and linked into RootBus. + + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. **/ EFI_STATUS EFIAPI @@ -108,6 +112,8 @@ PciHostBridgeUtilityInitRootBridge ( IN UINT64 Supports, IN UINT64 Attributes, IN UINT64 AllocAttributes, + IN BOOLEAN DmaAbove4G, + IN BOOLEAN NoExtendedConfigSpace, IN UINT8 RootBusNumber, IN UINT8 MaxSubBusNumber, IN PCI_ROOT_BRIDGE_APERTURE *Io, @@ -130,7 +136,7 @@ PciHostBridgeUtilityInitRootBridge ( RootBus->Supports =3D Supports; RootBus->Attributes =3D Attributes; =20 - RootBus->DmaAbove4G =3D FALSE; + RootBus->DmaAbove4G =3D DmaAbove4G; =20 RootBus->AllocationAttributes =3D AllocAttributes; RootBus->Bus.Base =3D RootBusNumber; @@ -141,8 +147,7 @@ PciHostBridgeUtilityInitRootBridge ( CopyMem (&RootBus->PMem, PMem, sizeof (*PMem)); CopyMem (&RootBus->PMemAbove4G, PMemAbove4G, sizeof (*PMemAbove4G)); =20 - RootBus->NoExtendedConfigSpace =3D (PcdGet16 (PcdOvmfHostBridgePciDevId)= !=3D - INTEL_Q35_MCH_DEVICE_ID); + RootBus->NoExtendedConfigSpace =3D NoExtendedConfigSpace; =20 DevicePath =3D AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate, &mRootBridgeDevicePathTemplate); --=20 2.29.2 -=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 (#70517): https://edk2.groups.io/g/devel/message/70517 Mute This Topic: https://groups.io/mt/79941620/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70518+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70518+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018906; cv=none; d=zohomail.com; s=zohoarc; b=nMKshXcQE0JNO33Jw4Hm9ukOvkNRpjdLkdDQXtt/6crXhDzHxEQGkxYFQBqB8WDb31e80aCrzU1ilKEXTrpPOecU6nBQI/zwoWpbZmdwHpSsEJp1B10KI6vj9lu8oq0gt0Hy/d33Rs8qFuWOUb5GrsPuVoFHWBzo4kJKH9eLMyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=okG+kiIDcz8zi5wetg/TcbiVE8545AF/O5fR6WAmQKU=; b=Ef0ZUpEXVpDL1iMQZumEHsq0xAdIvdp4G/aZW7PlqHVklPc5FxF8ifyerQeEQ7GWKGtGrXFxploCJbVcDCs5td8Jbs6Y//Q2ZZIy53S7UModyQ7K6+kyWUdQ0cH0YUT0hv41PXCMcmdhuR6h47qb+SfWnB4N+RHZ5PzwK/8m1l8= ARC-Authentication-Results: i=1; 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+70518+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018906063567.052540988537; Mon, 18 Jan 2021 17:15:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id anJNYY1788612xDNM3LSvX1T; Mon, 18 Jan 2021 17:15:05 -0800 X-Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web08.5320.1611018896460234270 for ; Mon, 18 Jan 2021 17:14:57 -0800 X-Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DKVyz25gwzl6fC; Tue, 19 Jan 2021 09:13:31 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:48 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 06/11] ArmVirtPkg/FdtPciHostBridgeLib: Refactor init/uninit of root bridge Date: Tue, 19 Jan 2021 09:12:57 +0800 Message-ID: <20210119011302.10908-7-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: xhVWRCM1tPtX2QzqykvJKWqRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018905; bh=fimG1FMtTwJ0pZK2zn2WA/cVqRFkwBhoSUe8RqLrnRo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=SdiewMDzBO/UxV7s8XGYLts6RZpfCZIPJCp1TuyZ/67ddd0bbtSZW4YxoeafFcFoi22 ebXw3le3L8Tp2m8JcYJR0lHywlVLq4C0wPRuNB9p0pqPkgJy1s/iDAneRyuGPzGoGdyw3 PK0phf3wrBv91KRMHZdpdmwqavB8ONTa1fE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new PciHostBridgeUtilityInitRootBridge()/PciHostBridgeUtilityUninitRootBridge() utility functions. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf | 1 + ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 124 +++++= +++++---------- 2 files changed, 61 insertions(+), 64 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf= b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf index 01d39626d14c..b813a0851d2a 100644 --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf @@ -34,6 +34,7 @@ [Packages] OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + BaseMemoryLib DebugLib DevicePathLib DxeServicesTableLib diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b= /ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c index d554479bf0de..3ec7992b6331 100644 --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c @@ -7,6 +7,7 @@ =20 **/ #include +#include #include #include #include @@ -20,37 +21,6 @@ #include #include =20 -#pragma pack(1) -typedef struct { - ACPI_HID_DEVICE_PATH AcpiDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH; -#pragma pack () - -STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath =3D { - { - { - ACPI_DEVICE_PATH, - ACPI_DP, - { - (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), - (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) - } - }, - EISA_PNP_ID(0x0A03), - 0 - }, - - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { - END_DEVICE_PATH_LENGTH, - 0 - } - } -}; - // // We expect the "ranges" property of "pci-host-ecam-generic" to consist of // records like this. @@ -319,11 +289,18 @@ PciHostBridgeGetRootBridges ( UINTN *Count ) { - UINT64 IoBase, IoSize; - UINT64 Mmio32Base, Mmio32Size; - UINT64 Mmio64Base, Mmio64Size; - UINT32 BusMin, BusMax; - EFI_STATUS Status; + UINT64 IoBase, IoSize; + UINT64 Mmio32Base, Mmio32Size; + UINT64 Mmio64Base, Mmio64Size; + UINT32 BusMin, BusMax; + EFI_STATUS Status; + UINT64 Attributes; + UINT64 AllocationAttributes; + PCI_ROOT_BRIDGE_APERTURE Io; + PCI_ROOT_BRIDGE_APERTURE Mem; + PCI_ROOT_BRIDGE_APERTURE MemAbove4G; + PCI_ROOT_BRIDGE_APERTURE PMem; + PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; =20 if (PcdGet64 (PcdPciExpressBaseAddress) =3D=3D 0) { DEBUG ((EFI_D_INFO, "%a: PCI host bridge not present\n", __FUNCTION__)= ); @@ -341,33 +318,29 @@ PciHostBridgeGetRootBridges ( return NULL; } =20 - *Count =3D 1; + ZeroMem (&Io, sizeof (Io)); + ZeroMem (&Mem, sizeof (Mem)); + ZeroMem (&MemAbove4G, sizeof (MemAbove4G)); + ZeroMem (&PMem, sizeof (PMem)); + ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G)); =20 - mRootBridge.Segment =3D 0; - mRootBridge.Supports =3D EFI_PCI_ATTRIBUTE_ISA_IO_16 | - EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO= | - EFI_PCI_ATTRIBUTE_VGA_IO_16 | - EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; - mRootBridge.Attributes =3D mRootBridge.Supports; + Attributes =3D EFI_PCI_ATTRIBUTE_ISA_IO_16 | + EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO | + EFI_PCI_ATTRIBUTE_VGA_IO_16 | + EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16; =20 - mRootBridge.DmaAbove4G =3D TRUE; - mRootBridge.NoExtendedConfigSpace =3D FALSE; - mRootBridge.ResourceAssigned =3D FALSE; + AllocationAttributes =3D EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM; =20 - mRootBridge.AllocationAttributes =3D EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PM= EM; - - mRootBridge.Bus.Base =3D BusMin; - mRootBridge.Bus.Limit =3D BusMax; - mRootBridge.Io.Base =3D IoBase; - mRootBridge.Io.Limit =3D IoBase + IoSize - 1; - mRootBridge.Mem.Base =3D Mmio32Base; - mRootBridge.Mem.Limit =3D Mmio32Base + Mmio32Size - 1; + Io.Base =3D IoBase; + Io.Limit =3D IoBase + IoSize - 1; + Mem.Base =3D Mmio32Base; + Mem.Limit =3D Mmio32Base + Mmio32Size - 1; =20 if (sizeof (UINTN) =3D=3D sizeof (UINT64)) { - mRootBridge.MemAbove4G.Base =3D Mmio64Base; - mRootBridge.MemAbove4G.Limit =3D Mmio64Base + Mmio64Size - 1; + MemAbove4G.Base =3D Mmio64Base; + MemAbove4G.Limit =3D Mmio64Base + Mmio64Size - 1; if (Mmio64Size > 0) { - mRootBridge.AllocationAttributes |=3D EFI_PCI_HOST_BRIDGE_MEM64_DECO= DE; + AllocationAttributes |=3D EFI_PCI_HOST_BRIDGE_MEM64_DECODE; } } else { // @@ -376,19 +349,41 @@ PciHostBridgeGetRootBridges ( // BARs unless they are allocated below 4 GB. So ignore the range above // 4 GB in this case. // - mRootBridge.MemAbove4G.Base =3D MAX_UINT64; - mRootBridge.MemAbove4G.Limit =3D 0; + MemAbove4G.Base =3D MAX_UINT64; + MemAbove4G.Limit =3D 0; } =20 // // No separate ranges for prefetchable and non-prefetchable BARs // - mRootBridge.PMem.Base =3D MAX_UINT64; - mRootBridge.PMem.Limit =3D 0; - mRootBridge.PMemAbove4G.Base =3D MAX_UINT64; - mRootBridge.PMemAbove4G.Limit =3D 0; + PMem.Base =3D MAX_UINT64; + PMem.Limit =3D 0; + PMemAbove4G.Base =3D MAX_UINT64; + PMemAbove4G.Limit =3D 0; =20 - mRootBridge.DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridg= eDevicePath; + Status =3D PciHostBridgeUtilityInitRootBridge ( + Attributes, + Attributes, + AllocationAttributes, + TRUE, + FALSE, + BusMin, + BusMax, + &Io, + &Mem, + &MemAbove4G, + &PMem, + &PMemAbove4G, + &mRootBridge + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: failed to initialize PCI host bridge: %r\n", + __FUNCTION__, Status)); + *Count =3D 0; + return NULL; + } + + *Count =3D 1; =20 return &mRootBridge; } @@ -408,6 +403,7 @@ PciHostBridgeFreeRootBridges ( ) { ASSERT (Count =3D=3D 1); + PciHostBridgeUtilityUninitRootBridge (Bridges); } =20 /** --=20 2.29.2 -=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 (#70518): https://edk2.groups.io/g/devel/message/70518 Mute This Topic: https://groups.io/mt/79941621/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70521+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70521+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018902; cv=none; d=zohomail.com; s=zohoarc; b=RD8sR3sXLB3+rvLEa5x3WGQQK1a1zIfID6mr69KVvBsDFJBY1uKTt+M+U6avOJd+L5cV8mwrFl+5ULufw6YVxh2wM/yfolknn4BEyu1ja01nZ/S+c7PqAFeiWg9PJBfj7shhUkwGZ+Q9mh2vayUJgtE6FDJ3T62QIuF3ckO/BnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018902; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7foMHXxgsps+fQ+0sXt+9z1ZnulGfz2OfCfRvbRwGnc=; b=LtZEHZByPwpflivA85yy5bqvwDWYuwKyVJGMkhtm20dIRX3Kv0qZfBF88dbzTrBmdDBW9AN/N0yX172N/SUbzKmZDqY63OysKWze33cc3tpoD8PVk37WVwB1zhKNUBYZ8Xd/UPBOZzqBJV/tqGh6Z0oOWoPjqbHqxIYGZj2zJaA= ARC-Authentication-Results: i=1; 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+70521+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018902785666.7938945636378; Mon, 18 Jan 2021 17:15:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6yuWYY1788612xS05bgrxxne; Mon, 18 Jan 2021 17:15:02 -0800 X-Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mx.groups.io with SMTP id smtpd.web11.5332.1611018900402349160 for ; Mon, 18 Jan 2021 17:15:01 -0800 X-Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DKVzL2Tsvz7X66; Tue, 19 Jan 2021 09:13:50 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:48 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 07/11] OvmfPkg/PciHostBridgeLib: Extract GetRootBridges() / FreeRootBridges() Date: Tue, 19 Jan 2021 09:12:58 +0800 Message-ID: <20210119011302.10908-8-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: Kf1Knk4BEYGbnlhQJWMD0cRvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018902; bh=4znXXiP64x9R8kKm4c0AeWLs3aW44kP/GNvdxxqS56g=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=BSc81BbqP7FjRXD2QCYtQPUIWWgvPHpXrObLQBBu5C6/nQq4qCvbwxK7536tetpU715 gUaie1F+8iHSGEk57hVWXezaTNQSQ9vCdIcINALpIrTdU0phTpiIDIXCrvkYI/tshMqIq Wi6e6gLYW49zhZ1ZoSN/GtQ7lSO4H5OZJII= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extract PciHostBridgeGetRootBridges() / PciHostBridgeFreeRootBridges() to PciHostBridgeUtilityLib as common utility functions to share support for scanning extra root bridges. No change of functionality. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 - OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 6 + OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 50 = +++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 138 = +------------- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 197 = ++++++++++++++++++++ 5 files changed, 257 insertions(+), 135 deletions(-) diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPk= g/Library/PciHostBridgeLib/PciHostBridgeLib.inf index 72458262cb42..4610a0c1490b 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -41,7 +41,6 @@ [LibraryClasses] PcdLib PciHostBridgeUtilityLib PciLib - QemuFwCfgLib =20 [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf index 4d6764b702f4..fdae8cfe872e 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -39,3 +39,9 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib + PcdLib + PciLib + QemuFwCfgLib + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h index a44ad5034520..2b7d5d3725c3 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -99,6 +99,56 @@ PciHostBridgeUtilityUninitRootBridge ( ); =20 =20 +/** + Utility function to return all the root bridge instances in an array. + + @param[out] Count The number of root bridge instances. + + @param[in] Attributes Initial attributes. + + @param[in] AllocAttributes Allocation attributes. + + @param[in] Io IO aperture. + + @param[in] Mem MMIO aperture. + + @param[in] MemAbove4G MMIO aperture above 4G. + + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @return All the root bridge instances in an array. +**/ +PCI_ROOT_BRIDGE * +EFIAPI +PciHostBridgeUtilityGetRootBridges ( + OUT UINTN *Count, + IN UINT64 Attributes, + IN UINT64 AllocationAttributes, + IN PCI_ROOT_BRIDGE_APERTURE *Io, + IN PCI_ROOT_BRIDGE_APERTURE *Mem, + IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, + IN PCI_ROOT_BRIDGE_APERTURE *PMem, + IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G + ); + + +/** + Utility function to free root bridge instances array from + PciHostBridgeUtilityGetRootBridges(). + + @param[in] Bridges The root bridge instances array. + @param[in] Count The count of the array. +**/ +VOID +EFIAPI +PciHostBridgeUtilityFreeRootBridges ( + IN PCI_ROOT_BRIDGE *Bridges, + IN UINTN Count + ); + + /** Utility function to inform the platform that the resource conflict happe= ns. =20 diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 8758d7c12bf0..6ac41ff853a9 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -9,9 +9,6 @@ **/ #include =20 -#include -#include - #include #include =20 @@ -21,8 +18,6 @@ #include #include #include -#include -#include #include "PciHostBridge.h" =20 =20 @@ -44,14 +39,6 @@ PciHostBridgeGetRootBridges ( UINTN *Count ) { - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT64 ExtraRootBridges; - PCI_ROOT_BRIDGE *Bridges; - UINTN Initialized; - UINTN LastRootBridgeNumber; - UINTN RootBridgeNumber; UINT64 Attributes; UINT64 AllocationAttributes; PCI_ROOT_BRIDGE_APERTURE Io; @@ -89,123 +76,16 @@ PciHostBridgeGetRootBridges ( Mem.Base =3D PcdGet64 (PcdPciMmio32Base); Mem.Limit =3D PcdGet64 (PcdPciMmio32Base) + (PcdGet64 (PcdPciMmio32Size)= - 1); =20 - *Count =3D 0; - - // - // QEMU provides the number of extra root buses, shortening the exhausti= ve - // search below. If there is no hint, the feature is missing. - // - Status =3D QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgS= ize); - if (EFI_ERROR (Status) || FwCfgSize !=3D sizeof ExtraRootBridges) { - ExtraRootBridges =3D 0; - } else { - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges); - - if (ExtraRootBridges > PCI_MAX_BUS) { - DEBUG ((DEBUG_ERROR, "%a: invalid count of extra root buses (%Lu) " - "reported by QEMU\n", __FUNCTION__, ExtraRootBridges)); - return NULL; - } - DEBUG ((DEBUG_INFO, "%a: %Lu extra root buses reported by QEMU\n", - __FUNCTION__, ExtraRootBridges)); - } - - // - // Allocate the "main" root bridge, and any extra root bridges. - // - Bridges =3D AllocatePool ((1 + (UINTN)ExtraRootBridges) * sizeof *Bridge= s); - if (Bridges =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); - return NULL; - } - Initialized =3D 0; - - // - // The "main" root bus is always there. - // - LastRootBridgeNumber =3D 0; - - // - // Scan all other root buses. If function 0 of any device on a bus retur= ns a - // VendorId register value different from all-bits-one, then that bus is - // alive. - // - for (RootBridgeNumber =3D 1; - RootBridgeNumber <=3D PCI_MAX_BUS && Initialized < ExtraRootBridges; - ++RootBridgeNumber) { - UINTN Device; - - for (Device =3D 0; Device <=3D PCI_MAX_DEVICE; ++Device) { - if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0, - PCI_VENDOR_ID_OFFSET)) !=3D MAX_UINT16) { - break; - } - } - if (Device <=3D PCI_MAX_DEVICE) { - // - // Found the next root bus. We can now install the *previous* one, - // because now we know how big a bus number range *that* one has, fo= r any - // subordinate buses that might exist behind PCI bridges hanging off= it. - // - Status =3D PciHostBridgeUtilityInitRootBridge ( - Attributes, - Attributes, - AllocationAttributes, - FALSE, - PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, - (UINT8) LastRootBridgeNumber, - (UINT8) (RootBridgeNumber - 1), - &Io, - &Mem, - &MemAbove4G, - &mNonExistAperture, - &mNonExistAperture, - &Bridges[Initialized] - ); - if (EFI_ERROR (Status)) { - goto FreeBridges; - } - ++Initialized; - LastRootBridgeNumber =3D RootBridgeNumber; - } - } - - // - // Install the last root bus (which might be the only, ie. main, root bu= s, if - // we've found no extra root buses). - // - Status =3D PciHostBridgeUtilityInitRootBridge ( - Attributes, + return PciHostBridgeUtilityGetRootBridges ( + Count, Attributes, AllocationAttributes, - FALSE, - PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, - (UINT8) LastRootBridgeNumber, - PCI_MAX_BUS, &Io, &Mem, &MemAbove4G, &mNonExistAperture, - &mNonExistAperture, - &Bridges[Initialized] + &mNonExistAperture ); - if (EFI_ERROR (Status)) { - goto FreeBridges; - } - ++Initialized; - - *Count =3D Initialized; - return Bridges; - -FreeBridges: - while (Initialized > 0) { - --Initialized; - PciHostBridgeUtilityUninitRootBridge (&Bridges[Initialized]); - } - - FreePool (Bridges); - return NULL; } =20 =20 @@ -223,17 +103,7 @@ PciHostBridgeFreeRootBridges ( UINTN Count ) { - if (Bridges =3D=3D NULL && Count =3D=3D 0) { - return; - } - ASSERT (Bridges !=3D NULL && Count > 0); - - do { - --Count; - PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]); - } while (Count > 0); - - FreePool (Bridges); + PciHostBridgeUtilityFreeRootBridges (Bridges, Count); } =20 =20 diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index bed2d87ea89c..b1e74a469d50 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -11,11 +11,16 @@ **/ =20 #include +#include +#include #include #include #include #include +#include #include +#include +#include =20 =20 #pragma pack(1) @@ -184,6 +189,198 @@ PciHostBridgeUtilityUninitRootBridge ( } =20 =20 +/** + Utility function to return all the root bridge instances in an array. + + @param[out] Count The number of root bridge instances. + + @param[in] Attributes Initial attributes. + + @param[in] AllocAttributes Allocation attributes. + + @param[in] Io IO aperture. + + @param[in] Mem MMIO aperture. + + @param[in] MemAbove4G MMIO aperture above 4G. + + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @return All the root bridge instances in an array. +**/ +PCI_ROOT_BRIDGE * +EFIAPI +PciHostBridgeUtilityGetRootBridges ( + OUT UINTN *Count, + IN UINT64 Attributes, + IN UINT64 AllocationAttributes, + IN PCI_ROOT_BRIDGE_APERTURE *Io, + IN PCI_ROOT_BRIDGE_APERTURE *Mem, + IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, + IN PCI_ROOT_BRIDGE_APERTURE *PMem, + IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G + ) +{ + EFI_STATUS Status; + FIRMWARE_CONFIG_ITEM FwCfgItem; + UINTN FwCfgSize; + UINT64 ExtraRootBridges; + PCI_ROOT_BRIDGE *Bridges; + UINTN Initialized; + UINTN LastRootBridgeNumber; + UINTN RootBridgeNumber; + + // + // QEMU provides the number of extra root buses, shortening the exhausti= ve + // search below. If there is no hint, the feature is missing. + // + Status =3D QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgS= ize); + if (EFI_ERROR (Status) || FwCfgSize !=3D sizeof ExtraRootBridges) { + ExtraRootBridges =3D 0; + } else { + QemuFwCfgSelectItem (FwCfgItem); + QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges); + + if (ExtraRootBridges > PCI_MAX_BUS) { + DEBUG ((DEBUG_ERROR, "%a: invalid count of extra root buses (%Lu) " + "reported by QEMU\n", __FUNCTION__, ExtraRootBridges)); + *Count =3D 0; + return NULL; + } + DEBUG ((DEBUG_INFO, "%a: %Lu extra root buses reported by QEMU\n", + __FUNCTION__, ExtraRootBridges)); + } + + // + // Allocate the "main" root bridge, and any extra root bridges. + // + Bridges =3D AllocatePool ((1 + (UINTN)ExtraRootBridges) * sizeof *Bridge= s); + if (Bridges =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); + *Count =3D 0; + return NULL; + } + Initialized =3D 0; + + // + // The "main" root bus is always there. + // + LastRootBridgeNumber =3D 0; + + // + // Scan all other root buses. If function 0 of any device on a bus retur= ns a + // VendorId register value different from all-bits-one, then that bus is + // alive. + // + for (RootBridgeNumber =3D 1; + RootBridgeNumber <=3D PCI_MAX_BUS && Initialized < ExtraRootBridges; + ++RootBridgeNumber) { + UINTN Device; + + for (Device =3D 0; Device <=3D PCI_MAX_DEVICE; ++Device) { + if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0, + PCI_VENDOR_ID_OFFSET)) !=3D MAX_UINT16) { + break; + } + } + if (Device <=3D PCI_MAX_DEVICE) { + // + // Found the next root bus. We can now install the *previous* one, + // because now we know how big a bus number range *that* one has, fo= r any + // subordinate buses that might exist behind PCI bridges hanging off= it. + // + Status =3D PciHostBridgeUtilityInitRootBridge ( + Attributes, + Attributes, + AllocationAttributes, + FALSE, + PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + (UINT8) LastRootBridgeNumber, + (UINT8) (RootBridgeNumber - 1), + Io, + Mem, + MemAbove4G, + PMem, + PMemAbove4G, + &Bridges[Initialized] + ); + if (EFI_ERROR (Status)) { + goto FreeBridges; + } + ++Initialized; + LastRootBridgeNumber =3D RootBridgeNumber; + } + } + + // + // Install the last root bus (which might be the only, ie. main, root bu= s, if + // we've found no extra root buses). + // + Status =3D PciHostBridgeUtilityInitRootBridge ( + Attributes, + Attributes, + AllocationAttributes, + FALSE, + PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + (UINT8) LastRootBridgeNumber, + PCI_MAX_BUS, + Io, + Mem, + MemAbove4G, + PMem, + PMemAbove4G, + &Bridges[Initialized] + ); + if (EFI_ERROR (Status)) { + goto FreeBridges; + } + ++Initialized; + + *Count =3D Initialized; + return Bridges; + +FreeBridges: + while (Initialized > 0) { + --Initialized; + PciHostBridgeUtilityUninitRootBridge (&Bridges[Initialized]); + } + + FreePool (Bridges); + *Count =3D 0; + return NULL; +} + + +/** + Utility function to free root bridge instances array from + PciHostBridgeUtilityGetRootBridges(). + + @param[in] Bridges The root bridge instances array. + @param[in] Count The count of the array. +**/ +VOID +EFIAPI +PciHostBridgeUtilityFreeRootBridges ( + IN PCI_ROOT_BRIDGE *Bridges, + IN UINTN Count + ) +{ + if (Bridges =3D=3D NULL && Count =3D=3D 0) { + return; + } + ASSERT (Bridges !=3D NULL && Count > 0); + + do { + --Count; + PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]); + } while (Count > 0); + + FreePool (Bridges); +} + + /** Utility function to inform the platform that the resource conflict happe= ns. =20 --=20 2.29.2 -=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 (#70521): https://edk2.groups.io/g/devel/message/70521 Mute This Topic: https://groups.io/mt/79941626/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70525+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70525+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018910; cv=none; d=zohomail.com; s=zohoarc; b=OZ0Va7M+7k+MhXUSDm423CJXA8InER7g7u3YWaC2/J9+BRejO8Q59Gvgz8F6pffGnNjtqRznFRi5I2i87bKMng4lzoqz3eZKsZjsOZ5VpSECOU9HuMe50vmi/3SNHAJrcnU2WEOg20aST+5CEQflr1Ge3DCgy6N0eeVhg8JyBFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018910; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=+3xIDFtKkh/3k8H7WCXORYbKxYJfXiWYvgR+KB1Fvxk=; b=TahDog6KChPr80Nw8JhzLxX8n6gX/jii+YYLTxvsKSNEMKVMLn5Td7SeF6g0uJgi6LGjrQ9tEsF3SOGGrl5HqHElXRuHEZzk/75cP8LcrnogOJU7fSk4keNcJn+V8DGuKFZi+GhhRIX6KhA+pTSKQTcHXp8xsvdY8ZwPCZdcw7Q= ARC-Authentication-Results: i=1; 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+70525+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018910712233.07999316125688; Mon, 18 Jan 2021 17:15:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZXNGYY1788612xlAR3xj65Yg; Mon, 18 Jan 2021 17:15:10 -0800 X-Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web12.5520.1611018903514289976 for ; Mon, 18 Jan 2021 17:15:04 -0800 X-Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DKVzP6yJSz15vhD; Tue, 19 Jan 2021 09:13:53 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:49 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 08/11] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Date: Tue, 19 Jan 2021 09:12:59 +0800 Message-ID: <20210119011302.10908-9-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: Kp8akP1biOpoyjahzZM1wa3Gx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018910; bh=4aBc1177EwLgoQ0w7RcHI/2RBNvJw0clh1ZOVYMKD+8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=aQ+2U24XWGCsE1M9hplS79rBhhfI01XAWjJU7UpiDzQaNWyQCGmPNayOCgfkIOnvoWT s/aA8qb6OfOayvGMrtrAEqe0KuFMTw6g4qajnsUNbiOXuiXqdFZZdQTDQXkFz6cpA7UdX +6Ol19keskbBxgmpnb1uH5P5bE9Ofx0kO5s= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extend parameter list of PciHostBridgeUtilityGetRootBridges() with DmaAbove4G, NoExtendedConfigSpace to support for ArmVirtPkg. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 4 -= -- OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 24 += +++++++------ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 5 += ++ OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 34 += ++++++++++--------- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.inf b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf index fdae8cfe872e..83a734c1725e 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf @@ -39,9 +39,5 @@ [LibraryClasses] DebugLib DevicePathLib MemoryAllocationLib - PcdLib PciLib QemuFwCfgLib - -[Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h index 2b7d5d3725c3..a0ea44d96a67 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -102,23 +102,27 @@ PciHostBridgeUtilityUninitRootBridge ( /** Utility function to return all the root bridge instances in an array. =20 - @param[out] Count The number of root bridge instances. + @param[out] Count The number of root bridge instances. =20 - @param[in] Attributes Initial attributes. + @param[in] Attributes Initial attributes. =20 - @param[in] AllocAttributes Allocation attributes. + @param[in] AllocAttributes Allocation attributes. =20 - @param[in] Io IO aperture. + @param[in] DmaAbove4G DMA above 4GB memory. =20 - @param[in] Mem MMIO aperture. + @param[in] NoExtendedConfigSpace No Extended Config Space. =20 - @param[in] MemAbove4G MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] Mem MMIO aperture. =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] MemAbove4G MMIO aperture above 4G. =20 - @return All the root bridge instances in an array. + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @return All the root bridge instances in an a= rray. **/ PCI_ROOT_BRIDGE * EFIAPI @@ -126,6 +130,8 @@ PciHostBridgeUtilityGetRootBridges ( OUT UINTN *Count, IN UINT64 Attributes, IN UINT64 AllocationAttributes, + IN BOOLEAN DmaAbove4G, + IN BOOLEAN NoExtendedConfigSpace, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 6ac41ff853a9..91b9e6baa1e8 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -9,6 +9,9 @@ **/ #include =20 +#include +#include + #include #include =20 @@ -80,6 +83,8 @@ PciHostBridgeGetRootBridges ( Count, Attributes, AllocationAttributes, + FALSE, + PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, &Io, &Mem, &MemAbove4G, diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index b1e74a469d50..1d78984b83ad 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -12,12 +12,10 @@ =20 #include #include -#include #include #include #include #include -#include #include #include #include @@ -192,23 +190,27 @@ PciHostBridgeUtilityUninitRootBridge ( /** Utility function to return all the root bridge instances in an array. =20 - @param[out] Count The number of root bridge instances. + @param[out] Count The number of root bridge instances. =20 - @param[in] Attributes Initial attributes. + @param[in] Attributes Initial attributes. =20 - @param[in] AllocAttributes Allocation attributes. + @param[in] AllocAttributes Allocation attributes. =20 - @param[in] Io IO aperture. + @param[in] DmaAbove4G DMA above 4GB memory. =20 - @param[in] Mem MMIO aperture. + @param[in] NoExtendedConfigSpace No Extended Config Space. =20 - @param[in] MemAbove4G MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] Mem MMIO aperture. =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] MemAbove4G MMIO aperture above 4G. =20 - @return All the root bridge instances in an array. + @param[in] PMem Prefetchable MMIO aperture. + + @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + + @return All the root bridge instances in an a= rray. **/ PCI_ROOT_BRIDGE * EFIAPI @@ -216,6 +218,8 @@ PciHostBridgeUtilityGetRootBridges ( OUT UINTN *Count, IN UINT64 Attributes, IN UINT64 AllocationAttributes, + IN BOOLEAN DmaAbove4G, + IN BOOLEAN NoExtendedConfigSpace, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, @@ -295,8 +299,8 @@ PciHostBridgeUtilityGetRootBridges ( Attributes, Attributes, AllocationAttributes, - FALSE, - PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + DmaAbove4G, + NoExtendedConfigSpace, (UINT8) LastRootBridgeNumber, (UINT8) (RootBridgeNumber - 1), Io, @@ -322,8 +326,8 @@ PciHostBridgeUtilityGetRootBridges ( Attributes, Attributes, AllocationAttributes, - FALSE, - PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + DmaAbove4G, + NoExtendedConfigSpace, (UINT8) LastRootBridgeNumber, PCI_MAX_BUS, Io, --=20 2.29.2 -=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 (#70525): https://edk2.groups.io/g/devel/message/70525 Mute This Topic: https://groups.io/mt/79941635/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70522+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70522+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018908; cv=none; d=zohomail.com; s=zohoarc; b=FjkWP3lnSKnVD7BxMX41ts3I5/t2CSZcPhKdKy+qobCNuv3TXduwkgOHvKLOFl2fsrkOF9kHukT5j60ZA63VqtflO4TWFeIf9DRHHO+vE+ly53Qb5kkvMWzsngI1Bj4LslcogxOeGMw3YGJqNv0yZkuia6k6WPkkDRLuvAEDat8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018908; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=m+1KvAqI8jAk6bOAjV6CTM4I4oE7wyEM8yCtCVlMKF0=; b=gQF1+kpTNc4eie4XW7Y30mMrOhYzo1wBJslmq+MPQ3gFWy79KGNVBlgcAUkxWsz38M7/la3fH1V7QDMs0mjFH5ZgZOKkxqd1CfotTT0QpbU+Q3y6eIgBVvv3+oecXCjzW60s29PuPTyW2B2H541ygzhYUGtP1xyzYK3ZfumWpNc= ARC-Authentication-Results: i=1; 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+70522+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018908150120.0307399490614; Mon, 18 Jan 2021 17:15:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Gs2EYY1788612xK8bDWceOSD; Mon, 18 Jan 2021 17:15:07 -0800 X-Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web12.5518.1611018901761625442 for ; Mon, 18 Jan 2021 17:15:02 -0800 X-Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DKVzc3pdjzj8GX; Tue, 19 Jan 2021 09:14:04 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:50 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen Subject: [edk2-devel] [PATCH v6 09/11] OvmfPkg/PciHostBridgeUtilityLib: Extend GetRootBridges() with BusMin/BusMax Date: Tue, 19 Jan 2021 09:13:00 +0800 Message-ID: <20210119011302.10908-10-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: KyNkH4e3PxFutFzteEH968O9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018907; bh=I37dIH4NGvTuX5mjIujtUxAN2WHVc4+TatweOvZ8yE4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=T/1+8gT8qewQVb9zaOVHN+1ED7x5nfJoYRUaCN2PZuhdwIXHduX2oiy6v4y6cmk+XyP pYN10Xkjfm7UpDBwbpwaDVRQfTtvhgaOQtzC1tBzzlkdz95jOZKMru0NVB7+UkBnT4cjS 6zNu+iOi/5/sxsiAKqR79FbroO32OzxbM9c= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extend parameter list of PciHostBridgeUtilityGetRootBridges() with BusMin/ BusMax, so that the utility function could be compatible with ArmVirtPkg who uses mutable bus range [BusMin, BusMax] insteand of [0, PCI_MAX_BUS]. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Signed-off-by: Jiahui Cen Reviewed-by: Laszlo Ersek --- OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 6 ++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 2 ++ OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 30 +++= +++++++++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/In= clude/Library/PciHostBridgeUtilityLib.h index a0ea44d96a67..d2dc18a1afad 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -112,6 +112,10 @@ PciHostBridgeUtilityUninitRootBridge ( =20 @param[in] NoExtendedConfigSpace No Extended Config Space. =20 + @param[in] BusMin Minimum Bus number, inclusive. + + @param[in] BusMax Maximum Bus number, inclusive. + @param[in] Io IO aperture. =20 @param[in] Mem MMIO aperture. @@ -132,6 +136,8 @@ PciHostBridgeUtilityGetRootBridges ( IN UINT64 AllocationAttributes, IN BOOLEAN DmaAbove4G, IN BOOLEAN NoExtendedConfigSpace, + IN UINTN BusMin, + IN UINTN BusMax, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 91b9e6baa1e8..7d9fb0fb293a 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -85,6 +85,8 @@ PciHostBridgeGetRootBridges ( AllocationAttributes, FALSE, PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + 0, + PCI_MAX_BUS, &Io, &Mem, &MemAbove4G, diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLi= b.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index 1d78984b83ad..69bed5c7843f 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -200,6 +200,10 @@ PciHostBridgeUtilityUninitRootBridge ( =20 @param[in] NoExtendedConfigSpace No Extended Config Space. =20 + @param[in] BusMin Minimum Bus number, inclusive. + + @param[in] BusMax Maximum Bus number, inclusive. + @param[in] Io IO aperture. =20 @param[in] Mem MMIO aperture. @@ -220,6 +224,8 @@ PciHostBridgeUtilityGetRootBridges ( IN UINT64 AllocationAttributes, IN BOOLEAN DmaAbove4G, IN BOOLEAN NoExtendedConfigSpace, + IN UINTN BusMin, + IN UINTN BusMax, IN PCI_ROOT_BRIDGE_APERTURE *Io, IN PCI_ROOT_BRIDGE_APERTURE *Mem, IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, @@ -236,6 +242,13 @@ PciHostBridgeUtilityGetRootBridges ( UINTN LastRootBridgeNumber; UINTN RootBridgeNumber; =20 + if (BusMin > BusMax || BusMax > PCI_MAX_BUS) { + DEBUG ((DEBUG_ERROR, "%a: invalid bus range with BusMin %d and BusMax = %d\n", + __FUNCTION__, BusMin, BusMax)); + *Count =3D 0; + return NULL; + } + // // QEMU provides the number of extra root buses, shortening the exhausti= ve // search below. If there is no hint, the feature is missing. @@ -247,7 +260,14 @@ PciHostBridgeUtilityGetRootBridges ( QemuFwCfgSelectItem (FwCfgItem); QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges); =20 - if (ExtraRootBridges > PCI_MAX_BUS) { + // + // Validate the number of extra root bridges. As BusMax is inclusive, = the + // max bus count is (BusMax - BusMin + 1). From that, the "main" root = bus + // is always givin, so the max count for the "extra" root bridges is o= ne + // less, i.e. (BusMax - BusMin). If QEME hint exceeds that, we have in= valid + // behavior. + // + if (ExtraRootBridges > BusMax - BusMin) { DEBUG ((DEBUG_ERROR, "%a: invalid count of extra root buses (%Lu) " "reported by QEMU\n", __FUNCTION__, ExtraRootBridges)); *Count =3D 0; @@ -271,15 +291,15 @@ PciHostBridgeUtilityGetRootBridges ( // // The "main" root bus is always there. // - LastRootBridgeNumber =3D 0; + LastRootBridgeNumber =3D BusMin; =20 // // Scan all other root buses. If function 0 of any device on a bus retur= ns a // VendorId register value different from all-bits-one, then that bus is // alive. // - for (RootBridgeNumber =3D 1; - RootBridgeNumber <=3D PCI_MAX_BUS && Initialized < ExtraRootBridges; + for (RootBridgeNumber =3D BusMin + 1; + RootBridgeNumber <=3D BusMax && Initialized < ExtraRootBridges; ++RootBridgeNumber) { UINTN Device; =20 @@ -329,7 +349,7 @@ PciHostBridgeUtilityGetRootBridges ( DmaAbove4G, NoExtendedConfigSpace, (UINT8) LastRootBridgeNumber, - PCI_MAX_BUS, + (UINT8) BusMax, Io, Mem, MemAbove4G, --=20 2.29.2 -=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 (#70522): https://edk2.groups.io/g/devel/message/70522 Mute This Topic: https://groups.io/mt/79941629/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70523+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70523+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018908; cv=none; d=zohomail.com; s=zohoarc; b=Vw0kiHJOEgd44BLZP4ZrExUiUk7nwk/kFsWv4nnOFvIakrOYdGF4H0HYU5rSWXqV55n3VQXtnKwqnrRtLFPHKEgon6f8CFbJbV4unzWK9o9sshEvYfqKWdZGDVN1uSMlXe7wU5JiCv79Xo/HbRkdlSfvArDbNhnBE1apHczzPyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018908; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=dtYtXuLA1OdMRb9rnI4Tt4xq9VvUD3uq3AH9+eFYgzE=; b=VCJgfLUhoI6ikg+NuQ6uuP3KUc0dFsDe0xP3Nwbp070MJYSqtdI+Mn0NL+3B42lfDw20xuCC2BYhElgVXRWZrt5AqaAPROuhKLyOa1wjh9OFwU1npRXqs9npme09QSeIUT+taCWuUk8o3woFkwLQimA2BneFaI/ysL+T2R0yAPg= ARC-Authentication-Results: i=1; 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+70523+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018908577391.5947821193455; Mon, 18 Jan 2021 17:15:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UzOwYY1788612xk3UXrtGM8a; Mon, 18 Jan 2021 17:15:08 -0800 X-Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web08.5322.1611018902051082868 for ; Mon, 18 Jan 2021 17:15:02 -0800 X-Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DKVzf4Zm3zj8GY; Tue, 19 Jan 2021 09:14:06 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:50 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 10/11] ArmVirtPkg/FdtPciHostBridgeLib: Add extra pci root buses support Date: Tue, 19 Jan 2021 09:13:01 +0800 Message-ID: <20210119011302.10908-11-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: gLq8GpajDx1Qr3jBjPO1b2EDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018908; bh=gl7dPUsuPI/MeIr5kzwPfeRaFBjSJvjDm+nyfNbrwAM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=eUocTMfk9xhkn2n06w9E933fkBj1Ue50xlryT7EsGoKBeyh0YtfcG7CUlwuT8aj+2CX Ot3NLanUD0iBcuwNM2/kZa1qwhj9CB1Cvl33nKz2HJs2BvRKFxGCJC9/3CfW1oSJu+MSj bxgATkT7/A1F92Bb+7qQfJXlKJq6oCu72ZA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In order to take advantages of extra pci root buses in ArmVirtPkg, it is necessary to scan extra root buses when getting root briges. And now PciHostBridgeUtilityLib already provides a set of utility functions that support for extra pci root buses, like PciHostBridgeUtilityGetRootBridges() / PciHostBridgeUtilityFreeRootBridges(). So let's rebase ArmVirtPkg/FdtPciHostBridgeLib to PciHostBridgeUtilityGetRootBridges() / PciHostBridgeUtilityFreeRootBridges() to extend ArmVirtPkg with extra pci root buses support. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 22 ++++----= ------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b= /ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c index 3ec7992b6331..0099b8e3c391 100644 --- a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c +++ b/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c @@ -272,8 +272,6 @@ ProcessPciHost ( return Status; } =20 -STATIC PCI_ROOT_BRIDGE mRootBridge; - /** Return all the root bridge instances in an array. =20 @@ -361,8 +359,8 @@ PciHostBridgeGetRootBridges ( PMemAbove4G.Base =3D MAX_UINT64; PMemAbove4G.Limit =3D 0; =20 - Status =3D PciHostBridgeUtilityInitRootBridge ( - Attributes, + return PciHostBridgeUtilityGetRootBridges ( + Count, Attributes, AllocationAttributes, TRUE, @@ -373,19 +371,8 @@ PciHostBridgeGetRootBridges ( &Mem, &MemAbove4G, &PMem, - &PMemAbove4G, - &mRootBridge + &PMemAbove4G ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: failed to initialize PCI host bridge: %r\n", - __FUNCTION__, Status)); - *Count =3D 0; - return NULL; - } - - *Count =3D 1; - - return &mRootBridge; } =20 /** @@ -402,8 +389,7 @@ PciHostBridgeFreeRootBridges ( UINTN Count ) { - ASSERT (Count =3D=3D 1); - PciHostBridgeUtilityUninitRootBridge (Bridges); + PciHostBridgeUtilityFreeRootBridges (Bridges, Count); } =20 /** --=20 2.29.2 -=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 (#70523): https://edk2.groups.io/g/devel/message/70523 Mute This Topic: https://groups.io/mt/79941630/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- From nobody Mon May 6 11:17:06 2024 Delivered-To: importer@patchew.org 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+70524+1787277+3901457@groups.io; helo=mail02.groups.io; 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+70524+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1611018905; cv=none; d=zohomail.com; s=zohoarc; b=ndpdrfydWNEZTPLK0zotyJ91sl+ks1/IW+drumnHNqjKIb5/98Pxe6Mr+qhlPWug1zc1OYt+7Dzd6X25dGpFQJUOROzzDUCtJPnk+Q2E841xRFTziCpQ0grtAeQO+U2E5Xfphzbck+KgxkRKXce5HBCMki0oEi/r2p0EQol3L7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611018905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=A97MKinvDf8qJ6IZmmhPK1LHxIwouCuyHuRefrFMOuw=; b=k4XwQKSZfgBnJ0T/8UKNeqqNSKrSwRAfR1vQPj4LgdC4Cdi3bFoMuHf4tmeWMJ10dB117/25KXv/VRU1tXnES+eB6R/rnMpA5M8uauLSqXTpEzu2CaPWDxeCMMwq5PMOAO/BybOAuREYDFT3cEBN1WBVI9J9RHSLKwHb99nuPWY= ARC-Authentication-Results: i=1; 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+70524+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611018905608382.1651042506189; Mon, 18 Jan 2021 17:15:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id QzBaYY1788612xK907aojBYT; Mon, 18 Jan 2021 17:15:05 -0800 X-Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by mx.groups.io with SMTP id smtpd.web11.5336.1611018903624623850 for ; Mon, 18 Jan 2021 17:15:04 -0800 X-Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DKVzf4F7Gzj8GS; Tue, 19 Jan 2021 09:14:06 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 19 Jan 2021 09:14:51 +0800 From: "Jiahui Cen via groups.io" To: CC: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Rebecca Cran , Peter Grehan , Anthony Perard , Julien Grall , Leif Lindholm , Sami Mujawar , , , Jiahui Cen , Yubo Miao Subject: [edk2-devel] [PATCH v6 11/11] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Date: Tue, 19 Jan 2021 09:13:02 +0800 Message-ID: <20210119011302.10908-12-cenjiahui@huawei.com> In-Reply-To: <20210119011302.10908-1-cenjiahui@huawei.com> References: <20210119011302.10908-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Precedence: Bulk List-Unsubscribe: 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,cenjiahui@huawei.com X-Gm-Message-State: N99mm3qaCoe5EiN58N2jDJ2rx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611018905; bh=u7x7i5Sj9BmaHd7Oj6ZZ5LXzPHV8SSuVi7e1en7PTLE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=qMeyfsQ2zOGnPbFEBoehvyhyrQT6Ad5R2ecOik33T1dsNFQfvrK4fb4o3a4OR+DWFh4 fUJOrrgI6X/e2ds2O554EADuo8Qn/Zu4OiGN5DxaD6UKSh+wEhWXPIXHho2JHUoybItsk GiBgiDY/SNII2fHxWaft9olLbYkszoj6eTI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" It is necessary to add padding for hotplugable PCI Devices like pcie-root-port. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3059 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao Reviewed-by: Laszlo Ersek --- ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 + 3 files changed, 3 insertions(+) diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc index a11ffd9ba553..d77c226d80ee 100644 --- a/ArmVirtPkg/ArmVirtQemu.dsc +++ b/ArmVirtPkg/ArmVirtQemu.dsc @@ -488,6 +488,7 @@ [Components.common] NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf } + OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf OvmfPkg/Virtio10Dxe/Virtio10.inf =20 diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKerne= l.dsc index c27752b4d5e5..92f327eec4fb 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -424,6 +424,7 @@ [Components.common] NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf } + OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf OvmfPkg/Virtio10Dxe/Virtio10.inf =20 diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuF= vMain.fdf.inc index 1752fee12b79..5b1d10057545 100644 --- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc +++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc @@ -162,6 +162,7 @@ [FV.FvMain] INF ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf INF MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf + INF OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf INF OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf INF OvmfPkg/Virtio10Dxe/Virtio10.inf =20 --=20 2.29.2 -=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 (#70524): https://edk2.groups.io/g/devel/message/70524 Mute This Topic: https://groups.io/mt/79941634/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-