]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c
OvmfPkg: Introduce PciHostBridgeUtilityLib class
[mirror_edk2.git] / OvmfPkg / Library / PciHostBridgeUtilityLib / PciHostBridgeUtilityLib.c
1 /** @file
2 Provide common utility functions to PciHostBridgeLib instances in
3 ArmVirtPkg and OvmfPkg.
4
5 Copyright (C) 2016, Red Hat, Inc.
6 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
7 Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>
8
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13 #include <IndustryStandard/Acpi10.h>
14 #include <Library/DebugLib.h>
15 #include <Library/PciHostBridgeUtilityLib.h>
16
17
18 GLOBAL_REMOVE_IF_UNREFERENCED
19 CHAR16 *mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[] = {
20 L"Mem", L"I/O", L"Bus"
21 };
22
23
24 /**
25 Utility function to inform the platform that the resource conflict happens.
26
27 @param[in] Configuration Pointer to PCI I/O and PCI memory resource
28 descriptors. The Configuration contains the
29 resources for all the root bridges. The resource
30 for each root bridge is terminated with END
31 descriptor and an additional END is appended
32 indicating the end of the entire resources. The
33 resource descriptor field values follow the
34 description in
35 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
36 .SubmitResources().
37 **/
38 VOID
39 EFIAPI
40 PciHostBridgeUtilityResourceConflict (
41 IN VOID *Configuration
42 )
43 {
44 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
45 UINTN RootBridgeIndex;
46 DEBUG ((DEBUG_ERROR, "PciHostBridge: Resource conflict happens!\n"));
47
48 RootBridgeIndex = 0;
49 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
50 while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
51 DEBUG ((DEBUG_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
52 for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
53 ASSERT (Descriptor->ResType <
54 ARRAY_SIZE (mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr)
55 );
56 DEBUG ((DEBUG_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
57 mPciHostBridgeUtilityLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
58 Descriptor->AddrLen, Descriptor->AddrRangeMax
59 ));
60 if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
61 DEBUG ((DEBUG_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
62 Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
63 ((Descriptor->SpecificFlag &
64 EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
65 ) != 0) ? L" (Prefetchable)" : L""
66 ));
67 }
68 }
69 //
70 // Skip the END descriptor for root bridge
71 //
72 ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
73 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
74 (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
75 );
76 }
77 }
78