2 Provide common utility functions to PciHostBridgeLib instances in
3 ArmVirtPkg and OvmfPkg.
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>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
13 #ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__
14 #define __PCI_HOST_BRIDGE_UTILITY_LIB_H__
16 #include <Library/PciHostBridgeLib.h>
19 Utility function to initialize a PCI_ROOT_BRIDGE structure.
21 @param[in] Supports Supported attributes.
23 @param[in] Attributes Initial attributes.
25 @param[in] AllocAttributes Allocation attributes.
27 @param[in] DmaAbove4G DMA above 4GB memory.
29 @param[in] NoExtendedConfigSpace No Extended Config Space.
31 @param[in] RootBusNumber The bus number to store in RootBus.
33 @param[in] MaxSubBusNumber The inclusive maximum bus number that can
34 be assigned to any subordinate bus found
35 behind any PCI bridge hanging off this
38 The caller is repsonsible for ensuring
39 that RootBusNumber <= MaxSubBusNumber. If
40 RootBusNumber equals MaxSubBusNumber, then
41 the root bus has no room for subordinate
44 @param[in] Io IO aperture.
46 @param[in] Mem MMIO aperture.
48 @param[in] MemAbove4G MMIO aperture above 4G.
50 @param[in] PMem Prefetchable MMIO aperture.
52 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
54 @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated
55 by the caller) that should be filled in by
58 @retval EFI_SUCCESS Initialization successful. A device path
59 consisting of an ACPI device path node,
60 with UID = RootBusNumber, has been
61 allocated and linked into RootBus.
63 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
67 PciHostBridgeUtilityInitRootBridge (
70 IN UINT64 AllocAttributes
,
71 IN BOOLEAN DmaAbove4G
,
72 IN BOOLEAN NoExtendedConfigSpace
,
73 IN UINT8 RootBusNumber
,
74 IN UINT8 MaxSubBusNumber
,
75 IN PCI_ROOT_BRIDGE_APERTURE
*Io
,
76 IN PCI_ROOT_BRIDGE_APERTURE
*Mem
,
77 IN PCI_ROOT_BRIDGE_APERTURE
*MemAbove4G
,
78 IN PCI_ROOT_BRIDGE_APERTURE
*PMem
,
79 IN PCI_ROOT_BRIDGE_APERTURE
*PMemAbove4G
,
80 OUT PCI_ROOT_BRIDGE
*RootBus
84 Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with
85 PciHostBridgeUtilityInitRootBridge().
87 @param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the caller and
88 initialized with PciHostBridgeUtilityInitRootBridge(),
89 that should be uninitialized. This function doesn't free
94 PciHostBridgeUtilityUninitRootBridge (
95 IN PCI_ROOT_BRIDGE
*RootBus
99 Utility function to return all the root bridge instances in an array.
101 @param[out] Count The number of root bridge instances.
103 @param[in] Attributes Initial attributes.
105 @param[in] AllocAttributes Allocation attributes.
107 @param[in] DmaAbove4G DMA above 4GB memory.
109 @param[in] NoExtendedConfigSpace No Extended Config Space.
111 @param[in] BusMin Minimum Bus number, inclusive.
113 @param[in] BusMax Maximum Bus number, inclusive.
115 @param[in] Io IO aperture.
117 @param[in] Mem MMIO aperture.
119 @param[in] MemAbove4G MMIO aperture above 4G.
121 @param[in] PMem Prefetchable MMIO aperture.
123 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.
125 @return All the root bridge instances in an array.
129 PciHostBridgeUtilityGetRootBridges (
131 IN UINT64 Attributes
,
132 IN UINT64 AllocationAttributes
,
133 IN BOOLEAN DmaAbove4G
,
134 IN BOOLEAN NoExtendedConfigSpace
,
137 IN PCI_ROOT_BRIDGE_APERTURE
*Io
,
138 IN PCI_ROOT_BRIDGE_APERTURE
*Mem
,
139 IN PCI_ROOT_BRIDGE_APERTURE
*MemAbove4G
,
140 IN PCI_ROOT_BRIDGE_APERTURE
*PMem
,
141 IN PCI_ROOT_BRIDGE_APERTURE
*PMemAbove4G
145 Utility function to free root bridge instances array from
146 PciHostBridgeUtilityGetRootBridges().
148 @param[in] Bridges The root bridge instances array.
149 @param[in] Count The count of the array.
153 PciHostBridgeUtilityFreeRootBridges (
154 IN PCI_ROOT_BRIDGE
*Bridges
,
159 Utility function to inform the platform that the resource conflict happens.
161 @param[in] Configuration Pointer to PCI I/O and PCI memory resource
162 descriptors. The Configuration contains the
163 resources for all the root bridges. The resource
164 for each root bridge is terminated with END
165 descriptor and an additional END is appended
166 indicating the end of the entire resources. The
167 resource descriptor field values follow the
169 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
174 PciHostBridgeUtilityResourceConflict (
175 IN VOID
*Configuration
178 #endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__