mirror of
https://github.com/acidanthera/audk.git
synced 2025-12-13 16:44:44 +01:00
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> Message-Id: <20210119011302.10908-2-cenjiahui@huawei.com>
79 lines
3.0 KiB
C
79 lines
3.0 KiB
C
/** @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[in] 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 (
|
|
IN 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
|
|
);
|
|
}
|
|
}
|
|
|