Home | History | Annotate | Line # | Download | only in ixdp425
ixdp425_start.S revision 1.3
      1 /*	$NetBSD: ixdp425_start.S,v 1.3 2003/12/08 16:15:31 scw 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  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by Ichiro FUKUHARA.
     19  * 4. The name of the company nor the name of the author may be used to
     20  *    endorse or promote products derived from this software without specific
     21  *    prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  */
     35 #include <machine/asm.h>
     36 #include <arm/armreg.h>
     37 #include <arm/arm32/pte.h>
     38 
     39 #include <arm/xscale/ixp425reg.h>
     40 
     41 	.section .start,"ax",%progbits
     42 
     43 	.global	_C_LABEL(ixdp425_start)
     44 _C_LABEL(ixdp425_start):
     45         /*
     46          * We will go ahead and disable the MMU here so that we don't
     47          * have to worry about flushing caches, etc.
     48          *
     49          * Note that we may not currently be running VA==PA, which means
     50          * we'll need to leap to the next insn after disabing the MMU.
     51          */
     52         adr     r8, Lunmapped
     53         bic     r8, r8, #0xff000000     /* clear upper 8 bits */
     54         orr     r8, r8, #0x10000000     /* OR in physical base address */
     55 
     56 	/*
     57 	 * Setup coprocessor 15.
     58 	 */
     59 	/*
     60 	 *IXDP425 with CSR(microengine code produced by Intel Corp.)
     61 	 *  running well on BigEndian, because CSR written on bigendian
     62 	 */
     63         mrc     p15, 0, r2, c1, c0, 0
     64         bic     r2, r2, #CPU_CONTROL_MMU_ENABLE
     65 	orr	r2, r2, #CPU_CONTROL_BEND_ENABLE
     66         mcr     p15, 0, r2, c1, c0, 0
     67 
     68         nop
     69         nop
     70         nop
     71 
     72         mov     pc, r8                  /* Heave-ho! */
     73 
     74 Lunmapped:
     75 	/*
     76 	 * We want to construct a memory map that maps us
     77 	 * VA==PA (SDRAM at 0x10000000). We create these
     78 	 * mappings uncached and unbuffered to be safe.
     79 	 */
     80 
     81 	/*
     82 	 * Step 1: Map the entire address space VA==PA.
     83 	 */
     84 	adr	r0, Ltable
     85 	ldr	r0, [r0]			/* r0 = &l1table */
     86 
     87 	mov	r1, #(L1_TABLE_SIZE / 4)	/* 4096 entry */
     88 	mov	r2, #(L1_S_SIZE)		/* 1MB / section */
     89 	mov	r3, #(L1_S_AP(AP_KRW))		/* kernel read/write */
     90 	orr	r3, r3, #(L1_TYPE_S)		/* L1 entry is section */
     91 1:
     92 	str	r3, [r0], #0x04
     93 	add	r3, r3, r2
     94 	subs	r1, r1, #1
     95 	bgt	1b
     96 
     97         /*
     98          * Step 2: Map VA 0xc0000000->0xc3ffffff to PA 0x10000000->0x13ffffff.
     99          */
    100         adr     r0, Ltable                      /* r0 = &l1table */
    101         ldr     r0, [r0]
    102 
    103         mov     r3, #(L1_S_AP(AP_KRW))
    104         orr     r3, r3, #(L1_TYPE_S)
    105         orr     r3, r3, #0x10000000
    106         add     r0, r0, #(0xc00 * 4)            /* offset to 0xc00xxxxx */
    107         mov     r1, #0x40                       /* 64MB */
    108 1:
    109         str     r3, [r0], #0x04
    110         add     r3, r3, r2
    111         subs    r1, r1, #1
    112         bgt     1b
    113 
    114 	/*
    115 	 * Step 3: Map VA 0xf0000000->0xf0100000 to PA 0xc8000000->0xc8100000.
    116 	 */
    117 	adr	r0, Ltable			/* r0 = &l1table */
    118 	ldr	r0, [r0]
    119 
    120 	add	r0, r0, #(0xf00 * 4)		/* offset to 0xf0000000 */
    121 	mov	r3, #0xc8000000
    122 	add	r3, r3, #0x00100000
    123 	orr	r3, r3, #(L1_S_AP(AP_KRW))
    124 	orr	r3, r3, #(L1_TYPE_S)
    125 	str	r3, [r0]
    126 
    127 	/*
    128 	 * Step 4: Map VA 0xf0200000->0xf0300000 to PA 0xcc000000->0xcc100000.
    129 	 */
    130 	adr	r0, Ltable			/* r0 = &l1table */
    131 	ldr	r0, [r0]
    132 
    133 	add	r0, r0, #(0xf00 * 4)		/* offset to 0xf0200000 */
    134 	add	r0, r0, #(0x002 * 4)
    135 	mov	r3, #0xcc000000
    136 	add	r3, r3, #0x00100000
    137 	orr	r3, r3, #(L1_S_AP(AP_KRW))
    138 	orr	r3, r3, #(L1_TYPE_S)
    139 	str	r3, [r0]
    140 
    141 	/* OK!  Page table is set up.  Give it to the CPU. */
    142 	adr	r0, Ltable
    143 	ldr	r0, [r0]
    144 	mcr	p15, 0, r0, c2, c0, 0
    145 
    146 	/* Flush the old TLBs, just in case. */
    147 	mcr	p15, 0, r0, c8, c7, 0
    148 
    149 	/* Set the Domain Access register.  Very important! */
    150 	mov	r0, #1
    151 	mcr	p15, 0, r0, c3, c0, 0
    152 
    153 	/* Get ready to jump to the "real" kernel entry point... */
    154 	ldr	r0, Lstart
    155 
    156 	/* OK, let's enable the MMU. */
    157 	mrc	p15, 0, r2, c1, c0, 0
    158 	orr	r2, r2, #CPU_CONTROL_MMU_ENABLE
    159 	orr	r2, r2, #CPU_CONTROL_BEND_ENABLE
    160 	mcr	p15, 0, r2, c1, c0, 0
    161 
    162 	nop
    163 	nop
    164 	nop
    165 
    166 	/* CPWAIT sequence to make sure the MMU is on... */
    167 	mrc	p15, 0, r2, c2, c0, 0	/* arbitrary read of CP15 */
    168 	mov	r2, r2			/* force it to complete */
    169 	mov	pc, r0			/* leap to kernel entry point! */
    170 
    171 Ltable:
    172 	.word	0x10200000 - 0x4000
    173 
    174 Lstart:
    175 	.word	start
    176