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