Home | History | Annotate | Line # | Download | only in wii
      1 /*	$NetBSD: wii_locore.S,v 1.3 2024/10/13 16:21:37 jmcneill 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_kgdb.h"
     37 #include "opt_ppcparam.h"
     38 #include "assym.h"
     39 
     40 #include <sys/syscall.h>
     41 
     42 #include <machine/param.h>
     43 #include <machine/psl.h>
     44 #include <machine/trap.h>
     45 #include <machine/asm.h>
     46 
     47 #include <powerpc/spr.h>
     48 #include <powerpc/oea/spr.h>
     49 #include <powerpc/oea/hid.h>
     50 
     51 #include "ksyms.h"
     52 
     53 /*
     54  * Some instructions gas doesn't understand (yet?)
     55  */
     56 #define	bdneq	bdnzf 2,
     57 
     58 /*
     59  * Globals
     60  */
     61 GLOBAL(startsym)
     62 	.long	0			/* start symbol table */
     63 GLOBAL(endsym)
     64 	.long	0			/* end symbol table */
     65 /*
     66  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     67  * mark the start of kernel text.
     68  */
     69 	.text
     70 	.globl	_C_LABEL(kernel_text)
     71 _C_LABEL(kernel_text):
     72 
     73 /*
     74  * Startup entry.  Note, this must be the first thing in the text
     75  * segment!
     76  */
     77 	.text
     78 	.globl	__start
     79 __start:
     80 	b	__mmu_init
     81 
     82 	/*
     83 	 * Command-line argument protocol supported by HBC.
     84 	 */
     85 	.long	0x5f617267	/* WII_ARGV_MAGIC */
     86 	.globl	_C_LABEL(wii_argv)
     87 _C_LABEL(wii_argv):
     88 	.long	0		/* argv magic, set by loader */
     89 	.long	0		/* command line */
     90 	.long	0		/* command line length */
     91 	.long	0		/* argc */
     92 	.long	0		/* argv */
     93 	.long	0		/* end of argv */
     94 
     95 __mmu_init:
     96 	/* reset MMU to a known state */
     97 #include "wii_mmuinit.S"
     98 
     99 	/* compute end of kernel memory */
    100 	lis	%r4, _C_LABEL(end)@ha
    101 	addi	%r4, %r4, _C_LABEL(end)@l
    102 
    103 #if NKSYMS || defined(DDB) || defined(MODULAR)
    104 	/* If we had symbol table location we'd store it here and would've adjusted r4 here */
    105 	lis	%r7, _C_LABEL(startsym)@ha
    106 	addi	%r7, %r7, _C_LABEL(startsym)@l
    107 	stw	%r4, 0(%r7)
    108 	lis	%r7, _C_LABEL(endsym)@ha
    109 	addi	%r7, %r7,_C_LABEL(endsym)@l
    110 	stw	%r4, 0(%r7)
    111 #endif
    112 
    113 	lis	%r1, 0
    114 	INIT_CPUINFO(%r4, %r1, %r9, %r0)
    115 
    116 	lis	%r3, __start@ha
    117 	addi	%r3, %r3, __start@l
    118 
    119 	xor	%r5, %r5, %r5
    120 	xor	%r6, %r6, %r6
    121 	bl	_C_LABEL(initppc)
    122 
    123 	sync
    124 	isync
    125 	mfspr	%r8, SPR_HID0
    126 	ori	%r8, %r8, (HID0_ICE | HID0_DCE)@l
    127 	isync
    128 	mtspr	SPR_HID0, %r8
    129 	sync
    130 	isync
    131 
    132 	bl	_C_LABEL(main)
    133 
    134 loop:	b	loop			/* XXX not reached */
    135 
    136 	.globl	_C_LABEL(enable_intr)
    137 _C_LABEL(enable_intr):
    138 	mfmsr	%r3
    139 	ori	%r3, %r3, PSL_EE@l
    140 	mtmsr	%r3
    141 	blr
    142 
    143 	.globl	_C_LABEL(disable_intr)
    144 _C_LABEL(disable_intr):
    145 	mfmsr	%r3
    146  	andi.	%r3, %r3, ~PSL_EE@l
    147 	mtmsr	%r3
    148 	blr
    149 
    150 /*
    151  * Include common switch / setfault code
    152  */
    153 #include <powerpc/powerpc/locore_subr.S>
    154 
    155 /*
    156  * Include common trap / exception code
    157  */
    158 #include <powerpc/powerpc/trap_subr.S>
    159 
    160 /*
    161  * Include PIO routines
    162  */
    163 #include <powerpc/powerpc/pio_subr.S>
    164