1 /* $NetBSD: intmmu.S,v 1.5.6.4 2005/11/10 13:55:53 skrll Exp $ */
4 * Copyright (c) 2001 ARM Ltd
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the company may not be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <machine/asm.h>
34 #include <arm/armreg.h>
35 #include <arm/arm32/pte.h>
37 .section .start,"ax",%progbits
39 ASENTRY_NP(integrator_start)
40 mov r6, #0x16000000 /* UART0 Physical base*/
41 #ifdef VERBOSE_INIT_ARM
43 str r3, [r6] /* Let the world know we are alive */
46 * Check that the processor has a CP15. Some core modules do not.
47 * We can tell by reading CM_PROC. If it is zero, then we're OK, otherwise
48 * let the user know why we've died.
55 * Now read CP15 and check what sort of core we have. We need to know
56 * if it has an MMU. There's no simple test for this, but the following
57 * hack should be sufficient for all currently supported CM boards:
58 * - Check that the product code has a '2' or '3' in bits 8-11
60 mrc p15, 0, r3, c0, c0, 0
61 and r0, r3, #0x00000f00
62 teq r0, #0x00000200 /* ARM 920, 1020, 1026, etc */
63 teqne r0, #0x00000300 /* ARM 1136 */
67 * At this time the MMU is off.
68 * We build up an initial memory map at 0x8000 that we can use to get
69 * the kernel running from the top of memory. All mappings in this table
70 * use L1 section maps.
74 * Set Virtual == Physical
76 mov r3, #(L1_S_AP(AP_KRW))
77 add r3, r3, #(L1_TYPE_S)
78 mov r2, #0x100000 /* advance by 1MB */
79 mov r1, #0x8000 /* page table start */
80 mov r0, #0x1000 /* page table size */
89 * Map VA 0xc0000000->0xc03fffff to PA 0x00000000->0x003fffff
91 mov r3, #(L1_S_AP(AP_KRW))
92 add r3, r3, #(L1_TYPE_S)
93 mov r1, #0x8000 /* page table start */
94 add r1, r1, #(0xc00 * 4) /* offset to 0xc00xxxxx */
95 # add r1, r1, #(0x001 * 4) /* offset to 0xc01xxxxx */
98 str r3, [r1], #0x0004 /* 0xc000000-0xc03fffff */
103 * Mapping the peripheral register region (0x10000000->0x1fffffff) linearly
104 * would require 256MB of virtual memory (as much space as the entire kernel
105 * virtual space). So we map the first 1M of each 16MB sub-space into the
106 * region VA 0xfd000000->0xfdffffff; this should map enough of the peripheral
107 * space to at least get us up and running.
109 mov r3, #(L1_S_AP(AP_KRW))
110 add r3, r3, #L1_TYPE_S
111 add r3, r3, #0x10000000 /* Peripherals base */
112 mov r1, #0x8000 /* page table start */
113 add r1, r1, #(0xfd0 * 4)
114 mov r2, #0x01000000 /* 16MB increment. */
117 str r3, [r1], #4 /* 0xfd000000-0xfdffffff */
123 * We now have our page table ready, so load it up and light the blue
127 /* set the location of the L1 page table */
129 mcr p15, 0, r1, c2, c0, 0
131 /* Flush the old TLBs (just in case) */
132 mcr p15, 0, r1, c8, c7, 0
135 mcr p15, 0, r1, c7, c6, 0
137 #ifdef VERBOSE_INIT_ARM
142 /* Set the Domain Access register. Very important! */
144 mcr p15, 0, r1, c3, c0, 0
147 * set mmu bit (don't set anything else for now, we don't know
148 * what sort of CPU we have yet.
150 mov r1, #CPU_CONTROL_MMU_ENABLE
153 * This is where it might all start to go wrong if the CPU fitted to your
154 * integrator does not have an MMU.
156 /* fetch current control state */
157 mrc p15, 0, r2, c1, c0, 0
160 /* set new control state */
161 mcr p15, 0, r2, c1, c0, 0
167 #ifdef VERBOSE_INIT_ARM
168 /* emit a char. Uart is now at 0xfd600000 */
170 add r6, r6, #0x00600000
175 /* jump to kernel space */
178 /* Switch to kernel VM and really set the ball rolling. */
204 .ascii "Core has no cp15\r\n\0"
206 .ascii "Core has no MMU\r\n\0"