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