blob: ce45a597db38243d8dffbe334d679de5dddda88b [file] [log] [blame]
pbrookca02f312007-11-10 18:03:23 +00001/*
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
pbrook87ecb682007-11-17 17:14:51 +00009#include "hw.h"
10#include "sysemu.h"
11#include "boards.h"
Blue Swirlca20cf32009-09-20 14:58:02 +000012#include "loader.h"
13#include "elf.h"
pbrookca02f312007-11-10 18:03:23 +000014
15#define KERNEL_LOAD_ADDR 0x10000
16
17/* Board init. */
18
Anthony Liguoric227f092009-10-01 16:12:16 -050019static void dummy_m68k_init(ram_addr_t ram_size,
aliguori3023f332009-01-16 19:04:14 +000020 const char *boot_device,
pbrookca02f312007-11-10 18:03:23 +000021 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 Liguoric227f092009-10-01 16:12:16 -050027 target_phys_addr_t entry;
pbrookca02f312007-11-10 18:03:23 +000028
pbrookca02f312007-11-10 18:03:23 +000029 if (!cpu_model)
30 cpu_model = "cfv4e";
pbrookcd08ce82007-11-10 19:21:30 +000031 env = cpu_init(cpu_model);
32 if (!env) {
33 fprintf(stderr, "Unable to find m68k CPU definition\n");
34 exit(1);
pbrookca02f312007-11-10 18:03:23 +000035 }
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 Swirlca20cf32009-09-20 14:58:02 +000046 kernel_size = load_elf(kernel_filename, 0, &elf_entry, NULL, NULL,
47 1, ELF_MACHINE, 0);
pbrookca02f312007-11-10 18:03:23 +000048 entry = elf_entry;
49 if (kernel_size < 0) {
aliguori5a9154e2008-11-20 22:14:40 +000050 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
pbrookca02f312007-11-10 18:03:23 +000051 }
52 if (kernel_size < 0) {
pbrookdcac9672009-04-09 20:05:49 +000053 kernel_size = load_image_targphys(kernel_filename,
54 KERNEL_LOAD_ADDR,
55 ram_size - KERNEL_LOAD_ADDR);
pbrookca02f312007-11-10 18:03:23 +000056 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 Liguorif80f9ec2009-05-20 18:38:09 -050069static QEMUMachine dummy_m68k_machine = {
aliguori4b32e162008-10-07 20:34:35 +000070 .name = "dummy",
71 .desc = "Dummy board",
72 .init = dummy_m68k_init,
pbrookca02f312007-11-10 18:03:23 +000073};
Anthony Liguorif80f9ec2009-05-20 18:38:09 -050074
75static void dummy_m68k_machine_init(void)
76{
77 qemu_register_machine(&dummy_m68k_machine);
78}
79
80machine_init(dummy_m68k_machine_init);