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