~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/mips_pica61.c

  • Committer: blueswir1
  • Date: 2007-11-25 08:48:16 UTC
  • Revision ID: git-v1:b76482e76560345c00e7d6c89199ced204a926d2
 Fix buffer mux handling for unconnected serial ports


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3737 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "hw.h"
 
26
#include "mips.h"
 
27
#include "isa.h"
 
28
#include "pc.h"
 
29
#include "fdc.h"
 
30
#include "sysemu.h"
 
31
#include "boards.h"
 
32
 
 
33
#ifdef TARGET_WORDS_BIGENDIAN
 
34
#define BIOS_FILENAME "mips_bios.bin"
 
35
#else
 
36
#define BIOS_FILENAME "mipsel_bios.bin"
 
37
#endif
 
38
 
 
39
#ifdef TARGET_MIPS64
 
40
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffULL)
 
41
#else
 
42
#define PHYS_TO_VIRT(x) ((x) | ~0x7fffffffU)
 
43
#endif
 
44
 
 
45
#define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000))
 
46
 
 
47
static const int ide_iobase[2] = { 0x1f0, 0x170 };
 
48
static const int ide_iobase2[2] = { 0x3f6, 0x376 };
 
49
static const int ide_irq[2] = { 14, 15 };
 
50
 
 
51
static uint32_t serial_base[MAX_SERIAL_PORTS] = { 0x80006000, 0x80007000 };
 
52
static int serial_irq[MAX_SERIAL_PORTS] = { 8, 9 };
 
53
 
 
54
extern FILE *logfile;
 
55
 
 
56
static void main_cpu_reset(void *opaque)
 
57
{
 
58
    CPUState *env = opaque;
 
59
    cpu_reset(env);
 
60
}
 
61
 
 
62
static
 
63
void mips_pica61_init (int ram_size, int vga_ram_size,
 
64
                       const char *boot_device, DisplayState *ds,
 
65
                    const char *kernel_filename, const char *kernel_cmdline,
 
66
                    const char *initrd_filename, const char *cpu_model)
 
67
{
 
68
    char buf[1024];
 
69
    unsigned long bios_offset;
 
70
    int bios_size;
 
71
    CPUState *env;
 
72
    int i;
 
73
    int available_ram;
 
74
    qemu_irq *i8259;
 
75
 
 
76
    /* init CPUs */
 
77
    if (cpu_model == NULL) {
 
78
#ifdef TARGET_MIPS64
 
79
        cpu_model = "R4000";
 
80
#else
 
81
        /* FIXME: All wrong, this maybe should be R3000 for the older PICAs. */
 
82
        cpu_model = "24Kf";
 
83
#endif
 
84
    }
 
85
    env = cpu_init(cpu_model);
 
86
    if (!env) {
 
87
        fprintf(stderr, "Unable to find CPU definition\n");
 
88
        exit(1);
 
89
    }
 
90
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
 
91
    qemu_register_reset(main_cpu_reset, env);
 
92
 
 
93
    /* allocate RAM (limited to 256 MB) */
 
94
    if (ram_size < 256 * 1024 * 1024)
 
95
        available_ram = ram_size;
 
96
    else
 
97
        available_ram = 256 * 1024 * 1024;
 
98
    cpu_register_physical_memory(0, available_ram, IO_MEM_RAM);
 
99
 
 
100
    /* load a BIOS image */
 
101
    bios_offset = ram_size + vga_ram_size;
 
102
    if (bios_name == NULL)
 
103
        bios_name = BIOS_FILENAME;
 
104
    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
 
105
    bios_size = load_image(buf, phys_ram_base + bios_offset);
 
106
    if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
 
107
        /* fatal */
 
108
        fprintf(stderr, "qemu: Error, could not load MIPS bios '%s'\n",
 
109
                buf);
 
110
        exit(1);
 
111
    }
 
112
    cpu_register_physical_memory(0x1fc00000,
 
113
                                     BIOS_SIZE, bios_offset | IO_MEM_ROM);
 
114
 
 
115
    /* Device map
 
116
     *
 
117
     * addr 0xe0004000: mc146818
 
118
     * addr 0xe0005000 intr 6: ps2 keyboard
 
119
     * addr 0xe0005000 intr 7: ps2 mouse
 
120
     * addr 0xe0006000 intr 8: ns16550a,
 
121
     * addr 0xe0007000 intr 9: ns16550a
 
122
     * isa_io_base 0xe2000000 isa_mem_base 0xe3000000
 
123
     */
 
124
 
 
125
    /* Init CPU internal devices */
 
126
    cpu_mips_irq_init_cpu(env);
 
127
    cpu_mips_clock_init(env);
 
128
    cpu_mips_irqctrl_init();
 
129
 
 
130
    /* Register 64 KB of ISA IO space at 0x10000000 */
 
131
    isa_mmio_init(0x10000000, 0x00010000);
 
132
    isa_mem_base = 0x11000000;
 
133
 
 
134
    /* PC style IRQ (i8259/i8254) and DMA (i8257) */
 
135
    /* The PIC is attached to the MIPS CPU INT0 pin */
 
136
    i8259 = i8259_init(env->irq[2]);
 
137
    rtc_mm_init(0x80004070, 1, i8259[14]);
 
138
    pit_init(0x40, 0);
 
139
 
 
140
    /* Keyboard (i8042) */
 
141
    i8042_mm_init(i8259[6], i8259[7], 0x80005060, 0);
 
142
 
 
143
    /* IDE controller */
 
144
    for(i = 0; i < 2; i++)
 
145
        isa_ide_init(ide_iobase[i], ide_iobase2[i], i8259[ide_irq[i]],
 
146
                     bs_table[2 * i], bs_table[2 * i + 1]);
 
147
 
 
148
    /* Network controller */
 
149
    /* FIXME: missing NS SONIC DP83932 */
 
150
 
 
151
    /* SCSI adapter */
 
152
    /* FIXME: missing NCR 53C94 */
 
153
 
 
154
    /* ISA devices (floppy, serial, parallel) */
 
155
    fdctrl_init(i8259[1], 1, 1, 0x80003000, fd_table);
 
156
    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
 
157
        if (serial_hds[i]) {
 
158
            serial_mm_init(serial_base[i], 0, i8259[serial_irq[i]], serial_hds[i], 1);
 
159
        }
 
160
    }
 
161
    /* Parallel port */
 
162
    if (parallel_hds[0]) parallel_mm_init(0x80008000, 0, i8259[1], parallel_hds[0]);
 
163
 
 
164
    /* Sound card */
 
165
    /* FIXME: missing Jazz sound, IRQ 18 */
 
166
 
 
167
    /* LED indicator */
 
168
    /* FIXME: missing LED indicator */
 
169
 
 
170
    /* NVRAM */
 
171
    ds1225y_init(0x80009000, "nvram");
 
172
 
 
173
    /* Video card */
 
174
    /* FIXME: This card is not the real one which was in the original PICA,
 
175
     * but let's do with what Qemu currenly emulates... */
 
176
    isa_vga_mm_init(ds, phys_ram_base + ram_size, ram_size, vga_ram_size,
 
177
                    0x40000000, 0x60000000, 0);
 
178
 
 
179
    /* LED indicator */
 
180
    jazz_led_init(ds, 0x8000f000);
 
181
}
 
182
 
 
183
QEMUMachine mips_pica61_machine = {
 
184
    "pica61",
 
185
    "Acer Pica 61",
 
186
    mips_pica61_init,
 
187
};