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