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