1/* $NetBSD: locore.S,v 1.39 2008/04/08 02:33:03 garbled Exp $ */ 2 3/* 4 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 5 * Copyright (C) 1995, 1996 TooLs GmbH. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by TooLs GmbH. 19 * 4. The name of TooLs GmbH may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include "opt_ddb.h" 35#include "opt_ipkdb.h" 36#include "opt_lockdebug.h" 37#include "opt_multiprocessor.h" 38#include "opt_ppcparam.h" 39#include "assym.h" 40 41#include <sys/syscall.h> 42 43#include <machine/param.h> 44#include <machine/pmap.h> 45#include <machine/psl.h> 46#include <machine/trap.h> 47#define _NOREGNAMES 48#include <machine/asm.h> 49#include <machine/vmparam.h> 50 51#include <powerpc/spr.h> 52 53#include "ksyms.h" 54 55/* 56 * Some instructions gas doesn't understand (yet?) 57 */ 58#define bdneq bdnzf 2, 59 60/* 61 * Globals 62 */ 63 .data 64GLOBAL(esym) 65 .long 0 /* end of symbol table */ 66GLOBAL(proc0paddr) 67 .long 0 /* proc0 p_addr */ 68GLOBAL(oeacpufeat) 69 .long 0 /* cpu features */ 70 71/* 72 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 73 * mark the start of kernel text. 74 */ 75 .text 76 .globl _C_LABEL(kernel_text) 77_C_LABEL(kernel_text): 78 79/* 80 * Startup entry. Note, this must be the first thing in the text 81 * segment! 82 */ 83 .text 84 .globl __start 85__start: 86 bl _C_LABEL(ofwinit) /* init our OF hooks */ 87 88 li 0,0 89 mtmsr 0 /* Disable FPU/MMU/exceptions */ 90 91 bl _C_LABEL(cpu_model_init) 92 lis 12,oeacpufeat@ha 93 lwz 12,oeacpufeat@l(12) 94 andi. 12,12,OEACPU_64_BRIDGE /* Compare against OEACPU_64_BRIDGE */ 95 beq 2f /* skip if this is a 32bit part */ 96 li 0,0 97 sync 98 slbia /* invalidate the slb table */ 99 sync 100 clrldi 0,0,32 /* clear SF/ISF (high order bits) */ 101 mtmsrd 0 102 mtspr 0x118,0 /* clear ASR[V] to enable segregs */ 1032: 104 isync 105 /* compute end of kernel memory */ 106 lis 4,_C_LABEL(end)@ha 107 addi 4,4,_C_LABEL(end)@l 108#if NKSYMS || defined(DDB) || defined(LKM) 109 /* skip symbol table */ 110 cmpwi 6,0 111 beq 1f 112 add 9,6,7 /* r9 = args + l */ 113 lwz 9,-8(9) /* esym */ 114 cmpwi 9,0 115 beq 1f 116 mr 4,9 1171: 118#endif 119 120 121 /* 122 * Initialize cpu_info[0] 123 */ 124 INIT_CPUINFO(4,1,9,0) 125 126 lis 3,__start@ha 127 addi 3,3,__start@l 128 mr 5,6 /* args string */ 129 bl _C_LABEL(initppc) 130 bl _C_LABEL(main) 131 b _C_LABEL(OF_exit) 132 133/* 134 * Pull in common OFW code. 135 */ 136#include <powerpc/oea/ofw_subr.S> 137 138/* 139 * Pull in common switch / setfault code. 140 */ 141#include <powerpc/powerpc/locore_subr.S> 142 143/* 144 * Pull in common trap vector code. 145 */ 146#include <powerpc/powerpc/trap_subr.S> 147 148/* 149 * Pull in common pio / bus_space code. 150 */ 151#include <powerpc/powerpc/pio_subr.S> 152