TianoCore EDK2 master
Loading...
Searching...
No Matches
PciResourceSupport.h File Reference

Go to the source code of this file.

Data Structures

struct  PCI_RESOURCE_NODE
 

Macros

#define PCI_RESOURCE_SIGNATURE   SIGNATURE_32 ('p', 'c', 'r', 'c')
 
#define RESOURCE_NODE_FROM_LINK(a)    CR (a, PCI_RESOURCE_NODE, Link, PCI_RESOURCE_SIGNATURE)
 

Enumerations

enum  PCI_RESOURCE_USAGE { PciResUsageTypical , PciResUsagePadding }
 

Functions

VOID SkipVGAAperture (OUT UINT64 *Start, IN UINT64 Length)
 
VOID SkipIsaAliasAperture (OUT UINT64 *Start, IN UINT64 Length)
 
VOID InsertResourceNode (IN OUT PCI_RESOURCE_NODE *Bridge, IN PCI_RESOURCE_NODE *ResNode)
 
VOID MergeResourceTree (IN PCI_RESOURCE_NODE *Dst, IN PCI_RESOURCE_NODE *Res, IN BOOLEAN TypeMerge)
 
VOID CalculateApertureIo16 (IN PCI_RESOURCE_NODE *Bridge)
 
VOID CalculateResourceAperture (IN PCI_RESOURCE_NODE *Bridge)
 
VOID GetResourceFromDevice (IN PCI_IO_DEVICE *PciDev, IN OUT PCI_RESOURCE_NODE *IoNode, IN OUT PCI_RESOURCE_NODE *Mem32Node, IN OUT PCI_RESOURCE_NODE *PMem32Node, IN OUT PCI_RESOURCE_NODE *Mem64Node, IN OUT PCI_RESOURCE_NODE *PMem64Node)
 
PCI_RESOURCE_NODECreateResourceNode (IN PCI_IO_DEVICE *PciDev, IN UINT64 Length, IN UINT64 Alignment, IN UINT8 Bar, IN PCI_BAR_TYPE ResType, IN PCI_RESOURCE_USAGE ResUsage)
 
PCI_RESOURCE_NODECreateVfResourceNode (IN PCI_IO_DEVICE *PciDev, IN UINT64 Length, IN UINT64 Alignment, IN UINT8 Bar, IN PCI_BAR_TYPE ResType, IN PCI_RESOURCE_USAGE ResUsage)
 
VOID CreateResourceMap (IN PCI_IO_DEVICE *Bridge, IN OUT PCI_RESOURCE_NODE *IoNode, IN OUT PCI_RESOURCE_NODE *Mem32Node, IN OUT PCI_RESOURCE_NODE *PMem32Node, IN OUT PCI_RESOURCE_NODE *Mem64Node, IN OUT PCI_RESOURCE_NODE *PMem64Node)
 
VOID ResourcePaddingPolicy (IN PCI_IO_DEVICE *PciDev, 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)
 
VOID DegradeResource (IN PCI_IO_DEVICE *Bridge, IN PCI_RESOURCE_NODE *Mem32Node, IN PCI_RESOURCE_NODE *PMem32Node, IN PCI_RESOURCE_NODE *Mem64Node, IN PCI_RESOURCE_NODE *PMem64Node)
 
BOOLEAN BridgeSupportResourceDecode (IN PCI_IO_DEVICE *Bridge, IN UINT32 Decode)
 
EFI_STATUS ProgramResource (IN UINT64 Base, IN PCI_RESOURCE_NODE *Bridge)
 
VOID ProgramBar (IN UINT64 Base, IN PCI_RESOURCE_NODE *Node)
 
EFI_STATUS ProgramVfBar (IN UINT64 Base, IN PCI_RESOURCE_NODE *Node)
 
VOID ProgramPpbApperture (IN UINT64 Base, IN PCI_RESOURCE_NODE *Node)
 
VOID ProgramUpstreamBridgeForRom (IN PCI_IO_DEVICE *PciDevice, IN UINT32 OptionRomBase, IN BOOLEAN Enable)
 
BOOLEAN ResourceRequestExisted (IN PCI_RESOURCE_NODE *Bridge)
 
VOID InitializeResourcePool (IN OUT PCI_RESOURCE_NODE *ResourcePool, IN PCI_BAR_TYPE ResourceType)
 
VOID DestroyResourceTree (IN PCI_RESOURCE_NODE *Bridge)
 
VOID ResourcePaddingForCardBusBridge (IN PCI_IO_DEVICE *PciDev, 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)
 
VOID ProgramP2C (IN UINT64 Base, IN PCI_RESOURCE_NODE *Node)
 
VOID ApplyResourcePadding (IN PCI_IO_DEVICE *PciDev, 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)
 
VOID GetResourcePaddingPpb (IN PCI_IO_DEVICE *PciIoDevice)
 

Detailed Description

PCI resources support functions declaration for PCI Bus module.

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PciResourceSupport.h.

Macro Definition Documentation

◆ PCI_RESOURCE_SIGNATURE

#define PCI_RESOURCE_SIGNATURE   SIGNATURE_32 ('p', 'c', 'r', 'c')

Definition at line 17 of file PciResourceSupport.h.

◆ RESOURCE_NODE_FROM_LINK

#define RESOURCE_NODE_FROM_LINK (   a)     CR (a, PCI_RESOURCE_NODE, Link, PCI_RESOURCE_SIGNATURE)

Definition at line 34 of file PciResourceSupport.h.

Enumeration Type Documentation

◆ PCI_RESOURCE_USAGE

enum PCI_RESOURCE_USAGE

Definition at line 12 of file PciResourceSupport.h.

Function Documentation

◆ ApplyResourcePadding()

VOID ApplyResourcePadding ( IN PCI_IO_DEVICE PciDev,
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 
)

Create padding resource node.

Parameters
PciDevPci device instance.
IoNodeResource info node for IO.
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 2118 of file PciResourceSupport.c.

◆ BridgeSupportResourceDecode()

BOOLEAN BridgeSupportResourceDecode ( IN PCI_IO_DEVICE Bridge,
IN UINT32  Decode 
)

Test whether bridge device support decode resource.

Parameters
BridgeBridge device instance.
DecodeDecode type according to resource type.
Returns
TRUE The bridge device support decode resource.
FALSE The bridge device don't support decode resource.

Definition at line 1174 of file PciResourceSupport.c.

◆ CalculateApertureIo16()

VOID CalculateApertureIo16 ( IN PCI_RESOURCE_NODE Bridge)

This function is used to calculate the IO16 aperture for a bridge.

Parameters
BridgePCI resource node for bridge.

Definition at line 181 of file PciResourceSupport.c.

◆ CalculateResourceAperture()

VOID CalculateResourceAperture ( IN PCI_RESOURCE_NODE Bridge)

This function is used to calculate the resource aperture for a given bridge device.

Parameters
BridgePCI resource node for given bridge device.

Definition at line 335 of file PciResourceSupport.c.

◆ CreateResourceMap()

VOID CreateResourceMap ( IN PCI_IO_DEVICE Bridge,
IN OUT PCI_RESOURCE_NODE IoNode,
IN OUT PCI_RESOURCE_NODE Mem32Node,
IN OUT PCI_RESOURCE_NODE PMem32Node,
IN OUT PCI_RESOURCE_NODE Mem64Node,
IN OUT PCI_RESOURCE_NODE PMem64Node 
)

This function is used to extract resource request from device node list.

Parameters
BridgePci device instance.
IoNodeResource info node for IO.
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 735 of file PciResourceSupport.c.

◆ CreateResourceNode()

PCI_RESOURCE_NODE * CreateResourceNode ( IN PCI_IO_DEVICE PciDev,
IN UINT64  Length,
IN UINT64  Alignment,
IN UINT8  Bar,
IN PCI_BAR_TYPE  ResType,
IN PCI_RESOURCE_USAGE  ResUsage 
)

This function is used to create a resource node.

Parameters
PciDevPci device instance.
LengthLength of Io/Memory resource.
AlignmentAlignment of resource.
BarBar index.
ResTypeType of resource: IO/Memory.
ResUsageResource usage.
Returns
PCI resource node created for given PCI device. NULL means PCI resource node is not created.

Definition at line 654 of file PciResourceSupport.c.

◆ CreateVfResourceNode()

PCI_RESOURCE_NODE * CreateVfResourceNode ( IN PCI_IO_DEVICE PciDev,
IN UINT64  Length,
IN UINT64  Alignment,
IN UINT8  Bar,
IN PCI_BAR_TYPE  ResType,
IN PCI_RESOURCE_USAGE  ResUsage 
)

This function is used to create a IOV VF resource node.

Parameters
PciDevPci device instance.
LengthLength of Io/Memory resource.
AlignmentAlignment of resource.
BarBar index.
ResTypeType of resource: IO/Memory.
ResUsageResource usage.
Returns
PCI resource node created for given VF PCI device. NULL means PCI resource node is not created.

Definition at line 701 of file PciResourceSupport.c.

◆ DegradeResource()

VOID DegradeResource ( IN PCI_IO_DEVICE Bridge,
IN PCI_RESOURCE_NODE Mem32Node,
IN PCI_RESOURCE_NODE PMem32Node,
IN PCI_RESOURCE_NODE Mem64Node,
IN PCI_RESOURCE_NODE PMem64Node 
)

This function is used to degrade resource if the upstream bridge doesn't support certain resource. Degradation path is PMEM64 -> MEM64 -> MEM32 PMEM64 -> PMEM32 -> MEM32 IO32 -> IO16.

Parameters
BridgePci device instance.
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 1011 of file PciResourceSupport.c.

◆ DestroyResourceTree()

VOID DestroyResourceTree ( IN PCI_RESOURCE_NODE Bridge)

Destroy given resource tree.

Parameters
BridgePCI resource root node of resource tree.

Definition at line 1756 of file PciResourceSupport.c.

◆ GetResourceFromDevice()

VOID GetResourceFromDevice ( IN PCI_IO_DEVICE PciDev,
IN OUT PCI_RESOURCE_NODE IoNode,
IN OUT PCI_RESOURCE_NODE Mem32Node,
IN OUT PCI_RESOURCE_NODE PMem32Node,
IN OUT PCI_RESOURCE_NODE Mem64Node,
IN OUT PCI_RESOURCE_NODE PMem64Node 
)

Get IO/Memory resource info for given PCI device.

Parameters
PciDevPci device instance.
IoNodeResource info node for IO .
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 422 of file PciResourceSupport.c.

◆ GetResourcePaddingPpb()

VOID GetResourcePaddingPpb ( IN PCI_IO_DEVICE PciIoDevice)

Get padding resource for PCI-PCI bridge.

Parameters
PciIoDevicePCI-PCI bridge device instance.
Note
Feature flag PcdPciBusHotplugDeviceSupport determines whether need to pad resource for them.

Definition at line 2266 of file PciResourceSupport.c.

◆ InitializeResourcePool()

VOID InitializeResourcePool ( IN OUT PCI_RESOURCE_NODE ResourcePool,
IN PCI_BAR_TYPE  ResourceType 
)

Initialize resource pool structure.

Parameters
ResourcePoolPoint to resource pool structure. This pool is reset to all zero when returned.
ResourceTypeType of resource.

Definition at line 1738 of file PciResourceSupport.c.

◆ InsertResourceNode()

VOID InsertResourceNode ( IN OUT PCI_RESOURCE_NODE Bridge,
IN PCI_RESOURCE_NODE ResNode 
)

This function inserts a resource node into the resource list. The resource list is sorted in descend order.

Parameters
BridgePCI resource node for bridge.
ResNodeResource node want to be inserted.

Definition at line 93 of file PciResourceSupport.c.

◆ MergeResourceTree()

VOID MergeResourceTree ( IN PCI_RESOURCE_NODE Dst,
IN PCI_RESOURCE_NODE Res,
IN BOOLEAN  TypeMerge 
)

This routine is used to merge two different resource trees in need of resource degradation.

For example, if an upstream PPB doesn't support, prefetchable memory decoding, the PCI bus driver will choose to call this function to merge prefetchable memory resource list into normal memory list.

If the TypeMerge is TRUE, Res resource type is changed to the type of destination resource type. If Dst is NULL or Res is NULL, ASSERT ().

Parameters
DstPoint to destination resource tree.
ResPoint to source resource tree.
TypeMergeIf the TypeMerge is TRUE, Res resource type is changed to the type of destination resource type.

Definition at line 147 of file PciResourceSupport.c.

◆ ProgramBar()

VOID ProgramBar ( IN UINT64  Base,
IN PCI_RESOURCE_NODE Node 
)

Program Bar register for PCI device.

Parameters
BaseBase address for PCI device resource to be programmed.
NodePoint to resource node structure.

Definition at line 1255 of file PciResourceSupport.c.

◆ ProgramP2C()

VOID ProgramP2C ( IN UINT64  Base,
IN PCI_RESOURCE_NODE Node 
)

Program PCI Card device register for given resource node.

Parameters
BaseBase address of PCI Card device to be programmed.
NodeGiven resource node.

Definition at line 1885 of file PciResourceSupport.c.

◆ ProgramPpbApperture()

VOID ProgramPpbApperture ( IN UINT64  Base,
IN PCI_RESOURCE_NODE Node 
)

Program PCI-PCI bridge aperture.

Parameters
BaseBase address for resource.
NodePoint to resource node structure.

Definition at line 1436 of file PciResourceSupport.c.

◆ ProgramResource()

EFI_STATUS ProgramResource ( IN UINT64  Base,
IN PCI_RESOURCE_NODE Bridge 
)

This function is used to program the resource allocated for each resource node under specified bridge.

Parameters
BaseBase address of resource to be programmed.
BridgePCI resource node for the bridge device.
Return values
EFI_SUCCESSSuccessfully to program all resources on given PCI bridge device.
EFI_OUT_OF_RESOURCESBase is all one.

Definition at line 1199 of file PciResourceSupport.c.

◆ ProgramUpstreamBridgeForRom()

VOID ProgramUpstreamBridgeForRom ( IN PCI_IO_DEVICE PciDevice,
IN UINT32  OptionRomBase,
IN BOOLEAN  Enable 
)

Program parent bridge for Option Rom.

Parameters
PciDevicePci device instance.
OptionRomBaseBase address for Option Rom.
EnableEnable or disable PCI memory.

Definition at line 1645 of file PciResourceSupport.c.

◆ ProgramVfBar()

EFI_STATUS ProgramVfBar ( IN UINT64  Base,
IN PCI_RESOURCE_NODE Node 
)

Program IOV VF Bar register for PCI device.

Parameters
BaseBase address for PCI device resource to be programmed.
NodePoint to resource node structure.

Definition at line 1351 of file PciResourceSupport.c.

◆ ResourcePaddingForCardBusBridge()

VOID ResourcePaddingForCardBusBridge ( IN PCI_IO_DEVICE PciDev,
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 
)

Insert resource padding for P2C.

Parameters
PciDevPci device instance.
IoNodeResource info node for IO.
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 1791 of file PciResourceSupport.c.

◆ ResourcePaddingPolicy()

VOID ResourcePaddingPolicy ( IN PCI_IO_DEVICE PciDev,
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 
)

This function is used to do the resource padding for a specific platform.

Parameters
PciDevPci device instance.
IoNodeResource info node for IO.
Mem32NodeResource info node for 32-bit memory.
PMem32NodeResource info node for 32-bit Prefetchable Memory.
Mem64NodeResource info node for 64-bit memory.
PMem64NodeResource info node for 64-bit Prefetchable Memory.

Definition at line 972 of file PciResourceSupport.c.

◆ ResourceRequestExisted()

BOOLEAN ResourceRequestExisted ( IN PCI_RESOURCE_NODE Bridge)

Test whether resource exists for a bridge.

Parameters
BridgePoint to resource node for a bridge.
Return values
TRUEThere is resource on the given bridge.
FALSEThere isn't resource on the given bridge.

Definition at line 1716 of file PciResourceSupport.c.

◆ SkipIsaAliasAperture()

VOID SkipIsaAliasAperture ( OUT UINT64 *  Start,
IN UINT64  Length 
)

This function is used to skip ISA aliasing aperture.

Parameters
StartReturned start address including ISA aliasing aperture.
LengthThe length of ISA aliasing aperture.

Definition at line 58 of file PciResourceSupport.c.

◆ SkipVGAAperture()

VOID SkipVGAAperture ( OUT UINT64 *  Start,
IN UINT64  Length 
)

The function is used to skip VGA range.

Parameters
StartReturned start address including VGA range.
LengthThe length of VGA range.

Definition at line 26 of file PciResourceSupport.c.