Home | History | Annotate | Line # | Download | only in ixdp425
ixdp425_start.S revision 1.6
      1 /*	$NetBSD: ixdp425_start.S,v 1.6 2009/10/21 14:15:51 rmind Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2003
      5  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     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.
     16  *
     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
     27  * SUCH DAMAGE.
     28  */
     29 #include <machine/asm.h>
     30 #include <arm/armreg.h>
     31 #include <arm/arm32/pte.h>
     32 
     33 #include <arm/xscale/ixp425reg.h>
     34 
     35 	.section .start,"ax",%progbits
     36 
     37 	.global	_C_LABEL(ixdp425_start)
     38 _C_LABEL(ixdp425_start):
     39         /*
     40          * We will go ahead and disable the MMU here so that we don't
     41          * have to worry about flushing caches, etc.
     42          *
     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.
     45          */
     46         adr     r8, Lunmapped
     47         bic     r8, r8, #0xff000000     /* clear upper 8 bits */
     48         orr     r8, r8, #0x10000000     /* OR in physical base address */
     49 
     50 	/*
     51 	 * Setup coprocessor 15.
     52 	 */
     53 	/*
     54 	 *IXDP425 with CSR(microengine code produced by Intel Corp.)
     55 	 *  running well on BigEndian, because CSR written on bigendian
     56 	 */
     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
     61 
     62         nop
     63         nop
     64         nop
     65 
     66         mov     pc, r8                  /* Heave-ho! */
     67 
     68 Lunmapped:
     69 	/*
     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.
     73 	 */
     74 
     75 	/*
     76 	 * Step 1: Map the entire address space VA==PA.
     77 	 */
     78 	adr	r0, Ltable
     79 	ldr	r0, [r0]			/* r0 = &l1table */
     80 
     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 */
     85 1:
     86 	str	r3, [r0], #0x04
     87 	add	r3, r3, r2
     88 	subs	r1, r1, #1
     89 	bgt	1b
     90 
     91         /*
     92          * Step 2: Map VA 0xc0000000->0xc3ffffff to PA 0x10000000->0x13ffffff.
     93          */
     94         adr     r0, Ltable                      /* r0 = &l1table */
     95         ldr     r0, [r0]
     96 
     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 */
    102 1:
    103         str     r3, [r0], #0x04
    104         add     r3, r3, r2
    105         subs    r1, r1, #1
    106         bgt     1b
    107 
    108 	/*
    109 	 * Step 3: Map VA 0xf0000000->0xf0100000 to PA 0xc8000000->0xc8100000.
    110 	 */
    111 	adr	r0, Ltable			/* r0 = &l1table */
    112 	ldr	r0, [r0]
    113 
    114 	add	r0, r0, #(0xf00 * 4)		/* offset to 0xf0000000 */
    115 	mov	r3, #0xc8000000
    116 	add	r3, r3, #0x00100000
    117 	orr	r3, r3, #(L1_S_AP(AP_KRW))
    118 	orr	r3, r3, #(L1_TYPE_S)
    119 	str	r3, [r0]
    120 
    121 	/*
    122 	 * Step 4: Map VA 0xf0200000->0xf0300000 to PA 0xcc000000->0xcc100000.
    123 	 */
    124 	adr	r0, Ltable			/* r0 = &l1table */
    125 	ldr	r0, [r0]
    126 
    127 	add	r0, r0, #(0xf00 * 4)		/* offset to 0xf0200000 */
    128 	add	r0, r0, #(0x002 * 4)
    129 	mov	r3, #0xcc000000
    130 	add	r3, r3, #0x00100000
    131 	orr	r3, r3, #(L1_S_AP(AP_KRW))
    132 	orr	r3, r3, #(L1_TYPE_S)
    133 	str	r3, [r0]
    134 
    135 	/* OK!  Page table is set up.  Give it to the CPU. */
    136 	adr	r0, Ltable
    137 	ldr	r0, [r0]
    138 	mcr	p15, 0, r0, c2, c0, 0
    139 
    140 	/* Flush the old TLBs, just in case. */
    141 	mcr	p15, 0, r0, c8, c7, 0
    142 
    143 	/* Set the Domain Access register.  Very important! */
    144 	mov	r0, #1
    145 	mcr	p15, 0, r0, c3, c0, 0
    146 
    147 	/* Get ready to jump to the "real" kernel entry point... */
    148 	ldr	r1, Lstart
    149 	mov	r1, r1			/* Make sure the load completes! */
    150 
    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
    156 
    157 	nop
    158 	nop
    159 	nop
    160 
    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! */
    165 
    166 Ltable:
    167 	.word	0x10200000 - 0x4000
    168 
    169 Lstart:
    170 	.word	start
    171