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