nbd: enable use of TLS with qemu-nbd server
[qemu/ar7.git] / hw / m68k / dummy_m68k.c
bloba213bcf307d9df864fb518ade9b47f3a21eca4c1
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 "hw/hw.h"
11 #include "hw/boards.h"
12 #include "hw/loader.h"
13 #include "elf.h"
14 #include "exec/address-spaces.h"
16 #define KERNEL_LOAD_ADDR 0x10000
18 /* Board init. */
20 static void dummy_m68k_init(MachineState *machine)
22 ram_addr_t ram_size = machine->ram_size;
23 const char *cpu_model = machine->cpu_model;
24 const char *kernel_filename = machine->kernel_filename;
25 M68kCPU *cpu;
26 CPUM68KState *env;
27 MemoryRegion *address_space_mem = get_system_memory();
28 MemoryRegion *ram = g_new(MemoryRegion, 1);
29 int kernel_size;
30 uint64_t elf_entry;
31 hwaddr entry;
33 if (!cpu_model)
34 cpu_model = "cfv4e";
35 cpu = cpu_m68k_init(cpu_model);
36 if (!cpu) {
37 fprintf(stderr, "Unable to find m68k CPU definition\n");
38 exit(1);
40 env = &cpu->env;
42 /* Initialize CPU registers. */
43 env->vbr = 0;
45 /* RAM at address zero */
46 memory_region_allocate_system_memory(ram, NULL, "dummy_m68k.ram",
47 ram_size);
48 memory_region_add_subregion(address_space_mem, 0, ram);
50 /* Load kernel. */
51 if (kernel_filename) {
52 kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
53 NULL, NULL, 1, EM_68K, 0);
54 entry = elf_entry;
55 if (kernel_size < 0) {
56 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL,
57 NULL, NULL);
59 if (kernel_size < 0) {
60 kernel_size = load_image_targphys(kernel_filename,
61 KERNEL_LOAD_ADDR,
62 ram_size - KERNEL_LOAD_ADDR);
63 entry = KERNEL_LOAD_ADDR;
65 if (kernel_size < 0) {
66 fprintf(stderr, "qemu: could not load kernel '%s'\n",
67 kernel_filename);
68 exit(1);
70 } else {
71 entry = 0;
73 env->pc = entry;
76 static void dummy_m68k_machine_init(MachineClass *mc)
78 mc->desc = "Dummy board";
79 mc->init = dummy_m68k_init;
82 DEFINE_MACHINE("dummy", dummy_m68k_machine_init)