blob: d1cc68062b735aa7c8de9b81f4f92983fd2bf431 [file] [log] [blame]
pbrook502a5392006-05-13 16:11:23 +00001/*
2 * QEMU Uninorth PCI host (for all Mac99 and newer machines)
3 *
4 * Copyright (c) 2006 Fabrice Bellard
ths5fafdf22007-09-16 21:08:06 +00005 *
pbrook502a5392006-05-13 16:11:23 +00006 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
pbrook87ecb682007-11-17 17:14:51 +000024#include "hw.h"
25#include "ppc_mac.h"
26#include "pci.h"
Isaku Yamahata4f5e19e2009-10-30 21:21:06 +090027#include "pci_host.h"
pbrook87ecb682007-11-17 17:14:51 +000028
blueswir1f3902382009-02-05 20:22:07 +000029/* debug UniNorth */
30//#define DEBUG_UNIN
31
32#ifdef DEBUG_UNIN
Blue Swirl001faf32009-05-13 17:53:17 +000033#define UNIN_DPRINTF(fmt, ...) \
34 do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0)
blueswir1f3902382009-02-05 20:22:07 +000035#else
Blue Swirl001faf32009-05-13 17:53:17 +000036#define UNIN_DPRINTF(fmt, ...)
blueswir1f3902382009-02-05 20:22:07 +000037#endif
38
Alexander Graffa0be692010-02-09 17:37:04 +010039static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
40
Andreas Färber57fd7b72012-08-20 19:08:06 +020041#define TYPE_UNI_NORTH_PCI_HOST_BRIDGE "uni-north-pci-pcihost"
42#define TYPE_UNI_NORTH_AGP_HOST_BRIDGE "uni-north-agp-pcihost"
43#define TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE "uni-north-internal-pci-pcihost"
44#define TYPE_U3_AGP_HOST_BRIDGE "u3-agp-pcihost"
45
46#define UNI_NORTH_PCI_HOST_BRIDGE(obj) \
47 OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_PCI_HOST_BRIDGE)
48#define UNI_NORTH_AGP_HOST_BRIDGE(obj) \
49 OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_AGP_HOST_BRIDGE)
50#define UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj) \
51 OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE)
52#define U3_AGP_HOST_BRIDGE(obj) \
53 OBJECT_CHECK(UNINState, (obj), TYPE_U3_AGP_HOST_BRIDGE)
54
Blue Swirl2e29bd02009-07-31 20:23:28 +000055typedef struct UNINState {
Andreas Färber67c332f2012-08-20 19:08:09 +020056 PCIHostState parent_obj;
Andreas Färber57fd7b72012-08-20 19:08:06 +020057
Blue Swirl46f30692011-09-17 20:30:50 +000058 MemoryRegion pci_mmio;
59 MemoryRegion pci_hole;
Blue Swirl2e29bd02009-07-31 20:23:28 +000060} UNINState;
pbrook502a5392006-05-13 16:11:23 +000061
pbrookd2b59312006-09-24 00:16:34 +000062static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
pbrook502a5392006-05-13 16:11:23 +000063{
Alexander Graffa0be692010-02-09 17:37:04 +010064 int retval;
65 int devfn = pci_dev->devfn & 0x00FFFFFF;
66
67 retval = (((devfn >> 11) & 0x1F) + irq_num) & 3;
68
69 return retval;
pbrookd2b59312006-09-24 00:16:34 +000070}
71
Juan Quintela5d4e84c2009-08-28 15:28:17 +020072static void pci_unin_set_irq(void *opaque, int irq_num, int level)
pbrookd2b59312006-09-24 00:16:34 +000073{
Juan Quintela5d4e84c2009-08-28 15:28:17 +020074 qemu_irq *pic = opaque;
75
Alexander Graffa0be692010-02-09 17:37:04 +010076 UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
77 unin_irq_line[irq_num], level);
78 qemu_set_irq(pic[unin_irq_line[irq_num]], level);
pbrook502a5392006-05-13 16:11:23 +000079}
80
Alexander Grafd86f0e32010-02-09 17:37:01 +010081static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
82{
83 uint32_t retval;
84
85 if (reg & (1u << 31)) {
86 /* XXX OpenBIOS compatibility hack */
87 retval = reg | (addr & 3);
88 } else if (reg & 1) {
89 /* CFA1 style */
90 retval = (reg & ~7u) | (addr & 7);
91 } else {
92 uint32_t slot, func;
93
94 /* Grab CFA0 style values */
95 slot = ffs(reg & 0xfffff800) - 1;
96 func = (reg >> 8) & 7;
97
98 /* ... and then convert them to x86 format */
99 /* config pointer */
100 retval = (reg & (0xff - 7)) | (addr & 7);
101 /* slot */
102 retval |= slot << 11;
103 /* fn */
104 retval |= func << 8;
105 }
106
107
108 UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
109 reg, addr, retval);
110
111 return retval;
112}
113
Avi Kivityd0ed8072011-07-24 17:47:18 +0300114static void unin_data_write(void *opaque, target_phys_addr_t addr,
115 uint64_t val, unsigned len)
Alexander Grafd86f0e32010-02-09 17:37:01 +0100116{
Avi Kivityd0ed8072011-07-24 17:47:18 +0300117 UNINState *s = opaque;
Andreas Färber67c332f2012-08-20 19:08:09 +0200118 PCIHostState *phb = PCI_HOST_BRIDGE(s);
Avi Kivityd0ed8072011-07-24 17:47:18 +0300119 UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n",
120 addr, len, val);
Andreas Färber67c332f2012-08-20 19:08:09 +0200121 pci_data_write(phb->bus,
122 unin_get_config_reg(phb->config_reg, addr),
Alexander Grafd86f0e32010-02-09 17:37:01 +0100123 val, len);
124}
125
Avi Kivityd0ed8072011-07-24 17:47:18 +0300126static uint64_t unin_data_read(void *opaque, target_phys_addr_t addr,
127 unsigned len)
Alexander Grafd86f0e32010-02-09 17:37:01 +0100128{
Avi Kivityd0ed8072011-07-24 17:47:18 +0300129 UNINState *s = opaque;
Andreas Färber67c332f2012-08-20 19:08:09 +0200130 PCIHostState *phb = PCI_HOST_BRIDGE(s);
Alexander Grafd86f0e32010-02-09 17:37:01 +0100131 uint32_t val;
132
Andreas Färber67c332f2012-08-20 19:08:09 +0200133 val = pci_data_read(phb->bus,
134 unin_get_config_reg(phb->config_reg, addr),
Alexander Grafd86f0e32010-02-09 17:37:01 +0100135 len);
Avi Kivityd0ed8072011-07-24 17:47:18 +0300136 UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n",
137 addr, len, val);
Alexander Grafd86f0e32010-02-09 17:37:01 +0100138 return val;
139}
140
Avi Kivityd0ed8072011-07-24 17:47:18 +0300141static const MemoryRegionOps unin_data_ops = {
142 .read = unin_data_read,
143 .write = unin_data_write,
144 .endianness = DEVICE_LITTLE_ENDIAN,
145};
146
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200147static int pci_unin_main_init_device(SysBusDevice *dev)
pbrook502a5392006-05-13 16:11:23 +0000148{
Andreas Färberff452ac2012-01-19 07:40:17 +0000149 PCIHostState *h;
pbrook502a5392006-05-13 16:11:23 +0000150
151 /* Use values found on a real PowerMac */
152 /* Uninorth main bus */
Andreas Färber8558d942012-08-20 19:08:08 +0200153 h = PCI_HOST_BRIDGE(dev);
pbrook502a5392006-05-13 16:11:23 +0000154
Andreas Färber57fd7b72012-08-20 19:08:06 +0200155 memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops,
156 dev, "pci-conf-idx", 0x1000);
157 memory_region_init_io(&h->data_mem, &unin_data_ops, dev,
Avi Kivityd0ed8072011-07-24 17:47:18 +0300158 "pci-conf-data", 0x1000);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200159 sysbus_init_mmio(dev, &h->conf_mem);
160 sysbus_init_mmio(dev, &h->data_mem);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000161
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200162 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000163}
164
Avi Kivityd0ed8072011-07-24 17:47:18 +0300165
Alexander Graf0f921192010-02-09 17:37:02 +0100166static int pci_u3_agp_init_device(SysBusDevice *dev)
167{
Andreas Färberff452ac2012-01-19 07:40:17 +0000168 PCIHostState *h;
Alexander Graf0f921192010-02-09 17:37:02 +0100169
170 /* Uninorth U3 AGP bus */
Andreas Färber8558d942012-08-20 19:08:08 +0200171 h = PCI_HOST_BRIDGE(dev);
Alexander Graf0f921192010-02-09 17:37:02 +0100172
Andreas Färber57fd7b72012-08-20 19:08:06 +0200173 memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops,
174 dev, "pci-conf-idx", 0x1000);
175 memory_region_init_io(&h->data_mem, &unin_data_ops, dev,
Avi Kivityd0ed8072011-07-24 17:47:18 +0300176 "pci-conf-data", 0x1000);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200177 sysbus_init_mmio(dev, &h->conf_mem);
178 sysbus_init_mmio(dev, &h->data_mem);
Alexander Graf0f921192010-02-09 17:37:02 +0100179
Alexander Graf0f921192010-02-09 17:37:02 +0100180 return 0;
181}
182
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200183static int pci_unin_agp_init_device(SysBusDevice *dev)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000184{
Andreas Färberff452ac2012-01-19 07:40:17 +0000185 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000186
187 /* Uninorth AGP bus */
Andreas Färber8558d942012-08-20 19:08:08 +0200188 h = PCI_HOST_BRIDGE(dev);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000189
Andreas Färber57fd7b72012-08-20 19:08:06 +0200190 memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops,
191 dev, "pci-conf-idx", 0x1000);
192 memory_region_init_io(&h->data_mem, &pci_host_data_le_ops,
193 dev, "pci-conf-data", 0x1000);
194 sysbus_init_mmio(dev, &h->conf_mem);
195 sysbus_init_mmio(dev, &h->data_mem);
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200196 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000197}
198
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200199static int pci_unin_internal_init_device(SysBusDevice *dev)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000200{
Andreas Färberff452ac2012-01-19 07:40:17 +0000201 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000202
203 /* Uninorth internal bus */
Andreas Färber8558d942012-08-20 19:08:08 +0200204 h = PCI_HOST_BRIDGE(dev);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000205
Andreas Färber57fd7b72012-08-20 19:08:06 +0200206 memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops,
207 dev, "pci-conf-idx", 0x1000);
208 memory_region_init_io(&h->data_mem, &pci_host_data_le_ops,
209 dev, "pci-conf-data", 0x1000);
210 sysbus_init_mmio(dev, &h->conf_mem);
211 sysbus_init_mmio(dev, &h->data_mem);
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200212 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000213}
214
Avi Kivityaee97b82011-08-08 16:09:04 +0300215PCIBus *pci_pmac_init(qemu_irq *pic,
216 MemoryRegion *address_space_mem,
217 MemoryRegion *address_space_io)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000218{
219 DeviceState *dev;
220 SysBusDevice *s;
Andreas Färberff452ac2012-01-19 07:40:17 +0000221 PCIHostState *h;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000222 UNINState *d;
223
224 /* Use values found on a real PowerMac */
225 /* Uninorth main bus */
Andreas Färber57fd7b72012-08-20 19:08:06 +0200226 dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE);
Markus Armbrustere23a1b32009-10-07 01:15:58 +0200227 qdev_init_nofail(dev);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200228 s = SYS_BUS_DEVICE(dev);
Andreas Färber8558d942012-08-20 19:08:08 +0200229 h = PCI_HOST_BRIDGE(s);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200230 d = UNI_NORTH_PCI_HOST_BRIDGE(dev);
Blue Swirl46f30692011-09-17 20:30:50 +0000231 memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL);
232 memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
233 0x80000000ULL, 0x70000000ULL);
234 memory_region_add_subregion(address_space_mem, 0x80000000ULL,
235 &d->pci_hole);
236
Andreas Färber57fd7b72012-08-20 19:08:06 +0200237 h->bus = pci_register_bus(dev, "pci",
238 pci_unin_set_irq, pci_unin_map_irq,
239 pic,
240 &d->pci_mmio,
241 address_space_io,
242 PCI_DEVFN(11, 0), 4);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000243
Blue Swirl60398742009-11-15 14:30:56 +0000244#if 0
Andreas Färber57fd7b72012-08-20 19:08:06 +0200245 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north");
Blue Swirl60398742009-11-15 14:30:56 +0000246#endif
Blue Swirl2e29bd02009-07-31 20:23:28 +0000247
248 sysbus_mmio_map(s, 0, 0xf2800000);
249 sysbus_mmio_map(s, 1, 0xf2c00000);
250
251 /* DEC 21154 bridge */
252#if 0
253 /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
Andreas Färber57fd7b72012-08-20 19:08:06 +0200254 pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154");
Blue Swirl2e29bd02009-07-31 20:23:28 +0000255#endif
256
257 /* Uninorth AGP bus */
Andreas Färber57fd7b72012-08-20 19:08:06 +0200258 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp");
259 dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE);
Blue Swirld27d06f2009-11-15 17:42:17 +0000260 qdev_init_nofail(dev);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200261 s = SYS_BUS_DEVICE(dev);
Blue Swirld27d06f2009-11-15 17:42:17 +0000262 sysbus_mmio_map(s, 0, 0xf0800000);
263 sysbus_mmio_map(s, 1, 0xf0c00000);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000264
265 /* Uninorth internal bus */
266#if 0
267 /* XXX: not needed for now */
Andreas Färber57fd7b72012-08-20 19:08:06 +0200268 pci_create_simple(h->bus, PCI_DEVFN(14, 0),
Andreas Färber70f9c982012-01-19 07:40:16 +0000269 "uni-north-internal-pci");
Andreas Färber57fd7b72012-08-20 19:08:06 +0200270 dev = qdev_create(NULL, TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE);
Blue Swirld27d06f2009-11-15 17:42:17 +0000271 qdev_init_nofail(dev);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200272 s = SYS_BUS_DEVICE(dev);
Blue Swirld27d06f2009-11-15 17:42:17 +0000273 sysbus_mmio_map(s, 0, 0xf4800000);
274 sysbus_mmio_map(s, 1, 0xf4c00000);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000275#endif
276
Andreas Färber57fd7b72012-08-20 19:08:06 +0200277 return h->bus;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000278}
279
Avi Kivityaee97b82011-08-08 16:09:04 +0300280PCIBus *pci_pmac_u3_init(qemu_irq *pic,
281 MemoryRegion *address_space_mem,
282 MemoryRegion *address_space_io)
Alexander Graf0f921192010-02-09 17:37:02 +0100283{
284 DeviceState *dev;
285 SysBusDevice *s;
Andreas Färberff452ac2012-01-19 07:40:17 +0000286 PCIHostState *h;
Alexander Graf0f921192010-02-09 17:37:02 +0100287 UNINState *d;
288
289 /* Uninorth AGP bus */
290
Andreas Färber57fd7b72012-08-20 19:08:06 +0200291 dev = qdev_create(NULL, TYPE_U3_AGP_HOST_BRIDGE);
Alexander Graf0f921192010-02-09 17:37:02 +0100292 qdev_init_nofail(dev);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200293 s = SYS_BUS_DEVICE(dev);
Andreas Färber8558d942012-08-20 19:08:08 +0200294 h = PCI_HOST_BRIDGE(dev);
Andreas Färber57fd7b72012-08-20 19:08:06 +0200295 d = U3_AGP_HOST_BRIDGE(dev);
Alexander Graf0f921192010-02-09 17:37:02 +0100296
Blue Swirl46f30692011-09-17 20:30:50 +0000297 memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL);
298 memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
299 0x80000000ULL, 0x70000000ULL);
300 memory_region_add_subregion(address_space_mem, 0x80000000ULL,
301 &d->pci_hole);
302
Andreas Färber57fd7b72012-08-20 19:08:06 +0200303 h->bus = pci_register_bus(dev, "pci",
304 pci_unin_set_irq, pci_unin_map_irq,
305 pic,
306 &d->pci_mmio,
307 address_space_io,
308 PCI_DEVFN(11, 0), 4);
Alexander Graf0f921192010-02-09 17:37:02 +0100309
310 sysbus_mmio_map(s, 0, 0xf0800000);
311 sysbus_mmio_map(s, 1, 0xf0c00000);
312
Andreas Färber57fd7b72012-08-20 19:08:06 +0200313 pci_create_simple(h->bus, 11 << 3, "u3-agp");
Alexander Graf0f921192010-02-09 17:37:02 +0100314
Andreas Färber57fd7b72012-08-20 19:08:06 +0200315 return h->bus;
Alexander Graf0f921192010-02-09 17:37:02 +0100316}
317
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200318static int unin_main_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000319{
pbrook502a5392006-05-13 16:11:23 +0000320 d->config[0x0C] = 0x08; // cache_line_size
321 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000322 d->config[0x34] = 0x00; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200323 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000324}
pbrook502a5392006-05-13 16:11:23 +0000325
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200326static int unin_agp_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000327{
pbrook502a5392006-05-13 16:11:23 +0000328 d->config[0x0C] = 0x08; // cache_line_size
329 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000330 // d->config[0x34] = 0x80; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200331 return 0;
Blue Swirl2e29bd02009-07-31 20:23:28 +0000332}
pbrook502a5392006-05-13 16:11:23 +0000333
Alexander Graf0f921192010-02-09 17:37:02 +0100334static int u3_agp_pci_host_init(PCIDevice *d)
335{
Alexander Graf0f921192010-02-09 17:37:02 +0100336 /* cache line size */
337 d->config[0x0C] = 0x08;
338 /* latency timer */
339 d->config[0x0D] = 0x10;
Alexander Graf0f921192010-02-09 17:37:02 +0100340 return 0;
341}
342
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200343static int unin_internal_pci_host_init(PCIDevice *d)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000344{
pbrook502a5392006-05-13 16:11:23 +0000345 d->config[0x0C] = 0x08; // cache_line_size
346 d->config[0x0D] = 0x10; // latency_timer
pbrook502a5392006-05-13 16:11:23 +0000347 d->config[0x34] = 0x00; // capabilities_pointer
Gerd Hoffmann81a322d2009-08-14 10:36:05 +0200348 return 0;
pbrook502a5392006-05-13 16:11:23 +0000349}
Blue Swirl2e29bd02009-07-31 20:23:28 +0000350
Anthony Liguori40021f02011-12-04 12:22:06 -0600351static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
352{
353 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
354
355 k->init = unin_main_pci_host_init;
356 k->vendor_id = PCI_VENDOR_ID_APPLE;
357 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI;
358 k->revision = 0x00;
359 k->class_id = PCI_CLASS_BRIDGE_HOST;
360}
361
Andreas Färber4240abf2012-08-20 19:07:56 +0200362static const TypeInfo unin_main_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600363 .name = "uni-north-pci",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600364 .parent = TYPE_PCI_DEVICE,
365 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600366 .class_init = unin_main_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000367};
368
Anthony Liguori40021f02011-12-04 12:22:06 -0600369static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
370{
371 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
372
373 k->init = u3_agp_pci_host_init;
374 k->vendor_id = PCI_VENDOR_ID_APPLE;
375 k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP;
376 k->revision = 0x00;
377 k->class_id = PCI_CLASS_BRIDGE_HOST;
378}
379
Andreas Färber4240abf2012-08-20 19:07:56 +0200380static const TypeInfo u3_agp_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600381 .name = "u3-agp",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600382 .parent = TYPE_PCI_DEVICE,
383 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600384 .class_init = u3_agp_pci_host_class_init,
Alexander Graf0f921192010-02-09 17:37:02 +0100385};
386
Anthony Liguori40021f02011-12-04 12:22:06 -0600387static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
388{
389 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
390
391 k->init = unin_agp_pci_host_init;
392 k->vendor_id = PCI_VENDOR_ID_APPLE;
393 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP;
394 k->revision = 0x00;
395 k->class_id = PCI_CLASS_BRIDGE_HOST;
396}
397
Andreas Färber4240abf2012-08-20 19:07:56 +0200398static const TypeInfo unin_agp_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600399 .name = "uni-north-agp",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600400 .parent = TYPE_PCI_DEVICE,
401 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600402 .class_init = unin_agp_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000403};
404
Anthony Liguori40021f02011-12-04 12:22:06 -0600405static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
406{
407 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
408
409 k->init = unin_internal_pci_host_init;
410 k->vendor_id = PCI_VENDOR_ID_APPLE;
411 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI;
412 k->revision = 0x00;
413 k->class_id = PCI_CLASS_BRIDGE_HOST;
414}
415
Andreas Färber4240abf2012-08-20 19:07:56 +0200416static const TypeInfo unin_internal_pci_host_info = {
Anthony Liguori40021f02011-12-04 12:22:06 -0600417 .name = "uni-north-internal-pci",
Anthony Liguori39bffca2011-12-07 21:34:16 -0600418 .parent = TYPE_PCI_DEVICE,
419 .instance_size = sizeof(PCIDevice),
Anthony Liguori40021f02011-12-04 12:22:06 -0600420 .class_init = unin_internal_pci_host_class_init,
Blue Swirl2e29bd02009-07-31 20:23:28 +0000421};
422
Anthony Liguori999e12b2012-01-24 13:12:29 -0600423static void pci_unin_main_class_init(ObjectClass *klass, void *data)
424{
425 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
426
427 sbc->init = pci_unin_main_init_device;
428}
429
Andreas Färber4240abf2012-08-20 19:07:56 +0200430static const TypeInfo pci_unin_main_info = {
Andreas Färber57fd7b72012-08-20 19:08:06 +0200431 .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE,
Andreas Färber8558d942012-08-20 19:08:08 +0200432 .parent = TYPE_PCI_HOST_BRIDGE,
Anthony Liguori39bffca2011-12-07 21:34:16 -0600433 .instance_size = sizeof(UNINState),
434 .class_init = pci_unin_main_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000435};
436
Anthony Liguori999e12b2012-01-24 13:12:29 -0600437static void pci_u3_agp_class_init(ObjectClass *klass, void *data)
438{
439 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
440
441 sbc->init = pci_u3_agp_init_device;
442}
443
Andreas Färber4240abf2012-08-20 19:07:56 +0200444static const TypeInfo pci_u3_agp_info = {
Andreas Färber57fd7b72012-08-20 19:08:06 +0200445 .name = TYPE_U3_AGP_HOST_BRIDGE,
Andreas Färber8558d942012-08-20 19:08:08 +0200446 .parent = TYPE_PCI_HOST_BRIDGE,
Anthony Liguori39bffca2011-12-07 21:34:16 -0600447 .instance_size = sizeof(UNINState),
448 .class_init = pci_u3_agp_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000449};
450
Anthony Liguori999e12b2012-01-24 13:12:29 -0600451static void pci_unin_agp_class_init(ObjectClass *klass, void *data)
452{
453 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
454
455 sbc->init = pci_unin_agp_init_device;
456}
457
Andreas Färber4240abf2012-08-20 19:07:56 +0200458static const TypeInfo pci_unin_agp_info = {
Andreas Färber57fd7b72012-08-20 19:08:06 +0200459 .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE,
Andreas Färber8558d942012-08-20 19:08:08 +0200460 .parent = TYPE_PCI_HOST_BRIDGE,
Anthony Liguori39bffca2011-12-07 21:34:16 -0600461 .instance_size = sizeof(UNINState),
462 .class_init = pci_unin_agp_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000463};
464
Anthony Liguori999e12b2012-01-24 13:12:29 -0600465static void pci_unin_internal_class_init(ObjectClass *klass, void *data)
466{
467 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
468
469 sbc->init = pci_unin_internal_init_device;
470}
471
Andreas Färber4240abf2012-08-20 19:07:56 +0200472static const TypeInfo pci_unin_internal_info = {
Andreas Färber57fd7b72012-08-20 19:08:06 +0200473 .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE,
Andreas Färber8558d942012-08-20 19:08:08 +0200474 .parent = TYPE_PCI_HOST_BRIDGE,
Anthony Liguori39bffca2011-12-07 21:34:16 -0600475 .instance_size = sizeof(UNINState),
476 .class_init = pci_unin_internal_class_init,
Andreas Färber70f9c982012-01-19 07:40:16 +0000477};
478
Andreas Färber83f7d432012-02-09 15:20:55 +0100479static void unin_register_types(void)
Blue Swirl2e29bd02009-07-31 20:23:28 +0000480{
Anthony Liguori39bffca2011-12-07 21:34:16 -0600481 type_register_static(&unin_main_pci_host_info);
482 type_register_static(&u3_agp_pci_host_info);
483 type_register_static(&unin_agp_pci_host_info);
484 type_register_static(&unin_internal_pci_host_info);
Anthony Liguori999e12b2012-01-24 13:12:29 -0600485
Anthony Liguori39bffca2011-12-07 21:34:16 -0600486 type_register_static(&pci_unin_main_info);
487 type_register_static(&pci_u3_agp_info);
488 type_register_static(&pci_unin_agp_info);
489 type_register_static(&pci_unin_internal_info);
Blue Swirl2e29bd02009-07-31 20:23:28 +0000490}
491
Andreas Färber83f7d432012-02-09 15:20:55 +0100492type_init(unin_register_types)