Statistics
| Branch: | Revision:

root / hw / piix_pci.c @ 3c619b59

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