/*
* arm v7 reboot code
*
* must fit in 11K to avoid stepping on PTEs; see mem.h.
* cache parameters are at CACHECONF.
*/
#include "arm.s"
/*
* All caches but L1 should be off before calling this.
* Turn off MMU, then copy the new kernel to its correct location
* in physical memory. Then jump to the start of the kernel.
*/
/* set up a new stack for local vars and memmove args */
MOVW R6, SP /* tiny trampoline stack */
SUB $(0x20 + 4), SP /* back up before a.out header */
// MOVW R14, -48(SP) /* store return addr */
SUB $48, SP /* allocate stack frame */
MOVW R5, 40(SP) /* save count */
MOVW R6, 44(SP) /* save dest/entry */
/* copy the new kernel into place */
DELAY(printloop2, 2)
PUTC('t')
MOVW 40(SP), R5 /* restore count */
MOVW 44(SP), R6 /* restore dest/entry */
MOVW R6, 0(SP) /* normally saved LR goes here */
MOVW R6, 4(SP) /* push dest */
MOVW R6, R0
MOVW R4, 8(SP) /* push src */
MOVW R5, 12(SP) /* push size */
BL memmove(SB)
PUTC('-')
PUTC('>')
DELAY(printloopret, 1)
PUTC('\r')
DELAY(printloopnl, 1)
PUTC('\n')
/*
* jump to kernel entry point. Note the true kernel entry point is
* the virtual address KZERO|R6, but this must wait until
* the MMU is enabled by the kernel in l.s
*/
MOVW 44(SP), R6 /* restore R6 (dest/entry) */
ORR R6, R6 /* NOP: avoid link bug */
B (R6)
PUTC('?')
PUTC('?')
B 0(PC)
/*
* turn the caches off, double map PHYSDRAM & KZERO, invalidate TLBs, revert
* to tiny addresses. upon return, it will be safe to turn off the mmu.
*/
TEXT cachesoff(SB), 1, $-4
MOVM.DB.W [R14,R1-R10], (R13) /* save regs on stack */
CPSID
BARRIERS