pcihp.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * QEMU<->ACPI BIOS PCI hotplug interface
  3. *
  4. * QEMU supports PCI hotplug via ACPI. This module
  5. * implements the interface between QEMU and the ACPI BIOS.
  6. * Interface specification - see docs/specs/acpi_pci_hotplug.txt
  7. *
  8. * Copyright (c) 2013, Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)
  9. * Copyright (c) 2006 Fabrice Bellard
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License version 2.1 as published by the Free Software Foundation.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, see <http://www.gnu.org/licenses/>
  22. *
  23. * Contributions after 2012-01-13 are licensed under the terms of the
  24. * GNU GPL, version 2 or (at your option) any later version.
  25. */
  26. #ifndef HW_ACPI_PCIHP_H
  27. #define HW_ACPI_PCIHP_H
  28. #include "hw/acpi/acpi.h"
  29. #include "hw/hotplug.h"
  30. #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
  31. #define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
  32. typedef struct AcpiPciHpPciStatus {
  33. uint32_t up;
  34. uint32_t down;
  35. uint32_t hotplug_enable;
  36. } AcpiPciHpPciStatus;
  37. #define ACPI_PCIHP_PROP_BSEL "acpi-pcihp-bsel"
  38. #define ACPI_PCIHP_MAX_HOTPLUG_BUS 256
  39. #define ACPI_PCIHP_BSEL_DEFAULT 0x0
  40. typedef struct AcpiPciHpState {
  41. AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS];
  42. uint32_t hotplug_select;
  43. uint32_t acpi_index;
  44. PCIBus *root;
  45. MemoryRegion io;
  46. uint16_t io_base;
  47. uint16_t io_len;
  48. bool use_acpi_hotplug_bridge;
  49. bool use_acpi_root_pci_hotplug;
  50. } AcpiPciHpState;
  51. void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root,
  52. MemoryRegion *io, uint16_t io_base);
  53. bool acpi_pcihp_is_hotpluggbale_bus(AcpiPciHpState *s, BusState *bus);
  54. void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
  55. DeviceState *dev, Error **errp);
  56. void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
  57. DeviceState *dev, Error **errp);
  58. void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
  59. DeviceState *dev, Error **errp);
  60. void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
  61. AcpiPciHpState *s, DeviceState *dev,
  62. Error **errp);
  63. /* Called on reset */
  64. void acpi_pcihp_reset(AcpiPciHpState *s);
  65. void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus);
  66. extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
  67. #define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp, test_acpi_index) \
  68. VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
  69. test_pcihp), \
  70. VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
  71. ACPI_PCIHP_MAX_HOTPLUG_BUS, \
  72. test_pcihp, 1, \
  73. vmstate_acpi_pcihp_pci_status, \
  74. AcpiPciHpPciStatus), \
  75. VMSTATE_UINT32_TEST(pcihp.acpi_index, state, \
  76. test_acpi_index)
  77. #endif