Remove unnecessary casts from PCI DMA code in lsi53c895a
[qemu/qmp-unstable.git] / hw / an5206.c
blob319a40e1d2ea7ad4dca8c489d49f9503c24ec383
1 /*
2 * Arnewsh 5206 ColdFire system emulation.
4 * Copyright (c) 2007 CodeSourcery.
6 * This code is licensed under the GPL
7 */
9 #include "hw.h"
10 #include "mcf.h"
11 #include "boards.h"
12 #include "loader.h"
13 #include "elf.h"
14 #include "exec-memory.h"
16 #define KERNEL_LOAD_ADDR 0x10000
17 #define AN5206_MBAR_ADDR 0x10000000
18 #define AN5206_RAMBAR_ADDR 0x20000000
20 /* Board init. */
22 static void an5206_init(ram_addr_t ram_size,
23 const char *boot_device,
24 const char *kernel_filename, const char *kernel_cmdline,
25 const char *initrd_filename, const char *cpu_model)
27 CPUState *env;
28 int kernel_size;
29 uint64_t elf_entry;
30 target_phys_addr_t entry;
31 MemoryRegion *address_space_mem = get_system_memory();
32 MemoryRegion *ram = g_new(MemoryRegion, 1);
33 MemoryRegion *sram = g_new(MemoryRegion, 1);
35 if (!cpu_model)
36 cpu_model = "m5206";
37 env = cpu_init(cpu_model);
38 if (!env) {
39 hw_error("Unable to find m68k CPU definition\n");
42 /* Initialize CPU registers. */
43 env->vbr = 0;
44 /* TODO: allow changing MBAR and RAMBAR. */
45 env->mbar = AN5206_MBAR_ADDR | 1;
46 env->rambar0 = AN5206_RAMBAR_ADDR | 1;
48 /* DRAM at address zero */
49 memory_region_init_ram(ram, NULL, "an5206.ram", ram_size);
50 memory_region_add_subregion(address_space_mem, 0, ram);
52 /* Internal SRAM. */
53 memory_region_init_ram(sram, NULL, "an5206.sram", 512);
54 memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram);
56 mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, env);
58 /* Load kernel. */
59 if (!kernel_filename) {
60 fprintf(stderr, "Kernel image must be specified\n");
61 exit(1);
64 kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
65 NULL, NULL, 1, ELF_MACHINE, 0);
66 entry = elf_entry;
67 if (kernel_size < 0) {
68 kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL);
70 if (kernel_size < 0) {
71 kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR,
72 ram_size - KERNEL_LOAD_ADDR);
73 entry = KERNEL_LOAD_ADDR;
75 if (kernel_size < 0) {
76 fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
77 exit(1);
80 env->pc = entry;
83 static QEMUMachine an5206_machine = {
84 .name = "an5206",
85 .desc = "Arnewsh 5206",
86 .init = an5206_init,
89 static void an5206_machine_init(void)
91 qemu_register_machine(&an5206_machine);
94 machine_init(an5206_machine_init);