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_
14 #include <IndustryStandard/Acpi.h>
15 #include <Library/UefiDriverEntryPoint.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/PciHostBridgeLib.h>
18 #include <Protocol/PciHostBridgeResourceAllocation.h>
19 #include <Protocol/IoMmu.h>
21 #include "PciRootBridge.h"
23 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
27 LIST_ENTRY RootBridges
;
29 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
30 } PCI_HOST_BRIDGE_INSTANCE
;
32 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
35 // Macros to translate device address to host address and vice versa. According
36 // to UEFI 2.7, device address = host address + translation offset.
38 #define TO_HOST_ADDRESS(DeviceAddress, TranslationOffset) ((DeviceAddress) - (TranslationOffset))
39 #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
69 Enter a certain phase of the PCI enumeration process.
71 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
72 @param Phase The phase during enumeration.
74 @retval EFI_SUCCESS Succeed.
75 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
76 @retval EFI_NOT_READY Resources have not been submitted yet.
82 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
83 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
88 Return the device handle of the next PCI root bridge that is associated with
91 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
92 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
93 On input, it holds the RootBridgeHandle returned by the most
94 recent call to GetNextRootBridge().The handle for the first
95 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
97 @retval EFI_SUCCESS Succeed.
98 @retval EFI_NOT_FOUND Next PCI root bridge not found.
99 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
105 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
106 IN OUT EFI_HANDLE
*RootBridgeHandle
111 Returns the attributes of a PCI Root Bridge.
113 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
114 @param RootBridgeHandle - The device handle of the PCI Root Bridge
115 that the caller is interested in
116 @param Attributes - The pointer to attributes of the PCI Root Bridge
118 @retval EFI_SUCCESS - Succeed.
119 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
120 @retval RootBridgeHandle is not an EFI_HANDLE
121 @retval that was returned on a previous call to
122 @retval GetNextRootBridge().
128 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
129 IN EFI_HANDLE RootBridgeHandle
,
130 OUT UINT64
*Attributes
135 This is the request from the PCI enumerator to set up
136 the specified PCI Root Bridge for bus enumeration process.
138 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
139 @param RootBridgeHandle - The PCI Root Bridge to be set up.
140 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
142 @retval EFI_SUCCESS - Succeed.
143 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
144 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
149 StartBusEnumeration (
150 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
151 IN EFI_HANDLE RootBridgeHandle
,
152 OUT VOID
**Configuration
157 This function programs the PCI Root Bridge hardware so that
158 it decodes the specified PCI bus range.
160 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
161 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
162 @param Configuration - The pointer to the PCI bus resource descriptor.
164 @retval EFI_SUCCESS - Succeed.
165 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
171 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
172 IN EFI_HANDLE RootBridgeHandle
,
173 IN VOID
*Configuration
178 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
180 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
181 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
183 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
185 @retval EFI_SUCCESS - Succeed.
186 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
192 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
193 IN EFI_HANDLE RootBridgeHandle
,
194 IN VOID
*Configuration
199 This function returns the proposed resource settings for the specified
202 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
203 @param RootBridgeHandle - The PCI Root Bridge handle.
204 @param Configuration - The pointer to the pointer to the PCI I/O
205 and memory resource descriptor.
207 @retval EFI_SUCCESS - Succeed.
208 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
209 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
214 GetProposedResources (
215 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
216 IN EFI_HANDLE RootBridgeHandle
,
217 OUT VOID
**Configuration
222 This function is called for all the PCI controllers that the PCI
223 bus driver finds. Can be used to Preprogram the controller.
225 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
226 @param RootBridgeHandle - The PCI Root Bridge handle.
227 @param PciAddress - Address of the controller on the PCI bus.
228 @param Phase - The Phase during resource allocation.
230 @retval EFI_SUCCESS - Succeed.
231 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
236 PreprocessController (
237 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
238 IN EFI_HANDLE RootBridgeHandle
,
239 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
240 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
244 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
246 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
250 IN PCI_HOST_BRIDGE_INSTANCE
*HostBridge
254 This routine gets translation offset from a root bridge instance by resource type.
256 @param RootBridge The Root Bridge Instance for the resources.
257 @param ResourceType The Resource Type of the translation offset.
259 @retval The Translation Offset of the specified resource.
262 GetTranslationByResourceType (
263 IN PCI_ROOT_BRIDGE_INSTANCE
*RootBridge
,
264 IN PCI_RESOURCE_TYPE ResourceType
267 extern EFI_CPU_IO2_PROTOCOL
*mCpuIo
;
268 extern EDKII_IOMMU_PROTOCOL
*mIoMmu
;