]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
MdeModulePkg/PciHostBridgeDxe: Add support for address translation
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciHostBridge.h
CommitLineData
4a50cf4e
RN
1/** @file\r
2\r
3 The Header file of the Pci Host Bridge Driver.\r
4\r
5Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _PCI_HOST_BRIDGE_H_\r
17#define _PCI_HOST_BRIDGE_H_\r
18\r
19\r
20#include <PiDxe.h>\r
21#include <IndustryStandard/Acpi.h>\r
22#include <Library/UefiDriverEntryPoint.h>\r
23#include <Library/MemoryAllocationLib.h>\r
24#include <Library/PciHostBridgeLib.h>\r
25#include <Protocol/PciHostBridgeResourceAllocation.h>\r
26\r
27#include "PciRootBridge.h"\r
28\r
29#define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')\r
30typedef struct {\r
31 UINTN Signature;\r
32 EFI_HANDLE Handle;\r
33 LIST_ENTRY RootBridges;\r
34 BOOLEAN CanRestarted;\r
35 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;\r
36} PCI_HOST_BRIDGE_INSTANCE;\r
37\r
38#define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)\r
39\r
74d0a339
HG
40//\r
41// Macros to translate device address to host address and vice versa. According\r
42// to UEFI 2.7, device address = host address + translation offset.\r
43//\r
44#define TO_HOST_ADDRESS(DeviceAddress,TranslationOffset) ((DeviceAddress) - (TranslationOffset))\r
45#define TO_DEVICE_ADDRESS(HostAddress,TranslationOffset) ((HostAddress) + (TranslationOffset))\r
46\r
4a50cf4e
RN
47//\r
48// Driver Entry Point\r
49//\r
50/**\r
51\r
52 Entry point of this driver.\r
53\r
54 @param ImageHandle - Image handle of this driver.\r
55 @param SystemTable - Pointer to standard EFI system table.\r
56\r
57 @retval EFI_SUCCESS - Succeed.\r
58 @retval EFI_DEVICE_ERROR - Fail to install PCI_ROOT_BRIDGE_IO protocol.\r
59\r
60**/\r
61EFI_STATUS\r
62EFIAPI\r
63InitializePciHostBridge (\r
64 IN EFI_HANDLE ImageHandle,\r
65 IN EFI_SYSTEM_TABLE *SystemTable\r
66 );\r
67\r
68//\r
69// HostBridge Resource Allocation interface\r
70//\r
71/**\r
72\r
73 Enter a certain phase of the PCI enumeration process.\r
74\r
63b90643
RN
75 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r
76 @param Phase The phase during enumeration.\r
4a50cf4e 77\r
63b90643
RN
78 @retval EFI_SUCCESS Succeed.\r
79 @retval EFI_INVALID_PARAMETER Wrong phase parameter passed in.\r
80 @retval EFI_NOT_READY Resources have not been submitted yet.\r
4a50cf4e
RN
81\r
82**/\r
83EFI_STATUS\r
84EFIAPI\r
85NotifyPhase (\r
86 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
87 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase\r
88 );\r
89\r
90/**\r
91\r
92 Return the device handle of the next PCI root bridge that is associated with\r
93 this Host Bridge.\r
94\r
63b90643
RN
95 @param This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
96 @param RootBridgeHandle Returns the device handle of the next PCI Root Bridge.\r
97 On input, it holds the RootBridgeHandle returned by the most\r
98 recent call to GetNextRootBridge().The handle for the first\r
99 PCI Root Bridge is returned if RootBridgeHandle is NULL on input.\r
4a50cf4e 100\r
63b90643
RN
101 @retval EFI_SUCCESS Succeed.\r
102 @retval EFI_NOT_FOUND Next PCI root bridge not found.\r
103 @retval EFI_INVALID_PARAMETER Wrong parameter passed in.\r
4a50cf4e
RN
104\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108GetNextRootBridge (\r
109 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
110 IN OUT EFI_HANDLE *RootBridgeHandle\r
111 );\r
112\r
113/**\r
114\r
115 Returns the attributes of a PCI Root Bridge.\r
116\r
117 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
118 @param RootBridgeHandle - The device handle of the PCI Root Bridge\r
119 that the caller is interested in\r
120 @param Attributes - The pointer to attributes of the PCI Root Bridge\r
121\r
122 @retval EFI_SUCCESS - Succeed.\r
123 @retval EFI_INVALID_PARAMETER - Attributes parameter passed in is NULL or\r
124 @retval RootBridgeHandle is not an EFI_HANDLE\r
125 @retval that was returned on a previous call to\r
126 @retval GetNextRootBridge().\r
127\r
128**/\r
129EFI_STATUS\r
130EFIAPI\r
131GetAttributes (\r
132 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
133 IN EFI_HANDLE RootBridgeHandle,\r
134 OUT UINT64 *Attributes\r
135 );\r
136\r
137/**\r
138\r
139 This is the request from the PCI enumerator to set up\r
140 the specified PCI Root Bridge for bus enumeration process.\r
141\r
142 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
143 @param RootBridgeHandle - The PCI Root Bridge to be set up.\r
144 @param Configuration - Pointer to the pointer to the PCI bus resource descriptor.\r
145\r
146 @retval EFI_SUCCESS - Succeed.\r
147 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.\r
148 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.\r
149\r
150**/\r
151EFI_STATUS\r
152EFIAPI\r
153StartBusEnumeration (\r
154 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
155 IN EFI_HANDLE RootBridgeHandle,\r
156 OUT VOID **Configuration\r
157 );\r
158\r
159/**\r
160\r
161 This function programs the PCI Root Bridge hardware so that\r
162 it decodes the specified PCI bus range.\r
163\r
164 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
165 @param RootBridgeHandle - The PCI Root Bridge whose bus range is to be programmed.\r
166 @param Configuration - The pointer to the PCI bus resource descriptor.\r
167\r
168 @retval EFI_SUCCESS - Succeed.\r
169 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.\r
170\r
171**/\r
172EFI_STATUS\r
173EFIAPI\r
174SetBusNumbers (\r
175 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
176 IN EFI_HANDLE RootBridgeHandle,\r
177 IN VOID *Configuration\r
178 );\r
179\r
180/**\r
181\r
182 Submits the I/O and memory resource requirements for the specified PCI Root Bridge.\r
183\r
184 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
185 @param RootBridgeHandle - The PCI Root Bridge whose I/O and memory resource requirements\r
186 are being submitted\r
187 @param Configuration - The pointer to the PCI I/O and PCI memory resource descriptor\r
188\r
189 @retval EFI_SUCCESS - Succeed.\r
190 @retval EFI_INVALID_PARAMETER - Wrong parameters passed in.\r
191\r
192**/\r
193EFI_STATUS\r
194EFIAPI\r
195SubmitResources (\r
196 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
197 IN EFI_HANDLE RootBridgeHandle,\r
198 IN VOID *Configuration\r
199 );\r
200\r
201/**\r
202\r
203 This function returns the proposed resource settings for the specified\r
204 PCI Root Bridge.\r
205\r
206 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
207 @param RootBridgeHandle - The PCI Root Bridge handle.\r
208 @param Configuration - The pointer to the pointer to the PCI I/O\r
209 and memory resource descriptor.\r
210\r
211 @retval EFI_SUCCESS - Succeed.\r
212 @retval EFI_OUT_OF_RESOURCES - Not enough pool to be allocated.\r
213 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.\r
214\r
215**/\r
216EFI_STATUS\r
217EFIAPI\r
218GetProposedResources (\r
219 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
220 IN EFI_HANDLE RootBridgeHandle,\r
221 OUT VOID **Configuration\r
222 );\r
223\r
224/**\r
225\r
226 This function is called for all the PCI controllers that the PCI\r
227 bus driver finds. Can be used to Preprogram the controller.\r
228\r
229 @param This - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
230 @param RootBridgeHandle - The PCI Root Bridge handle.\r
231 @param PciAddress - Address of the controller on the PCI bus.\r
232 @param Phase - The Phase during resource allocation.\r
233\r
234 @retval EFI_SUCCESS - Succeed.\r
235 @retval EFI_INVALID_PARAMETER - RootBridgeHandle is not a valid handle.\r
236\r
237**/\r
238EFI_STATUS\r
239EFIAPI\r
240PreprocessController (\r
241 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
242 IN EFI_HANDLE RootBridgeHandle,\r
243 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,\r
244 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase\r
245 );\r
246\r
247/**\r
248 This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().\r
249\r
250 @param HostBridge The Host Bridge Instance where the resource adjustment happens.\r
251**/\r
252VOID\r
253ResourceConflict (\r
254 IN PCI_HOST_BRIDGE_INSTANCE *HostBridge\r
255 );\r
256\r
74d0a339
HG
257/**\r
258 This routine gets translation offset from a root bridge instance by resource type.\r
259\r
260 @param RootBridge The Root Bridge Instance for the resources.\r
261 @param ResourceType The Resource Type of the translation offset.\r
262\r
263 @retval The Translation Offset of the specified resource.\r
264**/\r
265UINT64\r
266GetTranslationByResourceType (\r
267 IN PCI_ROOT_BRIDGE_INSTANCE *RootBridge,\r
268 IN PCI_RESOURCE_TYPE ResourceType\r
269 );\r
270\r
4a50cf4e
RN
271extern EFI_METRONOME_ARCH_PROTOCOL *mMetronome;\r
272extern EFI_CPU_IO2_PROTOCOL *mCpuIo;\r
273#endif\r