1/* $NetBSD: ev64260_locore.S,v 1.9 2008/02/05 22:31:49 garbled 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_ppcparam.h" 38#include "opt_ipkdb.h" 39#include "opt_multiprocessor.h" 40#include "opt_openpic.h" 41#include "assym.h" 42 43#include <sys/syscall.h> 44 45#include <machine/param.h> 46#include <machine/vmparam.h> 47#include <machine/pmap.h> 48#include <machine/psl.h> 49#include <machine/trap.h> 50#define _NOREGNAMES 51#include <machine/asm.h> 52 53#include <powerpc/spr.h> 54#include <powerpc/oea/bat.h> 55#include <powerpc/oea/hid.h> 56 57/* 58 * Some instructions gas doesn't understand (yet?) 59 */ 60#define bdneq bdnzf 2, 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 */ 71GLOBAL(oeacpufeat) 72 .long 0 /* cpu features */ 73/* 74 * File-scope for locore.S 75 */ 76#ifdef DINK 77 .data 78dink_return: 79 .long 0 /* fake uarea during idle after exit */ 80dink_stack: 81 .long 0 /* fake uarea during idle after exit */ 82#endif 83 84 85/* 86 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 87 * mark the start of kernel text. 88 */ 89 .text 90 .globl _C_LABEL(kernel_text) 91_C_LABEL(kernel_text): 92 93/* 94 * Startup entry. Note, this must be the first thing in the text 95 * segment! 96 */ 97 .text 98 .globl __start 99__start: 100#ifdef DINK 101 mflr 0 102 lis 8, dink_stack@ha 103 stw 1, dink_stack@l(8) 104 lis 8, dink_return@ha 105 stw 0, dink_return@l(8) 106#endif 107 108#if 0 109 eieio; sync 110 lis 8, 0xf100f104@ha 111 lwz 7, -3836(8) 112 li 0, 1 113 andc 7,7,0 114 stw 7, -3836(8) 115 eieio; sync 116#endif 117 118 /* 119 * Make sure that .bss is zeroed. 120 */ 121 li 0,0 122 lis 8,edata@ha 123 addi 8,8,edata@l 124 lis 9,end@ha 125 addi 9,9,end@l 1265: cmpw 0,8,9 /* edata & end are >= word aligned */ 127 bge 6f 128 stw 0,0(8) 129 addi 8,8,4 130 b 5b 1316: 132 133 li 0,0 134 mtmsr 0 /* Disable FPU/MMU/exceptions */ 135 sync ; isync 136 137#if 1 138 mfpvr 0 139 srwi 0,0,16 140 cmplwi 0,MPC7410 141 bne 16f 142 143#if 0 144 /* flush and disable L2 */ 145 mfspr 8,SPR_L2CR 146 lis 0,(L2CR_L2E|L2CR_L2WT)@h /* disable the L2 mode */ 147 andc 8,8,0 148 ori 8,8,L2CR_L2HWF /* enable hardware flush */ 149 sync 150 mtspr SPR_L2CR,8 /* do it */ 151 sync /* wait for it to finish */ 152 153 /* Disable data lock mode */ 154 mfspr 8,SPR_HID0 155 li 0,HID0_DLOCK 156 andc 8,8,0 157 mtspr SPR_HID0,8 158 sync 159#endif 160#if 0 161 /* 162 * Flush the L1 cache 163 */ 164 mfspr 8,SPR_MSSCR0 165 oris 8,8,MSSCR0_DL1HWF@h 166 sync 167 mtspr SPR_MSSCR0,8 168 sync 169#endif 170#if 1 171 /* disable data and instruction caches */ 172 mfspr 8,SPR_HID0 173 li 0,HID0_DLOCK@l 174 andc 8,8,0 175 sync 176 mtspr SPR_HID0,8 177 sync 178 isync 179#endif 1807: 181#if 0 182 /* disable data and instruction caches */ 183 mfspr 8,SPR_HID0 184 li 0,(HID0_ICE|HID0_DCE)@l 185 andc 8,8,0 186 sync 187 mtspr SPR_HID0,8 188 sync 189 isync 190#endif 1917: 192#if 0 193 /* Enable and flush data and instruction caches */ 194 ori 8,8,(HID0_ICFI|HID0_ICE|HID0_DCFI|HID0_DCE) 195# ori 8,8,(HID0_ICFI|HID0_ICE) 196 mtspr SPR_HID0,8 197 isync 1988: sync 199 mfspr 8,SPR_HID0 200 andi. 0,8,(HID0_ICFI|HID0_DCFI) 201 bne 8b 202#endif 203 204#if 0 205 mfspr 8,SPR_L2CR 206 oris 8,8,L2CR_L2E@h 207 sync 208 mtspr SPR_L2CR,8 209 sync 210#endif 21116: 212#endif 213 214/* compute end of kernel memory */ 215 lis 8,_C_LABEL(end)@ha 216 addi 8,8,_C_LABEL(end)@l 217#if NKSYMS || defined(DDB) || defined(LKM) || defined(KERNFS) 218 lis 7,_C_LABEL(startsym)@ha 219 addi 7,7,_C_LABEL(startsym)@l 220 stw 3,0(7) 221 lis 7,_C_LABEL(endsym)@ha 222 addi 7,7,_C_LABEL(endsym)@l 223 stw 4,0(7) 224/* mr 8,4 * end of symbol table */ 225#endif 226 mr 4,8 /* end of mem reserved for kernel */ 227 INIT_CPUINFO(4,1,9,0) 228 229 lis 3,__start@ha 230 addi 3,3,__start@l 231 li 5,0 232 li 6,0 233 234 bl _C_LABEL(initppc) 235 bl _C_LABEL(main) 236 237loop: b loop /* XXX not reached */ 238 239#if 0 240 .globl _C_LABEL(extintr_enable) 241_C_LABEL(extintr_enable): 242 mfmsr 3 243 ori 3,3,PSL_EE@l 244 sync 245 mtmsr 3 246 blr 247 248 .globl _C_LABEL(extintr_restore) 249_C_LABEL(extintr_restore): 250 mfmsr 4 251 or 3,4,3 252 sync 253 mtmsr 3 254 blr 255 256 .globl _C_LABEL(extintr_disable) 257_C_LABEL(extintr_disable): 258 mfmsr 3 259 andi. 4,3,~PSL_EE@l 260 sync 261 mtmsr 4 262 andi. 3,3,PSL_EE@l 263 blr 264 265 .globl _C_LABEL(mvpppc_reboot) 266_C_LABEL(mvpppc_reboot): 267 mfmsr 3 268 ori 3,3,PSL_IP@l 269 sync 270 mtmsr 3 271 b 0xFFF00100 272#endif 273 274#ifdef DINK 275 .globl _C_LABEL(return_to_dink) 276_C_LABEL(return_to_dink): 277 sync 278 lis 4, dink_stack@ha 279 lwz 1, dink_stack@l(4) 280 lis 4, dink_return@ha 281 lwz 5, dink_return@l(4) 282 mtlr 5 283 blr 284#endif 285 286/* 287 * Include common switch / setfault code 288 */ 289#include <powerpc/powerpc/locore_subr.S> 290 291/* 292 * Include common trap / execption code 293 */ 294#include <powerpc/powerpc/trap_subr.S> 295 296/* 297 * Include PIO routines 298 */ 299#include <powerpc/powerpc/pio_subr.S> 300