1/* $NetBSD: locore.S,v 1.13 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 * 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/* XXX All of this should die */ 73GLOBAL(intrnames) 74 .asciz "clock", "irq1", "irq2", "irq3" 75 .asciz "irq4", "irq5", "irq6", "irq7" 76 .asciz "irq8", "irq9", "irq10", "irq11" 77 .asciz "irq12", "irq13", "irq14", "irq15" 78 .asciz "irq16", "irq17", "irq18", "irq19" 79 .asciz "irq20", "irq21", "irq22", "irq23" 80 .asciz "irq24", "irq25", "irq26", "irq27" 81 .asciz "irq28", "softnet", "softclock", "softserial" 82GLOBAL(eintrnames) 83 .align 4 84GLOBAL(intrcnt) 85 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 86 .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 87GLOBAL(eintrcnt) 88 89/* 90 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 91 * mark the start of kernel text. 92 */ 93 .text 94 .globl _C_LABEL(kernel_text) 95_C_LABEL(kernel_text): 96 97/* 98 * Startup entry. Note, this must be the first thing in the text 99 * segment! 100 * 101 * The bootloaded passes the following registers: 102 * 103 * %r3 == start of symbol table 104 * %r4 == end of symbol table 105 * %r5 == boot parameters 106 */ 107 .text 108 .globl __start 109__start: 110 li %r0,0 111 mtmsr %r0 /* Disable FPU/MMU/exceptions */ 112 isync 113 114/* compute end of kernel memory */ 115#if NKSYMS || defined(DDB) || defined(MODULAR) 116 lis %r7,_C_LABEL(startsym)@ha 117 addi %r7,%r7,_C_LABEL(startsym)@l 118 stw %r3,0(%r7) 119 lis %r7,_C_LABEL(endsym)@ha 120 addi %r7,%r7,_C_LABEL(endsym)@l 121 stw %r4,0(%r7) /* end of symbol table */ 122#else 123 lis %r4,_C_LABEL(end)@ha 124 addi %r4,%r4,_C_LABEL(end)@l 125#endif 126 127 INIT_CPUINFO(%r4,%r1,%r9,%r0) 128 129 lis %r3,__start@ha 130 addi %r3,%r3,__start@l 131 132 bl _C_LABEL(initppc) 133 134/* enable internal i/d-cache */ 135 mfpvr %r9 136 rlwinm %r9,%r9,16,16,31 137 cmpi %cr0,%r9,1 138 beq 3f /* not needed for 601 */ 139 mfspr %r11,SPR_HID0 140 andi. %r0,%r11,HID0_DCE 141 ori %r11,%r11,HID0_ICE|HID0_DCE 142 ori %r8,%r11,HID0_ICFI 143 bne 1f /* don't invalidate the D-cache */ 144 ori %r8,%r8,HID0_DCFI /* unless it wasn't enabled */ 1451: 146 sync 147 mtspr SPR_HID0,%r8 /* enable and invalidate caches */ 148 sync 149 mtspr SPR_HID0,%r11 /* enable caches */ 150 sync 151 isync 152 cmpi %cr0,%r9,4 /* check for 604 */ 153 cmpi %cr1,%r9,9 /* or 604e */ 154 cmpi %cr2,%r9,10 /* or mach5 */ 155 cror 2,2,6 156 cror 2,2,10 157 bne 3f 158 ori %r11,%r11,HID0_SIED|HID0_BHTE /* for 604[e], enable */ 159 bne %cr2,2f 160 ori %r11,%r11,HID0_BTCD 1612: 162 mtspr SPR_HID0,%r11 1633: 164 sync 165 isync 166 167 bl _C_LABEL(main) 168 b bugret 169 170/* 171 * void _mvmeppc_unsup_board(const char *msg, const char *msgend) 172 * 173 * Print the specified message using ppcbug's console output syscall 174 * before dropping back out to bug. 175 */ 176ENTRY(_mvmeppc_unsup_board) 177 addi %r10,0,0x0022 178 sc 179bugret: addi %r10,0,0x0063 180 sc 181 /* NOTREACHED */ 182 183 .globl _C_LABEL(enable_intr) 184_C_LABEL(enable_intr): 185 mfmsr %r3 186 ori %r3,%r3,PSL_EE@l 187 mtmsr %r3 188 blr 189 190 .globl _C_LABEL(disable_intr) 191_C_LABEL(disable_intr): 192 mfmsr %r3 193 andi. %r3,%r3,~PSL_EE@l 194 mtmsr %r3 195 blr 196 197/* 198 * Pull in common switch / setfault code. 199 */ 200#include <powerpc/powerpc/locore_subr.S> 201 202/* 203 * Pull in common trap vector code. 204 */ 205#include <powerpc/powerpc/trap_subr.S> 206 207/* 208 * Pull in common pio / bus_space code. 209 */ 210#include <powerpc/powerpc/pio_subr.S> 211