root / hw / an5206.c @ 795928f6
History | View | Annotate | Download (2.5 kB)
1 | 5fafdf24 | ths | /*
|
---|---|---|---|
2 | 0633879f | pbrook | * Arnewsh 5206 ColdFire system emulation.
|
3 | 0633879f | pbrook | *
|
4 | 0633879f | pbrook | * Copyright (c) 2007 CodeSourcery.
|
5 | 0633879f | pbrook | *
|
6 | 8e31bf38 | Matthew Fernandez | * This code is licensed under the GPL
|
7 | 0633879f | pbrook | */
|
8 | 0633879f | pbrook | |
9 | 87ecb68b | pbrook | #include "hw.h" |
10 | 87ecb68b | pbrook | #include "mcf.h" |
11 | 87ecb68b | pbrook | #include "boards.h" |
12 | ca20cf32 | Blue Swirl | #include "loader.h" |
13 | ca20cf32 | Blue Swirl | #include "elf.h" |
14 | 72e4d255 | Avi Kivity | #include "exec-memory.h" |
15 | 0633879f | pbrook | |
16 | 0633879f | pbrook | #define KERNEL_LOAD_ADDR 0x10000 |
17 | 0633879f | pbrook | #define AN5206_MBAR_ADDR 0x10000000 |
18 | 0633879f | pbrook | #define AN5206_RAMBAR_ADDR 0x20000000 |
19 | 0633879f | pbrook | |
20 | 0633879f | pbrook | /* Board init. */
|
21 | 0633879f | pbrook | |
22 | c227f099 | Anthony Liguori | static void an5206_init(ram_addr_t ram_size, |
23 | 3023f332 | aliguori | const char *boot_device, |
24 | 0633879f | pbrook | const char *kernel_filename, const char *kernel_cmdline, |
25 | 0633879f | pbrook | const char *initrd_filename, const char *cpu_model) |
26 | 0633879f | pbrook | { |
27 | 0633879f | pbrook | CPUState *env; |
28 | 0633879f | pbrook | int kernel_size;
|
29 | 0633879f | pbrook | uint64_t elf_entry; |
30 | c227f099 | Anthony Liguori | target_phys_addr_t entry; |
31 | 72e4d255 | Avi Kivity | MemoryRegion *address_space_mem = get_system_memory(); |
32 | 72e4d255 | Avi Kivity | MemoryRegion *ram = g_new(MemoryRegion, 1);
|
33 | 72e4d255 | Avi Kivity | MemoryRegion *sram = g_new(MemoryRegion, 1);
|
34 | 0633879f | pbrook | |
35 | 0633879f | pbrook | if (!cpu_model)
|
36 | 0633879f | pbrook | cpu_model = "m5206";
|
37 | aaed909a | bellard | env = cpu_init(cpu_model); |
38 | aaed909a | bellard | if (!env) {
|
39 | 2ac71179 | Paul Brook | hw_error("Unable to find m68k CPU definition\n");
|
40 | 20dcee94 | pbrook | } |
41 | 0633879f | pbrook | |
42 | 0633879f | pbrook | /* Initialize CPU registers. */
|
43 | 0633879f | pbrook | env->vbr = 0;
|
44 | 0633879f | pbrook | /* TODO: allow changing MBAR and RAMBAR. */
|
45 | 0633879f | pbrook | env->mbar = AN5206_MBAR_ADDR | 1;
|
46 | 0633879f | pbrook | env->rambar0 = AN5206_RAMBAR_ADDR | 1;
|
47 | 0633879f | pbrook | |
48 | 0633879f | pbrook | /* DRAM at address zero */
|
49 | 72e4d255 | Avi Kivity | memory_region_init_ram(ram, NULL, "an5206.ram", ram_size); |
50 | 72e4d255 | Avi Kivity | memory_region_add_subregion(address_space_mem, 0, ram);
|
51 | 0633879f | pbrook | |
52 | 0633879f | pbrook | /* Internal SRAM. */
|
53 | 72e4d255 | Avi Kivity | memory_region_init_ram(sram, NULL, "an5206.sram", 512); |
54 | 72e4d255 | Avi Kivity | memory_region_add_subregion(address_space_mem, AN5206_RAMBAR_ADDR, sram); |
55 | 0633879f | pbrook | |
56 | 0633879f | pbrook | mcf5206_init(AN5206_MBAR_ADDR, env); |
57 | 0633879f | pbrook | |
58 | 0633879f | pbrook | /* Load kernel. */
|
59 | 0633879f | pbrook | if (!kernel_filename) {
|
60 | 0633879f | pbrook | fprintf(stderr, "Kernel image must be specified\n");
|
61 | 0633879f | pbrook | exit(1);
|
62 | 0633879f | pbrook | } |
63 | 0633879f | pbrook | |
64 | 409dbce5 | Aurelien Jarno | kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry, |
65 | 409dbce5 | Aurelien Jarno | NULL, NULL, 1, ELF_MACHINE, 0); |
66 | 0633879f | pbrook | entry = elf_entry; |
67 | 0633879f | pbrook | if (kernel_size < 0) { |
68 | 5a9154e0 | aliguori | kernel_size = load_uimage(kernel_filename, &entry, NULL, NULL); |
69 | 0633879f | pbrook | } |
70 | 0633879f | pbrook | if (kernel_size < 0) { |
71 | dcac9679 | pbrook | kernel_size = load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, |
72 | dcac9679 | pbrook | ram_size - KERNEL_LOAD_ADDR); |
73 | 0633879f | pbrook | entry = KERNEL_LOAD_ADDR; |
74 | 0633879f | pbrook | } |
75 | 0633879f | pbrook | if (kernel_size < 0) { |
76 | 0633879f | pbrook | fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
|
77 | 0633879f | pbrook | exit(1);
|
78 | 0633879f | pbrook | } |
79 | 0633879f | pbrook | |
80 | 0633879f | pbrook | env->pc = entry; |
81 | 0633879f | pbrook | } |
82 | 0633879f | pbrook | |
83 | f80f9ec9 | Anthony Liguori | static QEMUMachine an5206_machine = {
|
84 | 4b32e168 | aliguori | .name = "an5206",
|
85 | 4b32e168 | aliguori | .desc = "Arnewsh 5206",
|
86 | 4b32e168 | aliguori | .init = an5206_init, |
87 | 0633879f | pbrook | }; |
88 | f80f9ec9 | Anthony Liguori | |
89 | f80f9ec9 | Anthony Liguori | static void an5206_machine_init(void) |
90 | f80f9ec9 | Anthony Liguori | { |
91 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&an5206_machine); |
92 | f80f9ec9 | Anthony Liguori | } |
93 | f80f9ec9 | Anthony Liguori | |
94 | f80f9ec9 | Anthony Liguori | machine_init(an5206_machine_init); |