1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include "hw/hw.h"
26#include "hw/i386/pc.h"
27#include "hw/pci/pci.h"
28#include "hw/isa/isa.h"
29#include "hw/sysbus.h"
30
31PCIDevice *piix4_dev;
32
33typedef struct PIIX4State {
34 PCIDevice dev;
35} PIIX4State;
36
37static void piix4_reset(void *opaque)
38{
39 PIIX4State *d = opaque;
40 uint8_t *pci_conf = d->dev.config;
41
42 pci_conf[0x04] = 0x07;
43 pci_conf[0x05] = 0x00;
44 pci_conf[0x06] = 0x00;
45 pci_conf[0x07] = 0x02;
46 pci_conf[0x4c] = 0x4d;
47 pci_conf[0x4e] = 0x03;
48 pci_conf[0x4f] = 0x00;
49 pci_conf[0x60] = 0x0a;
50 pci_conf[0x61] = 0x0a;
51 pci_conf[0x62] = 0x0b;
52 pci_conf[0x63] = 0x0b;
53 pci_conf[0x69] = 0x02;
54 pci_conf[0x70] = 0x80;
55 pci_conf[0x76] = 0x0c;
56 pci_conf[0x77] = 0x0c;
57 pci_conf[0x78] = 0x02;
58 pci_conf[0x79] = 0x00;
59 pci_conf[0x80] = 0x00;
60 pci_conf[0x82] = 0x00;
61 pci_conf[0xa0] = 0x08;
62 pci_conf[0xa2] = 0x00;
63 pci_conf[0xa3] = 0x00;
64 pci_conf[0xa4] = 0x00;
65 pci_conf[0xa5] = 0x00;
66 pci_conf[0xa6] = 0x00;
67 pci_conf[0xa7] = 0x00;
68 pci_conf[0xa8] = 0x0f;
69 pci_conf[0xaa] = 0x00;
70 pci_conf[0xab] = 0x00;
71 pci_conf[0xac] = 0x00;
72 pci_conf[0xae] = 0x00;
73}
74
75static const VMStateDescription vmstate_piix4 = {
76 .name = "PIIX4",
77 .version_id = 2,
78 .minimum_version_id = 2,
79 .minimum_version_id_old = 2,
80 .fields = (VMStateField[]) {
81 VMSTATE_PCI_DEVICE(dev, PIIX4State),
82 VMSTATE_END_OF_LIST()
83 }
84};
85
86static int piix4_initfn(PCIDevice *dev)
87{
88 PIIX4State *d = DO_UPCAST(PIIX4State, dev, dev);
89
90 isa_bus_new(&d->dev.qdev, pci_address_space_io(dev));
91 piix4_dev = &d->dev;
92 qemu_register_reset(piix4_reset, d);
93 return 0;
94}
95
96int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)
97{
98 PCIDevice *d;
99
100 d = pci_create_simple_multifunction(bus, devfn, true, "PIIX4");
101 *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(d), "isa.0"));
102 return d->devfn;
103}
104
105static void piix4_class_init(ObjectClass *klass, void *data)
106{
107 DeviceClass *dc = DEVICE_CLASS(klass);
108 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
109
110 k->no_hotplug = 1;
111 k->init = piix4_initfn;
112 k->vendor_id = PCI_VENDOR_ID_INTEL;
113 k->device_id = PCI_DEVICE_ID_INTEL_82371AB_0;
114 k->class_id = PCI_CLASS_BRIDGE_ISA;
115 dc->desc = "ISA bridge";
116 dc->no_user = 1;
117 dc->vmsd = &vmstate_piix4;
118}
119
120static const TypeInfo piix4_info = {
121 .name = "PIIX4",
122 .parent = TYPE_PCI_DEVICE,
123 .instance_size = sizeof(PIIX4State),
124 .class_init = piix4_class_init,
125};
126
127static void piix4_register_types(void)
128{
129 type_register_static(&piix4_info);
130}
131
132type_init(piix4_register_types)
133