3 The Header file of the Pci Host Bridge Driver.
5 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.<BR>
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.
16 #ifndef _PCI_HOST_BRIDGE_H_
17 #define _PCI_HOST_BRIDGE_H_
21 #include <IndustryStandard/Acpi.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/PciHostBridgeLib.h>
25 #include <Protocol/PciHostBridgeResourceAllocation.h>
26 #include <Protocol/IoMmu.h>
28 #include "PciRootBridge.h"
30 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
34 LIST_ENTRY RootBridges
;
36 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
37 } PCI_HOST_BRIDGE_INSTANCE
;
39 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
42 // Macros to translate device address to host address and vice versa. According
43 // to UEFI 2.7, device address = host address + translation offset.
45 #define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) - (TranslationOffset))
46 #define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + (TranslationOffset))
53 Entry point of this driver.
55 @param ImageHandle - Image handle of this driver.
56 @param SystemTable - Pointer to standard EFI system table.
58 @retval EFI_SUCCESS - Succeed.
59 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
64 InitializePciHostBridge (
65 IN EFI_HANDLE ImageHandle
,
66 IN EFI_SYSTEM_TABLE
*SystemTable
70 // HostBridge Resource Allocation interface
74 Enter a certain phase of the PCI enumeration process.
76 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
77 @param Phase The phase during enumeration.
79 @retval EFI_SUCCESS Succeed.
80 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
81 @retval EFI_NOT_READY Resources have not been submitted yet.
87 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
88 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
93 Return the device handle of the next PCI root bridge that is associated with
96 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
97 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
98 On input, it holds the RootBridgeHandle returned by the most
99 recent call to GetNextRootBridge().The handle for the first
100 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
102 @retval EFI_SUCCESS Succeed.
103 @retval EFI_NOT_FOUND Next PCI root bridge not found.
104 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
110 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
111 IN OUT EFI_HANDLE
*RootBridgeHandle
116 Returns the attributes of a PCI Root Bridge.
118 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
119 @param RootBridgeHandle - The device handle of the PCI Root Bridge
120 that the caller is interested in
121 @param Attributes - The pointer to attributes of the PCI Root Bridge
123 @retval EFI_SUCCESS - Succeed.
124 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
125 @retval RootBridgeHandle is not an EFI_HANDLE
126 @retval that was returned on a previous call to
127 @retval GetNextRootBridge().
133 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
134 IN EFI_HANDLE RootBridgeHandle
,
135 OUT UINT64
*Attributes
140 This is the request from the PCI enumerator to set up
141 the specified PCI Root Bridge for bus enumeration process.
143 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
144 @param RootBridgeHandle - The PCI Root Bridge to be set up.
145 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
147 @retval EFI_SUCCESS - Succeed.
148 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
149 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
154 StartBusEnumeration (
155 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
156 IN EFI_HANDLE RootBridgeHandle
,
157 OUT VOID
**Configuration
162 This function programs the PCI Root Bridge hardware so that
163 it decodes the specified PCI bus range.
165 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
166 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
167 @param Configuration - The pointer to the PCI bus resource descriptor.
169 @retval EFI_SUCCESS - Succeed.
170 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
176 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
177 IN EFI_HANDLE RootBridgeHandle
,
178 IN VOID
*Configuration
183 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
185 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
186 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
188 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
190 @retval EFI_SUCCESS - Succeed.
191 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
197 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
198 IN EFI_HANDLE RootBridgeHandle
,
199 IN VOID
*Configuration
204 This function returns the proposed resource settings for the specified
207 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
208 @param RootBridgeHandle - The PCI Root Bridge handle.
209 @param Configuration - The pointer to the pointer to the PCI I/O
210 and memory resource descriptor.
212 @retval EFI_SUCCESS - Succeed.
213 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
214 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
219 GetProposedResources (
220 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
221 IN EFI_HANDLE RootBridgeHandle
,
222 OUT VOID
**Configuration
227 This function is called for all the PCI controllers that the PCI
228 bus driver finds. Can be used to Preprogram the controller.
230 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
231 @param RootBridgeHandle - The PCI Root Bridge handle.
232 @param PciAddress - Address of the controller on the PCI bus.
233 @param Phase - The Phase during resource allocation.
235 @retval EFI_SUCCESS - Succeed.
236 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
241 PreprocessController (
242 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
243 IN EFI_HANDLE RootBridgeHandle
,
244 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
245 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
249 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
251 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
255 IN PCI_HOST_BRIDGE_INSTANCE
*HostBridge
259 This routine gets translation offset from a root bridge instance by resource type.
261 @param RootBridge The Root Bridge Instance for the resources.
262 @param ResourceType The Resource Type of the translation offset.
264 @retval The Translation Offset of the specified resource.
267 GetTranslationByResourceType (
268 IN PCI_ROOT_BRIDGE_INSTANCE
*RootBridge
,
269 IN PCI_RESOURCE_TYPE ResourceType
272 extern EFI_CPU_IO2_PROTOCOL
*mCpuIo
;
273 extern EDKII_IOMMU_PROTOCOL
*mIoMmu
;