root / hw / dummy_m68k.c @ b6741956
History | View | Annotate | Download (1.8 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 | ca02f319 | pbrook | #include "vl.h" |
10 | ca02f319 | pbrook | |
11 | ca02f319 | pbrook | #define KERNEL_LOAD_ADDR 0x10000 |
12 | ca02f319 | pbrook | |
13 | ca02f319 | pbrook | /* Board init. */
|
14 | ca02f319 | pbrook | |
15 | cd08ce8f | pbrook | static void dummy_m68k_init(int ram_size, int vga_ram_size, |
16 | cd08ce8f | pbrook | const char *boot_device, DisplayState *ds, |
17 | cd08ce8f | pbrook | const char **fd_filename, int snapshot, |
18 | ca02f319 | pbrook | const char *kernel_filename, const char *kernel_cmdline, |
19 | ca02f319 | pbrook | const char *initrd_filename, const char *cpu_model) |
20 | ca02f319 | pbrook | { |
21 | ca02f319 | pbrook | CPUState *env; |
22 | ca02f319 | pbrook | int kernel_size;
|
23 | ca02f319 | pbrook | uint64_t elf_entry; |
24 | ca02f319 | pbrook | target_ulong entry; |
25 | ca02f319 | pbrook | |
26 | ca02f319 | pbrook | if (!cpu_model)
|
27 | ca02f319 | pbrook | cpu_model = "cfv4e";
|
28 | cd08ce8f | pbrook | env = cpu_init(cpu_model); |
29 | cd08ce8f | pbrook | if (!env) {
|
30 | cd08ce8f | pbrook | fprintf(stderr, "Unable to find m68k CPU definition\n");
|
31 | cd08ce8f | pbrook | exit(1);
|
32 | ca02f319 | pbrook | } |
33 | ca02f319 | pbrook | |
34 | ca02f319 | pbrook | /* Initialize CPU registers. */
|
35 | ca02f319 | pbrook | env->vbr = 0;
|
36 | ca02f319 | pbrook | |
37 | ca02f319 | pbrook | /* RAM at address zero */
|
38 | ca02f319 | pbrook | cpu_register_physical_memory(0, ram_size,
|
39 | ca02f319 | pbrook | qemu_ram_alloc(ram_size) | IO_MEM_RAM); |
40 | ca02f319 | pbrook | |
41 | ca02f319 | pbrook | /* Load kernel. */
|
42 | ca02f319 | pbrook | if (kernel_filename) {
|
43 | ca02f319 | pbrook | kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL); |
44 | ca02f319 | pbrook | entry = elf_entry; |
45 | ca02f319 | pbrook | if (kernel_size < 0) { |
46 | ca02f319 | pbrook | kernel_size = load_uboot(kernel_filename, &entry, NULL);
|
47 | ca02f319 | pbrook | } |
48 | ca02f319 | pbrook | if (kernel_size < 0) { |
49 | ca02f319 | pbrook | kernel_size = load_image(kernel_filename, |
50 | ca02f319 | pbrook | phys_ram_base + KERNEL_LOAD_ADDR); |
51 | ca02f319 | pbrook | entry = KERNEL_LOAD_ADDR; |
52 | ca02f319 | pbrook | } |
53 | ca02f319 | pbrook | if (kernel_size < 0) { |
54 | ca02f319 | pbrook | fprintf(stderr, "qemu: could not load kernel '%s'\n",
|
55 | ca02f319 | pbrook | kernel_filename); |
56 | ca02f319 | pbrook | exit(1);
|
57 | ca02f319 | pbrook | } |
58 | ca02f319 | pbrook | } else {
|
59 | ca02f319 | pbrook | entry = 0;
|
60 | ca02f319 | pbrook | } |
61 | ca02f319 | pbrook | env->pc = entry; |
62 | ca02f319 | pbrook | } |
63 | ca02f319 | pbrook | |
64 | ca02f319 | pbrook | QEMUMachine dummy_m68k_machine = { |
65 | ca02f319 | pbrook | "dummy",
|
66 | ca02f319 | pbrook | "Dummy board",
|
67 | ca02f319 | pbrook | dummy_m68k_init, |
68 | ca02f319 | pbrook | }; |