]>
Commit | Line | Data |
---|---|---|
5fafdf24 | 1 | /* |
0633879f PB |
2 | * Arnewsh 5206 ColdFire system emulation. |
3 | * | |
4 | * Copyright (c) 2007 CodeSourcery. | |
5 | * | |
8e31bf38 | 6 | * This code is licensed under the GPL |
0633879f PB |
7 | */ |
8 | ||
83c9f4ca | 9 | #include "hw/hw.h" |
0d09e41a | 10 | #include "hw/m68k/mcf.h" |
83c9f4ca PB |
11 | #include "hw/boards.h" |
12 | #include "hw/loader.h" | |
ca20cf32 | 13 | #include "elf.h" |
022c62cb | 14 | #include "exec/address-spaces.h" |
0633879f PB |
15 | |
16 | #define KERNEL_LOAD_ADDR 0x10000 | |
17 | #define AN5206_MBAR_ADDR 0x10000000 | |
18 | #define AN5206_RAMBAR_ADDR 0x20000000 | |
19 | ||
0633879f PB |
20 | /* Board init. */ |
21 | ||
5f072e1f | 22 | static void an5206_init(QEMUMachineInitArgs *args) |
0633879f | 23 | { |
5f072e1f EH |
24 | ram_addr_t ram_size = args->ram_size; |
25 | const char *cpu_model = args->cpu_model; | |
26 | const char *kernel_filename = args->kernel_filename; | |
4025cfd5 | 27 | M68kCPU *cpu; |
7927df3a | 28 | CPUM68KState *env; |
0633879f PB |
29 | int kernel_size; |
30 | uint64_t elf_entry; | |
a8170e5e | 31 | hwaddr entry; |
72e4d255 AK |
32 | MemoryRegion *address_space_mem = get_system_memory(); |
33 | MemoryRegion *ram = g_new(MemoryRegion, 1); | |
34 | MemoryRegion *sram = g_new(MemoryRegion, 1); | |
0633879f | 35 | |
4025cfd5 | 36 | if (!cpu_model) { |
0633879f | 37 | cpu_model = "m5206"; |
4025cfd5 AF |
38 | } |
39 | cpu = cpu_m68k_init(cpu_model); | |
40 | if (!cpu) { | |
2ac71179 | 41 | hw_error("Unable to find m68k CPU definition\n"); |
20dcee94 | 42 | } |
4025cfd5 | 43 | env = &cpu->env; |
0633879f PB |
44 | |
45 | /* Initialize CPU registers. */ | |
46 | env->vbr = 0; | |
47 | /* TODO: allow changing MBAR and RAMBAR. */ | |
48 | env->mbar = AN5206_MBAR_ADDR | 1; | |
49 | env->rambar0 = AN5206_RAMBAR_ADDR | 1; | |
50 | ||
51 | /* DRAM at address zero */ | |
2c9b15ca | 52 | memory_region_init_ram(ram, NULL, "an5206.ram", ram_size); |
c5705a77 | 53 | vmstate_register_ram_global(ram); |
72e4d255 | 54 | memory_region_add_subregion(address_space_mem, 0, ram); |
0633879f PB |
55 | |
56 | /* Internal SRAM. */ | |
2c9b15ca | 57 | memory_region_init_ram(sram, NULL, "an5206.sram", 512); |
c5705a77 | 58 | vmstate_register_ram_global(sram); |
72e4d255 | 59 | memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram); |
0633879f | 60 | |
4025cfd5 | 61 | mcf5206_init(address_space_mem, AN5206_MBAR_ADDR, cpu); |
0633879f PB |
62 | |
63 | /* Load kernel. */ | |
64 | if (!kernel_filename) { | |
65 | fprintf(stderr, "Kernel image must be specified\n"); | |
66 | exit(1); | |
67 | } | |
68 | ||
409dbce5 AJ |
69 | kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, |
70 | NULL, NULL, 1, ELF_MACHINE, 0); | |
0633879f PB |
71 | entry = elf_entry; |
72 | if (kernel_size < 0) { | |
5a9154e0 | 73 | kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
0633879f PB |
74 | } |
75 | if (kernel_size < 0) { | |
dcac9679 PB |
76 | kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, |
77 | ram_size - KERNEL_LOAD_ADDR); | |
0633879f PB |
78 | entry = KERNEL_LOAD_ADDR; |
79 | } | |
80 | if (kernel_size < 0) { | |
81 | fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); | |
82 | exit(1); | |
83 | } | |
84 | ||
85 | env->pc = entry; | |
86 | } | |
87 | ||
f80f9ec9 | 88 | static QEMUMachine an5206_machine = { |
4b32e168 AL |
89 | .name = "an5206", |
90 | .desc = "Arnewsh 5206", | |
91 | .init = an5206_init, | |
e4ada29e | 92 | DEFAULT_MACHINE_OPTIONS, |
0633879f | 93 | }; |
f80f9ec9 AL |
94 | |
95 | static void an5206_machine_init(void) | |
96 | { | |
97 | qemu_register_machine(&an5206_machine); | |
98 | } | |
99 | ||
100 | machine_init(an5206_machine_init); |