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

Go to the source code of this file.

Functions

UINT16 PciGetMaxBusNumber (IN PCI_IO_DEVICE *Bridge)
 
VOID GetBackPcCardBar (IN PCI_IO_DEVICE *PciIoDevice)
 
VOID RemoveRejectedPciDevices (IN EFI_HANDLE RootBridgeHandle, IN PCI_IO_DEVICE *Bridge)
 
VOID DumpBridgeResource (IN PCI_RESOURCE_NODE *BridgeResource)
 
UINTN FindResourceNode (IN PCI_IO_DEVICE *Device, IN PCI_RESOURCE_NODE *BridgeResource, OUT PCI_RESOURCE_NODE **DeviceResources OPTIONAL)
 
VOID DumpResourceMap (IN PCI_IO_DEVICE *Bridge, IN PCI_RESOURCE_NODE **Resources, IN UINTN ResourceCount)
 
BOOLEAN AdjustPciDeviceBarSize (IN PCI_IO_DEVICE *RootBridgeDev)
 
EFI_STATUS PciHostBridgeResourceAllocator (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
 
EFI_STATUS PciAllocateBusNumber (IN PCI_IO_DEVICE *Bridge, IN UINT8 StartBusNumber, IN UINT8 NumberOfBuses, OUT UINT8 *NextBusNumber)
 
EFI_STATUS PciScanBus (IN PCI_IO_DEVICE *Bridge, IN UINT8 StartBusNumber, OUT UINT8 *SubBusNumber, OUT UINT8 *PaddedBusRange)
 
EFI_STATUS PciRootBridgeP2CProcess (IN PCI_IO_DEVICE *Bridge)
 
EFI_STATUS PciHostBridgeP2CProcess (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
 
EFI_STATUS PciHostBridgeEnumerator (IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *PciResAlloc)
 
EFI_STATUS PciProgramResizableBar (IN PCI_IO_DEVICE *PciIoDevice, IN PCI_RESIZABLE_BAR_OPERATION ResizableBarOp)
 

Variables

GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 * mBarTypeStr []
 

Detailed Description

Internal library implementation for PCI Bus module.

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

Definition in file PciLib.c.

Function Documentation

◆ AdjustPciDeviceBarSize()

BOOLEAN AdjustPciDeviceBarSize ( IN PCI_IO_DEVICE RootBridgeDev)

Adjust the Devices' BAR size to minimum value if it support Resizeable BAR capability.

Parameters
RootBridgeDevPointer to instance of PCI_IO_DEVICE..
Returns
TRUE if BAR size is adjusted.

Definition at line 405 of file PciLib.c.

◆ DumpBridgeResource()

VOID DumpBridgeResource ( IN PCI_RESOURCE_NODE BridgeResource)

Dump the resourc map of the bridge device.

Parameters
[in]BridgeResourceResource descriptor of the bridge device.

Definition at line 207 of file PciLib.c.

◆ DumpResourceMap()

VOID DumpResourceMap ( IN PCI_IO_DEVICE Bridge,
IN PCI_RESOURCE_NODE **  Resources,
IN UINTN  ResourceCount 
)

Dump the resource map of all the devices under Bridge.

Parameters
[in]BridgeBridge device instance.
[in]ResourcesResource descriptors for the bridge device.
[in]ResourceCountCount of resource descriptors.

Definition at line 321 of file PciLib.c.

◆ FindResourceNode()

UINTN FindResourceNode ( IN PCI_IO_DEVICE Device,
IN PCI_RESOURCE_NODE BridgeResource,
OUT PCI_RESOURCE_NODE **DeviceResources  OPTIONAL 
)

Find the corresponding resource node for the Device in child list of BridgeResource.

Parameters
[in]DevicePointer to PCI_IO_DEVICE.
[in]BridgeResourcePointer to PCI_RESOURCE_NODE.
[out]DeviceResourcesPointer to a buffer to receive resources for the Device.
Returns
Count of the resource descriptors returned.

Definition at line 284 of file PciLib.c.

◆ GetBackPcCardBar()

VOID GetBackPcCardBar ( IN PCI_IO_DEVICE PciIoDevice)

Retrieve the PCI Card device BAR information via PciIo interface.

Parameters
PciIoDevicePCI Card device instance.

Definition at line 73 of file PciLib.c.

◆ PciAllocateBusNumber()

EFI_STATUS PciAllocateBusNumber ( IN PCI_IO_DEVICE Bridge,
IN UINT8  StartBusNumber,
IN UINT8  NumberOfBuses,
OUT UINT8 *  NextBusNumber 
)

Allocate NumberOfBuses buses and return the next available PCI bus number.

Parameters
BridgeBridge device instance.
StartBusNumberCurrent available PCI bus number.
NumberOfBusesNumber of buses enumerated below the StartBusNumber.
NextBusNumberNext available PCI bus number.
Return values
EFI_SUCCESSAvailable bus number resource is enough. Next available PCI bus number is returned in NextBusNumber.
EFI_OUT_OF_RESOURCESAvailable bus number resource is not enough for allocation.

Definition at line 1019 of file PciLib.c.

◆ PciGetMaxBusNumber()

UINT16 PciGetMaxBusNumber ( IN PCI_IO_DEVICE Bridge)

Retrieve the max bus number that is assigned to the Root Bridge hierarchy. It can support the case that there are multiple bus ranges.

Parameters
BridgeBridge device instance.
Return values
Themax bus number that is assigned to this Root Bridge hierarchy.

Definition at line 37 of file PciLib.c.

◆ PciHostBridgeEnumerator()

EFI_STATUS PciHostBridgeEnumerator ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc)

This function is used to enumerate the entire host bridge in a given platform.

Parameters
PciResAllocA pointer to the PCI Host Resource Allocation protocol.
Return values
EFI_SUCCESSSuccessfully enumerated the host bridge.
EFI_OUT_OF_RESOURCESNo enough memory available.
otherSome error occurred when enumerating the host bridge.

Definition at line 1543 of file PciLib.c.

◆ PciHostBridgeP2CProcess()

EFI_STATUS PciHostBridgeP2CProcess ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc)

Process Option Rom on the specified host bridge.

Parameters
PciResAllocPointer to instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
Return values
EFI_SUCCESSSuccess process.
EFI_NOT_FOUNDCan not find the root bridge instance.
otherSome error occurred when processing Option Rom on the host bridge.

Definition at line 1498 of file PciLib.c.

◆ PciHostBridgeResourceAllocator()

EFI_STATUS PciHostBridgeResourceAllocator ( IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL PciResAlloc)

Submits the I/O and memory resource requirements for the specified PCI Host Bridge.

Parameters
PciResAllocPoint to protocol instance of EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL.
Return values
EFI_SUCCESSSuccessfully finished resource allocation.
EFI_NOT_FOUNDCannot get root bridge instance.
EFI_OUT_OF_RESOURCESPlatform failed to program the resources if no hot plug supported.
otherSome error occurred when allocating resources for the PCI Host Bridge.
Note
Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.

Definition at line 469 of file PciLib.c.

◆ PciProgramResizableBar()

EFI_STATUS PciProgramResizableBar ( IN PCI_IO_DEVICE PciIoDevice,
IN PCI_RESIZABLE_BAR_OPERATION  ResizableBarOp 
)

This function is used to program the Resizable BAR Register.

Parameters
PciIoDeviceA pointer to the PCI_IO_DEVICE.
ResizableBarOpPciResizableBarMax: Set BAR to max size PciResizableBarMin: set BAR to min size.
Return values
EFI_SUCCESSSuccessfully enumerated the host bridge.
otherSome error occurred when enumerating the host bridge.

Definition at line 1793 of file PciLib.c.

◆ PciRootBridgeP2CProcess()

EFI_STATUS PciRootBridgeP2CProcess ( IN PCI_IO_DEVICE Bridge)

Process Option Rom on the specified root bridge.

Parameters
BridgePci root bridge device instance.
Return values
EFI_SUCCESSSuccess process.
otherSome error occurred when processing Option Rom on the root bridge.

Definition at line 1429 of file PciLib.c.

◆ PciScanBus()

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

Scan pci bus and assign bus number to the given PCI bus system.

Parameters
BridgeBridge device instance.
StartBusNumberstart point.
SubBusNumberPoint to sub bus number.
PaddedBusRangeCustomized bus number.
Return values
EFI_SUCCESSSuccessfully scanned and assigned bus number.
otherSome error occurred when scanning pci bus.
Note
Feature flag PcdPciBusHotplugDeviceSupport determine whether need support hotplug.

Definition at line 1082 of file PciLib.c.

◆ RemoveRejectedPciDevices()

VOID RemoveRejectedPciDevices ( IN EFI_HANDLE  RootBridgeHandle,
IN PCI_IO_DEVICE Bridge 
)

Remove rejected pci device from specific root bridge handle.

Parameters
RootBridgeHandleSpecific parent root bridge handle.
BridgeBridge device instance.

Definition at line 151 of file PciLib.c.

Variable Documentation

◆ mBarTypeStr

GLOBAL_REMOVE_IF_UNREFERENCED CHAR16* mBarTypeStr[]
Initial value:
= {
L"Unknow",
L" Io16",
L" Io32",
L" Mem32",
L"PMem32",
L" Mem64",
L"PMem64",
L" OpRom",
L" Io",
L" Mem",
L"Unknow"
}

Definition at line 13 of file PciLib.c.