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