]>
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 | ||
87ecb68b | 9 | #include "hw.h" |
376253ec | 10 | #include "pc.h" |
87ecb68b | 11 | #include "mcf.h" |
87ecb68b | 12 | #include "boards.h" |
ca20cf32 BS |
13 | #include "loader.h" |
14 | #include "elf.h" | |
72e4d255 | 15 | #include "exec-memory.h" |
0633879f PB |
16 | |
17 | #define KERNEL_LOAD_ADDR 0x10000 | |
18 | #define AN5206_MBAR_ADDR 0x10000000 | |
19 | #define AN5206_RAMBAR_ADDR 0x20000000 | |
20 | ||
21 | /* Stub functions for hardware that doesn't exist. */ | |
376253ec | 22 | void pic_info(Monitor *mon) |
0633879f PB |
23 | { |
24 | } | |
25 | ||
376253ec | 26 | void irq_info(Monitor *mon) |
0633879f PB |
27 | { |
28 | } | |
29 | ||
0633879f PB |
30 | /* Board init. */ |
31 | ||
c227f099 | 32 | static void an5206_init(ram_addr_t ram_size, |
3023f332 | 33 | const char *boot_device, |
0633879f PB |
34 | const char *kernel_filename, const char *kernel_cmdline, |
35 | const char *initrd_filename, const char *cpu_model) | |
36 | { | |
37 | CPUState *env; | |
38 | int kernel_size; | |
39 | uint64_t elf_entry; | |
c227f099 | 40 | target_phys_addr_t entry; |
72e4d255 AK |
41 | MemoryRegion *address_space_mem = get_system_memory(); |
42 | MemoryRegion *ram = g_new(MemoryRegion, 1); | |
43 | MemoryRegion *sram = g_new(MemoryRegion, 1); | |
0633879f | 44 | |
0633879f PB |
45 | if (!cpu_model) |
46 | cpu_model = "m5206"; | |
aaed909a FB |
47 | env = cpu_init(cpu_model); |
48 | if (!env) { | |
2ac71179 | 49 | hw_error("Unable to find m68k CPU definition\n"); |
20dcee94 | 50 | } |
0633879f PB |
51 | |
52 | /* Initialize CPU registers. */ | |
53 | env->vbr = 0; | |
54 | /* TODO: allow changing MBAR and RAMBAR. */ | |
55 | env->mbar = AN5206_MBAR_ADDR | 1; | |
56 | env->rambar0 = AN5206_RAMBAR_ADDR | 1; | |
57 | ||
58 | /* DRAM at address zero */ | |
72e4d255 AK |
59 | memory_region_init_ram(ram, NULL, "an5206.ram", ram_size); |
60 | memory_region_add_subregion(address_space_mem, 0, ram); | |
0633879f PB |
61 | |
62 | /* Internal SRAM. */ | |
72e4d255 AK |
63 | memory_region_init_ram(sram, NULL, "an5206.sram", 512); |
64 | memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram); | |
0633879f PB |
65 | |
66 | mcf5206_init(AN5206_MBAR_ADDR, env); | |
67 | ||
68 | /* Load kernel. */ | |
69 | if (!kernel_filename) { | |
70 | fprintf(stderr, "Kernel image must be specified\n"); | |
71 | exit(1); | |
72 | } | |
73 | ||
409dbce5 AJ |
74 | kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, |
75 | NULL, NULL, 1, ELF_MACHINE, 0); | |
0633879f PB |
76 | entry = elf_entry; |
77 | if (kernel_size < 0) { | |
5a9154e0 | 78 | kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
0633879f PB |
79 | } |
80 | if (kernel_size < 0) { | |
dcac9679 PB |
81 | kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, |
82 | ram_size - KERNEL_LOAD_ADDR); | |
0633879f PB |
83 | entry = KERNEL_LOAD_ADDR; |
84 | } | |
85 | if (kernel_size < 0) { | |
86 | fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); | |
87 | exit(1); | |
88 | } | |
89 | ||
90 | env->pc = entry; | |
91 | } | |
92 | ||
f80f9ec9 | 93 | static QEMUMachine an5206_machine = { |
4b32e168 AL |
94 | .name = "an5206", |
95 | .desc = "Arnewsh 5206", | |
96 | .init = an5206_init, | |
0633879f | 97 | }; |
f80f9ec9 AL |
98 | |
99 | static void an5206_machine_init(void) | |
100 | { | |
101 | qemu_register_machine(&an5206_machine); | |
102 | } | |
103 | ||
104 | machine_init(an5206_machine_init); |