1/* $NetBSD: locore.S,v 1.35 2005/12/11 12:18:29 christos 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 */ 63GLOBAL(startsym) 64 .long 0 /* start of symbol table */ 65GLOBAL(endsym) 66 .long 0 /* end of symbol table */ 67GLOBAL(proc0paddr) 68 .long 0 /* proc0 p_addr */ 69 70/* 71 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 72 * mark the start of kernel text. 73 */ 74 .text 75 .globl _C_LABEL(kernel_text) 76_C_LABEL(kernel_text): 77 78/* 79 * Startup entry. Note, this must be the first thing in the text 80 * segment! 81 */ 82 .text 83 .globl __start 84__start: 85 bl _C_LABEL(ofwinit) /* init our OF hooks */ 86 87 li 0,0 88 mtmsr 0 /* Disable FPU/MMU/exceptions */ 89 isync 90 91 /* compute end of kernel memory */ 92#if NKSYMS || defined(DDB) || defined(LKM) 93 /* skip symbol table */ 94 cmpwi 6,0 95 beq 1f 96 add 9,6,7 /* r9 = args + l */ 97 98 /* If the resulting address is misaligned, abort. */ 99 andi. 8,9,3 100 bne 1f /* misaligned */ 101 102 /* First, see if the loader even put the symbols there. */ 103 lwz 9,-12(9) 104 lis 8,0x19730224@h /* magic number */ 105 ori 8,8,0x19730224@l 106 cmplw 8,9 107 bne 1f /* nope */ 108 109 /* Okay, ssym and esym are here -- fetch them. */ 110 add 9,6,7 111 lwz 9,-8(9) 112 lis 8,_C_LABEL(startsym)@ha 113 stw 9,_C_LABEL(startsym)@l(8) 114 115 add 9,6,7 116 lwz 9,-4(9) 117 lis 8,_C_LABEL(endsym)@ha 118 stw 9,_C_LABEL(endsym)@l(8) 119 120 mr 4,9 /* r8 = end of kernel + symbols */ 121 b 2f 1221: 123#endif 124 lis 4,_C_LABEL(end)@ha 125 addi 4,4,_C_LABEL(end)@l 1262: 127 128 /* 129 * Initialize cpu_info[0] 130 */ 131 INIT_CPUINFO(4,1,9,0) 132 133 lis 3,__start@ha 134 addi 3,3,__start@l 135 mr 5,6 /* args string */ 136 bl _C_LABEL(initppc) 137 bl _C_LABEL(main) 138 b _C_LABEL(OF_exit) 139 140/* 141 * Pull in common OFW code. 142 */ 143#include <powerpc/oea/ofw_subr.S> 144 145/* 146 * Pull in common switch / setfault code. 147 */ 148#include <powerpc/powerpc/locore_subr.S> 149 150/* 151 * Pull in common trap vector code. 152 */ 153#include <powerpc/powerpc/trap_subr.S> 154