]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkPlatformPkg/Pci/Dxe/PciHostBridge/PciHostBridge.h
QuarkPlatformPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkPlatformPkg / Pci / Dxe / PciHostBridge / PciHostBridge.h
1 /** @file
2 The Header file of the Pci Host Bridge Driver.
3
4 Copyright (c) 2013-2015 Intel Corporation.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8
9 **/
10
11 #ifndef _PCI_HOST_BRIDGE_H_
12 #define _PCI_HOST_BRIDGE_H_
13
14
15 #include <PiDxe.h>
16 #include <IndustryStandard/Acpi.h>
17 #include <IndustryStandard/Pci.h>
18 #include <PciRootBridge.h>
19 #include <Library/UefiDriverEntryPoint.h>
20 #include <IndustryStandard/Pci22.h>
21 #include <Library/UefiLib.h>
22 #include <Guid/HobList.h>
23 #include <Library/UefiRuntimeServicesTableLib.h>
24 #include <Protocol/PciHostBridgeResourceAllocation.h>
25
26 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('e', 'h', 's', 't')
27 typedef struct {
28 UINTN Signature;
29 EFI_HANDLE HostBridgeHandle;
30 UINTN RootBridgeCount;
31 EFI_LIST_ENTRY Head;
32 BOOLEAN ResourceSubmited;
33 BOOLEAN CanRestarted;
34 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;
35 } PCI_HOST_BRIDGE_INSTANCE;
36
37 #define INSTANCE_FROM_RESOURCE_ALLOCATION_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
38
39 typedef enum {
40 SocketResourceRatioChanged,
41 SocketResourceRatioNotChanged,
42 SocketResourceAdjustMax
43 } SOCKET_RESOURCE_ADJUSTMENT_RESULT;
44
45 //
46 // Driver Entry Point
47 //
48 EFI_STATUS
49 EFIAPI
50 InitializePciHostBridge (
51 IN EFI_HANDLE ImageHandle,
52 IN EFI_SYSTEM_TABLE *SystemTable
53 )
54 /*++
55
56 Routine Description:
57
58 Entry point of this driver.
59
60 Arguments:
61
62 ImageHandle - Image handle of this driver.
63 SystemTable - Pointer to standard EFI system table.
64
65 Returns:
66
67 EFI_SUCCESS - Succeed.
68 EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
69
70 --*/
71 ;
72
73 //
74 // HostBridge Resource Allocation interface
75 //
76 EFI_STATUS
77 EFIAPI
78 NotifyPhase (
79 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
80 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
81 )
82 /*++
83
84 Routine Description:
85
86 Enter a certain phase of the PCI enumeration process.
87
88 Arguments:
89
90 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
91 Phase - The phase during enumeration.
92
93 Returns:
94
95 EFI_SUCCESS - Succeed.
96 EFI_INVALID_PARAMETER - Wrong phase parameter passed in.
97 EFI_NOT_READY - Resources have not been submitted yet.
98
99 --*/
100 ;
101
102 EFI_STATUS
103 EFIAPI
104 GetNextRootBridge (
105 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
106 IN OUT EFI_HANDLE *RootBridgeHandle
107 )
108 /*++
109
110 Routine Description:
111
112 Return the device handle of the next PCI root bridge that is associated with
113 this Host Bridge.
114
115 Arguments:
116
117 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
118 RootBridgeHandle - Returns the device handle of the next PCI Root Bridge.
119 On input, it holds the RootBridgeHandle returned by the most
120 recent call to GetNextRootBridge().The handle for the first
121 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
122
123 Returns:
124
125 EFI_SUCCESS - Succeed.
126 EFI_NOT_FOUND - Next PCI root bridge not found.
127 EFI_INVALID_PARAMETER - Wrong parameter passed in.
128
129 --*/
130 ;
131
132 EFI_STATUS
133 EFIAPI
134 GetAttributes (
135 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
136 IN EFI_HANDLE RootBridgeHandle,
137 OUT UINT64 *Attributes
138 )
139 /*++
140
141 Routine Description:
142
143 Returns the attributes of a PCI Root Bridge.
144
145 Arguments:
146
147 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
148 RootBridgeHandle - The device handle of the PCI Root Bridge
149 that the caller is interested in
150 Attributes - The pointer to attributes of the PCI Root Bridge
151
152 Returns:
153
154 EFI_SUCCESS - Succeed.
155 EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
156 RootBridgeHandle is not an EFI_HANDLE
157 that was returned on a previous call to
158 GetNextRootBridge().
159
160 --*/
161 ;
162
163 EFI_STATUS
164 EFIAPI
165 StartBusEnumeration (
166 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
167 IN EFI_HANDLE RootBridgeHandle,
168 OUT VOID **Configuration
169 )
170 /*++
171
172 Routine Description:
173
174 This is the request from the PCI enumerator to set up
175 the specified PCI Root Bridge for bus enumeration process.
176
177 Arguments:
178
179 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
180 RootBridgeHandle - The PCI Root Bridge to be set up.
181 Configuration - Pointer to the pointer to the PCI bus resource descriptor.
182
183 Returns:
184
185 EFI_SUCCESS - Succeed.
186 EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
187 EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
188
189 --*/
190 ;
191
192 EFI_STATUS
193 EFIAPI
194 SetBusNumbers (
195 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
196 IN EFI_HANDLE RootBridgeHandle,
197 IN VOID *Configuration
198 )
199 /*++
200
201 Routine Description:
202
203 This function programs the PCI Root Bridge hardware so that
204 it decodes the specified PCI bus range.
205
206 Arguments:
207
208 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
209 RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
210 Configuration - The pointer to the PCI bus resource descriptor.
211
212 Returns:
213
214 EFI_SUCCESS - Succeed.
215 EFI_INVALID_PARAMETER - Wrong parameters passed in.
216
217 --*/
218 ;
219
220 EFI_STATUS
221 EFIAPI
222 SubmitResources (
223 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
224 IN EFI_HANDLE RootBridgeHandle,
225 IN VOID *Configuration
226 )
227 /*++
228
229 Routine Description:
230
231 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
232
233 Arguments:
234
235 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
236 RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
237 are being submitted
238 Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
239
240 Returns:
241
242 EFI_SUCCESS - Succeed.
243 EFI_INVALID_PARAMETER - Wrong parameters passed in.
244
245 --*/
246 ;
247
248 EFI_STATUS
249 EFIAPI
250 GetProposedResources (
251 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
252 IN EFI_HANDLE RootBridgeHandle,
253 OUT VOID **Configuration
254 )
255 /*++
256
257 Routine Description:
258
259 This function returns the proposed resource settings for the specified
260 PCI Root Bridge.
261
262 Arguments:
263
264 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
265 RootBridgeHandle - The PCI Root Bridge handle.
266 Configuration - The pointer to the pointer to the PCI I/O
267 and memory resource descriptor.
268
269 Returns:
270
271 EFI_SUCCESS - Succeed.
272 EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
273 EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
274
275 --*/
276 ;
277
278 EFI_STATUS
279 EFIAPI
280 PreprocessController (
281 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
282 IN EFI_HANDLE RootBridgeHandle,
283 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
284 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
285 )
286 /*++
287
288 Routine Description:
289
290 This function is called for all the PCI controllers that the PCI
291 bus driver finds. Can be used to Preprogram the controller.
292
293 Arguments:
294
295 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
296 RootBridgeHandle - The PCI Root Bridge handle.
297 PciAddress - Address of the controller on the PCI bus.
298 Phase - The Phase during resource allocation.
299
300 Returns:
301
302 EFI_SUCCESS - Succeed.
303 EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
304
305 --*/
306 ;
307
308 //
309 // Host Bridge Silicon specific hooks
310 //
311 UINT64
312 GetAllocAttributes (
313 IN UINTN RootBridgeIndex
314 )
315 /*++
316
317 Routine Description:
318
319 Returns the Allocation attributes for the BNB Root Bridge.
320
321 Arguments:
322
323 RootBridgeIndex - The root bridge number. 0 based.
324
325 Returns:
326
327 EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE
328
329 --*/
330 ;
331
332 EFI_STATUS
333 GetHostBridgeMemApertures (
334 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
335 OUT UINT32 *Mem32Base,
336 OUT UINT32 *Mem32Limit,
337 OUT UINT64 *Mem64Base,
338 OUT UINT64 *Mem64Limit
339 )
340 /*++
341
342 Routine Description:
343
344 Returns memory apertures for the BNB Root Bridge.
345
346 Arguments:
347
348 PciRootBridgeIo - Pointer to Efi Pci root bridge Io protocol interface instance.
349 Mem32Base - Pointer to 32 bit memory base. This is the lowest 32 bit memory address
350 that is decoded by the Host Bridge.
351 Mem32Limit - Pointer to 32 bit memory limit.This is the highest 32 bit memory address
352 that is decoded by the Host Bridge. The size of the 32 bit window is
353 (Mem32Limit - Mem32base + 1).
354 Mem64Base - Pointer to 64 bit memory base. This is the lowest 64 bit memory address
355 that is decoded by the Host Bridge.
356 Mem64Limit - Pointer to 64 bit memory limit.This is the highest 64 bit memory address
357 that is decoded by the Host Bridge. The size of the 64 bit window is
358 (Mem64Limit - Mem64base + 1). Set Mem64Limit < Mem64Base if the host bridge
359 does not support 64 bit memory addresses.
360
361 Returns:
362
363 EFI_SUCCESS - Success.
364
365 --*/
366 ;
367
368 UINT64
369 Power2MaxMemory (
370 IN UINT64 MemoryLength
371 )
372 /*++
373
374 Routine Description:
375
376 Calculate maximum memory length that can be fit to a mtrr.
377
378 Arguments:
379
380 MemoryLength - Input memory length.
381
382 Returns:
383
384 Returned Maximum length.
385
386 --*/
387 ;
388
389 #endif