]>
Commit | Line | Data |
---|---|---|
5fafdf24 | 1 | /* |
0633879f PB |
2 | * Arnewsh 5206 ColdFire system emulation. |
3 | * | |
4 | * Copyright (c) 2007 CodeSourcery. | |
5 | * | |
6 | * This code is licenced under the GPL | |
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" | |
0633879f PB |
15 | |
16 | #define KERNEL_LOAD_ADDR 0x10000 | |
17 | #define AN5206_MBAR_ADDR 0x10000000 | |
18 | #define AN5206_RAMBAR_ADDR 0x20000000 | |
19 | ||
20 | /* Stub functions for hardware that doesn't exist. */ | |
376253ec | 21 | void pic_info(Monitor *mon) |
0633879f PB |
22 | { |
23 | } | |
24 | ||
376253ec | 25 | void irq_info(Monitor *mon) |
0633879f PB |
26 | { |
27 | } | |
28 | ||
0633879f PB |
29 | /* Board init. */ |
30 | ||
c227f099 | 31 | static void an5206_init(ram_addr_t ram_size, |
3023f332 | 32 | const char *boot_device, |
0633879f PB |
33 | const char *kernel_filename, const char *kernel_cmdline, |
34 | const char *initrd_filename, const char *cpu_model) | |
35 | { | |
36 | CPUState *env; | |
37 | int kernel_size; | |
38 | uint64_t elf_entry; | |
c227f099 | 39 | target_phys_addr_t entry; |
0633879f | 40 | |
0633879f PB |
41 | if (!cpu_model) |
42 | cpu_model = "m5206"; | |
aaed909a FB |
43 | env = cpu_init(cpu_model); |
44 | if (!env) { | |
2ac71179 | 45 | hw_error("Unable to find m68k CPU definition\n"); |
20dcee94 | 46 | } |
0633879f PB |
47 | |
48 | /* Initialize CPU registers. */ | |
49 | env->vbr = 0; | |
50 | /* TODO: allow changing MBAR and RAMBAR. */ | |
51 | env->mbar = AN5206_MBAR_ADDR | 1; | |
52 | env->rambar0 = AN5206_RAMBAR_ADDR | 1; | |
53 | ||
54 | /* DRAM at address zero */ | |
55 | cpu_register_physical_memory(0, ram_size, | |
1724f049 | 56 | qemu_ram_alloc(NULL, "an5206.ram", ram_size) | IO_MEM_RAM); |
0633879f PB |
57 | |
58 | /* Internal SRAM. */ | |
59 | cpu_register_physical_memory(AN5206_RAMBAR_ADDR, 512, | |
1724f049 | 60 | qemu_ram_alloc(NULL, "an5206.sram", 512) | IO_MEM_RAM); |
0633879f PB |
61 | |
62 | mcf5206_init(AN5206_MBAR_ADDR, env); | |
63 | ||
64 | /* Load kernel. */ | |
65 | if (!kernel_filename) { | |
66 | fprintf(stderr, "Kernel image must be specified\n"); | |
67 | exit(1); | |
68 | } | |
69 | ||
409dbce5 AJ |
70 | kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, |
71 | NULL, NULL, 1, ELF_MACHINE, 0); | |
0633879f PB |
72 | entry = elf_entry; |
73 | if (kernel_size < 0) { | |
5a9154e0 | 74 | kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
0633879f PB |
75 | } |
76 | if (kernel_size < 0) { | |
dcac9679 PB |
77 | kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, |
78 | ram_size - KERNEL_LOAD_ADDR); | |
0633879f PB |
79 | entry = KERNEL_LOAD_ADDR; |
80 | } | |
81 | if (kernel_size < 0) { | |
82 | fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); | |
83 | exit(1); | |
84 | } | |
85 | ||
86 | env->pc = entry; | |
87 | } | |
88 | ||
f80f9ec9 | 89 | static QEMUMachine an5206_machine = { |
4b32e168 AL |
90 | .name = "an5206", |
91 | .desc = "Arnewsh 5206", | |
92 | .init = an5206_init, | |
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); |