locore32.S revision 139825
1317017Sdim/* $FreeBSD: head/sys/powerpc/aim/locore.S 139825 2005-01-07 02:29:27Z imp $ */ 2317017Sdim/* $NetBSD: locore.S,v 1.24 2000/05/31 05:09:17 thorpej Exp $ */ 3353358Sdim 4353358Sdim/*- 5353358Sdim * Copyright (C) 2001 Benno Rice 6317017Sdim * All rights reserved. 7317017Sdim * 8317017Sdim * Redistribution and use in source and binary forms, with or without 9317017Sdim * modification, are permitted provided that the following conditions 10317017Sdim * are met: 11317017Sdim * 1. Redistributions of source code must retain the above copyright 12317017Sdim * notice, this list of conditions and the following disclaimer. 13317017Sdim * 2. Redistributions in binary form must reproduce the above copyright 14317017Sdim * notice, this list of conditions and the following disclaimer in the 15317017Sdim * documentation and/or other materials provided with the distribution. 16317017Sdim * 17317017Sdim * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR 18317017Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19317017Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20317017Sdim * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21317017Sdim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22317017Sdim * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23317017Sdim * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24317017Sdim * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25317017Sdim * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26317017Sdim * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27317017Sdim */ 28317017Sdim/*- 29317017Sdim * Copyright (C) 1995, 1996 Wolfgang Solfrank. 30317017Sdim * Copyright (C) 1995, 1996 TooLs GmbH. 31317017Sdim * All rights reserved. 32317017Sdim * 33317017Sdim * Redistribution and use in source and binary forms, with or without 34317017Sdim * modification, are permitted provided that the following conditions 35317017Sdim * are met: 36317017Sdim * 1. Redistributions of source code must retain the above copyright 37317017Sdim * notice, this list of conditions and the following disclaimer. 38317017Sdim * 2. Redistributions in binary form must reproduce the above copyright 39317017Sdim * notice, this list of conditions and the following disclaimer in the 40317017Sdim * documentation and/or other materials provided with the distribution. 41317017Sdim * 3. All advertising materials mentioning features or use of this software 42317017Sdim * must display the following acknowledgement: 43317472Sdim * This product includes software developed by TooLs GmbH. 44317472Sdim * 4. The name of TooLs GmbH may not be used to endorse or promote products 45317472Sdim * derived from this software without specific prior written permission. 46317472Sdim * 47317472Sdim * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 48317472Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 49317472Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 50317472Sdim * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 51317472Sdim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 52317472Sdim * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 53317017Sdim * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 54317472Sdim * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 55317017Sdim * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 56317017Sdim * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57317017Sdim */ 58317017Sdim 59317017Sdim#include "assym.s" 60317017Sdim 61317017Sdim#include <sys/syscall.h> 62317017Sdim 63317017Sdim#include <machine/trap.h> 64317017Sdim#include <machine/param.h> 65317017Sdim#include <machine/sr.h> 66317017Sdim#include <machine/spr.h> 67317017Sdim#include <machine/psl.h> 68317017Sdim#include <machine/asm.h> 69317017Sdim 70317017Sdim/* Locate the per-CPU data structure */ 71317472Sdim#define GET_CPUINFO(r) \ 72317017Sdim mfsprg0 r 73317017Sdim 74317017Sdim/* 75317017Sdim * Globals 76317017Sdim */ 77317017Sdim .data 78317017SdimGLOBAL(tmpstk) 79317472Sdim .space 8208 80317017SdimGLOBAL(esym) 81353358Sdim .long 0 /* end of symbol table */ 82317017Sdim 83317017SdimGLOBAL(ofmsr) 84317017Sdim .long 0 /* msr used in Open Firmware */ 85317017Sdim 86317017SdimGLOBAL(powersave) 87317017Sdim .long 0 88317017Sdim 89317017Sdim#define INTSTK 16384 /* 16K interrupt stack */ 90317472Sdim#define INTRCNT_COUNT 256 /* max(HROWPIC_IRQMAX,OPENPIC_IRQMAX) */ 91317472SdimGLOBAL(intrnames) 92317017Sdim .space INTRCNT_COUNT * (MAXCOMLEN + 1) * 2 93317017SdimGLOBAL(eintrnames) 94317017Sdim .align 4 95317017SdimGLOBAL(intrcnt) 96317017Sdim .space INTRCNT_COUNT * 4 * 2 97317017SdimGLOBAL(eintrcnt) 98317017Sdim 99317017Sdim/* 100317472Sdim * File-scope for locore.S 101317017Sdim */ 102317017Sdimidle_u: 103317017Sdim .long 0 /* fake uarea during idle after exit */ 104317017Sdimopenfirmware_entry: 105317017Sdim .long 0 /* Open Firmware entry point */ 106317017Sdimsrsave: 107317017Sdim .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 108317017Sdim 109317017Sdim/* 110317017Sdim * This symbol is here for the benefit of kvm_mkdb, and is supposed to 111317017Sdim * mark the start of kernel text. 112317017Sdim */ 113317017Sdim .text 114317017Sdim .globl kernel_text 115317017Sdimkernel_text: 116317017Sdim 117317017Sdim/* 118317017Sdim * Startup entry. Note, this must be the first thing in the text 119317017Sdim * segment! 120317017Sdim */ 121317017Sdim .text 122317017Sdim .globl __start 123317017Sdim__start: 124317017Sdim#ifdef FIRMWORKSBUGS 125317017Sdim mfmsr 0 126317017Sdim andi. 0,0,PSL_IR|PSL_DR 127317017Sdim beq 1f 128317017Sdim 129317017Sdim bl ofwr_init 130317017Sdim1: 131317017Sdim#endif 132317017Sdim li 8,0 133317017Sdim li 9,0x100 134317017Sdim mtctr 9 135317017Sdim1: 136317017Sdim dcbf 0,8 137317017Sdim icbi 0,8 138317017Sdim addi 8,8,0x20 139317017Sdim bdnz 1b 140317017Sdim sync 141317017Sdim isync 142317017Sdim 143317017Sdim /* Save the argument pointer and length */ 144317017Sdim mr 20,6 145317472Sdim mr 21,7 146317472Sdim 147317472Sdim lis 8,openfirmware_entry@ha 148317472Sdim stw 5,openfirmware_entry@l(8) /* save client interface handler */ 149317472Sdim mr 3,5 150317472Sdim 151317472Sdim lis 1,tmpstk@ha 152317472Sdim addi 1,1,tmpstk@l 153317472Sdim addi 1,1,8192 154317017Sdim 155317017Sdim mfmsr 0 156317472Sdim lis 9,ofmsr@ha 157317017Sdim stw 0,ofmsr@l(9) 158317017Sdim 159317017Sdim bl OF_init 160317017Sdim 161317017Sdim lis 4,end@ha 162317472Sdim addi 4,4,end@l 163317017Sdim mr 5,4 164317472Sdim 165317472Sdim lis 3,kernel_text@ha 166317472Sdim addi 3,3,kernel_text@l 167317472Sdim 168317472Sdim /* Restore the argument pointer and length */ 169317472Sdim mr 6,20 170317472Sdim mr 7,21 171317017Sdim 172317472Sdim bl powerpc_init 173317472Sdim bl mi_startup 174317472Sdim b OF_exit 175317472Sdim 176317472Sdim/* 177317472Sdim * int setfault() 178317472Sdim * 179317472Sdim * Similar to setjmp to setup for handling faults on accesses to user memory. 180317017Sdim * Any routine using this may only call bcopy, either the form below, 181317017Sdim * or the (currently used) C code optimized, so it doesn't use any non-volatile 182317472Sdim * registers. 183317472Sdim */ 184317472Sdim .globl setfault 185317472Sdimsetfault: 186317472Sdim mflr 0 187317472Sdim mfcr 12 188317472Sdim mfsprg 4,0 189317472Sdim lwz 4,PC_CURTHREAD(4) 190317472Sdim lwz 4,TD_PCB(4) 191317472Sdim stw 3,PCB_ONFAULT(4) 192317472Sdim stw 0,0(3) 193317472Sdim stw 1,4(3) 194317472Sdim stw 2,8(3) 195317472Sdim stmw 12,12(3) 196317472Sdim xor 3,3,3 197317472Sdim blr 198317472Sdim 199317472Sdim#include <powerpc/powerpc/trap_subr.S> 200317472Sdim