2 PCI bus enumeration logic function declaration for PCI bus module.
4 Copyright (c) 2006 - 2016, 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.
26 @retval EFI_SUCCESS PCI enumeration finished successfully.
27 @retval other Some error occurred when enumerating the pci bus system.
32 IN EFI_HANDLE Controller
36 Enumerate PCI root bridge.
38 @param PciResAlloc Pointer to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
39 @param RootBridgeDev Instance of root bridge device.
41 @retval EFI_SUCCESS Successfully enumerated root bridge.
42 @retval other Failed to enumerate root bridge.
46 PciRootBridgeEnumerator (
47 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
48 IN PCI_IO_DEVICE
*RootBridgeDev
52 This routine is used to process all PCI devices' Option Rom
53 on a certain root bridge.
55 @param Bridge Given parent's root bridge.
56 @param RomBase Base address of ROM driver loaded from.
57 @param MaxLength Maximum rom size.
62 IN PCI_IO_DEVICE
*Bridge
,
68 This routine is used to assign bus number to the given PCI bus system
70 @param Bridge Parent root bridge instance.
71 @param StartBusNumber Number of beginning.
72 @param SubBusNumber The number of sub bus.
74 @retval EFI_SUCCESS Successfully assigned bus number.
75 @retval EFI_DEVICE_ERROR Failed to assign bus number.
80 IN PCI_IO_DEVICE
*Bridge
,
81 IN UINT8 StartBusNumber
,
82 OUT UINT8
*SubBusNumber
86 This routine is used to determine the root bridge attribute by interfacing
87 the host bridge resource allocation protocol.
89 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
90 @param RootBridgeDev Root bridge instance
92 @retval EFI_SUCCESS Successfully got root bridge's attribute.
93 @retval other Failed to get attribute.
97 DetermineRootBridgeAttributes (
98 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
99 IN PCI_IO_DEVICE
*RootBridgeDev
103 Get Max Option Rom size on specified bridge.
105 @param Bridge Given bridge device instance.
107 @return Max size of option rom needed.
111 GetMaxOptionRomSize (
112 IN PCI_IO_DEVICE
*Bridge
116 Process attributes of devices on this host bridge
118 @param PciResAlloc Protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
120 @retval EFI_SUCCESS Successfully process attribute.
121 @retval EFI_NOT_FOUND Can not find the specific root bridge device.
122 @retval other Failed to determine the root bridge device's attribute.
126 PciHostBridgeDeviceAttribute (
127 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
131 Get resource allocation status from the ACPI resource descriptor.
133 @param AcpiConfig Point to Acpi configuration table.
134 @param IoResStatus Return the status of I/O resource.
135 @param Mem32ResStatus Return the status of 32-bit Memory resource.
136 @param PMem32ResStatus Return the status of 32-bit Prefetchable Memory resource.
137 @param Mem64ResStatus Return the status of 64-bit Memory resource.
138 @param PMem64ResStatus Return the status of 64-bit Prefetchable Memory resource.
142 GetResourceAllocationStatus (
144 OUT UINT64
*IoResStatus
,
145 OUT UINT64
*Mem32ResStatus
,
146 OUT UINT64
*PMem32ResStatus
,
147 OUT UINT64
*Mem64ResStatus
,
148 OUT UINT64
*PMem64ResStatus
152 Remove a PCI device from device pool and mark its bar.
154 @param PciDevice Instance of Pci device.
156 @retval EFI_SUCCESS Successfully remove the PCI device.
157 @retval EFI_ABORTED Pci device is a root bridge or a PCI-PCI bridge.
162 IN PCI_IO_DEVICE
*PciDevice
166 Determine whethter a PCI device can be rejected.
168 @param PciResNode Pointer to Pci resource node instance.
170 @retval TRUE The PCI device can be rejected.
171 @retval TRUE The PCI device cannot be rejected.
176 IN PCI_RESOURCE_NODE
*PciResNode
180 Compare two resource nodes and get the larger resource consumer.
182 @param PciResNode1 resource node 1 want to be compared
183 @param PciResNode2 resource node 2 want to be compared
185 @return Larger resource node.
189 GetLargerConsumerDevice (
190 IN PCI_RESOURCE_NODE
*PciResNode1
,
191 IN PCI_RESOURCE_NODE
*PciResNode2
195 Get the max resource consumer in the host resource pool.
197 @param ResPool Pointer to resource pool node.
199 @return The max resource consumer in the host resource pool.
203 GetMaxResourceConsumerDevice (
204 IN PCI_RESOURCE_NODE
*ResPool
208 Adjust host bridge allocation so as to reduce resource requirement
210 @param IoPool Pointer to instance of I/O resource Node.
211 @param Mem32Pool Pointer to instance of 32-bit memory resource Node.
212 @param PMem32Pool Pointer to instance of 32-bit Prefetchable memory resource node.
213 @param Mem64Pool Pointer to instance of 64-bit memory resource node.
214 @param PMem64Pool Pointer to instance of 64-bit Prefetchable memory resource node.
215 @param IoResStatus Status of I/O resource Node.
216 @param Mem32ResStatus Status of 32-bit memory resource Node.
217 @param PMem32ResStatus Status of 32-bit Prefetchable memory resource node.
218 @param Mem64ResStatus Status of 64-bit memory resource node.
219 @param PMem64ResStatus Status of 64-bit Prefetchable memory resource node.
221 @retval EFI_SUCCESS Successfully adjusted resource on host bridge.
222 @retval EFI_ABORTED Host bridge hasn't this resource type or no resource be adjusted.
226 PciHostBridgeAdjustAllocation (
227 IN PCI_RESOURCE_NODE
*IoPool
,
228 IN PCI_RESOURCE_NODE
*Mem32Pool
,
229 IN PCI_RESOURCE_NODE
*PMem32Pool
,
230 IN PCI_RESOURCE_NODE
*Mem64Pool
,
231 IN PCI_RESOURCE_NODE
*PMem64Pool
,
232 IN UINT64 IoResStatus
,
233 IN UINT64 Mem32ResStatus
,
234 IN UINT64 PMem32ResStatus
,
235 IN UINT64 Mem64ResStatus
,
236 IN UINT64 PMem64ResStatus
240 Summary requests for all resource type, and construct ACPI resource
243 @param Bridge detecting bridge
244 @param IoNode Pointer to instance of I/O resource Node
245 @param Mem32Node Pointer to instance of 32-bit memory resource Node
246 @param PMem32Node Pointer to instance of 32-bit Pmemory resource node
247 @param Mem64Node Pointer to instance of 64-bit memory resource node
248 @param PMem64Node Pointer to instance of 64-bit Pmemory resource node
249 @param Config Output buffer holding new constructed APCI resource requestor
251 @retval EFI_SUCCESS Successfully constructed ACPI resource.
252 @retval EFI_OUT_OF_RESOURCES No memory available.
256 ConstructAcpiResourceRequestor (
257 IN PCI_IO_DEVICE
*Bridge
,
258 IN PCI_RESOURCE_NODE
*IoNode
,
259 IN PCI_RESOURCE_NODE
*Mem32Node
,
260 IN PCI_RESOURCE_NODE
*PMem32Node
,
261 IN PCI_RESOURCE_NODE
*Mem64Node
,
262 IN PCI_RESOURCE_NODE
*PMem64Node
,
267 Get resource base from an acpi configuration descriptor.
269 @param Config An acpi configuration descriptor.
270 @param IoBase Output of I/O resource base address.
271 @param Mem32Base Output of 32-bit memory base address.
272 @param PMem32Base Output of 32-bit prefetchable memory base address.
273 @param Mem64Base Output of 64-bit memory base address.
274 @param PMem64Base Output of 64-bit prefetchable memory base address.
281 OUT UINT64
*Mem32Base
,
282 OUT UINT64
*PMem32Base
,
283 OUT UINT64
*Mem64Base
,
284 OUT UINT64
*PMem64Base
288 Enumerate pci bridge, allocate resource and determine attribute
289 for devices on this bridge.
291 @param BridgeDev Pointer to instance of bridge device.
293 @retval EFI_SUCCESS Successfully enumerated PCI bridge.
294 @retval other Failed to enumerate.
298 PciBridgeEnumerator (
299 IN PCI_IO_DEVICE
*BridgeDev
303 Allocate all kinds of resource for PCI bridge.
305 @param Bridge Pointer to bridge instance.
307 @retval EFI_SUCCESS Successfully allocated resource for PCI bridge.
308 @retval other Failed to allocate resource for bridge.
312 PciBridgeResourceAllocator (
313 IN PCI_IO_DEVICE
*Bridge
317 Get resource base address for a pci bridge device.
319 @param Bridge Given Pci driver instance.
320 @param IoBase Output for base address of I/O type resource.
321 @param Mem32Base Output for base address of 32-bit memory type resource.
322 @param PMem32Base Ooutput for base address of 32-bit Pmemory type resource.
323 @param Mem64Base Output for base address of 64-bit memory type resource.
324 @param PMem64Base Output for base address of 64-bit Pmemory type resource.
326 @retval EFI_SUCCESS Successfully got resource base address.
327 @retval EFI_OUT_OF_RESOURCES PCI bridge is not available.
331 GetResourceBaseFromBridge (
332 IN PCI_IO_DEVICE
*Bridge
,
334 OUT UINT64
*Mem32Base
,
335 OUT UINT64
*PMem32Base
,
336 OUT UINT64
*Mem64Base
,
337 OUT UINT64
*PMem64Base
341 Process Option Rom on this host bridge
343 @param PciResAlloc Pointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
345 @retval EFI_NOT_FOUND Can not find the root bridge instance.
346 @retval EFI_SUCCESS Success process.
349 PciHostBridgeP2CProcess (
350 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
354 These are the notifications from the PCI bus driver that it is about to enter a certain
355 phase of the PCI enumeration process.
357 This member function can be used to notify the host bridge driver to perform specific actions,
358 including any chipset-specific initialization, so that the chipset is ready to enter the next phase.
359 Eight notification points are defined at this time. See belows:
360 EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures and internal data
361 structures. The PCI enumerator should issue this notification
362 before starting a fresh enumeration process. Enumeration cannot
363 be restarted after sending any other notification such as
364 EfiPciHostBridgeBeginBusAllocation.
365 EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to begin. No specific action is
366 required here. This notification can be used to perform any
367 chipset-specific programming.
368 EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming phase is complete. No
369 specific action is required here. This notification can be used to
370 perform any chipset-specific programming.
371 EfiPciHostBridgeBeginResourceAllocation
372 The resource allocation phase is about to begin. No specific
373 action is required here. This notification can be used to perform
374 any chipset-specific programming.
375 EfiPciHostBridgeAllocateResources Allocates resources per previously submitted requests for all the PCI
376 root bridges. These resource settings are returned on the next call to
377 GetProposedResources(). Before calling NotifyPhase() with a Phase of
378 EfiPciHostBridgeAllocateResource, the PCI bus enumerator is responsible
379 for gathering I/O and memory requests for
380 all the PCI root bridges and submitting these requests using
381 SubmitResources(). This function pads the resource amount
382 to suit the root bridge hardware, takes care of dependencies between
383 the PCI root bridges, and calls the Global Coherency Domain (GCD)
384 with the allocation request. In the case of padding, the allocated range
385 could be bigger than what was requested.
386 EfiPciHostBridgeSetResources Programs the host bridge hardware to decode previously allocated
387 resources (proposed resources) for all the PCI root bridges. After the
388 hardware is programmed, reassigning resources will not be supported.
389 The bus settings are not affected.
390 EfiPciHostBridgeFreeResources Deallocates resources that were previously allocated for all the PCI
391 root bridges and resets the I/O and memory apertures to their initial
392 state. The bus settings are not affected. If the request to allocate
393 resources fails, the PCI enumerator can use this notification to
394 deallocate previous resources, adjust the requests, and retry
396 EfiPciHostBridgeEndResourceAllocation The resource allocation phase is completed. No specific action is
397 required here. This notification can be used to perform any chipsetspecific
400 @param[in] PciResAlloc The instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
401 @param[in] Phase The phase during enumeration
403 @retval EFI_NOT_READY This phase cannot be entered at this time. For example, this error
404 is valid for a Phase of EfiPciHostBridgeAllocateResources if
405 SubmitResources() has not been called for one or more
406 PCI root bridges before this call
407 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. This error is valid
408 for a Phase of EfiPciHostBridgeSetResources.
409 @retval EFI_INVALID_PARAMETER Invalid phase parameter
410 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
411 This error is valid for a Phase of EfiPciHostBridgeAllocateResources if the
412 previously submitted resource requests cannot be fulfilled or
413 were only partially fulfilled.
414 @retval EFI_SUCCESS The notification was accepted without any errors.
419 IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
*PciResAlloc
,
420 EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
424 Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various
425 stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual
426 PCI controllers before enumeration.
428 This function is called during the PCI enumeration process. No specific action is expected from this
429 member function. It allows the host bridge driver to preinitialize individual PCI controllers before
432 @param Bridge Pointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
433 @param Bus The bus number of the pci device.
434 @param Device The device number of the pci device.
435 @param Func The function number of the pci device.
436 @param Phase The phase of the PCI device enumeration.
438 @retval EFI_SUCCESS The requested parameters were returned.
439 @retval EFI_INVALID_PARAMETER RootBridgeHandle is not a valid root bridge handle.
440 @retval EFI_INVALID_PARAMETER Phase is not a valid phase that is defined in
441 EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.
442 @retval EFI_DEVICE_ERROR Programming failed due to a hardware error. The PCI enumerator should
443 not enumerate this device, including its child devices if it is a PCI-to-PCI
448 PreprocessController (
449 IN PCI_IO_DEVICE
*Bridge
,
453 IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
457 This function allows the PCI bus driver to be notified to act as requested when a hot-plug event has
458 happened on the hot-plug controller. Currently, the operations include add operation and remove operation..
460 @param This A pointer to the hot plug request protocol.
461 @param Operation The operation the PCI bus driver is requested to make.
462 @param Controller The handle of the hot-plug controller.
463 @param RemainingDevicePath The remaining device path for the PCI-like hot-plug device.
464 @param NumberOfChildren The number of child handles.
465 For a add operation, it is an output parameter.
466 For a remove operation, it's an input parameter.
467 @param ChildHandleBuffer The buffer which contains the child handles.
469 @retval EFI_INVALID_PARAMETER Operation is not a legal value.
470 Controller is NULL or not a valid handle.
471 NumberOfChildren is NULL.
472 ChildHandleBuffer is NULL while Operation is add.
473 @retval EFI_OUT_OF_RESOURCES There are no enough resources to start the devices.
474 @retval EFI_NOT_FOUND Can not find bridge according to controller handle.
475 @retval EFI_SUCCESS The handles for the specified device have been created or destroyed
476 as requested, and for an add operation, the new handles are
477 returned in ChildHandleBuffer.
481 PciHotPlugRequestNotify (
482 IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL
* This
,
483 IN EFI_PCI_HOTPLUG_OPERATION Operation
,
484 IN EFI_HANDLE Controller
,
485 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
,
486 IN OUT UINT8
*NumberOfChildren
,
487 IN OUT EFI_HANDLE
* ChildHandleBuffer
491 Search hostbridge according to given handle
493 @param RootBridgeHandle Host bridge handle.
495 @retval TRUE Found host bridge handle.
496 @retval FALSE Not found hot bridge handle.
500 SearchHostBridgeHandle (
501 IN EFI_HANDLE RootBridgeHandle
505 Add host bridge handle to global variable for enumerating.
507 @param HostBridgeHandle Host bridge handle.
509 @retval EFI_SUCCESS Successfully added host bridge.
510 @retval EFI_ABORTED Host bridge is NULL, or given host bridge
511 has been in host bridge list.
515 AddHostBridgeEnumerator (
516 IN EFI_HANDLE HostBridgeHandle