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