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