2 The Header file of the Pci Host Bridge Driver.
4 Copyright (c) 2013-2015 Intel Corporation.
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
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.
17 #ifndef _PCI_HOST_BRIDGE_H_
18 #define _PCI_HOST_BRIDGE_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>
32 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('e', 'h', 's', 't')
35 EFI_HANDLE HostBridgeHandle
;
36 UINTN RootBridgeCount
;
38 BOOLEAN ResourceSubmited
;
40 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
41 } PCI_HOST_BRIDGE_INSTANCE
;
43 #define INSTANCE_FROM_RESOURCE_ALLOCATION_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
46 SocketResourceRatioChanged
,
47 SocketResourceRatioNotChanged
,
48 SocketResourceAdjustMax
49 } SOCKET_RESOURCE_ADJUSTMENT_RESULT
;
56 InitializePciHostBridge (
57 IN EFI_HANDLE ImageHandle
,
58 IN EFI_SYSTEM_TABLE
*SystemTable
64 Entry point of this driver.
68 ImageHandle - Image handle of this driver.
69 SystemTable - Pointer to standard EFI system table.
73 EFI_SUCCESS - Succeed.
74 EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
80 // HostBridge Resource Allocation interface
85 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
86 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
92 Enter a certain phase of the PCI enumeration process.
96 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
97 Phase - The phase during enumeration.
101 EFI_SUCCESS - Succeed.
102 EFI_INVALID_PARAMETER - Wrong phase parameter passed in.
103 EFI_NOT_READY - Resources have not been submitted yet.
111 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
112 IN OUT EFI_HANDLE
*RootBridgeHandle
118 Return the device handle of the next PCI root bridge that is associated with
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.
131 EFI_SUCCESS - Succeed.
132 EFI_NOT_FOUND - Next PCI root bridge not found.
133 EFI_INVALID_PARAMETER - Wrong parameter passed in.
141 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
142 IN EFI_HANDLE RootBridgeHandle
,
143 OUT UINT64
*Attributes
149 Returns the attributes of a PCI Root Bridge.
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
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
171 StartBusEnumeration (
172 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
173 IN EFI_HANDLE RootBridgeHandle
,
174 OUT VOID
**Configuration
180 This is the request from the PCI enumerator to set up
181 the specified PCI Root Bridge for bus enumeration process.
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.
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.
201 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
202 IN EFI_HANDLE RootBridgeHandle
,
203 IN VOID
*Configuration
209 This function programs the PCI Root Bridge hardware so that
210 it decodes the specified PCI bus range.
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.
220 EFI_SUCCESS - Succeed.
221 EFI_INVALID_PARAMETER - Wrong parameters passed in.
229 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
230 IN EFI_HANDLE RootBridgeHandle
,
231 IN VOID
*Configuration
237 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
241 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
242 RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
244 Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
248 EFI_SUCCESS - Succeed.
249 EFI_INVALID_PARAMETER - Wrong parameters passed in.
256 GetProposedResources (
257 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
258 IN EFI_HANDLE RootBridgeHandle
,
259 OUT VOID
**Configuration
265 This function returns the proposed resource settings for the specified
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.
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.
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
296 This function is called for all the PCI controllers that the PCI
297 bus driver finds. Can be used to Preprogram the controller.
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.
308 EFI_SUCCESS - Succeed.
309 EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
315 // Host Bridge Silicon specific hooks
319 IN UINTN RootBridgeIndex
325 Returns the Allocation attributes for the BNB Root Bridge.
329 RootBridgeIndex - The root bridge number. 0 based.
333 EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE
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
350 Returns memory apertures for the BNB Root Bridge.
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.
369 EFI_SUCCESS - Success.
376 IN UINT64 MemoryLength
382 Calculate maximum memory length that can be fit to a mtrr.
386 MemoryLength - Input memory length.
390 Returned Maximum length.