]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciEnumerator.h
CommitLineData
9060e3ec 1/** @file\r
2 PCI bus enumeration logic function declaration for PCI bus module.\r
3\r
cd5ebaa0
HT
4Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
9060e3ec 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _EFI_PCI_ENUMERATOR_H_\r
16#define _EFI_PCI_ENUMERATOR_H_\r
17\r
18#include "PciResourceSupport.h"\r
19\r
20/**\r
21 This routine is used to enumerate entire pci bus system\r
22 in a given platform.\r
23\r
24 @param Controller Parent controller handle.\r
25\r
26 @retval EFI_SUCCESS PCI enumeration finished successfully.\r
27 @retval other Some error occurred when enumerating the pci bus system.\r
28\r
29**/\r
30EFI_STATUS\r
31PciEnumerator (\r
32 IN EFI_HANDLE Controller\r
33 );\r
34\r
35/**\r
36 Enumerate PCI root bridge.\r
37\r
38 @param PciResAlloc Pointer to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.\r
39 @param RootBridgeDev Instance of root bridge device.\r
40\r
41 @retval EFI_SUCCESS Successfully enumerated root bridge.\r
42 @retval other Failed to enumerate root bridge.\r
43\r
44**/\r
45EFI_STATUS\r
46PciRootBridgeEnumerator (\r
47 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc,\r
48 IN PCI_IO_DEVICE *RootBridgeDev\r
49 );\r
50\r
51/**\r
52 This routine is used to process all PCI devices' Option Rom\r
53 on a certain root bridge.\r
54\r
55 @param Bridge Given parent's root bridge.\r
56 @param RomBase Base address of ROM driver loaded from.\r
57 @param MaxLength Maximum rom size.\r
58\r
59**/\r
60VOID\r
61ProcessOptionRom (\r
62 IN PCI_IO_DEVICE *Bridge,\r
63 IN UINT64 RomBase,\r
64 IN UINT64 MaxLength\r
65 );\r
66\r
67/**\r
68 This routine is used to assign bus number to the given PCI bus system\r
69\r
70 @param Bridge Parent root bridge instance.\r
71 @param StartBusNumber Number of beginning.\r
72 @param SubBusNumber The number of sub bus.\r
73\r
74 @retval EFI_SUCCESS Successfully assigned bus number.\r
75 @retval EFI_DEVICE_ERROR Failed to assign bus number.\r
76\r
77**/\r
78EFI_STATUS\r
79PciAssignBusNumber (\r
80 IN PCI_IO_DEVICE *Bridge,\r
81 IN UINT8 StartBusNumber,\r
82 OUT UINT8 *SubBusNumber\r
83 );\r
84\r
85/**\r
86 This routine is used to determine the root bridge attribute by interfacing\r
87 the host bridge resource allocation protocol.\r
88\r
89 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
90 @param RootBridgeDev Root bridge instance\r
91\r
92 @retval EFI_SUCCESS Successfully got root bridge's attribute.\r
93 @retval other Failed to get attribute.\r
94\r
95**/\r
96EFI_STATUS\r
97DetermineRootBridgeAttributes (\r
98 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc,\r
99 IN PCI_IO_DEVICE *RootBridgeDev\r
100 );\r
101\r
102/**\r
103 Get Max Option Rom size on specified bridge.\r
104\r
105 @param Bridge Given bridge device instance.\r
106\r
107 @return Max size of option rom needed.\r
108\r
109**/\r
110UINT64\r
111GetMaxOptionRomSize (\r
112 IN PCI_IO_DEVICE *Bridge\r
113 );\r
114\r
115/**\r
116 Process attributes of devices on this host bridge\r
117\r
118 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.\r
119\r
120 @retval EFI_SUCCESS Successfully process attribute.\r
121 @retval EFI_NOT_FOUND Can not find the specific root bridge device.\r
122 @retval other Failed to determine the root bridge device's attribute.\r
123\r
124**/\r
125EFI_STATUS\r
126PciHostBridgeDeviceAttribute (\r
127 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc\r
128 );\r
129\r
130/**\r
131 Get resource allocation status from the ACPI resource descriptor.\r
132\r
133 @param AcpiConfig Point to Acpi configuration table.\r
134 @param IoResStatus Return the status of I/O resource.\r
135 @param Mem32ResStatus Return the status of 32-bit Memory resource.\r
136 @param PMem32ResStatus Return the status of 32-bit Prefetchable Memory resource.\r
137 @param Mem64ResStatus Return the status of 64-bit Memory resource.\r
138 @param PMem64ResStatus Return the status of 64-bit Prefetchable Memory resource.\r
139\r
140**/\r
141VOID\r
142GetResourceAllocationStatus (\r
143 VOID *AcpiConfig,\r
144 OUT UINT64 *IoResStatus,\r
145 OUT UINT64 *Mem32ResStatus,\r
146 OUT UINT64 *PMem32ResStatus,\r
147 OUT UINT64 *Mem64ResStatus,\r
148 OUT UINT64 *PMem64ResStatus\r
149 );\r
150\r
151/**\r
152 Remove a PCI device from device pool and mark its bar.\r
153\r
154 @param PciDevice Instance of Pci device.\r
155\r
156 @retval EFI_SUCCESS Successfully remove the PCI device.\r
157 @retval EFI_ABORTED Pci device is a root bridge or a PCI-PCI bridge.\r
158\r
159**/\r
160EFI_STATUS\r
161RejectPciDevice (\r
162 IN PCI_IO_DEVICE *PciDevice\r
163 );\r
164\r
165/**\r
166 Determine whethter a PCI device can be rejected.\r
167\r
168 @param PciResNode Pointer to Pci resource node instance.\r
169\r
170 @retval TRUE The PCI device can be rejected.\r
171 @retval TRUE The PCI device cannot be rejected.\r
172\r
173**/\r
174BOOLEAN\r
175IsRejectiveDevice (\r
176 IN PCI_RESOURCE_NODE *PciResNode\r
177 );\r
178\r
179/**\r
180 Compare two resource nodes and get the larger resource consumer.\r
181\r
182 @param PciResNode1 resource node 1 want to be compared\r
183 @param PciResNode2 resource node 2 want to be compared\r
184\r
185 @return Larger resource node.\r
186\r
187**/\r
188PCI_RESOURCE_NODE *\r
189GetLargerConsumerDevice (\r
190 IN PCI_RESOURCE_NODE *PciResNode1,\r
191 IN PCI_RESOURCE_NODE *PciResNode2\r
192 );\r
193\r
194/**\r
195 Get the max resource consumer in the host resource pool.\r
196\r
197 @param ResPool Pointer to resource pool node.\r
198\r
199 @return The max resource consumer in the host resource pool.\r
200\r
201**/\r
202PCI_RESOURCE_NODE *\r
203GetMaxResourceConsumerDevice (\r
204 IN PCI_RESOURCE_NODE *ResPool\r
205 );\r
206\r
207/**\r
208 Adjust host bridge allocation so as to reduce resource requirement\r
209\r
210 @param IoPool Pointer to instance of I/O resource Node.\r
211 @param Mem32Pool Pointer to instance of 32-bit memory resource Node.\r
212 @param PMem32Pool Pointer to instance of 32-bit Prefetchable memory resource node.\r
213 @param Mem64Pool Pointer to instance of 64-bit memory resource node.\r
214 @param PMem64Pool Pointer to instance of 64-bit Prefetchable memory resource node.\r
215 @param IoResStatus Status of I/O resource Node.\r
216 @param Mem32ResStatus Status of 32-bit memory resource Node.\r
217 @param PMem32ResStatus Status of 32-bit Prefetchable memory resource node.\r
218 @param Mem64ResStatus Status of 64-bit memory resource node.\r
219 @param PMem64ResStatus Status of 64-bit Prefetchable memory resource node.\r
220\r
221 @retval EFI_SUCCESS Successfully adjusted resoruce on host bridge.\r
222 @retval EFI_ABORTED Host bridge hasn't this resource type or no resource be adjusted.\r
223\r
224**/\r
225EFI_STATUS\r
226PciHostBridgeAdjustAllocation (\r
227 IN PCI_RESOURCE_NODE *IoPool,\r
228 IN PCI_RESOURCE_NODE *Mem32Pool,\r
229 IN PCI_RESOURCE_NODE *PMem32Pool,\r
230 IN PCI_RESOURCE_NODE *Mem64Pool,\r
231 IN PCI_RESOURCE_NODE *PMem64Pool,\r
232 IN UINT64 IoResStatus,\r
233 IN UINT64 Mem32ResStatus,\r
234 IN UINT64 PMem32ResStatus,\r
235 IN UINT64 Mem64ResStatus,\r
236 IN UINT64 PMem64ResStatus\r
237 );\r
238\r
239/**\r
240 Summary requests for all resource type, and contruct ACPI resource\r
241 requestor instance.\r
242\r
243 @param Bridge detecting bridge\r
244 @param IoNode Pointer to instance of I/O resource Node\r
245 @param Mem32Node Pointer to instance of 32-bit memory resource Node\r
246 @param PMem32Node Pointer to instance of 32-bit Pmemory resource node\r
247 @param Mem64Node Pointer to instance of 64-bit memory resource node\r
248 @param PMem64Node Pointer to instance of 64-bit Pmemory resource node\r
249 @param Config Output buffer holding new constructed APCI resource requestor\r
250\r
251 @retval EFI_SUCCESS Successfully constructed ACPI resource.\r
252 @retval EFI_OUT_OF_RESOURCES No memory availabe.\r
253\r
254**/\r
255EFI_STATUS\r
256ConstructAcpiResourceRequestor (\r
257 IN PCI_IO_DEVICE *Bridge,\r
258 IN PCI_RESOURCE_NODE *IoNode,\r
259 IN PCI_RESOURCE_NODE *Mem32Node,\r
260 IN PCI_RESOURCE_NODE *PMem32Node,\r
261 IN PCI_RESOURCE_NODE *Mem64Node,\r
262 IN PCI_RESOURCE_NODE *PMem64Node,\r
263 OUT VOID **Config\r
264 );\r
265\r
266/**\r
267 Get resource base from an acpi configuration descriptor.\r
268\r
269 @param Config An acpi configuration descriptor.\r
270 @param IoBase Output of I/O resource base address.\r
271 @param Mem32Base Output of 32-bit memory base address.\r
272 @param PMem32Base Output of 32-bit prefetchable memory base address.\r
273 @param Mem64Base Output of 64-bit memory base address.\r
274 @param PMem64Base Output of 64-bit prefetchable memory base address.\r
275\r
276**/\r
277VOID\r
278GetResourceBase (\r
279 IN VOID *Config,\r
280 OUT UINT64 *IoBase,\r
281 OUT UINT64 *Mem32Base,\r
282 OUT UINT64 *PMem32Base,\r
283 OUT UINT64 *Mem64Base,\r
284 OUT UINT64 *PMem64Base\r
285 );\r
286\r
287/**\r
288 Enumerate pci bridge, allocate resource and determine attribute\r
289 for devices on this bridge.\r
290\r
291 @param BridgeDev Pointer to instance of bridge device.\r
292\r
293 @retval EFI_SUCCESS Successfully enumerated PCI bridge.\r
294 @retval other Failed to enumerate.\r
295\r
296**/\r
297EFI_STATUS\r
298PciBridgeEnumerator (\r
299 IN PCI_IO_DEVICE *BridgeDev\r
300 );\r
301\r
302/**\r
303 Allocate all kinds of resource for PCI bridge.\r
304\r
305 @param Bridge Pointer to bridge instance.\r
306\r
307 @retval EFI_SUCCESS Successfully allocated resource for PCI bridge.\r
308 @retval other Failed to allocate resource for bridge.\r
309\r
310**/\r
311EFI_STATUS\r
312PciBridgeResourceAllocator (\r
313 IN PCI_IO_DEVICE *Bridge\r
314 );\r
315\r
316/**\r
317 Get resource base address for a pci bridge device.\r
318\r
319 @param Bridge Given Pci driver instance.\r
320 @param IoBase Output for base address of I/O type resource.\r
321 @param Mem32Base Output for base address of 32-bit memory type resource.\r
322 @param PMem32Base Ooutput for base address of 32-bit Pmemory type resource.\r
323 @param Mem64Base Output for base address of 64-bit memory type resource.\r
324 @param PMem64Base Output for base address of 64-bit Pmemory type resource.\r
325\r
326 @retval EFI_SUCCESS Successfully got resource base address.\r
327 @retval EFI_OUT_OF_RESOURCES PCI bridge is not available.\r
328\r
329**/\r
330EFI_STATUS\r
331GetResourceBaseFromBridge (\r
332 IN PCI_IO_DEVICE *Bridge,\r
333 OUT UINT64 *IoBase,\r
334 OUT UINT64 *Mem32Base,\r
335 OUT UINT64 *PMem32Base,\r
336 OUT UINT64 *Mem64Base,\r
337 OUT UINT64 *PMem64Base\r
338 );\r
339\r
340/**\r
341 Process Option Rom on this host bridge\r
342\r
343 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.\r
344\r
345 @retval EFI_NOT_FOUND Can not find the root bridge instance.\r
346 @retval EFI_SUCCESS Success process.\r
347**/\r
348EFI_STATUS\r
349PciHostBridgeP2CProcess (\r
350 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc\r
351 );\r
352\r
353/**\r
354 These are the notifications from the PCI bus driver that it is about to enter a certain\r
355 phase of the PCI enumeration process.\r
356\r
357 This member function can be used to notify the host bridge driver to perform specific actions,\r
358 including any chipset-specific initialization, so that the chipset is ready to enter the next phase.\r
359 Eight notification points are defined at this time. See belows:\r
360 EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures and internal data\r
361 structures. The PCI enumerator should issue this notification\r
362 before starting a fresh enumeration process. Enumeration cannot\r
363 be restarted after sending any other notification such as\r
364 EfiPciHostBridgeBeginBusAllocation.\r
365 EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to begin. No specific action is\r
366 required here. This notification can be used to perform any\r
367 chipset-specific programming.\r
368 EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming phase is complete. No\r
369 specific action is required here. This notification can be used to\r
370 perform any chipset-specific programming.\r
371 EfiPciHostBridgeBeginResourceAllocation\r
372 The resource allocation phase is about to begin. No specific\r
373 action is required here. This notification can be used to perform\r
374 any chipset-specific programming.\r
375 EfiPciHostBridgeAllocateResources Allocates resources per previously submitted requests for all the PCI\r
376 root bridges. These resource settings are returned on the next call to\r
377 GetProposedResources(). Before calling NotifyPhase() with a Phase of\r
378 EfiPciHostBridgeAllocateResource, the PCI bus enumerator is responsible\r
379 for gathering I/O and memory requests for\r
380 all the PCI root bridges and submitting these requests using\r
381 SubmitResources(). This function pads the resource amount\r
382 to suit the root bridge hardware, takes care of dependencies between\r
383 the PCI root bridges, and calls the Global Coherency Domain (GCD)\r
384 with the allocation request. In the case of padding, the allocated range\r
385 could be bigger than what was requested.\r
386 EfiPciHostBridgeSetResources Programs the host bridge hardware to decode previously allocated\r
387 resources (proposed resources) for all the PCI root bridges. After the\r
388 hardware is programmed, reassigning resources will not be supported.\r
389 The bus settings are not affected.\r
390 EfiPciHostBridgeFreeResources Deallocates resources that were previously allocated for all the PCI\r
391 root bridges and resets the I/O and memory apertures to their initial\r
392 state. The bus settings are not affected. If the request to allocate\r
393 resources fails, the PCI enumerator can use this notification to\r
394 deallocate previous resources, adjust the requests, and retry\r
395 allocation.\r
396 EfiPciHostBridgeEndResourceAllocation The resource allocation phase is completed. No specific action is\r
397 required here. This notification can be used to perform any chipsetspecific\r
398 programming.\r
399\r
400 @param[in] PciResAlloc The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
401 @param[in] Phase The phase during enumeration\r
402\r
403 @retval EFI_NOT_READY This phase cannot be entered at this time. For example, this error\r
404 is valid for a Phase of EfiPciHostBridgeAllocateResources if\r
405 SubmitResources() has not been called for one or more\r
406 PCI root bridges before this call\r
407 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. This error is valid\r
408 for a Phase of EfiPciHostBridgeSetResources.\r
409 @retval EFI_INVALID_PARAMETER Invalid phase parameter\r
410 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
411 This error is valid for a Phase of EfiPciHostBridgeAllocateResources if the\r
412 previously submitted resource requests cannot be fulfilled or\r
413 were only partially fulfilled.\r
414 @retval EFI_SUCCESS The notification was accepted without any errors.\r
415\r
416**/\r
417EFI_STATUS\r
418NotifyPhase (\r
419 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc,\r
420 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase\r
421 );\r
422\r
423/**\r
424 Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various\r
425 stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual\r
426 PCI controllers before enumeration.\r
427\r
428 This function is called during the PCI enumeration process. No specific action is expected from this\r
429 member function. It allows the host bridge driver to preinitialize individual PCI controllers before\r
430 enumeration.\r
431\r
432 @param Bridge Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r
433 @param Bus The bus number of the pci device.\r
434 @param Device The device number of the pci device.\r
435 @param Func The function number of the pci device.\r
436 @param Phase The phase of the PCI device enumeration.\r
437\r
438 @retval EFI_SUCCESS The requested parameters were returned.\r
439 @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.\r
440 @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined in\r
441 EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.\r
442 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. The PCI enumerator should\r
443 not enumerate this device, including its child devices if it is a PCI-to-PCI\r
444 bridge.\r
445\r
446**/\r
447EFI_STATUS\r
448PreprocessController (\r
449 IN PCI_IO_DEVICE *Bridge,\r
450 IN UINT8 Bus,\r
451 IN UINT8 Device,\r
452 IN UINT8 Func,\r
453 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase\r
454 );\r
455\r
456/**\r
457 This function allows the PCI bus driver to be notified to act as requested when a hot-plug event has\r
458 happened on the hot-plug controller. Currently, the operations include add operation and remove operation..\r
459\r
460 @param This A pointer to the hot plug request protocol.\r
461 @param Operation The operation the PCI bus driver is requested to make.\r
462 @param Controller The handle of the hot-plug controller.\r
463 @param RemainingDevicePath The remaining device path for the PCI-like hot-plug device.\r
464 @param NumberOfChildren The number of child handles.\r
465 For a add operation, it is an output parameter.\r
466 For a remove operation, it's an input parameter.\r
467 @param ChildHandleBuffer The buffer which contains the child handles.\r
468\r
469 @retval EFI_INVALID_PARAMETER Operation is not a legal value.\r
470 Controller is NULL or not a valid handle.\r
471 NumberOfChildren is NULL.\r
472 ChildHandleBuffer is NULL while Operation is add.\r
473 @retval EFI_OUT_OF_RESOURCES There are no enough resources to start the devices.\r
474 @retval EFI_NOT_FOUND Can not find bridge according to controller handle.\r
475 @retval EFI_SUCCESS The handles for the specified device have been created or destroyed\r
476 as requested, and for an add operation, the new handles are\r
477 returned in ChildHandleBuffer.\r
478**/\r
479EFI_STATUS\r
480EFIAPI\r
481PciHotPlugRequestNotify (\r
482 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL * This,\r
483 IN EFI_PCI_HOTPLUG_OPERATION Operation,\r
484 IN EFI_HANDLE Controller,\r
485 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL,\r
486 IN OUT UINT8 *NumberOfChildren,\r
487 IN OUT EFI_HANDLE * ChildHandleBuffer\r
488 );\r
489\r
490/**\r
491 Search hostbridge according to given handle\r
492\r
493 @param RootBridgeHandle Host bridge handle.\r
494\r
495 @retval TRUE Found host bridge handle.\r
496 @retval FALSE Not found hot bridge handle.\r
497\r
498**/\r
499BOOLEAN\r
500SearchHostBridgeHandle (\r
501 IN EFI_HANDLE RootBridgeHandle\r
502 );\r
503\r
504/**\r
505 Add host bridge handle to global variable for enumerating.\r
506\r
507 @param HostBridgeHandle Host bridge handle.\r
508\r
509 @retval EFI_SUCCESS Successfully added host bridge.\r
510 @retval EFI_ABORTED Host bridge is NULL, or given host bridge\r
511 has been in host bridge list.\r
512\r
513**/\r
514EFI_STATUS\r
515AddHostBridgeEnumerator (\r
516 IN EFI_HANDLE HostBridgeHandle\r
517 );\r
518\r
519#endif\r