1/* $NetBSD: locore.S,v 1.4 2001/08/30 02:08:45 briggs 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 "fs_kernfs.h" 37#include "opt_ipkdb.h" 38#include "opt_multiprocessor.h" 39#include "opt_openpic.h" 40#include "assym.h" 41 42#include <sys/syscall.h> 43 44#include <machine/param.h> 45#include <machine/vmparam.h> 46#include <machine/pmap.h> 47#include <machine/psl.h> 48#include <machine/trap.h> 49#include <machine/asm.h> 50 51#include <powerpc/spr.h> 52#include <powerpc/mpc6xx/hid.h> 53 54/* 55 * Some instructions gas doesn't understand (yet?) 56 */ 57#define bdneq bdnzf 2, 58 59#define INTSTK 8192 60#define SPILLSTK 4096 61 62/* 63 * Globals 64 */ 65GLOBAL(startsym) 66 .long 0 /* start symbol table */ 67GLOBAL(endsym) 68 .long 0 /* end symbol table */ 69GLOBAL(proc0paddr) 70 .long 0 /* proc0 p_addr */ 71 72GLOBAL(intrnames) 73#if defined(OPENPIC_SERIAL_MODE) 74 .asciz "sioint", "unknown", "pci0", "pci1" 75 .asciz "pci2", "pci3", "winbondA", "winbondB" 76 .asciz "winbondC", "winbondD", "rsvd10", "rsvd11" 77 .asciz "rsvd12", "rsvd13", "rsvd14", "rsvd15" 78 .asciz "sercon", "i2c", "dma0", "dma1" 79 .asciz "i2o", "timer0", "timer1", "timer2" 80 .asciz "timer3" 81#else 82 .asciz "pci0", "pci1", "pci2", "pci3" 83 .asciz "sercon", "i2c", "dma0", "dma1" 84 .asciz "i2o", "timer0", "timer1", "timer2" 85 .asciz "timer3", "unused0", "unused1", "unused2" 86 .asciz "unused3", "unused4", "unused5", "unused6" 87 .asciz "unused7", "unused8", "unused9", "unused10" 88 .asciz "unused11" 89#endif 90 91GLOBAL(eintrnames) 92 .align 4 93GLOBAL(intrcnt) 94 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 95 .long 0,0,0,0,0,0,0,0,0 96GLOBAL(eintrcnt) 97 98/* 99 * File-scope for locore.S 100 */ 101 .data 102idle_u: 103 .long 0 /* fake uarea during idle after exit */ 104 105/* 106 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 107 * mark the start of kernel text. 108 */ 109 .text 110 .globl _C_LABEL(kernel_text) 111_C_LABEL(kernel_text): 112 113/* 114 * Startup entry. Note, this must be the first thing in the text 115 * segment! 116 */ 117 .text 118 .globl __start 119__start: 120 li 0,0 121 mtmsr 0 /* Disable FPU/MMU/exceptions */ 122 isync 123 124 /* Enable data and instruction caches */ 125 mfspr 8,1008 126 ori 8, 8, (HID0_ICE | HID0_DCE)@l 127 mtspr 1008,8 128 129/* compute end of kernel memory */ 130 lis 8,_C_LABEL(end)@ha 131 addi 8,8,_C_LABEL(end)@l 132#if defined(DDB) || defined(KERNFS) 133 lis 7,_C_LABEL(startsym)@ha 134 addi 7,7,_C_LABEL(startsym)@l 135 stw 3,0(7) 136 lis 7,_C_LABEL(endsym)@ha 137 addi 7,7,_C_LABEL(endsym)@l 138 stw 4,0(7) 139/* mr 8,4 * end of symbol table */ 140#endif 141 li 9,PGOFSET 142 add 8,8,9 143 andc 8,8,9 144 addi 8,8,NBPG 145 lis 9,idle_u@ha 146 stw 8,idle_u@l(9) 147 addi 8,8,USPACE /* space for idle_u */ 148 lis 9,_C_LABEL(proc0paddr)@ha 149 stw 8,_C_LABEL(proc0paddr)@l(9) 150 addi 1,8,USPACE-FRAMELEN /* stackpointer for proc0 */ 151 mr 4,1 /* end of mem reserved for kernel */ 152 xor 0,0,0 153 stwu 0,-16(1) /* end of stack chain */ 154 155 lis 3,__start@ha 156 addi 3,3,__start@l 157 158 xor 5,5,5 159 xor 6,6,6 160 bl _C_LABEL(initppc) 161 bl _C_LABEL(main) 162 163loop: b loop /* XXX not reached */ 164 165 .globl _C_LABEL(enable_intr) 166_C_LABEL(enable_intr): 167 mfmsr 3 168 ori 3,3,PSL_EE@l 169 mtmsr 3 170 blr 171 172 .globl _C_LABEL(disable_intr) 173_C_LABEL(disable_intr): 174 mfmsr 3 175 andi. 3,3,~PSL_EE@l 176 mtmsr 3 177 blr 178 179 .globl _C_LABEL(sandpoint_reboot) 180_C_LABEL(sandpoint_reboot): 181 mfmsr 3 182 ori 3,3,PSL_IP@l 183 mtmsr 3 184 b 0xFFF00100 185 186/* 187 * Include common switch / setfault code 188 */ 189#include <powerpc/powerpc/locore_subr.S> 190 191/* 192 * Include common trap / execption code 193 */ 194#include <powerpc/powerpc/trap_subr.S> 195