Statistics
| Branch: | Revision:

root / hw / dummy_m68k.c @ e1dad5a6

History | View | Annotate | Download (1.8 kB)

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

    
9
#include "hw.h"
10
#include "sysemu.h"
11
#include "boards.h"
12

    
13
#define KERNEL_LOAD_ADDR 0x10000
14

    
15
/* Board init.  */
16

    
17
static void dummy_m68k_init(int ram_size, int vga_ram_size,
18
                     const char *boot_device, DisplayState *ds,
19
                     const char **fd_filename, int snapshot,
20
                     const char *kernel_filename, const char *kernel_cmdline,
21
                     const char *initrd_filename, const char *cpu_model)
22
{
23
    CPUState *env;
24
    int kernel_size;
25
    uint64_t elf_entry;
26
    target_ulong entry;
27

    
28
    if (!cpu_model)
29
        cpu_model = "cfv4e";
30
    env = cpu_init(cpu_model);
31
    if (!env) {
32
        fprintf(stderr, "Unable to find m68k CPU definition\n");
33
        exit(1);
34
    }
35

    
36
    /* Initialize CPU registers.  */
37
    env->vbr = 0;
38

    
39
    /* RAM at address zero */
40
    cpu_register_physical_memory(0, ram_size,
41
        qemu_ram_alloc(ram_size) | IO_MEM_RAM);
42

    
43
    /* Load kernel.  */
44
    if (kernel_filename) {
45
        kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL);
46
        entry = elf_entry;
47
        if (kernel_size < 0) {
48
            kernel_size = load_uboot(kernel_filename, &entry, NULL);
49
        }
50
        if (kernel_size < 0) {
51
            kernel_size = load_image(kernel_filename,
52
                                     phys_ram_base + KERNEL_LOAD_ADDR);
53
            entry = KERNEL_LOAD_ADDR;
54
        }
55
        if (kernel_size < 0) {
56
            fprintf(stderr, "qemu: could not load kernel '%s'\n",
57
                    kernel_filename);
58
            exit(1);
59
        }
60
    } else {
61
        entry = 0;
62
    }
63
    env->pc = entry;
64
}
65

    
66
QEMUMachine dummy_m68k_machine = {
67
    "dummy",
68
    "Dummy board",
69
    dummy_m68k_init,
70
};