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