root / hw / ppc_newworld.c @ 3ced9f7a
History | View | Annotate | Download (13.4 kB)
1 | 64201201 | bellard | /*
|
---|---|---|---|
2 | 3cbee15b | j_mayer | * QEMU PowerPC CHRP (currently NewWorld PowerMac) hardware System Emulator
|
3 | 5fafdf24 | ths | *
|
4 | 47103572 | j_mayer | * Copyright (c) 2004-2007 Fabrice Bellard
|
5 | 3cbee15b | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
6 | 5fafdf24 | ths | *
|
7 | 64201201 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | 64201201 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
9 | 64201201 | bellard | * in the Software without restriction, including without limitation the rights
|
10 | 64201201 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | 64201201 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
12 | 64201201 | bellard | * furnished to do so, subject to the following conditions:
|
13 | 64201201 | bellard | *
|
14 | 64201201 | bellard | * The above copyright notice and this permission notice shall be included in
|
15 | 64201201 | bellard | * all copies or substantial portions of the Software.
|
16 | 64201201 | bellard | *
|
17 | 64201201 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | 64201201 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | 64201201 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | 64201201 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | 64201201 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | 64201201 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | 64201201 | bellard | * THE SOFTWARE.
|
24 | 64201201 | bellard | */
|
25 | 87ecb68b | pbrook | #include "hw.h" |
26 | 87ecb68b | pbrook | #include "ppc.h" |
27 | 3cbee15b | j_mayer | #include "ppc_mac.h" |
28 | 28ce5ce6 | aurel32 | #include "mac_dbdma.h" |
29 | 87ecb68b | pbrook | #include "nvram.h" |
30 | 87ecb68b | pbrook | #include "pc.h" |
31 | 87ecb68b | pbrook | #include "pci.h" |
32 | 18e08a55 | Michael S. Tsirkin | #include "usb-ohci.h" |
33 | 87ecb68b | pbrook | #include "net.h" |
34 | 87ecb68b | pbrook | #include "sysemu.h" |
35 | 87ecb68b | pbrook | #include "boards.h" |
36 | 006f3a48 | blueswir1 | #include "fw_cfg.h" |
37 | 7fa9ae1a | blueswir1 | #include "escc.h" |
38 | b7169916 | aurel32 | #include "openpic.h" |
39 | 977e1244 | Gerd Hoffmann | #include "ide.h" |
40 | ca20cf32 | Blue Swirl | #include "loader.h" |
41 | ca20cf32 | Blue Swirl | #include "elf.h" |
42 | 267002cd | bellard | |
43 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
44 | 864c136a | blueswir1 | #define VGA_BIOS_SIZE 65536 |
45 | 006f3a48 | blueswir1 | #define CFG_ADDR 0xf0000510 |
46 | e4bcb14c | ths | |
47 | f3902383 | blueswir1 | /* debug UniNorth */
|
48 | f3902383 | blueswir1 | //#define DEBUG_UNIN
|
49 | f3902383 | blueswir1 | |
50 | f3902383 | blueswir1 | #ifdef DEBUG_UNIN
|
51 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...) \
|
52 | 001faf32 | Blue Swirl | do { printf("UNIN: " fmt , ## __VA_ARGS__); } while (0) |
53 | f3902383 | blueswir1 | #else
|
54 | 001faf32 | Blue Swirl | #define UNIN_DPRINTF(fmt, ...)
|
55 | f3902383 | blueswir1 | #endif
|
56 | f3902383 | blueswir1 | |
57 | 0aa6a4a2 | bellard | /* UniN device */
|
58 | c227f099 | Anthony Liguori | static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value) |
59 | 0aa6a4a2 | bellard | { |
60 | f3902383 | blueswir1 | UNIN_DPRINTF("writel addr " TARGET_FMT_plx " val %x\n", addr, value); |
61 | 0aa6a4a2 | bellard | } |
62 | 0aa6a4a2 | bellard | |
63 | c227f099 | Anthony Liguori | static uint32_t unin_readl (void *opaque, target_phys_addr_t addr) |
64 | 0aa6a4a2 | bellard | { |
65 | f3902383 | blueswir1 | uint32_t value; |
66 | f3902383 | blueswir1 | |
67 | f3902383 | blueswir1 | value = 0;
|
68 | f3902383 | blueswir1 | UNIN_DPRINTF("readl addr " TARGET_FMT_plx " val %x\n", addr, value); |
69 | f3902383 | blueswir1 | |
70 | f3902383 | blueswir1 | return value;
|
71 | 0aa6a4a2 | bellard | } |
72 | 0aa6a4a2 | bellard | |
73 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const unin_write[] = { |
74 | 0aa6a4a2 | bellard | &unin_writel, |
75 | 0aa6a4a2 | bellard | &unin_writel, |
76 | 0aa6a4a2 | bellard | &unin_writel, |
77 | 0aa6a4a2 | bellard | }; |
78 | 0aa6a4a2 | bellard | |
79 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const unin_read[] = { |
80 | 0aa6a4a2 | bellard | &unin_readl, |
81 | 0aa6a4a2 | bellard | &unin_readl, |
82 | 0aa6a4a2 | bellard | &unin_readl, |
83 | 0aa6a4a2 | bellard | }; |
84 | 0aa6a4a2 | bellard | |
85 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
86 | 513f789f | blueswir1 | { |
87 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
88 | 513f789f | blueswir1 | return 0; |
89 | 513f789f | blueswir1 | } |
90 | 513f789f | blueswir1 | |
91 | 3cbee15b | j_mayer | /* PowerPC Mac99 hardware initialisation */
|
92 | c227f099 | Anthony Liguori | static void ppc_core99_init (ram_addr_t ram_size, |
93 | 3023f332 | aliguori | const char *boot_device, |
94 | 3cbee15b | j_mayer | const char *kernel_filename, |
95 | 3cbee15b | j_mayer | const char *kernel_cmdline, |
96 | 3cbee15b | j_mayer | const char *initrd_filename, |
97 | 3cbee15b | j_mayer | const char *cpu_model) |
98 | 64201201 | bellard | { |
99 | aaed909a | bellard | CPUState *env = NULL, *envs[MAX_CPUS];
|
100 | 5cea8590 | Paul Brook | char *filename;
|
101 | e9df014c | j_mayer | qemu_irq *pic, **openpic_irqs; |
102 | aef445bd | pbrook | int unin_memory;
|
103 | d5295253 | bellard | int linux_boot, i;
|
104 | c227f099 | Anthony Liguori | ram_addr_t ram_offset, bios_offset, vga_bios_offset; |
105 | b6b8bd18 | bellard | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
106 | 46e50e9d | bellard | PCIBus *pci_bus; |
107 | 3cbee15b | j_mayer | MacIONVRAMState *nvr; |
108 | 3cbee15b | j_mayer | int nvram_mem_index;
|
109 | d5295253 | bellard | int vga_bios_size, bios_size;
|
110 | d537cf6c | pbrook | qemu_irq *dummy_irq; |
111 | 7fa9ae1a | blueswir1 | int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
|
112 | 28c5af54 | j_mayer | int ppc_boot_device;
|
113 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
114 | 006f3a48 | blueswir1 | void *fw_cfg;
|
115 | 28ce5ce6 | aurel32 | void *dbdma;
|
116 | 44654490 | pbrook | uint8_t *vga_bios_ptr; |
117 | 46e50e9d | bellard | |
118 | 64201201 | bellard | linux_boot = (kernel_filename != NULL);
|
119 | 64201201 | bellard | |
120 | c68ea704 | bellard | /* init CPUs */
|
121 | 94fc95cd | j_mayer | if (cpu_model == NULL) |
122 | e6bd862b | aurel32 | cpu_model = "G4";
|
123 | e9df014c | j_mayer | for (i = 0; i < smp_cpus; i++) { |
124 | aaed909a | bellard | env = cpu_init(cpu_model); |
125 | aaed909a | bellard | if (!env) {
|
126 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
127 | aaed909a | bellard | exit(1);
|
128 | aaed909a | bellard | } |
129 | e9df014c | j_mayer | /* Set time-base frequency to 100 Mhz */
|
130 | e9df014c | j_mayer | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
131 | 3cbee15b | j_mayer | #if 0
|
132 | e9df014c | j_mayer | env->osi_call = vga_osi_call;
|
133 | 3cbee15b | j_mayer | #endif
|
134 | d84bda46 | Blue Swirl | qemu_register_reset((QEMUResetHandler*)&cpu_reset, env); |
135 | e9df014c | j_mayer | envs[i] = env; |
136 | e9df014c | j_mayer | } |
137 | c68ea704 | bellard | |
138 | 64201201 | bellard | /* allocate RAM */
|
139 | 864c136a | blueswir1 | ram_offset = qemu_ram_alloc(ram_size); |
140 | 864c136a | blueswir1 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
141 | 864c136a | blueswir1 | |
142 | 64201201 | bellard | /* allocate and load BIOS */
|
143 | 864c136a | blueswir1 | bios_offset = qemu_ram_alloc(BIOS_SIZE); |
144 | 1192dad8 | j_mayer | if (bios_name == NULL) |
145 | 006f3a48 | blueswir1 | bios_name = PROM_FILENAME; |
146 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
147 | 006f3a48 | blueswir1 | cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); |
148 | 006f3a48 | blueswir1 | |
149 | 006f3a48 | blueswir1 | /* Load OpenBIOS (ELF) */
|
150 | 5cea8590 | Paul Brook | if (filename) {
|
151 | ca20cf32 | Blue Swirl | bios_size = load_elf(filename, 0, NULL, NULL, NULL, 1, ELF_MACHINE, 0); |
152 | ca20cf32 | Blue Swirl | |
153 | 5cea8590 | Paul Brook | qemu_free(filename); |
154 | 5cea8590 | Paul Brook | } else {
|
155 | 5cea8590 | Paul Brook | bios_size = -1;
|
156 | 5cea8590 | Paul Brook | } |
157 | d5295253 | bellard | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
158 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
|
159 | 64201201 | bellard | exit(1);
|
160 | 64201201 | bellard | } |
161 | 3b46e624 | ths | |
162 | d5295253 | bellard | /* allocate and load VGA BIOS */
|
163 | 864c136a | blueswir1 | vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE); |
164 | 44654490 | pbrook | vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset); |
165 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME); |
166 | 5cea8590 | Paul Brook | if (filename) {
|
167 | 5cea8590 | Paul Brook | vga_bios_size = load_image(filename, vga_bios_ptr + 8);
|
168 | 5cea8590 | Paul Brook | qemu_free(filename); |
169 | 5cea8590 | Paul Brook | } else {
|
170 | 5cea8590 | Paul Brook | vga_bios_size = -1;
|
171 | 5cea8590 | Paul Brook | } |
172 | d5295253 | bellard | if (vga_bios_size < 0) { |
173 | d5295253 | bellard | /* if no bios is present, we can still work */
|
174 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n",
|
175 | 5cea8590 | Paul Brook | VGABIOS_FILENAME); |
176 | d5295253 | bellard | vga_bios_size = 0;
|
177 | d5295253 | bellard | } else {
|
178 | d5295253 | bellard | /* set a specific header (XXX: find real Apple format for NDRV
|
179 | d5295253 | bellard | drivers) */
|
180 | 44654490 | pbrook | vga_bios_ptr[0] = 'N'; |
181 | 44654490 | pbrook | vga_bios_ptr[1] = 'D'; |
182 | 44654490 | pbrook | vga_bios_ptr[2] = 'R'; |
183 | 44654490 | pbrook | vga_bios_ptr[3] = 'V'; |
184 | 44654490 | pbrook | cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
|
185 | d5295253 | bellard | vga_bios_size += 8;
|
186 | a7b022e0 | Alexander Graf | |
187 | a7b022e0 | Alexander Graf | /* Round to page boundary */
|
188 | a7b022e0 | Alexander Graf | vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE - 1) &
|
189 | a7b022e0 | Alexander Graf | TARGET_PAGE_MASK; |
190 | d5295253 | bellard | } |
191 | 3b46e624 | ths | |
192 | b6b8bd18 | bellard | if (linux_boot) {
|
193 | 513f789f | blueswir1 | uint64_t lowaddr = 0;
|
194 | ca20cf32 | Blue Swirl | int bswap_needed;
|
195 | ca20cf32 | Blue Swirl | |
196 | ca20cf32 | Blue Swirl | #ifdef BSWAP_NEEDED
|
197 | ca20cf32 | Blue Swirl | bswap_needed = 1;
|
198 | ca20cf32 | Blue Swirl | #else
|
199 | ca20cf32 | Blue Swirl | bswap_needed = 0;
|
200 | ca20cf32 | Blue Swirl | #endif
|
201 | b6b8bd18 | bellard | kernel_base = KERNEL_LOAD_ADDR; |
202 | 513f789f | blueswir1 | |
203 | 513f789f | blueswir1 | /* Now we can load the kernel. The first step tries to load the kernel
|
204 | 513f789f | blueswir1 | supposing PhysAddr = 0x00000000. If that was wrong the kernel is
|
205 | 513f789f | blueswir1 | loaded again, the new PhysAddr being computed from lowaddr. */
|
206 | ca20cf32 | Blue Swirl | kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL, |
207 | ca20cf32 | Blue Swirl | 1, ELF_MACHINE, 0); |
208 | 513f789f | blueswir1 | if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) { |
209 | 513f789f | blueswir1 | kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
|
210 | ca20cf32 | Blue Swirl | NULL, NULL, NULL, 1, ELF_MACHINE, 0); |
211 | 513f789f | blueswir1 | } |
212 | 513f789f | blueswir1 | if (kernel_size < 0) |
213 | 513f789f | blueswir1 | kernel_size = load_aout(kernel_filename, kernel_base, |
214 | ca20cf32 | Blue Swirl | ram_size - kernel_base, bswap_needed, |
215 | ca20cf32 | Blue Swirl | TARGET_PAGE_SIZE); |
216 | 513f789f | blueswir1 | if (kernel_size < 0) |
217 | 513f789f | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
218 | 513f789f | blueswir1 | kernel_base, |
219 | 513f789f | blueswir1 | ram_size - kernel_base); |
220 | b6b8bd18 | bellard | if (kernel_size < 0) { |
221 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n", kernel_filename);
|
222 | b6b8bd18 | bellard | exit(1);
|
223 | b6b8bd18 | bellard | } |
224 | b6b8bd18 | bellard | /* load initrd */
|
225 | b6b8bd18 | bellard | if (initrd_filename) {
|
226 | b6b8bd18 | bellard | initrd_base = INITRD_LOAD_ADDR; |
227 | 44654490 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
228 | 44654490 | pbrook | ram_size - initrd_base); |
229 | b6b8bd18 | bellard | if (initrd_size < 0) { |
230 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
231 | 2ac71179 | Paul Brook | initrd_filename); |
232 | b6b8bd18 | bellard | exit(1);
|
233 | b6b8bd18 | bellard | } |
234 | b6b8bd18 | bellard | } else {
|
235 | b6b8bd18 | bellard | initrd_base = 0;
|
236 | b6b8bd18 | bellard | initrd_size = 0;
|
237 | b6b8bd18 | bellard | } |
238 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
239 | b6b8bd18 | bellard | } else {
|
240 | b6b8bd18 | bellard | kernel_base = 0;
|
241 | b6b8bd18 | bellard | kernel_size = 0;
|
242 | b6b8bd18 | bellard | initrd_base = 0;
|
243 | b6b8bd18 | bellard | initrd_size = 0;
|
244 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
245 | 28c5af54 | j_mayer | /* We consider that NewWorld PowerMac never have any floppy drive
|
246 | 28c5af54 | j_mayer | * For now, OHW cannot boot from the network.
|
247 | 28c5af54 | j_mayer | */
|
248 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
249 | 0d913fdb | j_mayer | if (boot_device[i] >= 'c' && boot_device[i] <= 'f') { |
250 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
251 | 28c5af54 | j_mayer | break;
|
252 | 0d913fdb | j_mayer | } |
253 | 28c5af54 | j_mayer | } |
254 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
255 | 28c5af54 | j_mayer | fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
256 | 28c5af54 | j_mayer | exit(1);
|
257 | 28c5af54 | j_mayer | } |
258 | b6b8bd18 | bellard | } |
259 | 0aa6a4a2 | bellard | |
260 | 3cbee15b | j_mayer | isa_mem_base = 0x80000000;
|
261 | aef445bd | pbrook | |
262 | 3cbee15b | j_mayer | /* Register 8 MB of ISA IO space */
|
263 | 3cbee15b | j_mayer | isa_mmio_init(0xf2000000, 0x00800000); |
264 | 3b46e624 | ths | |
265 | 3cbee15b | j_mayer | /* UniN init */
|
266 | 1eed09cb | Avi Kivity | unin_memory = cpu_register_io_memory(unin_read, unin_write, NULL);
|
267 | 3cbee15b | j_mayer | cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); |
268 | 47103572 | j_mayer | |
269 | 3cbee15b | j_mayer | openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
|
270 | 3cbee15b | j_mayer | openpic_irqs[0] =
|
271 | 3cbee15b | j_mayer | qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
|
272 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
273 | 3cbee15b | j_mayer | /* Mac99 IRQ connection between OpenPIC outputs pins
|
274 | 3cbee15b | j_mayer | * and PowerPC input pins
|
275 | 3cbee15b | j_mayer | */
|
276 | 3cbee15b | j_mayer | switch (PPC_INPUT(env)) {
|
277 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_6xx:
|
278 | 3cbee15b | j_mayer | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
|
279 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
280 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
281 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
282 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
283 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
284 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP]; |
285 | 3cbee15b | j_mayer | /* Not connected ? */
|
286 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
|
287 | 3cbee15b | j_mayer | /* Check this */
|
288 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
289 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET]; |
290 | 3cbee15b | j_mayer | break;
|
291 | 00af685f | j_mayer | #if defined(TARGET_PPC64)
|
292 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_970:
|
293 | 3cbee15b | j_mayer | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
|
294 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
295 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
296 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
297 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
298 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
299 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP]; |
300 | 3cbee15b | j_mayer | /* Not connected ? */
|
301 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
|
302 | 3cbee15b | j_mayer | /* Check this */
|
303 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
304 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET]; |
305 | 3cbee15b | j_mayer | break;
|
306 | 00af685f | j_mayer | #endif /* defined(TARGET_PPC64) */ |
307 | 3cbee15b | j_mayer | default:
|
308 | 2ac71179 | Paul Brook | hw_error("Bus model not supported on mac99 machine\n");
|
309 | 3cbee15b | j_mayer | exit(1);
|
310 | 0aa6a4a2 | bellard | } |
311 | 3cbee15b | j_mayer | } |
312 | 3cbee15b | j_mayer | pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL); |
313 | 3cbee15b | j_mayer | pci_bus = pci_pmac_init(pic); |
314 | 3cbee15b | j_mayer | /* init basic PC hardware */
|
315 | fbe1b595 | Paul Brook | pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size); |
316 | aae9366a | j_mayer | |
317 | 3cbee15b | j_mayer | /* XXX: suppress that */
|
318 | 3cbee15b | j_mayer | dummy_irq = i8259_init(NULL);
|
319 | 3cbee15b | j_mayer | |
320 | aeeb69c7 | aurel32 | escc_mem_index = escc_init(0x80013000, dummy_irq[4], dummy_irq[5], |
321 | aeeb69c7 | aurel32 | serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); |
322 | cb457d76 | aliguori | |
323 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
324 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL); |
325 | cb457d76 | aliguori | |
326 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
327 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
328 | e4bcb14c | ths | exit(1);
|
329 | e4bcb14c | ths | } |
330 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
331 | f455e98c | Gerd Hoffmann | hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
332 | e4bcb14c | ths | } |
333 | 28ce5ce6 | aurel32 | dbdma = DBDMA_init(&dbdma_mem_index); |
334 | 77f0435e | blueswir1 | pci_cmd646_ide_init(pci_bus, hd, 0);
|
335 | 77f0435e | blueswir1 | |
336 | 3cbee15b | j_mayer | /* cuda also initialize ADB */
|
337 | 3cbee15b | j_mayer | cuda_init(&cuda_mem_index, pic[0x19]);
|
338 | aae9366a | j_mayer | |
339 | 3cbee15b | j_mayer | adb_kbd_init(&adb_bus); |
340 | 3cbee15b | j_mayer | adb_mouse_init(&adb_bus); |
341 | 3b46e624 | ths | |
342 | 3b46e624 | ths | |
343 | 4ebcf884 | blueswir1 | macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
|
344 | 77f0435e | blueswir1 | dbdma_mem_index, cuda_mem_index, NULL, 0, NULL, |
345 | 4ebcf884 | blueswir1 | escc_mem_index); |
346 | 0d92ed30 | pbrook | |
347 | 0d92ed30 | pbrook | if (usb_enabled) {
|
348 | 5b19d9a2 | Gerd Hoffmann | usb_ohci_init_pci(pci_bus, -1);
|
349 | 0d92ed30 | pbrook | } |
350 | 0d92ed30 | pbrook | |
351 | b6b8bd18 | bellard | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
352 | b6b8bd18 | bellard | graphic_depth = 15;
|
353 | 4f3f238b | blueswir1 | |
354 | 3cbee15b | j_mayer | /* The NewWorld NVRAM is not located in the MacIO device */
|
355 | 68af3f24 | blueswir1 | nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1); |
356 | 3cbee15b | j_mayer | pmac_format_nvram_partition(nvr, 0x2000);
|
357 | 74e91155 | j_mayer | macio_nvram_map(nvr, 0xFFF04000);
|
358 | b6b8bd18 | bellard | /* No PCI init: the BIOS will do it */
|
359 | 0aa6a4a2 | bellard | |
360 | 006f3a48 | blueswir1 | fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
361 | 006f3a48 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
362 | 006f3a48 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
363 | 006f3a48 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_MAC99); |
364 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
365 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
366 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
367 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); |
368 | 3c178e72 | Gerd Hoffmann | pstrcpy_targphys("cmdline", CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
|
369 | 513f789f | blueswir1 | } else {
|
370 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
371 | 513f789f | blueswir1 | } |
372 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
373 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
374 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
375 | 10696b4f | Blue Swirl | |
376 | 10696b4f | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); |
377 | 10696b4f | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
378 | 10696b4f | Blue Swirl | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
379 | 10696b4f | Blue Swirl | |
380 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
381 | aae9366a | j_mayer | } |
382 | 0aa6a4a2 | bellard | |
383 | f80f9ec9 | Anthony Liguori | static QEMUMachine core99_machine = {
|
384 | 4b32e168 | aliguori | .name = "mac99",
|
385 | 4b32e168 | aliguori | .desc = "Mac99 based PowerMAC",
|
386 | 4b32e168 | aliguori | .init = ppc_core99_init, |
387 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
388 | 0aa6a4a2 | bellard | }; |
389 | f80f9ec9 | Anthony Liguori | |
390 | f80f9ec9 | Anthony Liguori | static void core99_machine_init(void) |
391 | f80f9ec9 | Anthony Liguori | { |
392 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&core99_machine); |
393 | f80f9ec9 | Anthony Liguori | } |
394 | f80f9ec9 | Anthony Liguori | |
395 | f80f9ec9 | Anthony Liguori | machine_init(core99_machine_init); |