]>
Commit | Line | Data |
---|---|---|
502a5395 PB |
1 | /* |
2 | * QEMU Uninorth PCI host (for all Mac99 and newer machines) | |
3 | * | |
4 | * Copyright (c) 2006 Fabrice Bellard | |
5fafdf24 | 5 | * |
502a5395 PB |
6 | * 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 | */ | |
0d75590d | 24 | #include "qemu/osdep.h" |
83c9f4ca PB |
25 | #include "hw/hw.h" |
26 | #include "hw/ppc/mac.h" | |
27 | #include "hw/pci/pci.h" | |
28 | #include "hw/pci/pci_host.h" | |
87ecb68b | 29 | |
f3902383 BS |
30 | /* debug UniNorth */ |
31 | //#define DEBUG_UNIN | |
32 | ||
33 | #ifdef DEBUG_UNIN | |
001faf32 BS |
34 | #define UNIN_DPRINTF(fmt, ...) \ |
35 | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) | |
f3902383 | 36 | #else |
001faf32 | 37 | #define UNIN_DPRINTF(fmt, ...) |
f3902383 BS |
38 | #endif |
39 | ||
fa0be69a AG |
40 | static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e }; |
41 | ||
57fd7b7f AF |
42 | #define TYPE_UNI_NORTH_PCI_HOST_BRIDGE "uni-north-pci-pcihost" |
43 | #define TYPE_UNI_NORTH_AGP_HOST_BRIDGE "uni-north-agp-pcihost" | |
44 | #define TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE "uni-north-internal-pci-pcihost" | |
45 | #define TYPE_U3_AGP_HOST_BRIDGE "u3-agp-pcihost" | |
46 | ||
47 | #define UNI_NORTH_PCI_HOST_BRIDGE(obj) \ | |
48 | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_PCI_HOST_BRIDGE) | |
49 | #define UNI_NORTH_AGP_HOST_BRIDGE(obj) \ | |
50 | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_AGP_HOST_BRIDGE) | |
51 | #define UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj) \ | |
52 | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE) | |
53 | #define U3_AGP_HOST_BRIDGE(obj) \ | |
54 | OBJECT_CHECK(UNINState, (obj), TYPE_U3_AGP_HOST_BRIDGE) | |
55 | ||
2e29bd04 | 56 | typedef struct UNINState { |
67c332fd | 57 | PCIHostState parent_obj; |
57fd7b7f | 58 | |
46f3069c BS |
59 | MemoryRegion pci_mmio; |
60 | MemoryRegion pci_hole; | |
2e29bd04 | 61 | } UNINState; |
502a5395 | 62 | |
d2b59317 | 63 | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
502a5395 | 64 | { |
fa0be69a AG |
65 | int retval; |
66 | int devfn = pci_dev->devfn & 0x00FFFFFF; | |
67 | ||
68 | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; | |
69 | ||
70 | return retval; | |
d2b59317 PB |
71 | } |
72 | ||
5d4e84c8 | 73 | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
d2b59317 | 74 | { |
5d4e84c8 JQ |
75 | qemu_irq *pic = opaque; |
76 | ||
fa0be69a AG |
77 | UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__, |
78 | unin_irq_line[irq_num], level); | |
79 | qemu_set_irq(pic[unin_irq_line[irq_num]], level); | |
502a5395 PB |
80 | } |
81 | ||
d86f0e32 AG |
82 | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr) |
83 | { | |
84 | uint32_t retval; | |
85 | ||
86 | if (reg & (1u << 31)) { | |
87 | /* XXX OpenBIOS compatibility hack */ | |
88 | retval = reg | (addr & 3); | |
89 | } else if (reg & 1) { | |
90 | /* CFA1 style */ | |
91 | retval = (reg & ~7u) | (addr & 7); | |
92 | } else { | |
93 | uint32_t slot, func; | |
94 | ||
95 | /* Grab CFA0 style values */ | |
5863d374 SH |
96 | slot = ctz32(reg & 0xfffff800); |
97 | if (slot == 32) { | |
98 | slot = -1; /* XXX: should this be 0? */ | |
99 | } | |
d86f0e32 AG |
100 | func = (reg >> 8) & 7; |
101 | ||
102 | /* ... and then convert them to x86 format */ | |
103 | /* config pointer */ | |
104 | retval = (reg & (0xff - 7)) | (addr & 7); | |
105 | /* slot */ | |
106 | retval |= slot << 11; | |
107 | /* fn */ | |
108 | retval |= func << 8; | |
109 | } | |
110 | ||
111 | ||
112 | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n", | |
113 | reg, addr, retval); | |
114 | ||
115 | return retval; | |
116 | } | |
117 | ||
a8170e5e | 118 | static void unin_data_write(void *opaque, hwaddr addr, |
d0ed8076 | 119 | uint64_t val, unsigned len) |
d86f0e32 | 120 | { |
d0ed8076 | 121 | UNINState *s = opaque; |
67c332fd | 122 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
d0ed8076 AK |
123 | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
124 | addr, len, val); | |
67c332fd AF |
125 | pci_data_write(phb->bus, |
126 | unin_get_config_reg(phb->config_reg, addr), | |
d86f0e32 AG |
127 | val, len); |
128 | } | |
129 | ||
a8170e5e | 130 | static uint64_t unin_data_read(void *opaque, hwaddr addr, |
d0ed8076 | 131 | unsigned len) |
d86f0e32 | 132 | { |
d0ed8076 | 133 | UNINState *s = opaque; |
67c332fd | 134 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
d86f0e32 AG |
135 | uint32_t val; |
136 | ||
67c332fd AF |
137 | val = pci_data_read(phb->bus, |
138 | unin_get_config_reg(phb->config_reg, addr), | |
d86f0e32 | 139 | len); |
d0ed8076 AK |
140 | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
141 | addr, len, val); | |
d86f0e32 AG |
142 | return val; |
143 | } | |
144 | ||
d0ed8076 AK |
145 | static const MemoryRegionOps unin_data_ops = { |
146 | .read = unin_data_read, | |
147 | .write = unin_data_write, | |
148 | .endianness = DEVICE_LITTLE_ENDIAN, | |
149 | }; | |
150 | ||
81a322d4 | 151 | static int pci_unin_main_init_device(SysBusDevice *dev) |
502a5395 | 152 | { |
ff452ace | 153 | PCIHostState *h; |
502a5395 PB |
154 | |
155 | /* Use values found on a real PowerMac */ | |
156 | /* Uninorth main bus */ | |
8558d942 | 157 | h = PCI_HOST_BRIDGE(dev); |
502a5395 | 158 | |
40c5dce9 | 159 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
57fd7b7f | 160 | dev, "pci-conf-idx", 0x1000); |
40c5dce9 | 161 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, dev, |
d0ed8076 | 162 | "pci-conf-data", 0x1000); |
57fd7b7f AF |
163 | sysbus_init_mmio(dev, &h->conf_mem); |
164 | sysbus_init_mmio(dev, &h->data_mem); | |
2e29bd04 | 165 | |
81a322d4 | 166 | return 0; |
2e29bd04 BS |
167 | } |
168 | ||
d0ed8076 | 169 | |
0f921197 AG |
170 | static int pci_u3_agp_init_device(SysBusDevice *dev) |
171 | { | |
ff452ace | 172 | PCIHostState *h; |
0f921197 AG |
173 | |
174 | /* Uninorth U3 AGP bus */ | |
8558d942 | 175 | h = PCI_HOST_BRIDGE(dev); |
0f921197 | 176 | |
40c5dce9 | 177 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
57fd7b7f | 178 | dev, "pci-conf-idx", 0x1000); |
40c5dce9 | 179 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, dev, |
d0ed8076 | 180 | "pci-conf-data", 0x1000); |
57fd7b7f AF |
181 | sysbus_init_mmio(dev, &h->conf_mem); |
182 | sysbus_init_mmio(dev, &h->data_mem); | |
0f921197 | 183 | |
0f921197 AG |
184 | return 0; |
185 | } | |
186 | ||
81a322d4 | 187 | static int pci_unin_agp_init_device(SysBusDevice *dev) |
2e29bd04 | 188 | { |
ff452ace | 189 | PCIHostState *h; |
2e29bd04 BS |
190 | |
191 | /* Uninorth AGP bus */ | |
8558d942 | 192 | h = PCI_HOST_BRIDGE(dev); |
57fd7b7f | 193 | |
40c5dce9 | 194 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
57fd7b7f | 195 | dev, "pci-conf-idx", 0x1000); |
40c5dce9 | 196 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
57fd7b7f AF |
197 | dev, "pci-conf-data", 0x1000); |
198 | sysbus_init_mmio(dev, &h->conf_mem); | |
199 | sysbus_init_mmio(dev, &h->data_mem); | |
81a322d4 | 200 | return 0; |
2e29bd04 BS |
201 | } |
202 | ||
81a322d4 | 203 | static int pci_unin_internal_init_device(SysBusDevice *dev) |
2e29bd04 | 204 | { |
ff452ace | 205 | PCIHostState *h; |
2e29bd04 BS |
206 | |
207 | /* Uninorth internal bus */ | |
8558d942 | 208 | h = PCI_HOST_BRIDGE(dev); |
57fd7b7f | 209 | |
40c5dce9 | 210 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
57fd7b7f | 211 | dev, "pci-conf-idx", 0x1000); |
40c5dce9 | 212 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
57fd7b7f AF |
213 | dev, "pci-conf-data", 0x1000); |
214 | sysbus_init_mmio(dev, &h->conf_mem); | |
215 | sysbus_init_mmio(dev, &h->data_mem); | |
81a322d4 | 216 | return 0; |
2e29bd04 BS |
217 | } |
218 | ||
aee97b84 AK |
219 | PCIBus *pci_pmac_init(qemu_irq *pic, |
220 | MemoryRegion *address_space_mem, | |
221 | MemoryRegion *address_space_io) | |
2e29bd04 BS |
222 | { |
223 | DeviceState *dev; | |
224 | SysBusDevice *s; | |
ff452ace | 225 | PCIHostState *h; |
2e29bd04 BS |
226 | UNINState *d; |
227 | ||
228 | /* Use values found on a real PowerMac */ | |
229 | /* Uninorth main bus */ | |
57fd7b7f | 230 | dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE); |
e23a1b33 | 231 | qdev_init_nofail(dev); |
57fd7b7f | 232 | s = SYS_BUS_DEVICE(dev); |
8558d942 | 233 | h = PCI_HOST_BRIDGE(s); |
57fd7b7f | 234 | d = UNI_NORTH_PCI_HOST_BRIDGE(dev); |
40c5dce9 PB |
235 | memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); |
236 | memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, | |
1be88255 | 237 | 0x80000000ULL, 0x10000000ULL); |
46f3069c BS |
238 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, |
239 | &d->pci_hole); | |
240 | ||
8a0e1104 | 241 | h->bus = pci_register_bus(dev, NULL, |
57fd7b7f AF |
242 | pci_unin_set_irq, pci_unin_map_irq, |
243 | pic, | |
244 | &d->pci_mmio, | |
245 | address_space_io, | |
60a0e443 | 246 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
2e29bd04 | 247 | |
60398748 | 248 | #if 0 |
57fd7b7f | 249 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north"); |
60398748 | 250 | #endif |
2e29bd04 BS |
251 | |
252 | sysbus_mmio_map(s, 0, 0xf2800000); | |
253 | sysbus_mmio_map(s, 1, 0xf2c00000); | |
254 | ||
255 | /* DEC 21154 bridge */ | |
256 | #if 0 | |
257 | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */ | |
57fd7b7f | 258 | pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154"); |
2e29bd04 BS |
259 | #endif |
260 | ||
261 | /* Uninorth AGP bus */ | |
57fd7b7f AF |
262 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
263 | dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE); | |
d27d06f2 | 264 | qdev_init_nofail(dev); |
57fd7b7f | 265 | s = SYS_BUS_DEVICE(dev); |
d27d06f2 BS |
266 | sysbus_mmio_map(s, 0, 0xf0800000); |
267 | sysbus_mmio_map(s, 1, 0xf0c00000); | |
2e29bd04 BS |
268 | |
269 | /* Uninorth internal bus */ | |
270 | #if 0 | |
271 | /* XXX: not needed for now */ | |
57fd7b7f | 272 | pci_create_simple(h->bus, PCI_DEVFN(14, 0), |
70f9c987 | 273 | "uni-north-internal-pci"); |
57fd7b7f | 274 | dev = qdev_create(NULL, TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE); |
d27d06f2 | 275 | qdev_init_nofail(dev); |
57fd7b7f | 276 | s = SYS_BUS_DEVICE(dev); |
d27d06f2 BS |
277 | sysbus_mmio_map(s, 0, 0xf4800000); |
278 | sysbus_mmio_map(s, 1, 0xf4c00000); | |
2e29bd04 BS |
279 | #endif |
280 | ||
57fd7b7f | 281 | return h->bus; |
2e29bd04 BS |
282 | } |
283 | ||
aee97b84 AK |
284 | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
285 | MemoryRegion *address_space_mem, | |
286 | MemoryRegion *address_space_io) | |
0f921197 AG |
287 | { |
288 | DeviceState *dev; | |
289 | SysBusDevice *s; | |
ff452ace | 290 | PCIHostState *h; |
0f921197 AG |
291 | UNINState *d; |
292 | ||
293 | /* Uninorth AGP bus */ | |
294 | ||
57fd7b7f | 295 | dev = qdev_create(NULL, TYPE_U3_AGP_HOST_BRIDGE); |
0f921197 | 296 | qdev_init_nofail(dev); |
57fd7b7f | 297 | s = SYS_BUS_DEVICE(dev); |
8558d942 | 298 | h = PCI_HOST_BRIDGE(dev); |
57fd7b7f | 299 | d = U3_AGP_HOST_BRIDGE(dev); |
0f921197 | 300 | |
40c5dce9 PB |
301 | memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); |
302 | memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, | |
46f3069c BS |
303 | 0x80000000ULL, 0x70000000ULL); |
304 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, | |
305 | &d->pci_hole); | |
306 | ||
8a0e1104 | 307 | h->bus = pci_register_bus(dev, NULL, |
57fd7b7f AF |
308 | pci_unin_set_irq, pci_unin_map_irq, |
309 | pic, | |
310 | &d->pci_mmio, | |
311 | address_space_io, | |
60a0e443 | 312 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
0f921197 AG |
313 | |
314 | sysbus_mmio_map(s, 0, 0xf0800000); | |
315 | sysbus_mmio_map(s, 1, 0xf0c00000); | |
316 | ||
57fd7b7f | 317 | pci_create_simple(h->bus, 11 << 3, "u3-agp"); |
0f921197 | 318 | |
57fd7b7f | 319 | return h->bus; |
0f921197 AG |
320 | } |
321 | ||
9af21dbe | 322 | static void unin_main_pci_host_realize(PCIDevice *d, Error **errp) |
2e29bd04 | 323 | { |
502a5395 PB |
324 | d->config[0x0C] = 0x08; // cache_line_size |
325 | d->config[0x0D] = 0x10; // latency_timer | |
502a5395 | 326 | d->config[0x34] = 0x00; // capabilities_pointer |
2e29bd04 | 327 | } |
502a5395 | 328 | |
9af21dbe | 329 | static void unin_agp_pci_host_realize(PCIDevice *d, Error **errp) |
2e29bd04 | 330 | { |
502a5395 PB |
331 | d->config[0x0C] = 0x08; // cache_line_size |
332 | d->config[0x0D] = 0x10; // latency_timer | |
502a5395 | 333 | // d->config[0x34] = 0x80; // capabilities_pointer |
98ae3b27 JA |
334 | /* |
335 | * Set kMacRISCPCIAddressSelect (0x48) register to indicate PCI | |
336 | * memory space with base 0x80000000, size 0x10000000 for Apple's | |
337 | * AppleMacRiscPCI driver | |
338 | */ | |
339 | d->config[0x48] = 0x0; | |
340 | d->config[0x49] = 0x0; | |
341 | d->config[0x4a] = 0x0; | |
342 | d->config[0x4b] = 0x1; | |
2e29bd04 | 343 | } |
502a5395 | 344 | |
9af21dbe | 345 | static void u3_agp_pci_host_realize(PCIDevice *d, Error **errp) |
0f921197 | 346 | { |
0f921197 AG |
347 | /* cache line size */ |
348 | d->config[0x0C] = 0x08; | |
349 | /* latency timer */ | |
350 | d->config[0x0D] = 0x10; | |
0f921197 AG |
351 | } |
352 | ||
9af21dbe | 353 | static void unin_internal_pci_host_realize(PCIDevice *d, Error **errp) |
2e29bd04 | 354 | { |
502a5395 PB |
355 | d->config[0x0C] = 0x08; // cache_line_size |
356 | d->config[0x0D] = 0x10; // latency_timer | |
502a5395 | 357 | d->config[0x34] = 0x00; // capabilities_pointer |
2e29bd04 BS |
358 | } |
359 | ||
40021f08 AL |
360 | static void unin_main_pci_host_class_init(ObjectClass *klass, void *data) |
361 | { | |
362 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
08c58f92 | 363 | DeviceClass *dc = DEVICE_CLASS(klass); |
40021f08 | 364 | |
9af21dbe | 365 | k->realize = unin_main_pci_host_realize; |
40021f08 AL |
366 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
367 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI; | |
368 | k->revision = 0x00; | |
369 | k->class_id = PCI_CLASS_BRIDGE_HOST; | |
08c58f92 MA |
370 | /* |
371 | * PCI-facing part of the host bridge, not usable without the | |
372 | * host-facing part, which can't be device_add'ed, yet. | |
373 | */ | |
374 | dc->cannot_instantiate_with_device_add_yet = true; | |
40021f08 AL |
375 | } |
376 | ||
4240abff | 377 | static const TypeInfo unin_main_pci_host_info = { |
40021f08 | 378 | .name = "uni-north-pci", |
39bffca2 AL |
379 | .parent = TYPE_PCI_DEVICE, |
380 | .instance_size = sizeof(PCIDevice), | |
40021f08 | 381 | .class_init = unin_main_pci_host_class_init, |
2e29bd04 BS |
382 | }; |
383 | ||
40021f08 AL |
384 | static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data) |
385 | { | |
386 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
08c58f92 | 387 | DeviceClass *dc = DEVICE_CLASS(klass); |
40021f08 | 388 | |
9af21dbe | 389 | k->realize = u3_agp_pci_host_realize; |
40021f08 AL |
390 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
391 | k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP; | |
392 | k->revision = 0x00; | |
393 | k->class_id = PCI_CLASS_BRIDGE_HOST; | |
08c58f92 MA |
394 | /* |
395 | * PCI-facing part of the host bridge, not usable without the | |
396 | * host-facing part, which can't be device_add'ed, yet. | |
397 | */ | |
398 | dc->cannot_instantiate_with_device_add_yet = true; | |
40021f08 AL |
399 | } |
400 | ||
4240abff | 401 | static const TypeInfo u3_agp_pci_host_info = { |
40021f08 | 402 | .name = "u3-agp", |
39bffca2 AL |
403 | .parent = TYPE_PCI_DEVICE, |
404 | .instance_size = sizeof(PCIDevice), | |
40021f08 | 405 | .class_init = u3_agp_pci_host_class_init, |
0f921197 AG |
406 | }; |
407 | ||
40021f08 AL |
408 | static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data) |
409 | { | |
410 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
08c58f92 | 411 | DeviceClass *dc = DEVICE_CLASS(klass); |
40021f08 | 412 | |
9af21dbe | 413 | k->realize = unin_agp_pci_host_realize; |
40021f08 AL |
414 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
415 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP; | |
416 | k->revision = 0x00; | |
417 | k->class_id = PCI_CLASS_BRIDGE_HOST; | |
08c58f92 MA |
418 | /* |
419 | * PCI-facing part of the host bridge, not usable without the | |
420 | * host-facing part, which can't be device_add'ed, yet. | |
421 | */ | |
422 | dc->cannot_instantiate_with_device_add_yet = true; | |
40021f08 AL |
423 | } |
424 | ||
4240abff | 425 | static const TypeInfo unin_agp_pci_host_info = { |
40021f08 | 426 | .name = "uni-north-agp", |
39bffca2 AL |
427 | .parent = TYPE_PCI_DEVICE, |
428 | .instance_size = sizeof(PCIDevice), | |
40021f08 | 429 | .class_init = unin_agp_pci_host_class_init, |
2e29bd04 BS |
430 | }; |
431 | ||
40021f08 AL |
432 | static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data) |
433 | { | |
434 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
08c58f92 | 435 | DeviceClass *dc = DEVICE_CLASS(klass); |
40021f08 | 436 | |
9af21dbe | 437 | k->realize = unin_internal_pci_host_realize; |
40021f08 AL |
438 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
439 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI; | |
440 | k->revision = 0x00; | |
441 | k->class_id = PCI_CLASS_BRIDGE_HOST; | |
08c58f92 MA |
442 | /* |
443 | * PCI-facing part of the host bridge, not usable without the | |
444 | * host-facing part, which can't be device_add'ed, yet. | |
445 | */ | |
446 | dc->cannot_instantiate_with_device_add_yet = true; | |
40021f08 AL |
447 | } |
448 | ||
4240abff | 449 | static const TypeInfo unin_internal_pci_host_info = { |
40021f08 | 450 | .name = "uni-north-internal-pci", |
39bffca2 AL |
451 | .parent = TYPE_PCI_DEVICE, |
452 | .instance_size = sizeof(PCIDevice), | |
40021f08 | 453 | .class_init = unin_internal_pci_host_class_init, |
2e29bd04 BS |
454 | }; |
455 | ||
999e12bb AL |
456 | static void pci_unin_main_class_init(ObjectClass *klass, void *data) |
457 | { | |
458 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); | |
1d16f86a | 459 | DeviceClass *dc = DEVICE_CLASS(klass); |
999e12bb AL |
460 | |
461 | sbc->init = pci_unin_main_init_device; | |
1d16f86a | 462 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
999e12bb AL |
463 | } |
464 | ||
4240abff | 465 | static const TypeInfo pci_unin_main_info = { |
57fd7b7f | 466 | .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE, |
8558d942 | 467 | .parent = TYPE_PCI_HOST_BRIDGE, |
39bffca2 AL |
468 | .instance_size = sizeof(UNINState), |
469 | .class_init = pci_unin_main_class_init, | |
70f9c987 AF |
470 | }; |
471 | ||
999e12bb AL |
472 | static void pci_u3_agp_class_init(ObjectClass *klass, void *data) |
473 | { | |
474 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); | |
1d16f86a | 475 | DeviceClass *dc = DEVICE_CLASS(klass); |
999e12bb AL |
476 | |
477 | sbc->init = pci_u3_agp_init_device; | |
1d16f86a | 478 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
999e12bb AL |
479 | } |
480 | ||
4240abff | 481 | static const TypeInfo pci_u3_agp_info = { |
57fd7b7f | 482 | .name = TYPE_U3_AGP_HOST_BRIDGE, |
8558d942 | 483 | .parent = TYPE_PCI_HOST_BRIDGE, |
39bffca2 AL |
484 | .instance_size = sizeof(UNINState), |
485 | .class_init = pci_u3_agp_class_init, | |
70f9c987 AF |
486 | }; |
487 | ||
999e12bb AL |
488 | static void pci_unin_agp_class_init(ObjectClass *klass, void *data) |
489 | { | |
490 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); | |
1d16f86a | 491 | DeviceClass *dc = DEVICE_CLASS(klass); |
999e12bb AL |
492 | |
493 | sbc->init = pci_unin_agp_init_device; | |
1d16f86a | 494 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
999e12bb AL |
495 | } |
496 | ||
4240abff | 497 | static const TypeInfo pci_unin_agp_info = { |
57fd7b7f | 498 | .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE, |
8558d942 | 499 | .parent = TYPE_PCI_HOST_BRIDGE, |
39bffca2 AL |
500 | .instance_size = sizeof(UNINState), |
501 | .class_init = pci_unin_agp_class_init, | |
70f9c987 AF |
502 | }; |
503 | ||
999e12bb AL |
504 | static void pci_unin_internal_class_init(ObjectClass *klass, void *data) |
505 | { | |
506 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); | |
1d16f86a | 507 | DeviceClass *dc = DEVICE_CLASS(klass); |
999e12bb AL |
508 | |
509 | sbc->init = pci_unin_internal_init_device; | |
1d16f86a | 510 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
999e12bb AL |
511 | } |
512 | ||
4240abff | 513 | static const TypeInfo pci_unin_internal_info = { |
57fd7b7f | 514 | .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE, |
8558d942 | 515 | .parent = TYPE_PCI_HOST_BRIDGE, |
39bffca2 AL |
516 | .instance_size = sizeof(UNINState), |
517 | .class_init = pci_unin_internal_class_init, | |
70f9c987 AF |
518 | }; |
519 | ||
83f7d43a | 520 | static void unin_register_types(void) |
2e29bd04 | 521 | { |
39bffca2 AL |
522 | type_register_static(&unin_main_pci_host_info); |
523 | type_register_static(&u3_agp_pci_host_info); | |
524 | type_register_static(&unin_agp_pci_host_info); | |
525 | type_register_static(&unin_internal_pci_host_info); | |
526 | ||
527 | type_register_static(&pci_unin_main_info); | |
528 | type_register_static(&pci_u3_agp_info); | |
529 | type_register_static(&pci_unin_agp_info); | |
530 | type_register_static(&pci_unin_internal_info); | |
502a5395 | 531 | } |
2e29bd04 | 532 | |
83f7d43a | 533 | type_init(unin_register_types) |