Home | History | Annotate | Line # | Download | only in ev64260
      1 /*	$NetBSD: ev64260_locore.S,v 1.21 2021/02/26 02:18:56 thorpej 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_modular.h"
     38 #include "opt_multiprocessor.h"
     39 #include "opt_openpic.h"
     40 #include "assym.h"
     41 
     42 #include <sys/syscall.h>
     43 
     44 #include <machine/param.h>
     45 #include <machine/psl.h>
     46 #include <machine/trap.h>
     47 #include <machine/asm.h>
     48 
     49 #include <powerpc/spr.h>
     50 #include <powerpc/oea/spr.h>
     51 #include <powerpc/oea/bat.h>
     52 #include <powerpc/oea/hid.h>
     53 
     54 /*
     55  * Some instructions gas doesn't understand (yet?)
     56  */
     57 #define	bdneq	bdnzf 2,
     58 
     59 /*
     60  * Globals
     61  */
     62 GLOBAL(startsym)
     63 	.long	0			/* start symbol table */
     64 GLOBAL(endsym)
     65 	.long	0			/* end symbol table */
     66 /*
     67  * File-scope for locore.S
     68  */
     69 #ifdef DINK
     70 	.data
     71 dink_return:
     72 	.long	0			/* fake uarea during idle after exit */
     73 dink_stack:
     74 	.long	0			/* fake uarea during idle after exit */
     75 #endif
     76 
     77 
     78 /*
     79  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     80  * mark the start of kernel text.
     81  */
     82 	.text
     83 	.globl	_C_LABEL(kernel_text)
     84 _C_LABEL(kernel_text):
     85 
     86 /*
     87  * Startup entry.  Note, this must be the first thing in the text
     88  * segment!
     89  */
     90 	.text
     91 	.globl	__start
     92 __start:
     93 #ifdef DINK
     94 	mflr	0
     95 	lis	8, dink_stack@ha
     96 	stw	1, dink_stack@l(8)
     97 	lis	8, dink_return@ha
     98 	stw	0, dink_return@l(8)
     99 #endif
    100 
    101 #if 0
    102 	eieio; sync
    103 	lis	8, 0xf100f104@ha
    104 	lwz	7, -3836(8)
    105 	li	0, 1
    106 	andc	7,7,0
    107 	stw	7, -3836(8)
    108 	eieio; sync
    109 #endif
    110 
    111 	/*
    112 	 * Make sure that .bss is zeroed.
    113 	 */
    114 	li	0,0
    115 	lis	8,edata@ha
    116 	addi	8,8,edata@l
    117 	lis	9,end@ha
    118 	addi	9,9,end@l
    119 5:	cmpw	0,8,9			/* edata & end are >= word aligned */
    120 	bge	6f
    121 	stw	0,0(8)
    122 	addi	8,8,4
    123 	b	5b
    124 6:
    125 
    126 	li	0,0
    127 	mtmsr	0			/* Disable FPU/MMU/exceptions */
    128 	sync ; isync
    129 
    130 #if 1
    131 	mfpvr	0
    132 	srwi	0,0,16
    133 	cmplwi	0,MPC7410
    134 	bne	16f
    135 
    136 #if 0
    137 	/* flush and disable L2 */
    138 	mfspr	8,SPR_L2CR
    139 	lis	0,(L2CR_L2E|L2CR_L2WT)@h	/* disable the L2 mode */
    140 	andc	8,8,0
    141 	ori	8,8,L2CR_L2HWF		/* enable hardware flush */
    142 	sync
    143 	mtspr	SPR_L2CR,8		/* do it */
    144 	sync				/* wait for it to finish */
    145 
    146 	/* Disable data lock mode */
    147 	mfspr	8,SPR_HID0
    148 	li	0,HID0_DLOCK
    149 	andc	8,8,0
    150 	mtspr	SPR_HID0,8
    151 	sync
    152 #endif
    153 #if 0
    154 	/*
    155 	 * Flush the L1 cache
    156 	 */
    157 	mfspr	8,SPR_MSSCR0
    158 	oris	8,8,MSSCR0_DL1HWF@h
    159 	sync
    160 	mtspr	SPR_MSSCR0,8
    161 	sync
    162 #endif
    163 #if 1
    164 	/* disable data and instruction caches */
    165 	mfspr	8,SPR_HID0
    166 	li	0,HID0_DLOCK@l
    167 	andc	8,8,0
    168 	sync
    169 	mtspr	SPR_HID0,8
    170 	sync
    171 	isync
    172 #endif
    173 7:
    174 #if 0
    175 	/* disable data and instruction caches */
    176 	mfspr	8,SPR_HID0
    177 	li	0,(HID0_ICE|HID0_DCE)@l
    178 	andc	8,8,0
    179 	sync
    180 	mtspr	SPR_HID0,8
    181 	sync
    182 	isync
    183 #endif
    184 7:
    185 #if 0
    186 	/* Enable and flush data and instruction caches */
    187 	ori	8,8,(HID0_ICFI|HID0_ICE|HID0_DCFI|HID0_DCE)
    188 #	ori	8,8,(HID0_ICFI|HID0_ICE)
    189 	mtspr	SPR_HID0,8
    190 	isync
    191 8:	sync
    192 	mfspr	8,SPR_HID0
    193 	andi.	0,8,(HID0_ICFI|HID0_DCFI)
    194 	bne	8b
    195 #endif
    196 
    197 #if 0
    198 	mfspr	8,SPR_L2CR
    199 	oris	8,8,L2CR_L2E@h
    200 	sync
    201 	mtspr	SPR_L2CR,8
    202 	sync
    203 #endif
    204 16:
    205 #endif
    206 
    207 /* compute end of kernel memory */
    208 	lis	8,_C_LABEL(end)@ha
    209 	addi	8,8,_C_LABEL(end)@l
    210 #if NKSYMS || defined(DDB) || defined(MODULAR)
    211 	lis	7,_C_LABEL(startsym)@ha
    212 	addi	7,7,_C_LABEL(startsym)@l
    213 	stw	3,0(7)
    214 	lis	7,_C_LABEL(endsym)@ha
    215 	addi	7,7,_C_LABEL(endsym)@l
    216 	stw	4,0(7)
    217 /*	mr	8,4			* end of symbol table */
    218 #endif
    219 	mr	4,8			/* end of mem reserved for kernel */
    220 	INIT_CPUINFO(4,1,9,0)
    221 
    222 	lis	3,__start@ha
    223 	addi	3,3,__start@l
    224 	li	5,0
    225 	li	6,0
    226 
    227 	bl	_C_LABEL(cpu_model_init)
    228 	bl	_C_LABEL(initppc)
    229 	bl	_C_LABEL(main)
    230 
    231 loop:	b	loop			/* XXX not reached */
    232 
    233 #if 0
    234 	.globl	_C_LABEL(extintr_enable)
    235 _C_LABEL(extintr_enable):
    236 	mfmsr	3
    237 	ori	3,3,PSL_EE@l
    238 	sync
    239 	mtmsr	3
    240 	blr
    241 
    242 	.globl	_C_LABEL(extintr_restore)
    243 _C_LABEL(extintr_restore):
    244 	mfmsr	4
    245 	or	3,4,3
    246 	sync
    247 	mtmsr	3
    248 	blr
    249 
    250 	.globl	_C_LABEL(extintr_disable)
    251 _C_LABEL(extintr_disable):
    252 	mfmsr	3
    253 	andi.	4,3,~PSL_EE@l
    254 	sync
    255 	mtmsr	4
    256 	andi.	3,3,PSL_EE@l
    257 	blr
    258 
    259 	.globl	_C_LABEL(mvpppc_reboot)
    260 _C_LABEL(mvpppc_reboot):
    261 	mfmsr	3
    262 	ori	3,3,PSL_IP@l
    263 	sync
    264 	mtmsr	3
    265 	b	0xFFF00100
    266 #endif
    267 
    268 #ifdef DINK
    269 	.globl	_C_LABEL(return_to_dink)
    270 _C_LABEL(return_to_dink):
    271 	sync
    272 	lis	4, dink_stack@ha
    273 	lwz	1, dink_stack@l(4)
    274 	lis	4, dink_return@ha
    275 	lwz	5, dink_return@l(4)
    276 	mtlr	5
    277 	blr
    278 #endif
    279 
    280 /*
    281  * Include common switch / setfault code
    282  */
    283 #include <powerpc/powerpc/locore_subr.S>
    284 
    285 /*
    286  * Include common trap / exception code
    287  */
    288 #include <powerpc/powerpc/trap_subr.S>
    289 
    290 /*
    291  * Include PIO routines
    292  */
    293 #include <powerpc/powerpc/pio_subr.S>
    294