Revision 16406950 hw/integratorcp.c
b/hw/integratorcp.c | ||
---|---|---|
10 | 10 |
#include "vl.h" |
11 | 11 |
#include "arm_pic.h" |
12 | 12 |
|
13 |
#define KERNEL_ARGS_ADDR 0x100 |
|
14 |
#define KERNEL_LOAD_ADDR 0x00010000 |
|
15 |
#define INITRD_LOAD_ADDR 0x00800000 |
|
16 |
|
|
17 | 13 |
void DMA_run (void) |
18 | 14 |
{ |
19 | 15 |
} |
... | ... | |
470 | 466 |
} |
471 | 467 |
|
472 | 468 |
|
473 |
/* The worlds second smallest bootloader. Set r0-r2, then jump to kernel. */ |
|
474 |
static uint32_t bootloader[] = { |
|
475 |
0xe3a00000, /* mov r0, #0 */ |
|
476 |
0xe3a01013, /* mov r1, #0x13 */ |
|
477 |
0xe3811c01, /* orr r1, r1, #0x100 */ |
|
478 |
0xe59f2000, /* ldr r2, [pc, #0] */ |
|
479 |
0xe59ff000, /* ldr pc, [pc, #0] */ |
|
480 |
0, /* Address of kernel args. Set by integratorcp_init. */ |
|
481 |
0 /* Kernel entry point. Set by integratorcp_init. */ |
|
482 |
}; |
|
483 |
|
|
484 |
static void set_kernel_args(uint32_t ram_size, int initrd_size, |
|
485 |
const char *kernel_cmdline) |
|
486 |
{ |
|
487 |
uint32_t *p; |
|
488 |
|
|
489 |
p = (uint32_t *)(phys_ram_base + KERNEL_ARGS_ADDR); |
|
490 |
/* ATAG_CORE */ |
|
491 |
stl_raw(p++, 5); |
|
492 |
stl_raw(p++, 0x54410001); |
|
493 |
stl_raw(p++, 1); |
|
494 |
stl_raw(p++, 0x1000); |
|
495 |
stl_raw(p++, 0); |
|
496 |
/* ATAG_MEM */ |
|
497 |
stl_raw(p++, 4); |
|
498 |
stl_raw(p++, 0x54410002); |
|
499 |
stl_raw(p++, ram_size); |
|
500 |
stl_raw(p++, 0); |
|
501 |
if (initrd_size) { |
|
502 |
/* ATAG_INITRD2 */ |
|
503 |
stl_raw(p++, 4); |
|
504 |
stl_raw(p++, 0x54420005); |
|
505 |
stl_raw(p++, INITRD_LOAD_ADDR); |
|
506 |
stl_raw(p++, initrd_size); |
|
507 |
} |
|
508 |
if (kernel_cmdline && *kernel_cmdline) { |
|
509 |
/* ATAG_CMDLINE */ |
|
510 |
int cmdline_size; |
|
511 |
|
|
512 |
cmdline_size = strlen(kernel_cmdline); |
|
513 |
memcpy (p + 2, kernel_cmdline, cmdline_size + 1); |
|
514 |
cmdline_size = (cmdline_size >> 2) + 1; |
|
515 |
stl_raw(p++, cmdline_size + 2); |
|
516 |
stl_raw(p++, 0x54410009); |
|
517 |
p += cmdline_size; |
|
518 |
} |
|
519 |
/* ATAG_END */ |
|
520 |
stl_raw(p++, 0); |
|
521 |
stl_raw(p++, 0); |
|
522 |
} |
|
523 |
|
|
524 | 469 |
/* Board init. */ |
525 | 470 |
|
526 | 471 |
static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, |
... | ... | |
532 | 477 |
uint32_t bios_offset; |
533 | 478 |
icp_pic_state *pic; |
534 | 479 |
void *cpu_pic; |
535 |
int kernel_size; |
|
536 |
int initrd_size; |
|
537 |
int n; |
|
538 | 480 |
|
539 | 481 |
env = cpu_init(); |
540 | 482 |
cpu_arm_set_model(env, cpuid); |
... | ... | |
567 | 509 |
} |
568 | 510 |
pl110_init(ds, 0xc0000000, pic, 22, 0); |
569 | 511 |
|
570 |
/* Load the kernel. */ |
|
571 |
if (!kernel_filename) { |
|
572 |
fprintf(stderr, "Kernel image must be specified\n"); |
|
573 |
exit(1); |
|
574 |
} |
|
575 |
kernel_size = load_image(kernel_filename, |
|
576 |
phys_ram_base + KERNEL_LOAD_ADDR); |
|
577 |
if (kernel_size < 0) { |
|
578 |
fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); |
|
579 |
exit(1); |
|
580 |
} |
|
581 |
if (initrd_filename) { |
|
582 |
initrd_size = load_image(initrd_filename, |
|
583 |
phys_ram_base + INITRD_LOAD_ADDR); |
|
584 |
if (initrd_size < 0) { |
|
585 |
fprintf(stderr, "qemu: could not load initrd '%s'\n", |
|
586 |
initrd_filename); |
|
587 |
exit(1); |
|
588 |
} |
|
589 |
} else { |
|
590 |
initrd_size = 0; |
|
591 |
} |
|
592 |
bootloader[5] = KERNEL_ARGS_ADDR; |
|
593 |
bootloader[6] = KERNEL_LOAD_ADDR; |
|
594 |
for (n = 0; n < sizeof(bootloader) / 4; n++) |
|
595 |
stl_raw(phys_ram_base + (n * 4), bootloader[n]); |
|
596 |
set_kernel_args(ram_size, initrd_size, kernel_cmdline); |
|
512 |
arm_load_kernel(ram_size, kernel_filename, kernel_cmdline, |
|
513 |
initrd_filename, 0x113); |
|
597 | 514 |
} |
598 | 515 |
|
599 | 516 |
static void integratorcp926_init(int ram_size, int vga_ram_size, |
Also available in: Unified diff