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

Go to the source code of this file.

Macros

#define PCI_MAX_DEVICE_COUNT_PER_BUS   32
 
#define PCI_MAX_FUNCTION_COUNT_PER_DEVICE   8
 
#define SSDT_PCI_GENERATOR_REVISION   CREATE_REVISION (1, 0)
 

Functions

 GET_OBJECT_LIST (EObjNameSpaceArchCommon, EArchCommonObjCmRef, CM_ARCH_COMMON_OBJ_REF)
 
 GET_OBJECT_LIST (EObjNameSpaceArchCommon, EArchCommonObjPciConfigSpaceInfo, CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO)
 
 GET_OBJECT_LIST (EObjNameSpaceArchCommon, EArchCommonObjPciAddressMapInfo, CM_ARCH_COMMON_PCI_ADDRESS_MAP_INFO)
 
 GET_OBJECT_LIST (EObjNameSpaceArchCommon, EArchCommonObjPciInterruptMapInfo, CM_ARCH_COMMON_PCI_INTERRUPT_MAP_INFO)
 
STATIC EFI_STATUS EFIAPI MappingTableInitialize (IN MAPPING_TABLE *MappingTable, IN UINT32 Count)
 
STATIC VOID EFIAPI MappingTableFree (IN OUT MAPPING_TABLE *MappingTable)
 
STATIC UINT32 EFIAPI MappingTableAdd (IN MAPPING_TABLE *MappingTable, IN UINT32 Integer)
 
STATIC EFI_STATUS EFIAPI GeneratePciDeviceInfo (IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN UINT32 Uid, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
 
STATIC EFI_STATUS EFIAPI GeneratePrt (IN ACPI_PCI_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN UINT32 Uid, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
 
STATIC EFI_STATUS EFIAPI GeneratePciCrs (IN ACPI_PCI_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
 
STATIC EFI_STATUS EFIAPI GenerateMotherboardDevice (IN AML_OBJECT_NODE_HANDLE PciNode, OUT AML_OBJECT_NODE_HANDLE *CrsNode)
 
STATIC EFI_STATUS EFIAPI ReserveEcamSpace (IN ACPI_PCI_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
 
STATIC EFI_STATUS EFIAPI GeneratePciDevice (IN ACPI_PCI_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN UINT32 Uid, IN OUT AML_ROOT_NODE_HANDLE *RootNode)
 
STATIC EFI_STATUS EFIAPI BuildSsdtPciTable (IN ACPI_PCI_GENERATOR *Generator, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN UINT32 Uid, OUT EFI_ACPI_DESCRIPTION_HEADER **Table)
 
STATIC EFI_STATUS EFIAPI BuildSsdtPciTableEx (IN CONST ACPI_TABLE_GENERATOR *This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, OUT EFI_ACPI_DESCRIPTION_HEADER ***Table, OUT UINTN *CONST TableCount)
 
STATIC EFI_STATUS EFIAPI FreeSsdtPciTableEx (IN CONST ACPI_TABLE_GENERATOR *CONST This, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN OUT EFI_ACPI_DESCRIPTION_HEADER ***CONST Table, IN CONST UINTN TableCount)
 
EFI_STATUS EFIAPI AcpiSsdtPcieLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI AcpiSsdtPcieLibDestructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC ACPI_PCI_GENERATOR SsdtPcieGenerator
 

Detailed Description

SSDT Pcie Table Generator.

Copyright (c) 2021 - 2022, Arm Limited. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Reference(s):
  • PCI Firmware Specification - Revision 3.0
  • ACPI 6.4 specification:
    • s6.2.13 "_PRT (PCI Routing Table)"
    • s6.1.1 "_ADR (Address)"
  • linux kernel code
  • Arm Base Boot Requirements v1.0
  • Arm Base System Architecture v1.0

Definition in file SsdtPcieGenerator.c.

Macro Definition Documentation

◆ PCI_MAX_DEVICE_COUNT_PER_BUS

#define PCI_MAX_DEVICE_COUNT_PER_BUS   32

Definition at line 37 of file SsdtPcieGenerator.c.

◆ PCI_MAX_FUNCTION_COUNT_PER_DEVICE

#define PCI_MAX_FUNCTION_COUNT_PER_DEVICE   8

Definition at line 38 of file SsdtPcieGenerator.c.

◆ SSDT_PCI_GENERATOR_REVISION

#define SSDT_PCI_GENERATOR_REVISION   CREATE_REVISION (1, 0)

This macro defines the SSDT Pci Table Generator revision.

Definition at line 1152 of file SsdtPcieGenerator.c.

Function Documentation

◆ AcpiSsdtPcieLibConstructor()

EFI_STATUS EFIAPI AcpiSsdtPcieLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Register the Generator with the ACPI Table Factory.

Parameters
[in]ImageHandleThe handle to the image.
[in]SystemTablePointer to the System Table.
Return values
EFI_SUCCESSThe Generator is registered.
EFI_INVALID_PARAMETERA parameter is invalid.
EFI_ALREADY_STARTEDThe Generator for the Table ID is already registered.

Definition at line 1209 of file SsdtPcieGenerator.c.

◆ AcpiSsdtPcieLibDestructor()

EFI_STATUS EFIAPI AcpiSsdtPcieLibDestructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Deregister the Generator from the ACPI Table Factory.

Parameters
[in]ImageHandleThe handle to the image.
[in]SystemTablePointer to the System Table.
Return values
EFI_SUCCESSThe Generator is deregistered.
EFI_INVALID_PARAMETERA parameter is invalid.
EFI_NOT_FOUNDThe Generator is not registered.

Definition at line 1237 of file SsdtPcieGenerator.c.

◆ BuildSsdtPciTable()

STATIC EFI_STATUS EFIAPI BuildSsdtPciTable ( IN ACPI_PCI_GENERATOR Generator,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST  CfgMgrProtocol,
IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST  AcpiTableInfo,
IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO PciInfo,
IN UINT32  Uid,
OUT EFI_ACPI_DESCRIPTION_HEADER **  Table 
)

Build an Ssdt table describing a Pci device.

Parameters
[in]GeneratorThe SSDT Pci generator.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[in]AcpiTableInfoPointer to the ACPI table information.
[in]PciInfoPci device information.
[in]UidUnique Id of the Pci device.
[out]TableIf success, contains the created SSDT table.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 867 of file SsdtPcieGenerator.c.

◆ BuildSsdtPciTableEx()

STATIC EFI_STATUS EFIAPI BuildSsdtPciTableEx ( IN CONST ACPI_TABLE_GENERATOR This,
IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST  AcpiTableInfo,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST  CfgMgrProtocol,
OUT EFI_ACPI_DESCRIPTION_HEADER ***  Table,
OUT UINTN *CONST  TableCount 
)

Construct SSDT tables describing Pci root complexes.

This function invokes the Configuration Manager protocol interface to get the required hardware information for generating the ACPI table.

If this function allocates any resources then they must be freed in the FreeXXXXTableResourcesEx function.

Parameters
[in]ThisPointer to the ACPI table generator.
[in]AcpiTableInfoPointer to the ACPI table information.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[out]TablePointer to a list of generated ACPI table(s).
[out]TableCountNumber of generated ACPI table(s).
Return values
EFI_SUCCESSTable generated successfully.
EFI_BAD_BUFFER_SIZEThe size returned by the Configuration Manager is less than the Object size for the requested object.
EFI_INVALID_PARAMETERA parameter is invalid.
EFI_NOT_FOUNDCould not find information.
EFI_OUT_OF_RESOURCESCould not allocate memory.
EFI_UNSUPPORTEDUnsupported configuration.

Definition at line 971 of file SsdtPcieGenerator.c.

◆ FreeSsdtPciTableEx()

STATIC EFI_STATUS EFIAPI FreeSsdtPciTableEx ( IN CONST ACPI_TABLE_GENERATOR *CONST  This,
IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST  AcpiTableInfo,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST  CfgMgrProtocol,
IN OUT EFI_ACPI_DESCRIPTION_HEADER ***CONST  Table,
IN CONST UINTN  TableCount 
)

Free any resources allocated for constructing the tables.

Parameters
[in]ThisPointer to the ACPI table generator.
[in]AcpiTableInfoPointer to the ACPI Table Info.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol Interface.
[in,out]TablePointer to an array of pointers to ACPI Table(s).
[in]TableCountNumber of ACPI table(s).
Return values
EFI_SUCCESSThe resources were freed successfully.
EFI_INVALID_PARAMETERThe table pointer is NULL or invalid.

Definition at line 1102 of file SsdtPcieGenerator.c.

◆ GenerateMotherboardDevice()

STATIC EFI_STATUS EFIAPI GenerateMotherboardDevice ( IN AML_OBJECT_NODE_HANDLE  PciNode,
OUT AML_OBJECT_NODE_HANDLE CrsNode 
)

Generate a RES0 device node to reserve PNP motherboard resources for a given PCI node.

Parameters
[in]PciNodeParent PCI node handle of the generated resource object.
[out]CrsNodeCRS node of the AML tree to populate.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid input parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 639 of file SsdtPcieGenerator.c.

◆ GeneratePciCrs()

Generate a _CRS method for the Pci device.

Parameters
[in]GeneratorThe SSDT Pci generator.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[in]PciInfoPci device information.
[in,out]PciNodePci node to amend.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 451 of file SsdtPcieGenerator.c.

◆ GeneratePciDevice()

STATIC EFI_STATUS EFIAPI GeneratePciDevice ( IN ACPI_PCI_GENERATOR Generator,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST  CfgMgrProtocol,
IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO PciInfo,
IN UINT32  Uid,
IN OUT AML_ROOT_NODE_HANDLE RootNode 
)

Generate a Pci device.

Parameters
[in]GeneratorThe SSDT Pci generator.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[in]PciInfoPci device information.
[in]UidUnique Id of the Pci device.
[in,out]RootNodeRootNode of the AML tree to populate.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 765 of file SsdtPcieGenerator.c.

◆ GeneratePciDeviceInfo()

STATIC EFI_STATUS EFIAPI GeneratePciDeviceInfo ( IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO PciInfo,
IN UINT32  Uid,
IN OUT AML_OBJECT_NODE_HANDLE  PciNode 
)

Generate required Pci device information.

ASL code: Name (_UID, <Uid>) // Uid of the Pci device Name (_HID, EISAID ("PNP0A08")) // PCI Express Root Bridge Name (_CID, EISAID ("PNP0A03")) // Compatible PCI Root Bridge Name (_SEG, <Pci segment group>) // PCI Segment Group number Name (_BBN, <Bus number>) // PCI Base Bus Number Name (_CCA, 1) // Initially mark the PCI coherent

Parameters
[in]PciInfoPci device information.
[in]UidUnique Id of the Pci device.
[in,out]PciNodePci node to amend.
Return values
EFI_SUCCESSSuccess.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESFailed to allocate memory.

Definition at line 210 of file SsdtPcieGenerator.c.

◆ GeneratePrt()

STATIC EFI_STATUS EFIAPI GeneratePrt ( IN ACPI_PCI_GENERATOR Generator,
IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST  CfgMgrProtocol,
IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO PciInfo,
IN UINT32  Uid,
IN OUT AML_OBJECT_NODE_HANDLE  PciNode 
)

Generate a _PRT object (Pci Routing Table) for the Pci device.

Cf. ACPI 6.4 specification, s6.2.13 "_PRT (PCI Routing Table)"

Parameters
[in]GeneratorThe SSDT Pci generator.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[in]PciInfoPci device information.
[in]UidUnique Id of the Pci device.
[in,out]PciNodePci node to amend.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 305 of file SsdtPcieGenerator.c.

◆ GET_OBJECT_LIST() [1/4]

ARM standard SSDT Pcie Table Generator.

Requirements: The following Configuration Manager Object(s) are required by this Generator:

  • EArchCommonObjCmRef
  • EArchCommonObjPciConfigSpaceInfo
  • EArchCommonObjPciAddressMapInfo
  • EArchCommonObjPciInterruptMapInfo This macro expands to a function that retrieves the cross-CM-object- reference information from the Configuration Manager.

◆ GET_OBJECT_LIST() [2/4]

This macro expands to a function that retrieves the Pci Address Mapping Information from the Configuration Manager.

◆ GET_OBJECT_LIST() [3/4]

This macro expands to a function that retrieves the Pci Configuration Space Information from the Configuration Manager.

◆ GET_OBJECT_LIST() [4/4]

This macro expands to a function that retrieves the Pci Interrupt Mapping Information from the Configuration Manager.

◆ MappingTableAdd()

STATIC UINT32 EFIAPI MappingTableAdd ( IN MAPPING_TABLE MappingTable,
IN UINT32  Integer 
)

Add a new entry to the MappingTable and return its index.

If an entry with [Integer] is already available in the table, return its index without adding a new entry.

Parameters
[in]MappingTableThe mapping table structure.
[in]IntegerNew Integer entry to add.
Return values
Theindex of the Integer entry in the MappingTable.

Definition at line 159 of file SsdtPcieGenerator.c.

◆ MappingTableFree()

STATIC VOID EFIAPI MappingTableFree ( IN OUT MAPPING_TABLE MappingTable)

Free the MappingTable.

Parameters
[in,out]MappingTableThe mapping table structure.

Definition at line 134 of file SsdtPcieGenerator.c.

◆ MappingTableInitialize()

STATIC EFI_STATUS EFIAPI MappingTableInitialize ( IN MAPPING_TABLE MappingTable,
IN UINT32  Count 
)

Initialize the MappingTable.

Parameters
[in]MappingTableThe mapping table structure.
[in]CountNumber of entries to allocate in the MappingTable.
Return values
EFI_SUCCESSSuccess.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESFailed to allocate memory.

Definition at line 100 of file SsdtPcieGenerator.c.

◆ ReserveEcamSpace()

Reserves ECAM space for PCI config space

Parameters
[in]GeneratorThe SSDT Pci generator.
[in]CfgMgrProtocolPointer to the Configuration Manager Protocol interface.
[in]PciInfoPci device information.
[in,out]PciNodeRootNode of the AML tree to populate.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 698 of file SsdtPcieGenerator.c.

Variable Documentation

◆ SsdtPcieGenerator

STATIC ACPI_PCI_GENERATOR SsdtPcieGenerator

The interface for the SSDT Pci Table Generator.

Definition at line 1157 of file SsdtPcieGenerator.c.