Revision 77d4f95e
b/Makefile.target | ||
---|---|---|
233 | 233 |
obj-microblaze-$(CONFIG_FDT) += device_tree.o |
234 | 234 |
|
235 | 235 |
# Boards |
236 |
obj-cris-y = cris_pic_cpu.o etraxfs.o axis_dev88.o |
|
236 |
obj-cris-y = cris_pic_cpu.o |
|
237 |
obj-cris-y += cris-boot.o |
|
238 |
obj-cris-y += etraxfs.o axis_dev88.o |
|
239 |
obj-cris-y += axis_dev88.o |
|
237 | 240 |
|
238 | 241 |
# IO blocks |
239 | 242 |
obj-cris-y += etraxfs_dma.o |
b/hw/axis_dev88.c | ||
---|---|---|
30 | 30 |
#include "etraxfs.h" |
31 | 31 |
#include "loader.h" |
32 | 32 |
#include "elf.h" |
33 |
#include "cris-boot.h" |
|
33 | 34 |
|
34 | 35 |
#define D(x) |
35 | 36 |
#define DNAND(x) |
... | ... | |
240 | 241 |
|
241 | 242 |
#define INTMEM_SIZE (128 * 1024) |
242 | 243 |
|
243 |
static struct { |
|
244 |
uint32_t bootstrap_pc; |
|
245 |
uint32_t regs[16]; |
|
246 |
} loadargs; |
|
247 |
|
|
248 |
static void main_cpu_reset(void *opaque) |
|
249 |
{ |
|
250 |
int i; |
|
251 |
|
|
252 |
CPUState *env = opaque; |
|
253 |
cpu_reset(env); |
|
254 |
|
|
255 |
env->pc = loadargs.bootstrap_pc; |
|
256 |
for (i = 0; i < 16; i++) { |
|
257 |
env->regs[i] = loadargs.regs[i]; |
|
258 |
} |
|
259 |
} |
|
260 |
|
|
261 |
static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
|
262 |
{ |
|
263 |
return addr - 0x80000000LL; |
|
264 |
} |
|
244 |
static struct cris_load_info li; |
|
265 | 245 |
|
266 | 246 |
static |
267 | 247 |
void axisdev88_init (ram_addr_t ram_size, |
... | ... | |
275 | 255 |
qemu_irq irq[30], nmi[2], *cpu_irq; |
276 | 256 |
void *etraxfs_dmac; |
277 | 257 |
struct etraxfs_dma_client *eth[2] = {NULL, NULL}; |
278 |
int kernel_size; |
|
279 | 258 |
int i; |
280 | 259 |
int nand_regs; |
281 | 260 |
int gpio_regs; |
... | ... | |
287 | 266 |
cpu_model = "crisv32"; |
288 | 267 |
} |
289 | 268 |
env = cpu_init(cpu_model); |
290 |
qemu_register_reset(main_cpu_reset, env); |
|
291 | 269 |
|
292 | 270 |
/* allocate RAM */ |
293 | 271 |
phys_ram = qemu_ram_alloc(ram_size); |
... | ... | |
353 | 331 |
irq[0x14 + i]); |
354 | 332 |
} |
355 | 333 |
|
356 |
if (kernel_filename) { |
|
357 |
uint64_t entry, high; |
|
358 |
int kcmdline_len; |
|
359 |
|
|
360 |
/* Boots a kernel elf binary, os/linux-2.6/vmlinux from the axis |
|
361 |
devboard SDK. */ |
|
362 |
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, |
|
363 |
&entry, NULL, &high, 0, ELF_MACHINE, 0); |
|
364 |
loadargs.bootstrap_pc = entry; |
|
365 |
if (kernel_size < 0) { |
|
366 |
/* Takes a kimage from the axis devboard SDK. */ |
|
367 |
kernel_size = load_image_targphys(kernel_filename, 0x40004000, |
|
368 |
ram_size); |
|
369 |
loadargs.bootstrap_pc = 0x40004000; |
|
370 |
loadargs.regs[9] = 0x40004000 + kernel_size; |
|
371 |
} |
|
372 |
loadargs.regs[8] = 0x56902387; /* RAM init magic. */ |
|
373 |
|
|
374 |
if (kernel_cmdline && (kcmdline_len = strlen(kernel_cmdline))) { |
|
375 |
if (kcmdline_len > 256) { |
|
376 |
fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n"); |
|
377 |
exit(1); |
|
378 |
} |
|
379 |
/* Let the kernel know we are modifying the cmdline. */ |
|
380 |
loadargs.regs[10] = 0x87109563; |
|
381 |
loadargs.regs[11] = 0x40000000; |
|
382 |
pstrcpy_targphys("cmdline", loadargs.regs[11], 256, kernel_cmdline); |
|
383 |
} |
|
334 |
if (!kernel_filename) { |
|
335 |
fprintf(stderr, "Kernel image must be specified\n"); |
|
336 |
exit(1); |
|
384 | 337 |
} |
338 |
|
|
339 |
li.image_filename = kernel_filename; |
|
340 |
li.cmdline = kernel_cmdline; |
|
341 |
cris_load_image(env, &li); |
|
385 | 342 |
} |
386 | 343 |
|
387 | 344 |
static QEMUMachine axisdev88_machine = { |
b/hw/cris-boot.c | ||
---|---|---|
1 |
/* |
|
2 |
* CRIS image loading. |
|
3 |
* |
|
4 |
* Copyright (c) 2010 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 |
|
|
25 |
#include "hw.h" |
|
26 |
#include "sysemu.h" |
|
27 |
#include "loader.h" |
|
28 |
#include "elf.h" |
|
29 |
#include "cris-boot.h" |
|
30 |
|
|
31 |
static void main_cpu_reset(void *opaque) |
|
32 |
{ |
|
33 |
CPUState *env = opaque; |
|
34 |
struct cris_load_info *li; |
|
35 |
|
|
36 |
li = env->load_info; |
|
37 |
|
|
38 |
cpu_reset(env); |
|
39 |
|
|
40 |
if (!li) { |
|
41 |
/* nothing more to do. */ |
|
42 |
return; |
|
43 |
} |
|
44 |
|
|
45 |
env->pc = li->entry; |
|
46 |
|
|
47 |
if (li->image_filename) { |
|
48 |
env->regs[8] = 0x56902387; /* RAM boot magic. */ |
|
49 |
env->regs[9] = 0x40004000 + li->image_size; |
|
50 |
} |
|
51 |
|
|
52 |
if (li->cmdline) { |
|
53 |
/* Let the kernel know we are modifying the cmdline. */ |
|
54 |
env->regs[10] = 0x87109563; |
|
55 |
env->regs[11] = 0x40000000; |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
|
60 |
{ |
|
61 |
return addr - 0x80000000LL; |
|
62 |
} |
|
63 |
|
|
64 |
void cris_load_image(CPUState *env, struct cris_load_info *li) |
|
65 |
{ |
|
66 |
uint64_t entry, high; |
|
67 |
int kcmdline_len; |
|
68 |
int image_size; |
|
69 |
|
|
70 |
env->load_info = li; |
|
71 |
/* Boots a kernel elf binary, os/linux-2.6/vmlinux from the axis |
|
72 |
devboard SDK. */ |
|
73 |
image_size = load_elf(li->image_filename, translate_kernel_address, NULL, |
|
74 |
&entry, NULL, &high, 0, ELF_MACHINE, 0); |
|
75 |
li->entry = entry; |
|
76 |
if (image_size < 0) { |
|
77 |
/* Takes a kimage from the axis devboard SDK. */ |
|
78 |
image_size = load_image_targphys(li->image_filename, 0x40004000, |
|
79 |
ram_size); |
|
80 |
li->entry = 0x40004000; |
|
81 |
} |
|
82 |
|
|
83 |
if (image_size < 0) { |
|
84 |
fprintf(stderr, "qemu: could not load kernel '%s'\n", |
|
85 |
li->image_filename); |
|
86 |
exit(1); |
|
87 |
} |
|
88 |
|
|
89 |
if (li->cmdline && (kcmdline_len = strlen(li->cmdline))) { |
|
90 |
if (kcmdline_len > 256) { |
|
91 |
fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n"); |
|
92 |
exit(1); |
|
93 |
} |
|
94 |
pstrcpy_targphys("cmdline", 0x40000000, 256, li->cmdline); |
|
95 |
} |
|
96 |
qemu_register_reset(main_cpu_reset, env); |
|
97 |
} |
b/hw/cris-boot.h | ||
---|---|---|
1 |
|
|
2 |
struct cris_load_info |
|
3 |
{ |
|
4 |
const char *image_filename; |
|
5 |
const char *cmdline; |
|
6 |
int image_size; |
|
7 |
|
|
8 |
target_phys_addr_t entry; |
|
9 |
}; |
|
10 |
|
|
11 |
void cris_load_image(CPUState *env, struct cris_load_info *li); |
b/hw/etraxfs.c | ||
---|---|---|
30 | 30 |
#include "etraxfs.h" |
31 | 31 |
#include "loader.h" |
32 | 32 |
#include "elf.h" |
33 |
#include "cris-boot.h" |
|
33 | 34 |
|
34 | 35 |
#define FLASH_SIZE 0x2000000 |
35 | 36 |
#define INTMEM_SIZE (128 * 1024) |
36 | 37 |
|
37 |
static uint32_t bootstrap_pc;
|
|
38 |
static struct cris_load_info li;
|
|
38 | 39 |
|
39 |
static void main_cpu_reset(void *opaque)
|
|
40 |
static void flash_cpu_reset(void *opaque)
|
|
40 | 41 |
{ |
41 | 42 |
CPUState *env = opaque; |
42 | 43 |
cpu_reset(env); |
43 |
|
|
44 |
env->pc = bootstrap_pc; |
|
45 |
} |
|
46 |
|
|
47 |
static uint64_t translate_kernel_address(void *opaque, uint64_t addr) |
|
48 |
{ |
|
49 |
return addr - 0x80000000LL; |
|
50 | 44 |
} |
51 | 45 |
|
52 | 46 |
static |
... | ... | |
61 | 55 |
qemu_irq irq[30], nmi[2], *cpu_irq; |
62 | 56 |
void *etraxfs_dmac; |
63 | 57 |
struct etraxfs_dma_client *eth[2] = {NULL, NULL}; |
64 |
int kernel_size; |
|
65 | 58 |
DriveInfo *dinfo; |
66 | 59 |
int i; |
67 | 60 |
ram_addr_t phys_ram; |
... | ... | |
73 | 66 |
cpu_model = "crisv32"; |
74 | 67 |
} |
75 | 68 |
env = cpu_init(cpu_model); |
76 |
qemu_register_reset(main_cpu_reset, env); |
|
77 | 69 |
|
78 | 70 |
/* allocate RAM */ |
79 | 71 |
phys_ram = qemu_ram_alloc(ram_size); |
... | ... | |
137 | 129 |
} |
138 | 130 |
|
139 | 131 |
if (kernel_filename) { |
140 |
uint64_t entry, high; |
|
141 |
int kcmdline_len; |
|
142 |
|
|
143 |
/* Boots a kernel elf binary, os/linux-2.6/vmlinux from the axis |
|
144 |
devboard SDK. */ |
|
145 |
kernel_size = load_elf(kernel_filename, translate_kernel_address, NULL, |
|
146 |
&entry, NULL, &high, 0, ELF_MACHINE, 0); |
|
147 |
bootstrap_pc = entry; |
|
148 |
if (kernel_size < 0) { |
|
149 |
/* Takes a kimage from the axis devboard SDK. */ |
|
150 |
kernel_size = load_image_targphys(kernel_filename, 0x40004000, |
|
151 |
ram_size); |
|
152 |
bootstrap_pc = 0x40004000; |
|
153 |
env->regs[9] = 0x40004000 + kernel_size; |
|
132 |
li.image_filename = kernel_filename; |
|
133 |
li.cmdline = kernel_cmdline; |
|
134 |
cris_load_image(env, &li); |
|
135 |
} else { |
|
136 |
if (!dinfo) { |
|
137 |
fprintf(stderr, |
|
138 |
"Provide a kernel image or a flash image to boot from.\n"); |
|
139 |
exit(1); |
|
154 | 140 |
} |
155 |
env->regs[8] = 0x56902387; /* RAM init magic. */ |
|
156 |
|
|
157 |
if (kernel_cmdline && (kcmdline_len = strlen(kernel_cmdline))) { |
|
158 |
if (kcmdline_len > 256) { |
|
159 |
fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n"); |
|
160 |
exit(1); |
|
161 |
} |
|
162 |
/* Let the kernel know we are modifying the cmdline. */ |
|
163 |
env->regs[10] = 0x87109563; |
|
164 |
env->regs[11] = 0x40000000; |
|
165 |
pstrcpy_targphys("cmdline", env->regs[11], 256, kernel_cmdline); |
|
166 |
} |
|
167 |
} |
|
168 |
env->pc = bootstrap_pc; |
|
169 | 141 |
|
170 |
printf ("pc =%x\n", env->pc); |
|
171 |
printf ("ram size =%ld\n", ram_size); |
|
142 |
/* Nothing more to do for flash images, those boot from addr 0. */ |
|
143 |
qemu_register_reset(flash_cpu_reset, env); |
|
144 |
} |
|
172 | 145 |
} |
173 | 146 |
|
174 | 147 |
static QEMUMachine bareetraxfs_machine = { |
b/target-cris/cpu.h | ||
---|---|---|
155 | 155 |
uint32_t lo; |
156 | 156 |
} tlbsets[2][4][16]; |
157 | 157 |
|
158 |
void *load_info; |
|
159 |
|
|
158 | 160 |
CPU_COMMON |
159 | 161 |
} CPUCRISState; |
160 | 162 |
|
Also available in: Unified diff