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