]> git.proxmox.com Git - mirror_qemu.git/blame - hw/ppc_chrp.c
PowerPC prep/chrp/pmac support
[mirror_qemu.git] / hw / ppc_chrp.c
CommitLineData
64201201
FB
1/*
2 * QEMU PPC CHRP/PMAC hardware System Emulator
3 *
4 * Copyright (c) 2004 Fabrice Bellard
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
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
22 * THE SOFTWARE.
23 */
24#include "vl.h"
25
26#define BIOS_FILENAME "ppc_rom.bin"
27#define NVRAM_SIZE 0x2000
28
29/* PowerPC PREP hardware initialisation */
30void 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)
34{
35 char buf[1024];
36 m48t59_t *nvram;
37 int PPC_io_memory;
38 int ret, linux_boot, i, fd;
39 unsigned long bios_offset;
40
41 linux_boot = (kernel_filename != NULL);
42
43 /* allocate RAM */
44 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
45
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);
52 exit(1);
53 }
54 cpu_register_physical_memory((uint32_t)(-BIOS_SIZE),
55 BIOS_SIZE, bios_offset | IO_MEM_ROM);
56 cpu_single_env->nip = 0xfffffffc;
57
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);
62
63 isa_mem_base = 0xc0000000;
64 pci_pmac_init();
65
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);
70
71 /* init basic PC hardware */
72 vga_initialize(ds, phys_ram_base + ram_size, ram_size,
73 vga_ram_size, 1);
74 // openpic = openpic_init(0x00000000, 0xF0000000, 1);
75 // pic_init(openpic);
76 pic_init();
77 // pit = pit_init(0x40, 0);
78
79 /* XXX: use Mac Serial port */
80 fd = serial_open_device();
81 serial_init(0x3f8, 4, fd);
82
83 for(i = 0; i < nb_nics; i++) {
84 pci_ne2000_init(&nd_table[i]);
85 }
86
87 pci_ide_init(bs_table);
88
89 kbd_init();
90
91 nvram = m48t59_init(8, 0x0074, NVRAM_SIZE);
92
93 PPC_NVRAM_set_params(nvram, NVRAM_SIZE, "PREP", ram_size, boot_device,
94 0, 0,
95 0,
96 0,
97 0, 0,
98 /* XXX: need an option to load a NVRAM image */
99 0
100 );
101
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);
105
106 pci_ppc_bios_init();
107}