]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
MdeModulePkg/PciHostBridge: Move declaration of mIoMmu to header file
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciHostBridge.h
1 /** @file
2
3 The Header file of the Pci Host Bridge Driver.
4
5 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _PCI_HOST_BRIDGE_H_
17 #define _PCI_HOST_BRIDGE_H_
18
19
20 #include <PiDxe.h>
21 #include <IndustryStandard/Acpi.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/PciHostBridgeLib.h>
25 #include <Protocol/PciHostBridgeResourceAllocation.h>
26 #include <Protocol/IoMmu.h>
27
28 #include "PciRootBridge.h"
29
30 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
31 typedef struct {
32 UINTN Signature;
33 EFI_HANDLE Handle;
34 LIST_ENTRY RootBridges;
35 BOOLEAN CanRestarted;
36 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;
37 } PCI_HOST_BRIDGE_INSTANCE;
38
39 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
40
41 //
42 // Macros to translate device address to host address and vice versa. According
43 // to UEFI 2.7, device address = host address + translation offset.
44 //
45 #define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) - (TranslationOffset))
46 #define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + (TranslationOffset))
47
48 //
49 // Driver Entry Point
50 //
51 /**
52
53 Entry point of this driver.
54
55 @param ImageHandle - Image handle of this driver.
56 @param SystemTable - Pointer to standard EFI system table.
57
58 @retval EFI_SUCCESS - Succeed.
59 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
60
61 **/
62 EFI_STATUS
63 EFIAPI
64 InitializePciHostBridge (
65 IN EFI_HANDLE ImageHandle,
66 IN EFI_SYSTEM_TABLE *SystemTable
67 );
68
69 //
70 // HostBridge Resource Allocation interface
71 //
72 /**
73
74 Enter a certain phase of the PCI enumeration process.
75
76 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
77 @param Phase The phase during enumeration.
78
79 @retval EFI_SUCCESS Succeed.
80 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
81 @retval EFI_NOT_READY Resources have not been submitted yet.
82
83 **/
84 EFI_STATUS
85 EFIAPI
86 NotifyPhase (
87 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
88 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
89 );
90
91 /**
92
93 Return the device handle of the next PCI root bridge that is associated with
94 this Host Bridge.
95
96 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
97 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
98 On input, it holds the RootBridgeHandle returned by the most
99 recent call to GetNextRootBridge().The handle for the first
100 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
101
102 @retval EFI_SUCCESS Succeed.
103 @retval EFI_NOT_FOUND Next PCI root bridge not found.
104 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
105
106 **/
107 EFI_STATUS
108 EFIAPI
109 GetNextRootBridge (
110 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
111 IN OUT EFI_HANDLE *RootBridgeHandle
112 );
113
114 /**
115
116 Returns the attributes of a PCI Root Bridge.
117
118 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
119 @param RootBridgeHandle - The device handle of the PCI Root Bridge
120 that the caller is interested in
121 @param Attributes - The pointer to attributes of the PCI Root Bridge
122
123 @retval EFI_SUCCESS - Succeed.
124 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
125 @retval RootBridgeHandle is not an EFI_HANDLE
126 @retval that was returned on a previous call to
127 @retval GetNextRootBridge().
128
129 **/
130 EFI_STATUS
131 EFIAPI
132 GetAttributes (
133 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
134 IN EFI_HANDLE RootBridgeHandle,
135 OUT UINT64 *Attributes
136 );
137
138 /**
139
140 This is the request from the PCI enumerator to set up
141 the specified PCI Root Bridge for bus enumeration process.
142
143 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
144 @param RootBridgeHandle - The PCI Root Bridge to be set up.
145 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
146
147 @retval EFI_SUCCESS - Succeed.
148 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
149 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
150
151 **/
152 EFI_STATUS
153 EFIAPI
154 StartBusEnumeration (
155 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
156 IN EFI_HANDLE RootBridgeHandle,
157 OUT VOID **Configuration
158 );
159
160 /**
161
162 This function programs the PCI Root Bridge hardware so that
163 it decodes the specified PCI bus range.
164
165 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
166 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
167 @param Configuration - The pointer to the PCI bus resource descriptor.
168
169 @retval EFI_SUCCESS - Succeed.
170 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
171
172 **/
173 EFI_STATUS
174 EFIAPI
175 SetBusNumbers (
176 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
177 IN EFI_HANDLE RootBridgeHandle,
178 IN VOID *Configuration
179 );
180
181 /**
182
183 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
184
185 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
186 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
187 are being submitted
188 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
189
190 @retval EFI_SUCCESS - Succeed.
191 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
192
193 **/
194 EFI_STATUS
195 EFIAPI
196 SubmitResources (
197 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
198 IN EFI_HANDLE RootBridgeHandle,
199 IN VOID *Configuration
200 );
201
202 /**
203
204 This function returns the proposed resource settings for the specified
205 PCI Root Bridge.
206
207 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
208 @param RootBridgeHandle - The PCI Root Bridge handle.
209 @param Configuration - The pointer to the pointer to the PCI I/O
210 and memory resource descriptor.
211
212 @retval EFI_SUCCESS - Succeed.
213 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
214 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
215
216 **/
217 EFI_STATUS
218 EFIAPI
219 GetProposedResources (
220 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
221 IN EFI_HANDLE RootBridgeHandle,
222 OUT VOID **Configuration
223 );
224
225 /**
226
227 This function is called for all the PCI controllers that the PCI
228 bus driver finds. Can be used to Preprogram the controller.
229
230 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
231 @param RootBridgeHandle - The PCI Root Bridge handle.
232 @param PciAddress - Address of the controller on the PCI bus.
233 @param Phase - The Phase during resource allocation.
234
235 @retval EFI_SUCCESS - Succeed.
236 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
237
238 **/
239 EFI_STATUS
240 EFIAPI
241 PreprocessController (
242 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
243 IN EFI_HANDLE RootBridgeHandle,
244 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
245 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
246 );
247
248 /**
249 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
250
251 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
252 **/
253 VOID
254 ResourceConflict (
255 IN PCI_HOST_BRIDGE_INSTANCE *HostBridge
256 );
257
258 /**
259 This routine gets translation offset from a root bridge instance by resource type.
260
261 @param RootBridge The Root Bridge Instance for the resources.
262 @param ResourceType The Resource Type of the translation offset.
263
264 @retval The Translation Offset of the specified resource.
265 **/
266 UINT64
267 GetTranslationByResourceType (
268 IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge,
269 IN PCI_RESOURCE_TYPE ResourceType
270 );
271
272 extern EFI_CPU_IO2_PROTOCOL *mCpuIo;
273 extern EDKII_IOMMU_PROTOCOL *mIoMmu;
274
275 #endif