2 /* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */
5 * Copyright (C) 2001 Benno Rice
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
17 * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
30 * Copyright (C) 1995, 1996 TooLs GmbH.
31 * All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution.
41 * 3. All advertising materials mentioning features or use of this software
42 * must display the following acknowledgement:
43 * This product includes software developed by TooLs GmbH.
44 * 4. The name of TooLs GmbH may not be used to endorse or promote products
45 * derived from this software without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
52 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
53 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
54 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
55 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
56 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 #include "opt_ipkdb.h"
63 #include <sys/syscall.h>
65 #include <machine/trap.h>
66 #include <machine/param.h>
67 #include <machine/sr.h>
68 #include <machine/spr.h>
69 #include <machine/psl.h>
70 #include <machine/asm.h>
73 * Some instructions gas doesn't understand (yet?)
75 #define bdneq bdnzf 2,
84 .long 0 /* end of symbol table */
86 .long 0 /* proc0 p_addr */
93 .asciz "irq0", "irq1", "irq2", "irq3"
94 .asciz "irq4", "irq5", "irq6", "irq7"
95 .asciz "irq8", "irq9", "irq10", "irq11"
96 .asciz "irq12", "irq13", "irq14", "irq15"
97 .asciz "irq16", "irq17", "irq18", "irq19"
98 .asciz "irq20", "irq21", "irq22", "irq23"
99 .asciz "irq24", "irq25", "irq26", "irq27"
100 .asciz "irq28", "irq29", "irq30", "irq31"
101 .asciz "irq32", "irq33", "irq34", "irq35"
102 .asciz "irq36", "irq37", "irq38", "irq39"
103 .asciz "irq40", "irq41", "irq42", "irq43"
104 .asciz "irq44", "irq45", "irq46", "irq47"
105 .asciz "irq48", "irq49", "irq50", "irq51"
106 .asciz "irq52", "irq53", "irq54", "irq55"
107 .asciz "irq56", "irq57", "irq58", "irq59"
108 .asciz "irq60", "irq61", "irq62", "irq63"
109 .asciz "clock", "softclock", "softnet", "softserial"
113 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
114 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
115 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
116 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
121 .long 0 /* msr used in Open Firmware */
126 #define INTSTK 8192 /* 8K interrupt stack */
127 #define SPILLSTK 4096 /* 4K spill stack */
130 * File-scope for locore.S
133 .long 0 /* fake uarea during idle after exit */
135 .long 0 /* openfirmware entry point */
137 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
140 * This symbol is here for the benefit of kvm_mkdb, and is supposed to
141 * mark the start of kernel text.
148 * Startup entry. Note, this must be the first thing in the text
156 andi. 0,0,PSL_IR|PSL_DR
190 lis 8,openfirmware_entry@ha
191 stw 5,openfirmware_entry@l(8) /* save client interface handler */
214 stw 4,proc0paddr@l(9)
215 addi 4,4,USPACE-FRAMELEN
221 addi 3,3,kernel_text@l
230 #if 0 /* XXX: We may switch back to this in the future. */
232 * OpenFirmware entry point
235 mflr 0 /* save return address */
237 stwu 1,-16(1) /* setup stack frame */
239 mfmsr 4 /* save msr */
242 lis 4,openfirmware_entry@ha /* get firmware entry point */
243 lwz 4,openfirmware_entry@l(4)
246 li 0,0 /* clear battable translations */
252 lis 4,ofmsr@ha /* Open Firmware msr */
257 lis 4,srsave@ha /* save old SR */
263 addis 5,5,0x10000000@h
267 lis 4,ofw_pmap@ha /* load OFW SR */
270 cmpwi 0,0 /* pm_sr[KERNEL_SR] == 0? */
271 beq 2f /* then skip (not initialized yet) */
276 addis 5,5,0x10000000@h
280 blrl /* call Open Firmware */
288 lis 4,srsave@ha /* restore saved SR */
294 addis 5,5,0x10000000@h
298 lwz 4,8(1) /* restore msr */
302 lwz 1,0(1) /* and return */
309 * Switch to/from OpenFirmware real mode stack
311 * Note: has to be called as the very first thing in OpenFirmware interface
335 * if (openfirmware(&args) < 0)
342 .comm firmstk,PAGE_SIZE,8
345 mfmsr 8 /* turn off interrupts */
346 andi. 0,8,~(PSL_EE|PSL_RI)@l
348 stw 8,4(1) /* abuse return address slot */
350 lwz 5,0(1) /* get length of stack frame */
353 lis 7,firmstk+PAGE_SIZE-8@ha
354 addi 7,7,firmstk+PAGE_SIZE-8@l
357 subf 4,5,7 /* make room for stack frame on
359 stw 6,-4(7) /* setup return pointer */
387 lwz 1,0(1) /* get callers original stack pointer */
389 lwz 0,4(1) /* get saved msr from abused slot */
392 lwz 1,0(1) /* return */
400 * Similar to setjmp to setup for handling faults on accesses to user memory.
401 * Any routine using this may only call bcopy, either the form below,
402 * or the (currently used) C code optimized, so it doesn't use any non-volatile
410 lwz 4,PC_CURTHREAD(4)
420 #include <powerpc/powerpc/trap_subr.S>