TianoCore EDK2 master
Loading...
Searching...
No Matches
PciEnumerator.c File Reference
#include "PciBus.h"

Go to the source code of this file.

Functions

EFI_STATUS PciEnumerator (IN EFI_HANDLE Controller, IN EFI_HANDLE HostBridgeHandle)
 
EFI_STATUS PciRootBridgeEnumerator (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc, IN PCI_IO_DEVICE *RootBridgeDev)
 
VOID ProcessOptionRom (IN PCI_IO_DEVICE *Bridge, IN UINT64 RomBase, IN UINT64 MaxLength)
 
EFI_STATUS PciAssignBusNumber (IN PCI_IO_DEVICE *Bridge, IN UINT8 StartBusNumber, OUT UINT8 *SubBusNumber)
 
EFI_STATUS DetermineRootBridgeAttributes (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc, IN PCI_IO_DEVICE *RootBridgeDev)
 
UINT32 GetMaxOptionRomSize (IN PCI_IO_DEVICE *Bridge)
 
EFI_STATUS PciHostBridgeDeviceAttribute (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
 
VOID GetResourceAllocationStatus (VOID *AcpiConfig, OUT UINT64 *IoResStatus, OUT UINT64 *Mem32ResStatus, OUT UINT64 *PMem32ResStatus, OUT UINT64 *Mem64ResStatus, OUT UINT64 *PMem64ResStatus)
 
EFI_STATUS RejectPciDevice (IN PCI_IO_DEVICE *PciDevice)
 
BOOLEAN IsRejectiveDevice (IN PCI_RESOURCE_NODE *PciResNode)
 
PCI_RESOURCE_NODEGetLargerConsumerDevice (IN PCI_RESOURCE_NODE *PciResNode1, IN PCI_RESOURCE_NODE *PciResNode2)
 
PCI_RESOURCE_NODEGetMaxResourceConsumerDevice (IN PCI_RESOURCE_NODE *ResPool)
 
EFI_STATUS PciHostBridgeAdjustAllocation (IN PCI_RESOURCE_NODE *IoPool, IN PCI_RESOURCE_NODE *Mem32Pool, IN PCI_RESOURCE_NODE *PMem32Pool, IN PCI_RESOURCE_NODE *Mem64Pool, IN PCI_RESOURCE_NODE *PMem64Pool, IN UINT64 IoResStatus, IN UINT64 Mem32ResStatus, IN UINT64 PMem32ResStatus, IN UINT64 Mem64ResStatus, IN UINT64 PMem64ResStatus)
 
EFI_STATUS ConstructAcpiResourceRequestor (IN PCI_IO_DEVICE *Bridge, IN PCI_RESOURCE_NODE *IoNode, IN PCI_RESOURCE_NODE *Mem32Node, IN PCI_RESOURCE_NODE *PMem32Node, IN PCI_RESOURCE_NODE *Mem64Node, IN PCI_RESOURCE_NODE *PMem64Node, OUT VOID **Config)
 
VOID GetResourceBase (IN VOID *Config, OUT UINT64 *IoBase, OUT UINT64 *Mem32Base, OUT UINT64 *PMem32Base, OUT UINT64 *Mem64Base, OUT UINT64 *PMem64Base)
 
EFI_STATUS PciBridgeEnumerator (IN PCI_IO_DEVICE *BridgeDev)
 
EFI_STATUS PciBridgeResourceAllocator (IN PCI_IO_DEVICE *Bridge)
 
EFI_STATUS GetResourceBaseFromBridge (IN PCI_IO_DEVICE *Bridge, OUT UINT64 *IoBase, OUT UINT64 *Mem32Base, OUT UINT64 *PMem32Base, OUT UINT64 *Mem64Base, OUT UINT64 *PMem64Base)
 
EFI_STATUS NotifyPhase (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc, EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase)
 
EFI_STATUS PreprocessController (IN PCI_IO_DEVICE *Bridge, IN UINT8 Bus, IN UINT8 Device, IN UINT8 Func, IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase)
 
EFI_STATUS EFIAPI PciHotPlugRequestNotify (IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL *This, IN EFI_PCI_HOTPLUG_OPERATION Operation, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL, IN OUT UINT8 *NumberOfChildren, IN OUT EFI_HANDLE *ChildHandleBuffer)
 
BOOLEAN SearchHostBridgeHandle (IN EFI_HANDLE RootBridgeHandle)
 
EFI_STATUS AddHostBridgeEnumerator (IN EFI_HANDLE HostBridgeHandle)
 

Detailed Description

PCI eunmeration implementation on entire PCI bus system for PCI Bus module.

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PciEnumerator.c.

Function Documentation

◆ AddHostBridgeEnumerator()

EFI_STATUS AddHostBridgeEnumerator ( IN EFI_HANDLE  HostBridgeHandle)

Add host bridge handle to global variable for enumerating.

Parameters
HostBridgeHandleHost bridge handle.
Return values
EFI_SUCCESSSuccessfully added host bridge.
EFI_ABORTEDHost bridge is NULL, or given host bridge has been in host bridge list.

Definition at line 2171 of file PciEnumerator.c.

◆ ConstructAcpiResourceRequestor()

EFI_STATUS ConstructAcpiResourceRequestor ( IN PCI_IO_DEVICE Bridge,
IN PCI_RESOURCE_NODE IoNode,
IN PCI_RESOURCE_NODE Mem32Node,
IN PCI_RESOURCE_NODE PMem32Node,
IN PCI_RESOURCE_NODE Mem64Node,
IN PCI_RESOURCE_NODE PMem64Node,
OUT VOID **  Config 
)

Summary requests for all resource type, and construct ACPI resource requestor instance.

Parameters
Bridgedetecting bridge
IoNodePointer to instance of I/O resource Node
Mem32NodePointer to instance of 32-bit memory resource Node
PMem32NodePointer to instance of 32-bit Pmemory resource node
Mem64NodePointer to instance of 64-bit memory resource node
PMem64NodePointer to instance of 64-bit Pmemory resource node
ConfigOutput buffer holding new constructed APCI resource requestor
Return values
EFI_SUCCESSSuccessfully constructed ACPI resource.
EFI_OUT_OF_RESOURCESNo memory available.

Definition at line 1056 of file PciEnumerator.c.

◆ DetermineRootBridgeAttributes()

EFI_STATUS DetermineRootBridgeAttributes ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc,
IN PCI_IO_DEVICE RootBridgeDev 
)

This routine is used to determine the root bridge attribute by interfacing the host bridge resource allocation protocol.

Parameters
PciResAllocProtocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
RootBridgeDevRoot bridge instance
Return values
EFI_SUCCESSSuccessfully got root bridge's attribute.
otherFailed to get attribute.

Definition at line 469 of file PciEnumerator.c.

◆ GetLargerConsumerDevice()

PCI_RESOURCE_NODE * GetLargerConsumerDevice ( IN PCI_RESOURCE_NODE PciResNode1,
IN PCI_RESOURCE_NODE PciResNode2 
)

Compare two resource nodes and get the larger resource consumer.

Parameters
PciResNode1resource node 1 want to be compared
PciResNode2resource node 2 want to be compared
Returns
Larger resource node.

Definition at line 825 of file PciEnumerator.c.

◆ GetMaxOptionRomSize()

UINT32 GetMaxOptionRomSize ( IN PCI_IO_DEVICE Bridge)

Get Max Option Rom size on specified bridge.

Parameters
BridgeGiven bridge device instance.
Returns
Max size of option rom needed.

Definition at line 523 of file PciEnumerator.c.

◆ GetMaxResourceConsumerDevice()

PCI_RESOURCE_NODE * GetMaxResourceConsumerDevice ( IN PCI_RESOURCE_NODE ResPool)

Get the max resource consumer in the host resource pool.

Parameters
ResPoolPointer to resource pool node.
Returns
The max resource consumer in the host resource pool.

Definition at line 860 of file PciEnumerator.c.

◆ GetResourceAllocationStatus()

VOID GetResourceAllocationStatus ( VOID *  AcpiConfig,
OUT UINT64 *  IoResStatus,
OUT UINT64 *  Mem32ResStatus,
OUT UINT64 *  PMem32ResStatus,
OUT UINT64 *  Mem64ResStatus,
OUT UINT64 *  PMem64ResStatus 
)

Get resource allocation status from the ACPI resource descriptor.

Parameters
AcpiConfigPoint to Acpi configuration table.
IoResStatusReturn the status of I/O resource.
Mem32ResStatusReturn the status of 32-bit Memory resource.
PMem32ResStatusReturn the status of 32-bit Prefetchable Memory resource.
Mem64ResStatusReturn the status of 64-bit Memory resource.
PMem64ResStatusReturn the status of 64-bit Prefetchable Memory resource.

Definition at line 628 of file PciEnumerator.c.

◆ GetResourceBase()

VOID GetResourceBase ( IN VOID *  Config,
OUT UINT64 *  IoBase,
OUT UINT64 *  Mem32Base,
OUT UINT64 *  PMem32Base,
OUT UINT64 *  Mem64Base,
OUT UINT64 *  PMem64Base 
)

Get resource base from an acpi configuration descriptor.

Parameters
ConfigAn acpi configuration descriptor.
IoBaseOutput of I/O resource base address.
Mem32BaseOutput of 32-bit memory base address.
PMem32BaseOutput of 32-bit prefetchable memory base address.
Mem64BaseOutput of 64-bit memory base address.
PMem64BaseOutput of 64-bit prefetchable memory base address.

Definition at line 1283 of file PciEnumerator.c.

◆ GetResourceBaseFromBridge()

EFI_STATUS GetResourceBaseFromBridge ( IN PCI_IO_DEVICE Bridge,
OUT UINT64 *  IoBase,
OUT UINT64 *  Mem32Base,
OUT UINT64 *  PMem32Base,
OUT UINT64 *  Mem64Base,
OUT UINT64 *  PMem64Base 
)

Get resource base address for a pci bridge device.

Parameters
BridgeGiven Pci driver instance.
IoBaseOutput for base address of I/O type resource.
Mem32BaseOutput for base address of 32-bit memory type resource.
PMem32BaseOoutput for base address of 32-bit Pmemory type resource.
Mem64BaseOutput for base address of 64-bit memory type resource.
PMem64BaseOutput for base address of 64-bit Pmemory type resource.
Return values
EFI_SUCCESSSuccessfully got resource base address.
EFI_OUT_OF_RESOURCESPCI bridge is not available.

Definition at line 1588 of file PciEnumerator.c.

◆ IsRejectiveDevice()

BOOLEAN IsRejectiveDevice ( IN PCI_RESOURCE_NODE PciResNode)

Determine whethter a PCI device can be rejected.

Parameters
PciResNodePointer to Pci resource node instance.
Return values
TRUEThe PCI device can be rejected.
TRUEThe PCI device cannot be rejected.

Definition at line 776 of file PciEnumerator.c.

◆ NotifyPhase()

These are the notifications from the PCI bus driver that it is about to enter a certain phase of the PCI enumeration process.

This member function can be used to notify the host bridge driver to perform specific actions, including any chipset-specific initialization, so that the chipset is ready to enter the next phase. Eight notification points are defined at this time. See belows: EfiPciHostBridgeBeginEnumeration Resets the host bridge PCI apertures and internal data structures. The PCI enumerator should issue this notification before starting a fresh enumeration process. Enumeration cannot be restarted after sending any other notification such as EfiPciHostBridgeBeginBusAllocation. EfiPciHostBridgeBeginBusAllocation The bus allocation phase is about to begin. No specific action is required here. This notification can be used to perform any chipset-specific programming. EfiPciHostBridgeEndBusAllocation The bus allocation and bus programming phase is complete. No specific action is required here. This notification can be used to perform any chipset-specific programming. EfiPciHostBridgeBeginResourceAllocation The resource allocation phase is about to begin. No specific action is required here. This notification can be used to perform any chipset-specific programming. EfiPciHostBridgeAllocateResources Allocates resources per previously submitted requests for all the PCI root bridges. These resource settings are returned on the next call to GetProposedResources(). Before calling NotifyPhase() with a Phase of EfiPciHostBridgeAllocateResource, the PCI bus enumerator is responsible for gathering I/O and memory requests for all the PCI root bridges and submitting these requests using SubmitResources(). This function pads the resource amount to suit the root bridge hardware, takes care of dependencies between the PCI root bridges, and calls the Global Coherency Domain (GCD) with the allocation request. In the case of padding, the allocated range could be bigger than what was requested. EfiPciHostBridgeSetResources Programs the host bridge hardware to decode previously allocated resources (proposed resources) for all the PCI root bridges. After the hardware is programmed, reassigning resources will not be supported. The bus settings are not affected. EfiPciHostBridgeFreeResources Deallocates resources that were previously allocated for all the PCI root bridges and resets the I/O and memory apertures to their initial state. The bus settings are not affected. If the request to allocate resources fails, the PCI enumerator can use this notification to deallocate previous resources, adjust the requests, and retry allocation. EfiPciHostBridgeEndResourceAllocation The resource allocation phase is completed. No specific action is required here. This notification can be used to perform any chipsetspecific programming.

Parameters
[in]PciResAllocThe instance pointer of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL
[in]PhaseThe phase during enumeration
Return values
EFI_NOT_READYThis phase cannot be entered at this time. For example, this error is valid for a Phase of EfiPciHostBridgeAllocateResources if SubmitResources() has not been called for one or more PCI root bridges before this call
EFI_DEVICE_ERRORProgramming failed due to a hardware error. This error is valid for a Phase of EfiPciHostBridgeSetResources.
EFI_INVALID_PARAMETERInvalid phase parameter
EFI_OUT_OF_RESOURCESThe request could not be completed due to a lack of resources. This error is valid for a Phase of EfiPciHostBridgeAllocateResources if the previously submitted resource requests cannot be fulfilled or were only partially fulfilled.
EFI_SUCCESSThe notification was accepted without any errors.

Definition at line 1725 of file PciEnumerator.c.

◆ PciAssignBusNumber()

EFI_STATUS PciAssignBusNumber ( IN PCI_IO_DEVICE Bridge,
IN UINT8  StartBusNumber,
OUT UINT8 *  SubBusNumber 
)

This routine is used to assign bus number to the given PCI bus system

Parameters
BridgeParent root bridge instance.
StartBusNumberNumber of beginning.
SubBusNumberThe number of sub bus.
Return values
EFI_SUCCESSSuccessfully assigned bus number.
EFI_DEVICE_ERRORFailed to assign bus number.

Definition at line 325 of file PciEnumerator.c.

◆ PciBridgeEnumerator()

EFI_STATUS PciBridgeEnumerator ( IN PCI_IO_DEVICE BridgeDev)

Enumerate pci bridge, allocate resource and determine attribute for devices on this bridge.

Parameters
BridgeDevPointer to instance of bridge device.
Return values
EFI_SUCCESSSuccessfully enumerated PCI bridge.
otherFailed to enumerate.

Definition at line 1373 of file PciEnumerator.c.

◆ PciBridgeResourceAllocator()

EFI_STATUS PciBridgeResourceAllocator ( IN PCI_IO_DEVICE Bridge)

Allocate all kinds of resource for PCI bridge.

Parameters
BridgePointer to bridge instance.
Return values
EFI_SUCCESSSuccessfully allocated resource for PCI bridge.
otherFailed to allocate resource for bridge.

Definition at line 1432 of file PciEnumerator.c.

◆ PciEnumerator()

EFI_STATUS PciEnumerator ( IN EFI_HANDLE  Controller,
IN EFI_HANDLE  HostBridgeHandle 
)

This routine is used to enumerate entire pci bus system in a given platform.

Parameters
ControllerParent controller handle.
HostBridgeHandleHost bridge handle.
Return values
EFI_SUCCESSPCI enumeration finished successfully.
otherSome error occurred when enumerating the pci bus system.

Definition at line 24 of file PciEnumerator.c.

◆ PciHostBridgeAdjustAllocation()

EFI_STATUS PciHostBridgeAdjustAllocation ( IN PCI_RESOURCE_NODE IoPool,
IN PCI_RESOURCE_NODE Mem32Pool,
IN PCI_RESOURCE_NODE PMem32Pool,
IN PCI_RESOURCE_NODE Mem64Pool,
IN PCI_RESOURCE_NODE PMem64Pool,
IN UINT64  IoResStatus,
IN UINT64  Mem32ResStatus,
IN UINT64  PMem32ResStatus,
IN UINT64  Mem64ResStatus,
IN UINT64  PMem64ResStatus 
)

Adjust host bridge allocation so as to reduce resource requirement

Parameters
IoPoolPointer to instance of I/O resource Node.
Mem32PoolPointer to instance of 32-bit memory resource Node.
PMem32PoolPointer to instance of 32-bit Prefetchable memory resource node.
Mem64PoolPointer to instance of 64-bit memory resource node.
PMem64PoolPointer to instance of 64-bit Prefetchable memory resource node.
IoResStatusStatus of I/O resource Node.
Mem32ResStatusStatus of 32-bit memory resource Node.
PMem32ResStatusStatus of 32-bit Prefetchable memory resource node.
Mem64ResStatusStatus of 64-bit memory resource node.
PMem64ResStatusStatus of 64-bit Prefetchable memory resource node.
Return values
EFI_SUCCESSSuccessfully adjusted resource on host bridge.
EFI_ABORTEDHost bridge hasn't this resource type or no resource be adjusted.

Definition at line 914 of file PciEnumerator.c.

◆ PciHostBridgeDeviceAttribute()

EFI_STATUS PciHostBridgeDeviceAttribute ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc)

Process attributes of devices on this host bridge

Parameters
PciResAllocProtocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
Return values
EFI_SUCCESSSuccessfully process attribute.
EFI_NOT_FOUNDCan not find the specific root bridge device.
otherFailed to determine the root bridge device's attribute.

Definition at line 584 of file PciEnumerator.c.

◆ PciHotPlugRequestNotify()

EFI_STATUS EFIAPI PciHotPlugRequestNotify ( IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL This,
IN EFI_PCI_HOTPLUG_OPERATION  Operation,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath  OPTIONAL,
IN OUT UINT8 *  NumberOfChildren,
IN OUT EFI_HANDLE ChildHandleBuffer 
)

This function allows the PCI bus driver to be notified to act as requested when a hot-plug event has happened on the hot-plug controller. Currently, the operations include add operation and remove operation..

Parameters
ThisA pointer to the hot plug request protocol.
OperationThe operation the PCI bus driver is requested to make.
ControllerThe handle of the hot-plug controller.
RemainingDevicePathThe remaining device path for the PCI-like hot-plug device.
NumberOfChildrenThe number of child handles. For a add operation, it is an output parameter. For a remove operation, it's an input parameter.
ChildHandleBufferThe buffer which contains the child handles.
Return values
EFI_INVALID_PARAMETEROperation is not a legal value. Controller is NULL or not a valid handle. NumberOfChildren is NULL. ChildHandleBuffer is NULL while Operation is add.
EFI_OUT_OF_RESOURCESThere are no enough resources to start the devices.
EFI_NOT_FOUNDCan not find bridge according to controller handle.
EFI_SUCCESSThe handles for the specified device have been created or destroyed as requested, and for an add operation, the new handles are returned in ChildHandleBuffer.

Definition at line 1991 of file PciEnumerator.c.

◆ PciRootBridgeEnumerator()

EFI_STATUS PciRootBridgeEnumerator ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc,
IN PCI_IO_DEVICE RootBridgeDev 
)

Enumerate PCI root bridge.

Parameters
PciResAllocPointer to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
RootBridgeDevInstance of root bridge device.
Return values
EFI_SUCCESSSuccessfully enumerated root bridge.
otherFailed to enumerate root bridge.

Definition at line 115 of file PciEnumerator.c.

◆ PreprocessController()

EFI_STATUS PreprocessController ( IN PCI_IO_DEVICE Bridge,
IN UINT8  Bus,
IN UINT8  Device,
IN UINT8  Func,
IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE  Phase 
)

Provides the hooks from the PCI bus driver to every PCI controller (device/function) at various stages of the PCI enumeration process that allow the host bridge driver to preinitialize individual PCI controllers before enumeration.

This function is called during the PCI enumeration process. No specific action is expected from this member function. It allows the host bridge driver to preinitialize individual PCI controllers before enumeration.

Parameters
BridgePointer to the EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.
BusThe bus number of the pci device.
DeviceThe device number of the pci device.
FuncThe function number of the pci device.
PhaseThe phase of the PCI device enumeration.
Return values
EFI_SUCCESSThe requested parameters were returned.
EFI_INVALID_PARAMETERRootBridgeHandle is not a valid root bridge handle.
EFI_INVALID_PARAMETERPhase is not a valid phase that is defined in EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE.
EFI_DEVICE_ERRORProgramming failed due to a hardware error. The PCI enumerator should not enumerate this device, including its child devices if it is a PCI-to-PCI bridge.

Definition at line 1854 of file PciEnumerator.c.

◆ ProcessOptionRom()

VOID ProcessOptionRom ( IN PCI_IO_DEVICE Bridge,
IN UINT64  RomBase,
IN UINT64  MaxLength 
)

This routine is used to process all PCI devices' Option Rom on a certain root bridge.

Parameters
BridgeGiven parent's root bridge.
RomBaseBase address of ROM driver loaded from.
MaxLengthMaximum rom size.

Definition at line 280 of file PciEnumerator.c.

◆ RejectPciDevice()

EFI_STATUS RejectPciDevice ( IN PCI_IO_DEVICE PciDevice)

Remove a PCI device from device pool and mark its bar.

Parameters
PciDeviceInstance of Pci device.
Return values
EFI_SUCCESSSuccessfully remove the PCI device.
EFI_ABORTEDPci device is a root bridge or a PCI-PCI bridge.

Definition at line 704 of file PciEnumerator.c.

◆ SearchHostBridgeHandle()

BOOLEAN SearchHostBridgeHandle ( IN EFI_HANDLE  RootBridgeHandle)

Search hostbridge according to given handle

Parameters
RootBridgeHandleHost bridge handle.
Return values
TRUEFound host bridge handle.
FALSENot found hot bridge handle.

Definition at line 2125 of file PciEnumerator.c.