root / hw / dummy_m68k.c @ b4b784fe
History | View | Annotate | Download (2 kB)
1 |
/*
|
---|---|
2 |
* Dummy board with just RAM and CPU for use as an ISS.
|
3 |
*
|
4 |
* Copyright (c) 2007 CodeSourcery.
|
5 |
*
|
6 |
* This code is licenced under the GPL
|
7 |
*/
|
8 |
|
9 |
#include "hw.h" |
10 |
#include "sysemu.h" |
11 |
#include "boards.h" |
12 |
#include "loader.h" |
13 |
#include "elf.h" |
14 |
|
15 |
#define KERNEL_LOAD_ADDR 0x10000 |
16 |
|
17 |
/* Board init. */
|
18 |
|
19 |
static void dummy_m68k_init(ram_addr_t ram_size, |
20 |
const char *boot_device, |
21 |
const char *kernel_filename, const char *kernel_cmdline, |
22 |
const char *initrd_filename, const char *cpu_model) |
23 |
{ |
24 |
CPUState *env; |
25 |
int kernel_size;
|
26 |
uint64_t elf_entry; |
27 |
target_phys_addr_t entry; |
28 |
|
29 |
if (!cpu_model)
|
30 |
cpu_model = "cfv4e";
|
31 |
env = cpu_init(cpu_model); |
32 |
if (!env) {
|
33 |
fprintf(stderr, "Unable to find m68k CPU definition\n");
|
34 |
exit(1);
|
35 |
} |
36 |
|
37 |
/* Initialize CPU registers. */
|
38 |
env->vbr = 0;
|
39 |
|
40 |
/* RAM at address zero */
|
41 |
cpu_register_physical_memory(0, ram_size,
|
42 |
qemu_ram_alloc(ram_size) | IO_MEM_RAM); |
43 |
|
44 |
/* Load kernel. */
|
45 |
if (kernel_filename) {
|
46 |
kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL, |
47 |
1, ELF_MACHINE, 0); |
48 |
entry = elf_entry; |
49 |
if (kernel_size < 0) { |
50 |
kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
51 |
} |
52 |
if (kernel_size < 0) { |
53 |
kernel_size = load_image_targphys(kernel_filename, |
54 |
KERNEL_LOAD_ADDR, |
55 |
ram_size - KERNEL_LOAD_ADDR); |
56 |
entry = KERNEL_LOAD_ADDR; |
57 |
} |
58 |
if (kernel_size < 0) { |
59 |
fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
60 |
kernel_filename); |
61 |
exit(1);
|
62 |
} |
63 |
} else {
|
64 |
entry = 0;
|
65 |
} |
66 |
env->pc = entry; |
67 |
} |
68 |
|
69 |
static QEMUMachine dummy_m68k_machine = {
|
70 |
.name = "dummy",
|
71 |
.desc = "Dummy board",
|
72 |
.init = dummy_m68k_init, |
73 |
}; |
74 |
|
75 |
static void dummy_m68k_machine_init(void) |
76 |
{ |
77 |
qemu_register_machine(&dummy_m68k_machine); |
78 |
} |
79 |
|
80 |
machine_init(dummy_m68k_machine_init); |