MAINTAINERS: Add files to the Moxie section.
[qemu/ar7.git] / hw / m68k / dummy_m68k.c
blob0b11d2074aaeeb6902a2bb38dbbef1a1fdfe8010
1 /*
2 * Dummy board with just RAM and CPU for use as an ISS.
4 * Copyright (c) 2007 CodeSourcery.
6 * This code is licensed under the GPL
7 */
9 #include "qemu/osdep.h"
10 #include "qemu-common.h"
11 #include "cpu.h"
12 #include "hw/hw.h"
13 #include "hw/boards.h"
14 #include "hw/loader.h"
15 #include "elf.h"
16 #include "exec/address-spaces.h"
18 #define KERNEL_LOAD_ADDR 0x10000
20 /* Board init. */
22 static void dummy_m68k_init(MachineState *machine)
24 ram_addr_t ram_size = machine->ram_size;
25 const char *cpu_model = machine->cpu_model;
26 const char *kernel_filename = machine->kernel_filename;
27 M68kCPU *cpu;
28 CPUM68KState *env;
29 MemoryRegion *address_space_mem = get_system_memory();
30 MemoryRegion *ram = g_new(MemoryRegion, 1);
31 int kernel_size;
32 uint64_t elf_entry;
33 hwaddr entry;
35 if (!cpu_model)
36 cpu_model = "cfv4e";
37 cpu = cpu_m68k_init(cpu_model);
38 if (!cpu) {
39 fprintf(stderr, "Unable to find m68k CPU definition\n");
40 exit(1);
42 env = &cpu->env;
44 /* Initialize CPU registers. */
45 env->vbr = 0;
47 /* RAM at address zero */
48 memory_region_allocate_system_memory(ram, NULL, "dummy_m68k.ram",
49 ram_size);
50 memory_region_add_subregion(address_space_mem, 0, ram);
52 /* Load kernel. */
53 if (kernel_filename) {
54 kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
55 NULL, NULL, 1, EM_68K, 0, 0);
56 entry = elf_entry;
57 if (kernel_size < 0) {
58 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
59 NULL, NULL);
61 if (kernel_size < 0) {
62 kernel_size = load_image_targphys(kernel_filename,
63 KERNEL_LOAD_ADDR,
64 ram_size - KERNEL_LOAD_ADDR);
65 entry = KERNEL_LOAD_ADDR;
67 if (kernel_size < 0) {
68 fprintf(stderr, "qemu: could not load kernel '%s'\n",
69 kernel_filename);
70 exit(1);
72 } else {
73 entry = 0;
75 env->pc = entry;
78 static void dummy_m68k_machine_init(MachineClass *mc)
80 mc->desc = "Dummy board";
81 mc->init = dummy_m68k_init;
84 DEFINE_MACHINE("dummy", dummy_m68k_machine_init)