From nobody Thu Mar 28 10:34:12 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+70238+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+70238+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534038; cv=none; d=zohomail.com; s=zohoarc; b=TEiwZuQMEO+cQ9uS8Eyd8LMnyhVCan7tXo5C0Tl0xNGZPsFmAJc5VpnjyeDdeksH9lRxdBBxCTIOW8FiO2BQX8+cTgGkIyNi8xmf+JGkKYMJZqZoxvV9vVcHYbvdwPJc4TOTol2dy23ieWdpUnBTvhJcRzmHISJO5e/nZy60ogs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534038; 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=KhOcTE2rfjipHdHr92hGe/HW7SVSrmkgxpuVXaTDO4c=; b=JSRwt8K/pIqlZn19FBycJ0kartjhXqEE4AyT/gNR0l6t4AKohMLJRMPAfzQSbs1YHzjEleu9QKM6NaYJlaX15tVd3i1OCwo7s+S1vh+EwTnfYPpEaZMtb0R4GmAaXscR5qxs0nWPWrsrDHERbpMBFQ5nRTw9z2sDUm1yw10ND8E= 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+70238+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534038542629.4128725612119; Wed, 13 Jan 2021 02:33:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jih0YY1788612xH2I70RFFLD; Wed, 13 Jan 2021 02:33: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.web10.6145.1610534029118702605 for ; Wed, 13 Jan 2021 02:33:49 -0800 X-Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DG3g26Jl5z7KZb; Wed, 13 Jan 2021 18:32:46 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:40 +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 v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class Date: Wed, 13 Jan 2021 18:33:22 +0800 Message-ID: <20210113103331.10375-2-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: JHOwSFpzgmVPkzIRZiZhidzex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534038; bh=9bDgUjeLFWYUqiyRBs7OQK9Zo/S/+FJe0xd/sV80Glo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=f6YeHYKaFSG8NRfpGGOtXCJ2i3fZhcmzoHhl337PHf1ONJ1SP29wjJc2GgI28p5jjV4 X2DZnivEMNi3hJpfMKdCWTU6Jz9S83CfpolGrmZSLgw2Ib7JnG8Lfvb5P/C6aUKcZfZU8 XeIvkbwbDgmgeUhJumkpi1RmGkbqgChASEU= 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 | 37 += +++++++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 41 += ---------- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 77 += +++++++++++++++++++ 12 files changed, 164 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..f932d412aa10 --- /dev/null +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -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, 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 Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the reso= urces + for all the root bridges. The resource 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_PROTOCOL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeUtilityResourceConflict ( + 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..bbaa5f830c98 --- /dev/null +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -0,0 +1,77 @@ +/** @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 Configuration Pointer to PCI I/O and PCI memory resource + descriptors. The Configuration contains the reso= urces + for all the root bridges. The resource 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_PROTOCOL + .SubmitResources(). +**/ +VOID +EFIAPI +PciHostBridgeUtilityResourceConflict ( + 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 (#70238): https://edk2.groups.io/g/devel/message/70238 Mute This Topic: https://groups.io/mt/79647745/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 Thu Mar 28 10:34:12 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+70239+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+70239+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534039; cv=none; d=zohomail.com; s=zohoarc; b=ORTby9/Omp41DaJrNv2yiUUDY5qvrtV5E9ebO1kUoifsOnIpSnN2EYn3SH9ZyK6LLPym/6tfUzqYUb5BtYAy6rK1vYdlrynEkZPWzro3bNlivs25sv8M4+PPGqKoOSy7CG8UX+bw4a2PuSJwzV24B0ac/8i8AeqanwT7gTcBFyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534039; 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=ngsOOGPpEapTRCVI8Ji6ut3116aPJs7kMS+5+inhVnA=; b=bWshwNB5pAvKxddCZXxkSGNmNn+7ggaolk02CZ15dN8kPtV797wyEOdjw9O53lcjITGYE9ojzJlExDl0ofWyVmj6DhdNbwhE64lClvOxGnymLbpjEfzZ4wDAi/YJIGfsPer3CQEAP6ySBZn8dJAoyFoZdOY+BSESdJ/p2KgWXP8= 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+70239+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534039050296.0202886902491; Wed, 13 Jan 2021 02:33:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id m3DmYY1788612xdLI535ufdr; Wed, 13 Jan 2021 02:33: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.web10.6146.1610534029750830833 for ; Wed, 13 Jan 2021 02:33:50 -0800 X-Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DG3g32G9mz7T5D; Wed, 13 Jan 2021 18:32:47 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:40 +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 v5 02/10] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Date: Wed, 13 Jan 2021 18:33:23 +0800 Message-ID: <20210113103331.10375-3-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: S9KpzInZTzZP7M870kHJl99gx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534038; bh=BCWVbwnAn6wOYTGUI0jnWGA1br5Z9V51IPwlHhUADVA=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=tKtlVmOp7h4lIEuN4gEWI1b2g9sqf1Dq/n8bDo/PW+OZ44+6e6qBzkdsMMW1y98+s0Q ZWMUwiwp+M4AMTLibhV9HX31tPZKIfYvO8IeXn3xie380iwVt8wjfU7dIjKQvUgdJx6JD xhgiQ3B+Eis2u/yfbW1gVEMa0LIz2S/w9rs= 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 (#70239): https://edk2.groups.io/g/devel/message/70239 Mute This Topic: https://groups.io/mt/79647746/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 Thu Mar 28 10:34:12 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+70240+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+70240+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534036; cv=none; d=zohomail.com; s=zohoarc; b=L2A6logUGnTx4iq+OdsNzFc4mnbzr2QVixpDzE/1suxwiyOCDTEGyX3f5/IK7EDqcdK+n+M9fpX6AfU7Krjfh1xsYtJp/rNRM04I8/sLNChvKdim10b+ki3luZK/FR2fEDT5DHJgQOPGSEp8Qpoqkj0is3G5P1qmylxT7Y8N+Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534036; 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=g7+y6h+LYhVXlP4od7lMVA1lk7z70MYPasB75wpTfec=; b=PjL1M5CaG622zuNeelXbTXYIIizbobL/DCyNf+RAv6UwebwVJCyPiNBy0SaA5rIucb3MBP0KbQdIQBYXpfHH7yhHhreWpYn5O/t+xOC8V7OhxTzSB4SmBqbyG+q9EFMhztrrFN3ynZBvFVD6f2q6svcsQjq9zhZSYAuycDi1vP4= 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+70240+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534036988127.47554454686951; Wed, 13 Jan 2021 02:33:56 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jCtTYY1788612xlcVlHmtZez; Wed, 13 Jan 2021 02:33:52 -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.6229.1610534032005045924 for ; Wed, 13 Jan 2021 02:33:52 -0800 X-Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DG3gH5L48zj5JX; Wed, 13 Jan 2021 18:32:59 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:41 +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 v5 03/10] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency Date: Wed, 13 Jan 2021 18:33:24 +0800 Message-ID: <20210113103331.10375-4-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: rwCgV67B5LGRcpoDYiPAr3xSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534032; bh=5EFF5uKeVLKNOfTlGwj5T9rjaEC/THxs3AmE8puGMms=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=KYICuUfQRybE1B3nbIcFslVOzhXtBNxLS31PSaJ/3XJtQR449G4zjgh3/qYmk4tFroV pmQEz6nCvHmmLcQi+XkYhjne5hVmX2MY3UsTrhBB/qwo0OSq36myHwA6YVMUtT8e3M4kR Qge3xDr0jECaJIfH4CXAlwhah20e5pVtVeU= 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 --- 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 (#70240): https://edk2.groups.io/g/devel/message/70240 Mute This Topic: https://groups.io/mt/79647747/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 Thu Mar 28 10:34:12 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+70241+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+70241+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534037; cv=none; d=zohomail.com; s=zohoarc; b=XclNeJGtKccfjXrgwyjnvHN/kqKkH95J4mFThNcBHVY7+kDtz805b+EKGmnQhXLdtvTga8X4qY6DQldQaCryFtODjxYQktREM7WIhyba2cQ3KhOJxju8zyJvlQxEuGmdU965EQH8kE9iABx1TFD8RGoV3wloDxHADUdBrkiCrPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534037; 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=V5Hru/n/l67zI0P/HI4Ktcv86K2yR9R/MkowTfYFwY0=; b=OsA1J7qNnch4QhuPH9q/hLVjpHPgdtTkCWl46q9ZBjVVkyNFStIgWLBmyHSPNEHr3ShXfGrZXdFE/EZbJF0Rr6+KJpQC+FOFePI6aXexoay8pvnQI+URPaYGpnm1TlfVTtDq9YV6qZdPmmb+5qMoPWT1UfeUGUKJgsZuQZcXm7Y= 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+70241+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534037461980.1019461984904; Wed, 13 Jan 2021 02:33:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4Gb7YY1788612xkpRCI4TxEx; Wed, 13 Jan 2021 02:33:57 -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.6135.1610534032202109297 for ; Wed, 13 Jan 2021 02:33:52 -0800 X-Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DG3gH5jFLzj5L4; Wed, 13 Jan 2021 18:32:59 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:42 +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 v5 04/10] OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge Date: Wed, 13 Jan 2021 18:33:25 +0800 Message-ID: <20210113103331.10375-5-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: O841yGNSsHoJSG4KSXVUYrkpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534037; bh=e9Iwj/JWQqg8ISnDmk7W4sbwssPv0WX9ZaaCNxCfxjk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=USTLmP1d+iJRnNa/3vcvk3uB86IeubFnh4s+IcRbzrEZyOPUQ+C1c+jw0fWRUqOdPZm gv4+Sx5JFQtR3ARhEFz2n1VHJJjk9/GRGHzjl4BCrC3gOw+IaXs/tXRKaFCIzdhO8U4t1 pihzPnwYgCOKR9hjOmeb4NvIG5Fl0WMrM0U= 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 --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 2 - OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 8 + OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 75 = ++++++++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h | 56 = ------- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 158 = +------------------- OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 3 = +- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 156 = +++++++++++++++++++ 7 files changed, 245 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 f932d412aa10..f02cec812a50 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -14,6 +14,81 @@ #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 +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 calle= r and + initialized with PciHostBridgeUtilityInitRootBridge(), + that should be uninitialized. This function doesn't f= ree + RootBus. +**/ +VOID +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 bbaa5f830c98..eed3d7f871ea 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -11,16 +11,172 @@ **/ =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 +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 calle= r and + initialized with PciHostBridgeUtilityInitRootBridge(), + that should be uninitialized. This function doesn't f= ree + RootBus. +**/ +VOID +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 (#70241): https://edk2.groups.io/g/devel/message/70241 Mute This Topic: https://groups.io/mt/79647748/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 Thu Mar 28 10:34:12 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+70246+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+70246+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534044; cv=none; d=zohomail.com; s=zohoarc; b=krOrKlbSb9M19o3CD1MQEiyhS/+pp9TRf+SvVrbJQRdt2Zs3ANcWAnbxca5HBKgUtkgSLNloPswSx5Dtz053hVMiaP4gatsNR5djbYk4uVXf6yHbUJHhpd8pkvFlf7CDCEmP+nMrZWBXEwCPsdUVq2VEtjHlAbRqg2GYKmBqywE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534044; 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=+GEjH04I/UGPR25CSp8sfYHFmXMbBeI5NdHR+o7Pvzw=; b=HrYMpWprBkDl+Sm4iEnAy+uyYtyf19G5BqZEsKIi+Szie7lenO2m+Lguc4b3KTv9lX92TAHVWvdVMs382ELd436tzAqasRAPKSfTQijTBUsmO7M00NbTtTPZ1rFMKI7CZDB2ciRxpFF37SHNv7t9EUTXeHX69xArrhr3FgMH00w= 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+70246+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534044379494.9254220490194; Wed, 13 Jan 2021 02:34:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id iaRbYY1788612ximAqVCy3EO; Wed, 13 Jan 2021 02:34:04 -0800 X-Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web09.6237.1610534043060810728 for ; Wed, 13 Jan 2021 02:34:03 -0800 X-Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DG3fq2FxCzl39Q; Wed, 13 Jan 2021 18:32:35 +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; Wed, 13 Jan 2021 18:33:43 +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 v5 05/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge Date: Wed, 13 Jan 2021 18:33:26 +0800 Message-ID: <20210113103331.10375-6-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: smDIZcpRgsraaL8S2WKELa7Lx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534044; bh=7ljW51a9bW4ipxUysOjFMccpSQoXEHPhJFvsncvjo88=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=mV5SolLA9/LHxcuTvZOxoA4dcKmwA3KEMswRBbUdF5za9Duso1kkoQUIgMkf0taZH86 Modhm5Mt7f7/592r02nR5lH0cjgWTLXTrKlnr+YnR1WIoEdhdH5U9iVTKSkMvcT0cxLSt tNLsjAvgG+/HrkTr8OpDBiAHh7r4O+1l+Co= 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 support of 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 --- 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 f02cec812a50..13c591641d7a 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -20,49 +20,57 @@ /** 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 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 eed3d7f871ea..15b2045197a8 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,49 +62,57 @@ 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 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, @@ -129,7 +135,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; @@ -140,8 +146,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 (#70246): https://edk2.groups.io/g/devel/message/70246 Mute This Topic: https://groups.io/mt/79647754/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 Thu Mar 28 10:34:12 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+70243+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+70243+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534040; cv=none; d=zohomail.com; s=zohoarc; b=jRDm9Ixvj1wUpTCebZgjSGXfz5ZkGtYYwejew3VoSgP3F+oU2vOL9YMkn918ZZBTQWR/dlD08JHWTmr+W+DtLE7BymtmQcFyAwc9fmMkLX6CXloMKgqZ2HDuO/dFlpSDDCX2l3VAuaYsBcGe1ZZkDsE2cd6YwYmQt9wDovsxZg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534040; 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=RKHm3Kuy9sEcxxNDVvusiZW3S4E9nk13ybBR6vgD0i8=; b=fObz7axlkE33INexFZIAaYBBbs2NDkOJk+3rI3Jmm3mQJRvrYzvdylFbNPtNn+WLhPwlZ6JettixUx3duYwSwdTXU//b/a0Xnmo9GBdEPmEzL9EQasw43JSATMQrWrhZyLwrMrZLN0vYIRNxja992rzR6uUdy+VPd0cZQsdaB6I= 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+70243+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534040512585.3150076521995; Wed, 13 Jan 2021 02:34:00 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id vVRoYY1788612xeoMBRARKPx; Wed, 13 Jan 2021 02:34:00 -0800 X-Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web11.6231.1610534033959322406 for ; Wed, 13 Jan 2021 02:33:54 -0800 X-Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DG3g73kWzzj6wq; Wed, 13 Jan 2021 18:32:51 +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; Wed, 13 Jan 2021 18:33:43 +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 v5 06/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge() Date: Wed, 13 Jan 2021 18:33:27 +0800 Message-ID: <20210113103331.10375-7-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: z2QiQQU5tdMWoX2rTTQ4mdnSx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534040; bh=KAzmFrXRLKu0lvru9I98ljKuIz/y6TkaiLjukkx1jIY=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=EB8C/BzzV1VHQxBnLAiN0mGzBR8HmmN684jAB15e7BfRi/IMV6vKmeihT9neAksjMEE SJWNk4Ejetfq4OJDtgQFKsXUOOFljMUwU/ycUzx8X88A1Ey7fFfyoTJ9x11GTQZ1cnjZ3 AjJr5SnItkXc7xSj+bDilZhgNe5vGFfewDU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new PciHostBridgeUtilityInitRootBridge()/PciHostBridgeUtilityUninitRootBridge() 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 --- 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 (#70243): https://edk2.groups.io/g/devel/message/70243 Mute This Topic: https://groups.io/mt/79647750/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 Thu Mar 28 10:34:12 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+70244+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+70244+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534039; cv=none; d=zohomail.com; s=zohoarc; b=ROJ/1HxJaRDZJcVIm3jxgyDMxCKzZYxLN0V/SMfbqxAAO4eyRXOyLA8qiZqU2nhcmZg5+USP01oT+mNPFMS+AogG6iDq1aQpu1KWIiA1ipuXRL9tjOjFG3z2AZVAQ3ja8tI1+yo2bvxAa1LGyOtVTi45de/c/QM+DjtIurIGQD0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534039; 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=8HGTBtINgbdKzSaEo+FdmsUF+dqTucO7JlqnV64cQFg=; b=eCQRkspg/GuSGZZiAQIk266Uj4qC12MihxJOhYH7oRTK5zhkWlMNLeb+yOnlTJNlnCoM0u80T5eBZ0yb7Pdf/24JVYJNvBU9qCI3d+2Af6/2QDkUnJhfMMF+5caZtkiRC1OPUyYtgmyNFtcFW/kV+Z9FSFTtavNxbhSX1N+8ZHQ= 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+70244+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534039696984.7442916350182; Wed, 13 Jan 2021 02:33:59 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8yuBYY1788612xLW52xOYTpb; Wed, 13 Jan 2021 02:33:59 -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.6137.1610534035084713015 for ; Wed, 13 Jan 2021 02:33:55 -0800 X-Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DG3g808gnz15rwQ; Wed, 13 Jan 2021 18:32:52 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:43 +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 v5 07/10] OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges Date: Wed, 13 Jan 2021 18:33:28 +0800 Message-ID: <20210113103331.10375-8-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: UpGYynxt2055z347vdwUloT0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534039; bh=G3zz3oU/lwZx2aiy2S6gc8XEGh/wVrRAxb+OilnhyIM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=DSZAKH7qa37kJDLJiWTIAklHJdFxCKxow0bFTqOVlw4uiNnNiEU0P2MkfVAMuYz6qY1 Ws6qntVQqr5SM5SbXMRYeUlTbL9c8rfbL1BxkrphGuFw71zGycUpx3mxEz5fJjNS9FULB QwMc3L6eOjHPajExGBw9DgQU4ZZIYSRcy8M= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extract PciHostBridgeGetRootBridges()/PciHostBridgeFreeRootBridges() 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 Signed-off-by: Jiahui Cen Signed-off-by: Yubo Miao --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 - OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 6 + OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 50 = +++++ OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 136 = +------------- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 194 = ++++++++++++++++++++ 5 files changed, 254 insertions(+), 133 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 13c591641d7a..29ea19f2d7e5 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -97,6 +97,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 ( + UINTN *Count, + 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 + ); + + +/** + 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 ( + PCI_ROOT_BRIDGE *Bridges, + 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..62e0a517a938 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; @@ -91,121 +78,16 @@ PciHostBridgeGetRootBridges ( =20 *Count =3D 0; =20 - // - // 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 +105,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 15b2045197a8..31a8c19d4f7f 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) @@ -182,6 +187,195 @@ 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 ( + UINTN *Count, + 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 + ) +{ + 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)); + 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, + 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); + 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 ( + PCI_ROOT_BRIDGE *Bridges, + 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 (#70244): https://edk2.groups.io/g/devel/message/70244 Mute This Topic: https://groups.io/mt/79647751/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 Thu Mar 28 10:34:12 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+70242+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+70242+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534037; cv=none; d=zohomail.com; s=zohoarc; b=IHRt9FmTSFpEds/Hx1X3Oo28eAE+YJjZNIbhoa9jM8UAiXCVR+WX5hk55r/Pw1FFXJqENdui3TKmsT9PQCU+7i7SsO6VHMr2wIUW1OCHVS7xGDnrRysWQaXLRVeTQgL/IO1GnjQ8SPlJRsnhGwui+KF2lJvnJRsu92NhAcnq+4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534037; 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+H85HbUQTKJ7D2tGHsiZrTP6pHCRj9b8ac96a01Z/w=; b=Rpv7x9QvboTGb7AcATSXEs8Z5NRJFm+vU8x9g1Og4WYYrFJm1GJC1j7cwRwkbHKUbxsBSSKJiZgqn0jKesonChwHC9oCqS+nBRDuD49LgjmrnsRYSET08uoIbbcPOdKW+d7qElcaIC8Ky0LxADAKJgNIvmDX2vuUIM27iQpO2MQ= 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+70242+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534037510264.1498326539231; Wed, 13 Jan 2021 02:33:57 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kiOjYY1788612xEb1CQOWc4O; Wed, 13 Jan 2021 02:33:57 -0800 X-Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web12.6136.1610534033004198989 for ; Wed, 13 Jan 2021 02:33:53 -0800 X-Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DG3g60HSTzj6Q6; Wed, 13 Jan 2021 18:32:50 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33:44 +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 v5 08/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Date: Wed, 13 Jan 2021 18:33:29 +0800 Message-ID: <20210113103331.10375-9-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: pYm8VbacGS8MNt6RyTlywmcPx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534037; bh=KhY++vg6GxqlnwOkkDluqFJ5SsDeUcAtmSDs5X+O8YU=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ojPoF/OLVXNApOS4+RTkKtyE212VwiIBlxbS20mKzj974Uqto/NLwajdpJlvnD+P2Od q7xSuAu4kjZc8+HA5eJXsVp+GhAHVyjGg25KRWUM2OfEMDwP3GPefcyjkqyo6NZw28Inu 8+Cyv4r1X8xVCeGB5R8m/74aadhq5M1YBME= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Extend parameter list of PciHostBridgeUtilityGetRootBridges() with DmaAbove4G, NoExtendedConfigSpace, BusMin and BusMax 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 --- OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 4 -- OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 30 += +++++++---- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 7 += ++ OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 48 += +++++++++++-------- 4 files changed, 57 insertions(+), 32 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 29ea19f2d7e5..ed2b386001e1 100644 --- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h +++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h @@ -100,23 +100,31 @@ 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] BusMin Minimum Bus number =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] BusMax Maximum Bus number =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @return All the root bridge instances in an array. + @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 a= rray. **/ PCI_ROOT_BRIDGE * EFIAPI @@ -124,6 +132,10 @@ PciHostBridgeUtilityGetRootBridges ( UINTN *Count, UINT64 Attributes, UINT64 AllocationAttributes, + BOOLEAN DmaAbove4G, + BOOLEAN NoExtendedConfigSpace, + UINT32 BusMin, + UINT32 BusMax, PCI_ROOT_BRIDGE_APERTURE *Io, PCI_ROOT_BRIDGE_APERTURE *Mem, PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/= Library/PciHostBridgeLib/PciHostBridgeLib.c index 62e0a517a938..bd125834e5c4 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -9,6 +9,9 @@ **/ #include =20 +#include +#include + #include #include =20 @@ -82,6 +85,10 @@ PciHostBridgeGetRootBridges ( Count, Attributes, 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 31a8c19d4f7f..fa090c428d13 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 @@ -190,23 +188,31 @@ 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] BusMin Minimum Bus number =20 - @param[in] PMem Prefetchable MMIO aperture. + @param[in] BusMax Maximum Bus number =20 - @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G. + @param[in] Io IO aperture. =20 - @return All the root bridge instances in an array. + @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 a= rray. **/ PCI_ROOT_BRIDGE * EFIAPI @@ -214,6 +220,10 @@ PciHostBridgeUtilityGetRootBridges ( UINTN *Count, UINT64 Attributes, UINT64 AllocationAttributes, + BOOLEAN DmaAbove4G, + BOOLEAN NoExtendedConfigSpace, + UINT32 BusMin, + UINT32 BusMax, PCI_ROOT_BRIDGE_APERTURE *Io, PCI_ROOT_BRIDGE_APERTURE *Mem, PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, @@ -241,7 +251,7 @@ PciHostBridgeUtilityGetRootBridges ( QemuFwCfgSelectItem (FwCfgItem); QemuFwCfgReadBytes (FwCfgSize, &ExtraRootBridges); =20 - if (ExtraRootBridges > PCI_MAX_BUS) { + if (ExtraRootBridges > BusMax - BusMin) { DEBUG ((DEBUG_ERROR, "%a: invalid count of extra root buses (%Lu) " "reported by QEMU\n", __FUNCTION__, ExtraRootBridges)); return NULL; @@ -263,15 +273,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 @@ -291,8 +301,8 @@ PciHostBridgeUtilityGetRootBridges ( Attributes, Attributes, AllocationAttributes, - FALSE, - PcdGet16 (PcdOvmfHostBridgePciDevId) !=3D INTEL_Q35_MCH_DEVICE_ID, + DmaAbove4G, + NoExtendedConfigSpace, (UINT8) LastRootBridgeNumber, (UINT8) (RootBridgeNumber - 1), Io, @@ -318,8 +328,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 (#70242): https://edk2.groups.io/g/devel/message/70242 Mute This Topic: https://groups.io/mt/79647749/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 Thu Mar 28 10:34:12 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+70247+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+70247+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534048; cv=none; d=zohomail.com; s=zohoarc; b=T8JctLXv9RDBNPmic3UzsNC6buMosmbeCQ5H9MAwDtYO0yrdZ+wOdpKHFa0LIh9lqIrlsFAmZF17YF8377+1ZBpFl2HN6hKalVt8BruxLuhXvuXbnlu4c7Xf+BcR7gTDgQu1OA+RI2vIYMPBidaDom1zMzZXFfK80iz4oBFf7qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534048; 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=88+59K+7dniZGUS5FmZxiw+yui33kzXkwwqmbE/7vRk=; b=U0YM2uVzgzlOji1asjpdznD0fpu/29UH1Lv/AnMHhw594squbkGkBVx6KKlIyFKV+W9yfd4z8hLhNpQ0VvCvSzOMUHSog6Yow7/EbpRC+t8BVeWJfNEbAVnZHYTBq/vj9LUml2qu0zVwkokJiw3aq+CodUjIMCKKq9vLtFTJPYY= 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+70247+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534048272697.11871049699; Wed, 13 Jan 2021 02:34:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id q9VUYY1788612xfqPn2V39gO; Wed, 13 Jan 2021 02:34:07 -0800 X-Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web08.6256.1610534047211932749 for ; Wed, 13 Jan 2021 02:34:07 -0800 X-Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4DG3fq1tYfzMHTD; Wed, 13 Jan 2021 18:32:35 +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; Wed, 13 Jan 2021 18:33: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 v5 09/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges() Date: Wed, 13 Jan 2021 18:33:30 +0800 Message-ID: <20210113103331.10375-10-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: RH8zt290soH9Diks9CmxbJwhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534047; bh=uz3RU7gDMrSB+PG2IEZruJvD/Bv5Tgsie5rplxonFhw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=awJR/OwJJcmTbV+FlfrygsHk4ykocGzwDyxMWtIBbNWhQEXn8k5vn50SW08iToqz2Hx NU1simhENEArQBzaxl1ckibuXtNy0YBugBR7I6gFG1dmbDZLSXz46JLgFITHvYKmMDIiL RVhCtdhWyWLblePZ+ZdMUlzZrtufk8mvYdk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new PciHostBridgeUtilityGetRootBridges()/PciHostBridgeUtilityFreeRootBridges() 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 --- ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 24 +++++---= ------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c b= /ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c index 3ec7992b6331..89582ef76eb3 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,10 @@ PciHostBridgeGetRootBridges ( PMemAbove4G.Base =3D MAX_UINT64; PMemAbove4G.Limit =3D 0; =20 - Status =3D PciHostBridgeUtilityInitRootBridge ( - Attributes, + *Count =3D 0; + + return PciHostBridgeUtilityGetRootBridges ( + Count, Attributes, AllocationAttributes, TRUE, @@ -373,19 +373,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 +391,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 (#70247): https://edk2.groups.io/g/devel/message/70247 Mute This Topic: https://groups.io/mt/79647755/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 Thu Mar 28 10:34:12 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+70245+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+70245+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610534044; cv=none; d=zohomail.com; s=zohoarc; b=j8LmUZckh0rYgeQgBV6npQETjLdlDIZTcU5U8VYfRp9kZTyDpyqYnKcp91NuHi1GGqoMs03xwEyWgZi1ZifHW5qfb7QkzeTyCGHbSuYbeVd6/o5IdJyLqds91FZMrnRp2Iggm59DgXsl2KB1YXo4TRkSXR+UtmIEuwx44cXFYBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610534044; 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=/0vaHVQ1UNqZa1fr7ORbEYZZZQj8jzRei1hugNlbO0w=; b=iJanx+C9ZFTGo/quIm6fs2lshkA5yhT5dYTevfemeZ63WLOXGNACe6LQz1zhrNWzTSKnRH1YJcrEvJq8OvGQv2jodfO9lcifDtjLBMIIo2ZsbBIRPEU3NgRWx4ER6tubCuWH6OBAMv5wFNL6hk/Tm8vJ18nnDpKmPqQCZ+YyLWc= 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+70245+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610534044982373.00254157078984; Wed, 13 Jan 2021 02:34:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id MFXLYY1788612xjBoqvFFDyO; Wed, 13 Jan 2021 02:34:04 -0800 X-Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web09.6233.1610534038937900427 for ; Wed, 13 Jan 2021 02:33:59 -0800 X-Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DG3ft5BZbzl3fd; Wed, 13 Jan 2021 18:32:38 +0800 (CST) X-Received: from localhost (10.174.184.155) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Wed, 13 Jan 2021 18:33: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 , Yubo Miao Subject: [edk2-devel] [PATCH v5 10/10] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Date: Wed, 13 Jan 2021 18:33:31 +0800 Message-ID: <20210113103331.10375-11-cenjiahui@huawei.com> In-Reply-To: <20210113103331.10375-1-cenjiahui@huawei.com> References: <20210113103331.10375-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: Y4JRHKDanhF1FFvtSEyn0Mr1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610534044; bh=Ea3fF9G9j+a7eHZZqDTYCuxINaJhyxtznU2ySer8duQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ZYDjw2kRcI7wnPKxpK1b4iM9KumR0LeZLrP86KULnWptEnjTszFVnvVlJPmPi9kbL++ kWjpc31JhvZpZf4NztiSn4I07SOfpSU2g9MuQAlmXys57YnSxZ+YSaREY0E0iWY98+pm7 J2lhH4Nunms0q/zkk2/S8C8RzBoocX4/fGs= 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 --- 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 (#70245): https://edk2.groups.io/g/devel/message/70245 Mute This Topic: https://groups.io/mt/79647752/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-