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 31f13a944cSWei Yang void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info) 32f13a944cSWei Yang { 33*e4610781SWei Yang int mcfg_start = table_data->len; 34f13a944cSWei Yang 35*e4610781SWei Yang /* 36*e4610781SWei Yang * PCI Firmware Specification, Revision 3.0 37*e4610781SWei Yang * 4.1.2 MCFG Table Description. 38*e4610781SWei Yang */ 39*e4610781SWei Yang acpi_data_push(table_data, sizeof(AcpiTableHeader)); 40*e4610781SWei Yang /* Reserved */ 41*e4610781SWei Yang build_append_int_noprefix(table_data, 0, 8); 42f13a944cSWei Yang 43*e4610781SWei Yang /* 44*e4610781SWei Yang * Memory Mapped Enhanced Configuration Space Base Address Allocation 45*e4610781SWei Yang * Structure 46*e4610781SWei Yang */ 47*e4610781SWei Yang /* Base address, processor-relative */ 48*e4610781SWei Yang build_append_int_noprefix(table_data, info->base, 8); 49*e4610781SWei Yang /* PCI segment group number */ 50*e4610781SWei Yang build_append_int_noprefix(table_data, 0, 2); 51*e4610781SWei Yang /* Starting PCI Bus number */ 52*e4610781SWei Yang build_append_int_noprefix(table_data, 0, 1); 53*e4610781SWei Yang /* Final PCI Bus number */ 54*e4610781SWei Yang build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1); 55*e4610781SWei Yang /* Reserved */ 56*e4610781SWei Yang build_append_int_noprefix(table_data, 0, 4); 57f13a944cSWei Yang 58*e4610781SWei Yang build_header(linker, table_data, (void *)(table_data->data + mcfg_start), 59*e4610781SWei Yang "MCFG", table_data->len - mcfg_start, 1, NULL, NULL); 60f13a944cSWei Yang } 61f13a944cSWei Yang 62