4 * Copyright (c) 2006 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2 as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>
18 * Contributions after 2012-01-13 are licensed under the terms of the
19 * GNU GPL, version 2 or (at your option) any later version.
22 #include "hw/i386/pc.h"
23 #include "hw/isa/apm.h"
24 #include "hw/i2c/pm_smbus.h"
25 #include "hw/pci/pci.h"
26 #include "hw/acpi/acpi.h"
27 #include "sysemu/sysemu.h"
28 #include "qemu/range.h"
29 #include "exec/ioport.h"
30 #include "hw/nvram/fw_cfg.h"
31 #include "exec/address-spaces.h"
32 #include "hw/acpi/piix4.h"
37 # define PIIX4_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
39 # define PIIX4_DPRINTF(format, ...) do { } while (0)
42 #define GPE_BASE 0xafe0
45 #define PCI_HOTPLUG_ADDR 0xae00
46 #define PCI_HOTPLUG_SIZE 0x000f
47 #define PCI_UP_BASE 0xae00
48 #define PCI_DOWN_BASE 0xae04
49 #define PCI_EJ_BASE 0xae08
50 #define PCI_RMV_BASE 0xae0c
52 #define PIIX4_PROC_BASE 0xaf00
53 #define PIIX4_PROC_LEN 32
55 #define PIIX4_PCI_HOTPLUG_STATUS 2
56 #define PIIX4_CPU_HOTPLUG_STATUS 4
59 uint32_t up; /* deprecated, maintained for migration compatibility */
63 typedef struct CPUStatus {
64 uint8_t sts[PIIX4_PROC_LEN];
67 typedef struct PIIX4PMState {
88 Notifier machine_ready;
89 Notifier powerdown_notifier;
92 struct pci_status pci0_status;
93 uint32_t pci0_hotplug_enable;
94 uint32_t pci0_slot_device_present;
101 Notifier cpu_added_notifier;
104 #define TYPE_PIIX4_PM "PIIX4_PM"
106 #define PIIX4_PM(obj) \
107 OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM)
109 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
110 PCIBus *bus, PIIX4PMState *s);
112 #define ACPI_ENABLE 0xf1
113 #define ACPI_DISABLE 0xf0
115 static void pm_tmr_timer(ACPIREGS *ar)
117 PIIX4PMState *s = container_of(ar, PIIX4PMState, ar);
118 acpi_update_sci(&s->ar, s->irq);
121 static void apm_ctrl_changed(uint32_t val, void *arg)
123 PIIX4PMState *s = arg;
124 PCIDevice *d = PCI_DEVICE(s);
126 /* ACPI specs 3.0, 4.7.2.5 */
127 acpi_pm1_cnt_update(&s->ar, val == ACPI_ENABLE, val == ACPI_DISABLE);
129 if (d->config[0x5b] & (1 << 1)) {
131 qemu_irq_raise(s->smi_irq);
136 static void pm_io_space_update(PIIX4PMState *s)
138 PCIDevice *d = PCI_DEVICE(s);
140 s->io_base = le32_to_cpu(*(uint32_t *)(d->config + 0x40));
141 s->io_base &= 0xffc0;
143 memory_region_transaction_begin();
144 memory_region_set_enabled(&s->io, d->config[0x80] & 1);
145 memory_region_set_address(&s->io, s->io_base);
146 memory_region_transaction_commit();
149 static void smbus_io_space_update(PIIX4PMState *s)
151 PCIDevice *d = PCI_DEVICE(s);
153 s->smb_io_base = le32_to_cpu(*(uint32_t *)(d->config + 0x90));
154 s->smb_io_base &= 0xffc0;
156 memory_region_transaction_begin();
157 memory_region_set_enabled(&s->smb.io, d->config[0xd2] & 1);
158 memory_region_set_address(&s->smb.io, s->smb_io_base);
159 memory_region_transaction_commit();
162 static void pm_write_config(PCIDevice *d,
163 uint32_t address, uint32_t val, int len)
165 pci_default_write_config(d, address, val, len);
166 if (range_covers_byte(address, len, 0x80) ||
167 ranges_overlap(address, len, 0x40, 4)) {
168 pm_io_space_update((PIIX4PMState *)d);
170 if (range_covers_byte(address, len, 0xd2) ||
171 ranges_overlap(address, len, 0x90, 4)) {
172 smbus_io_space_update((PIIX4PMState *)d);
176 static void vmstate_pci_status_pre_save(void *opaque)
178 struct pci_status *pci0_status = opaque;
179 PIIX4PMState *s = container_of(pci0_status, PIIX4PMState, pci0_status);
181 /* We no longer track up, so build a safe value for migrating
182 * to a version that still does... of course these might get lost
183 * by an old buggy implementation, but we try. */
184 pci0_status->up = s->pci0_slot_device_present & s->pci0_hotplug_enable;
187 static int vmstate_acpi_post_load(void *opaque, int version_id)
189 PIIX4PMState *s = opaque;
191 pm_io_space_update(s);
195 #define VMSTATE_GPE_ARRAY(_field, _state) \
197 .name = (stringify(_field)), \
199 .info = &vmstate_info_uint16, \
200 .size = sizeof(uint16_t), \
201 .flags = VMS_SINGLE | VMS_POINTER, \
202 .offset = vmstate_offset_pointer(_state, _field, uint8_t), \
205 static const VMStateDescription vmstate_gpe = {
208 .minimum_version_id = 1,
209 .minimum_version_id_old = 1,
210 .fields = (VMStateField []) {
211 VMSTATE_GPE_ARRAY(sts, ACPIGPE),
212 VMSTATE_GPE_ARRAY(en, ACPIGPE),
213 VMSTATE_END_OF_LIST()
217 static const VMStateDescription vmstate_pci_status = {
218 .name = "pci_status",
220 .minimum_version_id = 1,
221 .minimum_version_id_old = 1,
222 .pre_save = vmstate_pci_status_pre_save,
223 .fields = (VMStateField []) {
224 VMSTATE_UINT32(up, struct pci_status),
225 VMSTATE_UINT32(down, struct pci_status),
226 VMSTATE_END_OF_LIST()
230 static int acpi_load_old(QEMUFile *f, void *opaque, int version_id)
232 PIIX4PMState *s = opaque;
236 ret = pci_device_load(PCI_DEVICE(s), f);
240 qemu_get_be16s(f, &s->ar.pm1.evt.sts);
241 qemu_get_be16s(f, &s->ar.pm1.evt.en);
242 qemu_get_be16s(f, &s->ar.pm1.cnt.cnt);
244 ret = vmstate_load_state(f, &vmstate_apm, &s->apm, 1);
249 timer_get(f, s->ar.tmr.timer);
250 qemu_get_sbe64s(f, &s->ar.tmr.overflow_time);
252 qemu_get_be16s(f, (uint16_t *)s->ar.gpe.sts);
253 for (i = 0; i < 3; i++) {
254 qemu_get_be16s(f, &temp);
257 qemu_get_be16s(f, (uint16_t *)s->ar.gpe.en);
258 for (i = 0; i < 3; i++) {
259 qemu_get_be16s(f, &temp);
262 ret = vmstate_load_state(f, &vmstate_pci_status, &s->pci0_status, 1);
266 /* qemu-kvm 1.2 uses version 3 but advertised as 2
267 * To support incoming qemu-kvm 1.2 migration, change version_id
268 * and minimum_version_id to 2 below (which breaks migration from
272 static const VMStateDescription vmstate_acpi = {
275 .minimum_version_id = 3,
276 .minimum_version_id_old = 1,
277 .load_state_old = acpi_load_old,
278 .post_load = vmstate_acpi_post_load,
279 .fields = (VMStateField []) {
280 VMSTATE_PCI_DEVICE(parent_obj, PIIX4PMState),
281 VMSTATE_UINT16(ar.pm1.evt.sts, PIIX4PMState),
282 VMSTATE_UINT16(ar.pm1.evt.en, PIIX4PMState),
283 VMSTATE_UINT16(ar.pm1.cnt.cnt, PIIX4PMState),
284 VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
285 VMSTATE_TIMER(ar.tmr.timer, PIIX4PMState),
286 VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
287 VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
288 VMSTATE_STRUCT(pci0_status, PIIX4PMState, 2, vmstate_pci_status,
290 VMSTATE_END_OF_LIST()
294 static void acpi_piix_eject_slot(PIIX4PMState *s, unsigned slots)
296 BusChild *kid, *next;
297 BusState *bus = qdev_get_parent_bus(DEVICE(s));
298 int slot = ffs(slots) - 1;
299 bool slot_free = true;
301 /* Mark request as complete */
302 s->pci0_status.down &= ~(1U << slot);
304 QTAILQ_FOREACH_SAFE(kid, &bus->children, sibling, next) {
305 DeviceState *qdev = kid->child;
306 PCIDevice *dev = PCI_DEVICE(qdev);
307 PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
308 if (PCI_SLOT(dev->devfn) == slot) {
309 if (pc->no_hotplug) {
312 object_unparent(OBJECT(qdev));
317 s->pci0_slot_device_present &= ~(1U << slot);
321 static void piix4_update_hotplug(PIIX4PMState *s)
323 BusState *bus = qdev_get_parent_bus(DEVICE(s));
324 BusChild *kid, *next;
326 /* Execute any pending removes during reset */
327 while (s->pci0_status.down) {
328 acpi_piix_eject_slot(s, s->pci0_status.down);
331 s->pci0_hotplug_enable = ~0;
332 s->pci0_slot_device_present = 0;
334 QTAILQ_FOREACH_SAFE(kid, &bus->children, sibling, next) {
335 DeviceState *qdev = kid->child;
336 PCIDevice *pdev = PCI_DEVICE(qdev);
337 PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pdev);
338 int slot = PCI_SLOT(pdev->devfn);
340 if (pc->no_hotplug) {
341 s->pci0_hotplug_enable &= ~(1U << slot);
344 s->pci0_slot_device_present |= (1U << slot);
348 static void piix4_reset(void *opaque)
350 PIIX4PMState *s = opaque;
351 PCIDevice *d = PCI_DEVICE(s);
352 uint8_t *pci_conf = d->config;
359 pci_conf[0x40] = 0x01; /* PM io base read only bit */
362 if (s->kvm_enabled) {
363 /* Mark SMM as already inited (until KVM supports SMM). */
364 pci_conf[0x5B] = 0x02;
366 pm_io_space_update(s);
367 piix4_update_hotplug(s);
370 static void piix4_pm_powerdown_req(Notifier *n, void *opaque)
372 PIIX4PMState *s = container_of(n, PIIX4PMState, powerdown_notifier);
375 acpi_pm1_evt_power_down(&s->ar);
378 static void piix4_pm_machine_ready(Notifier *n, void *opaque)
380 PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);
381 PCIDevice *d = PCI_DEVICE(s);
382 MemoryRegion *io_as = pci_address_space_io(d);
385 pci_conf = d->config;
386 pci_conf[0x5f] = 0x10 |
387 (memory_region_present(io_as, 0x378) ? 0x80 : 0);
388 pci_conf[0x63] = 0x60;
389 pci_conf[0x67] = (memory_region_present(io_as, 0x3f8) ? 0x08 : 0) |
390 (memory_region_present(io_as, 0x2f8) ? 0x90 : 0);
393 static void piix4_pm_add_propeties(PIIX4PMState *s)
395 static const uint8_t acpi_enable_cmd = ACPI_ENABLE;
396 static const uint8_t acpi_disable_cmd = ACPI_DISABLE;
397 static const uint32_t gpe0_blk = GPE_BASE;
398 static const uint32_t gpe0_blk_len = GPE_LEN;
399 static const uint16_t sci_int = 9;
401 object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_ENABLE_CMD,
402 &acpi_enable_cmd, NULL);
403 object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_DISABLE_CMD,
404 &acpi_disable_cmd, NULL);
405 object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK,
407 object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK_LEN,
408 &gpe0_blk_len, NULL);
409 object_property_add_uint16_ptr(OBJECT(s), ACPI_PM_PROP_SCI_INT,
411 object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
415 static int piix4_pm_initfn(PCIDevice *dev)
417 PIIX4PMState *s = PIIX4_PM(dev);
420 pci_conf = dev->config;
421 pci_conf[0x06] = 0x80;
422 pci_conf[0x07] = 0x02;
423 pci_conf[0x09] = 0x00;
424 pci_conf[0x3d] = 0x01; // interrupt pin 1
427 apm_init(dev, &s->apm, apm_ctrl_changed, s);
429 if (s->kvm_enabled) {
430 /* Mark SMM as already inited to prevent SMM from running. KVM does not
431 * support SMM mode. */
432 pci_conf[0x5B] = 0x02;
435 /* XXX: which specification is used ? The i82731AB has different
437 pci_conf[0x90] = s->smb_io_base | 1;
438 pci_conf[0x91] = s->smb_io_base >> 8;
439 pci_conf[0xd2] = 0x09;
440 pm_smbus_init(DEVICE(dev), &s->smb);
441 memory_region_set_enabled(&s->smb.io, pci_conf[0xd2] & 1);
442 memory_region_add_subregion(pci_address_space_io(dev),
443 s->smb_io_base, &s->smb.io);
445 memory_region_init(&s->io, OBJECT(s), "piix4-pm", 64);
446 memory_region_set_enabled(&s->io, false);
447 memory_region_add_subregion(pci_address_space_io(dev),
450 acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io);
451 acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io);
452 acpi_pm1_cnt_init(&s->ar, &s->io, s->s4_val);
453 acpi_gpe_init(&s->ar, GPE_LEN);
455 s->powerdown_notifier.notify = piix4_pm_powerdown_req;
456 qemu_register_powerdown_notifier(&s->powerdown_notifier);
458 s->machine_ready.notify = piix4_pm_machine_ready;
459 qemu_add_machine_init_done_notifier(&s->machine_ready);
460 qemu_register_reset(piix4_reset, s);
462 piix4_acpi_system_hot_add_init(pci_address_space_io(dev), dev->bus, s);
464 piix4_pm_add_propeties(s);
468 Object *piix4_pm_find(void)
471 Object *o = object_resolve_path_type("", TYPE_PIIX4_PM, &ambig);
479 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
480 qemu_irq sci_irq, qemu_irq smi_irq,
481 int kvm_enabled, FWCfgState *fw_cfg)
486 dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM));
487 qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base);
491 s->smi_irq = smi_irq;
492 s->kvm_enabled = kvm_enabled;
494 qdev_init_nofail(dev);
497 uint8_t suspend[6] = {128, 0, 0, 129, 128, 128};
498 suspend[3] = 1 | ((!s->disable_s3) << 7);
499 suspend[4] = s->s4_val | ((!s->disable_s4) << 7);
501 fw_cfg_add_file(fw_cfg, "etc/system-states", g_memdup(suspend, 6), 6);
507 static Property piix4_pm_properties[] = {
508 DEFINE_PROP_UINT32("smb_io_base", PIIX4PMState, smb_io_base, 0),
509 DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
510 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
511 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
512 DEFINE_PROP_END_OF_LIST(),
515 static void piix4_pm_class_init(ObjectClass *klass, void *data)
517 DeviceClass *dc = DEVICE_CLASS(klass);
518 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
521 k->init = piix4_pm_initfn;
522 k->config_write = pm_write_config;
523 k->vendor_id = PCI_VENDOR_ID_INTEL;
524 k->device_id = PCI_DEVICE_ID_INTEL_82371AB_3;
526 k->class_id = PCI_CLASS_BRIDGE_OTHER;
528 dc->vmsd = &vmstate_acpi;
529 dc->props = piix4_pm_properties;
531 * Reason: part of PIIX4 southbridge, needs to be wired up,
532 * e.g. by mips_malta_init()
534 dc->cannot_instantiate_with_device_add_yet = true;
537 static const TypeInfo piix4_pm_info = {
538 .name = TYPE_PIIX4_PM,
539 .parent = TYPE_PCI_DEVICE,
540 .instance_size = sizeof(PIIX4PMState),
541 .class_init = piix4_pm_class_init,
544 static void piix4_pm_register_types(void)
546 type_register_static(&piix4_pm_info);
549 type_init(piix4_pm_register_types)
551 static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
553 PIIX4PMState *s = opaque;
554 uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);
556 PIIX4_DPRINTF("gpe read %" HWADDR_PRIx " == %" PRIu32 "\n", addr, val);
560 static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
563 PIIX4PMState *s = opaque;
565 acpi_gpe_ioport_writeb(&s->ar, addr, val);
566 acpi_update_sci(&s->ar, s->irq);
568 PIIX4_DPRINTF("gpe write %" HWADDR_PRIx " <== %" PRIu64 "\n", addr, val);
571 static const MemoryRegionOps piix4_gpe_ops = {
574 .valid.min_access_size = 1,
575 .valid.max_access_size = 4,
576 .impl.min_access_size = 1,
577 .impl.max_access_size = 1,
578 .endianness = DEVICE_LITTLE_ENDIAN,
581 static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
583 PIIX4PMState *s = opaque;
587 case PCI_UP_BASE - PCI_HOTPLUG_ADDR:
588 /* Manufacture an "up" value to cause a device check on any hotplug
589 * slot with a device. Extra device checks are harmless. */
590 val = s->pci0_slot_device_present & s->pci0_hotplug_enable;
591 PIIX4_DPRINTF("pci_up_read %" PRIu32 "\n", val);
593 case PCI_DOWN_BASE - PCI_HOTPLUG_ADDR:
594 val = s->pci0_status.down;
595 PIIX4_DPRINTF("pci_down_read %" PRIu32 "\n", val);
597 case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
598 /* No feature defined yet */
599 PIIX4_DPRINTF("pci_features_read %" PRIu32 "\n", val);
601 case PCI_RMV_BASE - PCI_HOTPLUG_ADDR:
602 val = s->pci0_hotplug_enable;
611 static void pci_write(void *opaque, hwaddr addr, uint64_t data,
615 case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
616 acpi_piix_eject_slot(opaque, (uint32_t)data);
617 PIIX4_DPRINTF("pciej write %" HWADDR_PRIx " <== %" PRIu64 "\n",
625 static const MemoryRegionOps piix4_pci_ops = {
628 .endianness = DEVICE_LITTLE_ENDIAN,
630 .min_access_size = 4,
631 .max_access_size = 4,
635 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
637 PIIX4PMState *s = opaque;
638 CPUStatus *cpus = &s->gpe_cpu;
639 uint64_t val = cpus->sts[addr];
644 static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data,
647 /* TODO: implement VCPU removal on guest signal that CPU can be removed */
650 static const MemoryRegionOps cpu_hotplug_ops = {
651 .read = cpu_status_read,
652 .write = cpu_status_write,
653 .endianness = DEVICE_LITTLE_ENDIAN,
655 .min_access_size = 1,
656 .max_access_size = 1,
665 static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu,
666 HotplugEventType action)
668 CPUStatus *g = &s->gpe_cpu;
669 ACPIGPE *gpe = &s->ar.gpe;
670 CPUClass *k = CPU_GET_CLASS(cpu);
675 *gpe->sts = *gpe->sts | PIIX4_CPU_HOTPLUG_STATUS;
676 cpu_id = k->get_arch_id(CPU(cpu));
677 if (action == PLUG) {
678 g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
680 g->sts[cpu_id / 8] &= ~(1 << (cpu_id % 8));
682 acpi_update_sci(&s->ar, s->irq);
685 static void piix4_cpu_added_req(Notifier *n, void *opaque)
687 PIIX4PMState *s = container_of(n, PIIX4PMState, cpu_added_notifier);
689 piix4_cpu_hotplug_req(s, CPU(opaque), PLUG);
692 static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
693 PCIHotplugState state);
695 static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
696 PCIBus *bus, PIIX4PMState *s)
700 memory_region_init_io(&s->io_gpe, OBJECT(s), &piix4_gpe_ops, s,
701 "acpi-gpe0", GPE_LEN);
702 memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
704 memory_region_init_io(&s->io_pci, OBJECT(s), &piix4_pci_ops, s,
705 "acpi-pci-hotplug", PCI_HOTPLUG_SIZE);
706 memory_region_add_subregion(parent, PCI_HOTPLUG_ADDR,
708 pci_bus_hotplug(bus, piix4_device_hotplug, DEVICE(s));
711 CPUClass *cc = CPU_GET_CLASS(cpu);
712 int64_t id = cc->get_arch_id(cpu);
714 g_assert((id / 8) < PIIX4_PROC_LEN);
715 s->gpe_cpu.sts[id / 8] |= (1 << (id % 8));
717 memory_region_init_io(&s->io_cpu, OBJECT(s), &cpu_hotplug_ops, s,
718 "acpi-cpu-hotplug", PIIX4_PROC_LEN);
719 memory_region_add_subregion(parent, PIIX4_PROC_BASE, &s->io_cpu);
720 s->cpu_added_notifier.notify = piix4_cpu_added_req;
721 qemu_register_cpu_added_notifier(&s->cpu_added_notifier);
724 static void enable_device(PIIX4PMState *s, int slot)
726 s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
727 s->pci0_slot_device_present |= (1U << slot);
730 static void disable_device(PIIX4PMState *s, int slot)
732 s->ar.gpe.sts[0] |= PIIX4_PCI_HOTPLUG_STATUS;
733 s->pci0_status.down |= (1U << slot);
736 static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev,
737 PCIHotplugState state)
739 int slot = PCI_SLOT(dev->devfn);
740 PIIX4PMState *s = PIIX4_PM(qdev);
742 /* Don't send event when device is enabled during qemu machine creation:
743 * it is present on boot, no hotplug event is necessary. We do send an
744 * event when the device is disabled later. */
745 if (state == PCI_COLDPLUG_ENABLED) {
746 s->pci0_slot_device_present |= (1U << slot);
750 if (state == PCI_HOTPLUG_ENABLED) {
751 enable_device(s, slot);
753 disable_device(s, slot);
756 acpi_update_sci(&s->ar, s->irq);