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