1/* $NetBSD: locore.S,v 1.16 2011/01/17 08:23:56 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_ipkdb.h" 37#include "opt_lockdebug.h" 38#include "opt_modular.h" 39#include "opt_multiprocessor.h" 40#include "opt_ppcparam.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 55#include "ksyms.h" 56 57/* 58 * Some instructions gas doesn't understand (yet?) 59 */ 60#define bdneq bdnzf 2, 61 62/* 63 * cache bit 64 */ 65#define HID0_BTCD (1<<1) 66#define HID0_BHTE (1<<2) 67#define HID0_SIED (1<<7) 68#define HID0_DCI (1<<10) 69#define HID0_ICFI (1<<11) 70#define HID0_DCE (1<<14) 71#define HID0_ICE (1<<15) 72 73/* 74 * Globals 75 */ 76GLOBAL(startsym) 77 .long 0 /* start symbol table */ 78GLOBAL(endsym) 79 .long 0 /* end symbol table */ 80GLOBAL(oeacpufeat) 81 .long 0 /* cpu features */ 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 li 0,0 99 mtmsr 0 /* Disable FPU/MMU/exceptions */ 100 isync 101 102/* compute end of kernel memory */ 103#if NKSYMS || defined(DDB) || defined(MODULAR) 104 lis 7,_C_LABEL(startsym)@ha 105 addi 7,7,_C_LABEL(startsym)@l 106 stw 3,0(7) 107 lis 7,_C_LABEL(endsym)@ha 108 addi 7,7,_C_LABEL(endsym)@l 109 stw 4,0(7) 110#else 111 lis 4,_C_LABEL(end)@ha 112 addi 4,4,_C_LABEL(end)@l 113#endif 114 115 INIT_CPUINFO(4,1,9,0) 116 117 lis 3,__start@ha 118 addi 3,3,__start@l 119 120 bl _C_LABEL(initppc) 121 122/* enable internal i/d-cache */ 123 mfpvr 9 124 rlwinm 9,9,16,16,31 125 cmpi 0,9,1 126 beq 3f /* not needed for 601 */ 127 mfspr 11,SPR_HID0 128 andi. 0,11,HID0_DCE 129 ori 11,11,HID0_ICE|HID0_DCE 130 ori 8,11,HID0_ICFI 131 bne 1f /* don't invalidate the D-cache */ 132 ori 8,8,HID0_DCI /* unless it wasn't enabled */ 1331: 134 sync 135 mtspr SPR_HID0,8 /* enable and invalidate caches */ 136 sync 137 mtspr SPR_HID0,11 /* enable caches */ 138 sync 139 isync 140 cmpi 0,9,4 /* check for 604 */ 141 cmpi 1,9,9 /* or 604e */ 142 cmpi 2,9,10 /* or mach5 */ 143 cror 2,2,6 144 cror 2,2,10 145 bne 3f 146 ori 11,11,HID0_SIED|HID0_BHTE /* for 604[e], enable */ 147 bne 2,2f 148 ori 11,11,HID0_BTCD 1492: 150 mtspr SPR_HID0,11 1513: 152 sync 153 isync 154 155 bl _C_LABEL(main) 156 157loop: 158 b loop /* not reached */ 159 160 .globl _C_LABEL(enable_intr) 161_C_LABEL(enable_intr): 162 mfmsr 3 163 ori 4,3,PSL_EE@l 164 mtmsr 4 165 blr 166 167 .globl _C_LABEL(disable_intr) 168_C_LABEL(disable_intr): 169 mfmsr 3 170 andi. 4,3,~PSL_EE@l 171 mtmsr 4 172 blr 173 174/* 175 * Pull in common switch / setfault code. 176 */ 177#include <powerpc/powerpc/locore_subr.S> 178 179/* 180 * Pull in common trap vector code. 181 */ 182#include <powerpc/powerpc/trap_subr.S> 183 184/* 185 * Pull in common pio / bus_space code. 186 */ 187#include <powerpc/powerpc/pio_subr.S> 188