acpi, acpi_piix, vt82c686: factor out PM1_CNT logic
[qemu.git] / hw / dummy_m68k.c
blob61efb39896a673e842c38dac786ce8545515dd95
1 /*
2 * Dummy board with just RAM and CPU for use as an ISS.
4 * Copyright (c) 2007 CodeSourcery.
6 * This code is licenced under the GPL
7 */
9 #include "hw.h"
10 #include "sysemu.h"
11 #include "boards.h"
12 #include "loader.h"
13 #include "elf.h"
15 #define KERNEL_LOAD_ADDR 0x10000
17 /* Board init. */
19 static void dummy_m68k_init(ram_addr_t ram_size,
20 const char *boot_device,
21 const char *kernel_filename, const char *kernel_cmdline,
22 const char *initrd_filename, const char *cpu_model)
24 CPUState *env;
25 int kernel_size;
26 uint64_t elf_entry;
27 target_phys_addr_t entry;
29 if (!cpu_model)
30 cpu_model = "cfv4e";
31 env = cpu_init(cpu_model);
32 if (!env) {
33 fprintf(stderr, "Unable to find m68k CPU definition\n");
34 exit(1);
37 /* Initialize CPU registers. */
38 env->vbr = 0;
40 /* RAM at address zero */
41 cpu_register_physical_memory(0, ram_size,
42 qemu_ram_alloc(NULL, "dummy_m68k.ram", ram_size) | IO_MEM_RAM);
44 /* Load kernel. */
45 if (kernel_filename) {
46 kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
47 NULL, NULL, 1, ELF_MACHINE, 0);
48 entry = elf_entry;
49 if (kernel_size < 0) {
50 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
52 if (kernel_size < 0) {
53 kernel_size = load_image_targphys(kernel_filename,
54 KERNEL_LOAD_ADDR,
55 ram_size - KERNEL_LOAD_ADDR);
56 entry = KERNEL_LOAD_ADDR;
58 if (kernel_size < 0) {
59 fprintf(stderr, "qemu: could not load kernel '%s'\n",
60 kernel_filename);
61 exit(1);
63 } else {
64 entry = 0;
66 env->pc = entry;
69 static QEMUMachine dummy_m68k_machine = {
70 .name = "dummy",
71 .desc = "Dummy board",
72 .init = dummy_m68k_init,
75 static void dummy_m68k_machine_init(void)
77 qemu_register_machine(&dummy_m68k_machine);
80 machine_init(dummy_m68k_machine_init);