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 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 27 #ifndef HW_ACPI_PCIHP_H 28 #define HW_ACPI_PCIHP_H 29 30 #include <inttypes.h> 31 #include <qemu/typedefs.h> 32 #include "hw/acpi/acpi.h" 33 #include "migration/vmstate.h" 34 35 typedef struct AcpiPciHpPciStatus { 36 uint32_t up; 37 uint32_t down; 38 uint32_t hotplug_enable; 39 } AcpiPciHpPciStatus; 40 41 #define ACPI_PCIHP_PROP_BSEL "acpi-pcihp-bsel" 42 #define ACPI_PCIHP_MAX_HOTPLUG_BUS 256 43 #define ACPI_PCIHP_BSEL_DEFAULT 0x0 44 45 typedef struct AcpiPciHpState { 46 AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS]; 47 uint32_t hotplug_select; 48 PCIBus *root; 49 MemoryRegion io; 50 bool legacy_piix; 51 } AcpiPciHpState; 52 53 void acpi_pcihp_init(AcpiPciHpState *, PCIBus *root, 54 MemoryRegion *address_space_io, bool bridges_enabled); 55 56 void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, 57 DeviceState *dev, Error **errp); 58 void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, 59 DeviceState *dev, Error **errp); 60 61 /* Called on reset */ 62 void acpi_pcihp_reset(AcpiPciHpState *s); 63 64 extern const VMStateDescription vmstate_acpi_pcihp_pci_status; 65 66 #define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp) \ 67 VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \ 68 test_pcihp), \ 69 VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \ 70 ACPI_PCIHP_MAX_HOTPLUG_BUS, \ 71 test_pcihp, 1, \ 72 vmstate_acpi_pcihp_pci_status, \ 73 AcpiPciHpPciStatus) 74 75 #endif 76