Home | History | Annotate | Line # | Download | only in ibmnws
      1 /*	$NetBSD: locore.S,v 1.13 2021/02/26 02:18:56 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
      5  * Copyright (C) 1995, 1996 TooLs GmbH.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *	This product includes software developed by TooLs GmbH.
     19  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     30  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     31  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #include "opt_ddb.h"
     35 #include "opt_lockdebug.h"
     36 #include "opt_ppcparam.h"
     37 #include "assym.h"
     38 
     39 #include <sys/syscall.h>
     40 
     41 #include <machine/param.h>
     42 #include <machine/psl.h>
     43 #include <machine/trap.h>
     44 #include <machine/asm.h>
     45 
     46 #include <powerpc/spr.h>
     47 #include <powerpc/oea/spr.h>
     48 #include <powerpc/oea/hid.h>
     49 
     50 /*
     51  * Some instructions gas doesn't understand (yet?)
     52  */
     53 #define	bdneq	bdnzf 2,
     54 
     55 /*
     56  * Globals
     57  */
     58 GLOBAL(startsym)
     59 	.long	0			/* start symbol table */
     60 GLOBAL(endsym)
     61 	.long	0			/* end symbol table */
     62 /*
     63 
     64  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     65  * mark the start of kernel text.
     66  */
     67 	.text
     68 	.globl	_C_LABEL(kernel_text)
     69 _C_LABEL(kernel_text):
     70 
     71 /*
     72  * Startup entry.  Note, this must be the first thing in the text
     73  * segment!
     74  */
     75 	.text
     76 	.globl	__start
     77 __start:
     78 
     79         bl      __start_
     80         nop
     81         nop
     82         .long   0x33
     83         .string "XncdPPC"
     84 
     85         /*
     86          * These next two entries are patched at the end of
     87          * of the build
     88          */
     89 
     90         .long   0xffff0000      /* 16 bit CRC */
     91         .long   0xffffffff      /* Image size */
     92 
     93         /* More magic numbers */
     94 
     95         .long   0x00092214
     96         .long   0x00000000
     97         .long   0x39771c2a
     98         .long   0x00000010
     99 
    100 __start_:
    101 
    102 	li	0,0
    103 	mtmsr	0			/* Disable FPU/MMU/exceptions */
    104 	isync
    105 
    106 /* compute end of kernel memory */
    107 	lis	8,_C_LABEL(end)@ha
    108 	addi	8,8,_C_LABEL(end)@l
    109 #if defined(DDB)
    110 	lis	7,_C_LABEL(startsym)@ha
    111 	addi	7,7,_C_LABEL(startsym)@l
    112 	stw	3,0(7)
    113 	lis	7,_C_LABEL(endsym)@ha
    114 	addi	7,7,_C_LABEL(endsym)@l
    115 	stw	4,0(7)
    116 #endif
    117 	mr	4,8
    118 	INIT_CPUINFO(4,1,9,0)
    119 
    120 	lis	3,__start@ha
    121 	addi	3,3,__start@l
    122 
    123 	bl	_C_LABEL(initppc)
    124 
    125 /* enable internal i/d-cache */
    126 
    127 	mfspr	11,SPR_HID0
    128 	andi.	0,11,HID0_DCE
    129 	ori	11,11,HID0_ICE|HID0_DCE
    130 	ori	8,11,HID0_ICFI
    131 	bne	1f			/* don't invalidate the D-cache */
    132 	ori	8,8,HID0_DCFI		/* unless it wasn't enabled */
    133 1:
    134 	sync
    135 	mtspr	SPR_HID0,8		/* enable and invalidate caches */
    136 	sync
    137 	mtspr	SPR_HID0,11		/* enable caches */
    138 	sync
    139 	isync
    140 
    141 	bl	_C_LABEL(main)
    142 
    143 loop:
    144 	b	loop			/* not reached */
    145 
    146 	.globl	_C_LABEL(enable_intr)
    147 _C_LABEL(enable_intr):
    148 	mfmsr	3
    149 	ori	4,3,PSL_EE@l
    150 	mtmsr	4
    151 	blr
    152 
    153 	.globl	_C_LABEL(disable_intr)
    154 _C_LABEL(disable_intr):
    155 	mfmsr	3
    156 	andi.	4,3,~PSL_EE@l
    157 	mtmsr	4
    158 	blr
    159 
    160 /*
    161  * Pull in common switch / setfault code.
    162  */
    163 #include <powerpc/powerpc/locore_subr.S>
    164 
    165 /*
    166  * Pull in common trap vector code.
    167  */
    168 #include <powerpc/powerpc/trap_subr.S>
    169 
    170 /*
    171  * Pull in common pio / bus_space code.
    172  */
    173 #include <powerpc/powerpc/pio_subr.S>
    174