]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/PciHostBridgeUtilityLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
7ac1f28d
JC
16#include <Library/PciHostBridgeLib.h>\r
17\r
7ac1f28d
JC
18/**\r
19 Utility function to initialize a PCI_ROOT_BRIDGE structure.\r
20\r
e1b259da 21 @param[in] Supports Supported attributes.\r
7ac1f28d 22\r
e1b259da 23 @param[in] Attributes Initial attributes.\r
7ac1f28d 24\r
e1b259da 25 @param[in] AllocAttributes Allocation attributes.\r
7ac1f28d 26\r
e1b259da 27 @param[in] DmaAbove4G DMA above 4GB memory.\r
7ac1f28d 28\r
e1b259da 29 @param[in] NoExtendedConfigSpace No Extended Config Space.\r
7ac1f28d 30\r
e1b259da 31 @param[in] RootBusNumber The bus number to store in RootBus.\r
7ac1f28d 32\r
e1b259da
JC
33 @param[in] MaxSubBusNumber The inclusive maximum bus number that can\r
34 be assigned to any subordinate bus found\r
35 behind any PCI bridge hanging off this\r
36 root bus.\r
7ac1f28d 37\r
e1b259da
JC
38 The caller is repsonsible for ensuring\r
39 that RootBusNumber <= MaxSubBusNumber. If\r
40 RootBusNumber equals MaxSubBusNumber, then\r
41 the root bus has no room for subordinate\r
42 buses.\r
7ac1f28d 43\r
e1b259da 44 @param[in] Io IO aperture.\r
7ac1f28d 45\r
e1b259da 46 @param[in] Mem MMIO aperture.\r
7ac1f28d 47\r
e1b259da 48 @param[in] MemAbove4G MMIO aperture above 4G.\r
7ac1f28d 49\r
e1b259da 50 @param[in] PMem Prefetchable MMIO aperture.\r
7ac1f28d 51\r
e1b259da 52 @param[in] PMemAbove4G Prefetchable MMIO aperture above 4G.\r
7ac1f28d 53\r
e1b259da
JC
54 @param[out] RootBus The PCI_ROOT_BRIDGE structure (allocated\r
55 by the caller) that should be filled in by\r
56 this function.\r
57\r
58 @retval EFI_SUCCESS Initialization successful. A device path\r
59 consisting of an ACPI device path node,\r
60 with UID = RootBusNumber, has been\r
61 allocated and linked into RootBus.\r
62\r
63 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.\r
7ac1f28d
JC
64**/\r
65EFI_STATUS\r
66EFIAPI\r
67PciHostBridgeUtilityInitRootBridge (\r
ac0a286f
MK
68 IN UINT64 Supports,\r
69 IN UINT64 Attributes,\r
70 IN UINT64 AllocAttributes,\r
71 IN BOOLEAN DmaAbove4G,\r
72 IN BOOLEAN NoExtendedConfigSpace,\r
73 IN UINT8 RootBusNumber,\r
74 IN UINT8 MaxSubBusNumber,\r
75 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
76 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
77 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
78 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
79 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G,\r
80 OUT PCI_ROOT_BRIDGE *RootBus\r
7ac1f28d
JC
81 );\r
82\r
7ac1f28d
JC
83/**\r
84 Utility function to uninitialize a PCI_ROOT_BRIDGE structure set up with\r
85 PciHostBridgeUtilityInitRootBridge().\r
86\r
87 @param[in] RootBus The PCI_ROOT_BRIDGE structure, allocated by the caller and\r
88 initialized with PciHostBridgeUtilityInitRootBridge(),\r
89 that should be uninitialized. This function doesn't free\r
90 RootBus.\r
91**/\r
92VOID\r
93EFIAPI\r
94PciHostBridgeUtilityUninitRootBridge (\r
ac0a286f 95 IN PCI_ROOT_BRIDGE *RootBus\r
7ac1f28d
JC
96 );\r
97\r
4edba296
JC
98/**\r
99 Utility function to return all the root bridge instances in an array.\r
100\r
14d4b6be 101 @param[out] Count The number of root bridge instances.\r
4edba296 102\r
14d4b6be 103 @param[in] Attributes Initial attributes.\r
4edba296 104\r
14d4b6be 105 @param[in] AllocAttributes Allocation attributes.\r
4edba296 106\r
14d4b6be 107 @param[in] DmaAbove4G DMA above 4GB memory.\r
4edba296 108\r
14d4b6be 109 @param[in] NoExtendedConfigSpace No Extended Config Space.\r
4edba296 110\r
f4a257a3
JC
111 @param[in] BusMin Minimum Bus number, inclusive.\r
112\r
113 @param[in] BusMax Maximum Bus number, inclusive.\r
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
ac0a286f
MK
130 OUT UINTN *Count,\r
131 IN UINT64 Attributes,\r
132 IN UINT64 AllocationAttributes,\r
133 IN BOOLEAN DmaAbove4G,\r
134 IN BOOLEAN NoExtendedConfigSpace,\r
135 IN UINTN BusMin,\r
136 IN UINTN BusMax,\r
137 IN PCI_ROOT_BRIDGE_APERTURE *Io,\r
138 IN PCI_ROOT_BRIDGE_APERTURE *Mem,\r
139 IN PCI_ROOT_BRIDGE_APERTURE *MemAbove4G,\r
140 IN PCI_ROOT_BRIDGE_APERTURE *PMem,\r
141 IN PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G\r
4edba296
JC
142 );\r
143\r
4edba296
JC
144/**\r
145 Utility function to free root bridge instances array from\r
146 PciHostBridgeUtilityGetRootBridges().\r
147\r
148 @param[in] Bridges The root bridge instances array.\r
149 @param[in] Count The count of the array.\r
150**/\r
151VOID\r
152EFIAPI\r
153PciHostBridgeUtilityFreeRootBridges (\r
ac0a286f
MK
154 IN PCI_ROOT_BRIDGE *Bridges,\r
155 IN UINTN Count\r
4edba296
JC
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
7a6172f8 178#endif // __PCI_HOST_BRIDGE_UTILITY_LIB_H__\r