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