2 The Header file of the Pci Host Bridge Driver.
4 Copyright (c) 2013-2015 Intel Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef _PCI_HOST_BRIDGE_H_
12 #define _PCI_HOST_BRIDGE_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>
26 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('e', 'h', 's', 't')
29 EFI_HANDLE HostBridgeHandle
;
30 UINTN RootBridgeCount
;
32 BOOLEAN ResourceSubmited
;
34 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
35 } PCI_HOST_BRIDGE_INSTANCE
;
37 #define INSTANCE_FROM_RESOURCE_ALLOCATION_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
40 SocketResourceRatioChanged
,
41 SocketResourceRatioNotChanged
,
42 SocketResourceAdjustMax
43 } SOCKET_RESOURCE_ADJUSTMENT_RESULT
;
50 InitializePciHostBridge (
51 IN EFI_HANDLE ImageHandle
,
52 IN EFI_SYSTEM_TABLE
*SystemTable
58 Entry point of this driver.
62 ImageHandle - Image handle of this driver.
63 SystemTable - Pointer to standard EFI system table.
67 EFI_SUCCESS - Succeed.
68 EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
74 // HostBridge Resource Allocation interface
79 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
80 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
86 Enter a certain phase of the PCI enumeration process.
90 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
91 Phase - The phase during enumeration.
95 EFI_SUCCESS - Succeed.
96 EFI_INVALID_PARAMETER - Wrong phase parameter passed in.
97 EFI_NOT_READY - Resources have not been submitted yet.
105 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
106 IN OUT EFI_HANDLE
*RootBridgeHandle
112 Return the device handle of the next PCI root bridge that is associated with
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.
125 EFI_SUCCESS - Succeed.
126 EFI_NOT_FOUND - Next PCI root bridge not found.
127 EFI_INVALID_PARAMETER - Wrong parameter passed in.
135 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
136 IN EFI_HANDLE RootBridgeHandle
,
137 OUT UINT64
*Attributes
143 Returns the attributes of a PCI Root Bridge.
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
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
165 StartBusEnumeration (
166 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
167 IN EFI_HANDLE RootBridgeHandle
,
168 OUT VOID
**Configuration
174 This is the request from the PCI enumerator to set up
175 the specified PCI Root Bridge for bus enumeration process.
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.
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.
195 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
196 IN EFI_HANDLE RootBridgeHandle
,
197 IN VOID
*Configuration
203 This function programs the PCI Root Bridge hardware so that
204 it decodes the specified PCI bus range.
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.
214 EFI_SUCCESS - Succeed.
215 EFI_INVALID_PARAMETER - Wrong parameters passed in.
223 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
224 IN EFI_HANDLE RootBridgeHandle
,
225 IN VOID
*Configuration
231 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
235 This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
236 RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
238 Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
242 EFI_SUCCESS - Succeed.
243 EFI_INVALID_PARAMETER - Wrong parameters passed in.
250 GetProposedResources (
251 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
252 IN EFI_HANDLE RootBridgeHandle
,
253 OUT VOID
**Configuration
259 This function returns the proposed resource settings for the specified
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.
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.
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
290 This function is called for all the PCI controllers that the PCI
291 bus driver finds. Can be used to Preprogram the controller.
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.
302 EFI_SUCCESS - Succeed.
303 EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
309 // Host Bridge Silicon specific hooks
313 IN UINTN RootBridgeIndex
319 Returns the Allocation attributes for the BNB Root Bridge.
323 RootBridgeIndex - The root bridge number. 0 based.
327 EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM | EFI_PCI_HOST_BRIDGE_MEM64_DECODE
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
344 Returns memory apertures for the BNB Root Bridge.
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.
363 EFI_SUCCESS - Success.
370 IN UINT64 MemoryLength
376 Calculate maximum memory length that can be fit to a mtrr.
380 MemoryLength - Input memory length.
384 Returned Maximum length.