root / hw / unin_pci.c @ 9077f01b
History | View | Annotate | Download (14.6 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 | PCIHostState host_state; |
43 | 46f3069c | Blue Swirl | MemoryRegion pci_mmio; |
44 | 46f3069c | Blue Swirl | MemoryRegion pci_hole; |
45 | 2e29bd04 | Blue Swirl | } UNINState; |
46 | 502a5395 | pbrook | |
47 | d2b59317 | pbrook | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
48 | 502a5395 | pbrook | { |
49 | fa0be69a | Alexander Graf | int retval;
|
50 | fa0be69a | Alexander Graf | int devfn = pci_dev->devfn & 0x00FFFFFF; |
51 | fa0be69a | Alexander Graf | |
52 | fa0be69a | Alexander Graf | retval = (((devfn >> 11) & 0x1F) + irq_num) & 3; |
53 | fa0be69a | Alexander Graf | |
54 | fa0be69a | Alexander Graf | return retval;
|
55 | d2b59317 | pbrook | } |
56 | d2b59317 | pbrook | |
57 | 5d4e84c8 | Juan Quintela | static void pci_unin_set_irq(void *opaque, int irq_num, int level) |
58 | d2b59317 | pbrook | { |
59 | 5d4e84c8 | Juan Quintela | qemu_irq *pic = opaque; |
60 | 5d4e84c8 | Juan Quintela | |
61 | fa0be69a | Alexander Graf | UNIN_DPRINTF("%s: setting INT %d = %d\n", __func__,
|
62 | fa0be69a | Alexander Graf | unin_irq_line[irq_num], level); |
63 | fa0be69a | Alexander Graf | qemu_set_irq(pic[unin_irq_line[irq_num]], level); |
64 | 502a5395 | pbrook | } |
65 | 502a5395 | pbrook | |
66 | d86f0e32 | Alexander Graf | static uint32_t unin_get_config_reg(uint32_t reg, uint32_t addr)
|
67 | d86f0e32 | Alexander Graf | { |
68 | d86f0e32 | Alexander Graf | uint32_t retval; |
69 | d86f0e32 | Alexander Graf | |
70 | d86f0e32 | Alexander Graf | if (reg & (1u << 31)) { |
71 | d86f0e32 | Alexander Graf | /* XXX OpenBIOS compatibility hack */
|
72 | d86f0e32 | Alexander Graf | retval = reg | (addr & 3);
|
73 | d86f0e32 | Alexander Graf | } else if (reg & 1) { |
74 | d86f0e32 | Alexander Graf | /* CFA1 style */
|
75 | d86f0e32 | Alexander Graf | retval = (reg & ~7u) | (addr & 7); |
76 | d86f0e32 | Alexander Graf | } else {
|
77 | d86f0e32 | Alexander Graf | uint32_t slot, func; |
78 | d86f0e32 | Alexander Graf | |
79 | d86f0e32 | Alexander Graf | /* Grab CFA0 style values */
|
80 | d86f0e32 | Alexander Graf | slot = ffs(reg & 0xfffff800) - 1; |
81 | d86f0e32 | Alexander Graf | func = (reg >> 8) & 7; |
82 | d86f0e32 | Alexander Graf | |
83 | d86f0e32 | Alexander Graf | /* ... and then convert them to x86 format */
|
84 | d86f0e32 | Alexander Graf | /* config pointer */
|
85 | d86f0e32 | Alexander Graf | retval = (reg & (0xff - 7)) | (addr & 7); |
86 | d86f0e32 | Alexander Graf | /* slot */
|
87 | d86f0e32 | Alexander Graf | retval |= slot << 11;
|
88 | d86f0e32 | Alexander Graf | /* fn */
|
89 | d86f0e32 | Alexander Graf | retval |= func << 8;
|
90 | d86f0e32 | Alexander Graf | } |
91 | d86f0e32 | Alexander Graf | |
92 | d86f0e32 | Alexander Graf | |
93 | d86f0e32 | Alexander Graf | UNIN_DPRINTF("Converted config space accessor %08x/%08x -> %08x\n",
|
94 | d86f0e32 | Alexander Graf | reg, addr, retval); |
95 | d86f0e32 | Alexander Graf | |
96 | d86f0e32 | Alexander Graf | return retval;
|
97 | d86f0e32 | Alexander Graf | } |
98 | d86f0e32 | Alexander Graf | |
99 | d0ed8076 | Avi Kivity | static void unin_data_write(void *opaque, target_phys_addr_t addr, |
100 | d0ed8076 | Avi Kivity | uint64_t val, unsigned len)
|
101 | d86f0e32 | Alexander Graf | { |
102 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
103 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("write addr %" TARGET_FMT_plx " len %d val %"PRIx64"\n", |
104 | d0ed8076 | Avi Kivity | addr, len, val); |
105 | d86f0e32 | Alexander Graf | pci_data_write(s->host_state.bus, |
106 | d86f0e32 | Alexander Graf | unin_get_config_reg(s->host_state.config_reg, addr), |
107 | d86f0e32 | Alexander Graf | val, len); |
108 | d86f0e32 | Alexander Graf | } |
109 | d86f0e32 | Alexander Graf | |
110 | d0ed8076 | Avi Kivity | static uint64_t unin_data_read(void *opaque, target_phys_addr_t addr, |
111 | d0ed8076 | Avi Kivity | unsigned len)
|
112 | d86f0e32 | Alexander Graf | { |
113 | d0ed8076 | Avi Kivity | UNINState *s = opaque; |
114 | d86f0e32 | Alexander Graf | uint32_t val; |
115 | d86f0e32 | Alexander Graf | |
116 | d86f0e32 | Alexander Graf | val = pci_data_read(s->host_state.bus, |
117 | d86f0e32 | Alexander Graf | unin_get_config_reg(s->host_state.config_reg, addr), |
118 | d86f0e32 | Alexander Graf | len); |
119 | d0ed8076 | Avi Kivity | UNIN_DPRINTF("read addr %" TARGET_FMT_plx " len %d val %x\n", |
120 | d0ed8076 | Avi Kivity | addr, len, val); |
121 | d86f0e32 | Alexander Graf | return val;
|
122 | d86f0e32 | Alexander Graf | } |
123 | d86f0e32 | Alexander Graf | |
124 | d0ed8076 | Avi Kivity | static const MemoryRegionOps unin_data_ops = { |
125 | d0ed8076 | Avi Kivity | .read = unin_data_read, |
126 | d0ed8076 | Avi Kivity | .write = unin_data_write, |
127 | d0ed8076 | Avi Kivity | .endianness = DEVICE_LITTLE_ENDIAN, |
128 | d0ed8076 | Avi Kivity | }; |
129 | d0ed8076 | Avi Kivity | |
130 | 81a322d4 | Gerd Hoffmann | static int pci_unin_main_init_device(SysBusDevice *dev) |
131 | 502a5395 | pbrook | { |
132 | ff452ace | Andreas Färber | PCIHostState *h; |
133 | 502a5395 | pbrook | UNINState *s; |
134 | 502a5395 | pbrook | |
135 | 502a5395 | pbrook | /* Use values found on a real PowerMac */
|
136 | 502a5395 | pbrook | /* Uninorth main bus */
|
137 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, dev); |
138 | ff452ace | Andreas Färber | s = DO_UPCAST(UNINState, host_state, h); |
139 | 502a5395 | pbrook | |
140 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
141 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
142 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
143 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
144 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.conf_mem); |
145 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.data_mem); |
146 | 2e29bd04 | Blue Swirl | |
147 | 81a322d4 | Gerd Hoffmann | return 0; |
148 | 2e29bd04 | Blue Swirl | } |
149 | 2e29bd04 | Blue Swirl | |
150 | d0ed8076 | Avi Kivity | |
151 | 0f921197 | Alexander Graf | static int pci_u3_agp_init_device(SysBusDevice *dev) |
152 | 0f921197 | Alexander Graf | { |
153 | ff452ace | Andreas Färber | PCIHostState *h; |
154 | 0f921197 | Alexander Graf | UNINState *s; |
155 | 0f921197 | Alexander Graf | |
156 | 0f921197 | Alexander Graf | /* Uninorth U3 AGP bus */
|
157 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, dev); |
158 | ff452ace | Andreas Färber | s = DO_UPCAST(UNINState, host_state, h); |
159 | 0f921197 | Alexander Graf | |
160 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
161 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
162 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &unin_data_ops, s, |
163 | d0ed8076 | Avi Kivity | "pci-conf-data", 0x1000); |
164 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.conf_mem); |
165 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.data_mem); |
166 | 0f921197 | Alexander Graf | |
167 | 0f921197 | Alexander Graf | return 0; |
168 | 0f921197 | Alexander Graf | } |
169 | 0f921197 | Alexander Graf | |
170 | 81a322d4 | Gerd Hoffmann | static int pci_unin_agp_init_device(SysBusDevice *dev) |
171 | 2e29bd04 | Blue Swirl | { |
172 | ff452ace | Andreas Färber | PCIHostState *h; |
173 | 2e29bd04 | Blue Swirl | UNINState *s; |
174 | 2e29bd04 | Blue Swirl | |
175 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
176 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, dev); |
177 | ff452ace | Andreas Färber | s = DO_UPCAST(UNINState, host_state, h); |
178 | 2e29bd04 | Blue Swirl | |
179 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.conf_mem, &pci_host_conf_le_ops, |
180 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-idx", 0x1000); |
181 | d0ed8076 | Avi Kivity | memory_region_init_io(&s->host_state.data_mem, &pci_host_data_le_ops, |
182 | d0ed8076 | Avi Kivity | &s->host_state, "pci-conf-data", 0x1000); |
183 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.conf_mem); |
184 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.data_mem); |
185 | 81a322d4 | Gerd Hoffmann | return 0; |
186 | 2e29bd04 | Blue Swirl | } |
187 | 2e29bd04 | Blue Swirl | |
188 | 81a322d4 | Gerd Hoffmann | static int pci_unin_internal_init_device(SysBusDevice *dev) |
189 | 2e29bd04 | Blue Swirl | { |
190 | ff452ace | Andreas Färber | PCIHostState *h; |
191 | 2e29bd04 | Blue Swirl | UNINState *s; |
192 | 2e29bd04 | Blue Swirl | |
193 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
194 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, dev); |
195 | ff452ace | Andreas Färber | s = DO_UPCAST(UNINState, host_state, h); |
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 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->host_state.conf_mem); |
202 | 750ecd44 | Avi Kivity | sysbus_init_mmio(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 | ff452ace | Andreas Färber | PCIHostState *h; |
213 | 2e29bd04 | Blue Swirl | UNINState *d; |
214 | 2e29bd04 | Blue Swirl | |
215 | 2e29bd04 | Blue Swirl | /* Use values found on a real PowerMac */
|
216 | 2e29bd04 | Blue Swirl | /* Uninorth main bus */
|
217 | 70f9c987 | Andreas Färber | dev = qdev_create(NULL, "uni-north-pci-pcihost"); |
218 | e23a1b33 | Markus Armbruster | qdev_init_nofail(dev); |
219 | 2e29bd04 | Blue Swirl | s = sysbus_from_qdev(dev); |
220 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, s); |
221 | ff452ace | Andreas Färber | d = DO_UPCAST(UNINState, host_state, h); |
222 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
223 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
224 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
225 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
226 | 46f3069c | Blue Swirl | &d->pci_hole); |
227 | 46f3069c | Blue Swirl | |
228 | ff452ace | Andreas Färber | d->host_state.bus = pci_register_bus(dev, "pci",
|
229 | 2e29bd04 | Blue Swirl | pci_unin_set_irq, pci_unin_map_irq, |
230 | aee97b84 | Avi Kivity | pic, |
231 | 46f3069c | Blue Swirl | &d->pci_mmio, |
232 | aee97b84 | Avi Kivity | address_space_io, |
233 | 1e39101c | Avi Kivity | PCI_DEVFN(11, 0), 4); |
234 | 2e29bd04 | Blue Swirl | |
235 | 60398748 | Blue Swirl | #if 0
|
236 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north");
|
237 | 60398748 | Blue Swirl | #endif
|
238 | 2e29bd04 | Blue Swirl | |
239 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf2800000); |
240 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf2c00000); |
241 | 2e29bd04 | Blue Swirl | |
242 | 2e29bd04 | Blue Swirl | /* DEC 21154 bridge */
|
243 | 2e29bd04 | Blue Swirl | #if 0
|
244 | 2e29bd04 | Blue Swirl | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
|
245 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(12, 0), "dec-21154");
|
246 | 2e29bd04 | Blue Swirl | #endif
|
247 | 2e29bd04 | Blue Swirl | |
248 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
249 | 520128bd | Isaku Yamahata | pci_create_simple(d->host_state.bus, PCI_DEVFN(11, 0), "uni-north-agp"); |
250 | 70f9c987 | Andreas Färber | dev = qdev_create(NULL, "uni-north-agp-pcihost"); |
251 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev); |
252 | d27d06f2 | Blue Swirl | s = sysbus_from_qdev(dev); |
253 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf0800000); |
254 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf0c00000); |
255 | 2e29bd04 | Blue Swirl | |
256 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
257 | 2e29bd04 | Blue Swirl | #if 0
|
258 | 2e29bd04 | Blue Swirl | /* XXX: not needed for now */
|
259 | 70f9c987 | Andreas Färber | pci_create_simple(d->host_state.bus, PCI_DEVFN(14, 0),
|
260 | 70f9c987 | Andreas Färber | "uni-north-internal-pci");
|
261 | 70f9c987 | Andreas Färber | dev = qdev_create(NULL, "uni-north-internal-pci-pcihost");
|
262 | d27d06f2 | Blue Swirl | qdev_init_nofail(dev);
|
263 | d27d06f2 | Blue Swirl | s = sysbus_from_qdev(dev);
|
264 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf4800000);
|
265 | d27d06f2 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf4c00000);
|
266 | 2e29bd04 | Blue Swirl | #endif
|
267 | 2e29bd04 | Blue Swirl | |
268 | 2e29bd04 | Blue Swirl | return d->host_state.bus;
|
269 | 2e29bd04 | Blue Swirl | } |
270 | 2e29bd04 | Blue Swirl | |
271 | aee97b84 | Avi Kivity | PCIBus *pci_pmac_u3_init(qemu_irq *pic, |
272 | aee97b84 | Avi Kivity | MemoryRegion *address_space_mem, |
273 | aee97b84 | Avi Kivity | MemoryRegion *address_space_io) |
274 | 0f921197 | Alexander Graf | { |
275 | 0f921197 | Alexander Graf | DeviceState *dev; |
276 | 0f921197 | Alexander Graf | SysBusDevice *s; |
277 | ff452ace | Andreas Färber | PCIHostState *h; |
278 | 0f921197 | Alexander Graf | UNINState *d; |
279 | 0f921197 | Alexander Graf | |
280 | 0f921197 | Alexander Graf | /* Uninorth AGP bus */
|
281 | 0f921197 | Alexander Graf | |
282 | 70f9c987 | Andreas Färber | dev = qdev_create(NULL, "u3-agp-pcihost"); |
283 | 0f921197 | Alexander Graf | qdev_init_nofail(dev); |
284 | 0f921197 | Alexander Graf | s = sysbus_from_qdev(dev); |
285 | ff452ace | Andreas Färber | h = FROM_SYSBUS(PCIHostState, s); |
286 | ff452ace | Andreas Färber | d = DO_UPCAST(UNINState, host_state, h); |
287 | 0f921197 | Alexander Graf | |
288 | 46f3069c | Blue Swirl | memory_region_init(&d->pci_mmio, "pci-mmio", 0x100000000ULL); |
289 | 46f3069c | Blue Swirl | memory_region_init_alias(&d->pci_hole, "pci-hole", &d->pci_mmio,
|
290 | 46f3069c | Blue Swirl | 0x80000000ULL, 0x70000000ULL); |
291 | 46f3069c | Blue Swirl | memory_region_add_subregion(address_space_mem, 0x80000000ULL,
|
292 | 46f3069c | Blue Swirl | &d->pci_hole); |
293 | 46f3069c | Blue Swirl | |
294 | ff452ace | Andreas Färber | d->host_state.bus = pci_register_bus(dev, "pci",
|
295 | 0f921197 | Alexander Graf | pci_unin_set_irq, pci_unin_map_irq, |
296 | aee97b84 | Avi Kivity | pic, |
297 | 46f3069c | Blue Swirl | &d->pci_mmio, |
298 | aee97b84 | Avi Kivity | address_space_io, |
299 | 1e39101c | Avi Kivity | PCI_DEVFN(11, 0), 4); |
300 | 0f921197 | Alexander Graf | |
301 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 0, 0xf0800000); |
302 | 0f921197 | Alexander Graf | sysbus_mmio_map(s, 1, 0xf0c00000); |
303 | 0f921197 | Alexander Graf | |
304 | 0f921197 | Alexander Graf | pci_create_simple(d->host_state.bus, 11 << 3, "u3-agp"); |
305 | 0f921197 | Alexander Graf | |
306 | 0f921197 | Alexander Graf | return d->host_state.bus;
|
307 | 0f921197 | Alexander Graf | } |
308 | 0f921197 | Alexander Graf | |
309 | 81a322d4 | Gerd Hoffmann | static int unin_main_pci_host_init(PCIDevice *d) |
310 | 2e29bd04 | Blue Swirl | { |
311 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
312 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
313 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
314 | 81a322d4 | Gerd Hoffmann | return 0; |
315 | 2e29bd04 | Blue Swirl | } |
316 | 502a5395 | pbrook | |
317 | 81a322d4 | Gerd Hoffmann | static int unin_agp_pci_host_init(PCIDevice *d) |
318 | 2e29bd04 | Blue Swirl | { |
319 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
320 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
321 | 502a5395 | pbrook | // d->config[0x34] = 0x80; // capabilities_pointer
|
322 | 81a322d4 | Gerd Hoffmann | return 0; |
323 | 2e29bd04 | Blue Swirl | } |
324 | 502a5395 | pbrook | |
325 | 0f921197 | Alexander Graf | static int u3_agp_pci_host_init(PCIDevice *d) |
326 | 0f921197 | Alexander Graf | { |
327 | 0f921197 | Alexander Graf | /* cache line size */
|
328 | 0f921197 | Alexander Graf | d->config[0x0C] = 0x08; |
329 | 0f921197 | Alexander Graf | /* latency timer */
|
330 | 0f921197 | Alexander Graf | d->config[0x0D] = 0x10; |
331 | 0f921197 | Alexander Graf | return 0; |
332 | 0f921197 | Alexander Graf | } |
333 | 0f921197 | Alexander Graf | |
334 | 81a322d4 | Gerd Hoffmann | static int unin_internal_pci_host_init(PCIDevice *d) |
335 | 2e29bd04 | Blue Swirl | { |
336 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
337 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
338 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
339 | 81a322d4 | Gerd Hoffmann | return 0; |
340 | 2e29bd04 | Blue Swirl | } |
341 | 2e29bd04 | Blue Swirl | |
342 | 40021f08 | Anthony Liguori | static void unin_main_pci_host_class_init(ObjectClass *klass, void *data) |
343 | 40021f08 | Anthony Liguori | { |
344 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
345 | 40021f08 | Anthony Liguori | |
346 | 40021f08 | Anthony Liguori | k->init = unin_main_pci_host_init; |
347 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
348 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_PCI; |
349 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
350 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
351 | 40021f08 | Anthony Liguori | } |
352 | 40021f08 | Anthony Liguori | |
353 | 39bffca2 | Anthony Liguori | static TypeInfo unin_main_pci_host_info = {
|
354 | 40021f08 | Anthony Liguori | .name = "uni-north-pci",
|
355 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
356 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
357 | 40021f08 | Anthony Liguori | .class_init = unin_main_pci_host_class_init, |
358 | 2e29bd04 | Blue Swirl | }; |
359 | 2e29bd04 | Blue Swirl | |
360 | 40021f08 | Anthony Liguori | static void u3_agp_pci_host_class_init(ObjectClass *klass, void *data) |
361 | 40021f08 | Anthony Liguori | { |
362 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
363 | 40021f08 | Anthony Liguori | |
364 | 40021f08 | Anthony Liguori | k->init = u3_agp_pci_host_init; |
365 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
366 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_U3_AGP; |
367 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
368 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
369 | 40021f08 | Anthony Liguori | } |
370 | 40021f08 | Anthony Liguori | |
371 | 39bffca2 | Anthony Liguori | static TypeInfo u3_agp_pci_host_info = {
|
372 | 40021f08 | Anthony Liguori | .name = "u3-agp",
|
373 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
374 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
375 | 40021f08 | Anthony Liguori | .class_init = u3_agp_pci_host_class_init, |
376 | 0f921197 | Alexander Graf | }; |
377 | 0f921197 | Alexander Graf | |
378 | 40021f08 | Anthony Liguori | static void unin_agp_pci_host_class_init(ObjectClass *klass, void *data) |
379 | 40021f08 | Anthony Liguori | { |
380 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
381 | 40021f08 | Anthony Liguori | |
382 | 40021f08 | Anthony Liguori | k->init = unin_agp_pci_host_init; |
383 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
384 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_AGP; |
385 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
386 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
387 | 40021f08 | Anthony Liguori | } |
388 | 40021f08 | Anthony Liguori | |
389 | 39bffca2 | Anthony Liguori | static TypeInfo unin_agp_pci_host_info = {
|
390 | 40021f08 | Anthony Liguori | .name = "uni-north-agp",
|
391 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
392 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
393 | 40021f08 | Anthony Liguori | .class_init = unin_agp_pci_host_class_init, |
394 | 2e29bd04 | Blue Swirl | }; |
395 | 2e29bd04 | Blue Swirl | |
396 | 40021f08 | Anthony Liguori | static void unin_internal_pci_host_class_init(ObjectClass *klass, void *data) |
397 | 40021f08 | Anthony Liguori | { |
398 | 40021f08 | Anthony Liguori | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); |
399 | 40021f08 | Anthony Liguori | |
400 | 40021f08 | Anthony Liguori | k->init = unin_internal_pci_host_init; |
401 | 40021f08 | Anthony Liguori | k->vendor_id = PCI_VENDOR_ID_APPLE; |
402 | 40021f08 | Anthony Liguori | k->device_id = PCI_DEVICE_ID_APPLE_UNI_N_I_PCI; |
403 | 40021f08 | Anthony Liguori | k->revision = 0x00;
|
404 | 40021f08 | Anthony Liguori | k->class_id = PCI_CLASS_BRIDGE_HOST; |
405 | 40021f08 | Anthony Liguori | } |
406 | 40021f08 | Anthony Liguori | |
407 | 39bffca2 | Anthony Liguori | static TypeInfo unin_internal_pci_host_info = {
|
408 | 40021f08 | Anthony Liguori | .name = "uni-north-internal-pci",
|
409 | 39bffca2 | Anthony Liguori | .parent = TYPE_PCI_DEVICE, |
410 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(PCIDevice),
|
411 | 40021f08 | Anthony Liguori | .class_init = unin_internal_pci_host_class_init, |
412 | 2e29bd04 | Blue Swirl | }; |
413 | 2e29bd04 | Blue Swirl | |
414 | 999e12bb | Anthony Liguori | static void pci_unin_main_class_init(ObjectClass *klass, void *data) |
415 | 999e12bb | Anthony Liguori | { |
416 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
417 | 999e12bb | Anthony Liguori | |
418 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_main_init_device; |
419 | 999e12bb | Anthony Liguori | } |
420 | 999e12bb | Anthony Liguori | |
421 | 39bffca2 | Anthony Liguori | static TypeInfo pci_unin_main_info = {
|
422 | 39bffca2 | Anthony Liguori | .name = "uni-north-pci-pcihost",
|
423 | 39bffca2 | Anthony Liguori | .parent = TYPE_SYS_BUS_DEVICE, |
424 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
425 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_main_class_init, |
426 | 70f9c987 | Andreas Färber | }; |
427 | 70f9c987 | Andreas Färber | |
428 | 999e12bb | Anthony Liguori | static void pci_u3_agp_class_init(ObjectClass *klass, void *data) |
429 | 999e12bb | Anthony Liguori | { |
430 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
431 | 999e12bb | Anthony Liguori | |
432 | 999e12bb | Anthony Liguori | sbc->init = pci_u3_agp_init_device; |
433 | 999e12bb | Anthony Liguori | } |
434 | 999e12bb | Anthony Liguori | |
435 | 39bffca2 | Anthony Liguori | static TypeInfo pci_u3_agp_info = {
|
436 | 39bffca2 | Anthony Liguori | .name = "u3-agp-pcihost",
|
437 | 39bffca2 | Anthony Liguori | .parent = TYPE_SYS_BUS_DEVICE, |
438 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
439 | 39bffca2 | Anthony Liguori | .class_init = pci_u3_agp_class_init, |
440 | 70f9c987 | Andreas Färber | }; |
441 | 70f9c987 | Andreas Färber | |
442 | 999e12bb | Anthony Liguori | static void pci_unin_agp_class_init(ObjectClass *klass, void *data) |
443 | 999e12bb | Anthony Liguori | { |
444 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
445 | 999e12bb | Anthony Liguori | |
446 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_agp_init_device; |
447 | 999e12bb | Anthony Liguori | } |
448 | 999e12bb | Anthony Liguori | |
449 | 39bffca2 | Anthony Liguori | static TypeInfo pci_unin_agp_info = {
|
450 | 39bffca2 | Anthony Liguori | .name = "uni-north-agp-pcihost",
|
451 | 39bffca2 | Anthony Liguori | .parent = TYPE_SYS_BUS_DEVICE, |
452 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
453 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_agp_class_init, |
454 | 70f9c987 | Andreas Färber | }; |
455 | 70f9c987 | Andreas Färber | |
456 | 999e12bb | Anthony Liguori | static void pci_unin_internal_class_init(ObjectClass *klass, void *data) |
457 | 999e12bb | Anthony Liguori | { |
458 | 999e12bb | Anthony Liguori | SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass); |
459 | 999e12bb | Anthony Liguori | |
460 | 999e12bb | Anthony Liguori | sbc->init = pci_unin_internal_init_device; |
461 | 999e12bb | Anthony Liguori | } |
462 | 999e12bb | Anthony Liguori | |
463 | 39bffca2 | Anthony Liguori | static TypeInfo pci_unin_internal_info = {
|
464 | 39bffca2 | Anthony Liguori | .name = "uni-north-internal-pci-pcihost",
|
465 | 39bffca2 | Anthony Liguori | .parent = TYPE_SYS_BUS_DEVICE, |
466 | 39bffca2 | Anthony Liguori | .instance_size = sizeof(UNINState),
|
467 | 39bffca2 | Anthony Liguori | .class_init = pci_unin_internal_class_init, |
468 | 70f9c987 | Andreas Färber | }; |
469 | 70f9c987 | Andreas Färber | |
470 | 83f7d43a | Andreas Färber | static void unin_register_types(void) |
471 | 2e29bd04 | Blue Swirl | { |
472 | 39bffca2 | Anthony Liguori | type_register_static(&unin_main_pci_host_info); |
473 | 39bffca2 | Anthony Liguori | type_register_static(&u3_agp_pci_host_info); |
474 | 39bffca2 | Anthony Liguori | type_register_static(&unin_agp_pci_host_info); |
475 | 39bffca2 | Anthony Liguori | type_register_static(&unin_internal_pci_host_info); |
476 | 39bffca2 | Anthony Liguori | |
477 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_main_info); |
478 | 39bffca2 | Anthony Liguori | type_register_static(&pci_u3_agp_info); |
479 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_agp_info); |
480 | 39bffca2 | Anthony Liguori | type_register_static(&pci_unin_internal_info); |
481 | 502a5395 | pbrook | } |
482 | 2e29bd04 | Blue Swirl | |
483 | 83f7d43a | Andreas Färber | type_init(unin_register_types) |