]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
OvmfPkg/PciHostBridgeUtilityLib: Extend parameter list of GetRootBridges
[mirror_edk2.git] / OvmfPkg / Include / Library / PciHostBridgeUtilityLib.h
CommitLineData
7a6172f8
JC
1/** @file\r
2 Provide common utility functions to PciHostBridgeLib instances in\r
3 ArmVirtPkg and OvmfPkg.\r
4\r
5 Copyright (C) 2016, Red Hat, Inc.\r
6 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
7 Copyright (c) 2020, Huawei Corporation. All rights reserved.<BR>\r
8\r
9 SPDX-License-Identifier: BSD-2-Clause-Patent\r
10\r
11**/\r
12\r
13#ifndef __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r
14#define __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r
15\r
16\r
7ac1f28d
JC
17#include <Library/PciHostBridgeLib.h>\r
18\r
19\r
20/**\r
21 Utility function to initialize a PCI_ROOT_BRIDGE structure.\r
22\r
e1b259da 23 @param[in] Supports Supported attributes.\r
7ac1f28d 24\r
e1b259da 25 @param[in] Attributes Initial attributes.\r
7ac1f28d 26\r
e1b259da 27 @param[in] AllocAttributes Allocation attributes.\r
7ac1f28d 28\r
e1b259da 29 @param[in] DmaAbove4G DMA above 4GB memory.\r
7ac1f28d 30\r
e1b259da 31 @param[in] NoExtendedConfigSpace No Extended Config Space.\r
7ac1f28d 32\r
e1b259da 33 @param[in] RootBusNumber The bus number to store in RootBus.\r
7ac1f28d 34\r
e1b259da
JC
35 @param[in] MaxSubBusNumber The inclusive maximum bus number that can\r
36 be assigned to any subordinate bus found\r
37 behind any PCI bridge hanging off this\r
38 root bus.\r
7ac1f28d 39\r
e1b259da
JC
40 The caller is repsonsible for ensuring\r
41 that RootBusNumber <= MaxSubBusNumber. If\r
42 RootBusNumber equals MaxSubBusNumber, then\r
43 the root bus has no room for subordinate\r
44 buses.\r
7ac1f28d 45\r
e1b259da 46 @param[in] Io IO aperture.\r
7ac1f28d 47\r
e1b259da 48 @param[in] Mem MMIO aperture.\r
7ac1f28d 49\r
e1b259da 50 @param[in] MemAbove4G MMIO aperture above 4G.\r
7ac1f28d 51\r
e1b259da 52 @param[in] PMem Prefetchable MMIO aperture.\r
7ac1f28d 53\r
e1b259da 54 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
7ac1f28d 55\r
e1b259da
JC
56 @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated\r
57 by the caller) that should be filled in by\r
58 this function.\r
59\r
60 @retval EFI_SUCCESS Initialization successful. A device path\r
61 consisting of an ACPI device path node,\r
62 with UID = RootBusNumber, has been\r
63 allocated and linked into RootBus.\r
64\r
65 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
7ac1f28d
JC
66**/\r
67EFI_STATUS\r
68EFIAPI\r
69PciHostBridgeUtilityInitRootBridge (\r
70 IN UINT64 Supports,\r
71 IN UINT64 Attributes,\r
72 IN UINT64 AllocAttributes,\r
e1b259da
JC
73 IN BOOLEAN DmaAbove4G,\r
74 IN BOOLEAN NoExtendedConfigSpace,\r
7ac1f28d
JC
75 IN UINT8 RootBusNumber,\r
76 IN UINT8 MaxSubBusNumber,\r
77 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
78 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
79 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
80 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
81 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,\r
82 OUT PCI_ROOT_BRIDGE *RootBus\r
83 );\r
84\r
85\r
86/**\r
87 Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with\r
88 PciHostBridgeUtilityInitRootBridge().\r
89\r
90 @param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the caller and\r
91 initialized with PciHostBridgeUtilityInitRootBridge(),\r
92 that should be uninitialized. This function doesn't free\r
93 RootBus.\r
94**/\r
95VOID\r
96EFIAPI\r
97PciHostBridgeUtilityUninitRootBridge (\r
98 IN PCI_ROOT_BRIDGE *RootBus\r
99 );\r
100\r
101\r
4edba296
JC
102/**\r
103 Utility function to return all the root bridge instances in an array.\r
104\r
14d4b6be 105 @param[out] Count The number of root bridge instances.\r
4edba296 106\r
14d4b6be 107 @param[in] Attributes Initial attributes.\r
4edba296 108\r
14d4b6be 109 @param[in] AllocAttributes Allocation attributes.\r
4edba296 110\r
14d4b6be 111 @param[in] DmaAbove4G DMA above 4GB memory.\r
4edba296 112\r
14d4b6be 113 @param[in] NoExtendedConfigSpace No Extended Config Space.\r
4edba296 114\r
14d4b6be 115 @param[in] Io IO aperture.\r
4edba296 116\r
14d4b6be 117 @param[in] Mem MMIO aperture.\r
4edba296 118\r
14d4b6be 119 @param[in] MemAbove4G MMIO aperture above 4G.\r
4edba296 120\r
14d4b6be
JC
121 @param[in] PMem Prefetchable MMIO aperture.\r
122\r
123 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
124\r
125 @return All the root bridge instances in an array.\r
4edba296
JC
126**/\r
127PCI_ROOT_BRIDGE *\r
128EFIAPI\r
129PciHostBridgeUtilityGetRootBridges (\r
130 OUT UINTN *Count,\r
131 IN UINT64 Attributes,\r
132 IN UINT64 AllocationAttributes,\r
14d4b6be
JC
133 IN BOOLEAN DmaAbove4G,\r
134 IN BOOLEAN NoExtendedConfigSpace,\r
4edba296
JC
135 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
136 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
137 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
138 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
139 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G\r
140 );\r
141\r
142\r
143/**\r
144 Utility function to free root bridge instances array from\r
145 PciHostBridgeUtilityGetRootBridges().\r
146\r
147 @param[in] Bridges The root bridge instances array.\r
148 @param[in] Count The count of the array.\r
149**/\r
150VOID\r
151EFIAPI\r
152PciHostBridgeUtilityFreeRootBridges (\r
153 IN PCI_ROOT_BRIDGE *Bridges,\r
154 IN UINTN Count\r
155 );\r
156\r
157\r
7a6172f8
JC
158/**\r
159 Utility function to inform the platform that the resource conflict happens.\r
160\r
161 @param[in] Configuration Pointer to PCI I/O and PCI memory resource\r
162 descriptors. The Configuration contains the\r
163 resources for all the root bridges. The resource\r
164 for each root bridge is terminated with END\r
165 descriptor and an additional END is appended\r
166 indicating the end of the entire resources. The\r
167 resource descriptor field values follow the\r
168 description in\r
169 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
170 .SubmitResources().\r
171**/\r
172VOID\r
173EFIAPI\r
174PciHostBridgeUtilityResourceConflict (\r
175 IN VOID *Configuration\r
176 );\r
177\r
178\r
179#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r