2 * Arnewsh 5206 ColdFire system emulation.
4 * Copyright (c) 2007 CodeSourcery.
6 * This code is licensed under the GPL
10 #include "hw/m68k/mcf.h"
11 #include "hw/boards.h"
12 #include "hw/loader.h"
14 #include "exec/address-spaces.h"
15 #include "sysemu/qtest.h"
17 #define KERNEL_LOAD_ADDR 0x10000
18 #define AN5206_MBAR_ADDR 0x10000000
19 #define AN5206_RAMBAR_ADDR 0x20000000
23 static void an5206_init(MachineState
*machine
)
25 ram_addr_t ram_size
= machine
->ram_size
;
26 const char *cpu_model
= machine
->cpu_model
;
27 const char *kernel_filename
= machine
->kernel_filename
;
33 MemoryRegion
*address_space_mem
= get_system_memory();
34 MemoryRegion
*ram
= g_new(MemoryRegion
, 1);
35 MemoryRegion
*sram
= g_new(MemoryRegion
, 1);
40 cpu
= cpu_m68k_init(cpu_model
);
42 hw_error("Unable to find m68k CPU definition\n");
46 /* Initialize CPU registers. */
48 /* TODO: allow changing MBAR and RAMBAR. */
49 env
->mbar
= AN5206_MBAR_ADDR
| 1;
50 env
->rambar0
= AN5206_RAMBAR_ADDR
| 1;
52 /* DRAM at address zero */
53 memory_region_allocate_system_memory(ram
, NULL
, "an5206.ram", ram_size
);
54 memory_region_add_subregion(address_space_mem
, 0, ram
);
57 memory_region_init_ram(sram
, NULL
, "an5206.sram", 512, &error_fatal
);
58 vmstate_register_ram_global(sram
);
59 memory_region_add_subregion(address_space_mem
, AN5206_RAMBAR_ADDR
, sram
);
61 mcf5206_init(address_space_mem
, AN5206_MBAR_ADDR
, cpu
);
64 if (!kernel_filename
) {
65 if (qtest_enabled()) {
68 fprintf(stderr
, "Kernel image must be specified\n");
72 kernel_size
= load_elf(kernel_filename
, NULL
, NULL
, &elf_entry
,
73 NULL
, NULL
, 1, EM_68K
, 0);
75 if (kernel_size
< 0) {
76 kernel_size
= load_uimage(kernel_filename
, &entry
, NULL
, NULL
,
79 if (kernel_size
< 0) {
80 kernel_size
= load_image_targphys(kernel_filename
, KERNEL_LOAD_ADDR
,
81 ram_size
- KERNEL_LOAD_ADDR
);
82 entry
= KERNEL_LOAD_ADDR
;
84 if (kernel_size
< 0) {
85 fprintf(stderr
, "qemu: could not load kernel '%s'\n", kernel_filename
);
92 static void an5206_machine_init(MachineClass
*mc
)
94 mc
->desc
= "Arnewsh 5206";
95 mc
->init
= an5206_init
;
98 DEFINE_MACHINE("an5206", an5206_machine_init
)