root / hw / unin_pci.c @ a8a358bf
History | View | Annotate | Download (11.9 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 | 87ecb68b | pbrook | |
28 | f3902383 | blueswir1 | /* debug UniNorth */
|
29 | f3902383 | blueswir1 | //#define DEBUG_UNIN
|
30 | f3902383 | blueswir1 | |
31 | f3902383 | blueswir1 | #ifdef DEBUG_UNIN
|
32 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...) \
|
33 | 001faf32 | Blue Swirl | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) |
34 | f3902383 | blueswir1 | #else
|
35 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...)
|
36 | f3902383 | blueswir1 | #endif
|
37 | f3902383 | blueswir1 | |
38 | 502a5395 | pbrook | typedef target_phys_addr_t pci_addr_t;
|
39 | 502a5395 | pbrook | #include "pci_host.h" |
40 | 502a5395 | pbrook | |
41 | 2e29bd04 | Blue Swirl | typedef struct UNINState { |
42 | 2e29bd04 | Blue Swirl | SysBusDevice busdev; |
43 | 2e29bd04 | Blue Swirl | PCIHostState host_state; |
44 | 2e29bd04 | Blue Swirl | } UNINState; |
45 | 502a5395 | pbrook | |
46 | 502a5395 | pbrook | static void pci_unin_main_config_writel (void *opaque, target_phys_addr_t addr, |
47 | 502a5395 | pbrook | uint32_t val) |
48 | 502a5395 | pbrook | { |
49 | 502a5395 | pbrook | UNINState *s = opaque; |
50 | 502a5395 | pbrook | |
51 | f3902383 | blueswir1 | UNIN_DPRINTF("config_writel addr " TARGET_FMT_plx " val %x\n", addr, val); |
52 | 502a5395 | pbrook | #ifdef TARGET_WORDS_BIGENDIAN
|
53 | 502a5395 | pbrook | val = bswap32(val); |
54 | 502a5395 | pbrook | #endif
|
55 | 502a5395 | pbrook | |
56 | 2e29bd04 | Blue Swirl | s->host_state.config_reg = val; |
57 | 502a5395 | pbrook | } |
58 | 502a5395 | pbrook | |
59 | 502a5395 | pbrook | static uint32_t pci_unin_main_config_readl (void *opaque, |
60 | 502a5395 | pbrook | target_phys_addr_t addr) |
61 | 502a5395 | pbrook | { |
62 | 502a5395 | pbrook | UNINState *s = opaque; |
63 | 502a5395 | pbrook | uint32_t val; |
64 | 502a5395 | pbrook | |
65 | 2e29bd04 | Blue Swirl | val = s->host_state.config_reg; |
66 | 502a5395 | pbrook | #ifdef TARGET_WORDS_BIGENDIAN
|
67 | 502a5395 | pbrook | val = bswap32(val); |
68 | 502a5395 | pbrook | #endif
|
69 | f3902383 | blueswir1 | UNIN_DPRINTF("config_readl addr " TARGET_FMT_plx " val %x\n", addr, val); |
70 | 502a5395 | pbrook | |
71 | 502a5395 | pbrook | return val;
|
72 | 502a5395 | pbrook | } |
73 | 502a5395 | pbrook | |
74 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const pci_unin_main_config_write[] = { |
75 | 502a5395 | pbrook | &pci_unin_main_config_writel, |
76 | 502a5395 | pbrook | &pci_unin_main_config_writel, |
77 | 502a5395 | pbrook | &pci_unin_main_config_writel, |
78 | 502a5395 | pbrook | }; |
79 | 502a5395 | pbrook | |
80 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const pci_unin_main_config_read[] = { |
81 | 502a5395 | pbrook | &pci_unin_main_config_readl, |
82 | 502a5395 | pbrook | &pci_unin_main_config_readl, |
83 | 502a5395 | pbrook | &pci_unin_main_config_readl, |
84 | 502a5395 | pbrook | }; |
85 | 502a5395 | pbrook | |
86 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const pci_unin_main_write[] = { |
87 | 502a5395 | pbrook | &pci_host_data_writeb, |
88 | 502a5395 | pbrook | &pci_host_data_writew, |
89 | 502a5395 | pbrook | &pci_host_data_writel, |
90 | 502a5395 | pbrook | }; |
91 | 502a5395 | pbrook | |
92 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const pci_unin_main_read[] = { |
93 | 502a5395 | pbrook | &pci_host_data_readb, |
94 | 502a5395 | pbrook | &pci_host_data_readw, |
95 | 502a5395 | pbrook | &pci_host_data_readl, |
96 | 502a5395 | pbrook | }; |
97 | 502a5395 | pbrook | |
98 | 502a5395 | pbrook | static void pci_unin_config_writel (void *opaque, target_phys_addr_t addr, |
99 | 502a5395 | pbrook | uint32_t val) |
100 | 502a5395 | pbrook | { |
101 | 502a5395 | pbrook | UNINState *s = opaque; |
102 | 502a5395 | pbrook | |
103 | 2e29bd04 | Blue Swirl | s->host_state.config_reg = val; |
104 | 502a5395 | pbrook | } |
105 | 502a5395 | pbrook | |
106 | 502a5395 | pbrook | static uint32_t pci_unin_config_readl (void *opaque, |
107 | 502a5395 | pbrook | target_phys_addr_t addr) |
108 | 502a5395 | pbrook | { |
109 | 502a5395 | pbrook | UNINState *s = opaque; |
110 | 502a5395 | pbrook | |
111 | 2e29bd04 | Blue Swirl | return s->host_state.config_reg;
|
112 | 502a5395 | pbrook | } |
113 | 502a5395 | pbrook | |
114 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const pci_unin_config_write[] = { |
115 | 502a5395 | pbrook | &pci_unin_config_writel, |
116 | 502a5395 | pbrook | &pci_unin_config_writel, |
117 | 502a5395 | pbrook | &pci_unin_config_writel, |
118 | 502a5395 | pbrook | }; |
119 | 502a5395 | pbrook | |
120 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const pci_unin_config_read[] = { |
121 | 502a5395 | pbrook | &pci_unin_config_readl, |
122 | 502a5395 | pbrook | &pci_unin_config_readl, |
123 | 502a5395 | pbrook | &pci_unin_config_readl, |
124 | 502a5395 | pbrook | }; |
125 | 502a5395 | pbrook | |
126 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const pci_unin_write[] = { |
127 | 2e29bd04 | Blue Swirl | &pci_host_data_writeb, |
128 | 2e29bd04 | Blue Swirl | &pci_host_data_writew, |
129 | 2e29bd04 | Blue Swirl | &pci_host_data_writel, |
130 | 502a5395 | pbrook | }; |
131 | 502a5395 | pbrook | |
132 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const pci_unin_read[] = { |
133 | 2e29bd04 | Blue Swirl | &pci_host_data_readb, |
134 | 2e29bd04 | Blue Swirl | &pci_host_data_readw, |
135 | 2e29bd04 | Blue Swirl | &pci_host_data_readl, |
136 | 502a5395 | pbrook | }; |
137 | 502a5395 | pbrook | |
138 | d2b59317 | pbrook | /* Don't know if this matches real hardware, but it agrees with OHW. */
|
139 | d2b59317 | pbrook | static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num) |
140 | 502a5395 | pbrook | { |
141 | d2b59317 | pbrook | return (irq_num + (pci_dev->devfn >> 3)) & 3; |
142 | d2b59317 | pbrook | } |
143 | d2b59317 | pbrook | |
144 | d537cf6c | pbrook | static void pci_unin_set_irq(qemu_irq *pic, int irq_num, int level) |
145 | d2b59317 | pbrook | { |
146 | d537cf6c | pbrook | qemu_set_irq(pic[irq_num + 8], level);
|
147 | 502a5395 | pbrook | } |
148 | 502a5395 | pbrook | |
149 | f3902383 | blueswir1 | static void pci_unin_save(QEMUFile* f, void *opaque) |
150 | f3902383 | blueswir1 | { |
151 | f3902383 | blueswir1 | PCIDevice *d = opaque; |
152 | f3902383 | blueswir1 | |
153 | f3902383 | blueswir1 | pci_device_save(d, f); |
154 | f3902383 | blueswir1 | } |
155 | f3902383 | blueswir1 | |
156 | f3902383 | blueswir1 | static int pci_unin_load(QEMUFile* f, void *opaque, int version_id) |
157 | f3902383 | blueswir1 | { |
158 | f3902383 | blueswir1 | PCIDevice *d = opaque; |
159 | f3902383 | blueswir1 | |
160 | f3902383 | blueswir1 | if (version_id != 1) |
161 | f3902383 | blueswir1 | return -EINVAL;
|
162 | f3902383 | blueswir1 | |
163 | f3902383 | blueswir1 | return pci_device_load(d, f);
|
164 | f3902383 | blueswir1 | } |
165 | f3902383 | blueswir1 | |
166 | f3902383 | blueswir1 | static void pci_unin_reset(void *opaque) |
167 | f3902383 | blueswir1 | { |
168 | f3902383 | blueswir1 | } |
169 | f3902383 | blueswir1 | |
170 | 2e29bd04 | Blue Swirl | static void pci_unin_main_init_device(SysBusDevice *dev) |
171 | 502a5395 | pbrook | { |
172 | 502a5395 | pbrook | UNINState *s; |
173 | 502a5395 | pbrook | int pci_mem_config, pci_mem_data;
|
174 | 502a5395 | pbrook | |
175 | 502a5395 | pbrook | /* Use values found on a real PowerMac */
|
176 | 502a5395 | pbrook | /* Uninorth main bus */
|
177 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
178 | 502a5395 | pbrook | |
179 | 1eed09cb | Avi Kivity | pci_mem_config = cpu_register_io_memory(pci_unin_main_config_read, |
180 | 502a5395 | pbrook | pci_unin_main_config_write, s); |
181 | 1eed09cb | Avi Kivity | pci_mem_data = cpu_register_io_memory(pci_unin_main_read, |
182 | 2e29bd04 | Blue Swirl | pci_unin_main_write, &s->host_state); |
183 | 2e29bd04 | Blue Swirl | |
184 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_config);
|
185 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_data);
|
186 | 2e29bd04 | Blue Swirl | |
187 | 2e29bd04 | Blue Swirl | register_savevm("uninorth", 0, 1, pci_unin_save, pci_unin_load, &s->host_state); |
188 | 2e29bd04 | Blue Swirl | qemu_register_reset(pci_unin_reset, &s->host_state); |
189 | 2e29bd04 | Blue Swirl | pci_unin_reset(&s->host_state); |
190 | 2e29bd04 | Blue Swirl | } |
191 | 2e29bd04 | Blue Swirl | |
192 | 2e29bd04 | Blue Swirl | static void pci_dec_21154_init_device(SysBusDevice *dev) |
193 | 2e29bd04 | Blue Swirl | { |
194 | 2e29bd04 | Blue Swirl | UNINState *s; |
195 | 2e29bd04 | Blue Swirl | int pci_mem_config, pci_mem_data;
|
196 | 2e29bd04 | Blue Swirl | |
197 | 2e29bd04 | Blue Swirl | /* Uninorth bridge */
|
198 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
199 | 2e29bd04 | Blue Swirl | |
200 | 2e29bd04 | Blue Swirl | // XXX: s = &pci_bridge[2];
|
201 | 2e29bd04 | Blue Swirl | pci_mem_config = cpu_register_io_memory(pci_unin_config_read, |
202 | 2e29bd04 | Blue Swirl | pci_unin_config_write, s); |
203 | 2e29bd04 | Blue Swirl | pci_mem_data = cpu_register_io_memory(pci_unin_main_read, |
204 | 2e29bd04 | Blue Swirl | pci_unin_main_write, &s->host_state); |
205 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_config);
|
206 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_data);
|
207 | 2e29bd04 | Blue Swirl | } |
208 | 2e29bd04 | Blue Swirl | |
209 | 2e29bd04 | Blue Swirl | static void pci_unin_agp_init_device(SysBusDevice *dev) |
210 | 2e29bd04 | Blue Swirl | { |
211 | 2e29bd04 | Blue Swirl | UNINState *s; |
212 | 2e29bd04 | Blue Swirl | int pci_mem_config, pci_mem_data;
|
213 | 2e29bd04 | Blue Swirl | |
214 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
215 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
216 | 2e29bd04 | Blue Swirl | |
217 | 2e29bd04 | Blue Swirl | pci_mem_config = cpu_register_io_memory(pci_unin_config_read, |
218 | 2e29bd04 | Blue Swirl | pci_unin_config_write, s); |
219 | 2e29bd04 | Blue Swirl | pci_mem_data = cpu_register_io_memory(pci_unin_main_read, |
220 | 2e29bd04 | Blue Swirl | pci_unin_main_write, &s->host_state); |
221 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_config);
|
222 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_data);
|
223 | 2e29bd04 | Blue Swirl | } |
224 | 2e29bd04 | Blue Swirl | |
225 | 2e29bd04 | Blue Swirl | static void pci_unin_internal_init_device(SysBusDevice *dev) |
226 | 2e29bd04 | Blue Swirl | { |
227 | 2e29bd04 | Blue Swirl | UNINState *s; |
228 | 2e29bd04 | Blue Swirl | int pci_mem_config, pci_mem_data;
|
229 | 2e29bd04 | Blue Swirl | |
230 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
231 | 2e29bd04 | Blue Swirl | s = FROM_SYSBUS(UNINState, dev); |
232 | 2e29bd04 | Blue Swirl | |
233 | 2e29bd04 | Blue Swirl | pci_mem_config = cpu_register_io_memory(pci_unin_config_read, |
234 | 2e29bd04 | Blue Swirl | pci_unin_config_write, s); |
235 | 2e29bd04 | Blue Swirl | pci_mem_data = cpu_register_io_memory(pci_unin_read, |
236 | 2e29bd04 | Blue Swirl | pci_unin_write, s); |
237 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_config);
|
238 | 2e29bd04 | Blue Swirl | sysbus_init_mmio(dev, 0x1000, pci_mem_data);
|
239 | 2e29bd04 | Blue Swirl | } |
240 | 2e29bd04 | Blue Swirl | |
241 | 2e29bd04 | Blue Swirl | PCIBus *pci_pmac_init(qemu_irq *pic) |
242 | 2e29bd04 | Blue Swirl | { |
243 | 2e29bd04 | Blue Swirl | DeviceState *dev; |
244 | 2e29bd04 | Blue Swirl | SysBusDevice *s; |
245 | 2e29bd04 | Blue Swirl | UNINState *d; |
246 | 2e29bd04 | Blue Swirl | |
247 | 2e29bd04 | Blue Swirl | /* Use values found on a real PowerMac */
|
248 | 2e29bd04 | Blue Swirl | /* Uninorth main bus */
|
249 | 2e29bd04 | Blue Swirl | dev = qdev_create(NULL, "Uni-north main"); |
250 | 2e29bd04 | Blue Swirl | qdev_init(dev); |
251 | 2e29bd04 | Blue Swirl | s = sysbus_from_qdev(dev); |
252 | 2e29bd04 | Blue Swirl | d = FROM_SYSBUS(UNINState, s); |
253 | 2e29bd04 | Blue Swirl | d->host_state.bus = pci_register_bus(NULL, "pci", |
254 | 2e29bd04 | Blue Swirl | pci_unin_set_irq, pci_unin_map_irq, |
255 | 2e29bd04 | Blue Swirl | pic, 11 << 3, 4); |
256 | 2e29bd04 | Blue Swirl | |
257 | 2e29bd04 | Blue Swirl | pci_create_simple(d->host_state.bus, 11 << 3, "Uni-north main"); |
258 | 2e29bd04 | Blue Swirl | |
259 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 0, 0xf2800000); |
260 | 2e29bd04 | Blue Swirl | sysbus_mmio_map(s, 1, 0xf2c00000); |
261 | 2e29bd04 | Blue Swirl | |
262 | 2e29bd04 | Blue Swirl | /* DEC 21154 bridge */
|
263 | 2e29bd04 | Blue Swirl | #if 0
|
264 | 2e29bd04 | Blue Swirl | /* XXX: not activated as PPC BIOS doesn't handle multiple buses properly */
|
265 | 2e29bd04 | Blue Swirl | pci_create_simple(d->host_state.bus, 12 << 3, "DEC 21154");
|
266 | 2e29bd04 | Blue Swirl | #endif
|
267 | 2e29bd04 | Blue Swirl | |
268 | 2e29bd04 | Blue Swirl | /* Uninorth AGP bus */
|
269 | 2e29bd04 | Blue Swirl | pci_create_simple(d->host_state.bus, 13 << 3, "Uni-north AGP"); |
270 | 2e29bd04 | Blue Swirl | |
271 | 2e29bd04 | Blue Swirl | /* Uninorth internal bus */
|
272 | 2e29bd04 | Blue Swirl | #if 0
|
273 | 2e29bd04 | Blue Swirl | /* XXX: not needed for now */
|
274 | 2e29bd04 | Blue Swirl | pci_create_simple(d->host_state.bus, 14 << 3, "Uni-north internal");
|
275 | 2e29bd04 | Blue Swirl | #endif
|
276 | 2e29bd04 | Blue Swirl | |
277 | 2e29bd04 | Blue Swirl | return d->host_state.bus;
|
278 | 2e29bd04 | Blue Swirl | } |
279 | 2e29bd04 | Blue Swirl | |
280 | 2e29bd04 | Blue Swirl | static void unin_main_pci_host_init(PCIDevice *d) |
281 | 2e29bd04 | Blue Swirl | { |
282 | deb54399 | aliguori | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); |
283 | 4ebcf884 | blueswir1 | pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_PCI); |
284 | 502a5395 | pbrook | d->config[0x08] = 0x00; // revision |
285 | 173a543b | blueswir1 | pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); |
286 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
287 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
288 | 6407f373 | Isaku Yamahata | d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
289 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
290 | 2e29bd04 | Blue Swirl | } |
291 | 502a5395 | pbrook | |
292 | 2e29bd04 | Blue Swirl | static void dec_21154_pci_host_init(PCIDevice *d) |
293 | 2e29bd04 | Blue Swirl | { |
294 | 502a5395 | pbrook | /* pci-to-pci bridge */
|
295 | 4ebcf884 | blueswir1 | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_DEC); |
296 | 4ebcf884 | blueswir1 | pci_config_set_device_id(d->config, PCI_DEVICE_ID_DEC_21154); |
297 | 502a5395 | pbrook | d->config[0x08] = 0x05; // revision |
298 | 173a543b | blueswir1 | pci_config_set_class(d->config, PCI_CLASS_BRIDGE_PCI); |
299 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
300 | 502a5395 | pbrook | d->config[0x0D] = 0x20; // latency_timer |
301 | 6407f373 | Isaku Yamahata | d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_BRIDGE; // header_type
|
302 | 502a5395 | pbrook | |
303 | 502a5395 | pbrook | d->config[0x18] = 0x01; // primary_bus |
304 | 502a5395 | pbrook | d->config[0x19] = 0x02; // secondary_bus |
305 | 502a5395 | pbrook | d->config[0x1A] = 0x02; // subordinate_bus |
306 | 502a5395 | pbrook | d->config[0x1B] = 0x20; // secondary_latency_timer |
307 | 502a5395 | pbrook | d->config[0x1C] = 0x11; // io_base |
308 | 502a5395 | pbrook | d->config[0x1D] = 0x01; // io_limit |
309 | 502a5395 | pbrook | d->config[0x20] = 0x00; // memory_base |
310 | 502a5395 | pbrook | d->config[0x21] = 0x80; |
311 | 502a5395 | pbrook | d->config[0x22] = 0x00; // memory_limit |
312 | 502a5395 | pbrook | d->config[0x23] = 0x80; |
313 | 502a5395 | pbrook | d->config[0x24] = 0x01; // prefetchable_memory_base |
314 | 502a5395 | pbrook | d->config[0x25] = 0x80; |
315 | 502a5395 | pbrook | d->config[0x26] = 0xF1; // prefectchable_memory_limit |
316 | 502a5395 | pbrook | d->config[0x27] = 0x7F; |
317 | 502a5395 | pbrook | // d->config[0x34] = 0xdc // capabilities_pointer
|
318 | 2e29bd04 | Blue Swirl | } |
319 | 502a5395 | pbrook | |
320 | 2e29bd04 | Blue Swirl | static void unin_agp_pci_host_init(PCIDevice *d) |
321 | 2e29bd04 | Blue Swirl | { |
322 | deb54399 | aliguori | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); |
323 | deb54399 | aliguori | pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_AGP); |
324 | 502a5395 | pbrook | d->config[0x08] = 0x00; // revision |
325 | 173a543b | blueswir1 | pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); |
326 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
327 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
328 | 6407f373 | Isaku Yamahata | d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
329 | 502a5395 | pbrook | // d->config[0x34] = 0x80; // capabilities_pointer
|
330 | 2e29bd04 | Blue Swirl | } |
331 | 502a5395 | pbrook | |
332 | 2e29bd04 | Blue Swirl | static void unin_internal_pci_host_init(PCIDevice *d) |
333 | 2e29bd04 | Blue Swirl | { |
334 | deb54399 | aliguori | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_APPLE); |
335 | 4ebcf884 | blueswir1 | pci_config_set_device_id(d->config, PCI_DEVICE_ID_APPLE_UNI_N_I_PCI); |
336 | 502a5395 | pbrook | d->config[0x08] = 0x00; // revision |
337 | 173a543b | blueswir1 | pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); |
338 | 502a5395 | pbrook | d->config[0x0C] = 0x08; // cache_line_size |
339 | 502a5395 | pbrook | d->config[0x0D] = 0x10; // latency_timer |
340 | 6407f373 | Isaku Yamahata | d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
|
341 | 502a5395 | pbrook | d->config[0x34] = 0x00; // capabilities_pointer |
342 | 2e29bd04 | Blue Swirl | } |
343 | 2e29bd04 | Blue Swirl | |
344 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_main_pci_host_info = {
|
345 | 2e29bd04 | Blue Swirl | .qdev.name = "Uni-north main",
|
346 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
347 | 2e29bd04 | Blue Swirl | .init = unin_main_pci_host_init, |
348 | 2e29bd04 | Blue Swirl | }; |
349 | 2e29bd04 | Blue Swirl | |
350 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo dec_21154_pci_host_info = {
|
351 | 2e29bd04 | Blue Swirl | .qdev.name = "DEC 21154",
|
352 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
353 | 2e29bd04 | Blue Swirl | .init = dec_21154_pci_host_init, |
354 | 2e29bd04 | Blue Swirl | }; |
355 | f3902383 | blueswir1 | |
356 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_agp_pci_host_info = {
|
357 | 2e29bd04 | Blue Swirl | .qdev.name = "Uni-north AGP",
|
358 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
359 | 2e29bd04 | Blue Swirl | .init = unin_agp_pci_host_init, |
360 | 2e29bd04 | Blue Swirl | }; |
361 | 2e29bd04 | Blue Swirl | |
362 | 2e29bd04 | Blue Swirl | static PCIDeviceInfo unin_internal_pci_host_info = {
|
363 | 2e29bd04 | Blue Swirl | .qdev.name = "Uni-north internal",
|
364 | 2e29bd04 | Blue Swirl | .qdev.size = sizeof(PCIDevice),
|
365 | 2e29bd04 | Blue Swirl | .init = unin_internal_pci_host_init, |
366 | 2e29bd04 | Blue Swirl | }; |
367 | 2e29bd04 | Blue Swirl | |
368 | 2e29bd04 | Blue Swirl | static void unin_register_devices(void) |
369 | 2e29bd04 | Blue Swirl | { |
370 | 2e29bd04 | Blue Swirl | sysbus_register_dev("Uni-north main", sizeof(UNINState), |
371 | 2e29bd04 | Blue Swirl | pci_unin_main_init_device); |
372 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_main_pci_host_info); |
373 | 2e29bd04 | Blue Swirl | sysbus_register_dev("DEC 21154", sizeof(UNINState), |
374 | 2e29bd04 | Blue Swirl | pci_dec_21154_init_device); |
375 | 2e29bd04 | Blue Swirl | pci_qdev_register(&dec_21154_pci_host_info); |
376 | 2e29bd04 | Blue Swirl | sysbus_register_dev("Uni-north AGP", sizeof(UNINState), |
377 | 2e29bd04 | Blue Swirl | pci_unin_agp_init_device); |
378 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_agp_pci_host_info); |
379 | 2e29bd04 | Blue Swirl | sysbus_register_dev("Uni-north internal", sizeof(UNINState), |
380 | 2e29bd04 | Blue Swirl | pci_unin_internal_init_device); |
381 | 2e29bd04 | Blue Swirl | pci_qdev_register(&unin_internal_pci_host_info); |
382 | 502a5395 | pbrook | } |
383 | 2e29bd04 | Blue Swirl | |
384 | 2e29bd04 | Blue Swirl | device_init(unin_register_devices) |