114a026ddSPhilippe Mathieu-Daudé /* 214a026ddSPhilippe Mathieu-Daudé * QEMU PIIX PCI ISA Bridge Emulation 314a026ddSPhilippe Mathieu-Daudé * 414a026ddSPhilippe Mathieu-Daudé * Copyright (c) 2006 Fabrice Bellard 516971899SBernhard Beschow * Copyright (c) 2018 Hervé Poussineau 614a026ddSPhilippe Mathieu-Daudé * 714a026ddSPhilippe Mathieu-Daudé * Permission is hereby granted, free of charge, to any person obtaining a copy 814a026ddSPhilippe Mathieu-Daudé * of this software and associated documentation files (the "Software"), to deal 914a026ddSPhilippe Mathieu-Daudé * in the Software without restriction, including without limitation the rights 1014a026ddSPhilippe Mathieu-Daudé * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 1114a026ddSPhilippe Mathieu-Daudé * copies of the Software, and to permit persons to whom the Software is 1214a026ddSPhilippe Mathieu-Daudé * furnished to do so, subject to the following conditions: 1314a026ddSPhilippe Mathieu-Daudé * 1414a026ddSPhilippe Mathieu-Daudé * The above copyright notice and this permission notice shall be included in 1514a026ddSPhilippe Mathieu-Daudé * all copies or substantial portions of the Software. 1614a026ddSPhilippe Mathieu-Daudé * 1714a026ddSPhilippe Mathieu-Daudé * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1814a026ddSPhilippe Mathieu-Daudé * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1914a026ddSPhilippe Mathieu-Daudé * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2014a026ddSPhilippe Mathieu-Daudé * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 2114a026ddSPhilippe Mathieu-Daudé * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 2214a026ddSPhilippe Mathieu-Daudé * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 2314a026ddSPhilippe Mathieu-Daudé * THE SOFTWARE. 2414a026ddSPhilippe Mathieu-Daudé */ 2514a026ddSPhilippe Mathieu-Daudé 2614a026ddSPhilippe Mathieu-Daudé #include "qemu/osdep.h" 2714a026ddSPhilippe Mathieu-Daudé #include "qemu/range.h" 28fe3055d2SBernhard Beschow #include "qapi/error.h" 29503a35e7SBernhard Beschow #include "hw/dma/i8257.h" 3014a026ddSPhilippe Mathieu-Daudé #include "hw/southbridge/piix.h" 3116971899SBernhard Beschow #include "hw/timer/i8254.h" 3214a026ddSPhilippe Mathieu-Daudé #include "hw/irq.h" 33f0bc6bf7SBernhard Beschow #include "hw/qdev-properties.h" 34e47e5a5bSBernhard Beschow #include "hw/ide/piix.h" 3516971899SBernhard Beschow #include "hw/intc/i8259.h" 3614a026ddSPhilippe Mathieu-Daudé #include "hw/isa/isa.h" 3714a026ddSPhilippe Mathieu-Daudé #include "sysemu/runstate.h" 3814a026ddSPhilippe Mathieu-Daudé #include "migration/vmstate.h" 3992ea7fb3SIgor Mammedov #include "hw/acpi/acpi_aml_interface.h" 4014a026ddSPhilippe Mathieu-Daudé 4116971899SBernhard Beschow typedef struct PIIXState PIIX4State; 4216971899SBernhard Beschow 4316971899SBernhard Beschow DECLARE_INSTANCE_CHECKER(PIIX4State, PIIX4_PCI_DEVICE, TYPE_PIIX4_PCI_DEVICE) 4416971899SBernhard Beschow 459769cfc3SBernhard Beschow static void piix3_set_irq_pic(PIIXState *piix3, int pic_irq) 4614a026ddSPhilippe Mathieu-Daudé { 4740f70623SBernhard Beschow qemu_set_irq(piix3->isa_irqs_in[pic_irq], 4814a026ddSPhilippe Mathieu-Daudé !!(piix3->pic_levels & 4914a026ddSPhilippe Mathieu-Daudé (((1ULL << PIIX_NUM_PIRQS) - 1) << 5014a026ddSPhilippe Mathieu-Daudé (pic_irq * PIIX_NUM_PIRQS)))); 5114a026ddSPhilippe Mathieu-Daudé } 5214a026ddSPhilippe Mathieu-Daudé 539769cfc3SBernhard Beschow static void piix3_set_irq_level_internal(PIIXState *piix3, int pirq, int level) 5414a026ddSPhilippe Mathieu-Daudé { 5514a026ddSPhilippe Mathieu-Daudé int pic_irq; 5614a026ddSPhilippe Mathieu-Daudé uint64_t mask; 5714a026ddSPhilippe Mathieu-Daudé 5814a026ddSPhilippe Mathieu-Daudé pic_irq = piix3->dev.config[PIIX_PIRQCA + pirq]; 5932f29b26SBernhard Beschow if (pic_irq >= ISA_NUM_IRQS) { 6014a026ddSPhilippe Mathieu-Daudé return; 6114a026ddSPhilippe Mathieu-Daudé } 6214a026ddSPhilippe Mathieu-Daudé 6314a026ddSPhilippe Mathieu-Daudé mask = 1ULL << ((pic_irq * PIIX_NUM_PIRQS) + pirq); 6414a026ddSPhilippe Mathieu-Daudé piix3->pic_levels &= ~mask; 6514a026ddSPhilippe Mathieu-Daudé piix3->pic_levels |= mask * !!level; 6614a026ddSPhilippe Mathieu-Daudé } 6714a026ddSPhilippe Mathieu-Daudé 689769cfc3SBernhard Beschow static void piix3_set_irq_level(PIIXState *piix3, int pirq, int level) 6914a026ddSPhilippe Mathieu-Daudé { 7014a026ddSPhilippe Mathieu-Daudé int pic_irq; 7114a026ddSPhilippe Mathieu-Daudé 7214a026ddSPhilippe Mathieu-Daudé pic_irq = piix3->dev.config[PIIX_PIRQCA + pirq]; 7332f29b26SBernhard Beschow if (pic_irq >= ISA_NUM_IRQS) { 7414a026ddSPhilippe Mathieu-Daudé return; 7514a026ddSPhilippe Mathieu-Daudé } 7614a026ddSPhilippe Mathieu-Daudé 7714a026ddSPhilippe Mathieu-Daudé piix3_set_irq_level_internal(piix3, pirq, level); 7814a026ddSPhilippe Mathieu-Daudé 7914a026ddSPhilippe Mathieu-Daudé piix3_set_irq_pic(piix3, pic_irq); 8014a026ddSPhilippe Mathieu-Daudé } 8114a026ddSPhilippe Mathieu-Daudé 8214a026ddSPhilippe Mathieu-Daudé static void piix3_set_irq(void *opaque, int pirq, int level) 8314a026ddSPhilippe Mathieu-Daudé { 849769cfc3SBernhard Beschow PIIXState *piix3 = opaque; 8514a026ddSPhilippe Mathieu-Daudé piix3_set_irq_level(piix3, pirq, level); 8614a026ddSPhilippe Mathieu-Daudé } 8714a026ddSPhilippe Mathieu-Daudé 8816971899SBernhard Beschow static void piix4_set_irq(void *opaque, int irq_num, int level) 8916971899SBernhard Beschow { 9016971899SBernhard Beschow int i, pic_irq, pic_level; 9116971899SBernhard Beschow PIIX4State *s = opaque; 9216971899SBernhard Beschow PCIBus *bus = pci_get_bus(&s->dev); 9316971899SBernhard Beschow 9416971899SBernhard Beschow /* now we change the pic irq level according to the piix irq mappings */ 9516971899SBernhard Beschow /* XXX: optimize */ 9616971899SBernhard Beschow pic_irq = s->dev.config[PIIX_PIRQCA + irq_num]; 9716971899SBernhard Beschow if (pic_irq < ISA_NUM_IRQS) { 9816971899SBernhard Beschow /* The pic level is the logical OR of all the PCI irqs mapped to it. */ 9916971899SBernhard Beschow pic_level = 0; 10016971899SBernhard Beschow for (i = 0; i < PIIX_NUM_PIRQS; i++) { 10116971899SBernhard Beschow if (pic_irq == s->dev.config[PIIX_PIRQCA + i]) { 10216971899SBernhard Beschow pic_level |= pci_bus_get_irq_level(bus, i); 10316971899SBernhard Beschow } 10416971899SBernhard Beschow } 10516971899SBernhard Beschow qemu_set_irq(s->isa_irqs_in[pic_irq], pic_level); 10616971899SBernhard Beschow } 10716971899SBernhard Beschow } 10816971899SBernhard Beschow 1092d7630f5SBernhard Beschow static void piix_request_i8259_irq(void *opaque, int irq, int level) 11016971899SBernhard Beschow { 11116971899SBernhard Beschow PIIX4State *s = opaque; 11216971899SBernhard Beschow qemu_set_irq(s->cpu_intr, level); 11316971899SBernhard Beschow } 11416971899SBernhard Beschow 11514a026ddSPhilippe Mathieu-Daudé static PCIINTxRoute piix3_route_intx_pin_to_irq(void *opaque, int pin) 11614a026ddSPhilippe Mathieu-Daudé { 1179769cfc3SBernhard Beschow PIIXState *piix3 = opaque; 11814a026ddSPhilippe Mathieu-Daudé int irq = piix3->dev.config[PIIX_PIRQCA + pin]; 11914a026ddSPhilippe Mathieu-Daudé PCIINTxRoute route; 12014a026ddSPhilippe Mathieu-Daudé 12132f29b26SBernhard Beschow if (irq < ISA_NUM_IRQS) { 12214a026ddSPhilippe Mathieu-Daudé route.mode = PCI_INTX_ENABLED; 12314a026ddSPhilippe Mathieu-Daudé route.irq = irq; 12414a026ddSPhilippe Mathieu-Daudé } else { 12514a026ddSPhilippe Mathieu-Daudé route.mode = PCI_INTX_DISABLED; 12614a026ddSPhilippe Mathieu-Daudé route.irq = -1; 12714a026ddSPhilippe Mathieu-Daudé } 12814a026ddSPhilippe Mathieu-Daudé return route; 12914a026ddSPhilippe Mathieu-Daudé } 13014a026ddSPhilippe Mathieu-Daudé 13114a026ddSPhilippe Mathieu-Daudé /* irq routing is changed. so rebuild bitmap */ 1329769cfc3SBernhard Beschow static void piix3_update_irq_levels(PIIXState *piix3) 13314a026ddSPhilippe Mathieu-Daudé { 13414a026ddSPhilippe Mathieu-Daudé PCIBus *bus = pci_get_bus(&piix3->dev); 13514a026ddSPhilippe Mathieu-Daudé int pirq; 13614a026ddSPhilippe Mathieu-Daudé 13714a026ddSPhilippe Mathieu-Daudé piix3->pic_levels = 0; 13814a026ddSPhilippe Mathieu-Daudé for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) { 13914a026ddSPhilippe Mathieu-Daudé piix3_set_irq_level(piix3, pirq, pci_bus_get_irq_level(bus, pirq)); 14014a026ddSPhilippe Mathieu-Daudé } 14114a026ddSPhilippe Mathieu-Daudé } 14214a026ddSPhilippe Mathieu-Daudé 14314a026ddSPhilippe Mathieu-Daudé static void piix3_write_config(PCIDevice *dev, 14414a026ddSPhilippe Mathieu-Daudé uint32_t address, uint32_t val, int len) 14514a026ddSPhilippe Mathieu-Daudé { 14614a026ddSPhilippe Mathieu-Daudé pci_default_write_config(dev, address, val, len); 14714a026ddSPhilippe Mathieu-Daudé if (ranges_overlap(address, len, PIIX_PIRQCA, 4)) { 1489769cfc3SBernhard Beschow PIIXState *piix3 = PIIX_PCI_DEVICE(dev); 14914a026ddSPhilippe Mathieu-Daudé int pic_irq; 15014a026ddSPhilippe Mathieu-Daudé 15114a026ddSPhilippe Mathieu-Daudé pci_bus_fire_intx_routing_notifier(pci_get_bus(&piix3->dev)); 15214a026ddSPhilippe Mathieu-Daudé piix3_update_irq_levels(piix3); 15332f29b26SBernhard Beschow for (pic_irq = 0; pic_irq < ISA_NUM_IRQS; pic_irq++) { 15414a026ddSPhilippe Mathieu-Daudé piix3_set_irq_pic(piix3, pic_irq); 15514a026ddSPhilippe Mathieu-Daudé } 15614a026ddSPhilippe Mathieu-Daudé } 15714a026ddSPhilippe Mathieu-Daudé } 15814a026ddSPhilippe Mathieu-Daudé 15916971899SBernhard Beschow static void piix_reset(PIIXState *d) 16014a026ddSPhilippe Mathieu-Daudé { 16114a026ddSPhilippe Mathieu-Daudé uint8_t *pci_conf = d->dev.config; 16214a026ddSPhilippe Mathieu-Daudé 16314a026ddSPhilippe Mathieu-Daudé pci_conf[0x04] = 0x07; /* master, memory and I/O */ 16414a026ddSPhilippe Mathieu-Daudé pci_conf[0x05] = 0x00; 16514a026ddSPhilippe Mathieu-Daudé pci_conf[0x06] = 0x00; 16614a026ddSPhilippe Mathieu-Daudé pci_conf[0x07] = 0x02; /* PCI_status_devsel_medium */ 16714a026ddSPhilippe Mathieu-Daudé pci_conf[0x4c] = 0x4d; 16814a026ddSPhilippe Mathieu-Daudé pci_conf[0x4e] = 0x03; 16914a026ddSPhilippe Mathieu-Daudé pci_conf[0x4f] = 0x00; 17014a026ddSPhilippe Mathieu-Daudé pci_conf[0x60] = 0x80; 17114a026ddSPhilippe Mathieu-Daudé pci_conf[0x61] = 0x80; 17214a026ddSPhilippe Mathieu-Daudé pci_conf[0x62] = 0x80; 17314a026ddSPhilippe Mathieu-Daudé pci_conf[0x63] = 0x80; 17414a026ddSPhilippe Mathieu-Daudé pci_conf[0x69] = 0x02; 17514a026ddSPhilippe Mathieu-Daudé pci_conf[0x70] = 0x80; 17614a026ddSPhilippe Mathieu-Daudé pci_conf[0x76] = 0x0c; 17714a026ddSPhilippe Mathieu-Daudé pci_conf[0x77] = 0x0c; 17814a026ddSPhilippe Mathieu-Daudé pci_conf[0x78] = 0x02; 17914a026ddSPhilippe Mathieu-Daudé pci_conf[0x79] = 0x00; 18014a026ddSPhilippe Mathieu-Daudé pci_conf[0x80] = 0x00; 18114a026ddSPhilippe Mathieu-Daudé pci_conf[0x82] = 0x00; 18214a026ddSPhilippe Mathieu-Daudé pci_conf[0xa0] = 0x08; 18314a026ddSPhilippe Mathieu-Daudé pci_conf[0xa2] = 0x00; 18414a026ddSPhilippe Mathieu-Daudé pci_conf[0xa3] = 0x00; 18514a026ddSPhilippe Mathieu-Daudé pci_conf[0xa4] = 0x00; 18614a026ddSPhilippe Mathieu-Daudé pci_conf[0xa5] = 0x00; 18714a026ddSPhilippe Mathieu-Daudé pci_conf[0xa6] = 0x00; 18814a026ddSPhilippe Mathieu-Daudé pci_conf[0xa7] = 0x00; 18914a026ddSPhilippe Mathieu-Daudé pci_conf[0xa8] = 0x0f; 19014a026ddSPhilippe Mathieu-Daudé pci_conf[0xaa] = 0x00; 19114a026ddSPhilippe Mathieu-Daudé pci_conf[0xab] = 0x00; 19214a026ddSPhilippe Mathieu-Daudé pci_conf[0xac] = 0x00; 19314a026ddSPhilippe Mathieu-Daudé pci_conf[0xae] = 0x00; 19414a026ddSPhilippe Mathieu-Daudé 19514a026ddSPhilippe Mathieu-Daudé d->pic_levels = 0; 19614a026ddSPhilippe Mathieu-Daudé d->rcr = 0; 19714a026ddSPhilippe Mathieu-Daudé } 19814a026ddSPhilippe Mathieu-Daudé 19916971899SBernhard Beschow static void piix3_reset(DeviceState *dev) 20016971899SBernhard Beschow { 20116971899SBernhard Beschow PIIXState *d = PIIX_PCI_DEVICE(dev); 20216971899SBernhard Beschow 20316971899SBernhard Beschow piix_reset(d); 20416971899SBernhard Beschow } 20516971899SBernhard Beschow 20614a026ddSPhilippe Mathieu-Daudé static int piix3_post_load(void *opaque, int version_id) 20714a026ddSPhilippe Mathieu-Daudé { 2089769cfc3SBernhard Beschow PIIXState *piix3 = opaque; 20914a026ddSPhilippe Mathieu-Daudé int pirq; 21014a026ddSPhilippe Mathieu-Daudé 21114a026ddSPhilippe Mathieu-Daudé /* 21214a026ddSPhilippe Mathieu-Daudé * Because the i8259 has not been deserialized yet, qemu_irq_raise 21314a026ddSPhilippe Mathieu-Daudé * might bring the system to a different state than the saved one; 21414a026ddSPhilippe Mathieu-Daudé * for example, the interrupt could be masked but the i8259 would 21514a026ddSPhilippe Mathieu-Daudé * not know that yet and would trigger an interrupt in the CPU. 21614a026ddSPhilippe Mathieu-Daudé * 21714a026ddSPhilippe Mathieu-Daudé * Here, we update irq levels without raising the interrupt. 21814a026ddSPhilippe Mathieu-Daudé * Interrupt state will be deserialized separately through the i8259. 21914a026ddSPhilippe Mathieu-Daudé */ 22014a026ddSPhilippe Mathieu-Daudé piix3->pic_levels = 0; 22114a026ddSPhilippe Mathieu-Daudé for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) { 22214a026ddSPhilippe Mathieu-Daudé piix3_set_irq_level_internal(piix3, pirq, 22314a026ddSPhilippe Mathieu-Daudé pci_bus_get_irq_level(pci_get_bus(&piix3->dev), pirq)); 22414a026ddSPhilippe Mathieu-Daudé } 22514a026ddSPhilippe Mathieu-Daudé return 0; 22614a026ddSPhilippe Mathieu-Daudé } 22714a026ddSPhilippe Mathieu-Daudé 22816971899SBernhard Beschow static int piix4_post_load(void *opaque, int version_id) 22916971899SBernhard Beschow { 23016971899SBernhard Beschow PIIX4State *s = opaque; 23116971899SBernhard Beschow 23216971899SBernhard Beschow if (version_id == 2) { 23316971899SBernhard Beschow s->rcr = 0; 23416971899SBernhard Beschow } 23516971899SBernhard Beschow 23616971899SBernhard Beschow return 0; 23716971899SBernhard Beschow } 23816971899SBernhard Beschow 23914a026ddSPhilippe Mathieu-Daudé static int piix3_pre_save(void *opaque) 24014a026ddSPhilippe Mathieu-Daudé { 24114a026ddSPhilippe Mathieu-Daudé int i; 2429769cfc3SBernhard Beschow PIIXState *piix3 = opaque; 24314a026ddSPhilippe Mathieu-Daudé 24414a026ddSPhilippe Mathieu-Daudé for (i = 0; i < ARRAY_SIZE(piix3->pci_irq_levels_vmstate); i++) { 24514a026ddSPhilippe Mathieu-Daudé piix3->pci_irq_levels_vmstate[i] = 24614a026ddSPhilippe Mathieu-Daudé pci_bus_get_irq_level(pci_get_bus(&piix3->dev), i); 24714a026ddSPhilippe Mathieu-Daudé } 24814a026ddSPhilippe Mathieu-Daudé 24914a026ddSPhilippe Mathieu-Daudé return 0; 25014a026ddSPhilippe Mathieu-Daudé } 25114a026ddSPhilippe Mathieu-Daudé 25214a026ddSPhilippe Mathieu-Daudé static bool piix3_rcr_needed(void *opaque) 25314a026ddSPhilippe Mathieu-Daudé { 2549769cfc3SBernhard Beschow PIIXState *piix3 = opaque; 25514a026ddSPhilippe Mathieu-Daudé 25614a026ddSPhilippe Mathieu-Daudé return (piix3->rcr != 0); 25714a026ddSPhilippe Mathieu-Daudé } 25814a026ddSPhilippe Mathieu-Daudé 25914a026ddSPhilippe Mathieu-Daudé static const VMStateDescription vmstate_piix3_rcr = { 26014a026ddSPhilippe Mathieu-Daudé .name = "PIIX3/rcr", 26114a026ddSPhilippe Mathieu-Daudé .version_id = 1, 26214a026ddSPhilippe Mathieu-Daudé .minimum_version_id = 1, 26314a026ddSPhilippe Mathieu-Daudé .needed = piix3_rcr_needed, 26414a026ddSPhilippe Mathieu-Daudé .fields = (VMStateField[]) { 2659769cfc3SBernhard Beschow VMSTATE_UINT8(rcr, PIIXState), 26614a026ddSPhilippe Mathieu-Daudé VMSTATE_END_OF_LIST() 26714a026ddSPhilippe Mathieu-Daudé } 26814a026ddSPhilippe Mathieu-Daudé }; 26914a026ddSPhilippe Mathieu-Daudé 27014a026ddSPhilippe Mathieu-Daudé static const VMStateDescription vmstate_piix3 = { 27114a026ddSPhilippe Mathieu-Daudé .name = "PIIX3", 27214a026ddSPhilippe Mathieu-Daudé .version_id = 3, 27314a026ddSPhilippe Mathieu-Daudé .minimum_version_id = 2, 27414a026ddSPhilippe Mathieu-Daudé .post_load = piix3_post_load, 27514a026ddSPhilippe Mathieu-Daudé .pre_save = piix3_pre_save, 27614a026ddSPhilippe Mathieu-Daudé .fields = (VMStateField[]) { 2779769cfc3SBernhard Beschow VMSTATE_PCI_DEVICE(dev, PIIXState), 2789769cfc3SBernhard Beschow VMSTATE_INT32_ARRAY_V(pci_irq_levels_vmstate, PIIXState, 27914a026ddSPhilippe Mathieu-Daudé PIIX_NUM_PIRQS, 3), 28014a026ddSPhilippe Mathieu-Daudé VMSTATE_END_OF_LIST() 28114a026ddSPhilippe Mathieu-Daudé }, 28214a026ddSPhilippe Mathieu-Daudé .subsections = (const VMStateDescription*[]) { 28314a026ddSPhilippe Mathieu-Daudé &vmstate_piix3_rcr, 28414a026ddSPhilippe Mathieu-Daudé NULL 28514a026ddSPhilippe Mathieu-Daudé } 28614a026ddSPhilippe Mathieu-Daudé }; 28714a026ddSPhilippe Mathieu-Daudé 28816971899SBernhard Beschow static const VMStateDescription vmstate_piix4 = { 28916971899SBernhard Beschow .name = "PIIX4", 29016971899SBernhard Beschow .version_id = 3, 29116971899SBernhard Beschow .minimum_version_id = 2, 29216971899SBernhard Beschow .post_load = piix4_post_load, 29316971899SBernhard Beschow .fields = (VMStateField[]) { 29416971899SBernhard Beschow VMSTATE_PCI_DEVICE(dev, PIIX4State), 29516971899SBernhard Beschow VMSTATE_UINT8_V(rcr, PIIX4State, 3), 29616971899SBernhard Beschow VMSTATE_END_OF_LIST() 29716971899SBernhard Beschow } 29816971899SBernhard Beschow }; 29914a026ddSPhilippe Mathieu-Daudé 30014a026ddSPhilippe Mathieu-Daudé static void rcr_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) 30114a026ddSPhilippe Mathieu-Daudé { 3029769cfc3SBernhard Beschow PIIXState *d = opaque; 30314a026ddSPhilippe Mathieu-Daudé 30414a026ddSPhilippe Mathieu-Daudé if (val & 4) { 30514a026ddSPhilippe Mathieu-Daudé qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); 30614a026ddSPhilippe Mathieu-Daudé return; 30714a026ddSPhilippe Mathieu-Daudé } 30814a026ddSPhilippe Mathieu-Daudé d->rcr = val & 2; /* keep System Reset type only */ 30914a026ddSPhilippe Mathieu-Daudé } 31014a026ddSPhilippe Mathieu-Daudé 31114a026ddSPhilippe Mathieu-Daudé static uint64_t rcr_read(void *opaque, hwaddr addr, unsigned len) 31214a026ddSPhilippe Mathieu-Daudé { 3139769cfc3SBernhard Beschow PIIXState *d = opaque; 31414a026ddSPhilippe Mathieu-Daudé 31514a026ddSPhilippe Mathieu-Daudé return d->rcr; 31614a026ddSPhilippe Mathieu-Daudé } 31714a026ddSPhilippe Mathieu-Daudé 31814a026ddSPhilippe Mathieu-Daudé static const MemoryRegionOps rcr_ops = { 31914a026ddSPhilippe Mathieu-Daudé .read = rcr_read, 32014a026ddSPhilippe Mathieu-Daudé .write = rcr_write, 3213ee15e80SBernhard Beschow .endianness = DEVICE_LITTLE_ENDIAN, 3223ee15e80SBernhard Beschow .impl = { 3233ee15e80SBernhard Beschow .min_access_size = 1, 3243ee15e80SBernhard Beschow .max_access_size = 1, 3253ee15e80SBernhard Beschow }, 32614a026ddSPhilippe Mathieu-Daudé }; 32714a026ddSPhilippe Mathieu-Daudé 328fe3055d2SBernhard Beschow static void pci_piix3_realize(PCIDevice *dev, Error **errp) 32914a026ddSPhilippe Mathieu-Daudé { 3309769cfc3SBernhard Beschow PIIXState *d = PIIX_PCI_DEVICE(dev); 331e47e5a5bSBernhard Beschow PCIBus *pci_bus = pci_get_bus(dev); 332503a35e7SBernhard Beschow ISABus *isa_bus; 33356b1f50eSBernhard Beschow uint32_t irq; 33414a026ddSPhilippe Mathieu-Daudé 33557654b8eSBernhard Beschow isa_bus = isa_bus_new(DEVICE(d), pci_address_space(dev), 336503a35e7SBernhard Beschow pci_address_space_io(dev), errp); 337503a35e7SBernhard Beschow if (!isa_bus) { 33814a026ddSPhilippe Mathieu-Daudé return; 33914a026ddSPhilippe Mathieu-Daudé } 34014a026ddSPhilippe Mathieu-Daudé 34114a026ddSPhilippe Mathieu-Daudé memory_region_init_io(&d->rcr_mem, OBJECT(dev), &rcr_ops, d, 34214a026ddSPhilippe Mathieu-Daudé "piix3-reset-control", 1); 34314a026ddSPhilippe Mathieu-Daudé memory_region_add_subregion_overlap(pci_address_space_io(dev), 34414a026ddSPhilippe Mathieu-Daudé PIIX_RCR_IOPORT, &d->rcr_mem, 1); 34514a026ddSPhilippe Mathieu-Daudé 3462d7630f5SBernhard Beschow /* PIC */ 3472d7630f5SBernhard Beschow if (d->has_pic) { 3482d7630f5SBernhard Beschow qemu_irq *i8259_out_irq = qemu_allocate_irqs(piix_request_i8259_irq, d, 3492d7630f5SBernhard Beschow 1); 3502d7630f5SBernhard Beschow qemu_irq *i8259 = i8259_init(isa_bus, *i8259_out_irq); 3512d7630f5SBernhard Beschow size_t i; 3522d7630f5SBernhard Beschow 3532d7630f5SBernhard Beschow for (i = 0; i < ISA_NUM_IRQS; i++) { 3542d7630f5SBernhard Beschow d->isa_irqs_in[i] = i8259[i]; 3552d7630f5SBernhard Beschow } 3562d7630f5SBernhard Beschow 3572d7630f5SBernhard Beschow g_free(i8259); 3582d7630f5SBernhard Beschow 3592d7630f5SBernhard Beschow qdev_init_gpio_out_named(DEVICE(dev), &d->cpu_intr, "intr", 1); 3602d7630f5SBernhard Beschow } 3612d7630f5SBernhard Beschow 36264127940SBernhard Beschow isa_bus_register_input_irqs(isa_bus, d->isa_irqs_in); 36364127940SBernhard Beschow 364*ac433035SBernhard Beschow /* PIT */ 365*ac433035SBernhard Beschow if (d->has_pit) { 366*ac433035SBernhard Beschow i8254_pit_init(isa_bus, 0x40, 0, NULL); 367*ac433035SBernhard Beschow } 368*ac433035SBernhard Beschow 369503a35e7SBernhard Beschow i8257_dma_init(isa_bus, 0); 370f0bc6bf7SBernhard Beschow 371f0bc6bf7SBernhard Beschow /* RTC */ 372f0bc6bf7SBernhard Beschow qdev_prop_set_int32(DEVICE(&d->rtc), "base_year", 2000); 373f0bc6bf7SBernhard Beschow if (!qdev_realize(DEVICE(&d->rtc), BUS(isa_bus), errp)) { 374f0bc6bf7SBernhard Beschow return; 375f0bc6bf7SBernhard Beschow } 37656b1f50eSBernhard Beschow irq = object_property_get_uint(OBJECT(&d->rtc), "irq", &error_fatal); 37756b1f50eSBernhard Beschow isa_connect_gpio_out(ISA_DEVICE(&d->rtc), 0, irq); 378e47e5a5bSBernhard Beschow 379e47e5a5bSBernhard Beschow /* IDE */ 380e47e5a5bSBernhard Beschow qdev_prop_set_int32(DEVICE(&d->ide), "addr", dev->devfn + 1); 381e47e5a5bSBernhard Beschow if (!qdev_realize(DEVICE(&d->ide), BUS(pci_bus), errp)) { 382e47e5a5bSBernhard Beschow return; 383e47e5a5bSBernhard Beschow } 3846fe4464cSBernhard Beschow 3856fe4464cSBernhard Beschow /* USB */ 3866fe4464cSBernhard Beschow if (d->has_usb) { 3876fe4464cSBernhard Beschow object_initialize_child(OBJECT(dev), "uhci", &d->uhci, 3886fe4464cSBernhard Beschow TYPE_PIIX3_USB_UHCI); 3896fe4464cSBernhard Beschow qdev_prop_set_int32(DEVICE(&d->uhci), "addr", dev->devfn + 2); 3906fe4464cSBernhard Beschow if (!qdev_realize(DEVICE(&d->uhci), BUS(pci_bus), errp)) { 3916fe4464cSBernhard Beschow return; 3926fe4464cSBernhard Beschow } 3936fe4464cSBernhard Beschow } 3940a15cf08SBernhard Beschow 3950a15cf08SBernhard Beschow /* Power Management */ 3960a15cf08SBernhard Beschow if (d->has_acpi) { 3970a15cf08SBernhard Beschow object_initialize_child(OBJECT(d), "pm", &d->pm, TYPE_PIIX4_PM); 3980a15cf08SBernhard Beschow qdev_prop_set_int32(DEVICE(&d->pm), "addr", dev->devfn + 3); 3990a15cf08SBernhard Beschow qdev_prop_set_uint32(DEVICE(&d->pm), "smb_io_base", d->smb_io_base); 4000a15cf08SBernhard Beschow qdev_prop_set_bit(DEVICE(&d->pm), "smm-enabled", d->smm_enabled); 4010a15cf08SBernhard Beschow if (!qdev_realize(DEVICE(&d->pm), BUS(pci_bus), errp)) { 4020a15cf08SBernhard Beschow return; 4030a15cf08SBernhard Beschow } 4040a15cf08SBernhard Beschow qdev_connect_gpio_out(DEVICE(&d->pm), 0, d->isa_irqs_in[9]); 4050a15cf08SBernhard Beschow } 40614a026ddSPhilippe Mathieu-Daudé } 40714a026ddSPhilippe Mathieu-Daudé 40892ea7fb3SIgor Mammedov static void build_pci_isa_aml(AcpiDevAmlIf *adev, Aml *scope) 40992ea7fb3SIgor Mammedov { 41047a373faSIgor Mammedov Aml *field; 4114fd75ce0SIgor Mammedov Aml *sb_scope = aml_scope("\\_SB"); 41292ea7fb3SIgor Mammedov BusState *bus = qdev_get_child_bus(DEVICE(adev), "isa.0"); 41392ea7fb3SIgor Mammedov 41492ea7fb3SIgor Mammedov /* PIIX PCI to ISA irq remapping */ 41592ea7fb3SIgor Mammedov aml_append(scope, aml_operation_region("P40C", AML_PCI_CONFIG, 41692ea7fb3SIgor Mammedov aml_int(0x60), 0x04)); 41747a373faSIgor Mammedov /* Fields declarion has to happen *after* operation region */ 4184fd75ce0SIgor Mammedov field = aml_field("PCI0.S08.P40C", AML_BYTE_ACC, AML_NOLOCK, AML_PRESERVE); 41947a373faSIgor Mammedov aml_append(field, aml_named_field("PRQ0", 8)); 42047a373faSIgor Mammedov aml_append(field, aml_named_field("PRQ1", 8)); 42147a373faSIgor Mammedov aml_append(field, aml_named_field("PRQ2", 8)); 42247a373faSIgor Mammedov aml_append(field, aml_named_field("PRQ3", 8)); 4234fd75ce0SIgor Mammedov aml_append(sb_scope, field); 4244fd75ce0SIgor Mammedov aml_append(scope, sb_scope); 42547a373faSIgor Mammedov 4269c6c0aeaSBernhard Beschow qbus_build_aml(bus, scope); 42792ea7fb3SIgor Mammedov } 42892ea7fb3SIgor Mammedov 429f0bc6bf7SBernhard Beschow static void pci_piix3_init(Object *obj) 430f0bc6bf7SBernhard Beschow { 4319769cfc3SBernhard Beschow PIIXState *d = PIIX_PCI_DEVICE(obj); 432f0bc6bf7SBernhard Beschow 43340f70623SBernhard Beschow qdev_init_gpio_out_named(DEVICE(obj), d->isa_irqs_in, "isa-irqs", 43440f70623SBernhard Beschow ISA_NUM_IRQS); 435001cb25fSBernhard Beschow 436f0bc6bf7SBernhard Beschow object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC); 437e47e5a5bSBernhard Beschow object_initialize_child(obj, "ide", &d->ide, TYPE_PIIX3_IDE); 438f0bc6bf7SBernhard Beschow } 439f0bc6bf7SBernhard Beschow 4406fe4464cSBernhard Beschow static Property pci_piix3_props[] = { 4419769cfc3SBernhard Beschow DEFINE_PROP_UINT32("smb_io_base", PIIXState, smb_io_base, 0), 4429769cfc3SBernhard Beschow DEFINE_PROP_BOOL("has-acpi", PIIXState, has_acpi, true), 4432d7630f5SBernhard Beschow DEFINE_PROP_BOOL("has-pic", PIIXState, has_pic, true), 444*ac433035SBernhard Beschow DEFINE_PROP_BOOL("has-pit", PIIXState, has_pit, true), 4459769cfc3SBernhard Beschow DEFINE_PROP_BOOL("has-usb", PIIXState, has_usb, true), 4469769cfc3SBernhard Beschow DEFINE_PROP_BOOL("smm-enabled", PIIXState, smm_enabled, false), 4476fe4464cSBernhard Beschow DEFINE_PROP_END_OF_LIST(), 4486fe4464cSBernhard Beschow }; 4496fe4464cSBernhard Beschow 45014a026ddSPhilippe Mathieu-Daudé static void pci_piix3_class_init(ObjectClass *klass, void *data) 45114a026ddSPhilippe Mathieu-Daudé { 45214a026ddSPhilippe Mathieu-Daudé DeviceClass *dc = DEVICE_CLASS(klass); 45314a026ddSPhilippe Mathieu-Daudé PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); 45492ea7fb3SIgor Mammedov AcpiDevAmlIfClass *adevc = ACPI_DEV_AML_IF_CLASS(klass); 45514a026ddSPhilippe Mathieu-Daudé 4560f3e02a2SBernhard Beschow k->config_write = piix3_write_config; 457a1b05751SBernhard Beschow dc->reset = piix3_reset; 45814a026ddSPhilippe Mathieu-Daudé dc->desc = "ISA bridge"; 45914a026ddSPhilippe Mathieu-Daudé dc->vmsd = &vmstate_piix3; 46014a026ddSPhilippe Mathieu-Daudé dc->hotpluggable = false; 46114a026ddSPhilippe Mathieu-Daudé k->vendor_id = PCI_VENDOR_ID_INTEL; 46214a026ddSPhilippe Mathieu-Daudé /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ 46314a026ddSPhilippe Mathieu-Daudé k->device_id = PCI_DEVICE_ID_INTEL_82371SB_0; 46414a026ddSPhilippe Mathieu-Daudé k->class_id = PCI_CLASS_BRIDGE_ISA; 46514a026ddSPhilippe Mathieu-Daudé /* 46614a026ddSPhilippe Mathieu-Daudé * Reason: part of PIIX3 southbridge, needs to be wired up by 46714a026ddSPhilippe Mathieu-Daudé * pc_piix.c's pc_init1() 46814a026ddSPhilippe Mathieu-Daudé */ 46914a026ddSPhilippe Mathieu-Daudé dc->user_creatable = false; 4706fe4464cSBernhard Beschow device_class_set_props(dc, pci_piix3_props); 47192ea7fb3SIgor Mammedov adevc->build_dev_aml = build_pci_isa_aml; 47214a026ddSPhilippe Mathieu-Daudé } 47314a026ddSPhilippe Mathieu-Daudé 4749769cfc3SBernhard Beschow static const TypeInfo piix_pci_type_info = { 4759769cfc3SBernhard Beschow .name = TYPE_PIIX_PCI_DEVICE, 47614a026ddSPhilippe Mathieu-Daudé .parent = TYPE_PCI_DEVICE, 4779769cfc3SBernhard Beschow .instance_size = sizeof(PIIXState), 478f0bc6bf7SBernhard Beschow .instance_init = pci_piix3_init, 47914a026ddSPhilippe Mathieu-Daudé .abstract = true, 48014a026ddSPhilippe Mathieu-Daudé .class_init = pci_piix3_class_init, 48114a026ddSPhilippe Mathieu-Daudé .interfaces = (InterfaceInfo[]) { 48214a026ddSPhilippe Mathieu-Daudé { INTERFACE_CONVENTIONAL_PCI_DEVICE }, 48392ea7fb3SIgor Mammedov { TYPE_ACPI_DEV_AML_IF }, 48414a026ddSPhilippe Mathieu-Daudé { }, 48514a026ddSPhilippe Mathieu-Daudé }, 48614a026ddSPhilippe Mathieu-Daudé }; 48714a026ddSPhilippe Mathieu-Daudé 488fe3055d2SBernhard Beschow static void piix3_realize(PCIDevice *dev, Error **errp) 489fe3055d2SBernhard Beschow { 490fe3055d2SBernhard Beschow ERRP_GUARD(); 4919769cfc3SBernhard Beschow PIIXState *piix3 = PIIX_PCI_DEVICE(dev); 492fe3055d2SBernhard Beschow PCIBus *pci_bus = pci_get_bus(dev); 493fe3055d2SBernhard Beschow 494fe3055d2SBernhard Beschow pci_piix3_realize(dev, errp); 495fe3055d2SBernhard Beschow if (*errp) { 496fe3055d2SBernhard Beschow return; 497fe3055d2SBernhard Beschow } 498fe3055d2SBernhard Beschow 499f021f4e9SBernhard Beschow pci_bus_irqs(pci_bus, piix3_set_irq, piix3, PIIX_NUM_PIRQS); 500fe3055d2SBernhard Beschow pci_bus_set_route_irq_fn(pci_bus, piix3_route_intx_pin_to_irq); 50105c049f1SBernhard Beschow } 502fe3055d2SBernhard Beschow 50314a026ddSPhilippe Mathieu-Daudé static void piix3_class_init(ObjectClass *klass, void *data) 50414a026ddSPhilippe Mathieu-Daudé { 50514a026ddSPhilippe Mathieu-Daudé PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); 50614a026ddSPhilippe Mathieu-Daudé 507fe3055d2SBernhard Beschow k->realize = piix3_realize; 50814a026ddSPhilippe Mathieu-Daudé } 50914a026ddSPhilippe Mathieu-Daudé 51014a026ddSPhilippe Mathieu-Daudé static const TypeInfo piix3_info = { 51114a026ddSPhilippe Mathieu-Daudé .name = TYPE_PIIX3_DEVICE, 5129769cfc3SBernhard Beschow .parent = TYPE_PIIX_PCI_DEVICE, 51314a026ddSPhilippe Mathieu-Daudé .class_init = piix3_class_init, 51414a026ddSPhilippe Mathieu-Daudé }; 51514a026ddSPhilippe Mathieu-Daudé 51616971899SBernhard Beschow static void piix4_realize(PCIDevice *dev, Error **errp) 51716971899SBernhard Beschow { 51816971899SBernhard Beschow PIIX4State *s = PIIX4_PCI_DEVICE(dev); 51916971899SBernhard Beschow PCIBus *pci_bus = pci_get_bus(dev); 52016971899SBernhard Beschow ISABus *isa_bus; 52116971899SBernhard Beschow qemu_irq *i8259_out_irq; 52216971899SBernhard Beschow qemu_irq *i8259; 52316971899SBernhard Beschow size_t i; 52416971899SBernhard Beschow 52516971899SBernhard Beschow isa_bus = isa_bus_new(DEVICE(dev), pci_address_space(dev), 52616971899SBernhard Beschow pci_address_space_io(dev), errp); 52716971899SBernhard Beschow if (!isa_bus) { 52816971899SBernhard Beschow return; 52916971899SBernhard Beschow } 53016971899SBernhard Beschow 53116971899SBernhard Beschow qdev_init_gpio_out_named(DEVICE(dev), &s->cpu_intr, 53216971899SBernhard Beschow "intr", 1); 53316971899SBernhard Beschow 53416971899SBernhard Beschow memory_region_init_io(&s->rcr_mem, OBJECT(dev), &rcr_ops, s, 53516971899SBernhard Beschow "reset-control", 1); 53616971899SBernhard Beschow memory_region_add_subregion_overlap(pci_address_space_io(dev), 53716971899SBernhard Beschow PIIX_RCR_IOPORT, &s->rcr_mem, 1); 53816971899SBernhard Beschow 53916971899SBernhard Beschow /* initialize i8259 pic */ 5402d7630f5SBernhard Beschow i8259_out_irq = qemu_allocate_irqs(piix_request_i8259_irq, s, 1); 54116971899SBernhard Beschow i8259 = i8259_init(isa_bus, *i8259_out_irq); 54216971899SBernhard Beschow 54316971899SBernhard Beschow for (i = 0; i < ISA_NUM_IRQS; i++) { 54416971899SBernhard Beschow s->isa_irqs_in[i] = i8259[i]; 54516971899SBernhard Beschow } 54616971899SBernhard Beschow 54716971899SBernhard Beschow g_free(i8259); 54816971899SBernhard Beschow 54916971899SBernhard Beschow /* initialize ISA irqs */ 55016971899SBernhard Beschow isa_bus_register_input_irqs(isa_bus, s->isa_irqs_in); 55116971899SBernhard Beschow 55216971899SBernhard Beschow /* initialize pit */ 55316971899SBernhard Beschow i8254_pit_init(isa_bus, 0x40, 0, NULL); 55416971899SBernhard Beschow 55516971899SBernhard Beschow /* DMA */ 55616971899SBernhard Beschow i8257_dma_init(isa_bus, 0); 55716971899SBernhard Beschow 55816971899SBernhard Beschow /* RTC */ 55916971899SBernhard Beschow qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000); 56016971899SBernhard Beschow if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) { 56116971899SBernhard Beschow return; 56216971899SBernhard Beschow } 56316971899SBernhard Beschow s->rtc.irq = isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq); 56416971899SBernhard Beschow 56516971899SBernhard Beschow /* IDE */ 56616971899SBernhard Beschow qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1); 56716971899SBernhard Beschow if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { 56816971899SBernhard Beschow return; 56916971899SBernhard Beschow } 57016971899SBernhard Beschow 57116971899SBernhard Beschow /* USB */ 57216971899SBernhard Beschow qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2); 57316971899SBernhard Beschow if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) { 57416971899SBernhard Beschow return; 57516971899SBernhard Beschow } 57616971899SBernhard Beschow 57716971899SBernhard Beschow /* ACPI controller */ 57816971899SBernhard Beschow qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3); 57916971899SBernhard Beschow if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) { 58016971899SBernhard Beschow return; 58116971899SBernhard Beschow } 58216971899SBernhard Beschow qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa_irqs_in[9]); 58316971899SBernhard Beschow 58416971899SBernhard Beschow pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); 58516971899SBernhard Beschow } 58616971899SBernhard Beschow 58716971899SBernhard Beschow static void piix4_isa_reset(DeviceState *dev) 58816971899SBernhard Beschow { 58916971899SBernhard Beschow PIIX4State *s = PIIX4_PCI_DEVICE(dev); 59016971899SBernhard Beschow 59116971899SBernhard Beschow piix_reset(s); 59216971899SBernhard Beschow } 59316971899SBernhard Beschow 59416971899SBernhard Beschow static void piix4_init(Object *obj) 59516971899SBernhard Beschow { 59616971899SBernhard Beschow PIIX4State *s = PIIX4_PCI_DEVICE(obj); 59716971899SBernhard Beschow 59816971899SBernhard Beschow object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); 59916971899SBernhard Beschow object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE); 60016971899SBernhard Beschow object_initialize_child(obj, "uhci", &s->uhci, TYPE_PIIX4_USB_UHCI); 60116971899SBernhard Beschow 60216971899SBernhard Beschow object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM); 60316971899SBernhard Beschow qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100); 60416971899SBernhard Beschow qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0); 60516971899SBernhard Beschow } 60616971899SBernhard Beschow 60716971899SBernhard Beschow static void piix4_class_init(ObjectClass *klass, void *data) 60816971899SBernhard Beschow { 60916971899SBernhard Beschow DeviceClass *dc = DEVICE_CLASS(klass); 61016971899SBernhard Beschow PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); 61116971899SBernhard Beschow 61216971899SBernhard Beschow k->realize = piix4_realize; 61316971899SBernhard Beschow k->vendor_id = PCI_VENDOR_ID_INTEL; 61416971899SBernhard Beschow k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0; 61516971899SBernhard Beschow k->class_id = PCI_CLASS_BRIDGE_ISA; 61616971899SBernhard Beschow dc->reset = piix4_isa_reset; 61716971899SBernhard Beschow dc->desc = "ISA bridge"; 61816971899SBernhard Beschow dc->vmsd = &vmstate_piix4; 61916971899SBernhard Beschow /* 62016971899SBernhard Beschow * Reason: part of PIIX4 southbridge, needs to be wired up, 62116971899SBernhard Beschow * e.g. by mips_malta_init() 62216971899SBernhard Beschow */ 62316971899SBernhard Beschow dc->user_creatable = false; 62416971899SBernhard Beschow dc->hotpluggable = false; 62516971899SBernhard Beschow } 62616971899SBernhard Beschow 62716971899SBernhard Beschow static const TypeInfo piix4_info = { 62816971899SBernhard Beschow .name = TYPE_PIIX4_PCI_DEVICE, 62916971899SBernhard Beschow .parent = TYPE_PCI_DEVICE, 63016971899SBernhard Beschow .instance_size = sizeof(PIIX4State), 63116971899SBernhard Beschow .instance_init = piix4_init, 63216971899SBernhard Beschow .class_init = piix4_class_init, 63316971899SBernhard Beschow .interfaces = (InterfaceInfo[]) { 63416971899SBernhard Beschow { INTERFACE_CONVENTIONAL_PCI_DEVICE }, 63516971899SBernhard Beschow { }, 63616971899SBernhard Beschow }, 63716971899SBernhard Beschow }; 63816971899SBernhard Beschow 63914a026ddSPhilippe Mathieu-Daudé static void piix3_register_types(void) 64014a026ddSPhilippe Mathieu-Daudé { 6419769cfc3SBernhard Beschow type_register_static(&piix_pci_type_info); 64214a026ddSPhilippe Mathieu-Daudé type_register_static(&piix3_info); 64316971899SBernhard Beschow type_register_static(&piix4_info); 64414a026ddSPhilippe Mathieu-Daudé } 64514a026ddSPhilippe Mathieu-Daudé 64614a026ddSPhilippe Mathieu-Daudé type_init(piix3_register_types) 647