root / hw / piix_pci.c @ 5041fccd
History | View | Annotate | Download (11 kB)
1 | 502a5395 | pbrook | /*
|
---|---|---|---|
2 | 502a5395 | pbrook | * QEMU i440FX/PIIX3 PCI Bridge Emulation
|
3 | 502a5395 | pbrook | *
|
4 | 502a5395 | pbrook | * Copyright (c) 2006 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 502a5395 | pbrook | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 502a5395 | pbrook | * of this software and associated documentation files (the "Software"), to deal
|
8 | 502a5395 | pbrook | * in the Software without restriction, including without limitation the rights
|
9 | 502a5395 | pbrook | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 502a5395 | pbrook | * copies of the Software, and to permit persons to whom the Software is
|
11 | 502a5395 | pbrook | * furnished to do so, subject to the following conditions:
|
12 | 502a5395 | pbrook | *
|
13 | 502a5395 | pbrook | * The above copyright notice and this permission notice shall be included in
|
14 | 502a5395 | pbrook | * all copies or substantial portions of the Software.
|
15 | 502a5395 | pbrook | *
|
16 | 502a5395 | pbrook | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 502a5395 | pbrook | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 502a5395 | pbrook | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 502a5395 | pbrook | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 502a5395 | pbrook | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 502a5395 | pbrook | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 502a5395 | pbrook | * THE SOFTWARE.
|
23 | 502a5395 | pbrook | */
|
24 | 502a5395 | pbrook | |
25 | 87ecb68b | pbrook | #include "hw.h" |
26 | 87ecb68b | pbrook | #include "pc.h" |
27 | 87ecb68b | pbrook | #include "pci.h" |
28 | f75247f1 | Gerd Hoffmann | #include "isa.h" |
29 | 8a14daa5 | Gerd Hoffmann | #include "sysbus.h" |
30 | 87ecb68b | pbrook | |
31 | c227f099 | Anthony Liguori | typedef uint32_t pci_addr_t;
|
32 | 502a5395 | pbrook | #include "pci_host.h" |
33 | 502a5395 | pbrook | |
34 | 502a5395 | pbrook | typedef PCIHostState I440FXState;
|
35 | 502a5395 | pbrook | |
36 | fd37d881 | Juan Quintela | typedef struct PIIX3State { |
37 | fd37d881 | Juan Quintela | PCIDevice dev; |
38 | 8372615d | Juan Quintela | int pci_irq_levels[4]; |
39 | bd7dce87 | Juan Quintela | qemu_irq *pic; |
40 | 7cd9eee0 | Gerd Hoffmann | } PIIX3State; |
41 | bd7dce87 | Juan Quintela | |
42 | 0a3bacf3 | Juan Quintela | struct PCII440FXState {
|
43 | 0a3bacf3 | Juan Quintela | PCIDevice dev; |
44 | c227f099 | Anthony Liguori | target_phys_addr_t isa_page_descs[384 / 4]; |
45 | 6c009fa4 | Juan Quintela | uint8_t smm_enabled; |
46 | 7cd9eee0 | Gerd Hoffmann | PIIX3State *piix3; |
47 | 0a3bacf3 | Juan Quintela | }; |
48 | 0a3bacf3 | Juan Quintela | |
49 | 502a5395 | pbrook | static void i440fx_addr_writel(void* opaque, uint32_t addr, uint32_t val) |
50 | 502a5395 | pbrook | { |
51 | 502a5395 | pbrook | I440FXState *s = opaque; |
52 | 502a5395 | pbrook | s->config_reg = val; |
53 | 502a5395 | pbrook | } |
54 | 502a5395 | pbrook | |
55 | 502a5395 | pbrook | static uint32_t i440fx_addr_readl(void* opaque, uint32_t addr) |
56 | 502a5395 | pbrook | { |
57 | 502a5395 | pbrook | I440FXState *s = opaque; |
58 | 502a5395 | pbrook | return s->config_reg;
|
59 | 502a5395 | pbrook | } |
60 | 502a5395 | pbrook | |
61 | 5d4e84c8 | Juan Quintela | static void piix3_set_irq(void *opaque, int irq_num, int level); |
62 | d2b59317 | pbrook | |
63 | d2b59317 | pbrook | /* return the global irq number corresponding to a given device irq
|
64 | d2b59317 | pbrook | pin. We could also use the bus number to have a more precise
|
65 | d2b59317 | pbrook | mapping. */
|
66 | d2b59317 | pbrook | static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) |
67 | d2b59317 | pbrook | { |
68 | d2b59317 | pbrook | int slot_addend;
|
69 | d2b59317 | pbrook | slot_addend = (pci_dev->devfn >> 3) - 1; |
70 | d2b59317 | pbrook | return (irq_num + slot_addend) & 3; |
71 | d2b59317 | pbrook | } |
72 | 502a5395 | pbrook | |
73 | 0a3bacf3 | Juan Quintela | static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r) |
74 | 84631fd7 | bellard | { |
75 | 84631fd7 | bellard | uint32_t addr; |
76 | 84631fd7 | bellard | |
77 | 84631fd7 | bellard | // printf("ISA mapping %08x-0x%08x: %d\n", start, end, r);
|
78 | 84631fd7 | bellard | switch(r) {
|
79 | 84631fd7 | bellard | case 3: |
80 | 84631fd7 | bellard | /* RAM */
|
81 | 5fafdf24 | ths | cpu_register_physical_memory(start, end - start, |
82 | 84631fd7 | bellard | start); |
83 | 84631fd7 | bellard | break;
|
84 | 84631fd7 | bellard | case 1: |
85 | 84631fd7 | bellard | /* ROM (XXX: not quite correct) */
|
86 | 5fafdf24 | ths | cpu_register_physical_memory(start, end - start, |
87 | 84631fd7 | bellard | start | IO_MEM_ROM); |
88 | 84631fd7 | bellard | break;
|
89 | 84631fd7 | bellard | case 2: |
90 | 84631fd7 | bellard | case 0: |
91 | 84631fd7 | bellard | /* XXX: should distinguish read/write cases */
|
92 | 84631fd7 | bellard | for(addr = start; addr < end; addr += 4096) { |
93 | 5fafdf24 | ths | cpu_register_physical_memory(addr, 4096,
|
94 | 6c009fa4 | Juan Quintela | d->isa_page_descs[(addr - 0xa0000) >> 12]); |
95 | 84631fd7 | bellard | } |
96 | 84631fd7 | bellard | break;
|
97 | 84631fd7 | bellard | } |
98 | 84631fd7 | bellard | } |
99 | ee0ea1d0 | bellard | |
100 | 0a3bacf3 | Juan Quintela | static void i440fx_update_memory_mappings(PCII440FXState *d) |
101 | ee0ea1d0 | bellard | { |
102 | ee0ea1d0 | bellard | int i, r;
|
103 | 84631fd7 | bellard | uint32_t smram, addr; |
104 | 84631fd7 | bellard | |
105 | 0a3bacf3 | Juan Quintela | update_pam(d, 0xf0000, 0x100000, (d->dev.config[0x59] >> 4) & 3); |
106 | 84631fd7 | bellard | for(i = 0; i < 12; i++) { |
107 | 0a3bacf3 | Juan Quintela | r = (d->dev.config[(i >> 1) + 0x5a] >> ((i & 1) * 4)) & 3; |
108 | 84631fd7 | bellard | update_pam(d, 0xc0000 + 0x4000 * i, 0xc0000 + 0x4000 * (i + 1), r); |
109 | ee0ea1d0 | bellard | } |
110 | 0a3bacf3 | Juan Quintela | smram = d->dev.config[0x72];
|
111 | 6c009fa4 | Juan Quintela | if ((d->smm_enabled && (smram & 0x08)) || (smram & 0x40)) { |
112 | 84631fd7 | bellard | cpu_register_physical_memory(0xa0000, 0x20000, 0xa0000); |
113 | 84631fd7 | bellard | } else {
|
114 | 84631fd7 | bellard | for(addr = 0xa0000; addr < 0xc0000; addr += 4096) { |
115 | 5fafdf24 | ths | cpu_register_physical_memory(addr, 4096,
|
116 | 6c009fa4 | Juan Quintela | d->isa_page_descs[(addr - 0xa0000) >> 12]); |
117 | ee0ea1d0 | bellard | } |
118 | ee0ea1d0 | bellard | } |
119 | ee0ea1d0 | bellard | } |
120 | ee0ea1d0 | bellard | |
121 | 0a3bacf3 | Juan Quintela | void i440fx_set_smm(PCII440FXState *d, int val) |
122 | ee0ea1d0 | bellard | { |
123 | ee0ea1d0 | bellard | val = (val != 0);
|
124 | 6c009fa4 | Juan Quintela | if (d->smm_enabled != val) {
|
125 | 6c009fa4 | Juan Quintela | d->smm_enabled = val; |
126 | ee0ea1d0 | bellard | i440fx_update_memory_mappings(d); |
127 | ee0ea1d0 | bellard | } |
128 | ee0ea1d0 | bellard | } |
129 | ee0ea1d0 | bellard | |
130 | ee0ea1d0 | bellard | |
131 | ee0ea1d0 | bellard | /* XXX: suppress when better memory API. We make the assumption that
|
132 | ee0ea1d0 | bellard | no device (in particular the VGA) changes the memory mappings in
|
133 | ee0ea1d0 | bellard | the 0xa0000-0x100000 range */
|
134 | 0a3bacf3 | Juan Quintela | void i440fx_init_memory_mappings(PCII440FXState *d)
|
135 | ee0ea1d0 | bellard | { |
136 | ee0ea1d0 | bellard | int i;
|
137 | ee0ea1d0 | bellard | for(i = 0; i < 96; i++) { |
138 | 6c009fa4 | Juan Quintela | d->isa_page_descs[i] = cpu_get_physical_page_desc(0xa0000 + i * 0x1000); |
139 | ee0ea1d0 | bellard | } |
140 | ee0ea1d0 | bellard | } |
141 | ee0ea1d0 | bellard | |
142 | 0a3bacf3 | Juan Quintela | static void i440fx_write_config(PCIDevice *dev, |
143 | ee0ea1d0 | bellard | uint32_t address, uint32_t val, int len)
|
144 | ee0ea1d0 | bellard | { |
145 | 0a3bacf3 | Juan Quintela | PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); |
146 | 0a3bacf3 | Juan Quintela | |
147 | ee0ea1d0 | bellard | /* XXX: implement SMRAM.D_LOCK */
|
148 | 0a3bacf3 | Juan Quintela | pci_default_write_config(dev, address, val, len); |
149 | 84631fd7 | bellard | if ((address >= 0x59 && address <= 0x5f) || address == 0x72) |
150 | ee0ea1d0 | bellard | i440fx_update_memory_mappings(d); |
151 | ee0ea1d0 | bellard | } |
152 | ee0ea1d0 | bellard | |
153 | 0c7d19e5 | Juan Quintela | static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) |
154 | ee0ea1d0 | bellard | { |
155 | 0a3bacf3 | Juan Quintela | PCII440FXState *d = opaque; |
156 | 52fc1d83 | balrog | int ret, i;
|
157 | ee0ea1d0 | bellard | |
158 | 0a3bacf3 | Juan Quintela | ret = pci_device_load(&d->dev, f); |
159 | ee0ea1d0 | bellard | if (ret < 0) |
160 | ee0ea1d0 | bellard | return ret;
|
161 | ee0ea1d0 | bellard | i440fx_update_memory_mappings(d); |
162 | 6c009fa4 | Juan Quintela | qemu_get_8s(f, &d->smm_enabled); |
163 | 52fc1d83 | balrog | |
164 | da64182c | Juan Quintela | if (version_id == 2) |
165 | 52fc1d83 | balrog | for (i = 0; i < 4; i++) |
166 | 7cd9eee0 | Gerd Hoffmann | d->piix3->pci_irq_levels[i] = qemu_get_be32(f); |
167 | 52fc1d83 | balrog | |
168 | ee0ea1d0 | bellard | return 0; |
169 | ee0ea1d0 | bellard | } |
170 | ee0ea1d0 | bellard | |
171 | e59fb374 | Juan Quintela | static int i440fx_post_load(void *opaque, int version_id) |
172 | 0c7d19e5 | Juan Quintela | { |
173 | 0c7d19e5 | Juan Quintela | PCII440FXState *d = opaque; |
174 | 0c7d19e5 | Juan Quintela | |
175 | 0c7d19e5 | Juan Quintela | i440fx_update_memory_mappings(d); |
176 | 0c7d19e5 | Juan Quintela | return 0; |
177 | 0c7d19e5 | Juan Quintela | } |
178 | 0c7d19e5 | Juan Quintela | |
179 | 0c7d19e5 | Juan Quintela | static const VMStateDescription vmstate_i440fx = { |
180 | 0c7d19e5 | Juan Quintela | .name = "I440FX",
|
181 | 0c7d19e5 | Juan Quintela | .version_id = 3,
|
182 | 0c7d19e5 | Juan Quintela | .minimum_version_id = 3,
|
183 | 0c7d19e5 | Juan Quintela | .minimum_version_id_old = 1,
|
184 | 0c7d19e5 | Juan Quintela | .load_state_old = i440fx_load_old, |
185 | 752ff2fa | Juan Quintela | .post_load = i440fx_post_load, |
186 | 0c7d19e5 | Juan Quintela | .fields = (VMStateField []) { |
187 | 0c7d19e5 | Juan Quintela | VMSTATE_PCI_DEVICE(dev, PCII440FXState), |
188 | 0c7d19e5 | Juan Quintela | VMSTATE_UINT8(smm_enabled, PCII440FXState), |
189 | 0c7d19e5 | Juan Quintela | VMSTATE_END_OF_LIST() |
190 | 0c7d19e5 | Juan Quintela | } |
191 | 0c7d19e5 | Juan Quintela | }; |
192 | 0c7d19e5 | Juan Quintela | |
193 | 81a322d4 | Gerd Hoffmann | static int i440fx_pcihost_initfn(SysBusDevice *dev) |
194 | 502a5395 | pbrook | { |
195 | 8a14daa5 | Gerd Hoffmann | I440FXState *s = FROM_SYSBUS(I440FXState, dev); |
196 | 502a5395 | pbrook | |
197 | 502a5395 | pbrook | register_ioport_write(0xcf8, 4, 4, i440fx_addr_writel, s); |
198 | 502a5395 | pbrook | register_ioport_read(0xcf8, 4, 4, i440fx_addr_readl, s); |
199 | 502a5395 | pbrook | |
200 | 502a5395 | pbrook | register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s); |
201 | 502a5395 | pbrook | register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s); |
202 | 502a5395 | pbrook | register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s); |
203 | 502a5395 | pbrook | register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s); |
204 | 502a5395 | pbrook | register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s); |
205 | 502a5395 | pbrook | register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s); |
206 | 81a322d4 | Gerd Hoffmann | return 0; |
207 | 8a14daa5 | Gerd Hoffmann | } |
208 | 502a5395 | pbrook | |
209 | 0a3bacf3 | Juan Quintela | static int i440fx_initfn(PCIDevice *dev) |
210 | 8a14daa5 | Gerd Hoffmann | { |
211 | 0a3bacf3 | Juan Quintela | PCII440FXState *d = DO_UPCAST(PCII440FXState, dev, dev); |
212 | ee0ea1d0 | bellard | |
213 | 0a3bacf3 | Juan Quintela | pci_config_set_vendor_id(d->dev.config, PCI_VENDOR_ID_INTEL); |
214 | 0a3bacf3 | Juan Quintela | pci_config_set_device_id(d->dev.config, PCI_DEVICE_ID_INTEL_82441); |
215 | 0a3bacf3 | Juan Quintela | d->dev.config[0x08] = 0x02; // revision |
216 | 0a3bacf3 | Juan Quintela | pci_config_set_class(d->dev.config, PCI_CLASS_BRIDGE_HOST); |
217 | 0a3bacf3 | Juan Quintela | d->dev.config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
218 | 0a3bacf3 | Juan Quintela | |
219 | 0a3bacf3 | Juan Quintela | d->dev.config[0x72] = 0x02; /* SMRAM */ |
220 | ee0ea1d0 | bellard | |
221 | 0c7d19e5 | Juan Quintela | vmstate_register(0, &vmstate_i440fx, d);
|
222 | 81a322d4 | Gerd Hoffmann | return 0; |
223 | 8a14daa5 | Gerd Hoffmann | } |
224 | 8a14daa5 | Gerd Hoffmann | |
225 | 85a750ca | Juan Quintela | PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic)
|
226 | 8a14daa5 | Gerd Hoffmann | { |
227 | 8a14daa5 | Gerd Hoffmann | DeviceState *dev; |
228 | 8a14daa5 | Gerd Hoffmann | PCIBus *b; |
229 | 8a14daa5 | Gerd Hoffmann | PCIDevice *d; |
230 | 8a14daa5 | Gerd Hoffmann | I440FXState *s; |
231 | 7cd9eee0 | Gerd Hoffmann | PIIX3State *piix3; |
232 | 8a14daa5 | Gerd Hoffmann | |
233 | 8a14daa5 | Gerd Hoffmann | dev = qdev_create(NULL, "i440FX-pcihost"); |
234 | 8a14daa5 | Gerd Hoffmann | s = FROM_SYSBUS(I440FXState, sysbus_from_qdev(dev)); |
235 | 7cd9eee0 | Gerd Hoffmann | b = pci_bus_new(&s->busdev.qdev, NULL, 0); |
236 | 8a14daa5 | Gerd Hoffmann | s->bus = b; |
237 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
238 | 8a14daa5 | Gerd Hoffmann | |
239 | 8a14daa5 | Gerd Hoffmann | d = pci_create_simple(b, 0, "i440FX"); |
240 | 0a3bacf3 | Juan Quintela | *pi440fx_state = DO_UPCAST(PCII440FXState, dev, d); |
241 | 8a14daa5 | Gerd Hoffmann | |
242 | 7cd9eee0 | Gerd Hoffmann | piix3 = DO_UPCAST(PIIX3State, dev, |
243 | fd83e9b9 | Juan Quintela | pci_create_simple(b, -1, "PIIX3")); |
244 | 7cd9eee0 | Gerd Hoffmann | piix3->pic = pic; |
245 | 7cd9eee0 | Gerd Hoffmann | pci_bus_irqs(b, piix3_set_irq, pci_slot_get_pirq, piix3, 4);
|
246 | 7cd9eee0 | Gerd Hoffmann | (*pi440fx_state)->piix3 = piix3; |
247 | 7cd9eee0 | Gerd Hoffmann | |
248 | 7cd9eee0 | Gerd Hoffmann | *piix3_devfn = piix3->dev.devfn; |
249 | 85a750ca | Juan Quintela | |
250 | 502a5395 | pbrook | return b;
|
251 | 502a5395 | pbrook | } |
252 | 502a5395 | pbrook | |
253 | 502a5395 | pbrook | /* PIIX3 PCI to ISA bridge */
|
254 | 502a5395 | pbrook | |
255 | 5d4e84c8 | Juan Quintela | static void piix3_set_irq(void *opaque, int irq_num, int level) |
256 | 502a5395 | pbrook | { |
257 | d2b59317 | pbrook | int i, pic_irq, pic_level;
|
258 | 7cd9eee0 | Gerd Hoffmann | PIIX3State *piix3 = opaque; |
259 | 502a5395 | pbrook | |
260 | 7cd9eee0 | Gerd Hoffmann | piix3->pci_irq_levels[irq_num] = level; |
261 | 502a5395 | pbrook | |
262 | 502a5395 | pbrook | /* now we change the pic irq level according to the piix irq mappings */
|
263 | 502a5395 | pbrook | /* XXX: optimize */
|
264 | 7cd9eee0 | Gerd Hoffmann | pic_irq = piix3->dev.config[0x60 + irq_num];
|
265 | 502a5395 | pbrook | if (pic_irq < 16) { |
266 | d2b59317 | pbrook | /* The pic level is the logical OR of all the PCI irqs mapped
|
267 | 502a5395 | pbrook | to it */
|
268 | 502a5395 | pbrook | pic_level = 0;
|
269 | d2b59317 | pbrook | for (i = 0; i < 4; i++) { |
270 | 7cd9eee0 | Gerd Hoffmann | if (pic_irq == piix3->dev.config[0x60 + i]) |
271 | 7cd9eee0 | Gerd Hoffmann | pic_level |= piix3->pci_irq_levels[i]; |
272 | d2b59317 | pbrook | } |
273 | 7cd9eee0 | Gerd Hoffmann | qemu_set_irq(piix3->pic[pic_irq], pic_level); |
274 | 502a5395 | pbrook | } |
275 | 502a5395 | pbrook | } |
276 | 502a5395 | pbrook | |
277 | 15a1956a | Gleb Natapov | static void piix3_reset(void *opaque) |
278 | 502a5395 | pbrook | { |
279 | fd37d881 | Juan Quintela | PIIX3State *d = opaque; |
280 | fd37d881 | Juan Quintela | uint8_t *pci_conf = d->dev.config; |
281 | 502a5395 | pbrook | |
282 | 502a5395 | pbrook | pci_conf[0x04] = 0x07; // master, memory and I/O |
283 | 502a5395 | pbrook | pci_conf[0x05] = 0x00; |
284 | 502a5395 | pbrook | pci_conf[0x06] = 0x00; |
285 | 502a5395 | pbrook | pci_conf[0x07] = 0x02; // PCI_status_devsel_medium |
286 | 502a5395 | pbrook | pci_conf[0x4c] = 0x4d; |
287 | 502a5395 | pbrook | pci_conf[0x4e] = 0x03; |
288 | 502a5395 | pbrook | pci_conf[0x4f] = 0x00; |
289 | 502a5395 | pbrook | pci_conf[0x60] = 0x80; |
290 | 477afee3 | aurel32 | pci_conf[0x61] = 0x80; |
291 | 477afee3 | aurel32 | pci_conf[0x62] = 0x80; |
292 | 477afee3 | aurel32 | pci_conf[0x63] = 0x80; |
293 | 502a5395 | pbrook | pci_conf[0x69] = 0x02; |
294 | 502a5395 | pbrook | pci_conf[0x70] = 0x80; |
295 | 502a5395 | pbrook | pci_conf[0x76] = 0x0c; |
296 | 502a5395 | pbrook | pci_conf[0x77] = 0x0c; |
297 | 502a5395 | pbrook | pci_conf[0x78] = 0x02; |
298 | 502a5395 | pbrook | pci_conf[0x79] = 0x00; |
299 | 502a5395 | pbrook | pci_conf[0x80] = 0x00; |
300 | 502a5395 | pbrook | pci_conf[0x82] = 0x00; |
301 | 502a5395 | pbrook | pci_conf[0xa0] = 0x08; |
302 | 502a5395 | pbrook | pci_conf[0xa2] = 0x00; |
303 | 502a5395 | pbrook | pci_conf[0xa3] = 0x00; |
304 | 502a5395 | pbrook | pci_conf[0xa4] = 0x00; |
305 | 502a5395 | pbrook | pci_conf[0xa5] = 0x00; |
306 | 502a5395 | pbrook | pci_conf[0xa6] = 0x00; |
307 | 502a5395 | pbrook | pci_conf[0xa7] = 0x00; |
308 | 502a5395 | pbrook | pci_conf[0xa8] = 0x0f; |
309 | 502a5395 | pbrook | pci_conf[0xaa] = 0x00; |
310 | 502a5395 | pbrook | pci_conf[0xab] = 0x00; |
311 | 502a5395 | pbrook | pci_conf[0xac] = 0x00; |
312 | 502a5395 | pbrook | pci_conf[0xae] = 0x00; |
313 | 15a1956a | Gleb Natapov | |
314 | 8372615d | Juan Quintela | memset(d->pci_irq_levels, 0, sizeof(d->pci_irq_levels)); |
315 | 502a5395 | pbrook | } |
316 | 502a5395 | pbrook | |
317 | d1f171bd | Juan Quintela | static const VMStateDescription vmstate_piix3 = { |
318 | d1f171bd | Juan Quintela | .name = "PIIX3",
|
319 | d1f171bd | Juan Quintela | .version_id = 3,
|
320 | d1f171bd | Juan Quintela | .minimum_version_id = 2,
|
321 | d1f171bd | Juan Quintela | .minimum_version_id_old = 2,
|
322 | d1f171bd | Juan Quintela | .fields = (VMStateField []) { |
323 | d1f171bd | Juan Quintela | VMSTATE_PCI_DEVICE(dev, PIIX3State), |
324 | d1f171bd | Juan Quintela | VMSTATE_INT32_ARRAY_V(pci_irq_levels, PIIX3State, 4, 3), |
325 | d1f171bd | Juan Quintela | VMSTATE_END_OF_LIST() |
326 | da64182c | Juan Quintela | } |
327 | d1f171bd | Juan Quintela | }; |
328 | 1941d19c | bellard | |
329 | fd37d881 | Juan Quintela | static int piix3_initfn(PCIDevice *dev) |
330 | 502a5395 | pbrook | { |
331 | fd37d881 | Juan Quintela | PIIX3State *d = DO_UPCAST(PIIX3State, dev, dev); |
332 | 502a5395 | pbrook | uint8_t *pci_conf; |
333 | 502a5395 | pbrook | |
334 | fd37d881 | Juan Quintela | isa_bus_new(&d->dev.qdev); |
335 | d1f171bd | Juan Quintela | vmstate_register(0, &vmstate_piix3, d);
|
336 | 502a5395 | pbrook | |
337 | fd37d881 | Juan Quintela | pci_conf = d->dev.config; |
338 | deb54399 | aliguori | pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); |
339 | deb54399 | aliguori | pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371SB_0); // 82371SB PIIX3 PCI-to-ISA bridge (Step A1)
|
340 | 173a543b | blueswir1 | pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); |
341 | 6407f373 | Isaku Yamahata | pci_conf[PCI_HEADER_TYPE] = |
342 | 6407f373 | Isaku Yamahata | PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
|
343 | 502a5395 | pbrook | |
344 | 502a5395 | pbrook | piix3_reset(d); |
345 | a08d4367 | Jan Kiszka | qemu_register_reset(piix3_reset, d); |
346 | 81a322d4 | Gerd Hoffmann | return 0; |
347 | 502a5395 | pbrook | } |
348 | 5c2b87e3 | ths | |
349 | 8a14daa5 | Gerd Hoffmann | static PCIDeviceInfo i440fx_info[] = {
|
350 | 8a14daa5 | Gerd Hoffmann | { |
351 | 8a14daa5 | Gerd Hoffmann | .qdev.name = "i440FX",
|
352 | 8a14daa5 | Gerd Hoffmann | .qdev.desc = "Host bridge",
|
353 | 0a3bacf3 | Juan Quintela | .qdev.size = sizeof(PCII440FXState),
|
354 | 8a14daa5 | Gerd Hoffmann | .qdev.no_user = 1,
|
355 | 8a14daa5 | Gerd Hoffmann | .init = i440fx_initfn, |
356 | 8a14daa5 | Gerd Hoffmann | .config_write = i440fx_write_config, |
357 | 8a14daa5 | Gerd Hoffmann | },{ |
358 | 8a14daa5 | Gerd Hoffmann | .qdev.name = "PIIX3",
|
359 | 8a14daa5 | Gerd Hoffmann | .qdev.desc = "ISA bridge",
|
360 | fd37d881 | Juan Quintela | .qdev.size = sizeof(PIIX3State),
|
361 | 8a14daa5 | Gerd Hoffmann | .qdev.no_user = 1,
|
362 | 8a14daa5 | Gerd Hoffmann | .init = piix3_initfn, |
363 | 8a14daa5 | Gerd Hoffmann | },{ |
364 | 8a14daa5 | Gerd Hoffmann | /* end of list */
|
365 | 8a14daa5 | Gerd Hoffmann | } |
366 | 8a14daa5 | Gerd Hoffmann | }; |
367 | 8a14daa5 | Gerd Hoffmann | |
368 | 8a14daa5 | Gerd Hoffmann | static SysBusDeviceInfo i440fx_pcihost_info = {
|
369 | 8a14daa5 | Gerd Hoffmann | .init = i440fx_pcihost_initfn, |
370 | 8a14daa5 | Gerd Hoffmann | .qdev.name = "i440FX-pcihost",
|
371 | 8a14daa5 | Gerd Hoffmann | .qdev.size = sizeof(I440FXState),
|
372 | 8a14daa5 | Gerd Hoffmann | .qdev.no_user = 1,
|
373 | 8a14daa5 | Gerd Hoffmann | }; |
374 | 8a14daa5 | Gerd Hoffmann | |
375 | 8a14daa5 | Gerd Hoffmann | static void i440fx_register(void) |
376 | 8a14daa5 | Gerd Hoffmann | { |
377 | 8a14daa5 | Gerd Hoffmann | sysbus_register_withprop(&i440fx_pcihost_info); |
378 | 8a14daa5 | Gerd Hoffmann | pci_qdev_register_many(i440fx_info); |
379 | 8a14daa5 | Gerd Hoffmann | } |
380 | 8a14daa5 | Gerd Hoffmann | device_init(i440fx_register); |