#include "config.h" #include "cpu.h" #include "crt0-common.S" /* implement vectors, specify section and reset address */ RBIMPL_VECTORS .vectors, start /* When starting, we will be running at 0x40000000 most probably * but the code is expected to be loaded at 0x4xxxxxxx (uncached) and to be * running at virtual address 0xyyyyyyyy (cached). So we first * need to move everything to the right locationn then we setup the mmu and * jump to the final virtual address. */ .text .global start /** The code below must be able to run at any address **/ start: /* Copy running address */ sub r7, pc, #8 /* Save r0 */ mov r6, r0 RBIMPL_START_BEGIN /* Disable MMU, disable caching and buffering; * use low exception range address (the core uses high range by default) */ mrc p15, 0, r0, c1, c0, 0 ldr r1, =0x3005 bic r0, r1 mcr p15, 0, r0, c1, c0, 0 /* To call the C code we need a stack, since the stack is in virtual memory * use the stack's physical address */ ldr sp, =stackend_phys /* Enable MMU */ bl memory_init /* Copy the DRAM * Assume the dram binary blob is located at the loading address (r5) */ mov r2, r7 ldr r3, =_dramcopystart ldr r4, =_dramcopyend 1: cmp r4, r3 ldrhi r5, [r2], #4 strhi r5, [r3], #4 bhi 1b mov r2, #0 mcr p15, 0, r2, c7, c5, 0 @ Invalidate ICache /* Jump to real location */ ldr pc, =remap remap: RBIMPL_DO_STD_COPY _iedata, _iend, _iramcopy, _iramstart, _iramend, _initcopy, _initstart, _initend, _edata, _end RBIMPL_INIT_STACKS stackend, stackbegin, iriq_stack, fiq_stack RBIMPL_START_END /* Jump to main */ mov r0, r6 mov r1, r7 bl main 1: b 1b RBIMPL_STD_HANDLERS RBIMPL_IRQ_FIQ_STACKS irq_stack, fiq_stack end: