Revision 77d4f95e hw/axis_dev88.c
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 = { |
Also available in: Unified diff