1 /* $NetBSD: imx31lk_start.S,v 1.2 2008/04/27 18:58:46 matt Exp $ */
3 #include <machine/asm.h>
4 #include <arm/armreg.h>
5 #include <arm/arm32/pmap.h>
6 #include <arm/arm32/pte.h>
12 #define CPWAIT_BRANCH \
16 mrc p15, 0, tmp, c2, c0, 0 /* arbitrary read of CP15 */ ;\
17 mov tmp, tmp /* wait for it to complete */ ;\
18 CPWAIT_BRANCH /* branch to next insn */
22 #define SDRAM_START 0x80000000
25 #define IMX31_DCACHE_SIZE 0x4000 /* 16KB L1 */
28 * L1 == "Level One" == "first-level"
29 * L2 == "Level Two" == "second-level"
34 .global _C_LABEL(imx31lk_start)
35 _C_LABEL(imx31lk_start):
36 /* Figure out where we want to jump to when the time comes */
41 * set up virtual address space mapping
42 * for initial bootstrap.
44 mov r2, #(L1_S_SIZE) /* 1MB chunks */
47 * Firmware already mapped SDRAM VA == PA. at 0x800..
48 * now map SDRAM also at VA 0x800...
50 mrc p15, 0, r0, c2, c0, 0 /* L1 table addr into r0 */
51 add r0, r0, #(0x800 * 4) /* offset to 0x80000000 */
53 mov r3, #SDRAM_START /* map to 0x800.. */
54 orr r3, r3, #(L1_S_AP(AP_KRW)) /* the usual perms & stuff */
55 orr r3, r3, #(L1_TYPE_S)
56 orr r3, r3, #(L1_S_DOM(PMAP_DOMAIN_KERNEL))
58 mov r1, #0x80 /* 128 1MB entries */
60 /* and looplooploop */
67 * Map an L1 section for each device to make this easy.
70 mrc p15, 0, r0, c2, c0, 0 /* L1 table addr into r0 */
71 add r0, r0, #(0xfd0 * 4) /* offset to 0xfd000000 */
74 orr r3, r3, #0x00f00000
75 orr r3, r3, #(L1_S_AP(AP_KRW))
76 orr r3, r3, #(L1_TYPE_S)
77 orr r3, r3, #(L1_S_DOM(PMAP_DOMAIN_KERNEL))
78 str r3, [r0], #4 /* note autoinc */
83 * Make domain control go full art.
86 mcr p15, 0, r0, c3, c0, 0
89 * Now let's clean the cache again to make sure everything
92 * XXX: should this take into account the XScale cache clean bug?
94 mov r3, #(IMX31_DCACHE_SIZE)
97 mcr p15, 0, r3, c7, c10, 2
102 /* Drain write buffer */
103 mcr p15, 0, r6, c7, c10, 4
105 /* Invalidate TLBs just to be sure */
106 mcr p15, 0, r0, c8, c7, 0
109 * You are standing at the gate to NetBSD. --More--
110 * Unspeakable cruelty and harm lurk down there. --More--
111 * Are you sure you want to enter?
115 mov pc, r8 /* So be it */
117 /* symbol to use for address calculation in the right VA */
123 * Calculate size of kernel to copy. Don't bother to copy bss,
124 * although I guess the CPU could use the warmup exercise ...
127 .word _edata - _C_LABEL(imx31lk_start)