MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
--- /dev/null
+/** @file\r
+ Provide common utility functions to PciHostBridgeLib instances in\r
+ ArmVirtPkg and OvmfPkg.\r
+\r
+ Copyright (C) 2016, Red Hat, Inc.\r
+ Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r
+#define __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r
+\r
+\r
+/**\r
+ Utility function to inform the platform that the resource conflict happens.\r
+\r
+ @param[in] Configuration Pointer to PCI I/O and PCI memory resource\r
+ descriptors. The Configuration contains the\r
+ resources for all the root bridges. The resource\r
+ for each root bridge is terminated with END\r
+ descriptor and an additional END is appended\r
+ indicating the end of the entire resources. The\r
+ resource descriptor field values follow the\r
+ description in\r
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
+ .SubmitResources().\r
+**/\r
+VOID\r
+EFIAPI\r
+PciHostBridgeUtilityResourceConflict (\r
+ IN VOID *Configuration\r
+ );\r
+\r
+\r
+#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r
#include <Library/DevicePathLib.h>\r
#include <Library/MemoryAllocationLib.h>\r
#include <Library/PciHostBridgeLib.h>\r
+#include <Library/PciHostBridgeUtilityLib.h>\r
#include <Library/PciLib.h>\r
#include <Library/QemuFwCfgLib.h>\r
#include "PciHostBridge.h"\r
#pragma pack ()\r
\r
\r
-GLOBAL_REMOVE_IF_UNREFERENCED\r
-CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {\r
- L"Mem", L"I/O", L"Bus"\r
-};\r
-\r
-\r
STATIC\r
CONST\r
OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {\r
VOID *Configuration\r
)\r
{\r
- EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;\r
- UINTN RootBridgeIndex;\r
- DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));\r
-\r
- RootBridgeIndex = 0;\r
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;\r
- while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
- DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));\r
- for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {\r
- ASSERT (Descriptor->ResType <\r
- ARRAY_SIZE (mPciHostBridgeLibAcpiAddressSpaceTypeStr)\r
- );\r
- DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",\r
- mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],\r
- Descriptor->AddrLen, Descriptor->AddrRangeMax\r
- ));\r
- if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {\r
- DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",\r
- Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,\r
- ((Descriptor->SpecificFlag &\r
- EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE\r
- ) != 0) ? L" (Prefetchable)" : L""\r
- ));\r
- }\r
- }\r
- //\r
- // Skip the END descriptor for root bridge\r
- //\r
- ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);\r
- Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(\r
- (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1\r
- );\r
- }\r
+ PciHostBridgeUtilityResourceConflict (Configuration);\r
}\r
DebugLib\r
DevicePathLib\r
MemoryAllocationLib\r
+ PciHostBridgeUtilityLib\r
PciLib\r
QemuFwCfgLib\r
\r
--- /dev/null
+/** @file\r
+ Provide common utility functions to PciHostBridgeLib instances in\r
+ ArmVirtPkg and OvmfPkg.\r
+\r
+ Copyright (C) 2016, Red Hat, Inc.\r
+ Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <IndustryStandard/Acpi10.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PciHostBridgeUtilityLib.h>\r
+\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED\r
+CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] = {\r
+ L"Mem", L"I/O", L"Bus"\r
+};\r
+\r
+\r
+/**\r
+ Utility function to inform the platform that the resource conflict happens.\r
+\r
+ @param[in] Configuration Pointer to PCI I/O and PCI memory resource\r
+ descriptors. The Configuration contains the\r
+ resources for all the root bridges. The resource\r
+ for each root bridge is terminated with END\r
+ descriptor and an additional END is appended\r
+ indicating the end of the entire resources. The\r
+ resource descriptor field values follow the\r
+ description in\r
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
+ .SubmitResources().\r
+**/\r
+VOID\r
+EFIAPI\r
+PciHostBridgeUtilityResourceConflict (\r
+ IN VOID *Configuration\r
+ )\r
+{\r
+ EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;\r
+ UINTN RootBridgeIndex;\r
+ DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));\r
+\r
+ RootBridgeIndex = 0;\r
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;\r
+ while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
+ DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));\r
+ for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {\r
+ ASSERT (Descriptor->ResType <\r
+ ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr)\r
+ );\r
+ DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",\r
+ mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->ResType],\r
+ Descriptor->AddrLen, Descriptor->AddrRangeMax\r
+ ));\r
+ if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {\r
+ DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",\r
+ Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,\r
+ ((Descriptor->SpecificFlag &\r
+ EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE\r
+ ) != 0) ? L" (Prefetchable)" : L""\r
+ ));\r
+ }\r
+ }\r
+ //\r
+ // Skip the END descriptor for root bridge\r
+ //\r
+ ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);\r
+ Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(\r
+ (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1\r
+ );\r
+ }\r
+}\r
+\r
--- /dev/null
+## @file\r
+# Provide common utility functions to PciHostBridgeLib instances in\r
+# ArmVirtPkg and OvmfPkg.\r
+#\r
+# Copyright (C) 2016, Red Hat, Inc.\r
+# Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 1.29\r
+ BASE_NAME = PciHostBridgeUtilityLib\r
+ FILE_GUID = e3aa5932-527a-42e7-86f5-81b144c7e5f1\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = PciHostBridgeUtilityLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build\r
+# tools.\r
+#\r
+# VALID_ARCHITECTURES = IA32 X64 AARCH64 ARM\r
+#\r
+\r
+[Sources]\r
+ PciHostBridgeUtilityLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ DebugLib\r
# access.\r
PciCapPciSegmentLib|Include/Library/PciCapPciSegmentLib.h\r
\r
+ ## @libraryclass Provide common utility functions to PciHostBridgeLib\r
+ # instances in ArmVirtPkg and OvmfPkg.\r
+ PciHostBridgeUtilityLib|Include/Library/PciHostBridgeUtilityLib.h\r
+\r
## @libraryclass Register a status code handler for printing the Boot\r
# Manager's LoadImage() and StartImage() preparations, and\r
# return codes, to the UEFI console.\r
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {\r
<LibraryClasses>\r
PciHostBridgeLib|OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf\r
+ PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf\r
NULL|OvmfPkg/Library/PlatformHasIoMmuLib/PlatformHasIoMmuLib.inf\r
}\r
MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf {\r