]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
3752993f65aa2fe32671a638a3e12bb5460e3988
[mirror_edk2.git] / OvmfPkg / Library / PciHostBridgeLib / PciHostBridgeLib.c
1 /** @file
2 OVMF's instance of the PCI Host Bridge Library.
3
4 Copyright (C) 2016, Red Hat, Inc.
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16 #include <PiDxe.h>
17 #include <Library/PciHostBridgeLib.h>
18 #include <Library/DebugLib.h>
19
20 GLOBAL_REMOVE_IF_UNREFERENCED
21 CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {
22 L"Mem", L"I/O", L"Bus"
23 };
24
25 /**
26 Return all the root bridge instances in an array.
27
28 @param Count Return the count of root bridge instances.
29
30 @return All the root bridge instances in an array.
31 The array should be passed into PciHostBridgeFreeRootBridges()
32 when it's not used.
33 **/
34 PCI_ROOT_BRIDGE *
35 EFIAPI
36 PciHostBridgeGetRootBridges (
37 UINTN *Count
38 )
39 {
40 *Count = 0;
41 return NULL;
42 }
43
44 /**
45 Free the root bridge instances array returned from
46 PciHostBridgeGetRootBridges().
47
48 @param The root bridge instances array.
49 @param The count of the array.
50 **/
51 VOID
52 EFIAPI
53 PciHostBridgeFreeRootBridges (
54 PCI_ROOT_BRIDGE *Bridges,
55 UINTN Count
56 )
57 {
58 return;
59 }
60
61 /**
62 Inform the platform that the resource conflict happens.
63
64 @param HostBridgeHandle Handle of the Host Bridge.
65 @param Configuration Pointer to PCI I/O and PCI memory resource
66 descriptors. The Configuration contains the resources
67 for all the root bridges. The resource for each root
68 bridge is terminated with END descriptor and an
69 additional END is appended indicating the end of the
70 entire resources. The resource descriptor field
71 values follow the description in
72 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
73 .SubmitResources().
74 **/
75 VOID
76 EFIAPI
77 PciHostBridgeResourceConflict (
78 EFI_HANDLE HostBridgeHandle,
79 VOID *Configuration
80 )
81 {
82 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;
83 UINTN RootBridgeIndex;
84 DEBUG ((EFI_D_ERROR, "PciHostBridge: Resource conflict happens!\n"));
85
86 RootBridgeIndex = 0;
87 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;
88 while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {
89 DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));
90 for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {
91 ASSERT (Descriptor->ResType <
92 (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /
93 sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])
94 )
95 );
96 DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",
97 mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],
98 Descriptor->AddrLen, Descriptor->AddrRangeMax
99 ));
100 if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {
101 DEBUG ((EFI_D_ERROR, " Granularity/SpecificFlag = %ld / %02x%s\n",
102 Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,
103 ((Descriptor->SpecificFlag &
104 EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE
105 ) != 0) ? L" (Prefetchable)" : L""
106 ));
107 }
108 }
109 //
110 // Skip the END descriptor for root bridge
111 //
112 ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);
113 Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(
114 (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1
115 );
116 }
117 }