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