]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
MdeModulePkg/PciHostBridge: Add IOMMU support.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciHostBridge.h
1 /** @file
2
3 The Header file of the Pci Host Bridge Driver.
4
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
10
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.
13
14 **/
15
16 #ifndef _PCI_HOST_BRIDGE_H_
17 #define _PCI_HOST_BRIDGE_H_
18
19
20 #include <PiDxe.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
27 #include "PciRootBridge.h"
28
29 #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')
30 typedef struct {
31 UINTN Signature;
32 EFI_HANDLE Handle;
33 LIST_ENTRY RootBridges;
34 BOOLEAN CanRestarted;
35 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;
36 } PCI_HOST_BRIDGE_INSTANCE;
37
38 #define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)
39
40 //
41 // Driver Entry Point
42 //
43 /**
44
45 Entry point of this driver.
46
47 @param ImageHandle - Image handle of this driver.
48 @param SystemTable - Pointer to standard EFI system table.
49
50 @retval EFI_SUCCESS - Succeed.
51 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.
52
53 **/
54 EFI_STATUS
55 EFIAPI
56 InitializePciHostBridge (
57 IN EFI_HANDLE ImageHandle,
58 IN EFI_SYSTEM_TABLE *SystemTable
59 );
60
61 //
62 // HostBridge Resource Allocation interface
63 //
64 /**
65
66 Enter a certain phase of the PCI enumeration process.
67
68 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
69 @param Phase The phase during enumeration.
70
71 @retval EFI_SUCCESS Succeed.
72 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.
73 @retval EFI_NOT_READY Resources have not been submitted yet.
74
75 **/
76 EFI_STATUS
77 EFIAPI
78 NotifyPhase (
79 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
80 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
81 );
82
83 /**
84
85 Return the device handle of the next PCI root bridge that is associated with
86 this Host Bridge.
87
88 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
89 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.
90 On input, it holds the RootBridgeHandle returned by the most
91 recent call to GetNextRootBridge().The handle for the first
92 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.
93
94 @retval EFI_SUCCESS Succeed.
95 @retval EFI_NOT_FOUND Next PCI root bridge not found.
96 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.
97
98 **/
99 EFI_STATUS
100 EFIAPI
101 GetNextRootBridge (
102 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
103 IN OUT EFI_HANDLE *RootBridgeHandle
104 );
105
106 /**
107
108 Returns the attributes of a PCI Root Bridge.
109
110 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
111 @param RootBridgeHandle - The device handle of the PCI Root Bridge
112 that the caller is interested in
113 @param Attributes - The pointer to attributes of the PCI Root Bridge
114
115 @retval EFI_SUCCESS - Succeed.
116 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or
117 @retval RootBridgeHandle is not an EFI_HANDLE
118 @retval that was returned on a previous call to
119 @retval GetNextRootBridge().
120
121 **/
122 EFI_STATUS
123 EFIAPI
124 GetAttributes (
125 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
126 IN EFI_HANDLE RootBridgeHandle,
127 OUT UINT64 *Attributes
128 );
129
130 /**
131
132 This is the request from the PCI enumerator to set up
133 the specified PCI Root Bridge for bus enumeration process.
134
135 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
136 @param RootBridgeHandle - The PCI Root Bridge to be set up.
137 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.
138
139 @retval EFI_SUCCESS - Succeed.
140 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
141 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
142
143 **/
144 EFI_STATUS
145 EFIAPI
146 StartBusEnumeration (
147 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
148 IN EFI_HANDLE RootBridgeHandle,
149 OUT VOID **Configuration
150 );
151
152 /**
153
154 This function programs the PCI Root Bridge hardware so that
155 it decodes the specified PCI bus range.
156
157 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
158 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.
159 @param Configuration - The pointer to the PCI bus resource descriptor.
160
161 @retval EFI_SUCCESS - Succeed.
162 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
163
164 **/
165 EFI_STATUS
166 EFIAPI
167 SetBusNumbers (
168 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
169 IN EFI_HANDLE RootBridgeHandle,
170 IN VOID *Configuration
171 );
172
173 /**
174
175 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.
176
177 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
178 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements
179 are being submitted
180 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor
181
182 @retval EFI_SUCCESS - Succeed.
183 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.
184
185 **/
186 EFI_STATUS
187 EFIAPI
188 SubmitResources (
189 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
190 IN EFI_HANDLE RootBridgeHandle,
191 IN VOID *Configuration
192 );
193
194 /**
195
196 This function returns the proposed resource settings for the specified
197 PCI Root Bridge.
198
199 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
200 @param RootBridgeHandle - The PCI Root Bridge handle.
201 @param Configuration - The pointer to the pointer to the PCI I/O
202 and memory resource descriptor.
203
204 @retval EFI_SUCCESS - Succeed.
205 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.
206 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
207
208 **/
209 EFI_STATUS
210 EFIAPI
211 GetProposedResources (
212 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
213 IN EFI_HANDLE RootBridgeHandle,
214 OUT VOID **Configuration
215 );
216
217 /**
218
219 This function is called for all the PCI controllers that the PCI
220 bus driver finds. Can be used to Preprogram the controller.
221
222 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.
223 @param RootBridgeHandle - The PCI Root Bridge handle.
224 @param PciAddress - Address of the controller on the PCI bus.
225 @param Phase - The Phase during resource allocation.
226
227 @retval EFI_SUCCESS - Succeed.
228 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.
229
230 **/
231 EFI_STATUS
232 EFIAPI
233 PreprocessController (
234 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
235 IN EFI_HANDLE RootBridgeHandle,
236 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
237 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
238 );
239
240 /**
241 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().
242
243 @param HostBridge The Host Bridge Instance where the resource adjustment happens.
244 **/
245 VOID
246 ResourceConflict (
247 IN PCI_HOST_BRIDGE_INSTANCE *HostBridge
248 );
249
250 extern EFI_METRONOME_ARCH_PROTOCOL *mMetronome;
251 extern EFI_CPU_IO2_PROTOCOL *mCpuIo;
252 #endif