1f13a944cSWei Yang /* 2f13a944cSWei Yang * Support for generating PCI related ACPI tables and passing them to Guests 3f13a944cSWei Yang * 4f13a944cSWei Yang * Copyright (C) 2006 Fabrice Bellard 5f13a944cSWei Yang * Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net> 6f13a944cSWei Yang * Copyright (C) 2013-2019 Red Hat Inc 7f13a944cSWei Yang * Copyright (C) 2019 Intel Corporation 8f13a944cSWei Yang * 9f13a944cSWei Yang * Author: Wei Yang <richardw.yang@linux.intel.com> 10f13a944cSWei Yang * Author: Michael S. Tsirkin <mst@redhat.com> 11f13a944cSWei Yang * 12f13a944cSWei Yang * This program is free software; you can redistribute it and/or modify 13f13a944cSWei Yang * it under the terms of the GNU General Public License as published by 14f13a944cSWei Yang * the Free Software Foundation; either version 2 of the License, or 15f13a944cSWei Yang * (at your option) any later version. 16f13a944cSWei Yang 17f13a944cSWei Yang * This program is distributed in the hope that it will be useful, 18f13a944cSWei Yang * but WITHOUT ANY WARRANTY; without even the implied warranty of 19f13a944cSWei Yang * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20f13a944cSWei Yang * GNU General Public License for more details. 21f13a944cSWei Yang 22f13a944cSWei Yang * You should have received a copy of the GNU General Public License along 23f13a944cSWei Yang * with this program; if not, see <http://www.gnu.org/licenses/>. 24f13a944cSWei Yang */ 25f13a944cSWei Yang 26f13a944cSWei Yang #include "qemu/osdep.h" 27f13a944cSWei Yang #include "hw/acpi/aml-build.h" 28f13a944cSWei Yang #include "hw/acpi/pci.h" 29f13a944cSWei Yang #include "hw/pci/pcie_host.h" 30f13a944cSWei Yang 31e4610781SWei Yang /* 32e4610781SWei Yang * PCI Firmware Specification, Revision 3.0 33e4610781SWei Yang * 4.1.2 MCFG Table Description. 34e4610781SWei Yang */ 35*578bc7a0SIgor Mammedov void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info, 36*578bc7a0SIgor Mammedov const char *oem_id, const char *oem_table_id) 37*578bc7a0SIgor Mammedov { 38*578bc7a0SIgor Mammedov AcpiTable table = { .sig = "MCFG", .rev = 1, 39*578bc7a0SIgor Mammedov .oem_id = oem_id, .oem_table_id = oem_table_id }; 40*578bc7a0SIgor Mammedov 41*578bc7a0SIgor Mammedov acpi_table_begin(&table, table_data); 42*578bc7a0SIgor Mammedov 43e4610781SWei Yang /* Reserved */ 44e4610781SWei Yang build_append_int_noprefix(table_data, 0, 8); 45e4610781SWei Yang /* 46e4610781SWei Yang * Memory Mapped Enhanced Configuration Space Base Address Allocation 47e4610781SWei Yang * Structure 48e4610781SWei Yang */ 49e4610781SWei Yang /* Base address, processor-relative */ 50e4610781SWei Yang build_append_int_noprefix(table_data, info->base, 8); 51e4610781SWei Yang /* PCI segment group number */ 52e4610781SWei Yang build_append_int_noprefix(table_data, 0, 2); 53e4610781SWei Yang /* Starting PCI Bus number */ 54e4610781SWei Yang build_append_int_noprefix(table_data, 0, 1); 55e4610781SWei Yang /* Final PCI Bus number */ 56e4610781SWei Yang build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1); 57e4610781SWei Yang /* Reserved */ 58e4610781SWei Yang build_append_int_noprefix(table_data, 0, 4); 59f13a944cSWei Yang 60*578bc7a0SIgor Mammedov acpi_table_end(linker, &table); 61f13a944cSWei Yang } 62