37#define PCI_MAX_DEVICE_COUNT_PER_BUS 32
38#define PCI_MAX_FUNCTION_COUNT_PER_DEVICE 8
111 return EFI_INVALID_PARAMETER;
117 return EFI_OUT_OF_RESOURCES;
175 for (Index = 0; Index < LastIndex; Index++) {
176 if (Table[Index] == Integer) {
181 ASSERT (LastIndex < MappingTable->MaxIndex);
184 Table[LastIndex] = Integer;
219 ASSERT (PciInfo !=
NULL);
220 ASSERT (PciNode !=
NULL);
224 if (EFI_ERROR (Status)) {
231 if (EFI_ERROR (Status)) {
237 if (EFI_ERROR (Status)) {
244 if (EFI_ERROR (Status)) {
250 if (EFI_ERROR (Status)) {
258 PciInfo->PciSegmentGroupNumber,
262 if (EFI_ERROR (Status)) {
270 PciInfo->StartBusNumber,
274 if (EFI_ERROR (Status)) {
321 ASSERT (CfgMgrProtocol !=
NULL);
322 ASSERT (PciInfo !=
NULL);
323 ASSERT (PciNode !=
NULL);
329 Status = GetEArchCommonObjCmRef (
331 PciInfo->InterruptMapToken,
335 if (EFI_ERROR (Status)) {
342 if (EFI_ERROR (Status)) {
349 if (EFI_ERROR (Status)) {
354 for (Index = 0; Index < RefCount; Index++) {
356 Status = GetEArchCommonObjPciInterruptMapInfo (
358 RefInfo[Index].ReferenceToken,
362 if (EFI_ERROR (Status)) {
374 Status = EFI_INVALID_PARAMETER;
404 if (EFI_ERROR (Status)) {
412 if (EFI_ERROR (Status)) {
421 if (EFI_ERROR (Status)) {
429 if (PrtNode !=
NULL) {
468 ASSERT (CfgMgrProtocol !=
NULL);
469 ASSERT (PciInfo !=
NULL);
470 ASSERT (PciNode !=
NULL);
474 if (EFI_ERROR (Status)) {
494 PciInfo->StartBusNumber,
495 PciInfo->EndBusNumber,
497 PciInfo->EndBusNumber - PciInfo->StartBusNumber + 1,
503 if (EFI_ERROR (Status)) {
510 Status = GetEArchCommonObjCmRef (
512 PciInfo->AddressMapToken,
516 if (EFI_ERROR (Status)) {
521 for (Index = 0; Index < RefCount; Index++) {
523 Status = GetEArchCommonObjPciAddressMapInfo (
525 RefInfo[Index].ReferenceToken,
529 if (EFI_ERROR (Status)) {
564 ASSERT ((AddrMapInfo->
PciAddress & ~MAX_UINT32) == 0);
566 ASSERT (((Translation ? AddrMapInfo->
CpuAddress - AddrMapInfo->
PciAddress : 0) & ~MAX_UINT32) == 0);
567 ASSERT ((AddrMapInfo->
AddressSize & ~MAX_UINT32) == 0);
583 AmlAddressRangeMemory,
605 AmlAddressRangeMemory,
613 Status = EFI_INVALID_PARAMETER;
616 if (EFI_ERROR (Status)) {
648 if (CrsNode ==
NULL) {
650 return EFI_INVALID_PARAMETER;
655 if (EFI_ERROR (Status)) {
662 if (EFI_ERROR (Status)) {
668 if (EFI_ERROR (Status)) {
675 if (EFI_ERROR (Status)) {
707 UINT64 AddressMinimum;
708 UINT64 AddressMaximum;
711 if (EFI_ERROR (Status)) {
716 AddressMinimum = PciInfo->BaseAddress + (PciInfo->StartBusNumber *
717 PCI_MAX_DEVICE_COUNT_PER_BUS * PCI_MAX_FUNCTION_COUNT_PER_DEVICE * SIZE_4KB);
718 AddressMaximum = PciInfo->BaseAddress + ((PciInfo->EndBusNumber + 1) *
719 PCI_MAX_DEVICE_COUNT_PER_BUS * PCI_MAX_FUNCTION_COUNT_PER_DEVICE * SIZE_4KB) - 1;
726 AmlMemoryNonCacheable,
732 AddressMaximum - AddressMinimum + 1,
735 AmlAddressRangeMemory,
741 if (EFI_ERROR (Status)) {
775 CHAR8 AslName[AML_NAME_SEG_SIZE + 1];
780 ASSERT (CfgMgrProtocol !=
NULL);
781 ASSERT (PciInfo !=
NULL);
782 ASSERT (RootNode !=
NULL);
788 if (EFI_ERROR (Status)) {
794 CopyMem (AslName,
"PCIx", AML_NAME_SEG_SIZE + 1);
795 AslName[AML_NAME_SEG_SIZE - 1] =
AsciiFromHex (Uid & 0xF);
797 AslName[AML_NAME_SEG_SIZE - 2] =
AsciiFromHex ((Uid >> 4) & 0xF);
802 if (EFI_ERROR (Status)) {
809 if (EFI_ERROR (Status)) {
823 if (EFI_ERROR (Status)) {
831 if (EFI_ERROR (Status)) {
838 if (EFI_ERROR (Status)) {
881 ASSERT (CfgMgrProtocol !=
NULL);
882 ASSERT (PciInfo !=
NULL);
883 ASSERT (Table !=
NULL);
892 if (EFI_ERROR (Status)) {
904 if (EFI_ERROR (Status)) {
914 if (EFI_ERROR (Status)) {
917 "ERROR: SSDT-PCI: Failed to Serialize SSDT Table Data."
926 if (EFI_ERROR (Status1)) {
929 "ERROR: SSDT-PCI: Failed to cleanup AML tree."
935 if (!EFI_ERROR (Status)) {
987 ASSERT (This !=
NULL);
988 ASSERT (AcpiTableInfo !=
NULL);
989 ASSERT (CfgMgrProtocol !=
NULL);
990 ASSERT (Table !=
NULL);
991 ASSERT (TableCount !=
NULL);
992 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
993 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
998 Status = GetEArchCommonObjPciConfigSpaceInfo (
1004 if (EFI_ERROR (Status)) {
1012 "ERROR: SSDT-PCI: Too many Pci root complexes: %d."
1013 " Maximum Pci root complexes supported = %d.\n",
1017 return EFI_INVALID_PARAMETER;
1025 if (TableList ==
NULL) {
1026 Status = EFI_OUT_OF_RESOURCES;
1029 "ERROR: SSDT-PCI: Failed to allocate memory for Table List."
1040 for (Index = 0; Index < PciCount; Index++) {
1046 "ERROR: SSDT-PCI: Pci root complexes segment number: %d."
1047 " Greater than maximum number of Pci root complexes supported = %d.\n",
1051 return EFI_INVALID_PARAMETER;
1066 if (EFI_ERROR (Status)) {
1069 "ERROR: SSDT-PCI: Failed to build associated SSDT table."
1113 ASSERT (This !=
NULL);
1114 ASSERT (AcpiTableInfo !=
NULL);
1115 ASSERT (CfgMgrProtocol !=
NULL);
1116 ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);
1117 ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);
1119 if ((Table ==
NULL) ||
1123 DEBUG ((DEBUG_ERROR,
"ERROR: SSDT-PCI: Invalid Table Pointer\n"));
1124 return EFI_INVALID_PARAMETER;
1128 for (Index = 0; Index < TableCount; Index++) {
1129 if ((TableList[Index] !=
NULL) &&
1130 (TableList[Index]->Signature ==
1137 "ERROR: SSDT-PCI: Could not free SSDT table at index %d.",
1140 return EFI_INVALID_PARAMETER;
1152#define SSDT_PCI_GENERATOR_REVISION CREATE_REVISION (1, 0)
1163 L
"ACPI.STD.SSDT.PCI.GENERATOR",
1219 "SSDT-PCI: Register Generator. Status = %r\n",
1247 "SSDT-PCI: Deregister Generator. Status = %r\n",
#define EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE
EFI_STATUS EFIAPI AmlGetEisaIdFromString(IN CONST CHAR8 *EisaIdStr, OUT UINT32 *EisaIdInt)
UINT8 EFIAPI AsciiFromHex(IN UINT8 Hex)
EFI_STATUS EFIAPI RegisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
EFI_STATUS EFIAPI DeregisterAcpiTableGenerator(IN CONST ACPI_TABLE_GENERATOR *CONST Generator)
#define CREATE_STD_ACPI_TABLE_GEN_ID(TableId)
#define TABLE_GENERATOR_CREATOR_ID
@ EStdAcpiTableIdSsdtPciExpress
SSDT Pci Express Generator.
void * AML_ROOT_NODE_HANDLE
EFI_STATUS EFIAPI AmlAddPrtEntry(IN UINT32 Address, IN UINT8 Pin, IN CONST CHAR8 *LinkName, IN UINT32 SourceIndex, IN AML_OBJECT_NODE_HANDLE PrtNameNode)
EFI_STATUS EFIAPI AmlCodeGenDevice(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenNameResourceTemplate(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode, OPTIONAL OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenRdQWordIo(IN BOOLEAN IsResourceConsumer, IN BOOLEAN IsMinFixed, IN BOOLEAN IsMaxFixed, IN BOOLEAN IsPosDecode, IN UINT8 IsaRanges, IN UINT64 AddressGranularity, IN UINT64 AddressMinimum, IN UINT64 AddressMaximum, IN UINT64 AddressTranslation, IN UINT64 RangeLength, IN UINT8 ResourceSourceIndex, IN CONST CHAR8 *ResourceSource, IN BOOLEAN IsDenseTranslation, IN BOOLEAN IsTypeStatic, IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenScope(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenRdDWordMemory(IN BOOLEAN IsResourceConsumer, IN BOOLEAN IsPosDecode, IN BOOLEAN IsMinFixed, IN BOOLEAN IsMaxFixed, IN AML_MEMORY_ATTRIBUTES_MEM Cacheable, IN BOOLEAN IsReadWrite, IN UINT32 AddressGranularity, IN UINT32 AddressMinimum, IN UINT32 AddressMaximum, IN UINT32 AddressTranslation, IN UINT32 RangeLength, IN UINT8 ResourceSourceIndex, IN CONST CHAR8 *ResourceSource, IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType, IN BOOLEAN IsTypeStatic, IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenNamePackage(IN CONST CHAR8 *NameString, IN AML_NODE_HANDLE ParentNode, OPTIONAL OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenNameInteger(IN CONST CHAR8 *NameString, IN UINT64 Integer, IN AML_NODE_HANDLE ParentNode OPTIONAL, OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL)
EFI_STATUS EFIAPI AmlAttachNode(IN AML_NODE_HANDLE ParentNode, IN AML_NODE_HANDLE NewNode)
void * AML_OBJECT_NODE_HANDLE
EFI_STATUS EFIAPI AmlCodeGenRdQWordMemory(IN BOOLEAN IsResourceConsumer, IN BOOLEAN IsPosDecode, IN BOOLEAN IsMinFixed, IN BOOLEAN IsMaxFixed, IN AML_MEMORY_ATTRIBUTES_MEM Cacheable, IN BOOLEAN IsReadWrite, IN UINT64 AddressGranularity, IN UINT64 AddressMinimum, IN UINT64 AddressMaximum, IN UINT64 AddressTranslation, IN UINT64 RangeLength, IN UINT8 ResourceSourceIndex, IN CONST CHAR8 *ResourceSource, IN AML_MEMORY_ATTRIBUTES_MTP MemoryRangeType, IN BOOLEAN IsTypeStatic, IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL)
EFI_STATUS EFIAPI AmlCodeGenRdWordBusNumber(IN BOOLEAN IsResourceConsumer, IN BOOLEAN IsMinFixed, IN BOOLEAN IsMaxFixed, IN BOOLEAN IsPosDecode, IN UINT16 AddressGranularity, IN UINT16 AddressMinimum, IN UINT16 AddressMaximum, IN UINT16 AddressTranslation, IN UINT16 RangeLength, IN UINT8 ResourceSourceIndex, IN CONST CHAR8 *ResourceSource, IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL)
@ EArchCommonObjPciAddressMapInfo
9 - Pci Address Map Info
@ EArchCommonObjCmRef
7 - CM Object Reference
@ EArchCommonObjPciInterruptMapInfo
10 - Pci Interrupt Map Info
@ EArchCommonObjPciConfigSpaceInfo
8 - PCI Configuration Space Info
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type)
@ EObjNameSpaceArchCommon
Arch Common Objects Namespace.
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGetBool(TokenName)
EFI_STATUS EFIAPI AcpiSsdtPcieLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define SSDT_PCI_GENERATOR_REVISION
STATIC ACPI_PCI_GENERATOR SsdtPcieGenerator
STATIC EFI_STATUS EFIAPI GenerateMotherboardDevice(IN AML_OBJECT_NODE_HANDLE PciNode, OUT AML_OBJECT_NODE_HANDLE *CrsNode)
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 MappingTableInitialize(IN MAPPING_TABLE *MappingTable, IN UINT32 Count)
EFI_STATUS EFIAPI AcpiSsdtPcieLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
STATIC VOID EFIAPI MappingTableFree(IN OUT MAPPING_TABLE *MappingTable)
STATIC UINT32 EFIAPI MappingTableAdd(IN MAPPING_TABLE *MappingTable, IN UINT32 Integer)
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 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)
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 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 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 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)
#define MAX_PCI_ROOT_COMPLEXES_SUPPORTED
EFI_STATUS EFIAPI GeneratePciSlots(IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN CONST MAPPING_TABLE *MappingTable, IN UINT32 Uid, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
EFI_STATUS EFIAPI AddOscMethod(IN CONST CM_ARCH_COMMON_PCI_CONFIG_SPACE_INFO *PciInfo, IN OUT AML_OBJECT_NODE_HANDLE PciNode)
EFI_STATUS EFIAPI AddSsdtAcpiHeader(IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN CONST ACPI_TABLE_GENERATOR *CONST Generator, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, OUT AML_ROOT_NODE_HANDLE *RootNode)
EFI_STATUS EFIAPI AmlDeleteTree(IN AML_NODE_HANDLE Node)
EFI_STATUS EFIAPI AmlSerializeDefinitionBlock(IN AML_ROOT_NODE_HANDLE RootNode, OUT EFI_ACPI_DESCRIPTION_HEADER **Table)
ACPI_TABLE_GENERATOR Header
ACPI Table generator header.
UINT32 Interrupt
Interrupt number.
UINT64 AddressSize
Address size.
UINT64 CpuAddress
Cpu address.
UINT64 PciAddress
PCI address.
UINT16 PciSegmentGroupNumber
The PCI segment group number.
CM_ARCH_COMMON_GENERIC_INTERRUPT IntcInterrupt
UINT32 MaxIndex
Number of entries in the Table.