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