pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 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 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 9 | #include "hw.h" |
| 10 | #include "sysemu.h" |
| 11 | #include "boards.h" |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 12 | #include "loader.h" |
| 13 | #include "elf.h" |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 14 | |
| 15 | #define KERNEL_LOAD_ADDR 0x10000 |
| 16 | |
| 17 | /* Board init. */ |
| 18 | |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 19 | static void dummy_m68k_init(ram_addr_t ram_size, |
aliguori | 3023f33 | 2009-01-16 19:04:14 +0000 | [diff] [blame] | 20 | const char *boot_device, |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 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; |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 27 | target_phys_addr_t entry; |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 28 | |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 29 | if (!cpu_model) |
| 30 | cpu_model = "cfv4e"; |
pbrook | cd08ce8 | 2007-11-10 19:21:30 +0000 | [diff] [blame] | 31 | env = cpu_init(cpu_model); |
| 32 | if (!env) { |
| 33 | fprintf(stderr, "Unable to find m68k CPU definition\n"); |
| 34 | exit(1); |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 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) { |
Blue Swirl | ca20cf3 | 2009-09-20 14:58:02 +0000 | [diff] [blame] | 46 | kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL, |
| 47 | 1, ELF_MACHINE, 0); |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 48 | entry = elf_entry; |
| 49 | if (kernel_size < 0) { |
aliguori | 5a9154e | 2008-11-20 22:14:40 +0000 | [diff] [blame] | 50 | kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 51 | } |
| 52 | if (kernel_size < 0) { |
pbrook | dcac967 | 2009-04-09 20:05:49 +0000 | [diff] [blame] | 53 | kernel_size = load_image_targphys(kernel_filename, |
| 54 | KERNEL_LOAD_ADDR, |
| 55 | ram_size - KERNEL_LOAD_ADDR); |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 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 | |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 69 | static QEMUMachine dummy_m68k_machine = { |
aliguori | 4b32e16 | 2008-10-07 20:34:35 +0000 | [diff] [blame] | 70 | .name = "dummy", |
| 71 | .desc = "Dummy board", |
| 72 | .init = dummy_m68k_init, |
pbrook | ca02f31 | 2007-11-10 18:03:23 +0000 | [diff] [blame] | 73 | }; |
Anthony Liguori | f80f9ec | 2009-05-20 18:38:09 -0500 | [diff] [blame] | 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); |