root / hw / ppc_oldworld.c @ f7b4f61f
History | View | Annotate | Download (13.6 kB)
1 | 3cbee15b | j_mayer | /*
|
---|---|---|---|
2 | 4d7ca41e | aurel32 | * QEMU OldWorld PowerMac (currently ~G3 Beige) hardware System Emulator
|
3 | 3cbee15b | j_mayer | *
|
4 | 3cbee15b | j_mayer | * Copyright (c) 2004-2007 Fabrice Bellard
|
5 | 3cbee15b | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
6 | 3cbee15b | j_mayer | *
|
7 | 3cbee15b | j_mayer | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | 3cbee15b | j_mayer | * of this software and associated documentation files (the "Software"), to deal
|
9 | 3cbee15b | j_mayer | * in the Software without restriction, including without limitation the rights
|
10 | 3cbee15b | j_mayer | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | 3cbee15b | j_mayer | * copies of the Software, and to permit persons to whom the Software is
|
12 | 3cbee15b | j_mayer | * furnished to do so, subject to the following conditions:
|
13 | 3cbee15b | j_mayer | *
|
14 | 3cbee15b | j_mayer | * The above copyright notice and this permission notice shall be included in
|
15 | 3cbee15b | j_mayer | * all copies or substantial portions of the Software.
|
16 | 3cbee15b | j_mayer | *
|
17 | 3cbee15b | j_mayer | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | 3cbee15b | j_mayer | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | 3cbee15b | j_mayer | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | 3cbee15b | j_mayer | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | 3cbee15b | j_mayer | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | 3cbee15b | j_mayer | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | 3cbee15b | j_mayer | * THE SOFTWARE.
|
24 | 3cbee15b | j_mayer | */
|
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 "sysemu.h" |
32 | 87ecb68b | pbrook | #include "net.h" |
33 | 87ecb68b | pbrook | #include "isa.h" |
34 | 87ecb68b | pbrook | #include "pci.h" |
35 | 87ecb68b | pbrook | #include "boards.h" |
36 | 271dd5e0 | blueswir1 | #include "fw_cfg.h" |
37 | 7fa9ae1a | blueswir1 | #include "escc.h" |
38 | 977e1244 | Gerd Hoffmann | #include "ide.h" |
39 | 3cbee15b | j_mayer | |
40 | e4bcb14c | ths | #define MAX_IDE_BUS 2 |
41 | a748ab6d | aurel32 | #define VGA_BIOS_SIZE 65536 |
42 | 271dd5e0 | blueswir1 | #define CFG_ADDR 0xf0000510 |
43 | 271dd5e0 | blueswir1 | |
44 | 3cbee15b | j_mayer | /* temporary frame buffer OSI calls for the video.x driver. The right
|
45 | 3cbee15b | j_mayer | solution is to modify the driver to use VGA PCI I/Os */
|
46 | 3cbee15b | j_mayer | /* XXX: to be removed. This is no way related to emulation */
|
47 | 3cbee15b | j_mayer | static int vga_osi_call (CPUState *env) |
48 | 3cbee15b | j_mayer | { |
49 | 3cbee15b | j_mayer | static int vga_vbl_enabled; |
50 | 3cbee15b | j_mayer | int linesize;
|
51 | 3cbee15b | j_mayer | |
52 | b11ebf64 | Blue Swirl | #if 0
|
53 | b11ebf64 | Blue Swirl | printf("osi_call R5=%016" PRIx64 "\n", ppc_dump_gpr(env, 5));
|
54 | b11ebf64 | Blue Swirl | #endif
|
55 | 3cbee15b | j_mayer | |
56 | 3cbee15b | j_mayer | /* same handler as PearPC, coming from the original MOL video
|
57 | 3cbee15b | j_mayer | driver. */
|
58 | 3cbee15b | j_mayer | switch(env->gpr[5]) { |
59 | 3cbee15b | j_mayer | case 4: |
60 | 3cbee15b | j_mayer | break;
|
61 | 3cbee15b | j_mayer | case 28: /* set_vmode */ |
62 | 3cbee15b | j_mayer | if (env->gpr[6] != 1 || env->gpr[7] != 0) |
63 | 3cbee15b | j_mayer | env->gpr[3] = 1; |
64 | 3cbee15b | j_mayer | else
|
65 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
66 | 3cbee15b | j_mayer | break;
|
67 | 3cbee15b | j_mayer | case 29: /* get_vmode_info */ |
68 | 3cbee15b | j_mayer | if (env->gpr[6] != 0) { |
69 | 3cbee15b | j_mayer | if (env->gpr[6] != 1 || env->gpr[7] != 0) { |
70 | 3cbee15b | j_mayer | env->gpr[3] = 1; |
71 | 3cbee15b | j_mayer | break;
|
72 | 3cbee15b | j_mayer | } |
73 | 3cbee15b | j_mayer | } |
74 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
75 | 3cbee15b | j_mayer | env->gpr[4] = (1 << 16) | 1; /* num_vmodes, cur_vmode */ |
76 | 3cbee15b | j_mayer | env->gpr[5] = (1 << 16) | 0; /* num_depths, cur_depth_mode */ |
77 | 3cbee15b | j_mayer | env->gpr[6] = (graphic_width << 16) | graphic_height; /* w, h */ |
78 | 3cbee15b | j_mayer | env->gpr[7] = 85 << 16; /* refresh rate */ |
79 | 3cbee15b | j_mayer | env->gpr[8] = (graphic_depth + 7) & ~7; /* depth (round to byte) */ |
80 | 3cbee15b | j_mayer | linesize = ((graphic_depth + 7) >> 3) * graphic_width; |
81 | 3cbee15b | j_mayer | linesize = (linesize + 3) & ~3; |
82 | 3cbee15b | j_mayer | env->gpr[9] = (linesize << 16) | 0; /* row_bytes, offset */ |
83 | 3cbee15b | j_mayer | break;
|
84 | 3cbee15b | j_mayer | case 31: /* set_video power */ |
85 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
86 | 3cbee15b | j_mayer | break;
|
87 | 3cbee15b | j_mayer | case 39: /* video_ctrl */ |
88 | 3cbee15b | j_mayer | if (env->gpr[6] == 0 || env->gpr[6] == 1) |
89 | 3cbee15b | j_mayer | vga_vbl_enabled = env->gpr[6];
|
90 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
91 | 3cbee15b | j_mayer | break;
|
92 | 3cbee15b | j_mayer | case 47: |
93 | 3cbee15b | j_mayer | break;
|
94 | 3cbee15b | j_mayer | case 59: /* set_color */ |
95 | 3cbee15b | j_mayer | /* R6 = index, R7 = RGB */
|
96 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
97 | 3cbee15b | j_mayer | break;
|
98 | 3cbee15b | j_mayer | case 64: /* get color */ |
99 | 3cbee15b | j_mayer | /* R6 = index */
|
100 | 3cbee15b | j_mayer | env->gpr[3] = 0; |
101 | 3cbee15b | j_mayer | break;
|
102 | 3cbee15b | j_mayer | case 116: /* set hwcursor */ |
103 | 3cbee15b | j_mayer | /* R6 = x, R7 = y, R8 = visible, R9 = data */
|
104 | 3cbee15b | j_mayer | break;
|
105 | 3cbee15b | j_mayer | default:
|
106 | b11ebf64 | Blue Swirl | fprintf(stderr, "unsupported OSI call R5=%016" PRIx64 "\n", |
107 | aae9366a | j_mayer | ppc_dump_gpr(env, 5));
|
108 | 3cbee15b | j_mayer | break;
|
109 | 3cbee15b | j_mayer | } |
110 | 3cbee15b | j_mayer | |
111 | 3cbee15b | j_mayer | return 1; /* osi_call handled */ |
112 | 3cbee15b | j_mayer | } |
113 | 3cbee15b | j_mayer | |
114 | 513f789f | blueswir1 | static int fw_cfg_boot_set(void *opaque, const char *boot_device) |
115 | 513f789f | blueswir1 | { |
116 | 513f789f | blueswir1 | fw_cfg_add_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
|
117 | 513f789f | blueswir1 | return 0; |
118 | 513f789f | blueswir1 | } |
119 | 513f789f | blueswir1 | |
120 | fbe1b595 | Paul Brook | static void ppc_heathrow_init (ram_addr_t ram_size, |
121 | 3023f332 | aliguori | const char *boot_device, |
122 | 3cbee15b | j_mayer | const char *kernel_filename, |
123 | 3cbee15b | j_mayer | const char *kernel_cmdline, |
124 | 3cbee15b | j_mayer | const char *initrd_filename, |
125 | 3cbee15b | j_mayer | const char *cpu_model) |
126 | 3cbee15b | j_mayer | { |
127 | aaed909a | bellard | CPUState *env = NULL, *envs[MAX_CPUS];
|
128 | 5cea8590 | Paul Brook | char *filename;
|
129 | 3cbee15b | j_mayer | qemu_irq *pic, **heathrow_irqs; |
130 | 3cbee15b | j_mayer | int linux_boot, i;
|
131 | b584726d | pbrook | ram_addr_t ram_offset, bios_offset, vga_bios_offset; |
132 | 7373048c | blueswir1 | uint32_t kernel_base, initrd_base; |
133 | 7373048c | blueswir1 | int32_t kernel_size, initrd_size; |
134 | 3cbee15b | j_mayer | PCIBus *pci_bus; |
135 | 3cbee15b | j_mayer | MacIONVRAMState *nvr; |
136 | 3cbee15b | j_mayer | int vga_bios_size, bios_size;
|
137 | 3cbee15b | j_mayer | int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
|
138 | 7fa9ae1a | blueswir1 | int escc_mem_index, ide_mem_index[2]; |
139 | 513f789f | blueswir1 | uint16_t ppc_boot_device; |
140 | f455e98c | Gerd Hoffmann | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
141 | 271dd5e0 | blueswir1 | void *fw_cfg;
|
142 | 28ce5ce6 | aurel32 | void *dbdma;
|
143 | 44654490 | pbrook | uint8_t *vga_bios_ptr; |
144 | 3cbee15b | j_mayer | |
145 | 3cbee15b | j_mayer | linux_boot = (kernel_filename != NULL);
|
146 | 3cbee15b | j_mayer | |
147 | 3cbee15b | j_mayer | /* init CPUs */
|
148 | 3cbee15b | j_mayer | if (cpu_model == NULL) |
149 | f2fde45a | aurel32 | cpu_model = "G3";
|
150 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
151 | aaed909a | bellard | env = cpu_init(cpu_model); |
152 | aaed909a | bellard | if (!env) {
|
153 | aaed909a | bellard | fprintf(stderr, "Unable to find PowerPC CPU definition\n");
|
154 | aaed909a | bellard | exit(1);
|
155 | aaed909a | bellard | } |
156 | b0fb43d8 | aurel32 | /* Set time-base frequency to 16.6 Mhz */
|
157 | b0fb43d8 | aurel32 | cpu_ppc_tb_init(env, 16600000UL);
|
158 | 3cbee15b | j_mayer | env->osi_call = vga_osi_call; |
159 | a08d4367 | Jan Kiszka | qemu_register_reset(&cpu_ppc_reset, env); |
160 | 3cbee15b | j_mayer | envs[i] = env; |
161 | 3cbee15b | j_mayer | } |
162 | 3cbee15b | j_mayer | |
163 | 3cbee15b | j_mayer | /* allocate RAM */
|
164 | 6b4079f8 | aurel32 | if (ram_size > (2047 << 20)) { |
165 | 6b4079f8 | aurel32 | fprintf(stderr, |
166 | 6b4079f8 | aurel32 | "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
|
167 | 6b4079f8 | aurel32 | ((unsigned int)ram_size / (1 << 20))); |
168 | 6b4079f8 | aurel32 | exit(1);
|
169 | 6b4079f8 | aurel32 | } |
170 | 6b4079f8 | aurel32 | |
171 | a748ab6d | aurel32 | ram_offset = qemu_ram_alloc(ram_size); |
172 | a748ab6d | aurel32 | cpu_register_physical_memory(0, ram_size, ram_offset);
|
173 | a748ab6d | aurel32 | |
174 | 3cbee15b | j_mayer | /* allocate and load BIOS */
|
175 | a748ab6d | aurel32 | bios_offset = qemu_ram_alloc(BIOS_SIZE); |
176 | 3cbee15b | j_mayer | if (bios_name == NULL) |
177 | 992e5acd | blueswir1 | bios_name = PROM_FILENAME; |
178 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); |
179 | 992e5acd | blueswir1 | cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM); |
180 | 992e5acd | blueswir1 | |
181 | 992e5acd | blueswir1 | /* Load OpenBIOS (ELF) */
|
182 | 5cea8590 | Paul Brook | if (filename) {
|
183 | 5cea8590 | Paul Brook | bios_size = load_elf(filename, 0, NULL, NULL, NULL); |
184 | 5cea8590 | Paul Brook | qemu_free(filename); |
185 | 5cea8590 | Paul Brook | } else {
|
186 | 5cea8590 | Paul Brook | bios_size = -1;
|
187 | 5cea8590 | Paul Brook | } |
188 | 3cbee15b | j_mayer | if (bios_size < 0 || bios_size > BIOS_SIZE) { |
189 | 5cea8590 | Paul Brook | hw_error("qemu: could not load PowerPC bios '%s'\n", bios_name);
|
190 | 3cbee15b | j_mayer | exit(1);
|
191 | 3cbee15b | j_mayer | } |
192 | 3cbee15b | j_mayer | |
193 | 3cbee15b | j_mayer | /* allocate and load VGA BIOS */
|
194 | a748ab6d | aurel32 | vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE); |
195 | 44654490 | pbrook | vga_bios_ptr = qemu_get_ram_ptr(vga_bios_offset); |
196 | 5cea8590 | Paul Brook | filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, VGABIOS_FILENAME); |
197 | 5cea8590 | Paul Brook | if (filename) {
|
198 | 5cea8590 | Paul Brook | vga_bios_size = load_image(filename, vga_bios_ptr + 8);
|
199 | 5cea8590 | Paul Brook | qemu_free(filename); |
200 | 5cea8590 | Paul Brook | } else {
|
201 | 5cea8590 | Paul Brook | vga_bios_size = -1;
|
202 | 5cea8590 | Paul Brook | } |
203 | 3cbee15b | j_mayer | if (vga_bios_size < 0) { |
204 | 3cbee15b | j_mayer | /* if no bios is present, we can still work */
|
205 | 5cea8590 | Paul Brook | fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n",
|
206 | 5cea8590 | Paul Brook | VGABIOS_FILENAME); |
207 | 3cbee15b | j_mayer | vga_bios_size = 0;
|
208 | 3cbee15b | j_mayer | } else {
|
209 | 3cbee15b | j_mayer | /* set a specific header (XXX: find real Apple format for NDRV
|
210 | 3cbee15b | j_mayer | drivers) */
|
211 | 44654490 | pbrook | vga_bios_ptr[0] = 'N'; |
212 | 44654490 | pbrook | vga_bios_ptr[1] = 'D'; |
213 | 44654490 | pbrook | vga_bios_ptr[2] = 'R'; |
214 | 44654490 | pbrook | vga_bios_ptr[3] = 'V'; |
215 | 44654490 | pbrook | cpu_to_be32w((uint32_t *)(vga_bios_ptr + 4), vga_bios_size);
|
216 | 3cbee15b | j_mayer | vga_bios_size += 8;
|
217 | a7b022e0 | Alexander Graf | |
218 | a7b022e0 | Alexander Graf | /* Round to page boundary */
|
219 | a7b022e0 | Alexander Graf | vga_bios_size = (vga_bios_size + TARGET_PAGE_SIZE - 1) &
|
220 | a7b022e0 | Alexander Graf | TARGET_PAGE_MASK; |
221 | 3cbee15b | j_mayer | } |
222 | 3cbee15b | j_mayer | |
223 | 3cbee15b | j_mayer | if (linux_boot) {
|
224 | 36bee1e3 | aurel32 | uint64_t lowaddr = 0;
|
225 | 3cbee15b | j_mayer | kernel_base = KERNEL_LOAD_ADDR; |
226 | 36bee1e3 | aurel32 | /* Now we can load the kernel. The first step tries to load the kernel
|
227 | 36bee1e3 | aurel32 | supposing PhysAddr = 0x00000000. If that was wrong the kernel is
|
228 | 36bee1e3 | aurel32 | loaded again, the new PhysAddr being computed from lowaddr. */
|
229 | 36bee1e3 | aurel32 | kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL); |
230 | 36bee1e3 | aurel32 | if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) { |
231 | 36bee1e3 | aurel32 | kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
|
232 | 660f11be | Blue Swirl | NULL, NULL, NULL); |
233 | 36bee1e3 | aurel32 | } |
234 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
235 | 52f163b7 | blueswir1 | kernel_size = load_aout(kernel_filename, kernel_base, |
236 | 52f163b7 | blueswir1 | ram_size - kernel_base); |
237 | 52f163b7 | blueswir1 | if (kernel_size < 0) |
238 | 52f163b7 | blueswir1 | kernel_size = load_image_targphys(kernel_filename, |
239 | 52f163b7 | blueswir1 | kernel_base, |
240 | 52f163b7 | blueswir1 | ram_size - kernel_base); |
241 | 3cbee15b | j_mayer | if (kernel_size < 0) { |
242 | 2ac71179 | Paul Brook | hw_error("qemu: could not load kernel '%s'\n",
|
243 | 3cbee15b | j_mayer | kernel_filename); |
244 | 3cbee15b | j_mayer | exit(1);
|
245 | 3cbee15b | j_mayer | } |
246 | 3cbee15b | j_mayer | /* load initrd */
|
247 | 3cbee15b | j_mayer | if (initrd_filename) {
|
248 | 3cbee15b | j_mayer | initrd_base = INITRD_LOAD_ADDR; |
249 | dcac9679 | pbrook | initrd_size = load_image_targphys(initrd_filename, initrd_base, |
250 | dcac9679 | pbrook | ram_size - initrd_base); |
251 | 3cbee15b | j_mayer | if (initrd_size < 0) { |
252 | 2ac71179 | Paul Brook | hw_error("qemu: could not load initial ram disk '%s'\n",
|
253 | 2ac71179 | Paul Brook | initrd_filename); |
254 | 3cbee15b | j_mayer | exit(1);
|
255 | 3cbee15b | j_mayer | } |
256 | 3cbee15b | j_mayer | } else {
|
257 | 3cbee15b | j_mayer | initrd_base = 0;
|
258 | 3cbee15b | j_mayer | initrd_size = 0;
|
259 | 3cbee15b | j_mayer | } |
260 | 6ac0e82d | balrog | ppc_boot_device = 'm';
|
261 | 3cbee15b | j_mayer | } else {
|
262 | 3cbee15b | j_mayer | kernel_base = 0;
|
263 | 3cbee15b | j_mayer | kernel_size = 0;
|
264 | 3cbee15b | j_mayer | initrd_base = 0;
|
265 | 3cbee15b | j_mayer | initrd_size = 0;
|
266 | 28c5af54 | j_mayer | ppc_boot_device = '\0';
|
267 | 0d913fdb | j_mayer | for (i = 0; boot_device[i] != '\0'; i++) { |
268 | 28c5af54 | j_mayer | /* TOFIX: for now, the second IDE channel is not properly
|
269 | 0d913fdb | j_mayer | * used by OHW. The Mac floppy disk are not emulated.
|
270 | 28c5af54 | j_mayer | * For now, OHW cannot boot from the network.
|
271 | 28c5af54 | j_mayer | */
|
272 | 28c5af54 | j_mayer | #if 0
|
273 | 0d913fdb | j_mayer | if (boot_device[i] >= 'a' && boot_device[i] <= 'f') {
|
274 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i];
|
275 | 28c5af54 | j_mayer | break;
|
276 | 0d913fdb | j_mayer | }
|
277 | 28c5af54 | j_mayer | #else
|
278 | 0d913fdb | j_mayer | if (boot_device[i] >= 'c' && boot_device[i] <= 'd') { |
279 | 0d913fdb | j_mayer | ppc_boot_device = boot_device[i]; |
280 | 28c5af54 | j_mayer | break;
|
281 | 0d913fdb | j_mayer | } |
282 | 28c5af54 | j_mayer | #endif
|
283 | 28c5af54 | j_mayer | } |
284 | 28c5af54 | j_mayer | if (ppc_boot_device == '\0') { |
285 | 8a901def | aurel32 | fprintf(stderr, "No valid boot device for G3 Beige machine\n");
|
286 | 28c5af54 | j_mayer | exit(1);
|
287 | 28c5af54 | j_mayer | } |
288 | 3cbee15b | j_mayer | } |
289 | 3cbee15b | j_mayer | |
290 | 3cbee15b | j_mayer | isa_mem_base = 0x80000000;
|
291 | aae9366a | j_mayer | |
292 | 3cbee15b | j_mayer | /* Register 2 MB of ISA IO space */
|
293 | 3cbee15b | j_mayer | isa_mmio_init(0xfe000000, 0x00200000); |
294 | 3cbee15b | j_mayer | |
295 | 3cbee15b | j_mayer | /* XXX: we register only 1 output pin for heathrow PIC */
|
296 | 3cbee15b | j_mayer | heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *));
|
297 | 3cbee15b | j_mayer | heathrow_irqs[0] =
|
298 | 3cbee15b | j_mayer | qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1); |
299 | 3cbee15b | j_mayer | /* Connect the heathrow PIC outputs to the 6xx bus */
|
300 | 3cbee15b | j_mayer | for (i = 0; i < smp_cpus; i++) { |
301 | 3cbee15b | j_mayer | switch (PPC_INPUT(env)) {
|
302 | 3cbee15b | j_mayer | case PPC_FLAGS_INPUT_6xx:
|
303 | 3cbee15b | j_mayer | heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); |
304 | 3cbee15b | j_mayer | heathrow_irqs[i][0] =
|
305 | 3cbee15b | j_mayer | ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; |
306 | 3cbee15b | j_mayer | break;
|
307 | 3cbee15b | j_mayer | default:
|
308 | 2ac71179 | Paul Brook | hw_error("Bus model not supported on OldWorld Mac machine\n");
|
309 | 3cbee15b | j_mayer | } |
310 | 3cbee15b | j_mayer | } |
311 | 3cbee15b | j_mayer | |
312 | 3cbee15b | j_mayer | /* init basic PC hardware */
|
313 | 3cbee15b | j_mayer | if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
|
314 | 2ac71179 | Paul Brook | hw_error("Only 6xx bus is supported on heathrow machine\n");
|
315 | 3cbee15b | j_mayer | } |
316 | 3cbee15b | j_mayer | pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
|
317 | 3cbee15b | j_mayer | pci_bus = pci_grackle_init(0xfec00000, pic);
|
318 | fbe1b595 | Paul Brook | pci_vga_init(pci_bus, vga_bios_offset, vga_bios_size); |
319 | aae9366a | j_mayer | |
320 | aeeb69c7 | aurel32 | escc_mem_index = escc_init(0x80013000, pic[0x0f], pic[0x10], serial_hds[0], |
321 | 7fa9ae1a | blueswir1 | serial_hds[1], ESCC_CLOCK, 4); |
322 | aae9366a | j_mayer | |
323 | cb457d76 | aliguori | for(i = 0; i < nb_nics; i++) |
324 | 5607c388 | Markus Armbruster | pci_nic_init(&nd_table[i], "ne2k_pci", NULL); |
325 | 0d913fdb | j_mayer | |
326 | e4bcb14c | ths | |
327 | e4bcb14c | ths | if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
328 | e4bcb14c | ths | fprintf(stderr, "qemu: too many IDE bus\n");
|
329 | e4bcb14c | ths | exit(1);
|
330 | e4bcb14c | ths | } |
331 | bd4524ed | aurel32 | |
332 | bd4524ed | aurel32 | /* First IDE channel is a MAC IDE on the MacIO bus */
|
333 | f455e98c | Gerd Hoffmann | hd[0] = drive_get(IF_IDE, 0, 0); |
334 | f455e98c | Gerd Hoffmann | hd[1] = drive_get(IF_IDE, 0, 1); |
335 | bd4524ed | aurel32 | dbdma = DBDMA_init(&dbdma_mem_index); |
336 | bd4524ed | aurel32 | ide_mem_index[0] = -1; |
337 | bd4524ed | aurel32 | ide_mem_index[1] = pmac_ide_init(hd, pic[0x0D], dbdma, 0x16, pic[0x02]); |
338 | e4bcb14c | ths | |
339 | bd4524ed | aurel32 | /* Second IDE channel is a CMD646 on the PCI bus */
|
340 | f455e98c | Gerd Hoffmann | hd[0] = drive_get(IF_IDE, 1, 0); |
341 | f455e98c | Gerd Hoffmann | hd[1] = drive_get(IF_IDE, 1, 1); |
342 | bd4524ed | aurel32 | hd[3] = hd[2] = NULL; |
343 | bd4524ed | aurel32 | pci_cmd646_ide_init(pci_bus, hd, 0);
|
344 | 3cbee15b | j_mayer | |
345 | 3cbee15b | j_mayer | /* cuda also initialize ADB */
|
346 | 3cbee15b | j_mayer | cuda_init(&cuda_mem_index, pic[0x12]);
|
347 | 3cbee15b | j_mayer | |
348 | 3cbee15b | j_mayer | adb_kbd_init(&adb_bus); |
349 | 3cbee15b | j_mayer | adb_mouse_init(&adb_bus); |
350 | aae9366a | j_mayer | |
351 | 68af3f24 | blueswir1 | nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 4); |
352 | 3cbee15b | j_mayer | pmac_format_nvram_partition(nvr, 0x2000);
|
353 | 3cbee15b | j_mayer | |
354 | 4ebcf884 | blueswir1 | macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index,
|
355 | 4ebcf884 | blueswir1 | dbdma_mem_index, cuda_mem_index, nvr, 2, ide_mem_index,
|
356 | 4ebcf884 | blueswir1 | escc_mem_index); |
357 | 3cbee15b | j_mayer | |
358 | 3cbee15b | j_mayer | if (usb_enabled) {
|
359 | 5b19d9a2 | Gerd Hoffmann | usb_ohci_init_pci(pci_bus, -1);
|
360 | 3cbee15b | j_mayer | } |
361 | 3cbee15b | j_mayer | |
362 | 3cbee15b | j_mayer | if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) |
363 | 3cbee15b | j_mayer | graphic_depth = 15;
|
364 | 3cbee15b | j_mayer | |
365 | 3cbee15b | j_mayer | /* No PCI init: the BIOS will do it */
|
366 | 3cbee15b | j_mayer | |
367 | 271dd5e0 | blueswir1 | fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2); |
368 | 271dd5e0 | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
|
369 | 271dd5e0 | blueswir1 | fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); |
370 | 271dd5e0 | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); |
371 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); |
372 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); |
373 | 513f789f | blueswir1 | if (kernel_cmdline) {
|
374 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR); |
375 | 513f789f | blueswir1 | pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline); |
376 | 513f789f | blueswir1 | } else {
|
377 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
|
378 | 513f789f | blueswir1 | } |
379 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); |
380 | 513f789f | blueswir1 | fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); |
381 | 513f789f | blueswir1 | fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ppc_boot_device); |
382 | 7f1aec5f | Laurent Vivier | |
383 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_WIDTH, graphic_width); |
384 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); |
385 | 7f1aec5f | Laurent Vivier | fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); |
386 | 7f1aec5f | Laurent Vivier | |
387 | 513f789f | blueswir1 | qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); |
388 | 3cbee15b | j_mayer | } |
389 | 3cbee15b | j_mayer | |
390 | f80f9ec9 | Anthony Liguori | static QEMUMachine heathrow_machine = {
|
391 | 4d7ca41e | aurel32 | .name = "g3beige",
|
392 | 4b32e168 | aliguori | .desc = "Heathrow based PowerMAC",
|
393 | 4b32e168 | aliguori | .init = ppc_heathrow_init, |
394 | 3d878caa | balrog | .max_cpus = MAX_CPUS, |
395 | 0c257437 | Anthony Liguori | .is_default = 1,
|
396 | 3cbee15b | j_mayer | }; |
397 | f80f9ec9 | Anthony Liguori | |
398 | f80f9ec9 | Anthony Liguori | static void heathrow_machine_init(void) |
399 | f80f9ec9 | Anthony Liguori | { |
400 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&heathrow_machine); |
401 | f80f9ec9 | Anthony Liguori | } |
402 | f80f9ec9 | Anthony Liguori | |
403 | f80f9ec9 | Anthony Liguori | machine_init(heathrow_machine_init); |