]>
Commit | Line | Data |
---|---|---|
83fa1010 TS |
1 | /* |
2 | * QEMU ETRAX System Emulator | |
3 | * | |
4 | * Copyright (c) 2007 Edgar E. Iglesias, Axis Communications AB. | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | #include <time.h> | |
25 | #include <sys/time.h> | |
87ecb68b PB |
26 | #include "hw.h" |
27 | #include "sysemu.h" | |
e62b5b13 | 28 | #include "flash.h" |
87ecb68b | 29 | #include "boards.h" |
83fa1010 | 30 | |
83fa1010 TS |
31 | static void main_cpu_reset(void *opaque) |
32 | { | |
33 | CPUState *env = opaque; | |
34 | cpu_reset(env); | |
35 | } | |
36 | ||
83fa1010 | 37 | /* Init functions for different blocks. */ |
e62b5b13 EI |
38 | extern qemu_irq *etraxfs_pic_init(CPUState *env, target_ulong base); |
39 | /* TODO: Make these blocks relocate:able. */ | |
83fa1010 TS |
40 | extern void etraxfs_timer_init(CPUState *env, qemu_irq *irqs); |
41 | extern void etraxfs_ser_init(CPUState *env, qemu_irq *irqs); | |
42 | ||
83fa1010 | 43 | static |
b881c2c6 BS |
44 | void bareetraxfs_init (int ram_size, int vga_ram_size, |
45 | const char *boot_device, DisplayState *ds, | |
83fa1010 TS |
46 | const char *kernel_filename, const char *kernel_cmdline, |
47 | const char *initrd_filename, const char *cpu_model) | |
48 | { | |
49 | CPUState *env; | |
e62b5b13 | 50 | qemu_irq *pic; |
83fa1010 | 51 | int kernel_size; |
e62b5b13 EI |
52 | int flash_size = 0x800000; |
53 | int index; | |
54 | ram_addr_t phys_flash; | |
55 | ram_addr_t phys_ram; | |
83fa1010 TS |
56 | |
57 | /* init CPUs */ | |
58 | if (cpu_model == NULL) { | |
59 | cpu_model = "crisv32"; | |
60 | } | |
aaed909a | 61 | env = cpu_init(cpu_model); |
83fa1010 TS |
62 | /* register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */ |
63 | qemu_register_reset(main_cpu_reset, env); | |
83fa1010 | 64 | |
83fa1010 | 65 | /* allocate RAM */ |
e62b5b13 EI |
66 | phys_ram = qemu_ram_alloc(ram_size); |
67 | cpu_register_physical_memory(0x40000000, ram_size, phys_ram | IO_MEM_RAM); | |
68 | /* Unached mapping. */ | |
69 | cpu_register_physical_memory(0xc0000000, ram_size, phys_ram | IO_MEM_RAM); | |
70 | ||
71 | phys_flash = qemu_ram_alloc(flash_size); | |
72 | cpu_register_physical_memory(0,flash_size, IO_MEM_ROM); | |
73 | cpu_register_physical_memory(0x80000000, flash_size, IO_MEM_ROM); | |
74 | cpu_register_physical_memory(0x04000000, flash_size, IO_MEM_ROM); | |
75 | cpu_register_physical_memory(0x84000000, flash_size, | |
76 | 0x04000000 | IO_MEM_ROM); | |
77 | index = drive_get_index(IF_PFLASH, 0, 0); | |
78 | pflash_cfi01_register(0x80000000, flash_size, | |
79 | drives_table[index].bdrv, 65536, flash_size >> 16, | |
80 | 4, 0x0000, 0x0000, 0x0000, 0x0000); | |
81 | index = drive_get_index(IF_PFLASH, 0, 1); | |
82 | pflash_cfi01_register(0x84000000, flash_size, | |
83 | drives_table[index].bdrv, 65536, flash_size >> 16, | |
84 | 4, 0x0000, 0x0000, 0x0000, 0x0000); | |
85 | ||
86 | pic = etraxfs_pic_init(env, 0xb001c000); | |
87 | etraxfs_timer_init(env, pic); | |
88 | etraxfs_ser_init(env, pic); | |
83fa1010 TS |
89 | |
90 | kernel_size = load_image(kernel_filename, phys_ram_base + 0x4000); | |
91 | /* magic for boot. */ | |
92 | env->regs[8] = 0x56902387; | |
93 | env->regs[9] = 0x40004000 + kernel_size; | |
94 | env->pc = 0x40004000; | |
95 | ||
96 | { | |
97 | unsigned char *ptr = phys_ram_base + 0x4000; | |
98 | int i; | |
99 | for (i = 0; i < 8; i++) | |
100 | { | |
101 | printf ("%2.2x ", ptr[i]); | |
102 | } | |
103 | printf("\n"); | |
104 | } | |
105 | ||
106 | printf ("pc =%x\n", env->pc); | |
107 | printf ("ram size =%d\n", ram_size); | |
108 | printf ("kernel name =%s\n", kernel_filename); | |
109 | printf ("kernel size =%d\n", kernel_size); | |
110 | printf ("cpu haltd =%d\n", env->halted); | |
111 | } | |
112 | ||
113 | void DMA_run(void) | |
114 | { | |
115 | } | |
116 | ||
83fa1010 TS |
117 | QEMUMachine bareetraxfs_machine = { |
118 | "bareetraxfs", | |
119 | "Bare ETRAX FS board", | |
120 | bareetraxfs_init, | |
121 | }; |