/* $NetBSD: intmmu.S,v 1.12 2013/08/12 17:41:51 matt Exp $ */
/*
* Copyright (c) 2001 ARM Ltd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
ASENTRY_NP(integrator_start)
mov r6, #0x16000000 /* UART0 Physical base*/
#ifdef VERBOSE_INIT_ARM
mov r3, #'A'
str r3, [r6] /* Let the world know we are alive */
#endif
/*
* Check that the processor has a CP15. Some core modules do not.
* We can tell by reading CM_PROC. If it is zero, then we're OK, otherwise
* let the user know why we've died.
*/
mov r7, #0x10000000
ldr r3, [r7, #4]
cmp r3, #0
bne Lno_cp15
/*
* Now read CP15 and check what sort of core we have. We need to know
* if it has an MMU. There's no simple test for this, but the following
* hack should be sufficient for all currently supported CM boards:
* - Check that the product code has a '2' or '3' in bits 8-11
*/
mrc p15, 0, r3, c0, c0, 0
and r0, r3, #0x00000f00
teq r0, #0x00000200 /* ARM 920, 1020, 1026, etc */
teqne r0, #0x00000300 /* ARM 1136 */
bne Lno_mmu
/*
* At this time the MMU is off.
* We build up an initial memory map at 0x8000 that we can use to get
* the kernel running from the top of memory. All mappings in this table
* use L1 section maps.
*/
/* Set the Domain Access register. Very important! */
mov r1, #1
mcr p15, 0, r1, c3, c0, 0
/*
* set mmu bit (don't set anything else for now, we don't know
* what sort of CPU we have yet.
*/
mov r1, #CPU_CONTROL_MMU_ENABLE
/*
* This is where it might all start to go wrong if the CPU fitted to your
* integrator does not have an MMU.
*/
/* fetch current control state */
mrc p15, 0, r2, c1, c0, 0
orr r2, r2, r1
/* set new control state */
mcr p15, 0, r2, c1, c0, 0
mov r0, r0
mov r0, r0
mov r0, r0
#ifdef VERBOSE_INIT_ARM
/* emit a char. Uart is now at 0xfd600000 */
mov r6, #0xfd000000
add r6, r6, #0x00600000
mov r2, #'C'
strb r2, [r6]
#endif
/* jump to kernel space */
mov r0, #0x0200
/* Switch to kernel VM and really set the ball rolling. */
ldr pc, Lstart