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