root / hw / unin_pci.c @ f5654039
History | View | Annotate | Download (12.2 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 | 87ecb68b | pbrook | #include "hw.h" |
25 | 87ecb68b | pbrook | #include "ppc_mac.h" |
26 | 87ecb68b | pbrook | #include "pci.h" |
27 | 4f5e19e6 | Isaku Yamahata | #include "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 | 2e29bd04 | Blue Swirl | typedef struct UNINState { |
42 | 2e29bd04 | Blue Swirl | SysBusDevice busdev; |
43 | 2e29bd04 | Blue Swirl | PCIHostState host_state; |
44 | 46f3069c | Blue Swirl | MemoryRegion pci_mmio; |
45 | 46f3069c | Blue Swirl | MemoryRegion pci_hole; |
46 | 2e29bd04 | Blue Swirl | } UNINState; |
47 | 502a5395 | pbrook | |
48 | d2b59317 | pbrook | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
49 | 502a5395 | pbrook | { |
50 | fa0be69a | Alexander Graf | int retval;
|
51 | fa0be69a | Alexander Graf | int devfn = pci_dev->devfn & 0x00FFFFFF; |
52 | fa0be69a | Alexander Graf | |
53 | fa0be69a | Alexander Graf | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; |
54 | fa0be69a | Alexander Graf | |
55 | fa0be69a | Alexander Graf | return retval;
|
56 | d2b59317 | pbrook | } |
57 | d2b59317 | pbrook | |
58 | 5d4e84c8 | Juan Quintela | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
59 | d2b59317 | pbrook | { |
60 | 5d4e84c8 | Juan Quintela | qemu_irq *pic = opaque; |
61 | 5d4e84c8 | Juan Quintela | |
62 | fa0be69a | Alexander Graf | UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
|
63 | fa0be69a | Alexander Graf | unin_irq_line[irq_num], level); |
64 | fa0be69a | Alexander Graf | qemu_set_irq(pic[unin_irq_line[irq_num]], level); |
65 | 502a5395 | pbrook | } |
66 | 502a5395 | pbrook | |
67 | f3902383 | blueswir1 | static void pci_unin_reset(void *opaque) |
68 | f3902383 | blueswir1 | { |
69 | f3902383 | blueswir1 | } |
70 | f3902383 | blueswir1 | |
71 | d86f0e32 | Alexander Graf | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
|
72 | d86f0e32 | Alexander Graf | { |
73 | d86f0e32 | Alexander Graf | uint32_t retval; |
74 | d86f0e32 | Alexander Graf | |
75 | d86f0e32 | Alexander Graf | if (reg & (1u << 31)) { |
76 | d86f0e32 | Alexander Graf | /* XXX OpenBIOS compatibility hack */
|
77 | d86f0e32 | Alexander Graf | retval = reg | (addr & 3);
|
78 | d86f0e32 | Alexander Graf | } else if (reg & 1) { |
79 | d86f0e32 | Alexander Graf | /* CFA1 style */
|
80 | d86f0e32 | Alexander Graf | retval = (reg & ~7u) | (addr & 7); |
81 | d86f0e32 | Alexander Graf | } else {
|
82 | d86f0e32 | Alexander Graf | uint32_t slot, func; |
83 | d86f0e32 | Alexander Graf | |
84 | d86f0e32 | Alexander Graf | /* Grab CFA0 style values */
|
85 | d86f0e32 | Alexander Graf | slot = ffs(reg & 0xfffff800) - 1; |
86 | d86f0e32 | Alexander Graf | func = (reg >> 8) & 7; |
87 | d86f0e32 | Alexander Graf | |
88 | d86f0e32 | Alexander Graf | /* ... and then convert them to x86 format */
|
89 | d86f0e32 | Alexander Graf | /* config pointer */
|
90 | d86f0e32 | Alexander Graf | retval = (reg & (0xff - 7)) | (addr & 7); |
91 | d86f0e32 | Alexander Graf | /* slot */
|
92 | d86f0e32 | Alexander Graf | retval |= slot << 11;
|
93 | d86f0e32 | Alexander Graf | /* fn */
|
94 | d86f0e32 | Alexander Graf | retval |= func << 8;
|
95 | d86f0e32 | Alexander Graf | } |
96 | d86f0e32 | Alexander Graf | |
97 | d86f0e32 | Alexander Graf | |
98 | d86f0e32 | Alexander Graf | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
|
99 | d86f0e32 | Alexander Graf | reg, addr, retval); |
100 | d86f0e32 | Alexander Graf | |
101 | d86f0e32 | Alexander Graf | return retval;
|
102 | d86f0e32 | Alexander Graf | } |
103 | d86f0e32 | Alexander Graf | |
104 | d0ed8076 | Avi Kivity | static void unin_data_write(void *opaque, target_phys_addr_t addr, |
105 | d0ed8076 | Avi Kivity | uint64_t val, unsigned len)
|
106 | d86f0e32 | Alexander Graf | { |
107 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
108 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
109 | d0ed8076 | Avi Kivity | addr, len, val); |
110 | d86f0e32 | Alexander Graf | pci_data_write(s->host_state.bus, |
111 | d86f0e32 | Alexander Graf | unin_get_config_reg(s->host_state.config_reg, addr), |
112 | d86f0e32 | Alexander Graf | val, len); |
113 | d86f0e32 | Alexander Graf | } |
114 | d86f0e32 | Alexander Graf | |
115 | d0ed8076 | Avi Kivity | static uint64_t unin_data_read(void *opaque, target_phys_addr_t addr, |
116 | d0ed8076 | Avi Kivity | unsigned len)
|
117 | d86f0e32 | Alexander Graf | { |
118 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
119 | d86f0e32 | Alexander Graf | uint32_t val; |
120 | d86f0e32 | Alexander Graf | |
121 | d86f0e32 | Alexander Graf | val = pci_data_read(s->host_state.bus, |
122 | d86f0e32 | Alexander Graf | unin_get_config_reg(s->host_state.config_reg, addr), |
123 | d86f0e32 | Alexander Graf | len); |
124 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
125 | d0ed8076 | Avi Kivity | addr, len, val); |
126 | d86f0e32 | Alexander Graf | return val;
|
127 | d86f0e32 | Alexander Graf | } |
128 | d86f0e32 | Alexander Graf | |
129 | d0ed8076 | Avi Kivity | static const MemoryRegionOps unin_data_ops = { |
130 | d0ed8076 | Avi Kivity | .read = unin_data_read, |
131 | d0ed8076 | Avi Kivity | .write = unin_data_write, |
132 | d0ed8076 | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN, |
133 | d0ed8076 | Avi Kivity | }; |
134 | d0ed8076 | Avi Kivity | |
135 | 81a322d4 | Gerd Hoffmann | static int pci_unin_main_init_device(SysBusDevice *dev) |
136 | 502a5395 | pbrook | { |
137 | 502a5395 | pbrook | UNINState *s; |
138 | 502a5395 | pbrook | |
139 | 502a5395 | pbrook | /* Use values found on a real PowerMac */
|
140 | 502a5395 | pbrook | /* Uninorth main bus */
|
141 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
142 | 502a5395 | pbrook | |
143 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
144 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
145 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
146 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
147 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
148 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
149 | 2e29bd04 | Blue Swirl | |
150 | 2e29bd04 | Blue Swirl | qemu_register_reset(pci_unin_reset, &s->host_state); |
151 | 81a322d4 | Gerd Hoffmann | return 0; |
152 | 2e29bd04 | Blue Swirl | } |
153 | 2e29bd04 | Blue Swirl | |
154 | d0ed8076 | Avi Kivity | |
155 | 0f921197 | Alexander Graf | static int pci_u3_agp_init_device(SysBusDevice *dev) |
156 | 0f921197 | Alexander Graf | { |
157 | 0f921197 | Alexander Graf | UNINState *s; |
158 | 0f921197 | Alexander Graf | |
159 | 0f921197 | Alexander Graf | /* Uninorth U3 AGP bus */
|
160 | 0f921197 | Alexander Graf | s = FROM_SYSBUS(UNINState, dev); |
161 | 0f921197 | Alexander Graf | |
162 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
163 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
164 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
165 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
166 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
167 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
168 | 0f921197 | Alexander Graf | |
169 | 0f921197 | Alexander Graf | qemu_register_reset(pci_unin_reset, &s->host_state); |
170 | 0f921197 | Alexander Graf | |
171 | 0f921197 | Alexander Graf | return 0; |
172 | 0f921197 | Alexander Graf | } |
173 | 0f921197 | Alexander Graf | |
174 | 81a322d4 | Gerd Hoffmann | static int pci_unin_agp_init_device(SysBusDevice *dev) |
175 | 2e29bd04 | Blue Swirl | { |
176 | 2e29bd04 | Blue Swirl | UNINState *s; |
177 | 2e29bd04 | Blue Swirl | |
178 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
179 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
180 | 2e29bd04 | Blue Swirl | |
181 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
182 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
183 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
184 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-data", 0x1000); |
185 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
186 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
187 | 81a322d4 | Gerd Hoffmann | return 0; |
188 | 2e29bd04 | Blue Swirl | } |
189 | 2e29bd04 | Blue Swirl | |
190 | 81a322d4 | Gerd Hoffmann | static int pci_unin_internal_init_device(SysBusDevice *dev) |
191 | 2e29bd04 | Blue Swirl | { |
192 | 2e29bd04 | Blue Swirl | UNINState *s; |
193 | 2e29bd04 | Blue Swirl | |
194 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
195 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
196 | 2e29bd04 | Blue Swirl | |
197 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
198 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
199 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
200 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-data", 0x1000); |
201 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.conf_mem); |
202 | d0ed8076 | Avi Kivity | sysbus_init_mmio_region(dev, &s->host_state.data_mem); |
203 | 81a322d4 | Gerd Hoffmann | return 0; |
204 | 2e29bd04 | Blue Swirl | } |
205 | 2e29bd04 | Blue Swirl | |
206 | aee97b84 | Avi Kivity | PCIBus *pci_pmac_init(qemu_irq *pic, |
207 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
208 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io) |
209 | 2e29bd04 | Blue Swirl | { |
210 | 2e29bd04 | Blue Swirl | DeviceState *dev; |
211 | 2e29bd04 | Blue Swirl | SysBusDevice *s; |
212 | 2e29bd04 | Blue Swirl | UNINState *d; |
213 | 2e29bd04 | Blue Swirl | |
214 | 2e29bd04 | Blue Swirl | /* Use values found on a real PowerMac */
|
215 | 2e29bd04 | Blue Swirl | /* Uninorth main bus */
|
216 | 18dd19a7 | Markus Armbruster | dev = qdev_create(NULL, "uni-north"); |
217 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
218 | 2e29bd04 | Blue Swirl | s = sysbus_from_qdev(dev); |
219 | 2e29bd04 | Blue Swirl | d = FROM_SYSBUS(UNINState, s); |
220 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
221 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
222 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
223 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
224 | 46f3069c | Blue Swirl | &d->pci_hole); |
225 | 46f3069c | Blue Swirl | |
226 | cdd0935c | Blue Swirl | d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
|
227 | 2e29bd04 | Blue Swirl | pci_unin_set_irq, pci_unin_map_irq, |
228 | aee97b84 | Avi Kivity | pic, |
229 | 46f3069c | Blue Swirl | &d->pci_mmio, |
230 | aee97b84 | Avi Kivity | address_space_io, |
231 | 1e39101c | Avi Kivity | PCI_DEVFN(11, 0), 4); |
232 | 2e29bd04 | Blue Swirl | |
233 | 60398748 | Blue Swirl | #if 0
|
234 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north");
|
235 | 60398748 | Blue Swirl | #endif
|
236 | 2e29bd04 | Blue Swirl | |
237 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf2800000); |
238 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf2c00000); |
239 | 2e29bd04 | Blue Swirl | |
240 | 2e29bd04 | Blue Swirl | /* DEC 21154 bridge */
|
241 | 2e29bd04 | Blue Swirl | #if 0
|
242 | 2e29bd04 | Blue Swirl | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
|
243 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(12, 0), "dec-21154");
|
244 | 2e29bd04 | Blue Swirl | #endif
|
245 | 2e29bd04 | Blue Swirl | |
246 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
247 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
248 | 18dd19a7 | Markus Armbruster | dev = qdev_create(NULL, "uni-north-agp"); |
249 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev); |
250 | d27d06f2 | Blue Swirl | s = sysbus_from_qdev(dev); |
251 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf0800000); |
252 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf0c00000); |
253 | 2e29bd04 | Blue Swirl | |
254 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
255 | 2e29bd04 | Blue Swirl | #if 0
|
256 | 2e29bd04 | Blue Swirl | /* XXX: not needed for now */
|
257 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(14, 0), "uni-north-pci");
|
258 | 18dd19a7 | Markus Armbruster | dev = qdev_create(NULL, "uni-north-pci");
|
259 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev);
|
260 | d27d06f2 | Blue Swirl | s = sysbus_from_qdev(dev);
|
261 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf4800000);
|
262 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf4c00000);
|
263 | 2e29bd04 | Blue Swirl | #endif
|
264 | 2e29bd04 | Blue Swirl | |
265 | 2e29bd04 | Blue Swirl | return d->host_state.bus;
|
266 | 2e29bd04 | Blue Swirl | } |
267 | 2e29bd04 | Blue Swirl | |
268 | aee97b84 | Avi Kivity | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
269 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
270 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io) |
271 | 0f921197 | Alexander Graf | { |
272 | 0f921197 | Alexander Graf | DeviceState *dev; |
273 | 0f921197 | Alexander Graf | SysBusDevice *s; |
274 | 0f921197 | Alexander Graf | UNINState *d; |
275 | 0f921197 | Alexander Graf | |
276 | 0f921197 | Alexander Graf | /* Uninorth AGP bus */
|
277 | 0f921197 | Alexander Graf | |
278 | 0f921197 | Alexander Graf | dev = qdev_create(NULL, "u3-agp"); |
279 | 0f921197 | Alexander Graf | qdev_init_nofail(dev); |
280 | 0f921197 | Alexander Graf | s = sysbus_from_qdev(dev); |
281 | 0f921197 | Alexander Graf | d = FROM_SYSBUS(UNINState, s); |
282 | 0f921197 | Alexander Graf | |
283 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
284 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
285 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
286 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
287 | 46f3069c | Blue Swirl | &d->pci_hole); |
288 | 46f3069c | Blue Swirl | |
289 | 0f921197 | Alexander Graf | d->host_state.bus = pci_register_bus(&d->busdev.qdev, "pci",
|
290 | 0f921197 | Alexander Graf | pci_unin_set_irq, pci_unin_map_irq, |
291 | aee97b84 | Avi Kivity | pic, |
292 | 46f3069c | Blue Swirl | &d->pci_mmio, |
293 | aee97b84 | Avi Kivity | address_space_io, |
294 | 1e39101c | Avi Kivity | PCI_DEVFN(11, 0), 4); |
295 | 0f921197 | Alexander Graf | |
296 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 0, 0xf0800000); |
297 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 1, 0xf0c00000); |
298 | 0f921197 | Alexander Graf | |
299 | 0f921197 | Alexander Graf | pci_create_simple(d->host_state.bus, 11 << 3, "u3-agp"); |
300 | 0f921197 | Alexander Graf | |
301 | 0f921197 | Alexander Graf | return d->host_state.bus;
|
302 | 0f921197 | Alexander Graf | } |
303 | 0f921197 | Alexander Graf | |
304 | 81a322d4 | Gerd Hoffmann | static int unin_main_pci_host_init(PCIDevice *d) |
305 | 2e29bd04 | Blue Swirl | { |
306 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
307 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
308 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
309 | 81a322d4 | Gerd Hoffmann | return 0; |
310 | 2e29bd04 | Blue Swirl | } |
311 | 502a5395 | pbrook | |
312 | 81a322d4 | Gerd Hoffmann | static int unin_agp_pci_host_init(PCIDevice *d) |
313 | 2e29bd04 | Blue Swirl | { |
314 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
315 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
316 | 502a5395 | pbrook | // d->config[0x34] = 0x80; // capabilities_pointer
|
317 | 81a322d4 | Gerd Hoffmann | return 0; |
318 | 2e29bd04 | Blue Swirl | } |
319 | 502a5395 | pbrook | |
320 | 0f921197 | Alexander Graf | static int u3_agp_pci_host_init(PCIDevice *d) |
321 | 0f921197 | Alexander Graf | { |
322 | 0f921197 | Alexander Graf | /* cache line size */
|
323 | 0f921197 | Alexander Graf | d->config[0x0C] = 0x08; |
324 | 0f921197 | Alexander Graf | /* latency timer */
|
325 | 0f921197 | Alexander Graf | d->config[0x0D] = 0x10; |
326 | 0f921197 | Alexander Graf | return 0; |
327 | 0f921197 | Alexander Graf | } |
328 | 0f921197 | Alexander Graf | |
329 | 81a322d4 | Gerd Hoffmann | static int unin_internal_pci_host_init(PCIDevice *d) |
330 | 2e29bd04 | Blue Swirl | { |
331 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
332 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
333 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
334 | 81a322d4 | Gerd Hoffmann | return 0; |
335 | 2e29bd04 | Blue Swirl | } |
336 | 2e29bd04 | Blue Swirl | |
337 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_main_pci_host_info = {
|
338 | 18dd19a7 | Markus Armbruster | .qdev.name = "uni-north",
|
339 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
340 | 2e29bd04 | Blue Swirl | .init = unin_main_pci_host_init, |
341 | d7b61ecc | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_APPLE, |
342 | d7b61ecc | Isaku Yamahata | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI, |
343 | d7b61ecc | Isaku Yamahata | .revision = 0x00,
|
344 | d7b61ecc | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_HOST, |
345 | 2e29bd04 | Blue Swirl | }; |
346 | 2e29bd04 | Blue Swirl | |
347 | 0f921197 | Alexander Graf | static PCIDeviceInfo u3_agp_pci_host_info = {
|
348 | 0f921197 | Alexander Graf | .qdev.name = "u3-agp",
|
349 | 0f921197 | Alexander Graf | .qdev.size = sizeof(PCIDevice),
|
350 | 0f921197 | Alexander Graf | .init = u3_agp_pci_host_init, |
351 | d7b61ecc | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_APPLE, |
352 | d7b61ecc | Isaku Yamahata | .device_id = PCI_DEVICE_ID_APPLE_U3_AGP, |
353 | d7b61ecc | Isaku Yamahata | .revision = 0x00,
|
354 | d7b61ecc | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_HOST, |
355 | 0f921197 | Alexander Graf | }; |
356 | 0f921197 | Alexander Graf | |
357 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_agp_pci_host_info = {
|
358 | 18dd19a7 | Markus Armbruster | .qdev.name = "uni-north-agp",
|
359 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
360 | 2e29bd04 | Blue Swirl | .init = unin_agp_pci_host_init, |
361 | d7b61ecc | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_APPLE, |
362 | d7b61ecc | Isaku Yamahata | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP, |
363 | d7b61ecc | Isaku Yamahata | .revision = 0x00,
|
364 | d7b61ecc | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_HOST, |
365 | 2e29bd04 | Blue Swirl | }; |
366 | 2e29bd04 | Blue Swirl | |
367 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_internal_pci_host_info = {
|
368 | 18dd19a7 | Markus Armbruster | .qdev.name = "uni-north-pci",
|
369 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
370 | 2e29bd04 | Blue Swirl | .init = unin_internal_pci_host_init, |
371 | d7b61ecc | Isaku Yamahata | .vendor_id = PCI_VENDOR_ID_APPLE, |
372 | d7b61ecc | Isaku Yamahata | .device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI, |
373 | d7b61ecc | Isaku Yamahata | .revision = 0x00,
|
374 | d7b61ecc | Isaku Yamahata | .class_id = PCI_CLASS_BRIDGE_HOST, |
375 | 2e29bd04 | Blue Swirl | }; |
376 | 2e29bd04 | Blue Swirl | |
377 | 2e29bd04 | Blue Swirl | static void unin_register_devices(void) |
378 | 2e29bd04 | Blue Swirl | { |
379 | 18dd19a7 | Markus Armbruster | sysbus_register_dev("uni-north", sizeof(UNINState), |
380 | 2e29bd04 | Blue Swirl | pci_unin_main_init_device); |
381 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_main_pci_host_info); |
382 | 0f921197 | Alexander Graf | sysbus_register_dev("u3-agp", sizeof(UNINState), |
383 | 0f921197 | Alexander Graf | pci_u3_agp_init_device); |
384 | 0f921197 | Alexander Graf | pci_qdev_register(&u3_agp_pci_host_info); |
385 | 18dd19a7 | Markus Armbruster | sysbus_register_dev("uni-north-agp", sizeof(UNINState), |
386 | 2e29bd04 | Blue Swirl | pci_unin_agp_init_device); |
387 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_agp_pci_host_info); |
388 | 18dd19a7 | Markus Armbruster | sysbus_register_dev("uni-north-pci", sizeof(UNINState), |
389 | 2e29bd04 | Blue Swirl | pci_unin_internal_init_device); |
390 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_internal_pci_host_info); |
391 | 502a5395 | pbrook | } |
392 | 2e29bd04 | Blue Swirl | |
393 | 2e29bd04 | Blue Swirl | device_init(unin_register_devices) |