]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
OvmfPkg/PciHostBridgeLib: Extract GetRootBridges() / FreeRootBridges()
[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
105 @param[out] Count The number of root bridge instances.\r
106\r
107 @param[in] Attributes Initial attributes.\r
108\r
109 @param[in] AllocAttributes Allocation attributes.\r
110\r
111 @param[in] Io IO aperture.\r
112\r
113 @param[in] Mem MMIO aperture.\r
114\r
115 @param[in] MemAbove4G MMIO aperture above 4G.\r
116\r
117 @param[in] PMem Prefetchable MMIO aperture.\r
118\r
119 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
120\r
121 @return All the root bridge instances in an array.\r
122**/\r
123PCI_ROOT_BRIDGE *\r
124EFIAPI\r
125PciHostBridgeUtilityGetRootBridges (\r
126 OUT UINTN *Count,\r
127 IN UINT64 Attributes,\r
128 IN UINT64 AllocationAttributes,\r
129 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
130 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
131 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
132 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
133 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G\r
134 );\r
135\r
136\r
137/**\r
138 Utility function to free root bridge instances array from\r
139 PciHostBridgeUtilityGetRootBridges().\r
140\r
141 @param[in] Bridges The root bridge instances array.\r
142 @param[in] Count The count of the array.\r
143**/\r
144VOID\r
145EFIAPI\r
146PciHostBridgeUtilityFreeRootBridges (\r
147 IN PCI_ROOT_BRIDGE *Bridges,\r
148 IN UINTN Count\r
149 );\r
150\r
151\r
7a6172f8
JC
152/**\r
153 Utility function to inform the platform that the resource conflict happens.\r
154\r
155 @param[in] Configuration Pointer to PCI I/O and PCI memory resource\r
156 descriptors. The Configuration contains the\r
157 resources for all the root bridges. The resource\r
158 for each root bridge is terminated with END\r
159 descriptor and an additional END is appended\r
160 indicating the end of the entire resources. The\r
161 resource descriptor field values follow the\r
162 description in\r
163 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
164 .SubmitResources().\r
165**/\r
166VOID\r
167EFIAPI\r
168PciHostBridgeUtilityResourceConflict (\r
169 IN VOID *Configuration\r
170 );\r
171\r
172\r
173#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r