2 * QEMU PPC CHRP/PMAC hardware System Emulator
4 * Copyright (c) 2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #define BIOS_FILENAME "ppc_rom.bin"
27 #define NVRAM_SIZE 0x2000
29 /* PowerPC PREP hardware initialisation */
30 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
31 DisplayState *ds, const char **fd_filename, int snapshot,
32 const char *kernel_filename, const char *kernel_cmdline,
33 const char *initrd_filename)
38 int ret, linux_boot, i, fd;
39 unsigned long bios_offset;
41 linux_boot = (kernel_filename != NULL);
44 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
46 /* allocate and load BIOS */
47 bios_offset = ram_size + vga_ram_size;
48 snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
49 ret = load_image(buf, phys_ram_base + bios_offset);
50 if (ret != BIOS_SIZE) {
51 fprintf(stderr, "qemu: could not load PPC PREP bios '%s'\n", buf);
54 cpu_register_physical_memory((uint32_t)(-BIOS_SIZE),
55 BIOS_SIZE, bios_offset | IO_MEM_ROM);
56 cpu_single_env->nip = 0xfffffffc;
58 /* Register CPU as a 74x/75x */
59 cpu_ppc_register(cpu_single_env, 0x00080000);
60 /* Set time-base frequency to 100 Mhz */
61 cpu_ppc_tb_init(cpu_single_env, 100UL * 1000UL * 1000UL);
63 isa_mem_base = 0xc0000000;
66 /* Register 64 KB of ISA IO space */
67 PPC_io_memory = cpu_register_io_memory(0, PPC_io_read, PPC_io_write);
68 cpu_register_physical_memory(0x80000000, 0x10000, PPC_io_memory);
69 // cpu_register_physical_memory(0xfe000000, 0xfe010000, PPC_io_memory);
71 /* init basic PC hardware */
72 vga_initialize(ds, phys_ram_base + ram_size, ram_size,
74 // openpic = openpic_init(0x00000000, 0xF0000000, 1);
77 // pit = pit_init(0x40, 0);
79 /* XXX: use Mac Serial port */
80 fd = serial_open_device();
81 serial_init(0x3f8, 4, fd);
83 for(i = 0; i < nb_nics; i++) {
84 pci_ne2000_init(&nd_table[i]);
87 pci_ide_init(bs_table);
91 nvram = m48t59_init(8, 0x0074, NVRAM_SIZE);
93 PPC_NVRAM_set_params(nvram, NVRAM_SIZE, "PREP", ram_size, boot_device,
98 /* XXX: need an option to load a NVRAM image */
102 /* Special port to get debug messages from Open-Firmware */
103 register_ioport_write(0xFF00, 0x04, 1, &PREP_debug_write, NULL);
104 register_ioport_write(0xFF00, 0x04, 2, &PREP_debug_write, NULL);