Home | History | Annotate | Line # | Download | only in gemini
gemini_start.S revision 1.5.8.3
      1  1.5.8.3  yamt /*	$NetBSD: gemini_start.S,v 1.5.8.3 2010/03/11 15:02:14 yamt Exp $	*/
      2  1.5.8.2  yamt 
      3  1.5.8.2  yamt /*
      4  1.5.8.2  yamt  * Machine dependant startup code for GEMINI boards.
      5  1.5.8.2  yamt  * Based on omap_start.S
      6  1.5.8.2  yamt  *
      7  1.5.8.2  yamt  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
      8  1.5.8.2  yamt  * Written by Hiroyuki Bessho for Genetec Corporation.
      9  1.5.8.2  yamt  *
     10  1.5.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     11  1.5.8.2  yamt  * modification, are permitted provided that the following conditions
     12  1.5.8.2  yamt  * are met:
     13  1.5.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     14  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     15  1.5.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     17  1.5.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     18  1.5.8.2  yamt  * 3. The name of Genetec Corporation may not be used to endorse or
     19  1.5.8.2  yamt  *    promote products derived from this software without specific prior
     20  1.5.8.2  yamt  *    written permission.
     21  1.5.8.2  yamt  *
     22  1.5.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     23  1.5.8.2  yamt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24  1.5.8.2  yamt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25  1.5.8.2  yamt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     26  1.5.8.2  yamt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  1.5.8.2  yamt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  1.5.8.2  yamt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  1.5.8.2  yamt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  1.5.8.2  yamt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31  1.5.8.2  yamt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32  1.5.8.2  yamt  * POSSIBILITY OF SUCH DAMAGE.
     33  1.5.8.2  yamt  *
     34  1.5.8.2  yamt  * Copyright (c) 2003
     35  1.5.8.2  yamt  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
     36  1.5.8.2  yamt  * All rights reserved.
     37  1.5.8.2  yamt  *
     38  1.5.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     39  1.5.8.2  yamt  * modification, are permitted provided that the following conditions
     40  1.5.8.2  yamt  * are met:
     41  1.5.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     42  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     43  1.5.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     44  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     45  1.5.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     46  1.5.8.2  yamt  *
     47  1.5.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     48  1.5.8.2  yamt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     49  1.5.8.2  yamt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     50  1.5.8.2  yamt  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     51  1.5.8.2  yamt  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     52  1.5.8.2  yamt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     53  1.5.8.2  yamt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     54  1.5.8.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     55  1.5.8.2  yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     56  1.5.8.2  yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     57  1.5.8.2  yamt  * SUCH DAMAGE.
     58  1.5.8.2  yamt  *
     59  1.5.8.2  yamt  * Copyright (c) 2007 Microsoft
     60  1.5.8.2  yamt  * All rights reserved.
     61  1.5.8.2  yamt  *
     62  1.5.8.2  yamt  * Redistribution and use in source and binary forms, with or without
     63  1.5.8.2  yamt  * modification, are permitted provided that the following conditions
     64  1.5.8.2  yamt  * are met:
     65  1.5.8.2  yamt  * 1. Redistributions of source code must retain the above copyright
     66  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer.
     67  1.5.8.2  yamt  * 2. Redistributions in binary form must reproduce the above copyright
     68  1.5.8.2  yamt  *    notice, this list of conditions and the following disclaimer in the
     69  1.5.8.2  yamt  *    documentation and/or other materials provided with the distribution.
     70  1.5.8.2  yamt  * 3. All advertising materials mentioning features or use of this software
     71  1.5.8.2  yamt  *    must display the following acknowledgement:
     72  1.5.8.2  yamt  *	This product includes software developed by Microsoft
     73  1.5.8.2  yamt  *
     74  1.5.8.2  yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     75  1.5.8.2  yamt  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     76  1.5.8.2  yamt  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     77  1.5.8.2  yamt  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
     78  1.5.8.2  yamt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     79  1.5.8.2  yamt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     80  1.5.8.2  yamt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     81  1.5.8.2  yamt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     82  1.5.8.2  yamt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     83  1.5.8.2  yamt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     84  1.5.8.2  yamt  * SUCH DAMAGE.
     85  1.5.8.2  yamt  */
     86  1.5.8.2  yamt 
     87  1.5.8.2  yamt #include "opt_gemini.h"
     88  1.5.8.2  yamt #include "opt_com.h"
     89  1.5.8.2  yamt #include "assym.h"
     90  1.5.8.2  yamt 
     91  1.5.8.2  yamt #include <machine/asm.h>
     92  1.5.8.2  yamt #include <arm/armreg.h>
     93  1.5.8.2  yamt #undef DOMAIN_CLIENT	/* assym.h defines as 1, but pte.h defines as 0x01 */
     94  1.5.8.2  yamt #include <arm/arm32/pmap.h>
     95  1.5.8.2  yamt #include <arm/gemini/gemini_reg.h>
     96  1.5.8.2  yamt #include <evbarm/gemini/gemini.h>
     97  1.5.8.2  yamt 
     98  1.5.8.3  yamt RCSID("$NetBSD: gemini_start.S,v 1.5.8.3 2010/03/11 15:02:14 yamt Exp $")
     99  1.5.8.2  yamt 
    100  1.5.8.2  yamt 
    101  1.5.8.2  yamt #if defined(VERBOSE_INIT_ARM)
    102  1.5.8.2  yamt # define _PUTCHAR(addr, areg, breg, c) 			\
    103  1.5.8.2  yamt 	ldr	areg, addr;				\
    104  1.5.8.2  yamt 1:							\
    105  1.5.8.2  yamt 	ldr	breg, [ areg, #0x14 ];	/* LSR    */	\
    106  1.5.8.2  yamt 	tst	breg, #0x20;		/* TXRDY? */	\
    107  1.5.8.2  yamt 	beq	1b;					\
    108  1.5.8.2  yamt 	mov	breg, #(c);		/*   c    */	\
    109  1.5.8.2  yamt 	str	breg, [ areg ];		/* TXDATA */	\
    110  1.5.8.2  yamt 2:							\
    111  1.5.8.2  yamt 	ldr	breg, [ areg, #0x14 ];	/* LSR    */	\
    112  1.5.8.2  yamt 	tst	breg, #0x40;		/* TSRE?  */	\
    113  1.5.8.2  yamt 	beq	2b;
    114  1.5.8.2  yamt #else
    115  1.5.8.2  yamt # define _PUTCHAR(addr, areg, breg, c)
    116  1.5.8.2  yamt #endif
    117  1.5.8.2  yamt 
    118  1.5.8.2  yamt 
    119  1.5.8.2  yamt /*
    120  1.5.8.2  yamt  * Kernel start routine for GEMINI Eval board.
    121  1.5.8.2  yamt  * At this point, this code has been loaded into SDRAM
    122  1.5.8.2  yamt  * and the MMU is off
    123  1.5.8.2  yamt  */
    124  1.5.8.2  yamt 	.section .start,"ax",%progbits
    125  1.5.8.2  yamt 
    126  1.5.8.2  yamt 	.global	_C_LABEL(gemini_start)
    127  1.5.8.2  yamt _C_LABEL(gemini_start):
    128  1.5.8.2  yamt 	/* Move into supervisor mode and disable IRQs/FIQs. */
    129  1.5.8.2  yamt 	mrs	r0, cpsr
    130  1.5.8.2  yamt 	bic	r0, r0, #PSR_MODE
    131  1.5.8.2  yamt 	orr	r0, r0, #(I32_bit | F32_bit | PSR_SVC32_MODE)
    132  1.5.8.2  yamt 	msr	cpsr, r0
    133  1.5.8.2  yamt 
    134  1.5.8.2  yamt 	_PUTCHAR(Lconsole_pbase, r4, r3, 'a')
    135  1.5.8.2  yamt 
    136  1.5.8.2  yamt 	/*
    137  1.5.8.2  yamt 	 * Set up a preliminary mapping in the MMU to allow us to run
    138  1.5.8.2  yamt 	 * at KERNEL_BASE with caches on.
    139  1.5.8.2  yamt 	 */
    140  1.5.8.2  yamt 	/* Build page table from scratch */
    141  1.5.8.2  yamt 	ldr	r0, Ltemp_l1_table
    142  1.5.8.2  yamt 	mov	r1, r0			/* Save the page table address. */
    143  1.5.8.2  yamt 	/* Zero the entire table so all virtual addresses are invalid. */
    144  1.5.8.2  yamt 	mov	r2, #L1_TABLE_SIZE	/* in bytes */
    145  1.5.8.2  yamt 	mov	r3, #0
    146  1.5.8.2  yamt 	mov	r4, r3
    147  1.5.8.2  yamt 	mov	r5, r3
    148  1.5.8.2  yamt 	mov	r6, r3
    149  1.5.8.2  yamt 	mov	r7, r3
    150  1.5.8.2  yamt 	mov	r8, r3
    151  1.5.8.2  yamt 	mov	r10, r3
    152  1.5.8.2  yamt 	mov	r11, r3
    153  1.5.8.2  yamt 1:	stmia	r1!, {r3-r8,r10-r11}
    154  1.5.8.2  yamt 	stmia	r1!, {r3-r8,r10-r11}
    155  1.5.8.2  yamt 	stmia	r1!, {r3-r8,r10-r11}
    156  1.5.8.2  yamt 	stmia	r1!, {r3-r8,r10-r11}
    157  1.5.8.2  yamt 	subs	r2, r2, #(4 * 4 * 8)	/* bytes per loop */
    158  1.5.8.2  yamt 	bne	1b
    159  1.5.8.2  yamt 
    160  1.5.8.2  yamt 	_PUTCHAR(Lconsole_pbase, r4, r3, 'b')
    161  1.5.8.2  yamt 
    162  1.5.8.2  yamt 	/* Now create our entries per the mmu_init_table. */
    163  1.5.8.2  yamt 	l1table	.req r0
    164  1.5.8.2  yamt 	va	.req r1
    165  1.5.8.2  yamt 	pa	.req r2
    166  1.5.8.2  yamt 	n_sec	.req r3
    167  1.5.8.2  yamt 	attr	.req r4
    168  1.5.8.2  yamt 	itable	.req r5
    169  1.5.8.2  yamt 	l1sfrm	.req r6
    170  1.5.8.2  yamt 	ldr	l1table, Ltemp_l1_table
    171  1.5.8.2  yamt 	adr	itable, mmu_init_table
    172  1.5.8.2  yamt 	ldr	l1sfrm, Ll1_s_frame
    173  1.5.8.2  yamt 	b	3f
    174  1.5.8.2  yamt 2:	str	pa, [l1table, va]
    175  1.5.8.2  yamt 	add	va, va, #4
    176  1.5.8.2  yamt 	add	pa, pa, #(L1_S_SIZE)
    177  1.5.8.2  yamt 	adds	n_sec, n_sec, #-1
    178  1.5.8.2  yamt 	bhi	2b
    179  1.5.8.2  yamt 3:	ldmia	itable!, {va,pa,n_sec,attr}
    180  1.5.8.2  yamt 	/* Convert va to l1 offset:	va = 4 * (va >> L1_S_SHIFT)	*/
    181  1.5.8.2  yamt 	mov	va, va, LSR #L1_S_SHIFT
    182  1.5.8.2  yamt 	mov	va, va, LSL #2
    183  1.5.8.2  yamt 	/* Convert pa to l1 entry:	pa = (pa & L1_S_FRAME) | attr	*/
    184  1.5.8.2  yamt 	and	pa, pa, l1sfrm
    185  1.5.8.2  yamt 	orr	pa, pa, attr
    186  1.5.8.2  yamt 	cmp	n_sec, #0
    187  1.5.8.2  yamt 	bne	2b
    188  1.5.8.2  yamt 	mov	r5, r0			/* l1table */
    189  1.5.8.2  yamt 	.unreq	va
    190  1.5.8.2  yamt 	.unreq	pa
    191  1.5.8.2  yamt 	.unreq	n_sec
    192  1.5.8.2  yamt 	.unreq	attr
    193  1.5.8.2  yamt 	.unreq	itable
    194  1.5.8.2  yamt 	.unreq	l1table
    195  1.5.8.2  yamt 	.unreq	l1sfrm
    196  1.5.8.2  yamt 
    197  1.5.8.2  yamt 	_PUTCHAR(Lconsole_pbase, r4, r3, 'c')
    198  1.5.8.2  yamt 
    199  1.5.8.2  yamt 	/*
    200  1.5.8.2  yamt 	 * using FA526 -specific cache ops here...
    201  1.5.8.2  yamt 	 */
    202  1.5.8.2  yamt 	mov	r0, #0
    203  1.5.8.2  yamt 	mcr	p15, 0, r0, c7, c5,  0	/* Invalidate Entire I cache */
    204  1.5.8.2  yamt 	mcr	p15, 0, r0, c7, c14, 0	/* Clean & Invalidate Entire D cache */
    205  1.5.8.2  yamt 
    206  1.5.8.2  yamt         ldr     r2, Lctl_ID_dis		/* Disable I+D caches */
    207  1.5.8.2  yamt 	mrc	p15, 0, r1, c1, c0, 0	/*  "       "   "     */
    208  1.5.8.2  yamt 	and	r1, r1, r2		/*  "       "   "     */
    209  1.5.8.2  yamt 	mcr	p15, 0, r1, c1, c0, 0	/*  "       "   "     */
    210  1.5.8.2  yamt 
    211  1.5.8.2  yamt 	_PUTCHAR(Lconsole_pbase, r4, r3, 'd')
    212  1.5.8.2  yamt 
    213  1.5.8.2  yamt 	mcr	p15, 0, r0, c7, c5, 6	/* invalidate BTB all */
    214  1.5.8.2  yamt 	mcr	p15, 0, r0, c7, c10, 4	/* Drain the write buffers. */
    215  1.5.8.2  yamt 	mcr	p15, 0, r5, c2, c0, 0	/* Set Translation Table Base */
    216  1.5.8.2  yamt 	mcr	p15, 0, r0, c8, c7, 0	/* Invalidate TLBs */
    217  1.5.8.2  yamt 
    218  1.5.8.2  yamt 	/* Set the Domain Access register */
    219  1.5.8.2  yamt         mov     r0, #((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT)
    220  1.5.8.2  yamt 	mcr	p15, 0, r0, c3, c0, 0
    221  1.5.8.2  yamt 
    222  1.5.8.2  yamt 	/*
    223  1.5.8.2  yamt 	 * set Extension Control Enable in ECR, so we can use BTB
    224  1.5.8.2  yamt 	 */
    225  1.5.8.2  yamt 	ldr     r0, Lecr_set
    226  1.5.8.2  yamt 	mcr     p15, 0, r0, c1, c1, 0
    227  1.5.8.2  yamt 
    228  1.5.8.2  yamt 	/*
    229  1.5.8.2  yamt 	 * Enable the MMU, etc.
    230  1.5.8.2  yamt 	 */
    231  1.5.8.2  yamt 	mrc     p15, 0, r0, c1, c0, 0
    232  1.5.8.2  yamt 	ldr     r1, Lcontrol_wax
    233  1.5.8.2  yamt 	and	r0, r0, r1
    234  1.5.8.2  yamt 	ldr     r1, Lcontrol_clr
    235  1.5.8.2  yamt 	mvn	r1, r1
    236  1.5.8.2  yamt 	and	r0, r0, r1
    237  1.5.8.2  yamt 	ldr     r1, Lcontrol_set
    238  1.5.8.2  yamt 	orr	r0, r0, r1
    239  1.5.8.2  yamt 	mcr     p15, 0, r0, c1, c0, 0
    240  1.5.8.2  yamt 
    241  1.5.8.2  yamt 	/*
    242  1.5.8.2  yamt 	 * Ensure that the coprocessor has finished turning on the MMU.
    243  1.5.8.2  yamt 	 */
    244  1.5.8.2  yamt 	mrc	p15, 0, r0, c2, c0, 0	/* Read an arbitrary value. */
    245  1.5.8.2  yamt 	mov	r0, r0			/* Stall until read completes. */
    246  1.5.8.2  yamt 
    247  1.5.8.2  yamt 	_PUTCHAR(Luart_vbase, r4, r3, 'e')
    248  1.5.8.2  yamt 
    249  1.5.8.2  yamt 	/*
    250  1.5.8.2  yamt 	 * Zero .bss
    251  1.5.8.2  yamt 	 */
    252  1.5.8.2  yamt 	ldr	r0, L_edata
    253  1.5.8.2  yamt 	ldr	r1, L_end
    254  1.5.8.2  yamt 	mov	r2, #0
    255  1.5.8.2  yamt 1:
    256  1.5.8.2  yamt 	str	r2, [r0], #0x04		/* *r0++ = r2 */
    257  1.5.8.2  yamt 	cmp	r0, r1
    258  1.5.8.2  yamt 	bne	1b
    259  1.5.8.2  yamt 
    260  1.5.8.2  yamt #if 0
    261  1.5.8.2  yamt 	/*
    262  1.5.8.2  yamt 	 * Jump to start in locore.S, which in turn will call initarm and main.
    263  1.5.8.2  yamt 	 */
    264  1.5.8.2  yamt 	adr	r0, Ltestjmp
    265  1.5.8.2  yamt 	ldr	pc, [r0]
    266  1.5.8.2  yamt 	nop
    267  1.5.8.2  yamt 	nop
    268  1.5.8.2  yamt 	nop
    269  1.5.8.2  yamt 	nop
    270  1.5.8.2  yamt testjmp:
    271  1.5.8.2  yamt #endif
    272  1.5.8.2  yamt 
    273  1.5.8.2  yamt 	_PUTCHAR(Luart_vbase, r4, r3, 'f')
    274  1.5.8.2  yamt 
    275  1.5.8.2  yamt 	adr	r0, Lstart
    276  1.5.8.2  yamt 	ldr	pc, [r0]
    277  1.5.8.2  yamt 	nop
    278  1.5.8.2  yamt 	nop
    279  1.5.8.2  yamt 	nop
    280  1.5.8.2  yamt 	nop
    281  1.5.8.2  yamt 
    282  1.5.8.2  yamt 	/* NOTREACHED */
    283  1.5.8.2  yamt 
    284  1.5.8.2  yamt L_edata:
    285  1.5.8.2  yamt 	.word   _C_LABEL(_edata)
    286  1.5.8.2  yamt L_end:
    287  1.5.8.2  yamt 	.word   _C_LABEL(_end)
    288  1.5.8.2  yamt 
    289  1.5.8.2  yamt #if 0
    290  1.5.8.2  yamt Ltestjmp:
    291  1.5.8.2  yamt 	.word	testjmp
    292  1.5.8.2  yamt #endif
    293  1.5.8.2  yamt 
    294  1.5.8.2  yamt Lstart:
    295  1.5.8.2  yamt 	.word	start
    296  1.5.8.2  yamt Ll1_s_frame:
    297  1.5.8.2  yamt 	.word	L1_S_FRAME
    298  1.5.8.2  yamt Ltemp_l1_table:
    299  1.5.8.2  yamt 	/* Put the temporary L1 translation table at the end of SDRAM. */
    300  1.5.8.2  yamt 	.word	MEMSIZE * 0x100000 - L1_TABLE_SIZE
    301  1.5.8.2  yamt 
    302  1.5.8.2  yamt /*
    303  1.5.8.2  yamt  * Coprocessor register initialization values
    304  1.5.8.2  yamt  */
    305  1.5.8.2  yamt #if !defined(CPU_ECR_ECE)
    306  1.5.8.2  yamt # define	CPU_ECR_ECE		1
    307  1.5.8.2  yamt #endif
    308  1.5.8.2  yamt 	/* bits to set in the Extension Control Register */
    309  1.5.8.2  yamt Lecr_set:
    310  1.5.8.2  yamt 	.word	CPU_ECR_ECE
    311  1.5.8.2  yamt 
    312  1.5.8.2  yamt #if !defined(CPU_CONTROL_BTB_ENABLE)
    313  1.5.8.2  yamt # define	CPU_CONTROL_BTB_ENABLE	(1 << 11)
    314  1.5.8.2  yamt #endif
    315  1.5.8.2  yamt 	/* bits to set in the Control Register */
    316  1.5.8.2  yamt 	/* bits 6..4 SB1 */
    317  1.5.8.2  yamt Lcontrol_set:
    318  1.5.8.2  yamt 	.word CPU_CONTROL_MMU_ENABLE  | \
    319  1.5.8.2  yamt 	      CPU_CONTROL_AFLT_ENABLE | \
    320  1.5.8.2  yamt 	      CPU_CONTROL_DC_ENABLE   | \
    321  1.5.8.2  yamt 	      CPU_CONTROL_WBUF_ENABLE | \
    322  1.5.8.2  yamt 	      CPU_CONTROL_32BP_ENABLE | \
    323  1.5.8.2  yamt 	      CPU_CONTROL_32BD_ENABLE | \
    324  1.5.8.2  yamt 	      CPU_CONTROL_LABT_ENABLE | \
    325  1.5.8.2  yamt 	      CPU_CONTROL_SYST_ENABLE | \
    326  1.5.8.2  yamt 	      CPU_CONTROL_IC_ENABLE   | \
    327  1.5.8.2  yamt 	      CPU_CONTROL_DC_ENABLE   | \
    328  1.5.8.2  yamt 	      CPU_CONTROL_BTB_ENABLE
    329  1.5.8.2  yamt 
    330  1.5.8.2  yamt 	/* bits to clear in the Control Register */
    331  1.5.8.2  yamt 	/* bits 31..14, 10,  SBZ */
    332  1.5.8.2  yamt Lcontrol_clr:
    333  1.5.8.2  yamt 	.word	((~0) << 14) | \
    334  1.5.8.2  yamt 		(1 << 10)
    335  1.5.8.2  yamt 
    336  1.5.8.2  yamt 	/* bits to "write as existing" in the Control Register */
    337  1.5.8.2  yamt Lcontrol_wax:
    338  1.5.8.2  yamt 	.word	CPU_CONTROL_BEND_ENABLE
    339  1.5.8.2  yamt 
    340  1.5.8.2  yamt 	/* bits to disable the caches */
    341  1.5.8.2  yamt Lctl_ID_dis:
    342  1.5.8.2  yamt 	.word	~(CPU_CONTROL_IC_ENABLE|CPU_CONTROL_DC_ENABLE)
    343  1.5.8.2  yamt 
    344  1.5.8.2  yamt 	/* console addressing */
    345  1.5.8.2  yamt Lconsole_pbase:
    346  1.5.8.2  yamt #if 0
    347  1.5.8.2  yamt 	.word	CONSADDR
    348  1.5.8.2  yamt #else
    349  1.5.8.2  yamt 	.word	GEMINI_UART_BASE
    350  1.5.8.2  yamt #endif
    351  1.5.8.2  yamt Luart_vbase:
    352  1.5.8.2  yamt 	.word	GEMINI_UART_VBASE
    353  1.5.8.2  yamt 
    354  1.5.8.2  yamt 
    355  1.5.8.2  yamt /* We'll modify va and pa at run time so we can use relocatable addresses. */
    356  1.5.8.2  yamt #define MMU_INIT(va,pa,n_sec,attr) \
    357  1.5.8.2  yamt 	.word	va					    ; \
    358  1.5.8.2  yamt 	.word	pa					    ; \
    359  1.5.8.2  yamt 	.word	n_sec					    ; \
    360  1.5.8.2  yamt 	.word	attr					    ;
    361  1.5.8.2  yamt 
    362  1.5.8.2  yamt mmu_init_table:
    363  1.5.8.2  yamt 	/* Maintain current 1:1 addressability */
    364  1.5.8.2  yamt 	MMU_INIT(KERNEL_BASE_phys, KERNEL_BASE_phys,
    365  1.5.8.2  yamt 		(MEMSIZE * L1_S_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
    366  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW) | L1_S_B | L1_S_C)
    367  1.5.8.2  yamt 
    368  1.5.8.2  yamt 	/* Map Kernel base VA:PA, write-back cacheable */
    369  1.5.8.2  yamt 	MMU_INIT(KERNEL_BASE_virt, KERNEL_BASE_phys,
    370  1.5.8.2  yamt 		(MEMSIZE * L1_S_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
    371  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW) | L1_S_B | L1_S_C)
    372  1.5.8.2  yamt 
    373  1.5.8.2  yamt 	/* Map Gemini GLOBAL regs */
    374  1.5.8.2  yamt 	MMU_INIT(GEMINI_GLOBAL_VBASE, GEMINI_GLOBAL_BASE,
    375  1.5.8.2  yamt 		1,
    376  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW))
    377  1.5.8.2  yamt 
    378  1.5.8.2  yamt 	/* Map Gemini UART */
    379  1.5.8.2  yamt 	MMU_INIT(GEMINI_UART_VBASE, GEMINI_UART_BASE,
    380  1.5.8.2  yamt 		1,
    381  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW))
    382  1.5.8.2  yamt 
    383  1.5.8.2  yamt 	/* Map Gemini LPC Host Controlr Space */
    384  1.5.8.2  yamt 	MMU_INIT(GEMINI_LPCHC_VBASE, GEMINI_LPCHC_BASE,
    385  1.5.8.2  yamt 		1,
    386  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW))
    387  1.5.8.2  yamt 
    388  1.5.8.2  yamt 	/* Map Gemini LPC IO Space */
    389  1.5.8.2  yamt 	MMU_INIT(GEMINI_LPCIO_VBASE, GEMINI_LPCIO_BASE,
    390  1.5.8.2  yamt 		1,
    391  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW))
    392  1.5.8.2  yamt 
    393  1.5.8.2  yamt 	/* Map Gemini DRAM Controller Space */
    394  1.5.8.2  yamt 	MMU_INIT(GEMINI_DRAMC_VBASE, GEMINI_DRAMC_BASE,
    395  1.5.8.2  yamt 		1,
    396  1.5.8.2  yamt 		L1_S_PROTO | L1_S_AP(AP_KRW))
    397  1.5.8.2  yamt 
    398  1.5.8.2  yamt 	/* end of table */
    399  1.5.8.2  yamt 	MMU_INIT(0, 0, 0, 0)
    400  1.5.8.2  yamt 
    401