Statistics
| Branch: | Revision:

root / hw / mips_pica61.c @ 1192dad8

History | View | Annotate | Download (5.7 kB)

1
/*
2
 * QEMU Acer Pica Machine support
3
 *
4
 * Copyright (c) 2007 Herv? Poussineau
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

    
25
#include "vl.h"
26

    
27
#ifdef TARGET_WORDS_BIGENDIAN
28
#define BIOS_FILENAME "mips_bios.bin"
29
#else
30
#define BIOS_FILENAME "mipsel_bios.bin"
31
#endif
32

    
33
#ifdef TARGET_MIPS64
34
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffULL)
35
#else
36
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffU)
37
#endif
38

    
39
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
40

    
41
static const int ide_iobase[2] = { 0x1f0, 0x170 };
42
static const int ide_iobase2[2] = { 0x3f6, 0x376 };
43
static const int ide_irq[2] = { 14, 15 };
44

    
45
static uint32_t serial_base[MAX_SERIAL_PORTS] = { 0x80006000, 0x80007000 };
46
static int serial_irq[MAX_SERIAL_PORTS] = { 8, 9 };
47

    
48
extern FILE *logfile;
49

    
50
static void main_cpu_reset(void *opaque)
51
{
52
    CPUState *env = opaque;
53
    cpu_reset(env);
54
    cpu_mips_register(env, NULL);
55
}
56

    
57
static
58
void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device,
59
                    DisplayState *ds, const char **fd_filename, int snapshot,
60
                    const char *kernel_filename, const char *kernel_cmdline,
61
                    const char *initrd_filename, const char *cpu_model)
62
{
63
    char buf[1024];
64
    unsigned long bios_offset;
65
    int bios_size;
66
    CPUState *env;
67
    int i;
68
    mips_def_t *def;
69
    int available_ram;
70
    qemu_irq *i8259;
71

    
72
    /* init CPUs */
73
    if (cpu_model == NULL) {
74
#ifdef TARGET_MIPS64
75
        cpu_model = "R4000";
76
#else
77
        /* FIXME: All wrong, this maybe should be R3000 for the older PICAs. */
78
        cpu_model = "24Kf";
79
#endif
80
    }
81
    if (mips_find_by_name(cpu_model, &def) != 0)
82
        def = NULL;
83
    env = cpu_init();
84
    cpu_mips_register(env, def);
85
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
86
    qemu_register_reset(main_cpu_reset, env);
87

    
88
    /* allocate RAM (limited to 256 MB) */
89
    if (ram_size < 256 * 1024 * 1024)
90
        available_ram = ram_size;
91
    else
92
        available_ram = 256 * 1024 * 1024;
93
    cpu_register_physical_memory(0, available_ram, IO_MEM_RAM);
94

    
95
    /* load a BIOS image */
96
    bios_offset = ram_size + vga_ram_size;
97
    if (bios_name == NULL)
98
        bios_name = BIOS_FILENAME;
99
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
100
    bios_size = load_image(buf, phys_ram_base + bios_offset);
101
    if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
102
        /* fatal */
103
        fprintf(stderr, "qemu: Error, could not load MIPS bios '%s'\n",
104
                buf);
105
        exit(1);
106
    }
107
    cpu_register_physical_memory(0x1fc00000,
108
                                     BIOS_SIZE, bios_offset | IO_MEM_ROM);
109

    
110
    /* Device map
111
     *
112
     * addr 0xe0004000: mc146818
113
     * addr 0xe0005000 intr 6: ps2 keyboard
114
     * addr 0xe0005000 intr 7: ps2 mouse
115
     * addr 0xe0006000 intr 8: ns16550a,
116
     * addr 0xe0007000 intr 9: ns16550a
117
     * isa_io_base 0xe2000000 isa_mem_base 0xe3000000
118
     */
119

    
120
    /* Init CPU internal devices */
121
    cpu_mips_irq_init_cpu(env);
122
    cpu_mips_clock_init(env);
123
    cpu_mips_irqctrl_init();
124

    
125
    /* Register 64 KB of ISA IO space at 0x10000000 */
126
    isa_mmio_init(0x10000000, 0x00010000);
127
    isa_mem_base = 0x11000000;
128

    
129
    /* PC style IRQ (i8259/i8254) and DMA (i8257) */
130
    /* The PIC is attached to the MIPS CPU INT0 pin */
131
    i8259 = i8259_init(env->irq[2]);
132
    rtc_mm_init(0x80004070, 1, i8259[14]);
133
    pit_init(0x40, 0);
134

    
135
    /* Keyboard (i8042) */
136
    i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0);
137

    
138
    /* IDE controller */
139
    for(i = 0; i < 2; i++)
140
        isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
141
                     bs_table[2 * i], bs_table[2 * i + 1]);
142

    
143
    /* Network controller */
144
    /* FIXME: missing NS SONIC DP83932 */
145

    
146
    /* SCSI adapter */
147
    /* FIXME: missing NCR 53C94 */
148

    
149
    /* ISA devices (floppy, serial, parallel) */
150
    fdctrl_init(i8259[1], 1, 1, 0x80003000, fd_table);
151
    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
152
        if (serial_hds[i]) {
153
            serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1);
154
        }
155
    }
156
    /* Parallel port */
157
    if (parallel_hds[0]) parallel_mm_init(0x80008000, 0, i8259[1], parallel_hds[0]);
158

    
159
    /* Sound card */
160
    /* FIXME: missing Jazz sound, IRQ 18 */
161

    
162
    /* LED indicator */
163
    /* FIXME: missing LED indicator */
164

    
165
    /* NVRAM */
166
    ds1225y_init(0x80009000, "nvram");
167

    
168
    /* Video card */
169
    /* FIXME: This card is not the real one which was in the original PICA,
170
     * but let's do with what Qemu currenly emulates... */
171
    isa_vga_mm_init(ds, phys_ram_base + ram_size, ram_size, vga_ram_size,
172
                    0x40000000, 0x60000000, 0);
173

    
174
    /* LED indicator */
175
    jazz_led_init(ds, 0x8000f000);
176
}
177

    
178
QEMUMachine mips_pica61_machine = {
179
    "pica61",
180
    "Acer Pica 61",
181
    mips_pica61_init,
182
};