root / hw / pci-host / uninorth.c @ a8aec295
History | View | Annotate | Download (14.7 kB)
1 | 502a5395 | pbrook | /*
|
---|---|---|---|
2 | 502a5395 | pbrook | * QEMU Uninorth PCI host (for all Mac99 and newer machines)
|
3 | 502a5395 | pbrook | *
|
4 | 502a5395 | pbrook | * Copyright (c) 2006 Fabrice Bellard
|
5 | 5fafdf24 | ths | *
|
6 | 502a5395 | pbrook | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 502a5395 | pbrook | * of this software and associated documentation files (the "Software"), to deal
|
8 | 502a5395 | pbrook | * in the Software without restriction, including without limitation the rights
|
9 | 502a5395 | pbrook | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 502a5395 | pbrook | * copies of the Software, and to permit persons to whom the Software is
|
11 | 502a5395 | pbrook | * furnished to do so, subject to the following conditions:
|
12 | 502a5395 | pbrook | *
|
13 | 502a5395 | pbrook | * The above copyright notice and this permission notice shall be included in
|
14 | 502a5395 | pbrook | * all copies or substantial portions of the Software.
|
15 | 502a5395 | pbrook | *
|
16 | 502a5395 | pbrook | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 502a5395 | pbrook | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 502a5395 | pbrook | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 502a5395 | pbrook | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 502a5395 | pbrook | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 502a5395 | pbrook | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 502a5395 | pbrook | * THE SOFTWARE.
|
23 | 502a5395 | pbrook | */
|
24 | 83c9f4ca | Paolo Bonzini | #include "hw/hw.h" |
25 | 83c9f4ca | Paolo Bonzini | #include "hw/ppc/mac.h" |
26 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci.h" |
27 | 83c9f4ca | Paolo Bonzini | #include "hw/pci/pci_host.h" |
28 | 87ecb68b | pbrook | |
29 | f3902383 | blueswir1 | /* debug UniNorth */
|
30 | f3902383 | blueswir1 | //#define DEBUG_UNIN
|
31 | f3902383 | blueswir1 | |
32 | f3902383 | blueswir1 | #ifdef DEBUG_UNIN
|
33 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...) \
|
34 | 001faf32 | Blue Swirl | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) |
35 | f3902383 | blueswir1 | #else
|
36 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...)
|
37 | f3902383 | blueswir1 | #endif
|
38 | f3902383 | blueswir1 | |
39 | fa0be69a | Alexander Graf | static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e }; |
40 | fa0be69a | Alexander Graf | |
41 | 57fd7b7f | Andreas Färber | #define TYPE_UNI_NORTH_PCI_HOST_BRIDGE "uni-north-pci-pcihost" |
42 | 57fd7b7f | Andreas Färber | #define TYPE_UNI_NORTH_AGP_HOST_BRIDGE "uni-north-agp-pcihost" |
43 | 57fd7b7f | Andreas Färber | #define TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE "uni-north-internal-pci-pcihost" |
44 | 57fd7b7f | Andreas Färber | #define TYPE_U3_AGP_HOST_BRIDGE "u3-agp-pcihost" |
45 | 57fd7b7f | Andreas Färber | |
46 | 57fd7b7f | Andreas Färber | #define UNI_NORTH_PCI_HOST_BRIDGE(obj) \
|
47 | 57fd7b7f | Andreas Färber | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_PCI_HOST_BRIDGE) |
48 | 57fd7b7f | Andreas Färber | #define UNI_NORTH_AGP_HOST_BRIDGE(obj) \
|
49 | 57fd7b7f | Andreas Färber | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_AGP_HOST_BRIDGE) |
50 | 57fd7b7f | Andreas Färber | #define UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE(obj) \
|
51 | 57fd7b7f | Andreas Färber | OBJECT_CHECK(UNINState, (obj), TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE) |
52 | 57fd7b7f | Andreas Färber | #define U3_AGP_HOST_BRIDGE(obj) \
|
53 | 57fd7b7f | Andreas Färber | OBJECT_CHECK(UNINState, (obj), TYPE_U3_AGP_HOST_BRIDGE) |
54 | 57fd7b7f | Andreas Färber | |
55 | 2e29bd04 | Blue Swirl | typedef struct UNINState { |
56 | 67c332fd | Andreas Färber | PCIHostState parent_obj; |
57 | 57fd7b7f | Andreas Färber | |
58 | 46f3069c | Blue Swirl | MemoryRegion pci_mmio; |
59 | 46f3069c | Blue Swirl | MemoryRegion pci_hole; |
60 | 2e29bd04 | Blue Swirl | } UNINState; |
61 | 502a5395 | pbrook | |
62 | d2b59317 | pbrook | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
63 | 502a5395 | pbrook | { |
64 | fa0be69a | Alexander Graf | int retval;
|
65 | fa0be69a | Alexander Graf | int devfn = pci_dev->devfn & 0x00FFFFFF; |
66 | fa0be69a | Alexander Graf | |
67 | fa0be69a | Alexander Graf | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; |
68 | fa0be69a | Alexander Graf | |
69 | fa0be69a | Alexander Graf | return retval;
|
70 | d2b59317 | pbrook | } |
71 | d2b59317 | pbrook | |
72 | 5d4e84c8 | Juan Quintela | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
73 | d2b59317 | pbrook | { |
74 | 5d4e84c8 | Juan Quintela | qemu_irq *pic = opaque; |
75 | 5d4e84c8 | Juan Quintela | |
76 | fa0be69a | Alexander Graf | UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
|
77 | fa0be69a | Alexander Graf | unin_irq_line[irq_num], level); |
78 | fa0be69a | Alexander Graf | qemu_set_irq(pic[unin_irq_line[irq_num]], level); |
79 | 502a5395 | pbrook | } |
80 | 502a5395 | pbrook | |
81 | d86f0e32 | Alexander Graf | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
|
82 | d86f0e32 | Alexander Graf | { |
83 | d86f0e32 | Alexander Graf | uint32_t retval; |
84 | d86f0e32 | Alexander Graf | |
85 | d86f0e32 | Alexander Graf | if (reg & (1u << 31)) { |
86 | d86f0e32 | Alexander Graf | /* XXX OpenBIOS compatibility hack */
|
87 | d86f0e32 | Alexander Graf | retval = reg | (addr & 3);
|
88 | d86f0e32 | Alexander Graf | } else if (reg & 1) { |
89 | d86f0e32 | Alexander Graf | /* CFA1 style */
|
90 | d86f0e32 | Alexander Graf | retval = (reg & ~7u) | (addr & 7); |
91 | d86f0e32 | Alexander Graf | } else {
|
92 | d86f0e32 | Alexander Graf | uint32_t slot, func; |
93 | d86f0e32 | Alexander Graf | |
94 | d86f0e32 | Alexander Graf | /* Grab CFA0 style values */
|
95 | d86f0e32 | Alexander Graf | slot = ffs(reg & 0xfffff800) - 1; |
96 | d86f0e32 | Alexander Graf | func = (reg >> 8) & 7; |
97 | d86f0e32 | Alexander Graf | |
98 | d86f0e32 | Alexander Graf | /* ... and then convert them to x86 format */
|
99 | d86f0e32 | Alexander Graf | /* config pointer */
|
100 | d86f0e32 | Alexander Graf | retval = (reg & (0xff - 7)) | (addr & 7); |
101 | d86f0e32 | Alexander Graf | /* slot */
|
102 | d86f0e32 | Alexander Graf | retval |= slot << 11;
|
103 | d86f0e32 | Alexander Graf | /* fn */
|
104 | d86f0e32 | Alexander Graf | retval |= func << 8;
|
105 | d86f0e32 | Alexander Graf | } |
106 | d86f0e32 | Alexander Graf | |
107 | d86f0e32 | Alexander Graf | |
108 | d86f0e32 | Alexander Graf | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
|
109 | d86f0e32 | Alexander Graf | reg, addr, retval); |
110 | d86f0e32 | Alexander Graf | |
111 | d86f0e32 | Alexander Graf | return retval;
|
112 | d86f0e32 | Alexander Graf | } |
113 | d86f0e32 | Alexander Graf | |
114 | a8170e5e | Avi Kivity | static void unin_data_write(void *opaque, hwaddr addr, |
115 | d0ed8076 | Avi Kivity | uint64_t val, unsigned len)
|
116 | d86f0e32 | Alexander Graf | { |
117 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
118 | 67c332fd | Andreas Färber | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
119 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
120 | d0ed8076 | Avi Kivity | addr, len, val); |
121 | 67c332fd | Andreas Färber | pci_data_write(phb->bus, |
122 | 67c332fd | Andreas Färber | unin_get_config_reg(phb->config_reg, addr), |
123 | d86f0e32 | Alexander Graf | val, len); |
124 | d86f0e32 | Alexander Graf | } |
125 | d86f0e32 | Alexander Graf | |
126 | a8170e5e | Avi Kivity | static uint64_t unin_data_read(void *opaque, hwaddr addr, |
127 | d0ed8076 | Avi Kivity | unsigned len)
|
128 | d86f0e32 | Alexander Graf | { |
129 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
130 | 67c332fd | Andreas Färber | PCIHostState *phb = PCI_HOST_BRIDGE(s); |
131 | d86f0e32 | Alexander Graf | uint32_t val; |
132 | d86f0e32 | Alexander Graf | |
133 | 67c332fd | Andreas Färber | val = pci_data_read(phb->bus, |
134 | 67c332fd | Andreas Färber | unin_get_config_reg(phb->config_reg, addr), |
135 | d86f0e32 | Alexander Graf | len); |
136 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
137 | d0ed8076 | Avi Kivity | addr, len, val); |
138 | d86f0e32 | Alexander Graf | return val;
|
139 | d86f0e32 | Alexander Graf | } |
140 | d86f0e32 | Alexander Graf | |
141 | d0ed8076 | Avi Kivity | static const MemoryRegionOps unin_data_ops = { |
142 | d0ed8076 | Avi Kivity | .read = unin_data_read, |
143 | d0ed8076 | Avi Kivity | .write = unin_data_write, |
144 | d0ed8076 | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN, |
145 | d0ed8076 | Avi Kivity | }; |
146 | d0ed8076 | Avi Kivity | |
147 | 81a322d4 | Gerd Hoffmann | static int pci_unin_main_init_device(SysBusDevice *dev) |
148 | 502a5395 | pbrook | { |
149 | ff452ace | Andreas Färber | PCIHostState *h; |
150 | 502a5395 | pbrook | |
151 | 502a5395 | pbrook | /* Use values found on a real PowerMac */
|
152 | 502a5395 | pbrook | /* Uninorth main bus */
|
153 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(dev); |
154 | 502a5395 | pbrook | |
155 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops, |
156 | 57fd7b7f | Andreas Färber | dev, "pci-conf-idx", 0x1000); |
157 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->data_mem, &unin_data_ops, dev, |
158 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
159 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->conf_mem); |
160 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->data_mem); |
161 | 2e29bd04 | Blue Swirl | |
162 | 81a322d4 | Gerd Hoffmann | return 0; |
163 | 2e29bd04 | Blue Swirl | } |
164 | 2e29bd04 | Blue Swirl | |
165 | d0ed8076 | Avi Kivity | |
166 | 0f921197 | Alexander Graf | static int pci_u3_agp_init_device(SysBusDevice *dev) |
167 | 0f921197 | Alexander Graf | { |
168 | ff452ace | Andreas Färber | PCIHostState *h; |
169 | 0f921197 | Alexander Graf | |
170 | 0f921197 | Alexander Graf | /* Uninorth U3 AGP bus */
|
171 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(dev); |
172 | 0f921197 | Alexander Graf | |
173 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops, |
174 | 57fd7b7f | Andreas Färber | dev, "pci-conf-idx", 0x1000); |
175 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->data_mem, &unin_data_ops, dev, |
176 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
177 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->conf_mem); |
178 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->data_mem); |
179 | 0f921197 | Alexander Graf | |
180 | 0f921197 | Alexander Graf | return 0; |
181 | 0f921197 | Alexander Graf | } |
182 | 0f921197 | Alexander Graf | |
183 | 81a322d4 | Gerd Hoffmann | static int pci_unin_agp_init_device(SysBusDevice *dev) |
184 | 2e29bd04 | Blue Swirl | { |
185 | ff452ace | Andreas Färber | PCIHostState *h; |
186 | 2e29bd04 | Blue Swirl | |
187 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
188 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(dev); |
189 | 57fd7b7f | Andreas Färber | |
190 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops, |
191 | 57fd7b7f | Andreas Färber | dev, "pci-conf-idx", 0x1000); |
192 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->data_mem, &pci_host_data_le_ops, |
193 | 57fd7b7f | Andreas Färber | dev, "pci-conf-data", 0x1000); |
194 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->conf_mem); |
195 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->data_mem); |
196 | 81a322d4 | Gerd Hoffmann | return 0; |
197 | 2e29bd04 | Blue Swirl | } |
198 | 2e29bd04 | Blue Swirl | |
199 | 81a322d4 | Gerd Hoffmann | static int pci_unin_internal_init_device(SysBusDevice *dev) |
200 | 2e29bd04 | Blue Swirl | { |
201 | ff452ace | Andreas Färber | PCIHostState *h; |
202 | 2e29bd04 | Blue Swirl | |
203 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
204 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(dev); |
205 | 57fd7b7f | Andreas Färber | |
206 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops, |
207 | 57fd7b7f | Andreas Färber | dev, "pci-conf-idx", 0x1000); |
208 | 57fd7b7f | Andreas Färber | memory_region_init_io(&h->data_mem, &pci_host_data_le_ops, |
209 | 57fd7b7f | Andreas Färber | dev, "pci-conf-data", 0x1000); |
210 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->conf_mem); |
211 | 57fd7b7f | Andreas Färber | sysbus_init_mmio(dev, &h->data_mem); |
212 | 81a322d4 | Gerd Hoffmann | return 0; |
213 | 2e29bd04 | Blue Swirl | } |
214 | 2e29bd04 | Blue Swirl | |
215 | aee97b84 | Avi Kivity | PCIBus *pci_pmac_init(qemu_irq *pic, |
216 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
217 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io) |
218 | 2e29bd04 | Blue Swirl | { |
219 | 2e29bd04 | Blue Swirl | DeviceState *dev; |
220 | 2e29bd04 | Blue Swirl | SysBusDevice *s; |
221 | ff452ace | Andreas Färber | PCIHostState *h; |
222 | 2e29bd04 | Blue Swirl | UNINState *d; |
223 | 2e29bd04 | Blue Swirl | |
224 | 2e29bd04 | Blue Swirl | /* Use values found on a real PowerMac */
|
225 | 2e29bd04 | Blue Swirl | /* Uninorth main bus */
|
226 | 57fd7b7f | Andreas Färber | dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE);
|
227 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
228 | 57fd7b7f | Andreas Färber | s = SYS_BUS_DEVICE(dev); |
229 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(s); |
230 | 57fd7b7f | Andreas Färber | d = UNI_NORTH_PCI_HOST_BRIDGE(dev); |
231 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
232 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
233 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
234 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
235 | 46f3069c | Blue Swirl | &d->pci_hole); |
236 | 46f3069c | Blue Swirl | |
237 | 57fd7b7f | Andreas Färber | h->bus = pci_register_bus(dev, "pci",
|
238 | 57fd7b7f | Andreas Färber | pci_unin_set_irq, pci_unin_map_irq, |
239 | 57fd7b7f | Andreas Färber | pic, |
240 | 57fd7b7f | Andreas Färber | &d->pci_mmio, |
241 | 57fd7b7f | Andreas Färber | address_space_io, |
242 | 60a0e443 | Alex Williamson | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
243 | 2e29bd04 | Blue Swirl | |
244 | 60398748 | Blue Swirl | #if 0
|
245 | 57fd7b7f | Andreas Färber | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north");
|
246 | 60398748 | Blue Swirl | #endif
|
247 | 2e29bd04 | Blue Swirl | |
248 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf2800000); |
249 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf2c00000); |
250 | 2e29bd04 | Blue Swirl | |
251 | 2e29bd04 | Blue Swirl | /* DEC 21154 bridge */
|
252 | 2e29bd04 | Blue Swirl | #if 0
|
253 | 2e29bd04 | Blue Swirl | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
|
254 | 57fd7b7f | Andreas Färber | pci_create_simple(h->bus, PCI_DEVFN(12, 0), "dec-21154");
|
255 | 2e29bd04 | Blue Swirl | #endif
|
256 | 2e29bd04 | Blue Swirl | |
257 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
258 | 57fd7b7f | Andreas Färber | pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
259 | 57fd7b7f | Andreas Färber | dev = qdev_create(NULL, TYPE_UNI_NORTH_AGP_HOST_BRIDGE);
|
260 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev); |
261 | 57fd7b7f | Andreas Färber | s = SYS_BUS_DEVICE(dev); |
262 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf0800000); |
263 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf0c00000); |
264 | 2e29bd04 | Blue Swirl | |
265 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
266 | 2e29bd04 | Blue Swirl | #if 0
|
267 | 2e29bd04 | Blue Swirl | /* XXX: not needed for now */
|
268 | 57fd7b7f | Andreas Färber | pci_create_simple(h->bus, PCI_DEVFN(14, 0),
|
269 | 70f9c987 | Andreas Färber | "uni-north-internal-pci");
|
270 | 57fd7b7f | Andreas Färber | dev = qdev_create(NULL, TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE);
|
271 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev);
|
272 | 57fd7b7f | Andreas Färber | s = SYS_BUS_DEVICE(dev);
|
273 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf4800000);
|
274 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf4c00000);
|
275 | 2e29bd04 | Blue Swirl | #endif
|
276 | 2e29bd04 | Blue Swirl | |
277 | 57fd7b7f | Andreas Färber | return h->bus;
|
278 | 2e29bd04 | Blue Swirl | } |
279 | 2e29bd04 | Blue Swirl | |
280 | aee97b84 | Avi Kivity | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
281 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
282 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io) |
283 | 0f921197 | Alexander Graf | { |
284 | 0f921197 | Alexander Graf | DeviceState *dev; |
285 | 0f921197 | Alexander Graf | SysBusDevice *s; |
286 | ff452ace | Andreas Färber | PCIHostState *h; |
287 | 0f921197 | Alexander Graf | UNINState *d; |
288 | 0f921197 | Alexander Graf | |
289 | 0f921197 | Alexander Graf | /* Uninorth AGP bus */
|
290 | 0f921197 | Alexander Graf | |
291 | 57fd7b7f | Andreas Färber | dev = qdev_create(NULL, TYPE_U3_AGP_HOST_BRIDGE);
|
292 | 0f921197 | Alexander Graf | qdev_init_nofail(dev); |
293 | 57fd7b7f | Andreas Färber | s = SYS_BUS_DEVICE(dev); |
294 | 8558d942 | Andreas Färber | h = PCI_HOST_BRIDGE(dev); |
295 | 57fd7b7f | Andreas Färber | d = U3_AGP_HOST_BRIDGE(dev); |
296 | 0f921197 | Alexander Graf | |
297 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
298 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
299 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
300 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
301 | 46f3069c | Blue Swirl | &d->pci_hole); |
302 | 46f3069c | Blue Swirl | |
303 | 57fd7b7f | Andreas Färber | h->bus = pci_register_bus(dev, "pci",
|
304 | 57fd7b7f | Andreas Färber | pci_unin_set_irq, pci_unin_map_irq, |
305 | 57fd7b7f | Andreas Färber | pic, |
306 | 57fd7b7f | Andreas Färber | &d->pci_mmio, |
307 | 57fd7b7f | Andreas Färber | address_space_io, |
308 | 60a0e443 | Alex Williamson | PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS); |
309 | 0f921197 | Alexander Graf | |
310 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 0, 0xf0800000); |
311 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 1, 0xf0c00000); |
312 | 0f921197 | Alexander Graf | |
313 | 57fd7b7f | Andreas Färber | pci_create_simple(h->bus, 11 << 3, "u3-agp"); |
314 | 0f921197 | Alexander Graf | |
315 | 57fd7b7f | Andreas Färber | return h->bus;
|
316 | 0f921197 | Alexander Graf | } |
317 | 0f921197 | Alexander Graf | |
318 | 81a322d4 | Gerd Hoffmann | static int unin_main_pci_host_init(PCIDevice *d) |
319 | 2e29bd04 | Blue Swirl | { |
320 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
321 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
322 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
323 | 81a322d4 | Gerd Hoffmann | return 0; |
324 | 2e29bd04 | Blue Swirl | } |
325 | 502a5395 | pbrook | |
326 | 81a322d4 | Gerd Hoffmann | static int unin_agp_pci_host_init(PCIDevice *d) |
327 | 2e29bd04 | Blue Swirl | { |
328 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
329 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
330 | 502a5395 | pbrook | // d->config[0x34] = 0x80; // capabilities_pointer
|
331 | 81a322d4 | Gerd Hoffmann | return 0; |
332 | 2e29bd04 | Blue Swirl | } |
333 | 502a5395 | pbrook | |
334 | 0f921197 | Alexander Graf | static int u3_agp_pci_host_init(PCIDevice *d) |
335 | 0f921197 | Alexander Graf | { |
336 | 0f921197 | Alexander Graf | /* cache line size */
|
337 | 0f921197 | Alexander Graf | d->config[0x0C] = 0x08; |
338 | 0f921197 | Alexander Graf | /* latency timer */
|
339 | 0f921197 | Alexander Graf | d->config[0x0D] = 0x10; |
340 | 0f921197 | Alexander Graf | return 0; |
341 | 0f921197 | Alexander Graf | } |
342 | 0f921197 | Alexander Graf | |
343 | 81a322d4 | Gerd Hoffmann | static int unin_internal_pci_host_init(PCIDevice *d) |
344 | 2e29bd04 | Blue Swirl | { |
345 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
346 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
347 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
348 | 81a322d4 | Gerd Hoffmann | return 0; |
349 | 2e29bd04 | Blue Swirl | } |
350 | 2e29bd04 | Blue Swirl | |
351 | 40021f08 | Anthony Liguori | static void unin_main_pci_host_class_init(ObjectClass *klass, void *data) |
352 | 40021f08 | Anthony Liguori | { |
353 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
354 | 40021f08 | Anthony Liguori | |
355 | 40021f08 | Anthony Liguori | k->init = unin_main_pci_host_init; |
356 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
357 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI; |
358 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
359 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
360 | 40021f08 | Anthony Liguori | } |
361 | 40021f08 | Anthony Liguori | |
362 | 4240abff | Andreas Färber | static const TypeInfo unin_main_pci_host_info = { |
363 | 40021f08 | Anthony Liguori | .name = "uni-north-pci",
|
364 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
365 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
366 | 40021f08 | Anthony Liguori | .class_init = unin_main_pci_host_class_init, |
367 | 2e29bd04 | Blue Swirl | }; |
368 | 2e29bd04 | Blue Swirl | |
369 | 40021f08 | Anthony Liguori | static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data) |
370 | 40021f08 | Anthony Liguori | { |
371 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
372 | 40021f08 | Anthony Liguori | |
373 | 40021f08 | Anthony Liguori | k->init = u3_agp_pci_host_init; |
374 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
375 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP; |
376 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
377 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
378 | 40021f08 | Anthony Liguori | } |
379 | 40021f08 | Anthony Liguori | |
380 | 4240abff | Andreas Färber | static const TypeInfo u3_agp_pci_host_info = { |
381 | 40021f08 | Anthony Liguori | .name = "u3-agp",
|
382 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
383 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
384 | 40021f08 | Anthony Liguori | .class_init = u3_agp_pci_host_class_init, |
385 | 0f921197 | Alexander Graf | }; |
386 | 0f921197 | Alexander Graf | |
387 | 40021f08 | Anthony Liguori | static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data) |
388 | 40021f08 | Anthony Liguori | { |
389 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
390 | 40021f08 | Anthony Liguori | |
391 | 40021f08 | Anthony Liguori | k->init = unin_agp_pci_host_init; |
392 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
393 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP; |
394 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
395 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
396 | 40021f08 | Anthony Liguori | } |
397 | 40021f08 | Anthony Liguori | |
398 | 4240abff | Andreas Färber | static const TypeInfo unin_agp_pci_host_info = { |
399 | 40021f08 | Anthony Liguori | .name = "uni-north-agp",
|
400 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
401 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
402 | 40021f08 | Anthony Liguori | .class_init = unin_agp_pci_host_class_init, |
403 | 2e29bd04 | Blue Swirl | }; |
404 | 2e29bd04 | Blue Swirl | |
405 | 40021f08 | Anthony Liguori | static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data) |
406 | 40021f08 | Anthony Liguori | { |
407 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
408 | 40021f08 | Anthony Liguori | |
409 | 40021f08 | Anthony Liguori | k->init = unin_internal_pci_host_init; |
410 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
411 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI; |
412 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
413 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
414 | 40021f08 | Anthony Liguori | } |
415 | 40021f08 | Anthony Liguori | |
416 | 4240abff | Andreas Färber | static const TypeInfo unin_internal_pci_host_info = { |
417 | 40021f08 | Anthony Liguori | .name = "uni-north-internal-pci",
|
418 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
419 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
420 | 40021f08 | Anthony Liguori | .class_init = unin_internal_pci_host_class_init, |
421 | 2e29bd04 | Blue Swirl | }; |
422 | 2e29bd04 | Blue Swirl | |
423 | 999e12bb | Anthony Liguori | static void pci_unin_main_class_init(ObjectClass *klass, void *data) |
424 | 999e12bb | Anthony Liguori | { |
425 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
426 | 999e12bb | Anthony Liguori | |
427 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_main_init_device; |
428 | 999e12bb | Anthony Liguori | } |
429 | 999e12bb | Anthony Liguori | |
430 | 4240abff | Andreas Färber | static const TypeInfo pci_unin_main_info = { |
431 | 57fd7b7f | Andreas Färber | .name = TYPE_UNI_NORTH_PCI_HOST_BRIDGE, |
432 | 8558d942 | Andreas Färber | .parent = TYPE_PCI_HOST_BRIDGE, |
433 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
434 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_main_class_init, |
435 | 70f9c987 | Andreas Färber | }; |
436 | 70f9c987 | Andreas Färber | |
437 | 999e12bb | Anthony Liguori | static void pci_u3_agp_class_init(ObjectClass *klass, void *data) |
438 | 999e12bb | Anthony Liguori | { |
439 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
440 | 999e12bb | Anthony Liguori | |
441 | 999e12bb | Anthony Liguori | sbc->init = pci_u3_agp_init_device; |
442 | 999e12bb | Anthony Liguori | } |
443 | 999e12bb | Anthony Liguori | |
444 | 4240abff | Andreas Färber | static const TypeInfo pci_u3_agp_info = { |
445 | 57fd7b7f | Andreas Färber | .name = TYPE_U3_AGP_HOST_BRIDGE, |
446 | 8558d942 | Andreas Färber | .parent = TYPE_PCI_HOST_BRIDGE, |
447 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
448 | 39bffca2 | Anthony Liguori | .class_init = pci_u3_agp_class_init, |
449 | 70f9c987 | Andreas Färber | }; |
450 | 70f9c987 | Andreas Färber | |
451 | 999e12bb | Anthony Liguori | static void pci_unin_agp_class_init(ObjectClass *klass, void *data) |
452 | 999e12bb | Anthony Liguori | { |
453 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
454 | 999e12bb | Anthony Liguori | |
455 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_agp_init_device; |
456 | 999e12bb | Anthony Liguori | } |
457 | 999e12bb | Anthony Liguori | |
458 | 4240abff | Andreas Färber | static const TypeInfo pci_unin_agp_info = { |
459 | 57fd7b7f | Andreas Färber | .name = TYPE_UNI_NORTH_AGP_HOST_BRIDGE, |
460 | 8558d942 | Andreas Färber | .parent = TYPE_PCI_HOST_BRIDGE, |
461 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
462 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_agp_class_init, |
463 | 70f9c987 | Andreas Färber | }; |
464 | 70f9c987 | Andreas Färber | |
465 | 999e12bb | Anthony Liguori | static void pci_unin_internal_class_init(ObjectClass *klass, void *data) |
466 | 999e12bb | Anthony Liguori | { |
467 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
468 | 999e12bb | Anthony Liguori | |
469 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_internal_init_device; |
470 | 999e12bb | Anthony Liguori | } |
471 | 999e12bb | Anthony Liguori | |
472 | 4240abff | Andreas Färber | static const TypeInfo pci_unin_internal_info = { |
473 | 57fd7b7f | Andreas Färber | .name = TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE, |
474 | 8558d942 | Andreas Färber | .parent = TYPE_PCI_HOST_BRIDGE, |
475 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
476 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_internal_class_init, |
477 | 70f9c987 | Andreas Färber | }; |
478 | 70f9c987 | Andreas Färber | |
479 | 83f7d43a | Andreas Färber | static void unin_register_types(void) |
480 | 2e29bd04 | Blue Swirl | { |
481 | 39bffca2 | Anthony Liguori | type_register_static(&unin_main_pci_host_info); |
482 | 39bffca2 | Anthony Liguori | type_register_static(&u3_agp_pci_host_info); |
483 | 39bffca2 | Anthony Liguori | type_register_static(&unin_agp_pci_host_info); |
484 | 39bffca2 | Anthony Liguori | type_register_static(&unin_internal_pci_host_info); |
485 | 39bffca2 | Anthony Liguori | |
486 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_main_info); |
487 | 39bffca2 | Anthony Liguori | type_register_static(&pci_u3_agp_info); |
488 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_agp_info); |
489 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_internal_info); |
490 | 502a5395 | pbrook | } |
491 | 2e29bd04 | Blue Swirl | |
492 | 83f7d43a | Andreas Färber | type_init(unin_register_types) |