]>
Commit | Line | Data |
---|---|---|
9595e3cd | 1 | /** @file\r |
d1c561f9 | 2 | The Header file of the Pci Host Bridge Driver\r |
9595e3cd LE |
3 | \r |
4 | Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are\r | |
6 | licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
d1c561f9 | 9 | \r |
9595e3cd LE |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
d1c561f9 | 13 | **/\r |
9595e3cd LE |
14 | \r |
15 | #ifndef _PCI_HOST_BRIDGE_H_\r | |
16 | #define _PCI_HOST_BRIDGE_H_\r | |
17 | \r | |
18 | #include <PiDxe.h>\r | |
19 | \r | |
20 | #include <IndustryStandard/Pci.h>\r | |
21 | #include <IndustryStandard/Acpi.h>\r | |
22 | \r | |
23 | #include <Protocol/PciHostBridgeResourceAllocation.h>\r | |
24 | #include <Protocol/PciRootBridgeIo.h>\r | |
25 | #include <Protocol/Metronome.h>\r | |
26 | #include <Protocol/DevicePath.h>\r | |
cd2178bb | 27 | #include <Protocol/FdtClient.h>\r |
9595e3cd LE |
28 | \r |
29 | \r | |
30 | #include <Library/BaseLib.h>\r | |
31 | #include <Library/DebugLib.h>\r | |
32 | #include <Library/BaseMemoryLib.h>\r | |
33 | #include <Library/MemoryAllocationLib.h>\r | |
34 | #include <Library/UefiLib.h>\r | |
35 | #include <Library/UefiBootServicesTableLib.h>\r | |
36 | #include <Library/DxeServicesTableLib.h>\r | |
37 | #include <Library/DevicePathLib.h>\r | |
38 | #include <Library/IoLib.h>\r | |
39 | #include <Library/PciLib.h>\r | |
aca7e8b6 | 40 | #include <Library/PcdLib.h>\r |
9595e3cd LE |
41 | \r |
42 | //\r | |
43 | // Hard code the host bridge number in the platform.\r | |
44 | // In this chipset, there is only one host bridge.\r | |
45 | //\r | |
46 | #define HOST_BRIDGE_NUMBER 1\r | |
47 | \r | |
48 | #define MAX_PCI_DEVICE_NUMBER 31\r | |
49 | #define MAX_PCI_FUNCTION_NUMBER 7\r | |
e1ec934c | 50 | #define MAX_PCI_REG_ADDRESS (SIZE_4KB - 1)\r |
9595e3cd LE |
51 | \r |
52 | typedef enum {\r | |
53 | IoOperation,\r | |
54 | MemOperation,\r | |
55 | PciOperation\r | |
56 | } OPERATION_TYPE;\r | |
57 | \r | |
58 | #define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32('e', 'h', 's', 't')\r | |
59 | typedef struct {\r | |
60 | UINTN Signature;\r | |
61 | EFI_HANDLE HostBridgeHandle;\r | |
62 | UINTN RootBridgeNumber;\r | |
63 | LIST_ENTRY Head;\r | |
d1c561f9 OM |
64 | BOOLEAN ResourceSubmited;\r |
65 | BOOLEAN CanRestarted;\r | |
9595e3cd LE |
66 | EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL ResAlloc;\r |
67 | } PCI_HOST_BRIDGE_INSTANCE;\r | |
68 | \r | |
69 | #define INSTANCE_FROM_RESOURCE_ALLOCATION_THIS(a) \\r | |
70 | CR(a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)\r | |
d1c561f9 | 71 | \r |
9595e3cd LE |
72 | //\r |
73 | // HostBridge Resource Allocation interface\r | |
74 | //\r | |
75 | \r | |
76 | /**\r | |
77 | These are the notifications from the PCI bus driver that it is about to enter a certain\r | |
78 | phase of the PCI enumeration process.\r | |
79 | \r | |
80 | This member function can be used to notify the host bridge driver to perform specific actions,\r | |
81 | including any chipset-specific initialization, so that the chipset is ready to enter the next phase.\r | |
82 | Eight notification points are defined at this time. See belows:\r | |
83 | EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures and internal data\r | |
84 | structures. The PCI enumerator should issue this notification\r | |
85 | before starting a fresh enumeration process. Enumeration cannot\r | |
86 | be restarted after sending any other notification such as\r | |
87 | EfiPciHostBridgeBeginBusAllocation.\r | |
88 | EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to begin. No specific action is\r | |
89 | required here. This notification can be used to perform any\r | |
90 | chipset-specific programming.\r | |
91 | EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming phase is complete. No\r | |
92 | specific action is required here. This notification can be used to\r | |
93 | perform any chipset-specific programming.\r | |
94 | EfiPciHostBridgeBeginResourceAllocation\r | |
95 | The resource allocation phase is about to begin. No specific\r | |
96 | action is required here. This notification can be used to perform\r | |
97 | any chipset-specific programming.\r | |
98 | EfiPciHostBridgeAllocateResources Allocates resources per previously submitted requests for all the PCI\r | |
99 | root bridges. These resource settings are returned on the next call to\r | |
100 | GetProposedResources(). Before calling NotifyPhase() with a Phase of\r | |
101 | EfiPciHostBridgeAllocateResource, the PCI bus enumerator is responsible\r | |
102 | for gathering I/O and memory requests for\r | |
103 | all the PCI root bridges and submitting these requests using\r | |
104 | SubmitResources(). This function pads the resource amount\r | |
105 | to suit the root bridge hardware, takes care of dependencies between\r | |
106 | the PCI root bridges, and calls the Global Coherency Domain (GCD)\r | |
107 | with the allocation request. In the case of padding, the allocated range\r | |
108 | could be bigger than what was requested.\r | |
109 | EfiPciHostBridgeSetResources Programs the host bridge hardware to decode previously allocated\r | |
110 | resources (proposed resources) for all the PCI root bridges. After the\r | |
111 | hardware is programmed, reassigning resources will not be supported.\r | |
112 | The bus settings are not affected.\r | |
113 | EfiPciHostBridgeFreeResources Deallocates resources that were previously allocated for all the PCI\r | |
114 | root bridges and resets the I/O and memory apertures to their initial\r | |
115 | state. The bus settings are not affected. If the request to allocate\r | |
116 | resources fails, the PCI enumerator can use this notification to\r | |
117 | deallocate previous resources, adjust the requests, and retry\r | |
118 | allocation.\r | |
119 | EfiPciHostBridgeEndResourceAllocation The resource allocation phase is completed. No specific action is\r | |
120 | required here. This notification can be used to perform any chipsetspecific\r | |
121 | programming.\r | |
122 | \r | |
123 | @param[in] This The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r | |
124 | @param[in] Phase The phase during enumeration\r | |
125 | \r | |
126 | @retval EFI_NOT_READY This phase cannot be entered at this time. For example, this error\r | |
127 | is valid for a Phase of EfiPciHostBridgeAllocateResources if\r | |
128 | SubmitResources() has not been called for one or more\r | |
129 | PCI root bridges before this call\r | |
130 | @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. This error is valid\r | |
131 | for a Phase of EfiPciHostBridgeSetResources.\r | |
132 | @retval EFI_INVALID_PARAMETER Invalid phase parameter\r | |
133 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
134 | This error is valid for a Phase of EfiPciHostBridgeAllocateResources if the\r | |
135 | previously submitted resource requests cannot be fulfilled or\r | |
136 | were only partially fulfilled.\r | |
137 | @retval EFI_SUCCESS The notification was accepted without any errors.\r | |
138 | \r | |
139 | **/\r | |
140 | EFI_STATUS\r | |
141 | EFIAPI\r | |
142 | NotifyPhase(\r | |
143 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
144 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase\r | |
145 | );\r | |
146 | \r | |
147 | /**\r | |
148 | Return the device handle of the next PCI root bridge that is associated with this Host Bridge.\r | |
149 | \r | |
150 | This function is called multiple times to retrieve the device handles of all the PCI root bridges that\r | |
151 | are associated with this PCI host bridge. Each PCI host bridge is associated with one or more PCI\r | |
152 | root bridges. On each call, the handle that was returned by the previous call is passed into the\r | |
153 | interface, and on output the interface returns the device handle of the next PCI root bridge. The\r | |
154 | caller can use the handle to obtain the instance of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL\r | |
155 | for that root bridge. When there are no more PCI root bridges to report, the interface returns\r | |
156 | EFI_NOT_FOUND. A PCI enumerator must enumerate the PCI root bridges in the order that they\r | |
157 | are returned by this function.\r | |
158 | For D945 implementation, there is only one root bridge in PCI host bridge.\r | |
159 | \r | |
160 | @param[in] This The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r | |
161 | @param[in, out] RootBridgeHandle Returns the device handle of the next PCI root bridge.\r | |
d1c561f9 | 162 | \r |
9595e3cd | 163 | @retval EFI_SUCCESS If parameter RootBridgeHandle = NULL, then return the first Rootbridge handle of the\r |
d1c561f9 | 164 | specific Host bridge and return EFI_SUCCESS.\r |
9595e3cd LE |
165 | @retval EFI_NOT_FOUND Can not find the any more root bridge in specific host bridge.\r |
166 | @retval EFI_INVALID_PARAMETER RootBridgeHandle is not an EFI_HANDLE that was\r | |
167 | returned on a previous call to GetNextRootBridge().\r | |
168 | **/\r | |
169 | EFI_STATUS\r | |
170 | EFIAPI\r | |
171 | GetNextRootBridge(\r | |
172 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
173 | IN OUT EFI_HANDLE *RootBridgeHandle\r | |
174 | );\r | |
d1c561f9 | 175 | \r |
9595e3cd LE |
176 | /**\r |
177 | Returns the allocation attributes of a PCI root bridge.\r | |
178 | \r | |
179 | The function returns the allocation attributes of a specific PCI root bridge. The attributes can vary\r | |
180 | from one PCI root bridge to another. These attributes are different from the decode-related\r | |
181 | attributes that are returned by the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.GetAttributes() member function. The\r | |
182 | RootBridgeHandle parameter is used to specify the instance of the PCI root bridge. The device\r | |
183 | handles of all the root bridges that are associated with this host bridge must be obtained by calling\r | |
184 | GetNextRootBridge(). The attributes are static in the sense that they do not change during or\r | |
185 | after the enumeration process. The hardware may provide mechanisms to change the attributes on\r | |
d1c561f9 | 186 | the fly, but such changes must be completed before EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL is\r |
9595e3cd LE |
187 | installed. The permitted values of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES are defined in\r |
188 | "Related Definitions" below. The caller uses these attributes to combine multiple resource requests.\r | |
d1c561f9 OM |
189 | For example, if the flag EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM is set, the PCI bus enumerator needs to\r |
190 | include requests for the prefetchable memory in the nonprefetchable memory pool and not request any\r | |
9595e3cd LE |
191 | prefetchable memory.\r |
192 | Attribute Description\r | |
193 | ------------------------------------ ----------------------------------------------------------------------\r | |
194 | EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM If this bit is set, then the PCI root bridge does not support separate\r | |
195 | windows for nonprefetchable and prefetchable memory. A PCI bus\r | |
196 | driver needs to include requests for prefetchable memory in the\r | |
197 | nonprefetchable memory pool.\r | |
198 | \r | |
199 | EFI_PCI_HOST_BRIDGE_MEM64_DECODE If this bit is set, then the PCI root bridge supports 64-bit memory\r | |
200 | windows. If this bit is not set, the PCI bus driver needs to include\r | |
201 | requests for a 64-bit memory address in the corresponding 32-bit\r | |
202 | memory pool.\r | |
203 | \r | |
204 | @param[in] This The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r | |
205 | @param[in] RootBridgeHandle The device handle of the PCI root bridge in which the caller is interested. Type\r | |
206 | EFI_HANDLE is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r | |
207 | @param[out] Attributes The pointer to attribte of root bridge, it is output parameter\r | |
d1c561f9 | 208 | \r |
9595e3cd LE |
209 | @retval EFI_INVALID_PARAMETER Attribute pointer is NULL\r |
210 | @retval EFI_INVALID_PARAMETER RootBridgehandle is invalid.\r | |
211 | @retval EFI_SUCCESS Success to get attribute of interested root bridge.\r | |
212 | \r | |
d1c561f9 | 213 | **/\r |
9595e3cd LE |
214 | EFI_STATUS\r |
215 | EFIAPI\r | |
216 | GetAttributes(\r | |
217 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
218 | IN EFI_HANDLE RootBridgeHandle,\r | |
219 | OUT UINT64 *Attributes\r | |
220 | );\r | |
d1c561f9 | 221 | \r |
9595e3cd LE |
222 | /**\r |
223 | Sets up the specified PCI root bridge for the bus enumeration process.\r | |
224 | \r | |
225 | This member function sets up the root bridge for bus enumeration and returns the PCI bus range\r | |
226 | over which the search should be performed in ACPI 2.0 resource descriptor format.\r | |
227 | \r | |
228 | @param[in] This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r | |
229 | @param[in] RootBridgeHandle The PCI Root Bridge to be set up.\r | |
230 | @param[out] Configuration Pointer to the pointer to the PCI bus resource descriptor.\r | |
d1c561f9 | 231 | \r |
9595e3cd LE |
232 | @retval EFI_INVALID_PARAMETER Invalid Root bridge's handle\r |
233 | @retval EFI_OUT_OF_RESOURCES Fail to allocate ACPI resource descriptor tag.\r | |
234 | @retval EFI_SUCCESS Sucess to allocate ACPI resource descriptor.\r | |
235 | \r | |
236 | **/\r | |
237 | EFI_STATUS\r | |
238 | EFIAPI\r | |
239 | StartBusEnumeration(\r | |
240 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
241 | IN EFI_HANDLE RootBridgeHandle,\r | |
242 | OUT VOID **Configuration\r | |
243 | );\r | |
d1c561f9 | 244 | \r |
9595e3cd LE |
245 | /**\r |
246 | Programs the PCI root bridge hardware so that it decodes the specified PCI bus range.\r | |
247 | \r | |
248 | This member function programs the specified PCI root bridge to decode the bus range that is\r | |
249 | specified by the input parameter Configuration.\r | |
250 | The bus range information is specified in terms of the ACPI 2.0 resource descriptor format.\r | |
251 | \r | |
252 | @param[in] This The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r | |
253 | @param[in] RootBridgeHandle The PCI Root Bridge whose bus range is to be programmed\r | |
254 | @param[in] Configuration The pointer to the PCI bus resource descriptor\r | |
d1c561f9 | 255 | \r |
9595e3cd LE |
256 | @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.\r |
257 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
258 | @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI 2.0 resource descriptor.\r | |
259 | @retval EFI_INVALID_PARAMETER Configuration does not include a valid ACPI 2.0 bus resource descriptor.\r | |
d1c561f9 | 260 | @retval EFI_INVALID_PARAMETER Configuration includes valid ACPI 2.0 resource descriptors other than\r |
9595e3cd LE |
261 | bus descriptors.\r |
262 | @retval EFI_INVALID_PARAMETER Configuration contains one or more invalid ACPI resource descriptors.\r | |
263 | @retval EFI_INVALID_PARAMETER "Address Range Minimum" is invalid for this root bridge.\r | |
264 | @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this root bridge.\r | |
265 | @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.\r | |
266 | @retval EFI_SUCCESS The bus range for the PCI root bridge was programmed.\r | |
267 | \r | |
268 | **/\r | |
269 | EFI_STATUS\r | |
270 | EFIAPI\r | |
271 | SetBusNumbers(\r | |
272 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
273 | IN EFI_HANDLE RootBridgeHandle,\r | |
274 | IN VOID *Configuration\r | |
275 | );\r | |
d1c561f9 | 276 | \r |
9595e3cd LE |
277 | /**\r |
278 | Submits the I/O and memory resource requirements for the specified PCI root bridge.\r | |
279 | \r | |
280 | This function is used to submit all the I/O and memory resources that are required by the specified\r | |
281 | PCI root bridge. The input parameter Configuration is used to specify the following:\r | |
282 | - The various types of resources that are required\r | |
283 | - The associated lengths in terms of ACPI 2.0 resource descriptor format\r | |
284 | \r | |
285 | @param[in] This Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r | |
286 | @param[in] RootBridgeHandle The PCI root bridge whose I/O and memory resource requirements are being submitted.\r | |
287 | @param[in] Configuration The pointer to the PCI I/O and PCI memory resource descriptor.\r | |
d1c561f9 | 288 | \r |
9595e3cd LE |
289 | @retval EFI_SUCCESS The I/O and memory resource requests for a PCI root bridge were accepted.\r |
290 | @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.\r | |
291 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
292 | @retval EFI_INVALID_PARAMETER Configuration does not point to a valid ACPI 2.0 resource descriptor.\r | |
d1c561f9 OM |
293 | @retval EFI_INVALID_PARAMETER Configuration includes requests for one or more resource types that are\r |
294 | not supported by this PCI root bridge. This error will happen if the caller\r | |
9595e3cd LE |
295 | did not combine resources according to Attributes that were returned by\r |
296 | GetAllocAttributes().\r | |
297 | @retval EFI_INVALID_PARAMETER Address Range Maximum" is invalid.\r | |
298 | @retval EFI_INVALID_PARAMETER "Address Range Length" is invalid for this PCI root bridge.\r | |
299 | @retval EFI_INVALID_PARAMETER "Address Space Granularity" is invalid for this PCI root bridge.\r | |
300 | \r | |
301 | **/\r | |
302 | EFI_STATUS\r | |
303 | EFIAPI\r | |
304 | SubmitResources(\r | |
305 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
306 | IN EFI_HANDLE RootBridgeHandle,\r | |
307 | IN VOID *Configuration\r | |
308 | );\r | |
d1c561f9 | 309 | \r |
9595e3cd LE |
310 | /**\r |
311 | Returns the proposed resource settings for the specified PCI root bridge.\r | |
312 | \r | |
313 | This member function returns the proposed resource settings for the specified PCI root bridge. The\r | |
314 | proposed resource settings are prepared when NotifyPhase() is called with a Phase of\r | |
315 | EfiPciHostBridgeAllocateResources. The output parameter Configuration\r | |
316 | specifies the following:\r | |
317 | - The various types of resources, excluding bus resources, that are allocated\r | |
318 | - The associated lengths in terms of ACPI 2.0 resource descriptor format\r | |
319 | \r | |
320 | @param[in] This Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r | |
321 | @param[in] RootBridgeHandle The PCI root bridge handle. Type EFI_HANDLE is defined in InstallProtocolInterface() in the UEFI 2.0 Specification.\r | |
322 | @param[out] Configuration The pointer to the pointer to the PCI I/O and memory resource descriptor.\r | |
d1c561f9 | 323 | \r |
9595e3cd LE |
324 | @retval EFI_SUCCESS The requested parameters were returned.\r |
325 | @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.\r | |
326 | @retval EFI_DEVICE_ERROR Programming failed due to a hardware error.\r | |
327 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
328 | \r | |
329 | **/\r | |
330 | EFI_STATUS\r | |
331 | EFIAPI\r | |
332 | GetProposedResources(\r | |
333 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
334 | IN EFI_HANDLE RootBridgeHandle,\r | |
335 | OUT VOID **Configuration\r | |
336 | );\r | |
337 | \r | |
338 | /**\r | |
339 | Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various\r | |
340 | stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual\r | |
341 | PCI controllers before enumeration.\r | |
342 | \r | |
343 | This function is called during the PCI enumeration process. No specific action is expected from this\r | |
344 | member function. It allows the host bridge driver to preinitialize individual PCI controllers before\r | |
345 | enumeration.\r | |
346 | \r | |
347 | @param This Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r | |
348 | @param RootBridgeHandle The associated PCI root bridge handle. Type EFI_HANDLE is defined in\r | |
349 | InstallProtocolInterface() in the UEFI 2.0 Specification.\r | |
350 | @param PciAddress The address of the PCI device on the PCI bus. This address can be passed to the\r | |
351 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL member functions to access the PCI\r | |
352 | configuration space of the device. See Table 12-1 in the UEFI 2.0 Specification for\r | |
353 | the definition of EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS.\r | |
d1c561f9 OM |
354 | @param Phase The phase of the PCI device enumeration.\r |
355 | \r | |
9595e3cd LE |
356 | @retval EFI_SUCCESS The requested parameters were returned.\r |
357 | @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.\r | |
358 | @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined in\r | |
359 | EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.\r | |
360 | @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. The PCI enumerator should\r | |
361 | not enumerate this device, including its child devices if it is a PCI-to-PCI\r | |
362 | bridge.\r | |
363 | \r | |
364 | **/\r | |
365 | EFI_STATUS\r | |
366 | EFIAPI\r | |
367 | PreprocessController (\r | |
368 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r | |
369 | IN EFI_HANDLE RootBridgeHandle,\r | |
370 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,\r | |
371 | IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase\r | |
372 | );\r | |
373 | \r | |
374 | \r | |
375 | //\r | |
d1c561f9 | 376 | // Define resource status constant\r |
9595e3cd LE |
377 | //\r |
378 | #define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL\r | |
379 | #define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL\r | |
380 | \r | |
381 | \r | |
382 | //\r | |
383 | // Driver Instance Data Prototypes\r | |
384 | //\r | |
385 | \r | |
386 | typedef struct {\r | |
387 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation;\r | |
388 | UINTN NumberOfBytes;\r | |
389 | UINTN NumberOfPages;\r | |
390 | EFI_PHYSICAL_ADDRESS HostAddress;\r | |
391 | EFI_PHYSICAL_ADDRESS MappedHostAddress;\r | |
392 | } MAP_INFO;\r | |
393 | \r | |
394 | typedef struct {\r | |
395 | ACPI_HID_DEVICE_PATH AcpiDevicePath;\r | |
396 | EFI_DEVICE_PATH_PROTOCOL EndDevicePath;\r | |
397 | } EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;\r | |
398 | \r | |
399 | typedef struct {\r | |
400 | UINT64 BusBase;\r | |
d1c561f9 OM |
401 | UINT64 BusLimit;\r |
402 | \r | |
403 | UINT64 MemBase;\r | |
404 | UINT64 MemLimit;\r | |
405 | \r | |
406 | UINT64 IoBase;\r | |
407 | UINT64 IoLimit;\r | |
aca7e8b6 | 408 | UINT64 IoTranslation;\r |
9595e3cd LE |
409 | } PCI_ROOT_BRIDGE_RESOURCE_APERTURE;\r |
410 | \r | |
411 | typedef enum {\r | |
412 | TypeIo = 0,\r | |
413 | TypeMem32,\r | |
414 | TypePMem32,\r | |
415 | TypeMem64,\r | |
416 | TypePMem64,\r | |
417 | TypeBus,\r | |
418 | TypeMax\r | |
419 | } PCI_RESOURCE_TYPE;\r | |
420 | \r | |
421 | typedef enum {\r | |
422 | ResNone = 0,\r | |
423 | ResSubmitted,\r | |
424 | ResRequested,\r | |
425 | ResAllocated,\r | |
426 | ResStatusMax\r | |
427 | } RES_STATUS;\r | |
428 | \r | |
429 | typedef struct {\r | |
430 | PCI_RESOURCE_TYPE Type;\r | |
431 | UINT64 Base;\r | |
432 | UINT64 Length;\r | |
433 | UINT64 Alignment;\r | |
434 | RES_STATUS Status;\r | |
435 | } PCI_RES_NODE;\r | |
436 | \r | |
437 | #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32('e', '2', 'p', 'b')\r | |
438 | \r | |
439 | typedef struct {\r | |
440 | UINT32 Signature;\r | |
441 | LIST_ENTRY Link;\r | |
442 | EFI_HANDLE Handle;\r | |
443 | UINT64 RootBridgeAttrib;\r | |
444 | UINT64 Attributes;\r | |
445 | UINT64 Supports;\r | |
d1c561f9 | 446 | \r |
9595e3cd LE |
447 | //\r |
448 | // Specific for this memory controller: Bus, I/O, Mem\r | |
449 | //\r | |
450 | PCI_RES_NODE ResAllocNode[6];\r | |
d1c561f9 | 451 | \r |
9595e3cd LE |
452 | //\r |
453 | // Addressing for Memory and I/O and Bus arrange\r | |
454 | //\r | |
455 | UINT64 BusBase;\r | |
d1c561f9 OM |
456 | UINT64 MemBase;\r |
457 | UINT64 IoBase;\r | |
458 | UINT64 BusLimit;\r | |
459 | UINT64 MemLimit;\r | |
460 | UINT64 IoLimit;\r | |
1275aaf4 | 461 | UINT64 IoTranslation;\r |
9595e3cd LE |
462 | \r |
463 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
464 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io;\r | |
465 | \r | |
466 | } PCI_ROOT_BRIDGE_INSTANCE;\r | |
467 | \r | |
468 | \r | |
469 | //\r | |
470 | // Driver Instance Data Macros\r | |
471 | //\r | |
472 | #define DRIVER_INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) \\r | |
473 | CR(a, PCI_ROOT_BRIDGE_INSTANCE, Io, PCI_ROOT_BRIDGE_SIGNATURE)\r | |
474 | \r | |
475 | \r | |
476 | #define DRIVER_INSTANCE_FROM_LIST_ENTRY(a) \\r | |
477 | CR(a, PCI_ROOT_BRIDGE_INSTANCE, Link, PCI_ROOT_BRIDGE_SIGNATURE)\r | |
478 | \r | |
479 | /**\r | |
480 | \r | |
481 | Construct the Pci Root Bridge Io protocol\r | |
482 | \r | |
483 | @param Protocol Point to protocol instance\r | |
484 | @param HostBridgeHandle Handle of host bridge\r | |
485 | @param Attri Attribute of host bridge\r | |
486 | @param ResAperture ResourceAperture for host bridge\r | |
487 | \r | |
488 | @retval EFI_SUCCESS Success to initialize the Pci Root Bridge.\r | |
489 | \r | |
490 | **/\r | |
491 | EFI_STATUS\r | |
492 | RootBridgeConstructor (\r | |
493 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *Protocol,\r | |
494 | IN EFI_HANDLE HostBridgeHandle,\r | |
495 | IN UINT64 Attri,\r | |
496 | IN PCI_ROOT_BRIDGE_RESOURCE_APERTURE *ResAperture\r | |
497 | );\r | |
498 | \r | |
499 | #endif\r |