]> Git Repo - qemu.git/blame - hw/pci-host/uninorth.c
Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-sf0' into staging
[qemu.git] / hw / pci-host / uninorth.c
CommitLineData
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"
5d2eaa02 29#include "hw/pci-host/uninorth.h"
0b0c5e90 30#include "trace.h"
f3902383 31
fa0be69a
AG
32static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
33
d2b59317 34static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
502a5395 35{
39d97e14 36 return (irq_num + (pci_dev->devfn >> 3)) & 3;
d2b59317
PB
37}
38
5d4e84c8 39static void pci_unin_set_irq(void *opaque, int irq_num, int level)
d2b59317 40{
c90c393c 41 UNINHostState *s = opaque;
5d4e84c8 42
0b0c5e90 43 trace_unin_set_irq(unin_irq_line[irq_num], level);
e7755cc1 44 qemu_set_irq(s->irqs[irq_num], level);
502a5395
PB
45}
46
d86f0e32
AG
47static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
48{
49 uint32_t retval;
50
51 if (reg & (1u << 31)) {
52 /* XXX OpenBIOS compatibility hack */
53 retval = reg | (addr & 3);
54 } else if (reg & 1) {
55 /* CFA1 style */
56 retval = (reg & ~7u) | (addr & 7);
57 } else {
58 uint32_t slot, func;
59
60 /* Grab CFA0 style values */
5863d374
SH
61 slot = ctz32(reg & 0xfffff800);
62 if (slot == 32) {
63 slot = -1; /* XXX: should this be 0? */
64 }
d86f0e32
AG
65 func = (reg >> 8) & 7;
66
67 /* ... and then convert them to x86 format */
68 /* config pointer */
69 retval = (reg & (0xff - 7)) | (addr & 7);
70 /* slot */
71 retval |= slot << 11;
72 /* fn */
73 retval |= func << 8;
74 }
75
0b0c5e90 76 trace_unin_get_config_reg(reg, addr, retval);
d86f0e32
AG
77
78 return retval;
79}
80
a8170e5e 81static void unin_data_write(void *opaque, hwaddr addr,
d0ed8076 82 uint64_t val, unsigned len)
d86f0e32 83{
c90c393c 84 UNINHostState *s = opaque;
67c332fd 85 PCIHostState *phb = PCI_HOST_BRIDGE(s);
0b0c5e90 86 trace_unin_data_write(addr, len, val);
67c332fd
AF
87 pci_data_write(phb->bus,
88 unin_get_config_reg(phb->config_reg, addr),
d86f0e32
AG
89 val, len);
90}
91
a8170e5e 92static uint64_t unin_data_read(void *opaque, hwaddr addr,
d0ed8076 93 unsigned len)
d86f0e32 94{
c90c393c 95 UNINHostState *s = opaque;
67c332fd 96 PCIHostState *phb = PCI_HOST_BRIDGE(s);
d86f0e32
AG
97 uint32_t val;
98
67c332fd
AF
99 val = pci_data_read(phb->bus,
100 unin_get_config_reg(phb->config_reg, addr),
d86f0e32 101 len);
0b0c5e90 102 trace_unin_data_read(addr, len, val);
d86f0e32
AG
103 return val;
104}
105
d0ed8076
AK
106static const MemoryRegionOps unin_data_ops = {
107 .read = unin_data_read,
108 .write = unin_data_write,
109 .endianness = DEVICE_LITTLE_ENDIAN,
110};
111
c90c393c 112static void pci_unin_init_irqs(UNINHostState *s)
e7755cc1
MCA
113{
114 int i;
115
116 for (i = 0; i < ARRAY_SIZE(s->irqs); i++) {
117 s->irqs[i] = qdev_get_gpio_in(DEVICE(s->pic), unin_irq_line[i]);
118 }
119}
120
03756c84
MCA
121static char *pci_unin_main_ofw_unit_address(const SysBusDevice *dev)
122{
123 UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
124
125 return g_strdup_printf("%x", s->ofw_addr);
126}
127
32cde615
MCA
128static void pci_unin_main_realize(DeviceState *dev, Error **errp)
129{
c90c393c 130 UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
32cde615
MCA
131 PCIHostState *h = PCI_HOST_BRIDGE(dev);
132
133 h->bus = pci_register_root_bus(dev, NULL,
134 pci_unin_set_irq, pci_unin_map_irq,
e7755cc1 135 s,
32cde615 136 &s->pci_mmio,
e226efbb 137 &s->pci_io,
32cde615
MCA
138 PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
139
c1d66d37 140 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-pci");
e7755cc1 141 pci_unin_init_irqs(s);
32cde615
MCA
142
143 /* DEC 21154 bridge */
144#if 0
145 /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
146 pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154");
147#endif
148}
149
02034599 150static void pci_unin_main_init(Object *obj)
502a5395 151{
c90c393c 152 UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(obj);
02034599
MCA
153 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
154 PCIHostState *h = PCI_HOST_BRIDGE(obj);
502a5395
PB
155
156 /* Use values found on a real PowerMac */
157 /* Uninorth main bus */
40c5dce9 158 memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
132e9906 159 obj, "unin-pci-conf-idx", 0x1000);
02034599 160 memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj,
132e9906
MCA
161 "unin-pci-conf-data", 0x1000);
162
163 memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio",
164 0x100000000ULL);
e226efbb
MCA
165 memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj,
166 "unin-pci-isa-mmio", 0x00800000);
132e9906 167
7b19318b
MCA
168 memory_region_init_alias(&s->pci_hole, OBJECT(s),
169 "unin-pci-hole", &s->pci_mmio,
170 0x80000000ULL, 0x10000000ULL);
171
e7755cc1
MCA
172 object_property_add_link(obj, "pic", TYPE_OPENPIC,
173 (Object **) &s->pic,
174 qdev_prop_allow_set_link_before_realize,
175 0, NULL);
176
02034599
MCA
177 sysbus_init_mmio(sbd, &h->conf_mem);
178 sysbus_init_mmio(sbd, &h->data_mem);
7b19318b 179 sysbus_init_mmio(sbd, &s->pci_hole);
e226efbb 180 sysbus_init_mmio(sbd, &s->pci_io);
2e29bd04
BS
181}
182
32cde615
MCA
183static void pci_u3_agp_realize(DeviceState *dev, Error **errp)
184{
c90c393c 185 UNINHostState *s = U3_AGP_HOST_BRIDGE(dev);
32cde615
MCA
186 PCIHostState *h = PCI_HOST_BRIDGE(dev);
187
188 h->bus = pci_register_root_bus(dev, NULL,
189 pci_unin_set_irq, pci_unin_map_irq,
e7755cc1 190 s,
32cde615 191 &s->pci_mmio,
e226efbb 192 &s->pci_io,
32cde615
MCA
193 PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
194
195 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "u3-agp");
e7755cc1 196 pci_unin_init_irqs(s);
32cde615
MCA
197}
198
02034599 199static void pci_u3_agp_init(Object *obj)
0f921197 200{
c90c393c 201 UNINHostState *s = U3_AGP_HOST_BRIDGE(obj);
02034599
MCA
202 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
203 PCIHostState *h = PCI_HOST_BRIDGE(obj);
0f921197
AG
204
205 /* Uninorth U3 AGP bus */
40c5dce9 206 memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
132e9906 207 obj, "unin-pci-conf-idx", 0x1000);
02034599 208 memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, obj,
132e9906
MCA
209 "unin-pci-conf-data", 0x1000);
210
211 memory_region_init(&s->pci_mmio, OBJECT(s), "unin-pci-mmio",
212 0x100000000ULL);
e226efbb
MCA
213 memory_region_init_io(&s->pci_io, OBJECT(s), &unassigned_io_ops, obj,
214 "unin-pci-isa-mmio", 0x00800000);
132e9906 215
8ce3f743
MCA
216 memory_region_init_alias(&s->pci_hole, OBJECT(s),
217 "unin-pci-hole", &s->pci_mmio,
218 0x80000000ULL, 0x70000000ULL);
219
e7755cc1
MCA
220 object_property_add_link(obj, "pic", TYPE_OPENPIC,
221 (Object **) &s->pic,
222 qdev_prop_allow_set_link_before_realize,
223 0, NULL);
224
02034599
MCA
225 sysbus_init_mmio(sbd, &h->conf_mem);
226 sysbus_init_mmio(sbd, &h->data_mem);
8ce3f743 227 sysbus_init_mmio(sbd, &s->pci_hole);
e226efbb 228 sysbus_init_mmio(sbd, &s->pci_io);
0f921197
AG
229}
230
32cde615
MCA
231static void pci_unin_agp_realize(DeviceState *dev, Error **errp)
232{
c90c393c 233 UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(dev);
32cde615
MCA
234 PCIHostState *h = PCI_HOST_BRIDGE(dev);
235
236 h->bus = pci_register_root_bus(dev, NULL,
237 pci_unin_set_irq, pci_unin_map_irq,
e7755cc1 238 s,
32cde615 239 &s->pci_mmio,
e226efbb 240 &s->pci_io,
32cde615 241 PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
c1d66d37
MCA
242
243 pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp");
e7755cc1 244 pci_unin_init_irqs(s);
32cde615
MCA
245}
246
02034599 247static void pci_unin_agp_init(Object *obj)
2e29bd04 248{
c90c393c 249 UNINHostState *s = UNI_NORTH_AGP_HOST_BRIDGE(obj);
02034599
MCA
250 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
251 PCIHostState *h = PCI_HOST_BRIDGE(obj);
2e29bd04
BS
252
253 /* Uninorth AGP bus */
40c5dce9 254 memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
132e9906 255 obj, "unin-agp-conf-idx", 0x1000);
40c5dce9 256 memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
132e9906 257 obj, "unin-agp-conf-data", 0x1000);
e7755cc1
MCA
258
259 object_property_add_link(obj, "pic", TYPE_OPENPIC,
260 (Object **) &s->pic,
261 qdev_prop_allow_set_link_before_realize,
262 0, NULL);
263
02034599
MCA
264 sysbus_init_mmio(sbd, &h->conf_mem);
265 sysbus_init_mmio(sbd, &h->data_mem);
2e29bd04
BS
266}
267
1ff861d2
MCA
268static void pci_unin_internal_realize(DeviceState *dev, Error **errp)
269{
c90c393c 270 UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(dev);
1ff861d2
MCA
271 PCIHostState *h = PCI_HOST_BRIDGE(dev);
272
273 h->bus = pci_register_root_bus(dev, NULL,
274 pci_unin_set_irq, pci_unin_map_irq,
e7755cc1 275 s,
1ff861d2 276 &s->pci_mmio,
e226efbb 277 &s->pci_io,
1ff861d2
MCA
278 PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS);
279
280 pci_create_simple(h->bus, PCI_DEVFN(14, 0), "uni-north-internal-pci");
e7755cc1 281 pci_unin_init_irqs(s);
1ff861d2
MCA
282}
283
02034599 284static void pci_unin_internal_init(Object *obj)
2e29bd04 285{
c90c393c 286 UNINHostState *s = UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj);
02034599
MCA
287 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
288 PCIHostState *h = PCI_HOST_BRIDGE(obj);
2e29bd04
BS
289
290 /* Uninorth internal bus */
40c5dce9 291 memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops,
132e9906 292 obj, "unin-pci-conf-idx", 0x1000);
40c5dce9 293 memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
132e9906 294 obj, "unin-pci-conf-data", 0x1000);
e7755cc1
MCA
295
296 object_property_add_link(obj, "pic", TYPE_OPENPIC,
297 (Object **) &s->pic,
298 qdev_prop_allow_set_link_before_realize,
299 0, NULL);
300
02034599
MCA
301 sysbus_init_mmio(sbd, &h->conf_mem);
302 sysbus_init_mmio(sbd, &h->data_mem);
2e29bd04
BS
303}
304
9af21dbe 305static void unin_main_pci_host_realize(PCIDevice *d, Error **errp)
2e29bd04 306{
4d309c96
MCA
307 /* cache_line_size */
308 d->config[0x0C] = 0x08;
309 /* latency_timer */
310 d->config[0x0D] = 0x10;
311 /* capabilities_pointer */
312 d->config[0x34] = 0x00;
4d309c96 313
98ae3b27
JA
314 /*
315 * Set kMacRISCPCIAddressSelect (0x48) register to indicate PCI
316 * memory space with base 0x80000000, size 0x10000000 for Apple's
317 * AppleMacRiscPCI driver
318 */
319 d->config[0x48] = 0x0;
320 d->config[0x49] = 0x0;
321 d->config[0x4a] = 0x0;
322 d->config[0x4b] = 0x1;
2e29bd04 323}
502a5395 324
c1d66d37
MCA
325static void unin_agp_pci_host_realize(PCIDevice *d, Error **errp)
326{
327 /* cache_line_size */
328 d->config[0x0C] = 0x08;
329 /* latency_timer */
330 d->config[0x0D] = 0x10;
331 /* capabilities_pointer
332 d->config[0x34] = 0x80; */
333}
334
9af21dbe 335static void u3_agp_pci_host_realize(PCIDevice *d, Error **errp)
0f921197 336{
0f921197
AG
337 /* cache line size */
338 d->config[0x0C] = 0x08;
339 /* latency timer */
340 d->config[0x0D] = 0x10;
0f921197
AG
341}
342
9af21dbe 343static void unin_internal_pci_host_realize(PCIDevice *d, Error **errp)
2e29bd04 344{
4d309c96
MCA
345 /* cache_line_size */
346 d->config[0x0C] = 0x08;
347 /* latency_timer */
348 d->config[0x0D] = 0x10;
349 /* capabilities_pointer */
350 d->config[0x34] = 0x00;
2e29bd04
BS
351}
352
40021f08
AL
353static void unin_main_pci_host_class_init(ObjectClass *klass, void *data)
354{
355 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
08c58f92 356 DeviceClass *dc = DEVICE_CLASS(klass);
40021f08 357
9af21dbe 358 k->realize = unin_main_pci_host_realize;
40021f08
AL
359 k->vendor_id = PCI_VENDOR_ID_APPLE;
360 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI;
361 k->revision = 0x00;
362 k->class_id = PCI_CLASS_BRIDGE_HOST;
08c58f92
MA
363 /*
364 * PCI-facing part of the host bridge, not usable without the
365 * host-facing part, which can't be device_add'ed, yet.
366 */
e90f2a8c 367 dc->user_creatable = false;
40021f08
AL
368}
369
4240abff 370static const TypeInfo unin_main_pci_host_info = {
40021f08 371 .name = "uni-north-pci",
39bffca2
AL
372 .parent = TYPE_PCI_DEVICE,
373 .instance_size = sizeof(PCIDevice),
40021f08 374 .class_init = unin_main_pci_host_class_init,
fd3b02c8
EH
375 .interfaces = (InterfaceInfo[]) {
376 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
377 { },
378 },
2e29bd04
BS
379};
380
40021f08
AL
381static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data)
382{
383 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
08c58f92 384 DeviceClass *dc = DEVICE_CLASS(klass);
40021f08 385
9af21dbe 386 k->realize = u3_agp_pci_host_realize;
40021f08
AL
387 k->vendor_id = PCI_VENDOR_ID_APPLE;
388 k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP;
389 k->revision = 0x00;
390 k->class_id = PCI_CLASS_BRIDGE_HOST;
08c58f92
MA
391 /*
392 * PCI-facing part of the host bridge, not usable without the
393 * host-facing part, which can't be device_add'ed, yet.
394 */
e90f2a8c 395 dc->user_creatable = false;
40021f08
AL
396}
397
4240abff 398static const TypeInfo u3_agp_pci_host_info = {
40021f08 399 .name = "u3-agp",
39bffca2
AL
400 .parent = TYPE_PCI_DEVICE,
401 .instance_size = sizeof(PCIDevice),
40021f08 402 .class_init = u3_agp_pci_host_class_init,
fd3b02c8
EH
403 .interfaces = (InterfaceInfo[]) {
404 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
405 { },
406 },
0f921197
AG
407};
408
40021f08
AL
409static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data)
410{
411 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
08c58f92 412 DeviceClass *dc = DEVICE_CLASS(klass);
40021f08 413
9af21dbe 414 k->realize = unin_agp_pci_host_realize;
40021f08
AL
415 k->vendor_id = PCI_VENDOR_ID_APPLE;
416 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP;
417 k->revision = 0x00;
418 k->class_id = PCI_CLASS_BRIDGE_HOST;
08c58f92
MA
419 /*
420 * PCI-facing part of the host bridge, not usable without the
421 * host-facing part, which can't be device_add'ed, yet.
422 */
e90f2a8c 423 dc->user_creatable = false;
40021f08
AL
424}
425
4240abff 426static const TypeInfo unin_agp_pci_host_info = {
40021f08 427 .name = "uni-north-agp",
39bffca2
AL
428 .parent = TYPE_PCI_DEVICE,
429 .instance_size = sizeof(PCIDevice),
40021f08 430 .class_init = unin_agp_pci_host_class_init,
fd3b02c8
EH
431 .interfaces = (InterfaceInfo[]) {
432 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
433 { },
434 },
2e29bd04
BS
435};
436
40021f08
AL
437static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data)
438{
439 PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
08c58f92 440 DeviceClass *dc = DEVICE_CLASS(klass);
40021f08 441
9af21dbe 442 k->realize = unin_internal_pci_host_realize;
40021f08
AL
443 k->vendor_id = PCI_VENDOR_ID_APPLE;
444 k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI;
445 k->revision = 0x00;
446 k->class_id = PCI_CLASS_BRIDGE_HOST;
08c58f92
MA
447 /*
448 * PCI-facing part of the host bridge, not usable without the
449 * host-facing part, which can't be device_add'ed, yet.
450 */
e90f2a8c 451 dc->user_creatable = false;
40021f08
AL
452}
453
4240abff 454static const TypeInfo unin_internal_pci_host_info = {
40021f08 455 .name = "uni-north-internal-pci",
39bffca2
AL
456 .parent = TYPE_PCI_DEVICE,
457 .instance_size = sizeof(PCIDevice),
40021f08 458 .class_init = unin_internal_pci_host_class_init,
fd3b02c8
EH
459 .interfaces = (InterfaceInfo[]) {
460 { INTERFACE_CONVENTIONAL_PCI_DEVICE },
461 { },
462 },
2e29bd04
BS
463};
464
03756c84
MCA
465static Property pci_unin_main_pci_host_props[] = {
466 DEFINE_PROP_UINT32("ofw-addr", UNINHostState, ofw_addr, -1),
467 DEFINE_PROP_END_OF_LIST()
468};
469
999e12bb
AL
470static void pci_unin_main_class_init(ObjectClass *klass, void *data)
471{
1d16f86a 472 DeviceClass *dc = DEVICE_CLASS(klass);
03756c84 473 SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
999e12bb 474
32cde615 475 dc->realize = pci_unin_main_realize;
03756c84 476 dc->props = pci_unin_main_pci_host_props;
1d16f86a 477 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
03756c84
MCA
478 dc->fw_name = "pci";
479 sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
999e12bb
AL
480}
481
4240abff 482static const TypeInfo pci_unin_main_info = {
57fd7b7f 483 .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE,
8558d942 484 .parent = TYPE_PCI_HOST_BRIDGE,
c90c393c 485 .instance_size = sizeof(UNINHostState),
02034599 486 .instance_init = pci_unin_main_init,
39bffca2 487 .class_init = pci_unin_main_class_init,
70f9c987
AF
488};
489
999e12bb
AL
490static void pci_u3_agp_class_init(ObjectClass *klass, void *data)
491{
1d16f86a 492 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb 493
32cde615 494 dc->realize = pci_u3_agp_realize;
1d16f86a 495 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
999e12bb
AL
496}
497
4240abff 498static const TypeInfo pci_u3_agp_info = {
57fd7b7f 499 .name = TYPE_U3_AGP_HOST_BRIDGE,
8558d942 500 .parent = TYPE_PCI_HOST_BRIDGE,
c90c393c 501 .instance_size = sizeof(UNINHostState),
02034599 502 .instance_init = pci_u3_agp_init,
39bffca2 503 .class_init = pci_u3_agp_class_init,
70f9c987
AF
504};
505
999e12bb
AL
506static void pci_unin_agp_class_init(ObjectClass *klass, void *data)
507{
1d16f86a 508 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb 509
32cde615 510 dc->realize = pci_unin_agp_realize;
1d16f86a 511 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
999e12bb
AL
512}
513
4240abff 514static const TypeInfo pci_unin_agp_info = {
57fd7b7f 515 .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE,
8558d942 516 .parent = TYPE_PCI_HOST_BRIDGE,
c90c393c 517 .instance_size = sizeof(UNINHostState),
02034599 518 .instance_init = pci_unin_agp_init,
39bffca2 519 .class_init = pci_unin_agp_class_init,
70f9c987
AF
520};
521
999e12bb
AL
522static void pci_unin_internal_class_init(ObjectClass *klass, void *data)
523{
1d16f86a 524 DeviceClass *dc = DEVICE_CLASS(klass);
999e12bb 525
1ff861d2 526 dc->realize = pci_unin_internal_realize;
1d16f86a 527 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
999e12bb
AL
528}
529
4240abff 530static const TypeInfo pci_unin_internal_info = {
57fd7b7f 531 .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE,
8558d942 532 .parent = TYPE_PCI_HOST_BRIDGE,
c90c393c 533 .instance_size = sizeof(UNINHostState),
02034599 534 .instance_init = pci_unin_internal_init,
39bffca2 535 .class_init = pci_unin_internal_class_init,
70f9c987
AF
536};
537
0662946a
MCA
538/* UniN device */
539static void unin_write(void *opaque, hwaddr addr, uint64_t value,
540 unsigned size)
541{
542 trace_unin_write(addr, value);
0662946a
MCA
543}
544
545static uint64_t unin_read(void *opaque, hwaddr addr, unsigned size)
546{
547 uint32_t value;
548
0662946a
MCA
549 switch (addr) {
550 case 0:
45fefe7c
MCA
551 value = UNINORTH_VERSION_10A;
552 break;
553 default:
554 value = 0;
0662946a
MCA
555 }
556
557 trace_unin_read(addr, value);
558
559 return value;
560}
561
562static const MemoryRegionOps unin_ops = {
563 .read = unin_read,
564 .write = unin_write,
565 .endianness = DEVICE_BIG_ENDIAN,
566};
567
568static void unin_init(Object *obj)
569{
570 UNINState *s = UNI_NORTH(obj);
571 SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
572
45fefe7c 573 memory_region_init_io(&s->mem, obj, &unin_ops, s, "unin", 0x1000);
0662946a
MCA
574
575 sysbus_init_mmio(sbd, &s->mem);
576}
577
578static void unin_class_init(ObjectClass *klass, void *data)
579{
580 DeviceClass *dc = DEVICE_CLASS(klass);
581
582 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
583}
584
585static const TypeInfo unin_info = {
586 .name = TYPE_UNI_NORTH,
587 .parent = TYPE_SYS_BUS_DEVICE,
588 .instance_size = sizeof(UNINState),
589 .instance_init = unin_init,
590 .class_init = unin_class_init,
591};
592
83f7d43a 593static void unin_register_types(void)
2e29bd04 594{
39bffca2
AL
595 type_register_static(&unin_main_pci_host_info);
596 type_register_static(&u3_agp_pci_host_info);
597 type_register_static(&unin_agp_pci_host_info);
598 type_register_static(&unin_internal_pci_host_info);
599
600 type_register_static(&pci_unin_main_info);
601 type_register_static(&pci_u3_agp_info);
602 type_register_static(&pci_unin_agp_info);
603 type_register_static(&pci_unin_internal_info);
0662946a
MCA
604
605 type_register_static(&unin_info);
502a5395 606}
2e29bd04 607
83f7d43a 608type_init(unin_register_types)
This page took 1.098903 seconds and 4 git commands to generate.