1/* $NetBSD: obs600_locore.S,v 1.5 2011/12/12 11:28:04 kiyohara Exp $ */ 2 3/* 4 * Copyright (c) 2009 KIYOHARA Takashi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#undef PPC_4XX_NOCACHE 30 31#include "opt_ddb.h" 32#include "opt_ppcarch.h" 33#include "opt_ppcparam.h" 34#include "assym.h" 35#include "ksyms.h" 36 37#include <machine/param.h> 38#include <machine/psl.h> 39#include <machine/trap.h> 40#include <machine/asm.h> 41 42#include <powerpc/ibm4xx/spr.h> 43 44/* 45 * This symbol is here for the benefit of kvm_mkdb, and is supposed to 46 * mark the start of kernel text. 47 */ 48 .text 49 .globl _C_LABEL(kernel_text) 50_C_LABEL(kernel_text): 51 52/* 53 * Kernel start routine for OpenBlockS600 54 * this code is excuted at the very first after the kernel is loaded 55 * by U-Boot. 56 */ 57 .text 58 .globl __start 59__start: 60 mr %r31, %r3 /* argc of 'go's */ 61 mr %r30, %r4 /* argv of 'go's */ 62 mr %r29, %r6 /* arg string of 'bootm's */ 63 64 li %r0, 0 65 mtmsr %r0 /* Disable FPU/MMU/exceptions */ 66 isync 67 68#ifdef PPC_4XX_NOCACHE 69 /* Disable all caches for physical addresses */ 70 li %r0, 0 71#else 72 /* Allow cacheing for only the first 2GB of RAM */ 73 lis %r0, 0xffff 74#endif 75 mtdccr %r0 76 mticcr %r0 77 78 /* Invalidate all TLB entries */ 79 tlbia 80 sync 81 isync 82 83 /* get start of bss */ 84 lis %r3, _C_LABEL(_edata)-4@ha 85 addi %r3, %r3, _C_LABEL(_edata)-4@l 86 /* get end of kernel memory */ 87 lis %r8, _C_LABEL(end)@ha 88 addi %r8, %r8, _C_LABEL(end)@l 89 /* zero bss */ 90 li %r4, 0 912: stwu %r4, %r4(3) 92 cmpw %r3, %r8 93 bne+ 2b 94 95#if NKSYMS || defined(DDB) || defined(MODULAR) 96 /* If we had symbol table location we'd store it here and would've adjusted r8 here */ 97 lis %r7, _C_LABEL(startsym)@ha 98 addi %r7, %r7, _C_LABEL(startsym)@l 99 stw %r8, 0(%r7) 100 lis %r7, _C_LABEL(endsym)@ha 101 addi %r7, %r7, _C_LABEL(endsym)@l 102 stw %r8, 0(%r7) 103#endif 104 105 /* Set kernel MMU context. */ 106 li %r0, KERNEL_PID 107 mtpid %r0 108 sync 109 110 INIT_CPUINFO(8,1,9,0) 111 mr %r4, %r8 112 113 lis %r3, __start@ha 114 addi %r3, %r3, __start@l 115 116 mr %r5, %r31 /* argc of 'go's */ 117 mr %r6, %r30 /* argv of 'go's */ 118 mr %r7, %r29 /* arg strings of 'bootm's */ 119 120 bl _C_LABEL(initppc) 121 bl _C_LABEL(main) 122 123not_reached: 124 b not_reached 125 126#include <powerpc/ibm4xx/4xx_locore.S> 127