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

Go to the source code of this file.

Functions

STATIC EFI_STATUS EFIAPI GetPciSegGroup (IN CONST VOID *Fdt, IN INT32 HostPciNode, OUT INT32 *SegGroup)
 
STATIC EFI_STATUS EFIAPI PopulateBusRange (IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
 
STATIC EFI_STATUS EFIAPI ParseAddressMap (IN CONST VOID *Fdt, IN INT32 HostPciNode, IN INT32 AddressCells, IN OUT PCI_PARSER_TABLE *PciInfo)
 
STATIC EFI_STATUS EFIAPI ParseIrqMap (IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
 
STATIC EFI_STATUS EFIAPI PciNodeParser (IN CONST VOID *Fdt, IN INT32 HostPciNode, IN OUT PCI_PARSER_TABLE *PciInfo)
 
STATIC EFI_STATUS EFIAPI PciInfoAdd (IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN PCI_PARSER_TABLE *PciTableInfo)
 
STATIC EFI_STATUS EFIAPI FreeParserTable (IN PCI_PARSER_TABLE *PciTableInfo)
 
EFI_STATUS EFIAPI PciConfigInfoParser (IN CONST FDT_HW_INFO_PARSER_HANDLE FdtParserHandle, IN INT32 FdtBranch)
 

Variables

STATIC CONST COMPATIBILITY_STR PciCompatibleStr []
 
STATIC CONST COMPATIBILITY_INFO PciCompatibleInfo
 

Detailed Description

PCI Configuration Space Parser.

Copyright (c) 2021, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Reference(s):
  • linux/Documentation/devicetree/bindings/pci/host-generic-pci.yaml
  • PCI Firmware Specification - Revision 3.0
  • Open Firmware Recommended Practice: Interrupt Mapping, Version 0.9
  • Devicetree Specification Release v0.3
  • linux kernel code

Definition in file PciConfigSpaceParser.c.

Function Documentation

◆ FreeParserTable()

STATIC EFI_STATUS EFIAPI FreeParserTable ( IN PCI_PARSER_TABLE PciTableInfo)

Free the CmObjDesc of the ParserTable.

Parameters
[in]PciTableInfoPCI_PARSER_TABLE structure containing the CmObjs to free.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 657 of file PciConfigSpaceParser.c.

◆ GetPciSegGroup()

STATIC EFI_STATUS EFIAPI GetPciSegGroup ( IN CONST VOID *  Fdt,
IN INT32  HostPciNode,
OUT INT32 *  SegGroup 
)

Get the Segment group (also called: Domain Id) of a host-pci node.

kernel/Documentation/devicetree/bindings/pci/pci.txt: "It is required to either not set this property at all or set it for all host bridges in the system"

The function checks the "linux,pci-domain" property of the host-pci node. Either all host-pci nodes must have this property, or none of them. If the property is available, read it. Otherwise dynamically assign the Ids.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]HostPciNodeOffset of a host-pci node.
[out]SegGroupSegment group assigned to the host-pci controller.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 58 of file PciConfigSpaceParser.c.

◆ ParseAddressMap()

STATIC EFI_STATUS EFIAPI ParseAddressMap ( IN CONST VOID *  Fdt,
IN INT32  HostPciNode,
IN INT32  AddressCells,
IN OUT PCI_PARSER_TABLE PciInfo 
)

Parse the PCI address map.

The PCI address map is available in the "ranges" device-tree property.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]HostPciNodeOffset of a host-pci node.
[in]AddressCells# of cells used to encode an address on the parent bus.
[in,out]PciInfoPCI_PARSER_TABLE structure storing information about the current host-pci.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESAn allocation has failed.

Definition at line 176 of file PciConfigSpaceParser.c.

◆ ParseIrqMap()

STATIC EFI_STATUS EFIAPI ParseIrqMap ( IN CONST VOID *  Fdt,
IN INT32  HostPciNode,
IN OUT PCI_PARSER_TABLE PciInfo 
)

Parse the PCI interrupt map.

The PCI interrupt map is available in the "interrupt-map" and "interrupt-map-mask" device-tree properties.

Cf Devicetree Specification Release v0.3, s2.4.3 Interrupt Nexus Properties

An interrupt-map must be as: interrupt-map = < [child unit address] [child interrupt specifier] [interrupt-parent] [parent unit address] [parent interrupt specifier] >

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]HostPciNodeOffset of a host-pci node.
[in,out]PciInfoPCI_PARSER_TABLE structure storing information about the current host-pci.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.
EFI_OUT_OF_RESOURCESAn allocation has failed.

Definition at line 285 of file PciConfigSpaceParser.c.

◆ PciConfigInfoParser()

EFI_STATUS EFIAPI PciConfigInfoParser ( IN CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
IN INT32  FdtBranch 
)

CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO parser function.

The following structure is populated: typedef struct CmArchCommonPciConfigSpaceInfo { UINT64 BaseAddress; // {Populated} UINT16 PciSegmentGroupNumber; // {Populated} UINT8 StartBusNumber; // {Populated} UINT8 EndBusNumber; // {Populated} } CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO;

typedef struct CmArchCommonPciAddressMapInfo { UINT8 SpaceCode; // {Populated} UINT64 PciAddress; // {Populated} UINT64 CpuAddress; // {Populated} UINT64 AddressSize; // {Populated} } CM_ARCH_COMMON_PCI_ADDRESS_MAP_INFO;

typedef struct CmArchCommonPciInterruptMapInfo { UINT8 PciBus; // {Populated} UINT8 PciDevice; // {Populated} UINT8 PciInterrupt; // {Populated} CM_ARCH_COMMON_GENERIC_INTERRUPT IntcInterrupt; // {Populated} } CM_ARCH_COMMON_PCI_INTERRUPT_MAP_INFO;

A parser parses a Device Tree to populate a specific CmObj type. None, one or many CmObj can be created by the parser. The created CmObj are then handed to the parser's caller through the HW_INFO_ADD_OBJECT interface. This can also be a dispatcher. I.e. a function that not parsing a Device Tree but calling other parsers.

Parameters
[in]FdtParserHandleA handle to the parser instance.
[in]FdtBranchWhen searching for DT node name, restrict the search to this Device Tree branch.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNot found.
EFI_UNSUPPORTEDUnsupported.

Definition at line 722 of file PciConfigSpaceParser.c.

◆ PciInfoAdd()

STATIC EFI_STATUS EFIAPI PciInfoAdd ( IN CONST FDT_HW_INFO_PARSER_HANDLE  FdtParserHandle,
IN PCI_PARSER_TABLE PciTableInfo 
)

Add the parsed Pci information to the Configuration Manager.

CmObj of the following types are concerned:

  • EArchCommonObjPciConfigSpaceInfo
  • EArchCommonObjPciAddressMapInfo
  • EArchCommonObjPciInterruptMapInfo
Parameters
[in]FdtParserHandleA handle to the parser instance.
[in]PciTableInfoPCI_PARSER_TABLE structure containing the CmObjs to add.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESAn allocation has failed.

Definition at line 589 of file PciConfigSpaceParser.c.

◆ PciNodeParser()

STATIC EFI_STATUS EFIAPI PciNodeParser ( IN CONST VOID *  Fdt,
IN INT32  HostPciNode,
IN OUT PCI_PARSER_TABLE PciInfo 
)

Parse a Host-pci node.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]HostPciNodeOffset of a host-pci node.
[in,out]PciInfoThe CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO to populate.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESAn allocation has failed.

Definition at line 473 of file PciConfigSpaceParser.c.

◆ PopulateBusRange()

STATIC EFI_STATUS EFIAPI PopulateBusRange ( IN CONST VOID *  Fdt,
IN INT32  HostPciNode,
IN OUT PCI_PARSER_TABLE PciInfo 
)

Parse the bus-range controlled by this host-pci node.

Parameters
[in]FdtPointer to a Flattened Device Tree (Fdt).
[in]HostPciNodeOffset of a host-pci node.
[in,out]PciInfoPCI_PARSER_TABLE structure storing information about the current host-pci.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDAn error occurred.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 119 of file PciConfigSpaceParser.c.

Variable Documentation

◆ PciCompatibleInfo

STATIC CONST COMPATIBILITY_INFO PciCompatibleInfo
Initial value:
= {
}
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
STATIC CONST COMPATIBILITY_STR PciCompatibleStr[]

COMPATIBILITY_INFO structure for the PCIe.

Definition at line 32 of file PciConfigSpaceParser.c.

◆ PciCompatibleStr

STATIC CONST COMPATIBILITY_STR PciCompatibleStr[]
Initial value:
= {
{ "pci-host-ecam-generic" }
}

List of "compatible" property values for host PCIe bridges nodes.

Any other "compatible" value is not supported by this module.

Definition at line 26 of file PciConfigSpaceParser.c.