2
0

pci.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #include "qemu/osdep.h"
  24. #include "hw/acpi/aml-build.h"
  25. #include "hw/acpi/pci.h"
  26. #include "hw/pci/pcie_host.h"
  27. /*
  28. * PCI Firmware Specification, Revision 3.0
  29. * 4.1.2 MCFG Table Description.
  30. */
  31. void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
  32. const char *oem_id, const char *oem_table_id)
  33. {
  34. AcpiTable table = { .sig = "MCFG", .rev = 1,
  35. .oem_id = oem_id, .oem_table_id = oem_table_id };
  36. acpi_table_begin(&table, table_data);
  37. /* Reserved */
  38. build_append_int_noprefix(table_data, 0, 8);
  39. /*
  40. * Memory Mapped Enhanced Configuration Space Base Address Allocation
  41. * Structure
  42. */
  43. /* Base address, processor-relative */
  44. build_append_int_noprefix(table_data, info->base, 8);
  45. /* PCI segment group number */
  46. build_append_int_noprefix(table_data, 0, 2);
  47. /* Starting PCI Bus number */
  48. build_append_int_noprefix(table_data, 0, 1);
  49. /* Final PCI Bus number */
  50. build_append_int_noprefix(table_data, PCIE_MMCFG_BUS(info->size - 1), 1);
  51. /* Reserved */
  52. build_append_int_noprefix(table_data, 0, 4);
  53. acpi_table_end(linker, &table);
  54. }