* [PATCH v5 00/10] Add extra pci roots support for Arm
@ 2021-01-13 10:33 Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class Jiahui Cen
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
v4->v5:
* Revert some risky renames.
* Explicitly list PcdLib dependency.
* Fix issues reported by PatchCheck.py.
v3->v4:
* Refactor InitRootBridges/UninitRootBridges/GetRootBridges/FreeRootBridges.
* Fix library dependencies.
v2->v3:
* Rename utility functions under the PciHostBridgeUtilityLib namespace.
* Remove some unused Library dependencies.
* Sort the Include headers.
v1->v2:
* Separated into four patches.
* Factor the same logic parts into a new library.
v4: https://edk2.groups.io/g/devel/message/70147
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
QEMU: https://lore.kernel.org/qemu-devel/20201119014841.7298-1-cenjiahui@huawei.com/
This patch series adds support for extra pci roots for ARM.
In order to avoid duplicated codes, we introduce a new library
PciHostBridgeUtilityLib which extracts common interfaces from
OvmfPkg/PciHostBridgeLib. It provides conflicts informing and extra pci
roots scanning. Using the utility lib, the uefi could scan for extra
root buses and recognize multiple roots for ARM.
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
Jiahui Cen (10):
OvmfPkg: Introduce PciHostBridgeUtilityLib class
ArmVirtPkg: Refactor with PciHostBridgeUtilityLib
OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency
OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge
OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of
InitRootBridge
ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge()
OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges
OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of
GetRootBridges
ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges()
ArmVirtPkg/ArmVirtQemu: Add support for HotPlug
OvmfPkg/OvmfPkg.dec | 4 +
ArmVirtPkg/ArmVirtKvmTool.dsc | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 2 +
ArmVirtPkg/ArmVirtQemuKernel.dsc | 2 +
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 +
ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf | 3 +
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 4 +-
OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf | 43 +++
OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h | 182 +++++++++++
OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h | 56 ----
ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 164 ++++------
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 322 +-------------------
OvmfPkg/Library/PciHostBridgeLib/XenSupport.c | 5 +-
OvmfPkg/Library/{PciHostBridgeLib/PciHostBridgeLib.c => PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c} | 237 +++++++-------
ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 +
20 files changed, 433 insertions(+), 599 deletions(-)
create mode 100644 OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
create mode 100644 OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
copy OvmfPkg/Library/{PciHostBridgeLib/PciHostBridgeLib.c => PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c} (58%)
--
2.29.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 02/10] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Jiahui Cen
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
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=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
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
+ ## @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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 {
<LibraryClasses>
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf
}
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/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
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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.<BR>
+# Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 1.29
+ BASE_NAME = PciHostBridgeUtilityLib
+ FILE_GUID = e3aa5932-527a-42e7-86f5-81b144c7e5f1
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = PciHostBridgeUtilityLib
+
+#
+# The following information is for reference only and not required by the build
+# tools.
+#
+# VALID_ARCHITECTURES = 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/Include/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.<BR>
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>
+
+ 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 happens.
+
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ 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 <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PciHostBridgeLib.h>
+#include <Library/PciHostBridgeUtilityLib.h>
#include <Library/PciLib.h>
#include <Library/QemuFwCfgLib.h>
#include "PciHostBridge.h"
@@ -33,12 +34,6 @@ typedef struct {
#pragma pack ()
-GLOBAL_REMOVE_IF_UNREFERENCED
-CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
- L"Mem", L"I/O", L"Bus"
-};
-
-
STATIC
CONST
OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
@@ -407,37 +402,5 @@ PciHostBridgeResourceConflict (
VOID *Configuration
)
{
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
- UINTN RootBridgeIndex;
- DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
-
- RootBridgeIndex = 0;
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
- while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
- DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
- for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
- ASSERT (Descriptor->ResType <
- ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr)
- );
- DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
- mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
- Descriptor->AddrLen, Descriptor->AddrRangeMax
- ));
- if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
- DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
- Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
- ((Descriptor->SpecificFlag &
- EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
- ) != 0) ? L" (Prefetchable)" : L""
- ));
- }
- }
- //
- // Skip the END descriptor for root bridge
- //
- ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
- (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
- );
- }
+ PciHostBridgeUtilityResourceConflict (Configuration);
}
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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.<BR>
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <IndustryStandard/Acpi10.h>
+#include <Library/DebugLib.h>
+#include <Library/PciHostBridgeUtilityLib.h>
+
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] = {
+ L"Mem", L"I/O", L"Bus"
+};
+
+
+/**
+ Utility function to inform the platform that the resource conflict happens.
+
+ @param Configuration Pointer to PCI I/O and PCI memory resource
+ descriptors. The Configuration contains the resources
+ 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 = 0;
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
+ while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
+ DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
+ for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
+ ASSERT (Descriptor->ResType <
+ ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr)
+ );
+ DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
+ mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
+ Descriptor->AddrLen, Descriptor->AddrRangeMax
+ ));
+ if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
+ DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
+ Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
+ ((Descriptor->SpecificFlag &
+ EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
+ ) != 0) ? L" (Prefetchable)" : L""
+ ));
+ }
+ }
+ //
+ // Skip the END descriptor for root bridge
+ //
+ ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
+ (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
+ );
+ }
+}
+
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 02/10] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 03/10] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency Jiahui Cen
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Eliminate currently duplicated code in ArmVirtPkg with the common utility
class PciHostBridgeUtilityLib.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
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/FdtPciPcdProducerLib.inf
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.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/FdtPciPcdProducerLib.inf
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
!if $(TPM2_ENABLE) == TRUE
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index f8f5f7f4b94b..c27752b4d5e5 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -76,6 +76,7 @@ [LibraryClasses.common]
PciPcdProducerLib|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
[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
[LibraryClasses]
DebugLib
DevicePathLib
DxeServicesTableLib
MemoryAllocationLib
+ PciHostBridgeUtilityLib
PciPcdProducerLib
[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 @@
**/
#include <PiDxe.h>
-#include <Library/PciHostBridgeLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
+#include <Library/PciHostBridgeLib.h>
+#include <Library/PciHostBridgeUtilityLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/FdtClient.h>
@@ -50,11 +51,6 @@ STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mEfiPciRootBridgeDevicePath = {
}
};
-GLOBAL_REMOVE_IF_UNREFERENCED
-CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
- 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 = 0;
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
- while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
- DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
- for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
- ASSERT (Descriptor->ResType <
- (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
- sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
- )
- );
- DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
- mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
- Descriptor->AddrLen, Descriptor->AddrRangeMax
- ));
- if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
- DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
- Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
- ((Descriptor->SpecificFlag &
- EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
- ) != 0) ? L" (Prefetchable)" : L""
- ));
- }
- }
- //
- // Skip the END descriptor for root bridge
- //
- ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
- (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
- );
- }
+ PciHostBridgeUtilityResourceConflict (Configuration);
}
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 03/10] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 02/10] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 04/10] OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge Jiahui Cen
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen
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=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
---
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/OvmfPkg/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 <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
#include <Library/PciLib.h>
diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
index e161f14375ca..95ed0a280b9b 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
@@ -17,6 +17,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
#include <Library/PciLib.h>
#include "PciHostBridge.h"
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 04/10] OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (2 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 03/10] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 05/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge Jiahui Cen
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Extract InitRootBridge()/UninitRootBridge() to PciHostBridgeUtilityLib as
common utility functions. No change of functionality.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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/OvmfPkg/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/PciHostBridgeUtilityLib.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
[Packages]
+ MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseMemoryLib
DebugLib
+ DevicePathLib
+ MemoryAllocationLib
+ PcdLib
+
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
diff --git a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h b/OvmfPkg/Include/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__
+#include <Library/PciHostBridgeLib.h>
+
+
+/**
+ 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 behind any
+ PCI bridge hanging off this root bus.
+
+ The caller is repsonsible for ensuring that
+ RootBusNumber <= 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, with
+ UID = 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 caller and
+ initialized with PciHostBridgeUtilityInitRootBridge(),
+ that should be uninitialized. This function doesn't free
+ RootBus.
+**/
+VOID
+PciHostBridgeUtilityUninitRootBridge (
+ IN PCI_ROOT_BRIDGE *RootBus
+ );
+
+
/**
Utility function to inform the platform that the resource conflict happens.
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridge.h b/OvmfPkg/Library/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 behind any
- PCI bridge hanging off this root bus.
-
- The caller is repsonsible for ensuring that
- RootBusNumber <= 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, with
- UID = 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 <PiDxe.h>
#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Q35MchIch9.h>
#include <Protocol/PciHostBridgeResourceAllocation.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
@@ -27,156 +25,8 @@
#include "PciHostBridge.h"
-#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 = {
- {
- {
- 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 = { MAX_UINT64, 0 };
-/**
- 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 behind any
- PCI bridge hanging off this root bus.
-
- The caller is repsonsible for ensuring that
- RootBusNumber <= 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, with
- UID = 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 = 0;
-
- RootBus->Supports = Supports;
- RootBus->Attributes = Attributes;
-
- RootBus->DmaAbove4G = FALSE;
-
- RootBus->AllocationAttributes = AllocAttributes;
- RootBus->Bus.Base = RootBusNumber;
- RootBus->Bus.Limit = 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 = (PcdGet16 (PcdOvmfHostBridgePciDevId) !=
- INTEL_Q35_MCH_DEVICE_ID);
-
- DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate,
- &mRootBridgeDevicePathTemplate);
- if (DevicePath == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
- return EFI_OUT_OF_RESOURCES;
- }
- DevicePath->AcpiDevicePath.UID = RootBusNumber;
- RootBus->DevicePath = (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 caller 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);
-}
-
/**
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, for any
// subordinate buses that might exist behind PCI bridges hanging off it.
//
- Status = InitRootBridge (
+ Status = PciHostBridgeUtilityInitRootBridge (
Attributes,
Attributes,
AllocationAttributes,
@@ -322,7 +172,7 @@ PciHostBridgeGetRootBridges (
// Install the last root bus (which might be the only, ie. main, root bus, if
// we've found no extra root buses).
//
- Status = InitRootBridge (
+ Status = PciHostBridgeUtilityInitRootBridge (
Attributes,
Attributes,
AllocationAttributes,
@@ -346,7 +196,7 @@ PciHostBridgeGetRootBridges (
FreeBridges:
while (Initialized > 0) {
--Initialized;
- UninitRootBridge (&Bridges[Initialized]);
+ PciHostBridgeUtilityUninitRootBridge (&Bridges[Initialized]);
}
FreePool (Bridges);
@@ -375,7 +225,7 @@ PciHostBridgeFreeRootBridges (
do {
--Count;
- UninitRootBridge (&Bridges[Count]);
+ PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]);
} while (Count > 0);
FreePool (Bridges);
diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
index 95ed0a280b9b..5dfeba0e6e23 100644
--- a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
+++ b/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c
@@ -19,6 +19,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
+#include <Library/PciHostBridgeUtilityLib.h>
#include <Library/PciLib.h>
#include "PciHostBridge.h"
@@ -453,7 +454,7 @@ ScanForRootBridges (
RootBridges
);
ASSERT (RootBridges != NULL);
- InitRootBridge (
+ PciHostBridgeUtilityInitRootBridge (
Attributes, Attributes, 0,
(UINT8) PrimaryBus, (UINT8) SubBus,
&Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 @@
**/
#include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Q35MchIch9.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
+#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[] = {
L"Mem", L"I/O", L"Bus"
};
+STATIC
+CONST
+OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
+ {
+ {
+ 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 behind any
+ PCI bridge hanging off this root bus.
+
+ The caller is repsonsible for ensuring that
+ RootBusNumber <= 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, with
+ UID = 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 = 0;
+
+ RootBus->Supports = Supports;
+ RootBus->Attributes = Attributes;
+
+ RootBus->DmaAbove4G = FALSE;
+
+ RootBus->AllocationAttributes = AllocAttributes;
+ RootBus->Bus.Base = RootBusNumber;
+ RootBus->Bus.Limit = 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 = (PcdGet16 (PcdOvmfHostBridgePciDevId) !=
+ INTEL_Q35_MCH_DEVICE_ID);
+
+ DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate,
+ &mRootBridgeDevicePathTemplate);
+ if (DevicePath == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
+ return EFI_OUT_OF_RESOURCES;
+ }
+ DevicePath->AcpiDevicePath.UID = RootBusNumber;
+ RootBus->DevicePath = (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 caller and
+ initialized with PciHostBridgeUtilityInitRootBridge(),
+ that should be uninitialized. This function doesn't free
+ RootBus.
+**/
+VOID
+PciHostBridgeUtilityUninitRootBridge (
+ IN PCI_ROOT_BRIDGE *RootBus
+ )
+{
+ FreePool (RootBus->DevicePath);
+}
+
+
/**
Utility function to inform the platform that the resource conflict happens.
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 05/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (3 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 04/10] OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 06/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge() Jiahui Cen
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Extend parameter list of PciHostBridgeUtilityInitRootBridge() with
DmaAbove4G and NoExtendedConfigSpace to prepare for support of ArmVirtPkg.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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/OvmfPkg/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/PciHostBridgeUtilityLib.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/Include/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.
- @param[in] Supports Supported attributes.
+ @param[in] Supports Supported attributes.
- @param[in] Attributes Initial attributes.
+ @param[in] Attributes Initial attributes.
- @param[in] AllocAttributes Allocation attributes.
+ @param[in] AllocAttributes Allocation attributes.
- @param[in] RootBusNumber The bus number to store in RootBus.
+ @param[in] DmaAbove4G DMA above 4GB memory.
- @param[in] MaxSubBusNumber The inclusive maximum bus number that can be
- assigned to any subordinate bus found behind any
- PCI bridge hanging off this root bus.
+ @param[in] NoExtendedConfigSpace No Extended Config Space.
- The caller is repsonsible for ensuring that
- RootBusNumber <= 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.
- @param[in] Io IO aperture.
+ @param[in] MaxSubBusNumber The inclusive maximum bus number that can
+ be assigned to any subordinate bus found
+ behind any PCI bridge hanging off this
+ root bus.
- @param[in] Mem MMIO aperture.
+ The caller is repsonsible for ensuring
+ that RootBusNumber <= MaxSubBusNumber. If
+ RootBusNumber equals MaxSubBusNumber, then
+ the root bus has no room for subordinate
+ buses.
- @param[in] MemAbove4G MMIO aperture above 4G.
+ @param[in] Io IO aperture.
- @param[in] PMem Prefetchable MMIO aperture.
+ @param[in] Mem MMIO aperture.
- @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
+ @param[in] MemAbove4G MMIO aperture above 4G.
- @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.
- @retval EFI_SUCCESS Initialization successful. A device path
- consisting of an ACPI device path node, with
- UID = RootBusNumber, has been allocated and
- linked into RootBus.
+ @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
+ @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,
+ with UID = 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 <PiDxe.h>
#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Q35MchIch9.h>
#include <Protocol/PciHostBridgeResourceAllocation.h>
#include <Protocol/PciRootBridgeIo.h>
@@ -151,6 +152,8 @@ PciHostBridgeGetRootBridges (
Attributes,
Attributes,
AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
(UINT8) LastRootBridgeNumber,
(UINT8) (RootBridgeNumber - 1),
&Io,
@@ -176,6 +179,8 @@ PciHostBridgeGetRootBridges (
Attributes,
Attributes,
AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
(UINT8) LastRootBridgeNumber,
PCI_MAX_BUS,
&Io,
diff --git a/OvmfPkg/Library/PciHostBridgeLib/XenSupport.c b/OvmfPkg/Library/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 != NULL);
PciHostBridgeUtilityInitRootBridge (
Attributes, Attributes, 0,
+ FALSE, PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
(UINT8) PrimaryBus, (UINT8) SubBus,
&Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,
&RootBridges[*NumberOfRootBridges]
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 @@
**/
#include <IndustryStandard/Acpi10.h>
-#include <IndustryStandard/Q35MchIch9.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
@@ -64,49 +62,57 @@ OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {
/**
Utility function to initialize a PCI_ROOT_BRIDGE structure.
- @param[in] Supports Supported attributes.
+ @param[in] Supports Supported attributes.
- @param[in] Attributes Initial attributes.
+ @param[in] Attributes Initial attributes.
- @param[in] AllocAttributes Allocation attributes.
+ @param[in] AllocAttributes Allocation attributes.
- @param[in] RootBusNumber The bus number to store in RootBus.
+ @param[in] DmaAbove4G DMA above 4GB memory.
- @param[in] MaxSubBusNumber The inclusive maximum bus number that can be
- assigned to any subordinate bus found behind any
- PCI bridge hanging off this root bus.
+ @param[in] NoExtendedConfigSpace No Extended Config Space.
- The caller is repsonsible for ensuring that
- RootBusNumber <= 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.
- @param[in] Io IO aperture.
+ @param[in] MaxSubBusNumber The inclusive maximum bus number that can
+ be assigned to any subordinate bus found
+ behind any PCI bridge hanging off this
+ root bus.
- @param[in] Mem MMIO aperture.
+ The caller is repsonsible for ensuring
+ that RootBusNumber <= MaxSubBusNumber. If
+ RootBusNumber equals MaxSubBusNumber, then
+ the root bus has no room for subordinate
+ buses.
- @param[in] MemAbove4G MMIO aperture above 4G.
+ @param[in] Io IO aperture.
- @param[in] PMem Prefetchable MMIO aperture.
+ @param[in] Mem MMIO aperture.
- @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
+ @param[in] MemAbove4G MMIO aperture above 4G.
- @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.
- @retval EFI_SUCCESS Initialization successful. A device path
- consisting of an ACPI device path node, with
- UID = RootBusNumber, has been allocated and
- linked into RootBus.
+ @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
- @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
+ @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,
+ with UID = 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 = Supports;
RootBus->Attributes = Attributes;
- RootBus->DmaAbove4G = FALSE;
+ RootBus->DmaAbove4G = DmaAbove4G;
RootBus->AllocationAttributes = AllocAttributes;
RootBus->Bus.Base = RootBusNumber;
@@ -140,8 +146,7 @@ PciHostBridgeUtilityInitRootBridge (
CopyMem (&RootBus->PMem, PMem, sizeof (*PMem));
CopyMem (&RootBus->PMemAbove4G, PMemAbove4G, sizeof (*PMemAbove4G));
- RootBus->NoExtendedConfigSpace = (PcdGet16 (PcdOvmfHostBridgePciDevId) !=
- INTEL_Q35_MCH_DEVICE_ID);
+ RootBus->NoExtendedConfigSpace = NoExtendedConfigSpace;
DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate,
&mRootBridgeDevicePathTemplate);
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 06/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge()
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (4 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 05/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 07/10] OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges Jiahui Cen
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new
PciHostBridgeUtilityInitRootBridge()/PciHostBridgeUtilityUninitRootBridge()
functions.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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
[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 @@
**/
#include <PiDxe.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DxeServicesTableLib.h>
@@ -20,37 +21,6 @@
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/PciHostBridgeResourceAllocation.h>
-#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 = {
- {
- {
- 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;
if (PcdGet64 (PcdPciExpressBaseAddress) == 0) {
DEBUG ((EFI_D_INFO, "%a: PCI host bridge not present\n", __FUNCTION__));
@@ -341,33 +318,29 @@ PciHostBridgeGetRootBridges (
return NULL;
}
- *Count = 1;
+ ZeroMem (&Io, sizeof (Io));
+ ZeroMem (&Mem, sizeof (Mem));
+ ZeroMem (&MemAbove4G, sizeof (MemAbove4G));
+ ZeroMem (&PMem, sizeof (PMem));
+ ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G));
- mRootBridge.Segment = 0;
- mRootBridge.Supports = 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 = mRootBridge.Supports;
+ Attributes = 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.DmaAbove4G = TRUE;
- mRootBridge.NoExtendedConfigSpace = FALSE;
- mRootBridge.ResourceAssigned = FALSE;
+ AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
- mRootBridge.AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
-
- mRootBridge.Bus.Base = BusMin;
- mRootBridge.Bus.Limit = BusMax;
- mRootBridge.Io.Base = IoBase;
- mRootBridge.Io.Limit = IoBase + IoSize - 1;
- mRootBridge.Mem.Base = Mmio32Base;
- mRootBridge.Mem.Limit = Mmio32Base + Mmio32Size - 1;
+ Io.Base = IoBase;
+ Io.Limit = IoBase + IoSize - 1;
+ Mem.Base = Mmio32Base;
+ Mem.Limit = Mmio32Base + Mmio32Size - 1;
if (sizeof (UINTN) == sizeof (UINT64)) {
- mRootBridge.MemAbove4G.Base = Mmio64Base;
- mRootBridge.MemAbove4G.Limit = Mmio64Base + Mmio64Size - 1;
+ MemAbove4G.Base = Mmio64Base;
+ MemAbove4G.Limit = Mmio64Base + Mmio64Size - 1;
if (Mmio64Size > 0) {
- mRootBridge.AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
+ AllocationAttributes |= 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 = MAX_UINT64;
- mRootBridge.MemAbove4G.Limit = 0;
+ MemAbove4G.Base = MAX_UINT64;
+ MemAbove4G.Limit = 0;
}
//
// No separate ranges for prefetchable and non-prefetchable BARs
//
- mRootBridge.PMem.Base = MAX_UINT64;
- mRootBridge.PMem.Limit = 0;
- mRootBridge.PMemAbove4G.Base = MAX_UINT64;
- mRootBridge.PMemAbove4G.Limit = 0;
+ PMem.Base = MAX_UINT64;
+ PMem.Limit = 0;
+ PMemAbove4G.Base = MAX_UINT64;
+ PMemAbove4G.Limit = 0;
- mRootBridge.DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)&mEfiPciRootBridgeDevicePath;
+ Status = 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 = 0;
+ return NULL;
+ }
+
+ *Count = 1;
return &mRootBridge;
}
@@ -408,6 +403,7 @@ PciHostBridgeFreeRootBridges (
)
{
ASSERT (Count == 1);
+ PciHostBridgeUtilityUninitRootBridge (Bridges);
}
/**
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 07/10] OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (5 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 06/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge() Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 08/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Jiahui Cen
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Extract PciHostBridgeGetRootBridges()/PciHostBridgeFreeRootBridges() to
PciHostBridgeUtilityLib as common utility functions.
No change of functionality.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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/OvmfPkg/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
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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/Include/Library/PciHostBridgeUtilityLib.h
index 13c591641d7a..29ea19f2d7e5 100644
--- a/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
+++ b/OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
@@ -97,6 +97,56 @@ PciHostBridgeUtilityUninitRootBridge (
);
+/**
+ 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 happens.
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 <PiDxe.h>
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Q35MchIch9.h>
-
#include <Protocol/PciHostBridgeResourceAllocation.h>
#include <Protocol/PciRootBridgeIo.h>
@@ -21,8 +18,6 @@
#include <Library/PcdLib.h>
#include <Library/PciHostBridgeLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
-#include <Library/PciLib.h>
-#include <Library/QemuFwCfgLib.h>
#include "PciHostBridge.h"
@@ -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 (
*Count = 0;
- //
- // QEMU provides the number of extra root buses, shortening the exhaustive
- // search below. If there is no hint, the feature is missing.
- //
- Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize);
- if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridges) {
- ExtraRootBridges = 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 = AllocatePool ((1 + (UINTN)ExtraRootBridges) * sizeof *Bridges);
- if (Bridges == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
- return NULL;
- }
- Initialized = 0;
-
- //
- // The "main" root bus is always there.
- //
- LastRootBridgeNumber = 0;
-
- //
- // Scan all other root buses. If function 0 of any device on a bus returns a
- // VendorId register value different from all-bits-one, then that bus is
- // alive.
- //
- for (RootBridgeNumber = 1;
- RootBridgeNumber <= PCI_MAX_BUS && Initialized < ExtraRootBridges;
- ++RootBridgeNumber) {
- UINTN Device;
-
- for (Device = 0; Device <= PCI_MAX_DEVICE; ++Device) {
- if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0,
- PCI_VENDOR_ID_OFFSET)) != MAX_UINT16) {
- break;
- }
- }
- if (Device <= 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, for any
- // subordinate buses that might exist behind PCI bridges hanging off it.
- //
- Status = PciHostBridgeUtilityInitRootBridge (
- Attributes,
- Attributes,
- AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != 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 = RootBridgeNumber;
- }
- }
-
- //
- // Install the last root bus (which might be the only, ie. main, root bus, if
- // we've found no extra root buses).
- //
- Status = PciHostBridgeUtilityInitRootBridge (
- Attributes,
+ return PciHostBridgeUtilityGetRootBridges (
+ Count,
Attributes,
AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != 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 = Initialized;
- return Bridges;
-
-FreeBridges:
- while (Initialized > 0) {
- --Initialized;
- PciHostBridgeUtilityUninitRootBridge (&Bridges[Initialized]);
- }
-
- FreePool (Bridges);
- return NULL;
}
@@ -223,17 +105,7 @@ PciHostBridgeFreeRootBridges (
UINTN Count
)
{
- if (Bridges == NULL && Count == 0) {
- return;
- }
- ASSERT (Bridges != NULL && Count > 0);
-
- do {
- --Count;
- PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]);
- } while (Count > 0);
-
- FreePool (Bridges);
+ PciHostBridgeUtilityFreeRootBridges (Bridges, Count);
}
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 @@
**/
#include <IndustryStandard/Acpi10.h>
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Q35MchIch9.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
+#include <Library/PciLib.h>
+#include <Library/QemuFwCfgLib.h>
#pragma pack(1)
@@ -182,6 +187,195 @@ PciHostBridgeUtilityUninitRootBridge (
}
+/**
+ 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 exhaustive
+ // search below. If there is no hint, the feature is missing.
+ //
+ Status = QemuFwCfgFindFile ("etc/extra-pci-roots", &FwCfgItem, &FwCfgSize);
+ if (EFI_ERROR (Status) || FwCfgSize != sizeof ExtraRootBridges) {
+ ExtraRootBridges = 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 = AllocatePool ((1 + (UINTN)ExtraRootBridges) * sizeof *Bridges);
+ if (Bridges == NULL) {
+ DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));
+ return NULL;
+ }
+ Initialized = 0;
+
+ //
+ // The "main" root bus is always there.
+ //
+ LastRootBridgeNumber = 0;
+
+ //
+ // Scan all other root buses. If function 0 of any device on a bus returns a
+ // VendorId register value different from all-bits-one, then that bus is
+ // alive.
+ //
+ for (RootBridgeNumber = 1;
+ RootBridgeNumber <= PCI_MAX_BUS && Initialized < ExtraRootBridges;
+ ++RootBridgeNumber) {
+ UINTN Device;
+
+ for (Device = 0; Device <= PCI_MAX_DEVICE; ++Device) {
+ if (PciRead16 (PCI_LIB_ADDRESS (RootBridgeNumber, Device, 0,
+ PCI_VENDOR_ID_OFFSET)) != MAX_UINT16) {
+ break;
+ }
+ }
+ if (Device <= 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, for any
+ // subordinate buses that might exist behind PCI bridges hanging off it.
+ //
+ Status = PciHostBridgeUtilityInitRootBridge (
+ Attributes,
+ Attributes,
+ AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != 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 = RootBridgeNumber;
+ }
+ }
+
+ //
+ // Install the last root bus (which might be the only, ie. main, root bus, if
+ // we've found no extra root buses).
+ //
+ Status = PciHostBridgeUtilityInitRootBridge (
+ Attributes,
+ Attributes,
+ AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != 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 = 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 == NULL && Count == 0) {
+ return;
+ }
+ ASSERT (Bridges != NULL && Count > 0);
+
+ do {
+ --Count;
+ PciHostBridgeUtilityUninitRootBridge (&Bridges[Count]);
+ } while (Count > 0);
+
+ FreePool (Bridges);
+}
+
+
/**
Utility function to inform the platform that the resource conflict happens.
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 08/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (6 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 07/10] OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 09/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges() Jiahui Cen
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Extend parameter list of PciHostBridgeUtilityGetRootBridges() with
DmaAbove4G, NoExtendedConfigSpace, BusMin and BusMax to support for
ArmVirtPkg.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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/PciHostBridgeUtilityLib.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/Include/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.
- @param[out] Count The number of root bridge instances.
+ @param[out] Count The number of root bridge instances.
- @param[in] Attributes Initial attributes.
+ @param[in] Attributes Initial attributes.
- @param[in] AllocAttributes Allocation attributes.
+ @param[in] AllocAttributes Allocation attributes.
- @param[in] Io IO aperture.
+ @param[in] DmaAbove4G DMA above 4GB memory.
- @param[in] Mem MMIO aperture.
+ @param[in] NoExtendedConfigSpace No Extended Config Space.
- @param[in] MemAbove4G MMIO aperture above 4G.
+ @param[in] BusMin Minimum Bus number
- @param[in] PMem Prefetchable MMIO aperture.
+ @param[in] BusMax Maximum Bus number
- @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
+ @param[in] Io IO aperture.
- @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 array.
**/
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 <PiDxe.h>
+#include <IndustryStandard/Pci.h>
+#include <IndustryStandard/Q35MchIch9.h>
+
#include <Protocol/PciHostBridgeResourceAllocation.h>
#include <Protocol/PciRootBridgeIo.h>
@@ -82,6 +85,10 @@ PciHostBridgeGetRootBridges (
Count,
Attributes,
AllocationAttributes,
+ FALSE,
+ PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
+ 0,
+ PCI_MAX_BUS,
&Io,
&Mem,
&MemAbove4G,
diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.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 @@
#include <IndustryStandard/Acpi10.h>
#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Q35MchIch9.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
#include <Library/PciHostBridgeUtilityLib.h>
#include <Library/PciLib.h>
#include <Library/QemuFwCfgLib.h>
@@ -190,23 +188,31 @@ PciHostBridgeUtilityUninitRootBridge (
/**
Utility function to return all the root bridge instances in an array.
- @param[out] Count The number of root bridge instances.
+ @param[out] Count The number of root bridge instances.
- @param[in] Attributes Initial attributes.
+ @param[in] Attributes Initial attributes.
- @param[in] AllocAttributes Allocation attributes.
+ @param[in] AllocAttributes Allocation attributes.
- @param[in] Io IO aperture.
+ @param[in] DmaAbove4G DMA above 4GB memory.
- @param[in] Mem MMIO aperture.
+ @param[in] NoExtendedConfigSpace No Extended Config Space.
- @param[in] MemAbove4G MMIO aperture above 4G.
+ @param[in] BusMin Minimum Bus number
- @param[in] PMem Prefetchable MMIO aperture.
+ @param[in] BusMax Maximum Bus number
- @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
+ @param[in] Io IO aperture.
- @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 array.
**/
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);
- 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 = 0;
+ LastRootBridgeNumber = BusMin;
//
// Scan all other root buses. If function 0 of any device on a bus returns a
// VendorId register value different from all-bits-one, then that bus is
// alive.
//
- for (RootBridgeNumber = 1;
- RootBridgeNumber <= PCI_MAX_BUS && Initialized < ExtraRootBridges;
+ for (RootBridgeNumber = BusMin + 1;
+ RootBridgeNumber <= BusMax && Initialized < ExtraRootBridges;
++RootBridgeNumber) {
UINTN Device;
@@ -291,8 +301,8 @@ PciHostBridgeUtilityGetRootBridges (
Attributes,
Attributes,
AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
+ DmaAbove4G,
+ NoExtendedConfigSpace,
(UINT8) LastRootBridgeNumber,
(UINT8) (RootBridgeNumber - 1),
Io,
@@ -318,8 +328,8 @@ PciHostBridgeUtilityGetRootBridges (
Attributes,
Attributes,
AllocationAttributes,
- FALSE,
- PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,
+ DmaAbove4G,
+ NoExtendedConfigSpace,
(UINT8) LastRootBridgeNumber,
PCI_MAX_BUS,
Io,
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 09/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges()
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (7 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 08/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 10/10] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Jiahui Cen
2021-01-13 10:42 ` [PATCH v5 00/10] Add extra pci roots support for Arm Laszlo Ersek
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
Rebase ArmVirtPkg/FdtPciHostBridgeLib to the new
PciHostBridgeUtilityGetRootBridges()/PciHostBridgeUtilityFreeRootBridges()
functions.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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;
}
-STATIC PCI_ROOT_BRIDGE mRootBridge;
-
/**
Return all the root bridge instances in an array.
@@ -361,8 +359,10 @@ PciHostBridgeGetRootBridges (
PMemAbove4G.Base = MAX_UINT64;
PMemAbove4G.Limit = 0;
- Status = PciHostBridgeUtilityInitRootBridge (
- Attributes,
+ *Count = 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 = 0;
- return NULL;
- }
-
- *Count = 1;
-
- return &mRootBridge;
}
/**
@@ -402,8 +391,7 @@ PciHostBridgeFreeRootBridges (
UINTN Count
)
{
- ASSERT (Count == 1);
- PciHostBridgeUtilityUninitRootBridge (Bridges);
+ PciHostBridgeUtilityFreeRootBridges (Bridges, Count);
}
/**
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 10/10] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (8 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 09/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges() Jiahui Cen
@ 2021-01-13 10:33 ` Jiahui Cen
2021-01-13 10:42 ` [PATCH v5 00/10] Add extra pci roots support for Arm Laszlo Ersek
10 siblings, 0 replies; 12+ messages in thread
From: Jiahui Cen @ 2021-01-13 10:33 UTC (permalink / raw)
To: devel
Cc: Jordan Justen, Laszlo Ersek, Ard Biesheuvel, Rebecca Cran,
Peter Grehan, Anthony Perard, Julien Grall, Leif Lindholm,
Sami Mujawar, xieyingtai, wu.wubin, Jiahui Cen, Yubo Miao
It is necessary to add padding for hotplugable PCI Devices like
pcie-root-port.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3059
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
Signed-off-by: Yubo Miao <miaoyubo@huawei.com>
---
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]
<LibraryClasses>
NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
}
+ OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
OvmfPkg/Virtio10Dxe/Virtio10.inf
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index c27752b4d5e5..92f327eec4fb 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -424,6 +424,7 @@ [Components.common]
<LibraryClasses>
NULL|ArmVirtPkg/Library/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
}
+ OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
OvmfPkg/VirtioPciDeviceDxe/VirtioPciDeviceDxe.inf
OvmfPkg/Virtio10Dxe/Virtio10.inf
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc b/ArmVirtPkg/ArmVirtQemuFvMain.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
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v5 00/10] Add extra pci roots support for Arm
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
` (9 preceding siblings ...)
2021-01-13 10:33 ` [PATCH v5 10/10] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Jiahui Cen
@ 2021-01-13 10:42 ` Laszlo Ersek
10 siblings, 0 replies; 12+ messages in thread
From: Laszlo Ersek @ 2021-01-13 10:42 UTC (permalink / raw)
To: Jiahui Cen, devel
Cc: Jordan Justen, Ard Biesheuvel, Rebecca Cran, Peter Grehan,
Anthony Perard, Julien Grall, Leif Lindholm, Sami Mujawar,
xieyingtai, wu.wubin, Yubo Miao
On 01/13/21 11:33, Jiahui Cen wrote:
> v4->v5:
> * Revert some risky renames.
> * Explicitly list PcdLib dependency.
> * Fix issues reported by PatchCheck.py.
... I wasn't done reviewing v4, I just stopped reviewing the v4 series
for today. (There's only so much review I can perform in a single day --
I spent a bit more than two hours reviewing patches 1-5 in the v4 series.)
I think I'll ignore v5 for now, and continue with the rest of v4
tomorrow (patch #6 and onwards). Then I'll compare v4 <-> v6.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-01-13 10:42 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-13 10:33 [PATCH v5 00/10] Add extra pci roots support for Arm Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 01/10] OvmfPkg: Introduce PciHostBridgeUtilityLib class Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 02/10] ArmVirtPkg: Refactor with PciHostBridgeUtilityLib Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 03/10] OvmfPkg/PciHostBridgeLib: List missing PcdLib dependency Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 04/10] OvmfPkg/PciHostBridgeLib: Extract Init/UninitRootBridge Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 05/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of InitRootBridge Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 06/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Init/UninitRootBridge() Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 07/10] OvmfPkg/PciHostBridgeLib: Extract Get/FreeRootBridges Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 08/10] OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 09/10] ArmVirtPkg/FdtPciHostBridgeLib: Refactor Get/FreeRootBridges() Jiahui Cen
2021-01-13 10:33 ` [PATCH v5 10/10] ArmVirtPkg/ArmVirtQemu: Add support for HotPlug Jiahui Cen
2021-01-13 10:42 ` [PATCH v5 00/10] Add extra pci roots support for Arm Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox