Statistics
| Branch: | Revision:

root / hw / mips_pica61.c @ e1dad5a6

History | View | Annotate | Download (5.7 kB)

1 ad6fe1d2 ths
/*
2 9566782b ths
 * QEMU Acer Pica Machine support
3 ad6fe1d2 ths
 *
4 ad6fe1d2 ths
 * Copyright (c) 2007 Herv? Poussineau
5 ad6fe1d2 ths
 *
6 ad6fe1d2 ths
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 ad6fe1d2 ths
 * of this software and associated documentation files (the "Software"), to deal
8 ad6fe1d2 ths
 * in the Software without restriction, including without limitation the rights
9 ad6fe1d2 ths
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 ad6fe1d2 ths
 * copies of the Software, and to permit persons to whom the Software is
11 ad6fe1d2 ths
 * furnished to do so, subject to the following conditions:
12 ad6fe1d2 ths
 *
13 ad6fe1d2 ths
 * The above copyright notice and this permission notice shall be included in
14 ad6fe1d2 ths
 * all copies or substantial portions of the Software.
15 ad6fe1d2 ths
 *
16 ad6fe1d2 ths
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 ad6fe1d2 ths
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 ad6fe1d2 ths
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 ad6fe1d2 ths
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 ad6fe1d2 ths
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 ad6fe1d2 ths
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 ad6fe1d2 ths
 * THE SOFTWARE.
23 ad6fe1d2 ths
 */
24 ad6fe1d2 ths
25 87ecb68b pbrook
#include "hw.h"
26 87ecb68b pbrook
#include "mips.h"
27 87ecb68b pbrook
#include "isa.h"
28 87ecb68b pbrook
#include "pc.h"
29 87ecb68b pbrook
#include "fdc.h"
30 87ecb68b pbrook
#include "sysemu.h"
31 87ecb68b pbrook
#include "boards.h"
32 ad6fe1d2 ths
33 ad6fe1d2 ths
#ifdef TARGET_WORDS_BIGENDIAN
34 ad6fe1d2 ths
#define BIOS_FILENAME "mips_bios.bin"
35 ad6fe1d2 ths
#else
36 ad6fe1d2 ths
#define BIOS_FILENAME "mipsel_bios.bin"
37 ad6fe1d2 ths
#endif
38 ad6fe1d2 ths
39 ad6fe1d2 ths
#ifdef TARGET_MIPS64
40 ad6fe1d2 ths
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffULL)
41 ad6fe1d2 ths
#else
42 ad6fe1d2 ths
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffU)
43 ad6fe1d2 ths
#endif
44 ad6fe1d2 ths
45 ad6fe1d2 ths
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
46 ad6fe1d2 ths
47 ad6fe1d2 ths
static const int ide_iobase[2] = { 0x1f0, 0x170 };
48 ad6fe1d2 ths
static const int ide_iobase2[2] = { 0x3f6, 0x376 };
49 ad6fe1d2 ths
static const int ide_irq[2] = { 14, 15 };
50 ad6fe1d2 ths
51 ad6fe1d2 ths
static uint32_t serial_base[MAX_SERIAL_PORTS] = { 0x80006000, 0x80007000 };
52 ad6fe1d2 ths
static int serial_irq[MAX_SERIAL_PORTS] = { 8, 9 };
53 ad6fe1d2 ths
54 ad6fe1d2 ths
extern FILE *logfile;
55 ad6fe1d2 ths
56 ad6fe1d2 ths
static void main_cpu_reset(void *opaque)
57 ad6fe1d2 ths
{
58 ad6fe1d2 ths
    CPUState *env = opaque;
59 ad6fe1d2 ths
    cpu_reset(env);
60 ad6fe1d2 ths
}
61 ad6fe1d2 ths
62 ad6fe1d2 ths
static
63 6ac0e82d balrog
void mips_pica61_init (int ram_size, int vga_ram_size, const char *boot_device,
64 ad6fe1d2 ths
                    DisplayState *ds, const char **fd_filename, int snapshot,
65 ad6fe1d2 ths
                    const char *kernel_filename, const char *kernel_cmdline,
66 ad6fe1d2 ths
                    const char *initrd_filename, const char *cpu_model)
67 ad6fe1d2 ths
{
68 ad6fe1d2 ths
    char buf[1024];
69 ad6fe1d2 ths
    unsigned long bios_offset;
70 ad6fe1d2 ths
    int bios_size;
71 ad6fe1d2 ths
    CPUState *env;
72 ad6fe1d2 ths
    int i;
73 ad6fe1d2 ths
    int available_ram;
74 ad6fe1d2 ths
    qemu_irq *i8259;
75 ad6fe1d2 ths
76 ad6fe1d2 ths
    /* init CPUs */
77 ad6fe1d2 ths
    if (cpu_model == NULL) {
78 ad6fe1d2 ths
#ifdef TARGET_MIPS64
79 ad6fe1d2 ths
        cpu_model = "R4000";
80 ad6fe1d2 ths
#else
81 1c32f43e ths
        /* FIXME: All wrong, this maybe should be R3000 for the older PICAs. */
82 1c32f43e ths
        cpu_model = "24Kf";
83 ad6fe1d2 ths
#endif
84 ad6fe1d2 ths
    }
85 aaed909a bellard
    env = cpu_init(cpu_model);
86 aaed909a bellard
    if (!env) {
87 aaed909a bellard
        fprintf(stderr, "Unable to find CPU definition\n");
88 aaed909a bellard
        exit(1);
89 aaed909a bellard
    }
90 ad6fe1d2 ths
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
91 ad6fe1d2 ths
    qemu_register_reset(main_cpu_reset, env);
92 ad6fe1d2 ths
93 ad6fe1d2 ths
    /* allocate RAM (limited to 256 MB) */
94 ad6fe1d2 ths
    if (ram_size < 256 * 1024 * 1024)
95 ad6fe1d2 ths
        available_ram = ram_size;
96 ad6fe1d2 ths
    else
97 ad6fe1d2 ths
        available_ram = 256 * 1024 * 1024;
98 ad6fe1d2 ths
    cpu_register_physical_memory(0, available_ram, IO_MEM_RAM);
99 ad6fe1d2 ths
100 ad6fe1d2 ths
    /* load a BIOS image */
101 ad6fe1d2 ths
    bios_offset = ram_size + vga_ram_size;
102 1192dad8 j_mayer
    if (bios_name == NULL)
103 1192dad8 j_mayer
        bios_name = BIOS_FILENAME;
104 1192dad8 j_mayer
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
105 ad6fe1d2 ths
    bios_size = load_image(buf, phys_ram_base + bios_offset);
106 ad6fe1d2 ths
    if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
107 ad6fe1d2 ths
        /* fatal */
108 ad6fe1d2 ths
        fprintf(stderr, "qemu: Error, could not load MIPS bios '%s'\n",
109 ad6fe1d2 ths
                buf);
110 ad6fe1d2 ths
        exit(1);
111 ad6fe1d2 ths
    }
112 ad6fe1d2 ths
    cpu_register_physical_memory(0x1fc00000,
113 ad6fe1d2 ths
                                     BIOS_SIZE, bios_offset | IO_MEM_ROM);
114 ad6fe1d2 ths
115 ad6fe1d2 ths
    /* Device map
116 ad6fe1d2 ths
     *
117 ad6fe1d2 ths
     * addr 0xe0004000: mc146818
118 ad6fe1d2 ths
     * addr 0xe0005000 intr 6: ps2 keyboard
119 ad6fe1d2 ths
     * addr 0xe0005000 intr 7: ps2 mouse
120 ad6fe1d2 ths
     * addr 0xe0006000 intr 8: ns16550a,
121 ad6fe1d2 ths
     * addr 0xe0007000 intr 9: ns16550a
122 ad6fe1d2 ths
     * isa_io_base 0xe2000000 isa_mem_base 0xe3000000
123 ad6fe1d2 ths
     */
124 ad6fe1d2 ths
125 ad6fe1d2 ths
    /* Init CPU internal devices */
126 ad6fe1d2 ths
    cpu_mips_irq_init_cpu(env);
127 ad6fe1d2 ths
    cpu_mips_clock_init(env);
128 ad6fe1d2 ths
    cpu_mips_irqctrl_init();
129 ad6fe1d2 ths
130 ad6fe1d2 ths
    /* Register 64 KB of ISA IO space at 0x10000000 */
131 ad6fe1d2 ths
    isa_mmio_init(0x10000000, 0x00010000);
132 ad6fe1d2 ths
    isa_mem_base = 0x11000000;
133 ad6fe1d2 ths
134 ad6fe1d2 ths
    /* PC style IRQ (i8259/i8254) and DMA (i8257) */
135 ad6fe1d2 ths
    /* The PIC is attached to the MIPS CPU INT0 pin */
136 ad6fe1d2 ths
    i8259 = i8259_init(env->irq[2]);
137 18c6e2ff ths
    rtc_mm_init(0x80004070, 1, i8259[14]);
138 ad6fe1d2 ths
    pit_init(0x40, 0);
139 ad6fe1d2 ths
140 ad6fe1d2 ths
    /* Keyboard (i8042) */
141 ad6fe1d2 ths
    i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0);
142 ad6fe1d2 ths
143 ad6fe1d2 ths
    /* IDE controller */
144 ad6fe1d2 ths
    for(i = 0; i < 2; i++)
145 ad6fe1d2 ths
        isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
146 ad6fe1d2 ths
                     bs_table[2 * i], bs_table[2 * i + 1]);
147 ad6fe1d2 ths
148 ad6fe1d2 ths
    /* Network controller */
149 ad6fe1d2 ths
    /* FIXME: missing NS SONIC DP83932 */
150 ad6fe1d2 ths
151 ad6fe1d2 ths
    /* SCSI adapter */
152 ad6fe1d2 ths
    /* FIXME: missing NCR 53C94 */
153 ad6fe1d2 ths
154 ad6fe1d2 ths
    /* ISA devices (floppy, serial, parallel) */
155 ad6fe1d2 ths
    fdctrl_init(i8259[1], 1, 1, 0x80003000, fd_table);
156 ad6fe1d2 ths
    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
157 ad6fe1d2 ths
        if (serial_hds[i]) {
158 ad6fe1d2 ths
            serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1);
159 ad6fe1d2 ths
        }
160 ad6fe1d2 ths
    }
161 d60532ca ths
    /* Parallel port */
162 d60532ca ths
    if (parallel_hds[0]) parallel_mm_init(0x80008000, 0, i8259[1], parallel_hds[0]);
163 ad6fe1d2 ths
164 ad6fe1d2 ths
    /* Sound card */
165 ad6fe1d2 ths
    /* FIXME: missing Jazz sound, IRQ 18 */
166 ad6fe1d2 ths
167 ad6fe1d2 ths
    /* LED indicator */
168 ad6fe1d2 ths
    /* FIXME: missing LED indicator */
169 ad6fe1d2 ths
170 ad6fe1d2 ths
    /* NVRAM */
171 ad6fe1d2 ths
    ds1225y_init(0x80009000, "nvram");
172 ad6fe1d2 ths
173 ad6fe1d2 ths
    /* Video card */
174 2abec30b ths
    /* FIXME: This card is not the real one which was in the original PICA,
175 2abec30b ths
     * but let's do with what Qemu currenly emulates... */
176 2abec30b ths
    isa_vga_mm_init(ds, phys_ram_base + ram_size, ram_size, vga_ram_size,
177 2abec30b ths
                    0x40000000, 0x60000000, 0);
178 31211df1 ths
179 31211df1 ths
    /* LED indicator */
180 31211df1 ths
    jazz_led_init(ds, 0x8000f000);
181 ad6fe1d2 ths
}
182 ad6fe1d2 ths
183 ad6fe1d2 ths
QEMUMachine mips_pica61_machine = {
184 ad6fe1d2 ths
    "pica61",
185 ad6fe1d2 ths
    "Acer Pica 61",
186 ad6fe1d2 ths
    mips_pica61_init,
187 ad6fe1d2 ths
};