117
122
m48t59_t *m48t59;
118
123
int linux_boot, i;
119
unsigned long bios_offset, vga_bios_offset;
120
uint32_t kernel_base, kernel_size, initrd_base, initrd_size;
124
ram_addr_t ram_offset, vga_ram_offset, bios_offset, vga_bios_offset;
125
uint32_t kernel_base, initrd_base;
126
int32_t kernel_size, initrd_size;
122
128
MacIONVRAMState *nvr;
123
129
int vga_bios_size, bios_size;
125
130
int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index;
126
int ide_mem_index[2];
131
int escc_mem_index, ide_mem_index[2];
127
132
int ppc_boot_device;
128
133
BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
131
138
linux_boot = (kernel_filename != NULL);
134
141
if (cpu_model == NULL)
135
cpu_model = "default";
136
143
for (i = 0; i < smp_cpus; i++) {
137
144
env = cpu_init(cpu_model);
139
146
fprintf(stderr, "Unable to find PowerPC CPU definition\n");
142
/* Set time-base frequency to 100 Mhz */
143
cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL);
149
/* Set time-base frequency to 16.6 Mhz */
150
cpu_ppc_tb_init(env, 16600000UL);
144
151
env->osi_call = vga_osi_call;
145
152
qemu_register_reset(&cpu_ppc_reset, env);
146
register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
149
if (env->nip < 0xFFF80000) {
150
/* Special test for PowerPC 601:
151
* the boot vector is at 0xFFF00100, then we need a 1MB BIOS.
152
* But the NVRAM is located at 0xFFF04000...
154
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
157
156
/* allocate RAM */
158
cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
157
if (ram_size > (2047 << 20)) {
159
"qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
160
((unsigned int)ram_size / (1 << 20)));
164
ram_offset = qemu_ram_alloc(ram_size);
165
cpu_register_physical_memory(0, ram_size, ram_offset);
167
/* allocate VGA RAM */
168
vga_ram_offset = qemu_ram_alloc(vga_ram_size);
160
170
/* allocate and load BIOS */
161
bios_offset = ram_size + vga_ram_size;
171
bios_offset = qemu_ram_alloc(BIOS_SIZE);
162
172
if (bios_name == NULL)
163
bios_name = BIOS_FILENAME;
173
bios_name = PROM_FILENAME;
164
174
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
165
bios_size = load_image(buf, phys_ram_base + bios_offset);
175
cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
177
/* Load OpenBIOS (ELF) */
178
bios_size = load_elf(buf, 0, NULL, NULL, NULL);
166
179
if (bios_size < 0 || bios_size > BIOS_SIZE) {
167
180
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
170
bios_size = (bios_size + 0xfff) & ~0xfff;
171
if (bios_size > 0x00080000) {
172
/* As the NVRAM is located at 0xFFF04000, we cannot use 1 MB BIOSes */
173
cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n");
175
cpu_register_physical_memory((uint32_t)(-bios_size),
176
bios_size, bios_offset | IO_MEM_ROM);
178
184
/* allocate and load VGA BIOS */
179
vga_bios_offset = bios_offset + bios_size;
185
vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
180
186
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
181
187
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
182
188
if (vga_bios_size < 0) {
195
201
vga_bios_size += 8;
197
vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff;
199
204
if (linux_boot) {
205
uint64_t lowaddr = 0;
200
206
kernel_base = KERNEL_LOAD_ADDR;
201
/* now we can load the kernel */
202
kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base);
207
/* Now we can load the kernel. The first step tries to load the kernel
208
supposing PhysAddr = 0x00000000. If that was wrong the kernel is
209
loaded again, the new PhysAddr being computed from lowaddr. */
210
kernel_size = load_elf(kernel_filename, kernel_base, NULL, &lowaddr, NULL);
211
if (kernel_size > 0 && lowaddr != KERNEL_LOAD_ADDR) {
212
kernel_size = load_elf(kernel_filename, (2 * kernel_base) - lowaddr,
216
kernel_size = load_aout(kernel_filename, kernel_base,
217
ram_size - kernel_base);
219
kernel_size = load_image_targphys(kernel_filename,
221
ram_size - kernel_base);
203
222
if (kernel_size < 0) {
204
223
cpu_abort(env, "qemu: could not load kernel '%s'\n",
205
224
kernel_filename);
280
299
pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs);
281
300
pci_bus = pci_grackle_init(0xfec00000, pic);
282
pci_vga_init(pci_bus, ds, phys_ram_base + ram_size,
283
ram_size, vga_ram_size,
301
pci_vga_init(pci_bus, phys_ram_base + vga_ram_offset,
302
vga_ram_offset, vga_ram_size,
284
303
vga_bios_offset, vga_bios_size);
286
/* XXX: suppress that */
287
dummy_irq = i8259_init(NULL);
289
/* XXX: use Mac Serial port */
290
serial_init(0x3f8, dummy_irq[4], serial_hds[0]);
292
for(i = 0; i < nb_nics; i++) {
293
if (!nd_table[i].model)
294
nd_table[i].model = "ne2k_pci";
295
pci_nic_init(pci_bus, &nd_table[i], -1);
305
escc_mem_index = escc_init(0x80013000, pic[0x0f], pic[0x10], serial_hds[0],
306
serial_hds[1], ESCC_CLOCK, 4);
308
for(i = 0; i < nb_nics; i++)
309
pci_nic_init(pci_bus, &nd_table[i], -1, "ne2k_pci");
298
311
/* First IDE channel is a CMD646 on the PCI bus */
334
350
adb_kbd_init(&adb_bus);
335
351
adb_mouse_init(&adb_bus);
337
nvr = macio_nvram_init(&nvram_mem_index, 0x2000);
353
nvr = macio_nvram_init(&nvram_mem_index, 0x2000, 4);
338
354
pmac_format_nvram_partition(nvr, 0x2000);
340
dbdma_init(&dbdma_mem_index);
342
macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index,
343
cuda_mem_index, nvr, 2, ide_mem_index);
356
macio_init(pci_bus, PCI_DEVICE_ID_APPLE_343S1201, 1, pic_mem_index,
357
dbdma_mem_index, cuda_mem_index, nvr, 2, ide_mem_index,
345
360
if (usb_enabled) {
346
361
usb_ohci_init_pci(pci_bus, 3, -1);
362
377
graphic_width, graphic_height, graphic_depth);
363
378
/* No PCI init: the BIOS will do it */
365
/* Special port to get debug messages from Open-Firmware */
366
register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
380
fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
381
fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
382
fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
383
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
369
386
QEMUMachine heathrow_machine = {
371
"Heathrow based PowerMAC",
388
.desc = "Heathrow based PowerMAC",
389
.init = ppc_heathrow_init,
390
.ram_require = BIOS_SIZE + VGA_BIOS_SIZE + VGA_RAM_SIZE,
391
.max_cpus = MAX_CPUS,