Revert "gdbstub: Do not kill target in system emulation mode"
[qemu/qmp-unstable.git] / hw / m68k / dummy_m68k.c
blob5b77d930e42663add08be1ed0861cf86e9f7b8ab
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 "hw/hw.h"
10 #include "hw/boards.h"
11 #include "hw/loader.h"
12 #include "elf.h"
13 #include "exec/address-spaces.h"
15 #define KERNEL_LOAD_ADDR 0x10000
17 /* Board init. */
19 static void dummy_m68k_init(MachineState *machine)
21 ram_addr_t ram_size = machine->ram_size;
22 const char *cpu_model = machine->cpu_model;
23 const char *kernel_filename = machine->kernel_filename;
24 M68kCPU *cpu;
25 CPUM68KState *env;
26 MemoryRegion *address_space_mem = get_system_memory();
27 MemoryRegion *ram = g_new(MemoryRegion, 1);
28 int kernel_size;
29 uint64_t elf_entry;
30 hwaddr entry;
32 if (!cpu_model)
33 cpu_model = "cfv4e";
34 cpu = cpu_m68k_init(cpu_model);
35 if (!cpu) {
36 fprintf(stderr, "Unable to find m68k CPU definition\n");
37 exit(1);
39 env = &cpu->env;
41 /* Initialize CPU registers. */
42 env->vbr = 0;
44 /* RAM at address zero */
45 memory_region_allocate_system_memory(ram, NULL, "dummy_m68k.ram",
46 ram_size);
47 memory_region_add_subregion(address_space_mem, 0, ram);
49 /* Load kernel. */
50 if (kernel_filename) {
51 kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
52 NULL, NULL, 1, ELF_MACHINE, 0);
53 entry = elf_entry;
54 if (kernel_size < 0) {
55 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
56 NULL, NULL);
58 if (kernel_size < 0) {
59 kernel_size = load_image_targphys(kernel_filename,
60 KERNEL_LOAD_ADDR,
61 ram_size - KERNEL_LOAD_ADDR);
62 entry = KERNEL_LOAD_ADDR;
64 if (kernel_size < 0) {
65 fprintf(stderr, "qemu: could not load kernel '%s'\n",
66 kernel_filename);
67 exit(1);
69 } else {
70 entry = 0;
72 env->pc = entry;
75 static QEMUMachine dummy_m68k_machine = {
76 .name = "dummy",
77 .desc = "Dummy board",
78 .init = dummy_m68k_init,
81 static void dummy_m68k_machine_init(void)
83 qemu_register_machine(&dummy_m68k_machine);
86 machine_init(dummy_m68k_machine_init);