~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to hw/mips_r4k.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno, Aurelien Jarno
  • Date: 2009-03-07 06:20:34 UTC
  • mfrom: (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20090307062034-i3pead4mw653v2el
Tags: 0.10.0-1
[ Aurelien Jarno ]
* New upstream release:
  - Fix fr-be keyboard mapping (closes: bug#514462).
  - Fix stat64 structure on ppc-linux-user (closes: bug#470231).
  - Add a chroot option (closes: bug#415996).
  - Add evdev support (closes: bug#513210).
  - Fix loop on symlinks in user mode (closes: bug#297572).
  - Bump depends on openbios-sparc.
  - Depends on openbios-ppc.
  - Update 12_signal_powerpc_support.patch.
  - Update 21_net_soopts.patch.
  - Drop 44_socklen_t_check.patch (merged upstream).
  - Drop 49_null_check.patch (merged upstream).
  - Update 64_ppc_asm_constraints.patch.
  - Drop security/CVE-2008-0928-fedora.patch (merged upstream).
  - Drop security/CVE-2007-5730.patch (merged upstream).
* patches/80_stable-branch.patch: add patches from stable branch:
  - Fix race condition between signal handler/execution loop (closes:
    bug#474386, bug#501731).
* debian/copyright: update.
* Compile and install .dtb files:
  - debian/control: build-depends on device-tree-compiler.
  - debian/patches/81_compile_dtb.patch: new patch from upstream.
  - debian/rules: compile and install bamboo.dtb and mpc8544.dtb.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
#include "net.h"
15
15
#include "sysemu.h"
16
16
#include "boards.h"
 
17
#include "flash.h"
 
18
#include "qemu-log.h"
17
19
 
18
20
#ifdef TARGET_WORDS_BIGENDIAN
19
21
#define BIOS_FILENAME "mips_bios.bin"
34
36
static int serial_io[MAX_SERIAL_PORTS] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
35
37
static int serial_irq[MAX_SERIAL_PORTS] = { 4, 3, 4, 3 };
36
38
 
37
 
extern FILE *logfile;
38
 
 
39
39
static PITState *pit; /* PIT i8254 */
40
40
 
41
41
/* i8254 PIT is attached to the IRQ0 at PIC i8259 */
82
82
    ram_addr_t initrd_offset;
83
83
 
84
84
    kernel_size = load_elf(loaderparams.kernel_filename, VIRT_TO_PHYS_ADDEND,
85
 
                           &entry, &kernel_low, &kernel_high);
 
85
                           (uint64_t *)&entry, (uint64_t *)&kernel_low,
 
86
                           (uint64_t *)&kernel_high);
86
87
    if (kernel_size >= 0) {
87
88
        if ((entry & ~0x7fffffffULL) == 0x80000000)
88
89
            entry = (int32_t)entry;
89
 
        env->PC[env->current_tc] = entry;
 
90
        env->active_tc.PC = entry;
90
91
    } else {
91
92
        fprintf(stderr, "qemu: could not load kernel '%s'\n",
92
93
                loaderparams.kernel_filename);
119
120
    /* Store command line.  */
120
121
    if (initrd_size > 0) {
121
122
        int ret;
122
 
        ret = sprintf(phys_ram_base + (16 << 20) - 256,
 
123
        ret = sprintf((char *)(phys_ram_base + (16 << 20) - 256),
123
124
                      "rd_start=0x" TARGET_FMT_lx " rd_size=%li ",
124
125
                      PHYS_TO_VIRT((uint32_t)initrd_offset),
125
126
                      initrd_size);
126
 
        strcpy (phys_ram_base + (16 << 20) - 256 + ret,
 
127
        strcpy ((char *)(phys_ram_base + (16 << 20) - 256 + ret),
127
128
                loaderparams.kernel_cmdline);
128
129
    }
129
130
    else {
130
 
        strcpy (phys_ram_base + (16 << 20) - 256,
 
131
        strcpy ((char *)(phys_ram_base + (16 << 20) - 256),
131
132
                loaderparams.kernel_cmdline);
132
133
    }
133
134
 
144
145
        load_kernel (env);
145
146
}
146
147
 
 
148
static const int sector_len = 32 * 1024;
147
149
static
148
 
void mips_r4k_init (int ram_size, int vga_ram_size,
149
 
                    const char *boot_device, DisplayState *ds,
 
150
void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size,
 
151
                    const char *boot_device,
150
152
                    const char *kernel_filename, const char *kernel_cmdline,
151
153
                    const char *initrd_filename, const char *cpu_model)
152
154
{
173
175
        fprintf(stderr, "Unable to find CPU definition\n");
174
176
        exit(1);
175
177
    }
176
 
    register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
177
178
    qemu_register_reset(main_cpu_reset, env);
178
179
 
179
180
    /* allocate RAM */
 
181
    if (ram_size > (256 << 20)) {
 
182
        fprintf(stderr,
 
183
                "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
 
184
                ((unsigned int)ram_size / (1 << 20)));
 
185
        exit(1);
 
186
    }
180
187
    cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
181
188
 
182
189
    if (!mips_qemu_iomemtype) {
197
204
    if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
198
205
        cpu_register_physical_memory(0x1fc00000,
199
206
                                     BIOS_SIZE, bios_offset | IO_MEM_ROM);
200
 
    } else {
 
207
    } else if ((index = drive_get_index(IF_PFLASH, 0, 0)) > -1) {
 
208
        uint32_t mips_rom = 0x00400000;
 
209
        cpu_register_physical_memory(0x1fc00000, mips_rom,
 
210
                             qemu_ram_alloc(mips_rom) | IO_MEM_ROM);
 
211
        if (!pflash_cfi01_register(0x1fc00000, qemu_ram_alloc(mips_rom),
 
212
            drives_table[index].bdrv, sector_len, mips_rom / sector_len,
 
213
            4, 0, 0, 0, 0)) {
 
214
            fprintf(stderr, "qemu: Error registering flash memory.\n");
 
215
        }
 
216
    }
 
217
    else {
201
218
        /* not fatal */
202
219
        fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
203
220
                buf);
214
231
    /* Init CPU internal devices */
215
232
    cpu_mips_irq_init_cpu(env);
216
233
    cpu_mips_clock_init(env);
217
 
    cpu_mips_irqctrl_init();
218
234
 
219
235
    /* The PIC is attached to the MIPS CPU INT0 pin */
220
236
    i8259 = i8259_init(env->irq[2]);
221
237
 
222
 
    rtc_state = rtc_init(0x70, i8259[8]);
 
238
    rtc_state = rtc_init(0x70, i8259[8], 2000);
223
239
 
224
240
    /* Register 64 KB of ISA IO space at 0x14000000 */
225
241
    isa_mmio_init(0x14000000, 0x00010000);
229
245
 
230
246
    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
231
247
        if (serial_hds[i]) {
232
 
            serial_init(serial_io[i], i8259[serial_irq[i]], serial_hds[i]);
 
248
            serial_init(serial_io[i], i8259[serial_irq[i]], 115200,
 
249
                        serial_hds[i]);
233
250
        }
234
251
    }
235
252
 
236
 
    isa_vga_init(ds, phys_ram_base + ram_size, ram_size,
 
253
    isa_vga_init(phys_ram_base + ram_size, ram_size,
237
254
                 vga_ram_size);
238
255
 
239
 
    if (nd_table[0].vlan) {
240
 
        if (nd_table[0].model == NULL
241
 
            || strcmp(nd_table[0].model, "ne2k_isa") == 0) {
242
 
            isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
243
 
        } else if (strcmp(nd_table[0].model, "?") == 0) {
244
 
            fprintf(stderr, "qemu: Supported NICs: ne2k_isa\n");
245
 
            exit (1);
246
 
        } else {
247
 
            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
248
 
            exit (1);
249
 
        }
250
 
    }
 
256
    if (nd_table[0].vlan)
 
257
        isa_ne2000_init(0x300, i8259[9], &nd_table[0]);
251
258
 
252
259
    if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
253
260
        fprintf(stderr, "qemu: too many IDE bus\n");
271
278
}
272
279
 
273
280
QEMUMachine mips_machine = {
274
 
    "mips",
275
 
    "mips r4k platform",
276
 
    mips_r4k_init,
 
281
    .name = "mips",
 
282
    .desc = "mips r4k platform",
 
283
    .init = mips_r4k_init,
 
284
    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
 
285
    .nodisk_ok = 1,
277
286
};