3 The Header file of the Pci Host Bridge Driver.
5 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef _PCI_HOST_BRIDGE_H_
11 #define _PCI_HOST_BRIDGE_H_
15 #include <IndustryStandard/Acpi.h>
16 #include <Library/UefiDriverEntryPoint.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/PciHostBridgeLib.h>
19 #include <Protocol/PciHostBridgeResourceAllocation.h>
20 #include <Protocol/IoMmu.h>
22 #include "PciRootBridge.h"
24 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
28 LIST_ENTRY RootBridges
;
30 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
31 } PCI_HOST_BRIDGE_INSTANCE
;
33 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
36 // Macros to translate device address to host address and vice versa. According
37 // to UEFI 2.7, device address = host address + translation offset.
39 #define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) - (TranslationOffset))
40 #define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + (TranslationOffset))
47 Entry point of this driver.
49 @param ImageHandle - Image handle of this driver.
50 @param SystemTable - Pointer to standard EFI system table.
52 @retval EFI_SUCCESS - Succeed.
53 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
58 InitializePciHostBridge (
59 IN EFI_HANDLE ImageHandle
,
60 IN EFI_SYSTEM_TABLE
*SystemTable
64 // HostBridge Resource Allocation interface
68 Enter a certain phase of the PCI enumeration process.
70 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
71 @param Phase The phase during enumeration.
73 @retval EFI_SUCCESS Succeed.
74 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
75 @retval EFI_NOT_READY Resources have not been submitted yet.
81 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
82 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
87 Return the device handle of the next PCI root bridge that is associated with
90 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
91 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
92 On input, it holds the RootBridgeHandle returned by the most
93 recent call to GetNextRootBridge().The handle for the first
94 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
96 @retval EFI_SUCCESS Succeed.
97 @retval EFI_NOT_FOUND Next PCI root bridge not found.
98 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
104 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
105 IN OUT EFI_HANDLE
*RootBridgeHandle
110 Returns the attributes of a PCI Root Bridge.
112 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
113 @param RootBridgeHandle - The device handle of the PCI Root Bridge
114 that the caller is interested in
115 @param Attributes - The pointer to attributes of the PCI Root Bridge
117 @retval EFI_SUCCESS - Succeed.
118 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
119 @retval RootBridgeHandle is not an EFI_HANDLE
120 @retval that was returned on a previous call to
121 @retval GetNextRootBridge().
127 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
128 IN EFI_HANDLE RootBridgeHandle
,
129 OUT UINT64
*Attributes
134 This is the request from the PCI enumerator to set up
135 the specified PCI Root Bridge for bus enumeration process.
137 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
138 @param RootBridgeHandle - The PCI Root Bridge to be set up.
139 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
141 @retval EFI_SUCCESS - Succeed.
142 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
143 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
148 StartBusEnumeration (
149 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
150 IN EFI_HANDLE RootBridgeHandle
,
151 OUT VOID
**Configuration
156 This function programs the PCI Root Bridge hardware so that
157 it decodes the specified PCI bus range.
159 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
160 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
161 @param Configuration - The pointer to the PCI bus resource descriptor.
163 @retval EFI_SUCCESS - Succeed.
164 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
170 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
171 IN EFI_HANDLE RootBridgeHandle
,
172 IN VOID
*Configuration
177 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
179 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
180 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
182 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
184 @retval EFI_SUCCESS - Succeed.
185 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
191 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
192 IN EFI_HANDLE RootBridgeHandle
,
193 IN VOID
*Configuration
198 This function returns the proposed resource settings for the specified
201 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
202 @param RootBridgeHandle - The PCI Root Bridge handle.
203 @param Configuration - The pointer to the pointer to the PCI I/O
204 and memory resource descriptor.
206 @retval EFI_SUCCESS - Succeed.
207 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
208 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
213 GetProposedResources (
214 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
215 IN EFI_HANDLE RootBridgeHandle
,
216 OUT VOID
**Configuration
221 This function is called for all the PCI controllers that the PCI
222 bus driver finds. Can be used to Preprogram the controller.
224 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
225 @param RootBridgeHandle - The PCI Root Bridge handle.
226 @param PciAddress - Address of the controller on the PCI bus.
227 @param Phase - The Phase during resource allocation.
229 @retval EFI_SUCCESS - Succeed.
230 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
235 PreprocessController (
236 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
237 IN EFI_HANDLE RootBridgeHandle
,
238 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
239 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
243 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
245 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
249 IN PCI_HOST_BRIDGE_INSTANCE
*HostBridge
253 This routine gets translation offset from a root bridge instance by resource type.
255 @param RootBridge The Root Bridge Instance for the resources.
256 @param ResourceType The Resource Type of the translation offset.
258 @retval The Translation Offset of the specified resource.
261 GetTranslationByResourceType (
262 IN PCI_ROOT_BRIDGE_INSTANCE
*RootBridge
,
263 IN PCI_RESOURCE_TYPE ResourceType
266 extern EFI_CPU_IO2_PROTOCOL
*mCpuIo
;
267 extern EDKII_IOMMU_PROTOCOL
*mIoMmu
;