Statistics
| Branch: | Revision:

root / hw / mips_pica61.c @ 8f8e3aa4

History | View | Annotate | Download (6.3 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 e4bcb14c ths
#define MAX_IDE_BUS 2
48 e4bcb14c ths
#define MAX_FD 2
49 e4bcb14c ths
50 ad6fe1d2 ths
static const int ide_iobase[2] = { 0x1f0, 0x170 };
51 ad6fe1d2 ths
static const int ide_iobase2[2] = { 0x3f6, 0x376 };
52 ad6fe1d2 ths
static const int ide_irq[2] = { 14, 15 };
53 ad6fe1d2 ths
54 ad6fe1d2 ths
static uint32_t serial_base[MAX_SERIAL_PORTS] = { 0x80006000, 0x80007000 };
55 ad6fe1d2 ths
static int serial_irq[MAX_SERIAL_PORTS] = { 8, 9 };
56 ad6fe1d2 ths
57 ad6fe1d2 ths
extern FILE *logfile;
58 ad6fe1d2 ths
59 ad6fe1d2 ths
static void main_cpu_reset(void *opaque)
60 ad6fe1d2 ths
{
61 ad6fe1d2 ths
    CPUState *env = opaque;
62 ad6fe1d2 ths
    cpu_reset(env);
63 ad6fe1d2 ths
}
64 ad6fe1d2 ths
65 ad6fe1d2 ths
static
66 b881c2c6 blueswir1
void mips_pica61_init (int ram_size, int vga_ram_size,
67 b881c2c6 blueswir1
                       const char *boot_device, DisplayState *ds,
68 ad6fe1d2 ths
                    const char *kernel_filename, const char *kernel_cmdline,
69 ad6fe1d2 ths
                    const char *initrd_filename, const char *cpu_model)
70 ad6fe1d2 ths
{
71 ad6fe1d2 ths
    char buf[1024];
72 ad6fe1d2 ths
    unsigned long bios_offset;
73 ad6fe1d2 ths
    int bios_size;
74 ad6fe1d2 ths
    CPUState *env;
75 ad6fe1d2 ths
    int i;
76 ad6fe1d2 ths
    int available_ram;
77 ad6fe1d2 ths
    qemu_irq *i8259;
78 e4bcb14c ths
    int index;
79 e4bcb14c ths
    BlockDriverState *fd[MAX_FD];
80 ad6fe1d2 ths
81 ad6fe1d2 ths
    /* init CPUs */
82 ad6fe1d2 ths
    if (cpu_model == NULL) {
83 ad6fe1d2 ths
#ifdef TARGET_MIPS64
84 ad6fe1d2 ths
        cpu_model = "R4000";
85 ad6fe1d2 ths
#else
86 1c32f43e ths
        /* FIXME: All wrong, this maybe should be R3000 for the older PICAs. */
87 1c32f43e ths
        cpu_model = "24Kf";
88 ad6fe1d2 ths
#endif
89 ad6fe1d2 ths
    }
90 aaed909a bellard
    env = cpu_init(cpu_model);
91 aaed909a bellard
    if (!env) {
92 aaed909a bellard
        fprintf(stderr, "Unable to find CPU definition\n");
93 aaed909a bellard
        exit(1);
94 aaed909a bellard
    }
95 ad6fe1d2 ths
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
96 ad6fe1d2 ths
    qemu_register_reset(main_cpu_reset, env);
97 ad6fe1d2 ths
98 ad6fe1d2 ths
    /* allocate RAM (limited to 256 MB) */
99 ad6fe1d2 ths
    if (ram_size < 256 * 1024 * 1024)
100 ad6fe1d2 ths
        available_ram = ram_size;
101 ad6fe1d2 ths
    else
102 ad6fe1d2 ths
        available_ram = 256 * 1024 * 1024;
103 ad6fe1d2 ths
    cpu_register_physical_memory(0, available_ram, IO_MEM_RAM);
104 ad6fe1d2 ths
105 ad6fe1d2 ths
    /* load a BIOS image */
106 ad6fe1d2 ths
    bios_offset = ram_size + vga_ram_size;
107 1192dad8 j_mayer
    if (bios_name == NULL)
108 1192dad8 j_mayer
        bios_name = BIOS_FILENAME;
109 1192dad8 j_mayer
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
110 ad6fe1d2 ths
    bios_size = load_image(buf, phys_ram_base + bios_offset);
111 ad6fe1d2 ths
    if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
112 ad6fe1d2 ths
        /* fatal */
113 ad6fe1d2 ths
        fprintf(stderr, "qemu: Error, could not load MIPS bios '%s'\n",
114 ad6fe1d2 ths
                buf);
115 ad6fe1d2 ths
        exit(1);
116 ad6fe1d2 ths
    }
117 ad6fe1d2 ths
    cpu_register_physical_memory(0x1fc00000,
118 ad6fe1d2 ths
                                     BIOS_SIZE, bios_offset | IO_MEM_ROM);
119 ad6fe1d2 ths
120 ad6fe1d2 ths
    /* Device map
121 ad6fe1d2 ths
     *
122 ad6fe1d2 ths
     * addr 0xe0004000: mc146818
123 ad6fe1d2 ths
     * addr 0xe0005000 intr 6: ps2 keyboard
124 ad6fe1d2 ths
     * addr 0xe0005000 intr 7: ps2 mouse
125 ad6fe1d2 ths
     * addr 0xe0006000 intr 8: ns16550a,
126 ad6fe1d2 ths
     * addr 0xe0007000 intr 9: ns16550a
127 ad6fe1d2 ths
     * isa_io_base 0xe2000000 isa_mem_base 0xe3000000
128 ad6fe1d2 ths
     */
129 ad6fe1d2 ths
130 ad6fe1d2 ths
    /* Init CPU internal devices */
131 ad6fe1d2 ths
    cpu_mips_irq_init_cpu(env);
132 ad6fe1d2 ths
    cpu_mips_clock_init(env);
133 ad6fe1d2 ths
    cpu_mips_irqctrl_init();
134 ad6fe1d2 ths
135 ad6fe1d2 ths
    /* Register 64 KB of ISA IO space at 0x10000000 */
136 ad6fe1d2 ths
    isa_mmio_init(0x10000000, 0x00010000);
137 ad6fe1d2 ths
    isa_mem_base = 0x11000000;
138 ad6fe1d2 ths
139 ad6fe1d2 ths
    /* PC style IRQ (i8259/i8254) and DMA (i8257) */
140 ad6fe1d2 ths
    /* The PIC is attached to the MIPS CPU INT0 pin */
141 ad6fe1d2 ths
    i8259 = i8259_init(env->irq[2]);
142 18c6e2ff ths
    rtc_mm_init(0x80004070, 1, i8259[14]);
143 ad6fe1d2 ths
    pit_init(0x40, 0);
144 ad6fe1d2 ths
145 ad6fe1d2 ths
    /* Keyboard (i8042) */
146 ad6fe1d2 ths
    i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0);
147 ad6fe1d2 ths
148 ad6fe1d2 ths
    /* IDE controller */
149 e4bcb14c ths
150 e4bcb14c ths
    if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
151 e4bcb14c ths
        fprintf(stderr, "qemu: too many IDE bus\n");
152 e4bcb14c ths
        exit(1);
153 e4bcb14c ths
    }
154 e4bcb14c ths
155 e4bcb14c ths
    for(i = 0; i < MAX_IDE_BUS; i++) {
156 e4bcb14c ths
        int hd0, hd1;
157 e4bcb14c ths
        hd0 = drive_get_index(IF_IDE, i, 0);
158 e4bcb14c ths
        hd1 = drive_get_index(IF_IDE, i, 1);
159 ad6fe1d2 ths
        isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
160 e4bcb14c ths
                     hd0 == -1 ? NULL : drives_table[hd0].bdrv,
161 e4bcb14c ths
                     hd1 == -1 ? NULL : drives_table[hd1].bdrv);
162 e4bcb14c ths
    }
163 ad6fe1d2 ths
164 ad6fe1d2 ths
    /* Network controller */
165 ad6fe1d2 ths
    /* FIXME: missing NS SONIC DP83932 */
166 ad6fe1d2 ths
167 ad6fe1d2 ths
    /* SCSI adapter */
168 ad6fe1d2 ths
    /* FIXME: missing NCR 53C94 */
169 ad6fe1d2 ths
170 ad6fe1d2 ths
    /* ISA devices (floppy, serial, parallel) */
171 e4bcb14c ths
172 e4bcb14c ths
    for (i = 0; i < MAX_FD; i++) {
173 e4bcb14c ths
        index = drive_get_index(IF_FLOPPY, 0, i);
174 e4bcb14c ths
        if (index == -1)
175 001a3f5a ths
            fd[i] = NULL;
176 001a3f5a ths
        else
177 001a3f5a ths
            fd[i] = drives_table[index].bdrv;
178 e4bcb14c ths
    }
179 e4bcb14c ths
    fdctrl_init(i8259[1], 1, 1, 0x80003000, fd);
180 ad6fe1d2 ths
    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
181 ad6fe1d2 ths
        if (serial_hds[i]) {
182 ad6fe1d2 ths
            serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1);
183 ad6fe1d2 ths
        }
184 ad6fe1d2 ths
    }
185 d60532ca ths
    /* Parallel port */
186 d60532ca ths
    if (parallel_hds[0]) parallel_mm_init(0x80008000, 0, i8259[1], parallel_hds[0]);
187 ad6fe1d2 ths
188 ad6fe1d2 ths
    /* Sound card */
189 ad6fe1d2 ths
    /* FIXME: missing Jazz sound, IRQ 18 */
190 ad6fe1d2 ths
191 ad6fe1d2 ths
    /* LED indicator */
192 ad6fe1d2 ths
    /* FIXME: missing LED indicator */
193 ad6fe1d2 ths
194 ad6fe1d2 ths
    /* NVRAM */
195 ad6fe1d2 ths
    ds1225y_init(0x80009000, "nvram");
196 ad6fe1d2 ths
197 ad6fe1d2 ths
    /* Video card */
198 2abec30b ths
    /* FIXME: This card is not the real one which was in the original PICA,
199 2abec30b ths
     * but let's do with what Qemu currenly emulates... */
200 2abec30b ths
    isa_vga_mm_init(ds, phys_ram_base + ram_size, ram_size, vga_ram_size,
201 2abec30b ths
                    0x40000000, 0x60000000, 0);
202 31211df1 ths
203 31211df1 ths
    /* LED indicator */
204 31211df1 ths
    jazz_led_init(ds, 0x8000f000);
205 ad6fe1d2 ths
}
206 ad6fe1d2 ths
207 ad6fe1d2 ths
QEMUMachine mips_pica61_machine = {
208 ad6fe1d2 ths
    "pica61",
209 ad6fe1d2 ths
    "Acer Pica 61",
210 ad6fe1d2 ths
    mips_pica61_init,
211 ad6fe1d2 ths
};