Home | History | Annotate | Line # | Download | only in wii
      1  1.3  jmcneill /*	$NetBSD: wii_locore.S,v 1.3 2024/10/13 16:21:37 jmcneill Exp $	*/
      2  1.1  jmcneill /*	$OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $	*/
      3  1.1  jmcneill 
      4  1.1  jmcneill /*
      5  1.1  jmcneill  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      6  1.1  jmcneill  * Copyright (C) 1995, 1996 TooLs GmbH.
      7  1.1  jmcneill  * All rights reserved.
      8  1.1  jmcneill  *
      9  1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
     10  1.1  jmcneill  * modification, are permitted provided that the following conditions
     11  1.1  jmcneill  * are met:
     12  1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     13  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     14  1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     16  1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     17  1.1  jmcneill  * 3. All advertising materials mentioning features or use of this software
     18  1.1  jmcneill  *    must display the following acknowledgement:
     19  1.1  jmcneill  *	This product includes software developed by TooLs GmbH.
     20  1.1  jmcneill  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     21  1.1  jmcneill  *    derived from this software without specific prior written permission.
     22  1.1  jmcneill  *
     23  1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     24  1.1  jmcneill  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1  jmcneill  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1  jmcneill  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27  1.1  jmcneill  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     28  1.1  jmcneill  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     29  1.1  jmcneill  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     30  1.1  jmcneill  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     31  1.1  jmcneill  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     32  1.1  jmcneill  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  1.1  jmcneill  */
     34  1.1  jmcneill 
     35  1.1  jmcneill #include "opt_ddb.h"
     36  1.1  jmcneill #include "opt_kgdb.h"
     37  1.1  jmcneill #include "opt_ppcparam.h"
     38  1.1  jmcneill #include "assym.h"
     39  1.1  jmcneill 
     40  1.1  jmcneill #include <sys/syscall.h>
     41  1.1  jmcneill 
     42  1.1  jmcneill #include <machine/param.h>
     43  1.1  jmcneill #include <machine/psl.h>
     44  1.1  jmcneill #include <machine/trap.h>
     45  1.1  jmcneill #include <machine/asm.h>
     46  1.1  jmcneill 
     47  1.1  jmcneill #include <powerpc/spr.h>
     48  1.1  jmcneill #include <powerpc/oea/spr.h>
     49  1.1  jmcneill #include <powerpc/oea/hid.h>
     50  1.1  jmcneill 
     51  1.1  jmcneill #include "ksyms.h"
     52  1.1  jmcneill 
     53  1.1  jmcneill /*
     54  1.1  jmcneill  * Some instructions gas doesn't understand (yet?)
     55  1.1  jmcneill  */
     56  1.1  jmcneill #define	bdneq	bdnzf 2,
     57  1.1  jmcneill 
     58  1.1  jmcneill /*
     59  1.1  jmcneill  * Globals
     60  1.1  jmcneill  */
     61  1.1  jmcneill GLOBAL(startsym)
     62  1.1  jmcneill 	.long	0			/* start symbol table */
     63  1.1  jmcneill GLOBAL(endsym)
     64  1.1  jmcneill 	.long	0			/* end symbol table */
     65  1.1  jmcneill /*
     66  1.1  jmcneill  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     67  1.1  jmcneill  * mark the start of kernel text.
     68  1.1  jmcneill  */
     69  1.1  jmcneill 	.text
     70  1.1  jmcneill 	.globl	_C_LABEL(kernel_text)
     71  1.1  jmcneill _C_LABEL(kernel_text):
     72  1.1  jmcneill 
     73  1.1  jmcneill /*
     74  1.1  jmcneill  * Startup entry.  Note, this must be the first thing in the text
     75  1.1  jmcneill  * segment!
     76  1.1  jmcneill  */
     77  1.1  jmcneill 	.text
     78  1.1  jmcneill 	.globl	__start
     79  1.1  jmcneill __start:
     80  1.2  jmcneill 	b	__mmu_init
     81  1.1  jmcneill 
     82  1.2  jmcneill 	/*
     83  1.2  jmcneill 	 * Command-line argument protocol supported by HBC.
     84  1.2  jmcneill 	 */
     85  1.2  jmcneill 	.long	0x5f617267	/* WII_ARGV_MAGIC */
     86  1.2  jmcneill 	.globl	_C_LABEL(wii_argv)
     87  1.2  jmcneill _C_LABEL(wii_argv):
     88  1.2  jmcneill 	.long	0		/* argv magic, set by loader */
     89  1.2  jmcneill 	.long	0		/* command line */
     90  1.2  jmcneill 	.long	0		/* command line length */
     91  1.2  jmcneill 	.long	0		/* argc */
     92  1.2  jmcneill 	.long	0		/* argv */
     93  1.2  jmcneill 	.long	0		/* end of argv */
     94  1.2  jmcneill 
     95  1.2  jmcneill __mmu_init:
     96  1.1  jmcneill 	/* reset MMU to a known state */
     97  1.1  jmcneill #include "wii_mmuinit.S"
     98  1.1  jmcneill 
     99  1.1  jmcneill 	/* compute end of kernel memory */
    100  1.3  jmcneill 	lis	%r4, _C_LABEL(end)@ha
    101  1.3  jmcneill 	addi	%r4, %r4, _C_LABEL(end)@l
    102  1.3  jmcneill 
    103  1.3  jmcneill #if NKSYMS || defined(DDB) || defined(MODULAR)
    104  1.3  jmcneill 	/* If we had symbol table location we'd store it here and would've adjusted r4 here */
    105  1.3  jmcneill 	lis	%r7, _C_LABEL(startsym)@ha
    106  1.3  jmcneill 	addi	%r7, %r7, _C_LABEL(startsym)@l
    107  1.3  jmcneill 	stw	%r4, 0(%r7)
    108  1.3  jmcneill 	lis	%r7, _C_LABEL(endsym)@ha
    109  1.3  jmcneill 	addi	%r7, %r7,_C_LABEL(endsym)@l
    110  1.3  jmcneill 	stw	%r4, 0(%r7)
    111  1.3  jmcneill #endif
    112  1.3  jmcneill 
    113  1.3  jmcneill 	lis	%r1, 0
    114  1.3  jmcneill 	INIT_CPUINFO(%r4, %r1, %r9, %r0)
    115  1.3  jmcneill 
    116  1.3  jmcneill 	lis	%r3, __start@ha
    117  1.3  jmcneill 	addi	%r3, %r3, __start@l
    118  1.3  jmcneill 
    119  1.3  jmcneill 	xor	%r5, %r5, %r5
    120  1.3  jmcneill 	xor	%r6, %r6, %r6
    121  1.1  jmcneill 	bl	_C_LABEL(initppc)
    122  1.1  jmcneill 
    123  1.1  jmcneill 	sync
    124  1.1  jmcneill 	isync
    125  1.3  jmcneill 	mfspr	%r8, SPR_HID0
    126  1.3  jmcneill 	ori	%r8, %r8, (HID0_ICE | HID0_DCE)@l
    127  1.1  jmcneill 	isync
    128  1.3  jmcneill 	mtspr	SPR_HID0, %r8
    129  1.1  jmcneill 	sync
    130  1.1  jmcneill 	isync
    131  1.1  jmcneill 
    132  1.1  jmcneill 	bl	_C_LABEL(main)
    133  1.1  jmcneill 
    134  1.1  jmcneill loop:	b	loop			/* XXX not reached */
    135  1.1  jmcneill 
    136  1.1  jmcneill 	.globl	_C_LABEL(enable_intr)
    137  1.1  jmcneill _C_LABEL(enable_intr):
    138  1.3  jmcneill 	mfmsr	%r3
    139  1.3  jmcneill 	ori	%r3, %r3, PSL_EE@l
    140  1.3  jmcneill 	mtmsr	%r3
    141  1.1  jmcneill 	blr
    142  1.1  jmcneill 
    143  1.1  jmcneill 	.globl	_C_LABEL(disable_intr)
    144  1.1  jmcneill _C_LABEL(disable_intr):
    145  1.3  jmcneill 	mfmsr	%r3
    146  1.3  jmcneill  	andi.	%r3, %r3, ~PSL_EE@l
    147  1.3  jmcneill 	mtmsr	%r3
    148  1.1  jmcneill 	blr
    149  1.1  jmcneill 
    150  1.1  jmcneill /*
    151  1.1  jmcneill  * Include common switch / setfault code
    152  1.1  jmcneill  */
    153  1.1  jmcneill #include <powerpc/powerpc/locore_subr.S>
    154  1.1  jmcneill 
    155  1.1  jmcneill /*
    156  1.1  jmcneill  * Include common trap / exception code
    157  1.1  jmcneill  */
    158  1.1  jmcneill #include <powerpc/powerpc/trap_subr.S>
    159  1.1  jmcneill 
    160  1.1  jmcneill /*
    161  1.1  jmcneill  * Include PIO routines
    162  1.1  jmcneill  */
    163  1.1  jmcneill #include <powerpc/powerpc/pio_subr.S>
    164