1 1.13 maxv /* $NetBSD: obs200_locore.S,v 1.13 2018/07/15 05:16:42 maxv Exp $ */ 2 1.1 shige /* Original Tag: locore.S,v 1.1 2003/09/23 15:21:58 shige Exp */ 3 1.1 shige /* $OpenBSD: locore.S,v 1.4 1997/01/26 09:06:38 rahnds Exp $ */ 4 1.1 shige 5 1.1 shige /* 6 1.1 shige * Copyright 2001 Wasabi Systems, Inc. 7 1.1 shige * All rights reserved. 8 1.1 shige * 9 1.1 shige * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 10 1.1 shige * 11 1.1 shige * Redistribution and use in source and binary forms, with or without 12 1.1 shige * modification, are permitted provided that the following conditions 13 1.1 shige * are met: 14 1.1 shige * 1. Redistributions of source code must retain the above copyright 15 1.1 shige * notice, this list of conditions and the following disclaimer. 16 1.1 shige * 2. Redistributions in binary form must reproduce the above copyright 17 1.1 shige * notice, this list of conditions and the following disclaimer in the 18 1.1 shige * documentation and/or other materials provided with the distribution. 19 1.1 shige * 3. All advertising materials mentioning features or use of this software 20 1.1 shige * must display the following acknowledgement: 21 1.1 shige * This product includes software developed for the NetBSD Project by 22 1.1 shige * Wasabi Systems, Inc. 23 1.1 shige * 4. The name of Wasabi Systems, Inc. may not be used to endorse 24 1.1 shige * or promote products derived from this software without specific prior 25 1.1 shige * written permission. 26 1.1 shige * 27 1.1 shige * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 28 1.1 shige * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29 1.1 shige * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30 1.1 shige * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 31 1.1 shige * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 1.1 shige * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 1.1 shige * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 1.1 shige * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 1.1 shige * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 1.1 shige * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37 1.1 shige * POSSIBILITY OF SUCH DAMAGE. 38 1.1 shige */ 39 1.1 shige 40 1.1 shige /* 41 1.1 shige * Copyright (C) 1995, 1996 Wolfgang Solfrank. 42 1.1 shige * Copyright (C) 1995, 1996 TooLs GmbH. 43 1.1 shige * All rights reserved. 44 1.1 shige * 45 1.1 shige * Redistribution and use in source and binary forms, with or without 46 1.1 shige * modification, are permitted provided that the following conditions 47 1.1 shige * are met: 48 1.1 shige * 1. Redistributions of source code must retain the above copyright 49 1.1 shige * notice, this list of conditions and the following disclaimer. 50 1.1 shige * 2. Redistributions in binary form must reproduce the above copyright 51 1.1 shige * notice, this list of conditions and the following disclaimer in the 52 1.1 shige * documentation and/or other materials provided with the distribution. 53 1.1 shige * 3. All advertising materials mentioning features or use of this software 54 1.1 shige * must display the following acknowledgement: 55 1.1 shige * This product includes software developed by TooLs GmbH. 56 1.1 shige * 4. The name of TooLs GmbH may not be used to endorse or promote products 57 1.1 shige * derived from this software without specific prior written permission. 58 1.1 shige * 59 1.1 shige * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 60 1.1 shige * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 61 1.1 shige * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 62 1.1 shige * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 63 1.1 shige * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 64 1.1 shige * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 65 1.1 shige * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 66 1.1 shige * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 67 1.1 shige * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 68 1.1 shige * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 69 1.1 shige */ 70 1.1 shige 71 1.1 shige #undef PPC_4XX_NOCACHE 72 1.1 shige 73 1.1 shige #include "opt_ddb.h" 74 1.1 shige #include "opt_lockdebug.h" 75 1.6 apb #include "opt_modular.h" 76 1.1 shige #include "opt_multiprocessor.h" 77 1.1 shige #include "opt_ppcarch.h" 78 1.1 shige #include "opt_ppcparam.h" 79 1.1 shige #include "assym.h" 80 1.1 shige #include "ksyms.h" 81 1.1 shige 82 1.1 shige #include <sys/syscall.h> 83 1.1 shige 84 1.1 shige #include <machine/param.h> 85 1.1 shige #include <machine/psl.h> 86 1.1 shige #include <machine/trap.h> 87 1.1 shige #include <machine/asm.h> 88 1.1 shige 89 1.1 shige #include <powerpc/spr.h> 90 1.8 matt #include <powerpc/ibm4xx/spr.h> 91 1.9 kiyohara #include <powerpc/ibm4xx/dcr4xx.h> 92 1.1 shige 93 1.1 shige /* Function pointer for requesting board_config_data from OpenBlockS S/R BIOS */ 94 1.1 shige #define BOARD_CFG_FP (0x00100000) 95 1.1 shige 96 1.1 shige /* 97 1.1 shige * Some instructions gas doesn't understand (yet?) 98 1.1 shige */ 99 1.1 shige #define bdneq bdnzf 2, 100 1.1 shige 101 1.1 shige /* 102 1.1 shige * This symbol is here for the benefit of kvm_mkdb, and is supposed to 103 1.1 shige * mark the start of kernel text. 104 1.1 shige */ 105 1.1 shige .text 106 1.1 shige .globl _C_LABEL(kernel_text) 107 1.1 shige _C_LABEL(kernel_text): 108 1.1 shige 109 1.1 shige /* 110 1.1 shige * Startup entry. Note, this must be the first thing in the text 111 1.1 shige * segment! 112 1.1 shige */ 113 1.1 shige .text 114 1.1 shige .globl __start 115 1.1 shige __start: 116 1.1 shige b 1f 117 1.1 shige /* Reserve some space for info_block required for IBM eval board bootloader */ 118 1.1 shige nop 119 1.1 shige nop 120 1.1 shige nop 121 1.1 shige nop 122 1.1 shige nop 123 1.1 shige nop 124 1.1 shige nop 125 1.1 shige nop 126 1.1 shige nop 127 1.1 shige nop 128 1.1 shige 129 1.1 shige 1: 130 1.1 shige /* Get the board_config_data from openbios */ 131 1.1 shige lis %r3,BOARD_CFG_FP@h 132 1.1 shige ori %r3,%r3,BOARD_CFG_FP@l 133 1.1 shige mr %r31,%r3 /* Save value in r31 */ 134 1.1 shige 135 1.1 shige li %r0,0 136 1.1 shige mtmsr %r0 /* Disable FPU/MMU/exceptions */ 137 1.1 shige isync 138 1.1 shige 139 1.1 shige /* PPC405GP errata, item #58. 140 1.1 shige * Load string instructions may write incorrect data into the last GPR 141 1.1 shige * targeted in the operation. 142 1.1 shige * Workaround: set OCM0_DSCNTL[DSEN]=0 and OCM0_DSCNTL[DOF]=0 */ 143 1.1 shige mtdcr DCR_OCM0_DSCNTL, %r0 /* Disable Data access to OCM */ 144 1.1 shige mtdcr DCR_OCM0_ISCNTL, %r0 /* Disable Instruction access to OCM. Just in case */ 145 1.1 shige /* 146 1.1 shige * Cpu detect. 147 1.1 shige * 148 1.1 shige */ 149 1.1 shige __start_cpu0: 150 1.1 shige #ifdef PPC_4XX_NOCACHE 151 1.1 shige /* Disable all caches for physical addresses */ 152 1.1 shige li %r0,0 153 1.1 shige #else 154 1.1 shige /* Allow cacheing for only the first 2GB of RAM */ 155 1.1 shige lis %r0,0xffff 156 1.1 shige #endif 157 1.1 shige mtdccr %r0 158 1.1 shige mticcr %r0 159 1.1 shige 160 1.1 shige /* Invalidate all TLB entries */ 161 1.1 shige tlbia 162 1.1 shige sync 163 1.1 shige isync 164 1.1 shige /* get start of bss */ 165 1.1 shige lis %r3,_C_LABEL(_edata)-4@ha 166 1.1 shige addi %r3,%r3,_C_LABEL(_edata)-4@l 167 1.1 shige /* get end of kernel memory */ 168 1.1 shige lis %r8,_C_LABEL(end)@ha 169 1.1 shige addi %r8,%r8,_C_LABEL(end)@l 170 1.1 shige /* zero bss */ 171 1.1 shige li %r4,0 172 1.12 joerg 2: stwu %r4,4(%r3) 173 1.1 shige cmpw %r3,%r8 174 1.1 shige bne+ 2b 175 1.1 shige 176 1.5 ad #if NKSYMS || defined(DDB) || defined(MODULAR) 177 1.1 shige /* If we had symbol table location we'd store it here and would've adjusted r8 here */ 178 1.1 shige lis %r7,_C_LABEL(startsym)@ha 179 1.1 shige addi %r7,%r7,_C_LABEL(startsym)@l 180 1.1 shige stw %r8,0(%r7) 181 1.1 shige lis %r7,_C_LABEL(endsym)@ha 182 1.1 shige addi %r7,%r7,_C_LABEL(endsym)@l 183 1.1 shige stw %r8,0(%r7) 184 1.1 shige #endif 185 1.1 shige 186 1.4 kiyohara /* Set kernel MMU context. */ 187 1.4 kiyohara li %r0,KERNEL_PID 188 1.1 shige mtpid %r0 189 1.1 shige sync 190 1.1 shige 191 1.1 shige INIT_CPUINFO(8,1,9,0) 192 1.1 shige mr %r4,%r8 193 1.1 shige 194 1.1 shige lis %r3,__start@ha 195 1.1 shige addi %r3,%r3,__start@l 196 1.1 shige 197 1.1 shige mr %r6,%r31 /* info_block address */ 198 1.1 shige bl _C_LABEL(initppc) 199 1.1 shige bl _C_LABEL(main) 200 1.1 shige 201 1.1 shige loop: b loop /* XXX not reached */ 202 1.1 shige 203 1.1 shige #include <powerpc/ibm4xx/4xx_locore.S> 204