3 The Header file of the Pci Host Bridge Driver.
5 Copyright (c) 1999 - 2016, 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>
27 #include "PciRootBridge.h"
29 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
33 LIST_ENTRY RootBridges
;
35 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc
;
36 } PCI_HOST_BRIDGE_INSTANCE
;
38 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
41 // Macros to translate device address to host address and vice versa. According
42 // to UEFI 2.7, device address = host address + translation offset.
44 #define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) - (TranslationOffset))
45 #define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + (TranslationOffset))
52 Entry point of this driver.
54 @param ImageHandle - Image handle of this driver.
55 @param SystemTable - Pointer to standard EFI system table.
57 @retval EFI_SUCCESS - Succeed.
58 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
63 InitializePciHostBridge (
64 IN EFI_HANDLE ImageHandle
,
65 IN EFI_SYSTEM_TABLE
*SystemTable
69 // HostBridge Resource Allocation interface
73 Enter a certain phase of the PCI enumeration process.
75 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
76 @param Phase The phase during enumeration.
78 @retval EFI_SUCCESS Succeed.
79 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
80 @retval EFI_NOT_READY Resources have not been submitted yet.
86 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
87 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
92 Return the device handle of the next PCI root bridge that is associated with
95 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
96 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
97 On input, it holds the RootBridgeHandle returned by the most
98 recent call to GetNextRootBridge().The handle for the first
99 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
101 @retval EFI_SUCCESS Succeed.
102 @retval EFI_NOT_FOUND Next PCI root bridge not found.
103 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
109 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
110 IN OUT EFI_HANDLE
*RootBridgeHandle
115 Returns the attributes of a PCI Root Bridge.
117 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
118 @param RootBridgeHandle - The device handle of the PCI Root Bridge
119 that the caller is interested in
120 @param Attributes - The pointer to attributes of the PCI Root Bridge
122 @retval EFI_SUCCESS - Succeed.
123 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
124 @retval RootBridgeHandle is not an EFI_HANDLE
125 @retval that was returned on a previous call to
126 @retval GetNextRootBridge().
132 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
133 IN EFI_HANDLE RootBridgeHandle
,
134 OUT UINT64
*Attributes
139 This is the request from the PCI enumerator to set up
140 the specified PCI Root Bridge for bus enumeration process.
142 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
143 @param RootBridgeHandle - The PCI Root Bridge to be set up.
144 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
146 @retval EFI_SUCCESS - Succeed.
147 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
148 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
153 StartBusEnumeration (
154 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
155 IN EFI_HANDLE RootBridgeHandle
,
156 OUT VOID
**Configuration
161 This function programs the PCI Root Bridge hardware so that
162 it decodes the specified PCI bus range.
164 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
165 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
166 @param Configuration - The pointer to the PCI bus resource descriptor.
168 @retval EFI_SUCCESS - Succeed.
169 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
175 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
176 IN EFI_HANDLE RootBridgeHandle
,
177 IN VOID
*Configuration
182 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
184 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
185 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
187 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
189 @retval EFI_SUCCESS - Succeed.
190 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
196 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
197 IN EFI_HANDLE RootBridgeHandle
,
198 IN VOID
*Configuration
203 This function returns the proposed resource settings for the specified
206 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
207 @param RootBridgeHandle - The PCI Root Bridge handle.
208 @param Configuration - The pointer to the pointer to the PCI I/O
209 and memory resource descriptor.
211 @retval EFI_SUCCESS - Succeed.
212 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
213 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
218 GetProposedResources (
219 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
220 IN EFI_HANDLE RootBridgeHandle
,
221 OUT VOID
**Configuration
226 This function is called for all the PCI controllers that the PCI
227 bus driver finds. Can be used to Preprogram the controller.
229 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
230 @param RootBridgeHandle - The PCI Root Bridge handle.
231 @param PciAddress - Address of the controller on the PCI bus.
232 @param Phase - The Phase during resource allocation.
234 @retval EFI_SUCCESS - Succeed.
235 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
240 PreprocessController (
241 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*This
,
242 IN EFI_HANDLE RootBridgeHandle
,
243 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress
,
244 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
248 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
250 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
254 IN PCI_HOST_BRIDGE_INSTANCE
*HostBridge
258 This routine gets translation offset from a root bridge instance by resource type.
260 @param RootBridge The Root Bridge Instance for the resources.
261 @param ResourceType The Resource Type of the translation offset.
263 @retval The Translation Offset of the specified resource.
266 GetTranslationByResourceType (
267 IN PCI_ROOT_BRIDGE_INSTANCE
*RootBridge
,
268 IN PCI_RESOURCE_TYPE ResourceType
271 extern EFI_METRONOME_ARCH_PROTOCOL
*mMetronome
;
272 extern EFI_CPU_IO2_PROTOCOL
*mCpuIo
;