2 PCI bus enumeration logic function declaration for PCI bus module.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _EFI_PCI_ENUMERATOR_H_
16 #define _EFI_PCI_ENUMERATOR_H_
18 #include "PciResourceSupport.h"
21 This routine is used to enumerate entire pci bus system
24 @param Controller Parent controller handle.
25 @param HostBridgeHandle Host bridge handle.
27 @retval EFI_SUCCESS PCI enumeration finished successfully.
28 @retval other Some error occurred when enumerating the pci bus system.
33 IN EFI_HANDLE Controller
,
34 IN EFI_HANDLE HostBridgeHandle
38 Enumerate PCI root bridge.
40 @param PciResAlloc Pointer to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
41 @param RootBridgeDev Instance of root bridge device.
43 @retval EFI_SUCCESS Successfully enumerated root bridge.
44 @retval other Failed to enumerate root bridge.
48 PciRootBridgeEnumerator (
49 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
50 IN PCI_IO_DEVICE
*RootBridgeDev
54 This routine is used to process all PCI devices' Option Rom
55 on a certain root bridge.
57 @param Bridge Given parent's root bridge.
58 @param RomBase Base address of ROM driver loaded from.
59 @param MaxLength Maximum rom size.
64 IN PCI_IO_DEVICE
*Bridge
,
70 This routine is used to assign bus number to the given PCI bus system
72 @param Bridge Parent root bridge instance.
73 @param StartBusNumber Number of beginning.
74 @param SubBusNumber The number of sub bus.
76 @retval EFI_SUCCESS Successfully assigned bus number.
77 @retval EFI_DEVICE_ERROR Failed to assign bus number.
82 IN PCI_IO_DEVICE
*Bridge
,
83 IN UINT8 StartBusNumber
,
84 OUT UINT8
*SubBusNumber
88 This routine is used to determine the root bridge attribute by interfacing
89 the host bridge resource allocation protocol.
91 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
92 @param RootBridgeDev Root bridge instance
94 @retval EFI_SUCCESS Successfully got root bridge's attribute.
95 @retval other Failed to get attribute.
99 DetermineRootBridgeAttributes (
100 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
101 IN PCI_IO_DEVICE
*RootBridgeDev
105 Get Max Option Rom size on specified bridge.
107 @param Bridge Given bridge device instance.
109 @return Max size of option rom needed.
113 GetMaxOptionRomSize (
114 IN PCI_IO_DEVICE
*Bridge
118 Process attributes of devices on this host bridge
120 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
122 @retval EFI_SUCCESS Successfully process attribute.
123 @retval EFI_NOT_FOUND Can not find the specific root bridge device.
124 @retval other Failed to determine the root bridge device's attribute.
128 PciHostBridgeDeviceAttribute (
129 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
133 Get resource allocation status from the ACPI resource descriptor.
135 @param AcpiConfig Point to Acpi configuration table.
136 @param IoResStatus Return the status of I/O resource.
137 @param Mem32ResStatus Return the status of 32-bit Memory resource.
138 @param PMem32ResStatus Return the status of 32-bit Prefetchable Memory resource.
139 @param Mem64ResStatus Return the status of 64-bit Memory resource.
140 @param PMem64ResStatus Return the status of 64-bit Prefetchable Memory resource.
144 GetResourceAllocationStatus (
146 OUT UINT64
*IoResStatus
,
147 OUT UINT64
*Mem32ResStatus
,
148 OUT UINT64
*PMem32ResStatus
,
149 OUT UINT64
*Mem64ResStatus
,
150 OUT UINT64
*PMem64ResStatus
154 Remove a PCI device from device pool and mark its bar.
156 @param PciDevice Instance of Pci device.
158 @retval EFI_SUCCESS Successfully remove the PCI device.
159 @retval EFI_ABORTED Pci device is a root bridge or a PCI-PCI bridge.
164 IN PCI_IO_DEVICE
*PciDevice
168 Determine whethter a PCI device can be rejected.
170 @param PciResNode Pointer to Pci resource node instance.
172 @retval TRUE The PCI device can be rejected.
173 @retval TRUE The PCI device cannot be rejected.
178 IN PCI_RESOURCE_NODE
*PciResNode
182 Compare two resource nodes and get the larger resource consumer.
184 @param PciResNode1 resource node 1 want to be compared
185 @param PciResNode2 resource node 2 want to be compared
187 @return Larger resource node.
191 GetLargerConsumerDevice (
192 IN PCI_RESOURCE_NODE
*PciResNode1
,
193 IN PCI_RESOURCE_NODE
*PciResNode2
197 Get the max resource consumer in the host resource pool.
199 @param ResPool Pointer to resource pool node.
201 @return The max resource consumer in the host resource pool.
205 GetMaxResourceConsumerDevice (
206 IN PCI_RESOURCE_NODE
*ResPool
210 Adjust host bridge allocation so as to reduce resource requirement
212 @param IoPool Pointer to instance of I/O resource Node.
213 @param Mem32Pool Pointer to instance of 32-bit memory resource Node.
214 @param PMem32Pool Pointer to instance of 32-bit Prefetchable memory resource node.
215 @param Mem64Pool Pointer to instance of 64-bit memory resource node.
216 @param PMem64Pool Pointer to instance of 64-bit Prefetchable memory resource node.
217 @param IoResStatus Status of I/O resource Node.
218 @param Mem32ResStatus Status of 32-bit memory resource Node.
219 @param PMem32ResStatus Status of 32-bit Prefetchable memory resource node.
220 @param Mem64ResStatus Status of 64-bit memory resource node.
221 @param PMem64ResStatus Status of 64-bit Prefetchable memory resource node.
223 @retval EFI_SUCCESS Successfully adjusted resource on host bridge.
224 @retval EFI_ABORTED Host bridge hasn't this resource type or no resource be adjusted.
228 PciHostBridgeAdjustAllocation (
229 IN PCI_RESOURCE_NODE
*IoPool
,
230 IN PCI_RESOURCE_NODE
*Mem32Pool
,
231 IN PCI_RESOURCE_NODE
*PMem32Pool
,
232 IN PCI_RESOURCE_NODE
*Mem64Pool
,
233 IN PCI_RESOURCE_NODE
*PMem64Pool
,
234 IN UINT64 IoResStatus
,
235 IN UINT64 Mem32ResStatus
,
236 IN UINT64 PMem32ResStatus
,
237 IN UINT64 Mem64ResStatus
,
238 IN UINT64 PMem64ResStatus
242 Summary requests for all resource type, and construct ACPI resource
245 @param Bridge detecting bridge
246 @param IoNode Pointer to instance of I/O resource Node
247 @param Mem32Node Pointer to instance of 32-bit memory resource Node
248 @param PMem32Node Pointer to instance of 32-bit Pmemory resource node
249 @param Mem64Node Pointer to instance of 64-bit memory resource node
250 @param PMem64Node Pointer to instance of 64-bit Pmemory resource node
251 @param Config Output buffer holding new constructed APCI resource requestor
253 @retval EFI_SUCCESS Successfully constructed ACPI resource.
254 @retval EFI_OUT_OF_RESOURCES No memory available.
258 ConstructAcpiResourceRequestor (
259 IN PCI_IO_DEVICE
*Bridge
,
260 IN PCI_RESOURCE_NODE
*IoNode
,
261 IN PCI_RESOURCE_NODE
*Mem32Node
,
262 IN PCI_RESOURCE_NODE
*PMem32Node
,
263 IN PCI_RESOURCE_NODE
*Mem64Node
,
264 IN PCI_RESOURCE_NODE
*PMem64Node
,
269 Get resource base from an acpi configuration descriptor.
271 @param Config An acpi configuration descriptor.
272 @param IoBase Output of I/O resource base address.
273 @param Mem32Base Output of 32-bit memory base address.
274 @param PMem32Base Output of 32-bit prefetchable memory base address.
275 @param Mem64Base Output of 64-bit memory base address.
276 @param PMem64Base Output of 64-bit prefetchable memory base address.
283 OUT UINT64
*Mem32Base
,
284 OUT UINT64
*PMem32Base
,
285 OUT UINT64
*Mem64Base
,
286 OUT UINT64
*PMem64Base
290 Enumerate pci bridge, allocate resource and determine attribute
291 for devices on this bridge.
293 @param BridgeDev Pointer to instance of bridge device.
295 @retval EFI_SUCCESS Successfully enumerated PCI bridge.
296 @retval other Failed to enumerate.
300 PciBridgeEnumerator (
301 IN PCI_IO_DEVICE
*BridgeDev
305 Allocate all kinds of resource for PCI bridge.
307 @param Bridge Pointer to bridge instance.
309 @retval EFI_SUCCESS Successfully allocated resource for PCI bridge.
310 @retval other Failed to allocate resource for bridge.
314 PciBridgeResourceAllocator (
315 IN PCI_IO_DEVICE
*Bridge
319 Get resource base address for a pci bridge device.
321 @param Bridge Given Pci driver instance.
322 @param IoBase Output for base address of I/O type resource.
323 @param Mem32Base Output for base address of 32-bit memory type resource.
324 @param PMem32Base Ooutput for base address of 32-bit Pmemory type resource.
325 @param Mem64Base Output for base address of 64-bit memory type resource.
326 @param PMem64Base Output for base address of 64-bit Pmemory type resource.
328 @retval EFI_SUCCESS Successfully got resource base address.
329 @retval EFI_OUT_OF_RESOURCES PCI bridge is not available.
333 GetResourceBaseFromBridge (
334 IN PCI_IO_DEVICE
*Bridge
,
336 OUT UINT64
*Mem32Base
,
337 OUT UINT64
*PMem32Base
,
338 OUT UINT64
*Mem64Base
,
339 OUT UINT64
*PMem64Base
343 Process Option Rom on this host bridge
345 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
347 @retval EFI_NOT_FOUND Can not find the root bridge instance.
348 @retval EFI_SUCCESS Success process.
351 PciHostBridgeP2CProcess (
352 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
356 These are the notifications from the PCI bus driver that it is about to enter a certain
357 phase of the PCI enumeration process.
359 This member function can be used to notify the host bridge driver to perform specific actions,
360 including any chipset-specific initialization, so that the chipset is ready to enter the next phase.
361 Eight notification points are defined at this time. See belows:
362 EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures and internal data
363 structures. The PCI enumerator should issue this notification
364 before starting a fresh enumeration process. Enumeration cannot
365 be restarted after sending any other notification such as
366 EfiPciHostBridgeBeginBusAllocation.
367 EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to begin. No specific action is
368 required here. This notification can be used to perform any
369 chipset-specific programming.
370 EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming phase is complete. No
371 specific action is required here. This notification can be used to
372 perform any chipset-specific programming.
373 EfiPciHostBridgeBeginResourceAllocation
374 The resource allocation phase is about to begin. No specific
375 action is required here. This notification can be used to perform
376 any chipset-specific programming.
377 EfiPciHostBridgeAllocateResources Allocates resources per previously submitted requests for all the PCI
378 root bridges. These resource settings are returned on the next call to
379 GetProposedResources(). Before calling NotifyPhase() with a Phase of
380 EfiPciHostBridgeAllocateResource, the PCI bus enumerator is responsible
381 for gathering I/O and memory requests for
382 all the PCI root bridges and submitting these requests using
383 SubmitResources(). This function pads the resource amount
384 to suit the root bridge hardware, takes care of dependencies between
385 the PCI root bridges, and calls the Global Coherency Domain (GCD)
386 with the allocation request. In the case of padding, the allocated range
387 could be bigger than what was requested.
388 EfiPciHostBridgeSetResources Programs the host bridge hardware to decode previously allocated
389 resources (proposed resources) for all the PCI root bridges. After the
390 hardware is programmed, reassigning resources will not be supported.
391 The bus settings are not affected.
392 EfiPciHostBridgeFreeResources Deallocates resources that were previously allocated for all the PCI
393 root bridges and resets the I/O and memory apertures to their initial
394 state. The bus settings are not affected. If the request to allocate
395 resources fails, the PCI enumerator can use this notification to
396 deallocate previous resources, adjust the requests, and retry
398 EfiPciHostBridgeEndResourceAllocation The resource allocation phase is completed. No specific action is
399 required here. This notification can be used to perform any chipsetspecific
402 @param[in] PciResAlloc The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
403 @param[in] Phase The phase during enumeration
405 @retval EFI_NOT_READY This phase cannot be entered at this time. For example, this error
406 is valid for a Phase of EfiPciHostBridgeAllocateResources if
407 SubmitResources() has not been called for one or more
408 PCI root bridges before this call
409 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. This error is valid
410 for a Phase of EfiPciHostBridgeSetResources.
411 @retval EFI_INVALID_PARAMETER Invalid phase parameter
412 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
413 This error is valid for a Phase of EfiPciHostBridgeAllocateResources if the
414 previously submitted resource requests cannot be fulfilled or
415 were only partially fulfilled.
416 @retval EFI_SUCCESS The notification was accepted without any errors.
421 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
422 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
426 Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various
427 stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual
428 PCI controllers before enumeration.
430 This function is called during the PCI enumeration process. No specific action is expected from this
431 member function. It allows the host bridge driver to preinitialize individual PCI controllers before
434 @param Bridge Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
435 @param Bus The bus number of the pci device.
436 @param Device The device number of the pci device.
437 @param Func The function number of the pci device.
438 @param Phase The phase of the PCI device enumeration.
440 @retval EFI_SUCCESS The requested parameters were returned.
441 @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.
442 @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined in
443 EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.
444 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. The PCI enumerator should
445 not enumerate this device, including its child devices if it is a PCI-to-PCI
450 PreprocessController (
451 IN PCI_IO_DEVICE
*Bridge
,
455 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
459 This function allows the PCI bus driver to be notified to act as requested when a hot-plug event has
460 happened on the hot-plug controller. Currently, the operations include add operation and remove operation..
462 @param This A pointer to the hot plug request protocol.
463 @param Operation The operation the PCI bus driver is requested to make.
464 @param Controller The handle of the hot-plug controller.
465 @param RemainingDevicePath The remaining device path for the PCI-like hot-plug device.
466 @param NumberOfChildren The number of child handles.
467 For a add operation, it is an output parameter.
468 For a remove operation, it's an input parameter.
469 @param ChildHandleBuffer The buffer which contains the child handles.
471 @retval EFI_INVALID_PARAMETER Operation is not a legal value.
472 Controller is NULL or not a valid handle.
473 NumberOfChildren is NULL.
474 ChildHandleBuffer is NULL while Operation is add.
475 @retval EFI_OUT_OF_RESOURCES There are no enough resources to start the devices.
476 @retval EFI_NOT_FOUND Can not find bridge according to controller handle.
477 @retval EFI_SUCCESS The handles for the specified device have been created or destroyed
478 as requested, and for an add operation, the new handles are
479 returned in ChildHandleBuffer.
483 PciHotPlugRequestNotify (
484 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
485 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
486 IN EFI_HANDLE Controller
,
487 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
488 IN OUT UINT8
*NumberOfChildren
,
489 IN OUT EFI_HANDLE
* ChildHandleBuffer
493 Search hostbridge according to given handle
495 @param RootBridgeHandle Host bridge handle.
497 @retval TRUE Found host bridge handle.
498 @retval FALSE Not found hot bridge handle.
502 SearchHostBridgeHandle (
503 IN EFI_HANDLE RootBridgeHandle
507 Add host bridge handle to global variable for enumerating.
509 @param HostBridgeHandle Host bridge handle.
511 @retval EFI_SUCCESS Successfully added host bridge.
512 @retval EFI_ABORTED Host bridge is NULL, or given host bridge
513 has been in host bridge list.
517 AddHostBridgeEnumerator (
518 IN EFI_HANDLE HostBridgeHandle