pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * QEMU Uninorth PCI host (for all Mac99 and newer machines) |
| 3 | * |
| 4 | * Copyright (c) 2006 Fabrice Bellard |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 5 | * |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 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 | */ |
Paolo Bonzini | 83c9f4c | 2013-02-04 15:40:22 +0100 | [diff] [blame] | 24 | #include "hw/hw.h" |
| 25 | #include "hw/ppc/mac.h" |
| 26 | #include "hw/pci/pci.h" |
| 27 | #include "hw/pci/pci_host.h" |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 28 | |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 29 | /* debug UniNorth */ |
| 30 | //#define DEBUG_UNIN |
| 31 | |
| 32 | #ifdef DEBUG_UNIN |
Blue Swirl | 001faf3 | 2009-05-13 17:53:17 +0000 | [diff] [blame] | 33 | #define UNIN_DPRINTF(fmt, ...) \ |
| 34 | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 35 | #else |
Blue Swirl | 001faf3 | 2009-05-13 17:53:17 +0000 | [diff] [blame] | 36 | #define UNIN_DPRINTF(fmt, ...) |
blueswir1 | f390238 | 2009-02-05 20:22:07 +0000 | [diff] [blame] | 37 | #endif |
| 38 | |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 39 | static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e }; |
| 40 | |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 41 | #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 Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 55 | typedef struct UNINState { |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 56 | PCIHostState parent_obj; |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 57 | |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 58 | MemoryRegion pci_mmio; |
| 59 | MemoryRegion pci_hole; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 60 | } UNINState; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 61 | |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 62 | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 63 | { |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 64 | int retval; |
| 65 | int devfn = pci_dev->devfn & 0x00FFFFFF; |
| 66 | |
| 67 | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; |
| 68 | |
| 69 | return retval; |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 72 | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
pbrook | d2b5931 | 2006-09-24 00:16:34 +0000 | [diff] [blame] | 73 | { |
Juan Quintela | 5d4e84c | 2009-08-28 15:28:17 +0200 | [diff] [blame] | 74 | qemu_irq *pic = opaque; |
| 75 | |
Alexander Graf | fa0be69 | 2010-02-09 17:37:04 +0100 | [diff] [blame] | 76 | 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); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 81 | static 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 */ |
Stefan Hajnoczi | 5863d37 | 2015-03-23 15:29:25 +0000 | [diff] [blame] | 95 | slot = ctz32(reg & 0xfffff800); |
| 96 | if (slot == 32) { |
| 97 | slot = -1; /* XXX: should this be 0? */ |
| 98 | } |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 99 | func = (reg >> 8) & 7; |
| 100 | |
| 101 | /* ... and then convert them to x86 format */ |
| 102 | /* config pointer */ |
| 103 | retval = (reg & (0xff - 7)) | (addr & 7); |
| 104 | /* slot */ |
| 105 | retval |= slot << 11; |
| 106 | /* fn */ |
| 107 | retval |= func << 8; |
| 108 | } |
| 109 | |
| 110 | |
| 111 | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n", |
| 112 | reg, addr, retval); |
| 113 | |
| 114 | return retval; |
| 115 | } |
| 116 | |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 117 | static void unin_data_write(void *opaque, hwaddr addr, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 118 | uint64_t val, unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 119 | { |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 120 | UNINState *s = opaque; |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 121 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 122 | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
| 123 | addr, len, val); |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 124 | pci_data_write(phb->bus, |
| 125 | unin_get_config_reg(phb->config_reg, addr), |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 126 | val, len); |
| 127 | } |
| 128 | |
Avi Kivity | a8170e5 | 2012-10-23 12:30:10 +0200 | [diff] [blame] | 129 | static uint64_t unin_data_read(void *opaque, hwaddr addr, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 130 | unsigned len) |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 131 | { |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 132 | UNINState *s = opaque; |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 133 | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 134 | uint32_t val; |
| 135 | |
Andreas Färber | 67c332f | 2012-08-20 19:08:09 +0200 | [diff] [blame] | 136 | val = pci_data_read(phb->bus, |
| 137 | unin_get_config_reg(phb->config_reg, addr), |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 138 | len); |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 139 | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
| 140 | addr, len, val); |
Alexander Graf | d86f0e3 | 2010-02-09 17:37:01 +0100 | [diff] [blame] | 141 | return val; |
| 142 | } |
| 143 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 144 | static const MemoryRegionOps unin_data_ops = { |
| 145 | .read = unin_data_read, |
| 146 | .write = unin_data_write, |
| 147 | .endianness = DEVICE_LITTLE_ENDIAN, |
| 148 | }; |
| 149 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 150 | static int pci_unin_main_init_device(SysBusDevice *dev) |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 151 | { |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 152 | PCIHostState *h; |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 153 | |
| 154 | /* Use values found on a real PowerMac */ |
| 155 | /* Uninorth main bus */ |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 156 | h = PCI_HOST_BRIDGE(dev); |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 157 | |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 158 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 159 | dev, "pci-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 160 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, dev, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 161 | "pci-conf-data", 0x1000); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 162 | sysbus_init_mmio(dev, &h->conf_mem); |
| 163 | sysbus_init_mmio(dev, &h->data_mem); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 164 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 165 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 168 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 169 | static int pci_u3_agp_init_device(SysBusDevice *dev) |
| 170 | { |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 171 | PCIHostState *h; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 172 | |
| 173 | /* Uninorth U3 AGP bus */ |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 174 | h = PCI_HOST_BRIDGE(dev); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 175 | |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 176 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 177 | dev, "pci-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 178 | memory_region_init_io(&h->data_mem, OBJECT(h), &unin_data_ops, dev, |
Avi Kivity | d0ed807 | 2011-07-24 17:47:18 +0300 | [diff] [blame] | 179 | "pci-conf-data", 0x1000); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 180 | sysbus_init_mmio(dev, &h->conf_mem); |
| 181 | sysbus_init_mmio(dev, &h->data_mem); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 182 | |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 183 | return 0; |
| 184 | } |
| 185 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 186 | static int pci_unin_agp_init_device(SysBusDevice *dev) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 187 | { |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 188 | PCIHostState *h; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 189 | |
| 190 | /* Uninorth AGP bus */ |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 191 | h = PCI_HOST_BRIDGE(dev); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 192 | |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 193 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 194 | dev, "pci-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 195 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 196 | dev, "pci-conf-data", 0x1000); |
| 197 | sysbus_init_mmio(dev, &h->conf_mem); |
| 198 | sysbus_init_mmio(dev, &h->data_mem); |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 199 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 202 | static int pci_unin_internal_init_device(SysBusDevice *dev) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 203 | { |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 204 | PCIHostState *h; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 205 | |
| 206 | /* Uninorth internal bus */ |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 207 | h = PCI_HOST_BRIDGE(dev); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 208 | |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 209 | memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 210 | dev, "pci-conf-idx", 0x1000); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 211 | memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 212 | dev, "pci-conf-data", 0x1000); |
| 213 | sysbus_init_mmio(dev, &h->conf_mem); |
| 214 | sysbus_init_mmio(dev, &h->data_mem); |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 215 | return 0; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 218 | PCIBus *pci_pmac_init(qemu_irq *pic, |
| 219 | MemoryRegion *address_space_mem, |
| 220 | MemoryRegion *address_space_io) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 221 | { |
| 222 | DeviceState *dev; |
| 223 | SysBusDevice *s; |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 224 | PCIHostState *h; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 225 | UNINState *d; |
| 226 | |
| 227 | /* Use values found on a real PowerMac */ |
| 228 | /* Uninorth main bus */ |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 229 | dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE); |
Markus Armbruster | e23a1b3 | 2009-10-07 01:15:58 +0200 | [diff] [blame] | 230 | qdev_init_nofail(dev); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 231 | s = SYS_BUS_DEVICE(dev); |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 232 | h = PCI_HOST_BRIDGE(s); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 233 | d = UNI_NORTH_PCI_HOST_BRIDGE(dev); |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 234 | memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); |
| 235 | memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, |
BALATON Zoltan | 1be8825 | 2014-06-23 21:10:59 +0200 | [diff] [blame] | 236 | 0x80000000ULL, 0x10000000ULL); |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 237 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, |
| 238 | &d->pci_hole); |
| 239 | |
Alexander Graf | 8a0e110 | 2013-12-04 12:42:32 +0100 | [diff] [blame] | 240 | h->bus = pci_register_bus(dev, NULL, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 241 | pci_unin_set_irq, pci_unin_map_irq, |
| 242 | pic, |
| 243 | &d->pci_mmio, |
| 244 | address_space_io, |
Alex Williamson | 60a0e44 | 2013-03-14 16:01:11 -0600 | [diff] [blame] | 245 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 246 | |
Blue Swirl | 6039874 | 2009-11-15 14:30:56 +0000 | [diff] [blame] | 247 | #if 0 |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 248 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north"); |
Blue Swirl | 6039874 | 2009-11-15 14:30:56 +0000 | [diff] [blame] | 249 | #endif |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 250 | |
| 251 | sysbus_mmio_map(s, 0, 0xf2800000); |
| 252 | sysbus_mmio_map(s, 1, 0xf2c00000); |
| 253 | |
| 254 | /* DEC 21154 bridge */ |
| 255 | #if 0 |
| 256 | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */ |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 257 | pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154"); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 258 | #endif |
| 259 | |
| 260 | /* Uninorth AGP bus */ |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 261 | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
| 262 | dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 263 | qdev_init_nofail(dev); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 264 | s = SYS_BUS_DEVICE(dev); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 265 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 266 | sysbus_mmio_map(s, 1, 0xf0c00000); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 267 | |
| 268 | /* Uninorth internal bus */ |
| 269 | #if 0 |
| 270 | /* XXX: not needed for now */ |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 271 | pci_create_simple(h->bus, PCI_DEVFN(14, 0), |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 272 | "uni-north-internal-pci"); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 273 | dev = qdev_create(NULL, TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 274 | qdev_init_nofail(dev); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 275 | s = SYS_BUS_DEVICE(dev); |
Blue Swirl | d27d06f | 2009-11-15 17:42:17 +0000 | [diff] [blame] | 276 | sysbus_mmio_map(s, 0, 0xf4800000); |
| 277 | sysbus_mmio_map(s, 1, 0xf4c00000); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 278 | #endif |
| 279 | |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 280 | return h->bus; |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Avi Kivity | aee97b8 | 2011-08-08 16:09:04 +0300 | [diff] [blame] | 283 | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
| 284 | MemoryRegion *address_space_mem, |
| 285 | MemoryRegion *address_space_io) |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 286 | { |
| 287 | DeviceState *dev; |
| 288 | SysBusDevice *s; |
Andreas Färber | ff452ac | 2012-01-19 07:40:17 +0000 | [diff] [blame] | 289 | PCIHostState *h; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 290 | UNINState *d; |
| 291 | |
| 292 | /* Uninorth AGP bus */ |
| 293 | |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 294 | dev = qdev_create(NULL, TYPE_U3_AGP_HOST_BRIDGE); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 295 | qdev_init_nofail(dev); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 296 | s = SYS_BUS_DEVICE(dev); |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 297 | h = PCI_HOST_BRIDGE(dev); |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 298 | d = U3_AGP_HOST_BRIDGE(dev); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 299 | |
Paolo Bonzini | 40c5dce | 2013-06-06 21:25:08 -0400 | [diff] [blame] | 300 | memory_region_init(&d->pci_mmio, OBJECT(d), "pci-mmio", 0x100000000ULL); |
| 301 | memory_region_init_alias(&d->pci_hole, OBJECT(d), "pci-hole", &d->pci_mmio, |
Blue Swirl | 46f3069 | 2011-09-17 20:30:50 +0000 | [diff] [blame] | 302 | 0x80000000ULL, 0x70000000ULL); |
| 303 | memory_region_add_subregion(address_space_mem, 0x80000000ULL, |
| 304 | &d->pci_hole); |
| 305 | |
Alexander Graf | 8a0e110 | 2013-12-04 12:42:32 +0100 | [diff] [blame] | 306 | h->bus = pci_register_bus(dev, NULL, |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 307 | pci_unin_set_irq, pci_unin_map_irq, |
| 308 | pic, |
| 309 | &d->pci_mmio, |
| 310 | address_space_io, |
Alex Williamson | 60a0e44 | 2013-03-14 16:01:11 -0600 | [diff] [blame] | 311 | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 312 | |
| 313 | sysbus_mmio_map(s, 0, 0xf0800000); |
| 314 | sysbus_mmio_map(s, 1, 0xf0c00000); |
| 315 | |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 316 | pci_create_simple(h->bus, 11 << 3, "u3-agp"); |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 317 | |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 318 | return h->bus; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 321 | static void unin_main_pci_host_realize(PCIDevice *d, Error **errp) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 322 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 323 | d->config[0x0C] = 0x08; // cache_line_size |
| 324 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 325 | d->config[0x34] = 0x00; // capabilities_pointer |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 326 | } |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 327 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 328 | static void unin_agp_pci_host_realize(PCIDevice *d, Error **errp) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 329 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 330 | d->config[0x0C] = 0x08; // cache_line_size |
| 331 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 332 | // d->config[0x34] = 0x80; // capabilities_pointer |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 333 | } |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 334 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 335 | static void u3_agp_pci_host_realize(PCIDevice *d, Error **errp) |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 336 | { |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 337 | /* cache line size */ |
| 338 | d->config[0x0C] = 0x08; |
| 339 | /* latency timer */ |
| 340 | d->config[0x0D] = 0x10; |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 341 | } |
| 342 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 343 | static void unin_internal_pci_host_realize(PCIDevice *d, Error **errp) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 344 | { |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 345 | d->config[0x0C] = 0x08; // cache_line_size |
| 346 | d->config[0x0D] = 0x10; // latency_timer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 347 | d->config[0x34] = 0x00; // capabilities_pointer |
pbrook | 502a539 | 2006-05-13 16:11:23 +0000 | [diff] [blame] | 348 | } |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 349 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 350 | static void unin_main_pci_host_class_init(ObjectClass *klass, void *data) |
| 351 | { |
| 352 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 353 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 354 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 355 | k->realize = unin_main_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 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; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 360 | /* |
| 361 | * PCI-facing part of the host bridge, not usable without the |
| 362 | * host-facing part, which can't be device_add'ed, yet. |
| 363 | */ |
| 364 | dc->cannot_instantiate_with_device_add_yet = true; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 365 | } |
| 366 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 367 | static const TypeInfo unin_main_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 368 | .name = "uni-north-pci", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 369 | .parent = TYPE_PCI_DEVICE, |
| 370 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 371 | .class_init = unin_main_pci_host_class_init, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 372 | }; |
| 373 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 374 | static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data) |
| 375 | { |
| 376 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 377 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 378 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 379 | k->realize = u3_agp_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 380 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 381 | k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP; |
| 382 | k->revision = 0x00; |
| 383 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 384 | /* |
| 385 | * PCI-facing part of the host bridge, not usable without the |
| 386 | * host-facing part, which can't be device_add'ed, yet. |
| 387 | */ |
| 388 | dc->cannot_instantiate_with_device_add_yet = true; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 389 | } |
| 390 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 391 | static const TypeInfo u3_agp_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 392 | .name = "u3-agp", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 393 | .parent = TYPE_PCI_DEVICE, |
| 394 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 395 | .class_init = u3_agp_pci_host_class_init, |
Alexander Graf | 0f92119 | 2010-02-09 17:37:02 +0100 | [diff] [blame] | 396 | }; |
| 397 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 398 | static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data) |
| 399 | { |
| 400 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 401 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 402 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 403 | k->realize = unin_agp_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 404 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 405 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP; |
| 406 | k->revision = 0x00; |
| 407 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 408 | /* |
| 409 | * PCI-facing part of the host bridge, not usable without the |
| 410 | * host-facing part, which can't be device_add'ed, yet. |
| 411 | */ |
| 412 | dc->cannot_instantiate_with_device_add_yet = true; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 413 | } |
| 414 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 415 | static const TypeInfo unin_agp_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 416 | .name = "uni-north-agp", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 417 | .parent = TYPE_PCI_DEVICE, |
| 418 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 419 | .class_init = unin_agp_pci_host_class_init, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 420 | }; |
| 421 | |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 422 | static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data) |
| 423 | { |
| 424 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 425 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 426 | |
Markus Armbruster | 9af21db | 2015-01-19 15:52:30 +0100 | [diff] [blame] | 427 | k->realize = unin_internal_pci_host_realize; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 428 | k->vendor_id = PCI_VENDOR_ID_APPLE; |
| 429 | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI; |
| 430 | k->revision = 0x00; |
| 431 | k->class_id = PCI_CLASS_BRIDGE_HOST; |
Markus Armbruster | 08c58f9 | 2013-11-28 17:26:58 +0100 | [diff] [blame] | 432 | /* |
| 433 | * PCI-facing part of the host bridge, not usable without the |
| 434 | * host-facing part, which can't be device_add'ed, yet. |
| 435 | */ |
| 436 | dc->cannot_instantiate_with_device_add_yet = true; |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 437 | } |
| 438 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 439 | static const TypeInfo unin_internal_pci_host_info = { |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 440 | .name = "uni-north-internal-pci", |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 441 | .parent = TYPE_PCI_DEVICE, |
| 442 | .instance_size = sizeof(PCIDevice), |
Anthony Liguori | 40021f0 | 2011-12-04 12:22:06 -0600 | [diff] [blame] | 443 | .class_init = unin_internal_pci_host_class_init, |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 444 | }; |
| 445 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 446 | static void pci_unin_main_class_init(ObjectClass *klass, void *data) |
| 447 | { |
| 448 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 449 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 450 | |
| 451 | sbc->init = pci_unin_main_init_device; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 452 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 453 | } |
| 454 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 455 | static const TypeInfo pci_unin_main_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 456 | .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 457 | .parent = TYPE_PCI_HOST_BRIDGE, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 458 | .instance_size = sizeof(UNINState), |
| 459 | .class_init = pci_unin_main_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 460 | }; |
| 461 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 462 | static void pci_u3_agp_class_init(ObjectClass *klass, void *data) |
| 463 | { |
| 464 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 465 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 466 | |
| 467 | sbc->init = pci_u3_agp_init_device; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 468 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 469 | } |
| 470 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 471 | static const TypeInfo pci_u3_agp_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 472 | .name = TYPE_U3_AGP_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 473 | .parent = TYPE_PCI_HOST_BRIDGE, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 474 | .instance_size = sizeof(UNINState), |
| 475 | .class_init = pci_u3_agp_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 476 | }; |
| 477 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 478 | static void pci_unin_agp_class_init(ObjectClass *klass, void *data) |
| 479 | { |
| 480 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 481 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 482 | |
| 483 | sbc->init = pci_unin_agp_init_device; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 484 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 485 | } |
| 486 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 487 | static const TypeInfo pci_unin_agp_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 488 | .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 489 | .parent = TYPE_PCI_HOST_BRIDGE, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 490 | .instance_size = sizeof(UNINState), |
| 491 | .class_init = pci_unin_agp_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 492 | }; |
| 493 | |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 494 | static void pci_unin_internal_class_init(ObjectClass *klass, void *data) |
| 495 | { |
| 496 | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 497 | DeviceClass *dc = DEVICE_CLASS(klass); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 498 | |
| 499 | sbc->init = pci_unin_internal_init_device; |
Laurent Vivier | 1d16f86 | 2015-09-26 18:22:09 +0200 | [diff] [blame] | 500 | set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 501 | } |
| 502 | |
Andreas Färber | 4240abf | 2012-08-20 19:07:56 +0200 | [diff] [blame] | 503 | static const TypeInfo pci_unin_internal_info = { |
Andreas Färber | 57fd7b7 | 2012-08-20 19:08:06 +0200 | [diff] [blame] | 504 | .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE, |
Andreas Färber | 8558d94 | 2012-08-20 19:08:08 +0200 | [diff] [blame] | 505 | .parent = TYPE_PCI_HOST_BRIDGE, |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 506 | .instance_size = sizeof(UNINState), |
| 507 | .class_init = pci_unin_internal_class_init, |
Andreas Färber | 70f9c98 | 2012-01-19 07:40:16 +0000 | [diff] [blame] | 508 | }; |
| 509 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 510 | static void unin_register_types(void) |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 511 | { |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 512 | type_register_static(&unin_main_pci_host_info); |
| 513 | type_register_static(&u3_agp_pci_host_info); |
| 514 | type_register_static(&unin_agp_pci_host_info); |
| 515 | type_register_static(&unin_internal_pci_host_info); |
Anthony Liguori | 999e12b | 2012-01-24 13:12:29 -0600 | [diff] [blame] | 516 | |
Anthony Liguori | 39bffca | 2011-12-07 21:34:16 -0600 | [diff] [blame] | 517 | type_register_static(&pci_unin_main_info); |
| 518 | type_register_static(&pci_u3_agp_info); |
| 519 | type_register_static(&pci_unin_agp_info); |
| 520 | type_register_static(&pci_unin_internal_info); |
Blue Swirl | 2e29bd0 | 2009-07-31 20:23:28 +0000 | [diff] [blame] | 521 | } |
| 522 | |
Andreas Färber | 83f7d43 | 2012-02-09 15:20:55 +0100 | [diff] [blame] | 523 | type_init(unin_register_types) |