root / hw / ppc_newworld.c @ a3867ed2
History | View | Annotate | Download (12.5 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 | 87ecb68b | pbrook | #include "net.h" |
33 | 87ecb68b | pbrook | #include "sysemu.h" |
34 | 87ecb68b | pbrook | #include "boards.h" |
35 | 006f3a48 | blueswir1 | #include "fw_cfg.h" |
36 | 7fa9ae1a | blueswir1 | #include "escc.h" |
37 | b7169916 | aurel32 | #include "openpic.h" |
38 | 267002cd | bellard | |
39 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
40 | 864c136a | blueswir1 | #define VGA_BIOS_SIZE 65536 |
41 | 006f3a48 | blueswir1 | #define CFG_ADDR 0xf0000510 |
42 | e4bcb14c | ths | |
43 | f3902383 | blueswir1 | /* debug UniNorth */
|
44 | f3902383 | blueswir1 | //#define DEBUG_UNIN
|
45 | f3902383 | blueswir1 | |
46 | f3902383 | blueswir1 | #ifdef DEBUG_UNIN
|
47 | f3902383 | blueswir1 | #define UNIN_DPRINTF(fmt, args...) \
|
48 | f3902383 | blueswir1 | do { printf("UNIN: " fmt , ##args); } while (0) |
49 | f3902383 | blueswir1 | #else
|
50 | f3902383 | blueswir1 | #define UNIN_DPRINTF(fmt, args...)
|
51 | f3902383 | blueswir1 | #endif
|
52 | f3902383 | blueswir1 | |
53 | 0aa6a4a2 | bellard | /* UniN device */
|
54 | 0aa6a4a2 | bellard | static void unin_writel (void *opaque, target_phys_addr_t addr, uint32_t value) |
55 | 0aa6a4a2 | bellard | { |
56 | f3902383 | blueswir1 | UNIN_DPRINTF("writel addr " TARGET_FMT_plx " val %x\n", addr, value); |
57 | 0aa6a4a2 | bellard | } |
58 | 0aa6a4a2 | bellard | |
59 | 0aa6a4a2 | bellard | static uint32_t unin_readl (void *opaque, target_phys_addr_t addr) |
60 | 0aa6a4a2 | bellard | { |
61 | f3902383 | blueswir1 | uint32_t value; |
62 | f3902383 | blueswir1 | |
63 | f3902383 | blueswir1 | value = 0;
|
64 | f3902383 | blueswir1 | UNIN_DPRINTF("readl addr " TARGET_FMT_plx " val %x\n", addr, value); |
65 | f3902383 | blueswir1 | |
66 | f3902383 | blueswir1 | return value;
|
67 | 0aa6a4a2 | bellard | } |
68 | 0aa6a4a2 | bellard | |
69 | 0aa6a4a2 | bellard | static CPUWriteMemoryFunc *unin_write[] = {
|
70 | 0aa6a4a2 | bellard | &unin_writel, |
71 | 0aa6a4a2 | bellard | &unin_writel, |
72 | 0aa6a4a2 | bellard | &unin_writel, |
73 | 0aa6a4a2 | bellard | }; |
74 | 0aa6a4a2 | bellard | |
75 | 0aa6a4a2 | bellard | static CPUReadMemoryFunc *unin_read[] = {
|
76 | 0aa6a4a2 | bellard | &unin_readl, |
77 | 0aa6a4a2 | bellard | &unin_readl, |
78 | 0aa6a4a2 | bellard | &unin_readl, |
79 | 0aa6a4a2 | bellard | }; |
80 | 0aa6a4a2 | bellard | |
81 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
82 | 513f789f | blueswir1 | { |
83 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
84 | 513f789f | blueswir1 | return 0; |
85 | 513f789f | blueswir1 | } |
86 | 513f789f | blueswir1 | |
87 | 3cbee15b | j_mayer | /* PowerPC Mac99 hardware initialisation */
|
88 | 00f82b8a | aurel32 | static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size, |
89 | 3023f332 | aliguori | const char *boot_device, |
90 | 3cbee15b | j_mayer | const char *kernel_filename, |
91 | 3cbee15b | j_mayer | const char *kernel_cmdline, |
92 | 3cbee15b | j_mayer | const char *initrd_filename, |
93 | 3cbee15b | j_mayer | const char *cpu_model) |
94 | 64201201 | bellard | { |
95 | aaed909a | bellard | CPUState *env = NULL, *envs[MAX_CPUS];
|
96 | 64201201 | bellard | char buf[1024]; |
97 | e9df014c | j_mayer | qemu_irq *pic, **openpic_irqs; |
98 | aef445bd | pbrook | int unin_memory;
|
99 | d5295253 | bellard | int linux_boot, i;
|
100 | b584726d | pbrook | ram_addr_t ram_offset, bios_offset, vga_bios_offset; |
101 | b6b8bd18 | bellard | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
102 | 46e50e9d | bellard | PCIBus *pci_bus; |
103 | 3cbee15b | j_mayer | MacIONVRAMState *nvr; |
104 | 3cbee15b | j_mayer | int nvram_mem_index;
|
105 | d5295253 | bellard | int vga_bios_size, bios_size;
|
106 | d537cf6c | pbrook | qemu_irq *dummy_irq; |
107 | 7fa9ae1a | blueswir1 | int pic_mem_index, dbdma_mem_index, cuda_mem_index, escc_mem_index;
|
108 | 28c5af54 | j_mayer | int ppc_boot_device;
|
109 | e4bcb14c | ths | int index;
|
110 | e4bcb14c | ths | BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
111 | 006f3a48 | blueswir1 | void *fw_cfg;
|
112 | 28ce5ce6 | aurel32 | void *dbdma;
|
113 | 44654490 | pbrook | uint8_t *vga_bios_ptr; |
114 | 46e50e9d | bellard | |
115 | 64201201 | bellard | linux_boot = (kernel_filename != NULL);
|
116 | 64201201 | bellard | |
117 | c68ea704 | bellard | /* init CPUs */
|
118 | 94fc95cd | j_mayer | if (cpu_model == NULL) |
119 | e6bd862b | aurel32 | cpu_model = "G4";
|
120 | e9df014c | j_mayer | for (i = 0; i < smp_cpus; i++) { |
121 | aaed909a | bellard | env = cpu_init(cpu_model); |
122 | aaed909a | bellard | if (!env) {
|
123 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
124 | aaed909a | bellard | exit(1);
|
125 | aaed909a | bellard | } |
126 | e9df014c | j_mayer | /* Set time-base frequency to 100 Mhz */
|
127 | e9df014c | j_mayer | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
128 | 3cbee15b | j_mayer | #if 0
|
129 | e9df014c | j_mayer | env->osi_call = vga_osi_call;
|
130 | 3cbee15b | j_mayer | #endif
|
131 | fe33cc71 | j_mayer | qemu_register_reset(&cpu_ppc_reset, env); |
132 | e9df014c | j_mayer | envs[i] = env; |
133 | e9df014c | j_mayer | } |
134 | c68ea704 | bellard | |
135 | 64201201 | bellard | /* allocate RAM */
|
136 | 864c136a | blueswir1 | ram_offset = qemu_ram_alloc(ram_size); |
137 | 864c136a | blueswir1 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
138 | 864c136a | blueswir1 | |
139 | 64201201 | bellard | /* allocate and load BIOS */
|
140 | 864c136a | blueswir1 | bios_offset = qemu_ram_alloc(BIOS_SIZE); |
141 | 1192dad8 | j_mayer | if (bios_name == NULL) |
142 | 006f3a48 | blueswir1 | bios_name = PROM_FILENAME; |
143 | 1192dad8 | j_mayer | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); |
144 | 006f3a48 | blueswir1 | cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); |
145 | 006f3a48 | blueswir1 | |
146 | 006f3a48 | blueswir1 | /* Load OpenBIOS (ELF) */
|
147 | 006f3a48 | blueswir1 | bios_size = load_elf(buf, 0, NULL, NULL, NULL); |
148 | d5295253 | bellard | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
149 | 4a057712 | j_mayer | cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
|
150 | 64201201 | bellard | exit(1);
|
151 | 64201201 | bellard | } |
152 | 3b46e624 | ths | |
153 | d5295253 | bellard | /* allocate and load VGA BIOS */
|
154 | 864c136a | blueswir1 | vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE); |
155 | 44654490 | pbrook | vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset); |
156 | d5295253 | bellard | snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); |
157 | 44654490 | pbrook | vga_bios_size = load_image(buf, vga_bios_ptr + 8);
|
158 | d5295253 | bellard | if (vga_bios_size < 0) { |
159 | d5295253 | bellard | /* if no bios is present, we can still work */
|
160 | d5295253 | bellard | fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf);
|
161 | d5295253 | bellard | vga_bios_size = 0;
|
162 | d5295253 | bellard | } else {
|
163 | d5295253 | bellard | /* set a specific header (XXX: find real Apple format for NDRV
|
164 | d5295253 | bellard | drivers) */
|
165 | 44654490 | pbrook | vga_bios_ptr[0] = 'N'; |
166 | 44654490 | pbrook | vga_bios_ptr[1] = 'D'; |
167 | 44654490 | pbrook | vga_bios_ptr[2] = 'R'; |
168 | 44654490 | pbrook | vga_bios_ptr[3] = 'V'; |
169 | 44654490 | pbrook | cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
|
170 | d5295253 | bellard | vga_bios_size += 8;
|
171 | d5295253 | bellard | } |
172 | 3b46e624 | ths | |
173 | b6b8bd18 | bellard | if (linux_boot) {
|
174 | 513f789f | blueswir1 | uint64_t lowaddr = 0;
|
175 | b6b8bd18 | bellard | kernel_base = KERNEL_LOAD_ADDR; |
176 | 513f789f | blueswir1 | |
177 | 513f789f | blueswir1 | /* Now we can load the kernel. The first step tries to load the kernel
|
178 | 513f789f | blueswir1 | supposing PhysAddr = 0x00000000. If that was wrong the kernel is
|
179 | 513f789f | blueswir1 | loaded again, the new PhysAddr being computed from lowaddr. */
|
180 | 513f789f | blueswir1 | kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL); |
181 | 513f789f | blueswir1 | if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) { |
182 | 513f789f | blueswir1 | kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
|
183 | 513f789f | blueswir1 | NULL, 0, NULL); |
184 | 513f789f | blueswir1 | } |
185 | 513f789f | blueswir1 | if (kernel_size < 0) |
186 | 513f789f | blueswir1 | kernel_size = load_aout(kernel_filename, kernel_base, |
187 | 513f789f | blueswir1 | ram_size - kernel_base); |
188 | 513f789f | blueswir1 | if (kernel_size < 0) |
189 | 513f789f | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
190 | 513f789f | blueswir1 | kernel_base, |
191 | 513f789f | blueswir1 | ram_size - kernel_base); |
192 | b6b8bd18 | bellard | if (kernel_size < 0) { |
193 | 4a057712 | j_mayer | cpu_abort(env, "qemu: could not load kernel '%s'\n",
|
194 | 4a057712 | j_mayer | kernel_filename); |
195 | b6b8bd18 | bellard | exit(1);
|
196 | b6b8bd18 | bellard | } |
197 | b6b8bd18 | bellard | /* load initrd */
|
198 | b6b8bd18 | bellard | if (initrd_filename) {
|
199 | b6b8bd18 | bellard | initrd_base = INITRD_LOAD_ADDR; |
200 | 44654490 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
201 | 44654490 | pbrook | ram_size - initrd_base); |
202 | b6b8bd18 | bellard | if (initrd_size < 0) { |
203 | 4a057712 | j_mayer | cpu_abort(env, "qemu: could not load initial ram disk '%s'\n",
|
204 | 4a057712 | j_mayer | initrd_filename); |
205 | b6b8bd18 | bellard | exit(1);
|
206 | b6b8bd18 | bellard | } |
207 | b6b8bd18 | bellard | } else {
|
208 | b6b8bd18 | bellard | initrd_base = 0;
|
209 | b6b8bd18 | bellard | initrd_size = 0;
|
210 | b6b8bd18 | bellard | } |
211 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
212 | b6b8bd18 | bellard | } else {
|
213 | b6b8bd18 | bellard | kernel_base = 0;
|
214 | b6b8bd18 | bellard | kernel_size = 0;
|
215 | b6b8bd18 | bellard | initrd_base = 0;
|
216 | b6b8bd18 | bellard | initrd_size = 0;
|
217 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
218 | 28c5af54 | j_mayer | /* We consider that NewWorld PowerMac never have any floppy drive
|
219 | 28c5af54 | j_mayer | * For now, OHW cannot boot from the network.
|
220 | 28c5af54 | j_mayer | */
|
221 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
222 | 0d913fdb | j_mayer | if (boot_device[i] >= 'c' && boot_device[i] <= 'f') { |
223 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
224 | 28c5af54 | j_mayer | break;
|
225 | 0d913fdb | j_mayer | } |
226 | 28c5af54 | j_mayer | } |
227 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
228 | 28c5af54 | j_mayer | fprintf(stderr, "No valid boot device for Mac99 machine\n");
|
229 | 28c5af54 | j_mayer | exit(1);
|
230 | 28c5af54 | j_mayer | } |
231 | b6b8bd18 | bellard | } |
232 | 0aa6a4a2 | bellard | |
233 | 3cbee15b | j_mayer | isa_mem_base = 0x80000000;
|
234 | aef445bd | pbrook | |
235 | 3cbee15b | j_mayer | /* Register 8 MB of ISA IO space */
|
236 | 3cbee15b | j_mayer | isa_mmio_init(0xf2000000, 0x00800000); |
237 | 3b46e624 | ths | |
238 | 3cbee15b | j_mayer | /* UniN init */
|
239 | 3cbee15b | j_mayer | unin_memory = cpu_register_io_memory(0, unin_read, unin_write, NULL); |
240 | 3cbee15b | j_mayer | cpu_register_physical_memory(0xf8000000, 0x00001000, unin_memory); |
241 | 47103572 | j_mayer | |
242 | 3cbee15b | j_mayer | openpic_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
|
243 | 3cbee15b | j_mayer | openpic_irqs[0] =
|
244 | 3cbee15b | j_mayer | qemu_mallocz(smp_cpus * sizeof(qemu_irq) * OPENPIC_OUTPUT_NB);
|
245 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
246 | 3cbee15b | j_mayer | /* Mac99 IRQ connection between OpenPIC outputs pins
|
247 | 3cbee15b | j_mayer | * and PowerPC input pins
|
248 | 3cbee15b | j_mayer | */
|
249 | 3cbee15b | j_mayer | switch (PPC_INPUT(env)) {
|
250 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_6xx:
|
251 | 3cbee15b | j_mayer | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
|
252 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
253 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
254 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
255 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
256 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
257 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_MCP]; |
258 | 3cbee15b | j_mayer | /* Not connected ? */
|
259 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
|
260 | 3cbee15b | j_mayer | /* Check this */
|
261 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
262 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_HRESET]; |
263 | 3cbee15b | j_mayer | break;
|
264 | 00af685f | j_mayer | #if defined(TARGET_PPC64)
|
265 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_970:
|
266 | 3cbee15b | j_mayer | openpic_irqs[i] = openpic_irqs[0] + (i * OPENPIC_OUTPUT_NB);
|
267 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_INT] = |
268 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
269 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_CINT] = |
270 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_INT]; |
271 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_MCK] = |
272 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_MCP]; |
273 | 3cbee15b | j_mayer | /* Not connected ? */
|
274 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_DEBUG] = NULL;
|
275 | 3cbee15b | j_mayer | /* Check this */
|
276 | 3cbee15b | j_mayer | openpic_irqs[i][OPENPIC_OUTPUT_RESET] = |
277 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC970_INPUT_HRESET]; |
278 | 3cbee15b | j_mayer | break;
|
279 | 00af685f | j_mayer | #endif /* defined(TARGET_PPC64) */ |
280 | 3cbee15b | j_mayer | default:
|
281 | 3cbee15b | j_mayer | cpu_abort(env, "Bus model not supported on mac99 machine\n");
|
282 | 3cbee15b | j_mayer | exit(1);
|
283 | 0aa6a4a2 | bellard | } |
284 | 3cbee15b | j_mayer | } |
285 | 3cbee15b | j_mayer | pic = openpic_init(NULL, &pic_mem_index, smp_cpus, openpic_irqs, NULL); |
286 | 3cbee15b | j_mayer | pci_bus = pci_pmac_init(pic); |
287 | 3cbee15b | j_mayer | /* init basic PC hardware */
|
288 | b584726d | pbrook | pci_vga_init(pci_bus, vga_ram_size, |
289 | 3cbee15b | j_mayer | vga_bios_offset, vga_bios_size); |
290 | aae9366a | j_mayer | |
291 | 3cbee15b | j_mayer | /* XXX: suppress that */
|
292 | 3cbee15b | j_mayer | dummy_irq = i8259_init(NULL);
|
293 | 3cbee15b | j_mayer | |
294 | aeeb69c7 | aurel32 | escc_mem_index = escc_init(0x80013000, dummy_irq[4], dummy_irq[5], |
295 | aeeb69c7 | aurel32 | serial_hds[0], serial_hds[1], ESCC_CLOCK, 4); |
296 | cb457d76 | aliguori | |
297 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
298 | cb457d76 | aliguori | pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci"); |
299 | cb457d76 | aliguori | |
300 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
301 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
302 | e4bcb14c | ths | exit(1);
|
303 | e4bcb14c | ths | } |
304 | e4bcb14c | ths | for(i = 0; i < MAX_IDE_BUS * MAX_IDE_DEVS; i++) { |
305 | e4bcb14c | ths | index = drive_get_index(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); |
306 | e4bcb14c | ths | if (index != -1) |
307 | e4bcb14c | ths | hd[i] = drives_table[index].bdrv; |
308 | e4bcb14c | ths | else
|
309 | e4bcb14c | ths | hd[i] = NULL;
|
310 | e4bcb14c | ths | } |
311 | 28ce5ce6 | aurel32 | dbdma = DBDMA_init(&dbdma_mem_index); |
312 | 77f0435e | blueswir1 | pci_cmd646_ide_init(pci_bus, hd, 0);
|
313 | 77f0435e | blueswir1 | |
314 | 3cbee15b | j_mayer | /* cuda also initialize ADB */
|
315 | 3cbee15b | j_mayer | cuda_init(&cuda_mem_index, pic[0x19]);
|
316 | aae9366a | j_mayer | |
317 | 3cbee15b | j_mayer | adb_kbd_init(&adb_bus); |
318 | 3cbee15b | j_mayer | adb_mouse_init(&adb_bus); |
319 | 3b46e624 | ths | |
320 | 3b46e624 | ths | |
321 | 4ebcf884 | blueswir1 | macio_init(pci_bus, PCI_DEVICE_ID_APPLE_UNI_N_KEYL, 0, pic_mem_index,
|
322 | 77f0435e | blueswir1 | dbdma_mem_index, cuda_mem_index, NULL, 0, NULL, |
323 | 4ebcf884 | blueswir1 | escc_mem_index); |
324 | 0d92ed30 | pbrook | |
325 | 0d92ed30 | pbrook | if (usb_enabled) {
|
326 | e24ad6f1 | pbrook | usb_ohci_init_pci(pci_bus, 3, -1); |
327 | 0d92ed30 | pbrook | } |
328 | 0d92ed30 | pbrook | |
329 | b6b8bd18 | bellard | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
330 | b6b8bd18 | bellard | graphic_depth = 15;
|
331 | 4f3f238b | blueswir1 | |
332 | 3cbee15b | j_mayer | /* The NewWorld NVRAM is not located in the MacIO device */
|
333 | 68af3f24 | blueswir1 | nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 1); |
334 | 3cbee15b | j_mayer | pmac_format_nvram_partition(nvr, 0x2000);
|
335 | 74e91155 | j_mayer | macio_nvram_map(nvr, 0xFFF04000);
|
336 | b6b8bd18 | bellard | /* No PCI init: the BIOS will do it */
|
337 | 0aa6a4a2 | bellard | |
338 | 006f3a48 | blueswir1 | fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
339 | 006f3a48 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
340 | 006f3a48 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
341 | 006f3a48 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_MAC99); |
342 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
343 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
344 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
345 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); |
346 | 513f789f | blueswir1 | pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline); |
347 | 513f789f | blueswir1 | } else {
|
348 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
349 | 513f789f | blueswir1 | } |
350 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
351 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
352 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
353 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
354 | aae9366a | j_mayer | } |
355 | 0aa6a4a2 | bellard | |
356 | 0aa6a4a2 | bellard | QEMUMachine core99_machine = { |
357 | 4b32e168 | aliguori | .name = "mac99",
|
358 | 4b32e168 | aliguori | .desc = "Mac99 based PowerMAC",
|
359 | 4b32e168 | aliguori | .init = ppc_core99_init, |
360 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
361 | 0aa6a4a2 | bellard | }; |