Home | History | Annotate | Line # | Download | only in ev64260
ev64260_locore.S revision 1.9.10.2
      1 /*	$NetBSD: ev64260_locore.S,v 1.9.10.2 2010/03/11 15:02:20 yamt Exp $	*/
      2 /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
      3 
      4 /*
      5  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      6  * Copyright (C) 1995, 1996 TooLs GmbH.
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed by TooLs GmbH.
     20  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #include "opt_ddb.h"
     36 #include "opt_ppcparam.h"
     37 #include "opt_ipkdb.h"
     38 #include "opt_modular.h"
     39 #include "opt_multiprocessor.h"
     40 #include "opt_openpic.h"
     41 #include "assym.h"
     42 
     43 #include <sys/syscall.h>
     44 
     45 #include <machine/param.h>
     46 #include <machine/vmparam.h>
     47 #include <machine/pmap.h>
     48 #include <machine/psl.h>
     49 #include <machine/trap.h>
     50 #define _NOREGNAMES
     51 #include <machine/asm.h>
     52 
     53 #include <powerpc/spr.h>
     54 #include <powerpc/oea/spr.h>
     55 #include <powerpc/oea/bat.h>
     56 #include <powerpc/oea/hid.h>
     57 
     58 /*
     59  * Some instructions gas doesn't understand (yet?)
     60  */
     61 #define	bdneq	bdnzf 2,
     62 
     63 /*
     64  * Globals
     65  */
     66 GLOBAL(startsym)
     67 	.long	0			/* start symbol table */
     68 GLOBAL(endsym)
     69 	.long	0			/* end symbol table */
     70 GLOBAL(oeacpufeat)
     71 	.long	0			/* cpu features */
     72 /*
     73  * File-scope for locore.S
     74  */
     75 #ifdef DINK
     76 	.data
     77 dink_return:
     78 	.long	0			/* fake uarea during idle after exit */
     79 dink_stack:
     80 	.long	0			/* fake uarea during idle after exit */
     81 #endif
     82 
     83 
     84 /*
     85  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     86  * mark the start of kernel text.
     87  */
     88 	.text
     89 	.globl	_C_LABEL(kernel_text)
     90 _C_LABEL(kernel_text):
     91 
     92 /*
     93  * Startup entry.  Note, this must be the first thing in the text
     94  * segment!
     95  */
     96 	.text
     97 	.globl	__start
     98 __start:
     99 #ifdef DINK
    100 	mflr	0
    101 	lis	8, dink_stack@ha
    102 	stw	1, dink_stack@l(8)
    103 	lis	8, dink_return@ha
    104 	stw	0, dink_return@l(8)
    105 #endif
    106 
    107 #if 0
    108 	eieio; sync
    109 	lis	8, 0xf100f104@ha
    110 	lwz	7, -3836(8)
    111 	li	0, 1
    112 	andc	7,7,0
    113 	stw	7, -3836(8)
    114 	eieio; sync
    115 #endif
    116 
    117 	/*
    118 	 * Make sure that .bss is zeroed.
    119 	 */
    120 	li	0,0
    121 	lis	8,edata@ha
    122 	addi	8,8,edata@l
    123 	lis	9,end@ha
    124 	addi	9,9,end@l
    125 5:	cmpw	0,8,9			/* edata & end are >= word aligned */
    126 	bge	6f
    127 	stw	0,0(8)
    128 	addi	8,8,4
    129 	b	5b
    130 6:
    131 
    132 	li	0,0
    133 	mtmsr	0			/* Disable FPU/MMU/exceptions */
    134 	sync ; isync
    135 
    136 #if 1
    137 	mfpvr	0
    138 	srwi	0,0,16
    139 	cmplwi	0,MPC7410
    140 	bne	16f
    141 
    142 #if 0
    143 	/* flush and disable L2 */
    144 	mfspr	8,SPR_L2CR
    145 	lis	0,(L2CR_L2E|L2CR_L2WT)@h	/* disable the L2 mode */
    146 	andc	8,8,0
    147 	ori	8,8,L2CR_L2HWF		/* enable hardware flush */
    148 	sync
    149 	mtspr	SPR_L2CR,8		/* do it */
    150 	sync				/* wait for it to finish */
    151 
    152 	/* Disable data lock mode */
    153 	mfspr	8,SPR_HID0
    154 	li	0,HID0_DLOCK
    155 	andc	8,8,0
    156 	mtspr	SPR_HID0,8
    157 	sync
    158 #endif
    159 #if 0
    160 	/*
    161 	 * Flush the L1 cache
    162 	 */
    163 	mfspr	8,SPR_MSSCR0
    164 	oris	8,8,MSSCR0_DL1HWF@h
    165 	sync
    166 	mtspr	SPR_MSSCR0,8
    167 	sync
    168 #endif
    169 #if 1
    170 	/* disable data and instruction caches */
    171 	mfspr	8,SPR_HID0
    172 	li	0,HID0_DLOCK@l
    173 	andc	8,8,0
    174 	sync
    175 	mtspr	SPR_HID0,8
    176 	sync
    177 	isync
    178 #endif
    179 7:
    180 #if 0
    181 	/* disable data and instruction caches */
    182 	mfspr	8,SPR_HID0
    183 	li	0,(HID0_ICE|HID0_DCE)@l
    184 	andc	8,8,0
    185 	sync
    186 	mtspr	SPR_HID0,8
    187 	sync
    188 	isync
    189 #endif
    190 7:
    191 #if 0
    192 	/* Enable and flush data and instruction caches */
    193 	ori	8,8,(HID0_ICFI|HID0_ICE|HID0_DCFI|HID0_DCE)
    194 #	ori	8,8,(HID0_ICFI|HID0_ICE)
    195 	mtspr	SPR_HID0,8
    196 	isync
    197 8:	sync
    198 	mfspr	8,SPR_HID0
    199 	andi.	0,8,(HID0_ICFI|HID0_DCFI)
    200 	bne	8b
    201 #endif
    202 
    203 #if 0
    204 	mfspr	8,SPR_L2CR
    205 	oris	8,8,L2CR_L2E@h
    206 	sync
    207 	mtspr	SPR_L2CR,8
    208 	sync
    209 #endif
    210 16:
    211 #endif
    212 
    213 /* compute end of kernel memory */
    214 	lis	8,_C_LABEL(end)@ha
    215 	addi	8,8,_C_LABEL(end)@l
    216 #if NKSYMS || defined(DDB) || defined(MODULAR)
    217 	lis	7,_C_LABEL(startsym)@ha
    218 	addi	7,7,_C_LABEL(startsym)@l
    219 	stw	3,0(7)
    220 	lis	7,_C_LABEL(endsym)@ha
    221 	addi	7,7,_C_LABEL(endsym)@l
    222 	stw	4,0(7)
    223 /*	mr	8,4			* end of symbol table */
    224 #endif
    225 	mr	4,8			/* end of mem reserved for kernel */
    226 	INIT_CPUINFO(4,1,9,0)
    227 
    228 	lis	3,__start@ha
    229 	addi	3,3,__start@l
    230 	li	5,0
    231 	li	6,0
    232 
    233 	bl	_C_LABEL(initppc)
    234 	bl	_C_LABEL(main)
    235 
    236 loop:	b	loop			/* XXX not reached */
    237 
    238 #if 0
    239 	.globl	_C_LABEL(extintr_enable)
    240 _C_LABEL(extintr_enable):
    241 	mfmsr	3
    242 	ori	3,3,PSL_EE@l
    243 	sync
    244 	mtmsr	3
    245 	blr
    246 
    247 	.globl	_C_LABEL(extintr_restore)
    248 _C_LABEL(extintr_restore):
    249 	mfmsr	4
    250 	or	3,4,3
    251 	sync
    252 	mtmsr	3
    253 	blr
    254 
    255 	.globl	_C_LABEL(extintr_disable)
    256 _C_LABEL(extintr_disable):
    257 	mfmsr	3
    258 	andi.	4,3,~PSL_EE@l
    259 	sync
    260 	mtmsr	4
    261 	andi.	3,3,PSL_EE@l
    262 	blr
    263 
    264 	.globl	_C_LABEL(mvpppc_reboot)
    265 _C_LABEL(mvpppc_reboot):
    266 	mfmsr	3
    267 	ori	3,3,PSL_IP@l
    268 	sync
    269 	mtmsr	3
    270 	b	0xFFF00100
    271 #endif
    272 
    273 #ifdef DINK
    274 	.globl	_C_LABEL(return_to_dink)
    275 _C_LABEL(return_to_dink):
    276 	sync
    277 	lis	4, dink_stack@ha
    278 	lwz	1, dink_stack@l(4)
    279 	lis	4, dink_return@ha
    280 	lwz	5, dink_return@l(4)
    281 	mtlr	5
    282 	blr
    283 #endif
    284 
    285 /*
    286  * Include common switch / setfault code
    287  */
    288 #include <powerpc/powerpc/locore_subr.S>
    289 
    290 /*
    291  * Include common trap / exception code
    292  */
    293 #include <powerpc/powerpc/trap_subr.S>
    294 
    295 /*
    296  * Include PIO routines
    297  */
    298 #include <powerpc/powerpc/pio_subr.S>
    299