Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 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 | |
Peter Maydell | b6a0aa0 | 2016-01-26 18:17:03 +0000 | [diff] [blame] | 27 | #include "qemu/osdep.h" |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 28 | #include "hw/acpi/pcihp.h" |
| 29 | |
| 30 | #include "hw/hw.h" |
| 31 | #include "hw/i386/pc.h" |
| 32 | #include "hw/pci/pci.h" |
| 33 | #include "hw/acpi/acpi.h" |
| 34 | #include "sysemu/sysemu.h" |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 35 | #include "exec/ioport.h" |
| 36 | #include "exec/address-spaces.h" |
| 37 | #include "hw/pci/pci_bus.h" |
Markus Armbruster | da34e65 | 2016-03-14 09:01:28 +0100 | [diff] [blame] | 38 | #include "qapi/error.h" |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 39 | #include "qom/qom-qobject.h" |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 40 | |
| 41 | //#define DEBUG |
| 42 | |
| 43 | #ifdef DEBUG |
| 44 | # define ACPI_PCIHP_DPRINTF(format, ...) printf(format, ## __VA_ARGS__) |
| 45 | #else |
| 46 | # define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0) |
| 47 | #endif |
| 48 | |
Igor Mammedov | e358edc | 2014-02-03 11:45:01 +0100 | [diff] [blame] | 49 | #define ACPI_PCIHP_ADDR 0xae00 |
| 50 | #define ACPI_PCIHP_SIZE 0x0014 |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 51 | #define PCI_UP_BASE 0x0000 |
| 52 | #define PCI_DOWN_BASE 0x0004 |
| 53 | #define PCI_EJ_BASE 0x0008 |
| 54 | #define PCI_RMV_BASE 0x000c |
| 55 | #define PCI_SEL_BASE 0x0010 |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 56 | |
| 57 | typedef struct AcpiPciHpFind { |
| 58 | int bsel; |
| 59 | PCIBus *bus; |
| 60 | } AcpiPciHpFind; |
| 61 | |
| 62 | static int acpi_pcihp_get_bsel(PCIBus *bus) |
| 63 | { |
Kirill Batuzov | 7c38ecd | 2014-04-24 18:15:56 +0400 | [diff] [blame] | 64 | Error *local_err = NULL; |
Marc-André Lureau | c03d83d | 2017-06-07 20:36:15 +0400 | [diff] [blame] | 65 | uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, |
| 66 | &local_err); |
Kirill Batuzov | 7c38ecd | 2014-04-24 18:15:56 +0400 | [diff] [blame] | 67 | |
Marc-André Lureau | c03d83d | 2017-06-07 20:36:15 +0400 | [diff] [blame] | 68 | if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { |
Kirill Batuzov | 7c38ecd | 2014-04-24 18:15:56 +0400 | [diff] [blame] | 69 | if (local_err) { |
| 70 | error_free(local_err); |
| 71 | } |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 72 | return -1; |
Kirill Batuzov | 7c38ecd | 2014-04-24 18:15:56 +0400 | [diff] [blame] | 73 | } else { |
| 74 | return bsel; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 75 | } |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 76 | } |
| 77 | |
Anthony PERARD | ab938ae | 2017-09-06 14:40:32 +0100 | [diff] [blame] | 78 | /* Assign BSEL property to all buses. In the future, this can be changed |
| 79 | * to only assign to buses that support hotplug. |
| 80 | */ |
| 81 | static void *acpi_set_bsel(PCIBus *bus, void *opaque) |
| 82 | { |
| 83 | unsigned *bsel_alloc = opaque; |
| 84 | unsigned *bus_bsel; |
| 85 | |
| 86 | if (qbus_is_hotpluggable(BUS(bus))) { |
| 87 | bus_bsel = g_malloc(sizeof *bus_bsel); |
| 88 | |
| 89 | *bus_bsel = (*bsel_alloc)++; |
| 90 | object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, |
| 91 | bus_bsel, &error_abort); |
| 92 | } |
| 93 | |
| 94 | return bsel_alloc; |
| 95 | } |
| 96 | |
| 97 | static void acpi_set_pci_info(void) |
| 98 | { |
| 99 | static bool bsel_is_set; |
| 100 | PCIBus *bus; |
| 101 | unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT; |
| 102 | |
| 103 | if (bsel_is_set) { |
| 104 | return; |
| 105 | } |
| 106 | bsel_is_set = true; |
| 107 | |
| 108 | bus = find_i440fx(); /* TODO: Q35 support */ |
| 109 | if (bus) { |
| 110 | /* Scan all PCI buses. Set property to enable acpi based hotplug. */ |
| 111 | pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc); |
| 112 | } |
| 113 | } |
| 114 | |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 115 | static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) |
| 116 | { |
| 117 | AcpiPciHpFind *find = opaque; |
| 118 | if (find->bsel == acpi_pcihp_get_bsel(bus)) { |
| 119 | find->bus = bus; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static PCIBus *acpi_pcihp_find_hotplug_bus(AcpiPciHpState *s, int bsel) |
| 124 | { |
| 125 | AcpiPciHpFind find = { .bsel = bsel, .bus = NULL }; |
| 126 | |
| 127 | if (bsel < 0) { |
| 128 | return NULL; |
| 129 | } |
| 130 | |
| 131 | pci_for_each_bus(s->root, acpi_pcihp_test_hotplug_bus, &find); |
| 132 | |
| 133 | /* Make bsel 0 eject root bus if bsel property is not set, |
| 134 | * for compatibility with non acpi setups. |
| 135 | * TODO: really needed? |
| 136 | */ |
| 137 | if (!bsel && !find.bus) { |
| 138 | find.bus = s->root; |
| 139 | } |
| 140 | return find.bus; |
| 141 | } |
| 142 | |
| 143 | static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev) |
| 144 | { |
| 145 | PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); |
Igor Mammedov | 2897ae0 | 2014-02-05 16:36:48 +0100 | [diff] [blame] | 146 | DeviceClass *dc = DEVICE_GET_CLASS(dev); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 147 | /* |
| 148 | * ACPI doesn't allow hotplug of bridge devices. Don't allow |
| 149 | * hot-unplug of bridge devices unless they were added by hotplug |
| 150 | * (and so, not described by acpi). |
| 151 | */ |
Igor Mammedov | 2897ae0 | 2014-02-05 16:36:48 +0100 | [diff] [blame] | 152 | return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned slots) |
| 156 | { |
| 157 | BusChild *kid, *next; |
Stefan Hajnoczi | 786a4ea | 2015-03-23 15:29:26 +0000 | [diff] [blame] | 158 | int slot = ctz32(slots); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 159 | PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); |
| 160 | |
| 161 | if (!bus) { |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | /* Mark request as complete */ |
| 166 | s->acpi_pcihp_pci_status[bsel].down &= ~(1U << slot); |
Michael S. Tsirkin | 5a2223c | 2014-01-26 12:31:27 +0200 | [diff] [blame] | 167 | s->acpi_pcihp_pci_status[bsel].up &= ~(1U << slot); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 168 | |
| 169 | QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { |
| 170 | DeviceState *qdev = kid->child; |
| 171 | PCIDevice *dev = PCI_DEVICE(qdev); |
| 172 | if (PCI_SLOT(dev->devfn) == slot) { |
Michael S. Tsirkin | 5a2223c | 2014-01-26 12:31:27 +0200 | [diff] [blame] | 173 | if (!acpi_pcihp_pc_no_hotplug(s, dev)) { |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 174 | object_unparent(OBJECT(qdev)); |
| 175 | } |
| 176 | } |
| 177 | } |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static void acpi_pcihp_update_hotplug_bus(AcpiPciHpState *s, int bsel) |
| 181 | { |
| 182 | BusChild *kid, *next; |
| 183 | PCIBus *bus = acpi_pcihp_find_hotplug_bus(s, bsel); |
| 184 | |
| 185 | /* Execute any pending removes during reset */ |
| 186 | while (s->acpi_pcihp_pci_status[bsel].down) { |
| 187 | acpi_pcihp_eject_slot(s, bsel, s->acpi_pcihp_pci_status[bsel].down); |
| 188 | } |
| 189 | |
| 190 | s->acpi_pcihp_pci_status[bsel].hotplug_enable = ~0; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 191 | |
| 192 | if (!bus) { |
| 193 | return; |
| 194 | } |
| 195 | QTAILQ_FOREACH_SAFE(kid, &bus->qbus.children, sibling, next) { |
| 196 | DeviceState *qdev = kid->child; |
| 197 | PCIDevice *pdev = PCI_DEVICE(qdev); |
| 198 | int slot = PCI_SLOT(pdev->devfn); |
| 199 | |
| 200 | if (acpi_pcihp_pc_no_hotplug(s, pdev)) { |
| 201 | s->acpi_pcihp_pci_status[bsel].hotplug_enable &= ~(1U << slot); |
| 202 | } |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | |
| 206 | static void acpi_pcihp_update(AcpiPciHpState *s) |
| 207 | { |
| 208 | int i; |
| 209 | |
| 210 | for (i = 0; i < ACPI_PCIHP_MAX_HOTPLUG_BUS; ++i) { |
| 211 | acpi_pcihp_update_hotplug_bus(s, i); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | void acpi_pcihp_reset(AcpiPciHpState *s) |
| 216 | { |
Anthony PERARD | ab938ae | 2017-09-06 14:40:32 +0100 | [diff] [blame] | 217 | acpi_set_pci_info(); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 218 | acpi_pcihp_update(s); |
| 219 | } |
| 220 | |
Igor Mammedov | 0058c08 | 2016-05-31 12:01:17 +0200 | [diff] [blame] | 221 | void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 222 | DeviceState *dev, Error **errp) |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 223 | { |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 224 | PCIDevice *pdev = PCI_DEVICE(dev); |
| 225 | int slot = PCI_SLOT(pdev->devfn); |
David Gibson | fd56e06 | 2017-11-29 19:46:27 +1100 | [diff] [blame] | 226 | int bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev)); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 227 | if (bsel < 0) { |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 228 | error_setg(errp, "Unsupported bus. Bus doesn't have property '" |
| 229 | ACPI_PCIHP_PROP_BSEL "' set"); |
| 230 | return; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /* Don't send event when device is enabled during qemu machine creation: |
| 234 | * it is present on boot, no hotplug event is necessary. We do send an |
| 235 | * event when the device is disabled later. */ |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 236 | if (!dev->hotplugged) { |
| 237 | return; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 238 | } |
| 239 | |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 240 | s->acpi_pcihp_pci_status[bsel].up |= (1U << slot); |
Igor Mammedov | 0058c08 | 2016-05-31 12:01:17 +0200 | [diff] [blame] | 241 | acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 242 | } |
| 243 | |
Igor Mammedov | 0058c08 | 2016-05-31 12:01:17 +0200 | [diff] [blame] | 244 | void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 245 | DeviceState *dev, Error **errp) |
| 246 | { |
| 247 | PCIDevice *pdev = PCI_DEVICE(dev); |
| 248 | int slot = PCI_SLOT(pdev->devfn); |
David Gibson | fd56e06 | 2017-11-29 19:46:27 +1100 | [diff] [blame] | 249 | int bsel = acpi_pcihp_get_bsel(pci_get_bus(pdev)); |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 250 | if (bsel < 0) { |
| 251 | error_setg(errp, "Unsupported bus. Bus doesn't have property '" |
| 252 | ACPI_PCIHP_PROP_BSEL "' set"); |
| 253 | return; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 254 | } |
| 255 | |
Igor Mammedov | c24d5e0 | 2014-02-05 16:36:49 +0100 | [diff] [blame] | 256 | s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); |
Igor Mammedov | 0058c08 | 2016-05-31 12:01:17 +0200 | [diff] [blame] | 257 | acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size) |
| 261 | { |
| 262 | AcpiPciHpState *s = opaque; |
| 263 | uint32_t val = 0; |
| 264 | int bsel = s->hotplug_select; |
| 265 | |
Gonglei | fa365d7 | 2014-08-20 13:52:30 +0800 | [diff] [blame] | 266 | if (bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | switch (addr) { |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 271 | case PCI_UP_BASE: |
Michael S. Tsirkin | 5a2223c | 2014-01-26 12:31:27 +0200 | [diff] [blame] | 272 | val = s->acpi_pcihp_pci_status[bsel].up; |
Igor Mammedov | 99d09dd | 2014-02-03 11:44:59 +0100 | [diff] [blame] | 273 | if (!s->legacy_piix) { |
| 274 | s->acpi_pcihp_pci_status[bsel].up = 0; |
| 275 | } |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 276 | ACPI_PCIHP_DPRINTF("pci_up_read %" PRIu32 "\n", val); |
| 277 | break; |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 278 | case PCI_DOWN_BASE: |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 279 | val = s->acpi_pcihp_pci_status[bsel].down; |
| 280 | ACPI_PCIHP_DPRINTF("pci_down_read %" PRIu32 "\n", val); |
| 281 | break; |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 282 | case PCI_EJ_BASE: |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 283 | /* No feature defined yet */ |
| 284 | ACPI_PCIHP_DPRINTF("pci_features_read %" PRIu32 "\n", val); |
| 285 | break; |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 286 | case PCI_RMV_BASE: |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 287 | val = s->acpi_pcihp_pci_status[bsel].hotplug_enable; |
| 288 | ACPI_PCIHP_DPRINTF("pci_rmv_read %" PRIu32 "\n", val); |
| 289 | break; |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 290 | case PCI_SEL_BASE: |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 291 | val = s->hotplug_select; |
| 292 | ACPI_PCIHP_DPRINTF("pci_sel_read %" PRIu32 "\n", val); |
| 293 | default: |
| 294 | break; |
| 295 | } |
| 296 | |
| 297 | return val; |
| 298 | } |
| 299 | |
| 300 | static void pci_write(void *opaque, hwaddr addr, uint64_t data, |
| 301 | unsigned int size) |
| 302 | { |
| 303 | AcpiPciHpState *s = opaque; |
| 304 | switch (addr) { |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 305 | case PCI_EJ_BASE: |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 306 | if (s->hotplug_select >= ACPI_PCIHP_MAX_HOTPLUG_BUS) { |
| 307 | break; |
| 308 | } |
| 309 | acpi_pcihp_eject_slot(s, s->hotplug_select, data); |
| 310 | ACPI_PCIHP_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n", |
| 311 | addr, data); |
| 312 | break; |
Igor Mammedov | a7b613c | 2014-02-03 11:44:58 +0100 | [diff] [blame] | 313 | case PCI_SEL_BASE: |
Anthony PERARD | f585599 | 2017-09-06 14:40:31 +0100 | [diff] [blame] | 314 | s->hotplug_select = s->legacy_piix ? ACPI_PCIHP_BSEL_DEFAULT : data; |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 315 | ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <== %" PRIu64 "\n", |
| 316 | addr, data); |
| 317 | default: |
| 318 | break; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | static const MemoryRegionOps acpi_pcihp_io_ops = { |
| 323 | .read = pci_read, |
| 324 | .write = pci_write, |
| 325 | .endianness = DEVICE_LITTLE_ENDIAN, |
| 326 | .valid = { |
| 327 | .min_access_size = 4, |
| 328 | .max_access_size = 4, |
| 329 | }, |
| 330 | }; |
| 331 | |
Igor Mammedov | 78c2d87 | 2015-02-18 19:14:49 +0000 | [diff] [blame] | 332 | void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, |
Igor Mammedov | 99d09dd | 2014-02-03 11:44:59 +0100 | [diff] [blame] | 333 | MemoryRegion *address_space_io, bool bridges_enabled) |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 334 | { |
Igor Mammedov | 78c2d87 | 2015-02-18 19:14:49 +0000 | [diff] [blame] | 335 | s->io_len = ACPI_PCIHP_SIZE; |
| 336 | s->io_base = ACPI_PCIHP_ADDR; |
Igor Mammedov | e358edc | 2014-02-03 11:45:01 +0100 | [diff] [blame] | 337 | |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 338 | s->root= root_bus; |
Igor Mammedov | 99d09dd | 2014-02-03 11:44:59 +0100 | [diff] [blame] | 339 | s->legacy_piix = !bridges_enabled; |
Igor Mammedov | e358edc | 2014-02-03 11:45:01 +0100 | [diff] [blame] | 340 | |
Igor Mammedov | 78c2d87 | 2015-02-18 19:14:49 +0000 | [diff] [blame] | 341 | memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s, |
| 342 | "acpi-pci-hotplug", s->io_len); |
| 343 | memory_region_add_subregion(address_space_io, s->io_base, &s->io); |
| 344 | |
| 345 | object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_BASE_PROP, &s->io_base, |
| 346 | &error_abort); |
| 347 | object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_LEN_PROP, &s->io_len, |
| 348 | &error_abort); |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | const VMStateDescription vmstate_acpi_pcihp_pci_status = { |
| 352 | .name = "acpi_pcihp_pci_status", |
| 353 | .version_id = 1, |
| 354 | .minimum_version_id = 1, |
Juan Quintela | d49805a | 2014-04-16 15:32:32 +0200 | [diff] [blame] | 355 | .fields = (VMStateField[]) { |
Michael S. Tsirkin | db4728e | 2013-10-14 18:01:11 +0300 | [diff] [blame] | 356 | VMSTATE_UINT32(up, AcpiPciHpPciStatus), |
| 357 | VMSTATE_UINT32(down, AcpiPciHpPciStatus), |
| 358 | VMSTATE_END_OF_LIST() |
| 359 | } |
| 360 | }; |