xref: /openbmc/qemu/include/hw/acpi/pcihp.h (revision b2c623a3)
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/pci/pci.h" /* for PCIHotplugState */
33 
34 typedef struct AcpiPciHpPciStatus {
35     uint32_t up; /* deprecated, maintained for migration compatibility */
36     uint32_t down;
37     uint32_t hotplug_enable;
38     uint32_t device_present;
39 } AcpiPciHpPciStatus;
40 
41 #define ACPI_PCIHP_PROP_BSEL "acpi-pcihp-bsel"
42 #define ACPI_PCIHP_MAX_HOTPLUG_BUS 256
43 
44 typedef struct AcpiPciHpState {
45     AcpiPciHpPciStatus acpi_pcihp_pci_status[ACPI_PCIHP_MAX_HOTPLUG_BUS];
46     uint32_t hotplug_select;
47     PCIBus *root;
48     MemoryRegion io;
49 } AcpiPciHpState;
50 
51 void acpi_pcihp_init(AcpiPciHpState *, PCIBus *root,
52                      MemoryRegion *address_space_io);
53 
54 /* Invoke on device hotplug */
55 int acpi_pcihp_device_hotplug(AcpiPciHpState *, PCIDevice *,
56                               PCIHotplugState state);
57 
58 /* Called on reset */
59 void acpi_pcihp_reset(AcpiPciHpState *s);
60 
61 extern const VMStateDescription vmstate_acpi_pcihp_pci_status;
62 
63 #define VMSTATE_PCI_HOTPLUG(pcihp, state, test_pcihp) \
64         VMSTATE_UINT32_TEST(pcihp.hotplug_select, state, \
65                             test_pcihp), \
66         VMSTATE_STRUCT_ARRAY_TEST(pcihp.acpi_pcihp_pci_status, state, \
67                                   ACPI_PCIHP_MAX_HOTPLUG_BUS, \
68                                   test_pcihp, 1, \
69                                   vmstate_acpi_pcihp_pci_status, \
70                                   AcpiPciHpPciStatus)
71 
72 #endif
73