Home | History | Annotate | Line # | Download | only in obs405
obs600_locore.S revision 1.2.2.1
      1 /*	$NetBSD: obs600_locore.S,v 1.2.2.1 2011/06/06 09:05:32 jruoho 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 #include <powerpc/ibm4xx/pmap.h>
     44 
     45 /*
     46  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     47  * mark the start of kernel text.
     48  */
     49 	.text
     50 	.globl	_C_LABEL(kernel_text)
     51 _C_LABEL(kernel_text):
     52 
     53 /*
     54  * Kernel start routine for OpenBlockS600
     55  * this code is excuted at the very first after the kernel is loaded
     56  * by U-Boot.
     57  */
     58 	.text
     59 	.globl	__start
     60 __start:
     61 	mr	%r31, %r3		/* argc of 'go's */
     62 	mr	%r30, %r4		/* argv of 'go's */
     63 	mr	%r29, %r6		/* arg string of 'bootm's */
     64 
     65 	li	%r0, 0
     66 	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
     67 	isync
     68 
     69 #ifdef PPC_4XX_NOCACHE
     70 	/* Disable all caches for physical addresses */
     71 	li	%r0, 0
     72 #else
     73 	/* Allow cacheing for only the first 2GB of RAM */
     74 	lis	%r0, 0xffff
     75 #endif
     76 	mtdccr	%r0
     77 	mticcr	%r0
     78 
     79 	/* Invalidate all TLB entries */
     80 	tlbia
     81 	sync
     82 	isync
     83 
     84 	/* get start of bss */
     85 	lis	%r3, _C_LABEL(_edata)-4@ha
     86 	addi	%r3, %r3, _C_LABEL(_edata)-4@l
     87 	/* get end of kernel memory */
     88 	lis	%r8, _C_LABEL(end)@ha
     89 	addi	%r8, %r8, _C_LABEL(end)@l
     90 	/* zero bss */
     91 	li	%r4, 0
     92 2:	stwu	%r4, %r4(3)
     93 	cmpw	%r3, %r8
     94 	bne+	2b
     95 
     96 #if NKSYMS || defined(DDB) || defined(MODULAR)
     97 	/* If we had symbol table location we'd store it here and would've adjusted r8 here */
     98 	lis	%r7, _C_LABEL(startsym)@ha
     99 	addi	%r7, %r7, _C_LABEL(startsym)@l
    100 	stw	%r8, 0(%r7)
    101 	lis	%r7, _C_LABEL(endsym)@ha
    102 	addi	%r7, %r7, _C_LABEL(endsym)@l
    103 	stw	%r8, 0(%r7)
    104 #endif
    105 
    106 	/* Set kernel MMU context. */
    107 	li	%r0, KERNEL_PID
    108 	mtpid	%r0
    109 	sync
    110 
    111 	INIT_CPUINFO(8,1,9,0)
    112 	mr	%r4, %r8
    113 
    114 	lis	%r3, __start@ha
    115 	addi	%r3, %r3, __start@l
    116 
    117 	mr	%r6, %r31		/* argc of 'go's */
    118 	mr	%r7, %r30		/* argv of 'go's */
    119 	mr	%r8, %r29		/* arg strings of 'bootm's */
    120 
    121 	bl	_C_LABEL(initppc)
    122 	bl	_C_LABEL(main)
    123 
    124 not_reached:
    125 	b	not_reached
    126 
    127 #include <powerpc/ibm4xx/4xx_locore.S>
    128