Statistics
| Branch: | Revision:

root / hw / unin_pci.c @ 0f921197

History | View | Annotate | Download (11.6 kB)

1 502a5395 pbrook
/*
2 502a5395 pbrook
 * QEMU Uninorth PCI host (for all Mac99 and newer machines)
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 87ecb68b pbrook
#include "hw.h"
25 87ecb68b pbrook
#include "ppc_mac.h"
26 87ecb68b pbrook
#include "pci.h"
27 4f5e19e6 Isaku Yamahata
#include "pci_host.h"
28 87ecb68b pbrook
29 f3902383 blueswir1
/* debug UniNorth */
30 f3902383 blueswir1
//#define DEBUG_UNIN
31 f3902383 blueswir1
32 f3902383 blueswir1
#ifdef DEBUG_UNIN
33 001faf32 Blue Swirl
#define UNIN_DPRINTF(fmt, ...)                                  \
34 001faf32 Blue Swirl
    do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0)
35 f3902383 blueswir1
#else
36 001faf32 Blue Swirl
#define UNIN_DPRINTF(fmt, ...)
37 f3902383 blueswir1
#endif
38 f3902383 blueswir1
39 2e29bd04 Blue Swirl
typedef struct UNINState {
40 2e29bd04 Blue Swirl
    SysBusDevice busdev;
41 2e29bd04 Blue Swirl
    PCIHostState host_state;
42 d86f0e32 Alexander Graf
    ReadWriteHandler data_handler;
43 2e29bd04 Blue Swirl
} UNINState;
44 502a5395 pbrook
45 d2b59317 pbrook
/* Don't know if this matches real hardware, but it agrees with OHW.  */
46 d2b59317 pbrook
static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
47 502a5395 pbrook
{
48 d2b59317 pbrook
    return (irq_num + (pci_dev->devfn >> 3)) & 3;
49 d2b59317 pbrook
}
50 d2b59317 pbrook
51 5d4e84c8 Juan Quintela
static void pci_unin_set_irq(void *opaque, int irq_num, int level)
52 d2b59317 pbrook
{
53 5d4e84c8 Juan Quintela
    qemu_irq *pic = opaque;
54 5d4e84c8 Juan Quintela
55 d537cf6c pbrook
    qemu_set_irq(pic[irq_num + 8], level);
56 502a5395 pbrook
}
57 502a5395 pbrook
58 f3902383 blueswir1
static void pci_unin_save(QEMUFile* f, void *opaque)
59 f3902383 blueswir1
{
60 f3902383 blueswir1
    PCIDevice *d = opaque;
61 f3902383 blueswir1
62 f3902383 blueswir1
    pci_device_save(d, f);
63 f3902383 blueswir1
}
64 f3902383 blueswir1
65 f3902383 blueswir1
static int pci_unin_load(QEMUFile* f, void *opaque, int version_id)
66 f3902383 blueswir1
{
67 f3902383 blueswir1
    PCIDevice *d = opaque;
68 f3902383 blueswir1
69 f3902383 blueswir1
    if (version_id != 1)
70 f3902383 blueswir1
        return -EINVAL;
71 f3902383 blueswir1
72 f3902383 blueswir1
    return pci_device_load(d, f);
73 f3902383 blueswir1
}
74 f3902383 blueswir1
75 f3902383 blueswir1
static void pci_unin_reset(void *opaque)
76 f3902383 blueswir1
{
77 f3902383 blueswir1
}
78 f3902383 blueswir1
79 d86f0e32 Alexander Graf
static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
80 d86f0e32 Alexander Graf
{
81 d86f0e32 Alexander Graf
    uint32_t retval;
82 d86f0e32 Alexander Graf
83 d86f0e32 Alexander Graf
    if (reg & (1u << 31)) {
84 d86f0e32 Alexander Graf
        /* XXX OpenBIOS compatibility hack */
85 d86f0e32 Alexander Graf
        retval = reg | (addr & 3);
86 d86f0e32 Alexander Graf
    } else if (reg & 1) {
87 d86f0e32 Alexander Graf
        /* CFA1 style */
88 d86f0e32 Alexander Graf
        retval = (reg & ~7u) | (addr & 7);
89 d86f0e32 Alexander Graf
    } else {
90 d86f0e32 Alexander Graf
        uint32_t slot, func;
91 d86f0e32 Alexander Graf
92 d86f0e32 Alexander Graf
        /* Grab CFA0 style values */
93 d86f0e32 Alexander Graf
        slot = ffs(reg & 0xfffff800) - 1;
94 d86f0e32 Alexander Graf
        func = (reg >> 8) & 7;
95 d86f0e32 Alexander Graf
96 d86f0e32 Alexander Graf
        /* ... and then convert them to x86 format */
97 d86f0e32 Alexander Graf
        /* config pointer */
98 d86f0e32 Alexander Graf
        retval = (reg & (0xff - 7)) | (addr & 7);
99 d86f0e32 Alexander Graf
        /* slot */
100 d86f0e32 Alexander Graf
        retval |= slot << 11;
101 d86f0e32 Alexander Graf
        /* fn */
102 d86f0e32 Alexander Graf
        retval |= func << 8;
103 d86f0e32 Alexander Graf
    }
104 d86f0e32 Alexander Graf
105 d86f0e32 Alexander Graf
106 d86f0e32 Alexander Graf
    UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
107 d86f0e32 Alexander Graf
                 reg, addr, retval);
108 d86f0e32 Alexander Graf
109 d86f0e32 Alexander Graf
    return retval;
110 d86f0e32 Alexander Graf
}
111 d86f0e32 Alexander Graf
112 d86f0e32 Alexander Graf
static void unin_data_write(ReadWriteHandler *handler,
113 d86f0e32 Alexander Graf
                            pcibus_t addr, uint32_t val, int len)
114 d86f0e32 Alexander Graf
{
115 d86f0e32 Alexander Graf
    UNINState *s = container_of(handler, UNINState, data_handler);
116 d86f0e32 Alexander Graf
#ifdef TARGET_WORDS_BIGENDIAN
117 d86f0e32 Alexander Graf
    val = qemu_bswap_len(val, len);
118 d86f0e32 Alexander Graf
#endif
119 d86f0e32 Alexander Graf
    UNIN_DPRINTF("write addr %" FMT_PCIBUS " len %d val %x\n", addr, len, val);
120 d86f0e32 Alexander Graf
    pci_data_write(s->host_state.bus,
121 d86f0e32 Alexander Graf
                   unin_get_config_reg(s->host_state.config_reg, addr),
122 d86f0e32 Alexander Graf
                   val, len);
123 d86f0e32 Alexander Graf
}
124 d86f0e32 Alexander Graf
125 d86f0e32 Alexander Graf
static uint32_t unin_data_read(ReadWriteHandler *handler,
126 d86f0e32 Alexander Graf
                               pcibus_t addr, int len)
127 d86f0e32 Alexander Graf
{
128 d86f0e32 Alexander Graf
    UNINState *s = container_of(handler, UNINState, data_handler);
129 d86f0e32 Alexander Graf
    uint32_t val;
130 d86f0e32 Alexander Graf
131 d86f0e32 Alexander Graf
    val = pci_data_read(s->host_state.bus,
132 d86f0e32 Alexander Graf
                        unin_get_config_reg(s->host_state.config_reg, addr),
133 d86f0e32 Alexander Graf
                        len);
134 d86f0e32 Alexander Graf
    UNIN_DPRINTF("read addr %" FMT_PCIBUS " len %d val %x\n", addr, len, val);
135 d86f0e32 Alexander Graf
#ifdef TARGET_WORDS_BIGENDIAN
136 d86f0e32 Alexander Graf
    val = qemu_bswap_len(val, len);
137 d86f0e32 Alexander Graf
#endif
138 d86f0e32 Alexander Graf
    return val;
139 d86f0e32 Alexander Graf
}
140 d86f0e32 Alexander Graf
141 81a322d4 Gerd Hoffmann
static int pci_unin_main_init_device(SysBusDevice *dev)
142 502a5395 pbrook
{
143 502a5395 pbrook
    UNINState *s;
144 502a5395 pbrook
    int pci_mem_config, pci_mem_data;
145 502a5395 pbrook
146 502a5395 pbrook
    /* Use values found on a real PowerMac */
147 502a5395 pbrook
    /* Uninorth main bus */
148 2e29bd04 Blue Swirl
    s = FROM_SYSBUS(UNINState, dev);
149 502a5395 pbrook
150 f08b32fe Isaku Yamahata
    pci_mem_config = pci_host_conf_register_mmio(&s->host_state);
151 d86f0e32 Alexander Graf
    s->data_handler.read = unin_data_read;
152 d86f0e32 Alexander Graf
    s->data_handler.write = unin_data_write;
153 d86f0e32 Alexander Graf
    pci_mem_data = cpu_register_io_memory_simple(&s->data_handler);
154 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_config);
155 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_data);
156 2e29bd04 Blue Swirl
157 2e29bd04 Blue Swirl
    register_savevm("uninorth", 0, 1, pci_unin_save, pci_unin_load, &s->host_state);
158 2e29bd04 Blue Swirl
    qemu_register_reset(pci_unin_reset, &s->host_state);
159 81a322d4 Gerd Hoffmann
    return 0;
160 2e29bd04 Blue Swirl
}
161 2e29bd04 Blue Swirl
162 0f921197 Alexander Graf
static int pci_u3_agp_init_device(SysBusDevice *dev)
163 0f921197 Alexander Graf
{
164 0f921197 Alexander Graf
    UNINState *s;
165 0f921197 Alexander Graf
    int pci_mem_config, pci_mem_data;
166 0f921197 Alexander Graf
167 0f921197 Alexander Graf
    /* Uninorth U3 AGP bus */
168 0f921197 Alexander Graf
    s = FROM_SYSBUS(UNINState, dev);
169 0f921197 Alexander Graf
170 0f921197 Alexander Graf
    pci_mem_config = pci_host_conf_register_mmio(&s->host_state);
171 0f921197 Alexander Graf
    s->data_handler.read = unin_data_read;
172 0f921197 Alexander Graf
    s->data_handler.write = unin_data_write;
173 0f921197 Alexander Graf
    pci_mem_data = cpu_register_io_memory_simple(&s->data_handler);
174 0f921197 Alexander Graf
    sysbus_init_mmio(dev, 0x1000, pci_mem_config);
175 0f921197 Alexander Graf
    sysbus_init_mmio(dev, 0x1000, pci_mem_data);
176 0f921197 Alexander Graf
177 0f921197 Alexander Graf
    register_savevm("uninorth", 0, 1, pci_unin_save, pci_unin_load, &s->host_state);
178 0f921197 Alexander Graf
    qemu_register_reset(pci_unin_reset, &s->host_state);
179 0f921197 Alexander Graf
180 0f921197 Alexander Graf
    return 0;
181 0f921197 Alexander Graf
}
182 0f921197 Alexander Graf
183 81a322d4 Gerd Hoffmann
static int pci_unin_agp_init_device(SysBusDevice *dev)
184 2e29bd04 Blue Swirl
{
185 2e29bd04 Blue Swirl
    UNINState *s;
186 2e29bd04 Blue Swirl
    int pci_mem_config, pci_mem_data;
187 2e29bd04 Blue Swirl
188 2e29bd04 Blue Swirl
    /* Uninorth AGP bus */
189 2e29bd04 Blue Swirl
    s = FROM_SYSBUS(UNINState, dev);
190 2e29bd04 Blue Swirl
191 f08b32fe Isaku Yamahata
    pci_mem_config = pci_host_conf_register_mmio_noswap(&s->host_state);
192 f08b32fe Isaku Yamahata
    pci_mem_data = pci_host_data_register_mmio(&s->host_state);
193 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_config);
194 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_data);
195 81a322d4 Gerd Hoffmann
    return 0;
196 2e29bd04 Blue Swirl
}
197 2e29bd04 Blue Swirl
198 81a322d4 Gerd Hoffmann
static int pci_unin_internal_init_device(SysBusDevice *dev)
199 2e29bd04 Blue Swirl
{
200 2e29bd04 Blue Swirl
    UNINState *s;
201 2e29bd04 Blue Swirl
    int pci_mem_config, pci_mem_data;
202 2e29bd04 Blue Swirl
203 2e29bd04 Blue Swirl
    /* Uninorth internal bus */
204 2e29bd04 Blue Swirl
    s = FROM_SYSBUS(UNINState, dev);
205 2e29bd04 Blue Swirl
206 f08b32fe Isaku Yamahata
    pci_mem_config = pci_host_conf_register_mmio_noswap(&s->host_state);
207 f08b32fe Isaku Yamahata
    pci_mem_data = pci_host_data_register_mmio(&s->host_state);
208 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_config);
209 2e29bd04 Blue Swirl
    sysbus_init_mmio(dev, 0x1000, pci_mem_data);
210 81a322d4 Gerd Hoffmann
    return 0;
211 2e29bd04 Blue Swirl
}
212 2e29bd04 Blue Swirl
213 2e29bd04 Blue Swirl
PCIBus *pci_pmac_init(qemu_irq *pic)
214 2e29bd04 Blue Swirl
{
215 2e29bd04 Blue Swirl
    DeviceState *dev;
216 2e29bd04 Blue Swirl
    SysBusDevice *s;
217 2e29bd04 Blue Swirl
    UNINState *d;
218 2e29bd04 Blue Swirl
219 2e29bd04 Blue Swirl
    /* Use values found on a real PowerMac */
220 2e29bd04 Blue Swirl
    /* Uninorth main bus */
221 18dd19a7 Markus Armbruster
    dev = qdev_create(NULL, "uni-north");
222 e23a1b33 Markus Armbruster
    qdev_init_nofail(dev);
223 2e29bd04 Blue Swirl
    s = sysbus_from_qdev(dev);
224 2e29bd04 Blue Swirl
    d = FROM_SYSBUS(UNINState, s);
225 cdd0935c Blue Swirl
    d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
226 2e29bd04 Blue Swirl
                                         pci_unin_set_irq, pci_unin_map_irq,
227 2e29bd04 Blue Swirl
                                         pic, 11 << 3, 4);
228 2e29bd04 Blue Swirl
229 60398748 Blue Swirl
#if 0
230 18dd19a7 Markus Armbruster
    pci_create_simple(d->host_state.bus, 11 << 3, "uni-north");
231 60398748 Blue Swirl
#endif
232 2e29bd04 Blue Swirl
233 2e29bd04 Blue Swirl
    sysbus_mmio_map(s, 0, 0xf2800000);
234 2e29bd04 Blue Swirl
    sysbus_mmio_map(s, 1, 0xf2c00000);
235 2e29bd04 Blue Swirl
236 2e29bd04 Blue Swirl
    /* DEC 21154 bridge */
237 2e29bd04 Blue Swirl
#if 0
238 2e29bd04 Blue Swirl
    /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
239 556cd098 Markus Armbruster
    pci_create_simple(d->host_state.bus, 12 << 3, "dec-21154");
240 2e29bd04 Blue Swirl
#endif
241 2e29bd04 Blue Swirl
242 2e29bd04 Blue Swirl
    /* Uninorth AGP bus */
243 18dd19a7 Markus Armbruster
    pci_create_simple(d->host_state.bus, 11 << 3, "uni-north-agp");
244 18dd19a7 Markus Armbruster
    dev = qdev_create(NULL, "uni-north-agp");
245 d27d06f2 Blue Swirl
    qdev_init_nofail(dev);
246 d27d06f2 Blue Swirl
    s = sysbus_from_qdev(dev);
247 d27d06f2 Blue Swirl
    sysbus_mmio_map(s, 0, 0xf0800000);
248 d27d06f2 Blue Swirl
    sysbus_mmio_map(s, 1, 0xf0c00000);
249 2e29bd04 Blue Swirl
250 2e29bd04 Blue Swirl
    /* Uninorth internal bus */
251 2e29bd04 Blue Swirl
#if 0
252 2e29bd04 Blue Swirl
    /* XXX: not needed for now */
253 18dd19a7 Markus Armbruster
    pci_create_simple(d->host_state.bus, 14 << 3, "uni-north-pci");
254 18dd19a7 Markus Armbruster
    dev = qdev_create(NULL, "uni-north-pci");
255 d27d06f2 Blue Swirl
    qdev_init_nofail(dev);
256 d27d06f2 Blue Swirl
    s = sysbus_from_qdev(dev);
257 d27d06f2 Blue Swirl
    sysbus_mmio_map(s, 0, 0xf4800000);
258 d27d06f2 Blue Swirl
    sysbus_mmio_map(s, 1, 0xf4c00000);
259 2e29bd04 Blue Swirl
#endif
260 2e29bd04 Blue Swirl
261 2e29bd04 Blue Swirl
    return d->host_state.bus;
262 2e29bd04 Blue Swirl
}
263 2e29bd04 Blue Swirl
264 0f921197 Alexander Graf
PCIBus *pci_pmac_u3_init(qemu_irq *pic)
265 0f921197 Alexander Graf
{
266 0f921197 Alexander Graf
    DeviceState *dev;
267 0f921197 Alexander Graf
    SysBusDevice *s;
268 0f921197 Alexander Graf
    UNINState *d;
269 0f921197 Alexander Graf
270 0f921197 Alexander Graf
    /* Uninorth AGP bus */
271 0f921197 Alexander Graf
272 0f921197 Alexander Graf
    dev = qdev_create(NULL, "u3-agp");
273 0f921197 Alexander Graf
    qdev_init_nofail(dev);
274 0f921197 Alexander Graf
    s = sysbus_from_qdev(dev);
275 0f921197 Alexander Graf
    d = FROM_SYSBUS(UNINState, s);
276 0f921197 Alexander Graf
277 0f921197 Alexander Graf
    d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
278 0f921197 Alexander Graf
                                         pci_unin_set_irq, pci_unin_map_irq,
279 0f921197 Alexander Graf
                                         pic, 11 << 3, 4);
280 0f921197 Alexander Graf
281 0f921197 Alexander Graf
    sysbus_mmio_map(s, 0, 0xf0800000);
282 0f921197 Alexander Graf
    sysbus_mmio_map(s, 1, 0xf0c00000);
283 0f921197 Alexander Graf
284 0f921197 Alexander Graf
    pci_create_simple(d->host_state.bus, 11 << 3, "u3-agp");
285 0f921197 Alexander Graf
286 0f921197 Alexander Graf
    return d->host_state.bus;
287 0f921197 Alexander Graf
}
288 0f921197 Alexander Graf
289 81a322d4 Gerd Hoffmann
static int unin_main_pci_host_init(PCIDevice *d)
290 2e29bd04 Blue Swirl
{
291 deb54399 aliguori
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
292 4ebcf884 blueswir1
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI);
293 502a5395 pbrook
    d->config[0x08] = 0x00; // revision
294 173a543b blueswir1
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
295 502a5395 pbrook
    d->config[0x0C] = 0x08; // cache_line_size
296 502a5395 pbrook
    d->config[0x0D] = 0x10; // latency_timer
297 6407f373 Isaku Yamahata
    d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
298 502a5395 pbrook
    d->config[0x34] = 0x00; // capabilities_pointer
299 81a322d4 Gerd Hoffmann
    return 0;
300 2e29bd04 Blue Swirl
}
301 502a5395 pbrook
302 81a322d4 Gerd Hoffmann
static int unin_agp_pci_host_init(PCIDevice *d)
303 2e29bd04 Blue Swirl
{
304 deb54399 aliguori
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
305 deb54399 aliguori
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_AGP);
306 502a5395 pbrook
    d->config[0x08] = 0x00; // revision
307 173a543b blueswir1
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
308 502a5395 pbrook
    d->config[0x0C] = 0x08; // cache_line_size
309 502a5395 pbrook
    d->config[0x0D] = 0x10; // latency_timer
310 6407f373 Isaku Yamahata
    d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
311 502a5395 pbrook
    //    d->config[0x34] = 0x80; // capabilities_pointer
312 81a322d4 Gerd Hoffmann
    return 0;
313 2e29bd04 Blue Swirl
}
314 502a5395 pbrook
315 0f921197 Alexander Graf
static int u3_agp_pci_host_init(PCIDevice *d)
316 0f921197 Alexander Graf
{
317 0f921197 Alexander Graf
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
318 0f921197 Alexander Graf
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_U3_AGP);
319 0f921197 Alexander Graf
    /* revision */
320 0f921197 Alexander Graf
    d->config[0x08] = 0x00;
321 0f921197 Alexander Graf
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
322 0f921197 Alexander Graf
    /* cache line size */
323 0f921197 Alexander Graf
    d->config[0x0C] = 0x08;
324 0f921197 Alexander Graf
    /* latency timer */
325 0f921197 Alexander Graf
    d->config[0x0D] = 0x10;
326 0f921197 Alexander Graf
    d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;
327 0f921197 Alexander Graf
    return 0;
328 0f921197 Alexander Graf
}
329 0f921197 Alexander Graf
330 81a322d4 Gerd Hoffmann
static int unin_internal_pci_host_init(PCIDevice *d)
331 2e29bd04 Blue Swirl
{
332 deb54399 aliguori
    pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE);
333 4ebcf884 blueswir1
    pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI);
334 502a5395 pbrook
    d->config[0x08] = 0x00; // revision
335 173a543b blueswir1
    pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);
336 502a5395 pbrook
    d->config[0x0C] = 0x08; // cache_line_size
337 502a5395 pbrook
    d->config[0x0D] = 0x10; // latency_timer
338 6407f373 Isaku Yamahata
    d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
339 502a5395 pbrook
    d->config[0x34] = 0x00; // capabilities_pointer
340 81a322d4 Gerd Hoffmann
    return 0;
341 2e29bd04 Blue Swirl
}
342 2e29bd04 Blue Swirl
343 2e29bd04 Blue Swirl
static PCIDeviceInfo unin_main_pci_host_info = {
344 18dd19a7 Markus Armbruster
    .qdev.name = "uni-north",
345 2e29bd04 Blue Swirl
    .qdev.size = sizeof(PCIDevice),
346 2e29bd04 Blue Swirl
    .init      = unin_main_pci_host_init,
347 2e29bd04 Blue Swirl
};
348 2e29bd04 Blue Swirl
349 0f921197 Alexander Graf
static PCIDeviceInfo u3_agp_pci_host_info = {
350 0f921197 Alexander Graf
    .qdev.name = "u3-agp",
351 0f921197 Alexander Graf
    .qdev.size = sizeof(PCIDevice),
352 0f921197 Alexander Graf
    .init      = u3_agp_pci_host_init,
353 0f921197 Alexander Graf
};
354 0f921197 Alexander Graf
355 2e29bd04 Blue Swirl
static PCIDeviceInfo unin_agp_pci_host_info = {
356 18dd19a7 Markus Armbruster
    .qdev.name = "uni-north-agp",
357 2e29bd04 Blue Swirl
    .qdev.size = sizeof(PCIDevice),
358 2e29bd04 Blue Swirl
    .init      = unin_agp_pci_host_init,
359 2e29bd04 Blue Swirl
};
360 2e29bd04 Blue Swirl
361 2e29bd04 Blue Swirl
static PCIDeviceInfo unin_internal_pci_host_info = {
362 18dd19a7 Markus Armbruster
    .qdev.name = "uni-north-pci",
363 2e29bd04 Blue Swirl
    .qdev.size = sizeof(PCIDevice),
364 2e29bd04 Blue Swirl
    .init      = unin_internal_pci_host_init,
365 2e29bd04 Blue Swirl
};
366 2e29bd04 Blue Swirl
367 2e29bd04 Blue Swirl
static void unin_register_devices(void)
368 2e29bd04 Blue Swirl
{
369 18dd19a7 Markus Armbruster
    sysbus_register_dev("uni-north", sizeof(UNINState),
370 2e29bd04 Blue Swirl
                        pci_unin_main_init_device);
371 2e29bd04 Blue Swirl
    pci_qdev_register(&unin_main_pci_host_info);
372 0f921197 Alexander Graf
    sysbus_register_dev("u3-agp", sizeof(UNINState),
373 0f921197 Alexander Graf
                        pci_u3_agp_init_device);
374 0f921197 Alexander Graf
    pci_qdev_register(&u3_agp_pci_host_info);
375 18dd19a7 Markus Armbruster
    sysbus_register_dev("uni-north-agp", sizeof(UNINState),
376 2e29bd04 Blue Swirl
                        pci_unin_agp_init_device);
377 2e29bd04 Blue Swirl
    pci_qdev_register(&unin_agp_pci_host_info);
378 18dd19a7 Markus Armbruster
    sysbus_register_dev("uni-north-pci", sizeof(UNINState),
379 2e29bd04 Blue Swirl
                        pci_unin_internal_init_device);
380 2e29bd04 Blue Swirl
    pci_qdev_register(&unin_internal_pci_host_info);
381 502a5395 pbrook
}
382 2e29bd04 Blue Swirl
383 2e29bd04 Blue Swirl
device_init(unin_register_devices)