From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web12.9684.1608631235612256695 for ; Tue, 22 Dec 2020 02:00:36 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.190, mailfrom: cenjiahui@huawei.com) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D0Wyy6km4zkv3H; Tue, 22 Dec 2020 17:59:38 +0800 (CST) Received: from localhost (10.174.184.155) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Tue, 22 Dec 2020 18:00:23 +0800 From: "Jiahui Cen" 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: [PATCH v3 2/5] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Date: Tue, 22 Dec 2020 17:59:41 +0800 Message-ID: <20201222095944.8686-3-cenjiahui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201222095944.8686-1-cenjiahui@huawei.com> References: <20201222095944.8686-1-cenjiahui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.184.155] X-CFilter-Loop: Reflected Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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 --- ArmVirtPkg/ArmVirt.dsc.inc | 1 + ArmVirtPkg/ArmVirtKvmTool.dsc | 1 + ArmVirtPkg/ArmVirtQemu.dsc | 1 + ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 + ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf | 2 + ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 44 ++--= ---------------- 6 files changed, 9 insertions(+), 41 deletions(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 9ec92930472d..b9a0cd362416 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -145,6 +145,7 @@ [LibraryClasses.common] PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCap= PciSegmentLib.inf PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.i= nf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHos= tBridgeUtilityLib.inf =20 # USB Libraries UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.ds= c index bf008be50fcb..f817132ba7b0 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -65,6 +65,7 @@ [LibraryClasses.common] PlatformPeiLib|ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatfor= mPeiLib.inf =20 PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHos= tBridgeUtilityLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550S= erialPortHookLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo= rtLib16550.inf =20 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/FdtPciPcdPro= ducerLib.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci= .inf PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBrid= geLib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHos= tBridgeUtilityLib.inf =20 !if $(TPM2_ENABLE) =3D=3D TRUE Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKer= nel.dsc index f8f5f7f4b94b..c27752b4d5e5 100644 --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc @@ -76,6 +76,7 @@ [LibraryClasses.common] PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdPro= ducerLib.inf PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci= .inf PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBrid= geLib.inf + PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHos= tBridgeUtilityLib.inf TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasur= ementLibNull.inf =20 [LibraryClasses.common.DXE_DRIVER] diff --git a/ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.i= nf 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 mEfiPciRootBrid= geDevicePath =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; Descri= ptor++) { - ASSERT (Descriptor->ResType < - (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) / - sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0]) - ) - ); - DEBUG ((EFI_D_ERROR, " %s: Length/Alignment =3D 0x%lx / 0x%lx\n", - mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResTy= pe], - Descriptor->AddrLen, Descriptor->AddrRangeMax - )); - if (Descriptor->ResType =3D=3D ACPI_ADDRESS_SPACE_TYPE_MEM) { - DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag =3D %ld / %0= 2x%s\n", - Descriptor->AddrSpaceGranularity, Descriptor->SpecificFl= ag, - ((Descriptor->SpecificFlag & - EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFE= TCHABLE - ) !=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.28.0