TianoCore EDK2 master
Loading...
Searching...
No Matches
HardwareInfoPciHostBridgeLib.c File Reference

Go to the source code of this file.

Macros

#define IS_RANGE_INVALID(Start, Size, MaxValue)   (Start >= MaxValue || Size == 0)
 

Functions

STATIC UINT64 GetRangeEnd (IN UINT64 Start, IN UINT64 Size, IN UINT64 MaxValue)
 
STATIC VOID UpdateLastAddressIfHigher (IN PCI_ROOT_BRIDGE_APERTURE *Mem, OUT UINT64 *LastAddress)
 
EFI_STATUS HardwareInfoPciHostBridgeLastMmioAddress (IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, IN BOOLEAN HighMem, OUT UINT64 *LastMmioAddress)
 
STATIC VOID InvalidateRootBridgeAperture (OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
 
STATIC EFI_STATUS FillHostBridgeAperture (IN UINT64 Start, IN UINT64 Size, IN UINT64 MaxValue, OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
 
STATIC EFI_STATUS MergeHostBridgeApertures (IN UINT64 Start, IN UINT64 Size, IN UINT64 PStart, IN UINT64 PSize, IN UINT64 MaxValue, OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
 
EFI_STATUS HardwareInfoPciHostBridgeGetBusNrRange (IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINTN *BusNrStart, OUT UINTN *BusNrLast)
 
EFI_STATUS HardwareInfoPciHostBridgeGetApertures (IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT PCI_ROOT_BRIDGE_APERTURE *Io, OUT PCI_ROOT_BRIDGE_APERTURE *Mem, OUT PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, OUT PCI_ROOT_BRIDGE_APERTURE *PMem, OUT PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, OUT PCI_ROOT_BRIDGE_APERTURE *PcieConfig)
 
EFI_STATUS HardwareInfoPciHostBridgeGetFlags (IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINT64 *Attributes OPTIONAL, OUT BOOLEAN *DmaAbove4G OPTIONAL, OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL, OUT BOOLEAN *CombineMemPMem OPTIONAL)
 
EFI_STATUS HardwareInfoPciHostBridgeGet (IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINTN *BusNrStart, OUT UINTN *BusNrLast, OUT UINT64 *Attributes OPTIONAL, OUT BOOLEAN *DmaAbove4G OPTIONAL, OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL, OUT BOOLEAN *CombineMemPMem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *Io OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *Mem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *MemAbove4G OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PMem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PcieConfig OPTIONAL)
 

Detailed Description

Hardware info library with types and accessors to parse information about PCI host bridges.

Copyright 2021 - 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file HardwareInfoPciHostBridgeLib.c.

Macro Definition Documentation

◆ IS_RANGE_INVALID

#define IS_RANGE_INVALID (   Start,
  Size,
  MaxValue 
)    (Start >= MaxValue || Size == 0)

Definition at line 14 of file HardwareInfoPciHostBridgeLib.c.

Function Documentation

◆ FillHostBridgeAperture()

STATIC EFI_STATUS FillHostBridgeAperture ( IN UINT64  Start,
IN UINT64  Size,
IN UINT64  MaxValue,
OUT PCI_ROOT_BRIDGE_APERTURE Aperture 
)

Fill a PCI ROOT BRIDGE APERTURE with the proper values calculated from the provided start and size.

Parameters
[in]StartStart address of the aperture
[in]SizeSize, in bytes, of the aperture
[in]MaxValueMax value a valid address could take and which represents an invalid start address.
[out]AperturePointer to the aperture to be filled
Return values
EFI_SUCCESSAperture was filled successfully
EFI_INVALID_PARAMETERRange depicted by Start and Size is valid but ignored because aperture pointer is NULL
EFI_WARN_BUFFER_TOO_SMALLAperture pointer is invalid but the range also is so no harm.

Definition at line 157 of file HardwareInfoPciHostBridgeLib.c.

◆ GetRangeEnd()

STATIC UINT64 GetRangeEnd ( IN UINT64  Start,
IN UINT64  Size,
IN UINT64  MaxValue 
)

Calculate the last (inclusive) address of a range.

Parameters
[in]StartFirst address of the range
[in]SizeSize of the range
Returns
Last address of the range

Definition at line 25 of file HardwareInfoPciHostBridgeLib.c.

◆ HardwareInfoPciHostBridgeGet()

EFI_STATUS HardwareInfoPciHostBridgeGet ( IN CONST HOST_BRIDGE_INFO HostBridge,
IN UINTN  DataSize,
OUT UINTN BusNrStart,
OUT UINTN BusNrLast,
OUT UINT64 *Attributes  OPTIONAL,
OUT BOOLEAN *DmaAbove4G  OPTIONAL,
OUT BOOLEAN *NoExtendedConfigSpace  OPTIONAL,
OUT BOOLEAN *CombineMemPMem  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *Io  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *Mem  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *MemAbove4G  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *PMem  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G  OPTIONAL,
OUT PCI_ROOT_BRIDGE_APERTURE *PcieConfig  OPTIONAL 
)

Getter that parses information from a HOST_BRIDGE_INFO object into smaller chunks of types handled by the PciHostBridgeLib.

Parameters
[in]HostBridgeHost bridge information object
[in]DataSizeSize in bytes of the actually filled data available in the HostBridge object
[out]BusNrStartPointer to the Bus Number range start
[out]BusNrLastPointer to the Bus Number range end
[out]AttributesPointer to the host bridge's attributes
[out]DmaAbove4GPointer to the DMA Above 4G flag
[out]NoExtendedConfigSpacePointer to the Extended Config Space flag
[out]CombineMemPMemPointer to the Combine Mem and PMem flag
[out]IoPointer to the PIO aperture object
[out]MemPointer to the 32-bit MMIO aperture object
[out]MemAbove4GPointer to the 64-bit MMIO aperture object
[out]PMemPointer to the 32-bit prefetchable MMIO aperture object
[out]PMemAbove4GPointer to the 64-bit prefetchable MMIO aperture object
[out]PcieConfigMMIO mapped PCIe config aperture (ECAM)
Return values
EFI_SUCCESSWhole operation succeeded
EFI_INVALID_PARAMETERHostBridge object and/or non-optional output parameters are invalid
EFI_INCOMPATIBLE_VERSIONHostBridge information provided belongs to and unsupported version
EFI_WARN_STALE_DATAOne or more apertures having valid ranges in the HostBridge info were ignored because the correspnding aperture pointer is NULL

Definition at line 453 of file HardwareInfoPciHostBridgeLib.c.

◆ HardwareInfoPciHostBridgeGetApertures()

EFI_STATUS HardwareInfoPciHostBridgeGetApertures ( IN CONST HOST_BRIDGE_INFO HostBridge,
IN UINTN  DataSize,
OUT PCI_ROOT_BRIDGE_APERTURE Io,
OUT PCI_ROOT_BRIDGE_APERTURE Mem,
OUT PCI_ROOT_BRIDGE_APERTURE MemAbove4G,
OUT PCI_ROOT_BRIDGE_APERTURE PMem,
OUT PCI_ROOT_BRIDGE_APERTURE PMemAbove4G,
OUT PCI_ROOT_BRIDGE_APERTURE PcieConfig 
)

Interpret the MMIO resources in HostBridge and set the apertures in 32-bit space (Mem), 64-bit space (MemAbove4G), PIO (IO) and ECAM (PcieConfig) accordingly.

The 2 types of apertures in each MMIO space (prefetchable and non-prefetchable) may be merged into a single window, hence if both types of apertures are defined while the CombineMemPMem flag is set, the ranges must be contiguous.

Parameters
[in]HostBridgeRoot bridge's resources specification
[in]DataSizeSize in bytes of the actually filled data available in the HostBridge object
[out]MemPointer to 32-bit MMIO aperture
[out]MemAbove4GPointer to 64-bit MMIO aperture
[out]PMemPointer to the 32-bit prefetchable MMIO aperture
[out]PMemAbove4GPointer to the 64-bit prefetchable MMIO aperture
[out]PcieConfigPointer to MMIO mapped PCIe config aperture (ECAM)
Return values
EFI_INVALID_PARAMETERHostBridge object is invalid
EFI_INCOMPATIBLE_VERSIONHostBridge information belongs to an unsupported version
EFI_WARN_STALE_DATAOne or more valid aperture in the HostBridge's resources were ignored because corresponding aperture pointer is NULL.
EFI_SUCCESSOperation executed cleanly, all valid ranges were parsed into the corresponding aperture object.

Definition at line 297 of file HardwareInfoPciHostBridgeLib.c.

◆ HardwareInfoPciHostBridgeGetBusNrRange()

EFI_STATUS HardwareInfoPciHostBridgeGetBusNrRange ( IN CONST HOST_BRIDGE_INFO HostBridge,
IN UINTN  DataSize,
OUT UINTN BusNrStart,
OUT UINTN BusNrLast 
)

Interpret the HostBridge resources and extact the bus number range.

Parameters
[in]HostBridgeRoot bridge's resources specification
[in]DataSizeSize in bytes of the actually filled data available in the HostBridge object
[out]BusNrStartPointer to the Bus Number range start
[out]BusNrLastPointer to the Bus Number range end
Return values
EFI_SUCCESSRetrieved the bus number range without any issues.
EFI_INVALID_PARAMETEROne of the parameters is invalid, either NULL pointer or size 0
EFI_INCOMPATIBLE_VERSIONHostBridge data of unsupported version

Definition at line 270 of file HardwareInfoPciHostBridgeLib.c.

◆ HardwareInfoPciHostBridgeGetFlags()

EFI_STATUS HardwareInfoPciHostBridgeGetFlags ( IN CONST HOST_BRIDGE_INFO HostBridge,
IN UINTN  DataSize,
OUT UINT64 *Attributes  OPTIONAL,
OUT BOOLEAN *DmaAbove4G  OPTIONAL,
OUT BOOLEAN *NoExtendedConfigSpace  OPTIONAL,
OUT BOOLEAN *CombineMemPMem  OPTIONAL 
)

Retrieve all flags and attributes of a host bridge describing the resources and capabilities.

Parameters
[in]HostBridgeHost bridge information object
[in]DataSizeSize in bytes of the actually filled data available in the HostBridge object
[out]AttributesPointer to the host bridge's attributes
[out]DmaAbove4GPointer to the DMA Above 4G flag
[out]NoExtendedConfigSpacePointer to the Extended Config Space flag
[out]CombineMemPMemPointer to the Combine Mem and PMem flag
Return values
EFI_INVALID_PARAMETERHostBridge object is invalid
EFI_INCOMPATIBLE_VERSIONHostBridge information belongs to an unsupported version
EFI_SUCCESSOperation executed cleanly

Definition at line 413 of file HardwareInfoPciHostBridgeLib.c.

◆ HardwareInfoPciHostBridgeLastMmioAddress()

EFI_STATUS HardwareInfoPciHostBridgeLastMmioAddress ( IN CONST HOST_BRIDGE_INFO HostBridge,
IN UINTN  DataSize,
IN BOOLEAN  HighMem,
OUT UINT64 *  LastMmioAddress 
)

Extract the last MMIO address, either from high (64-bit) or low (32-bit) memory used by the HostBridge's apertures.

Parameters
[in]HostBridgeRoot bridge's resources specification
[in]DataSizeSize in bytes of the actually filled data available in the HostBridge object
[in]HighMem64-bit (true) or 32-bit (false) MMIO address
[out]LastMmioAddressPointer to last MMIO address
Return values
EFI_SUCCESSOperation succeeded
EFI_INVALID_PARAMETEROne or more pointer parameters are invalid
EFI_INCOMPATIBLE_VERSIONHostBridge information belongs to an unsupported version

Definition at line 61 of file HardwareInfoPciHostBridgeLib.c.

◆ InvalidateRootBridgeAperture()

STATIC VOID InvalidateRootBridgeAperture ( OUT PCI_ROOT_BRIDGE_APERTURE Aperture)

Set the boundaries of an aperture to invalid values having size zero and start MaxValue (yields Start > Limit which depicts an invalid range)

Parameters
[in]MaxValueMax value of the aperture's range (depends on the data type)
[out]ApertureAperture object to invalidate

Definition at line 126 of file HardwareInfoPciHostBridgeLib.c.

◆ MergeHostBridgeApertures()

STATIC EFI_STATUS MergeHostBridgeApertures ( IN UINT64  Start,
IN UINT64  Size,
IN UINT64  PStart,
IN UINT64  PSize,
IN UINT64  MaxValue,
OUT PCI_ROOT_BRIDGE_APERTURE Aperture 
)

Merge 2 ranges (normal and prefetchable) into a single aperture comprehending the addresses encompassed by both of them. If both ranges are not empty they must be contiguous for correctness.

Parameters
[in]StartRange start address
[in]SizeRange size in bytes
[in]PStartPrefetchable range start address
[in]PSizePrefetchable range size in bytes
[in]MaxValueMax value a valid address could take and which represents an invalid start address.
[out]AperturePointer to the aperture to be filled
Return values
EFI_SUCCESSAperture was filled successfully
EFI_INVALID_PARAMETEREither range depicted by Start, Size or PStart, PSize or both are valid but ignored because aperture pointer is NULL
EFI_WARN_BUFFER_TOO_SMALLAperture pointer is invalid but both ranges are too so no harm.

Definition at line 218 of file HardwareInfoPciHostBridgeLib.c.

◆ UpdateLastAddressIfHigher()

STATIC VOID UpdateLastAddressIfHigher ( IN PCI_ROOT_BRIDGE_APERTURE Mem,
OUT UINT64 *  LastAddress 
)

Internal helper to update LastAddress if the Limit address of the Mem aperture is higher than the provided value.

Parameters
[in]MemPointer to aperture whose limit is to be compared against accumulative last address.
[out]LastAddressPointer to accumulative last address to be updated if Limit is higher

Definition at line 50 of file HardwareInfoPciHostBridgeLib.c.