1 |
/* |
2 |
* Copyright (C) 2006-2007 Anders Gavare. All rights reserved. |
3 |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
6 |
* |
7 |
* 1. Redistributions of source code must retain the above copyright |
8 |
* notice, this list of conditions and the following disclaimer. |
9 |
* 2. Redistributions in binary form must reproduce the above copyright |
10 |
* notice, this list of conditions and the following disclaimer in the |
11 |
* documentation and/or other materials provided with the distribution. |
12 |
* 3. The name of the author may not be used to endorse or promote products |
13 |
* derived from this software without specific prior written permission. |
14 |
* |
15 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
16 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
19 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
20 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
21 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
22 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
23 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
24 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
25 |
* SUCH DAMAGE. |
26 |
* |
27 |
* |
28 |
* $Id: machine_qemu.c,v 1.14 2007/06/20 18:59:16 debug Exp $ |
29 |
* |
30 |
* COMMENT: Machine mimicing QEMU's default MIPS emulation mode |
31 |
* |
32 |
* See e.g. http://fabrice.bellard.free.fr/qemu/mips-test-0.2.tar.gz |
33 |
*/ |
34 |
|
35 |
#include <stdio.h> |
36 |
#include <stdlib.h> |
37 |
#include <string.h> |
38 |
|
39 |
#include "bus_isa.h" |
40 |
#include "cpu.h" |
41 |
#include "device.h" |
42 |
#include "devices.h" |
43 |
#include "machine.h" |
44 |
#include "memory.h" |
45 |
#include "misc.h" |
46 |
|
47 |
|
48 |
MACHINE_SETUP(qemu_mips) |
49 |
{ |
50 |
char tmpstr[300]; |
51 |
|
52 |
machine->machine_name = "QEMU MIPS"; |
53 |
cpu->byte_order = EMUL_BIG_ENDIAN; |
54 |
|
55 |
/* |
56 |
* An ISA bus, I/O ports at 0x14000000, memory at 0x10000000, |
57 |
* connected to MIPS irq 2: |
58 |
*/ |
59 |
snprintf(tmpstr, sizeof(tmpstr), "%s.cpu[%i].2", |
60 |
machine->path, machine->bootstrap_cpu); |
61 |
bus_isa_init(machine, tmpstr, BUS_ISA_IDE0 | BUS_ISA_IDE1, |
62 |
0x14000000ULL, 0x10000000ULL); |
63 |
|
64 |
if (!machine->prom_emulation) |
65 |
return; |
66 |
|
67 |
/* |
68 |
* Registers at startup do not seem to be defined in QEMU, but |
69 |
* bootargs and memory size are placed just below 16 MB. |
70 |
* |
71 |
* Remember to start the emulator with options, e.g.: |
72 |
* |
73 |
* -o "console=ttyS0 root=/dev/ram rd_start=0x80800000 |
74 |
* rd_size=10000000 init=/bin/sh" |
75 |
*/ |
76 |
|
77 |
store_string(cpu, (int32_t)(0x80000000 + 16*1048576 - 256), |
78 |
machine->boot_string_argument); |
79 |
store_32bit_word(cpu, (int32_t)(0x80000000 + 16*1048576 - 260), |
80 |
0x12345678); |
81 |
store_32bit_word(cpu, (int32_t)(0x80000000 + 16*1048576 - 264), |
82 |
machine->physical_ram_in_mb * 1048576); |
83 |
} |
84 |
|
85 |
|
86 |
MACHINE_DEFAULT_CPU(qemu_mips) |
87 |
{ |
88 |
/* QEMU emulates a MIPS32 rev 1, so 4Kc will do just fine. */ |
89 |
machine->cpu_name = strdup("4Kc"); |
90 |
} |
91 |
|
92 |
|
93 |
MACHINE_DEFAULT_RAM(qemu_mips) |
94 |
{ |
95 |
machine->physical_ram_in_mb = 64; |
96 |
} |
97 |
|
98 |
|
99 |
MACHINE_REGISTER(qemu_mips) |
100 |
{ |
101 |
MR_DEFAULT(qemu_mips, "QEMU MIPS", ARCH_MIPS, MACHINE_QEMU_MIPS); |
102 |
me->set_default_ram = machine_default_ram_qemu_mips; |
103 |
machine_entry_add_alias(me, "qemu_mips"); |
104 |
} |
105 |
|