1 /* $NetBSD: ixdp425_start.S,v 1.5 2005/12/11 12:17:09 christos Exp $ */
5 * Ichiro FUKUHARA <ichiro@ichiro.org>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <machine/asm.h>
30 #include <arm/armreg.h>
31 #include <arm/arm32/pte.h>
33 #include <arm/xscale/ixp425reg.h>
35 .section .start,"ax",%progbits
37 .global _C_LABEL(ixdp425_start)
38 _C_LABEL(ixdp425_start):
40 * We will go ahead and disable the MMU here so that we don't
41 * have to worry about flushing caches, etc.
43 * Note that we may not currently be running VA==PA, which means
44 * we'll need to leap to the next insn after disabing the MMU.
47 bic r8, r8, #0xff000000 /* clear upper 8 bits */
48 orr r8, r8, #0x10000000 /* OR in physical base address */
51 * Setup coprocessor 15.
54 *IXDP425 with CSR(microengine code produced by Intel Corp.)
55 * running well on BigEndian, because CSR written on bigendian
57 mrc p15, 0, r2, c1, c0, 0
58 bic r2, r2, #CPU_CONTROL_MMU_ENABLE
59 orr r2, r2, #CPU_CONTROL_BEND_ENABLE
60 mcr p15, 0, r2, c1, c0, 0
66 mov pc, r8 /* Heave-ho! */
70 * We want to construct a memory map that maps us
71 * VA==PA (SDRAM at 0x10000000). We create these
72 * mappings uncached and unbuffered to be safe.
76 * Step 1: Map the entire address space VA==PA.
79 ldr r0, [r0] /* r0 = &l1table */
81 mov r1, #(L1_TABLE_SIZE / 4) /* 4096 entry */
82 mov r2, #(L1_S_SIZE) /* 1MB / section */
83 mov r3, #(L1_S_AP(AP_KRW)) /* kernel read/write */
84 orr r3, r3, #(L1_TYPE_S) /* L1 entry is section */
92 * Step 2: Map VA 0xc0000000->0xc3ffffff to PA 0x10000000->0x13ffffff.
94 adr r0, Ltable /* r0 = &l1table */
97 mov r3, #(L1_S_AP(AP_KRW))
98 orr r3, r3, #(L1_TYPE_S)
99 orr r3, r3, #0x10000000
100 add r0, r0, #(0xc00 * 4) /* offset to 0xc00xxxxx */
101 mov r1, #0x40 /* 64MB */
109 * Step 3: Map VA 0xf0000000->0xf0100000 to PA 0xc8000000->0xc8100000.
111 adr r0, Ltable /* r0 = &l1table */
114 add r0, r0, #(0xf00 * 4) /* offset to 0xf0000000 */
116 add r3, r3, #0x00100000
117 orr r3, r3, #(L1_S_AP(AP_KRW))
118 orr r3, r3, #(L1_TYPE_S)
122 * Step 4: Map VA 0xf0200000->0xf0300000 to PA 0xcc000000->0xcc100000.
124 adr r0, Ltable /* r0 = &l1table */
127 add r0, r0, #(0xf00 * 4) /* offset to 0xf0200000 */
128 add r0, r0, #(0x002 * 4)
130 add r3, r3, #0x00100000
131 orr r3, r3, #(L1_S_AP(AP_KRW))
132 orr r3, r3, #(L1_TYPE_S)
135 /* OK! Page table is set up. Give it to the CPU. */
138 mcr p15, 0, r0, c2, c0, 0
140 /* Flush the old TLBs, just in case. */
141 mcr p15, 0, r0, c8, c7, 0
143 /* Set the Domain Access register. Very important! */
145 mcr p15, 0, r0, c3, c0, 0
147 /* Get ready to jump to the "real" kernel entry point... */
149 mov r1, r1 /* Make sure the load completes! */
151 /* OK, let's enable the MMU. */
152 mrc p15, 0, r2, c1, c0, 0
153 orr r2, r2, #CPU_CONTROL_MMU_ENABLE
154 orr r2, r2, #CPU_CONTROL_BEND_ENABLE
155 mcr p15, 0, r2, c1, c0, 0
161 /* CPWAIT sequence to make sure the MMU is on... */
162 mrc p15, 0, r2, c2, c0, 0 /* arbitrary read of CP15 */
163 mov r2, r2 /* force it to complete */
164 mov pc, r1 /* leap to kernel entry point! */
167 .word 0x10200000 - 0x4000