/** @file
 *
 *  PCI Express Memory-mapped Configuration Space base address description table (MCFG)
 *
 *  Copyright (c) 2021, Jared McNeill <jmcneill@invisible.ca>
 *  Copyright (c) 2024, Mario Bălănică <mariobalanica02@gmail.com>
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
 **/

#include "AcpiTables.h"

//
// MCFG is patched by AcpiPlatformDxe.
//

RK3588_MCFG_TABLE Mcfg = {
  {
    ACPI_HEADER (
      EFI_ACPI_6_4_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE,
      RK3588_MCFG_TABLE,
      EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION
      ),
  },
  { // Main config space
    {
      PCIE_CFG_BASE (0),
      0,  // PciSegmentNumber
      1,  // PciBusMin
      1,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_CFG_BASE (1),
      1,  // PciSegmentNumber
      1,  // PciBusMin
      1,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_CFG_BASE (2),
      2,  // PciSegmentNumber
      1,  // PciBusMin
      1,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_CFG_BASE (3),
      3,  // PciSegmentNumber
      1,  // PciBusMin
      1,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_CFG_BASE (4),
      4,  // PciSegmentNumber
      1,  // PciBusMin
      1,  // PciBusMax
      0   // Reserved
    }
  },
  { // Root Port DBI config space (for Windows)
    {
      PCIE_DBI_BASE (0),
      0,  // PciSegmentNumber
      0,  // PciBusMin
      0,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_DBI_BASE (1),
      1,  // PciSegmentNumber
      0,  // PciBusMin
      0,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_DBI_BASE (2),
      2,  // PciSegmentNumber
      0,  // PciBusMin
      0,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_DBI_BASE (3),
      3,  // PciSegmentNumber
      0,  // PciBusMin
      0,  // PciBusMax
      0   // Reserved
    },
    {
      PCIE_DBI_BASE (4),
      4,  // PciSegmentNumber
      0,  // PciBusMin
      0,  // PciBusMax
      0   // Reserved
    }
  }
};

VOID* CONST ReferenceAcpiTable = &Mcfg;
