Home | History | Annotate | Line # | Download | only in mpc85xx
mpc85xx_start.S revision 1.9.28.1
      1  1.9.28.1  christos /*	$NetBSD: mpc85xx_start.S,v 1.9.28.1 2019/06/10 22:06:14 christos Exp $	*/
      2       1.2      matt /*-
      3       1.2      matt  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
      4       1.2      matt  * All rights reserved.
      5       1.2      matt  *
      6       1.2      matt  * This code is derived from software contributed to The NetBSD Foundation
      7       1.2      matt  * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects
      8       1.2      matt  * Agency and which was developed by Matt Thomas of 3am Software Foundry.
      9       1.2      matt  *
     10       1.2      matt  * This material is based upon work supported by the Defense Advanced Research
     11       1.2      matt  * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under
     12       1.2      matt  * Contract No. N66001-09-C-2073.
     13       1.2      matt  * Approved for Public Release, Distribution Unlimited
     14       1.2      matt  *
     15       1.2      matt  * Redistribution and use in source and binary forms, with or without
     16       1.2      matt  * modification, are permitted provided that the following conditions
     17       1.2      matt  * are met:
     18       1.2      matt  * 1. Redistributions of source code must retain the above copyright
     19       1.2      matt  *    notice, this list of conditions and the following disclaimer.
     20       1.2      matt  * 2. Redistributions in binary form must reproduce the above copyright
     21       1.2      matt  *    notice, this list of conditions and the following disclaimer in the
     22       1.2      matt  *    documentation and/or other materials provided with the distribution.
     23       1.2      matt  *
     24       1.2      matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     25       1.2      matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     26       1.2      matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     27       1.2      matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     28       1.2      matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     29       1.2      matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     30       1.2      matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     31       1.2      matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     32       1.2      matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     33       1.2      matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     34       1.2      matt  * POSSIBILITY OF SUCH DAMAGE.
     35       1.2      matt  */
     36       1.2      matt 
     37       1.2      matt #include <sys/cdefs.h>
     38       1.2      matt #include <powerpc/asm.h>
     39       1.2      matt 
     40  1.9.28.1  christos RCSID("$NetBSD: mpc85xx_start.S,v 1.9.28.1 2019/06/10 22:06:14 christos Exp $")
     41       1.2      matt 
     42       1.2      matt #include "opt_altivec.h"
     43       1.2      matt #include "opt_ddb.h"
     44       1.2      matt #include "opt_lockdebug.h"
     45       1.2      matt #include "opt_modular.h"
     46       1.2      matt #include "opt_multiprocessor.h"
     47       1.2      matt #include "opt_ppcarch.h"
     48       1.2      matt #include "opt_ppcparam.h"
     49       1.2      matt 
     50       1.2      matt #include "ksyms.h"
     51       1.2      matt 
     52       1.2      matt #include <sys/param.h>
     53       1.2      matt 
     54       1.2      matt #include <powerpc/spr.h>
     55       1.2      matt #include <powerpc/trap.h>
     56       1.5      matt #include <powerpc/psl.h>
     57       1.2      matt #include <powerpc/booke/pte.h>
     58       1.2      matt #include <powerpc/booke/spr.h>
     59       1.2      matt #define	LBC_PRIVATE
     60       1.2      matt #include <powerpc/booke/e500reg.h>
     61       1.2      matt 
     62       1.2      matt #include "assym.h"
     63       1.2      matt 
     64       1.2      matt #define	INTSTK	0
     65       1.2      matt 
     66       1.2      matt /*
     67       1.2      matt  * This symbol is here for the benefit of kvm_mkdb, and is supposed to
     68       1.2      matt  * mark the start of kernel text.
     69       1.2      matt  */
     70       1.2      matt 	.text
     71       1.2      matt 	.globl	_C_LABEL(kernel_text)
     72       1.2      matt _C_LABEL(kernel_text):
     73       1.2      matt         .globl  __start
     74       1.2      matt __start:
     75       1.2      matt 
     76       1.2      matt /*
     77       1.2      matt  * Startup entry.  Note, this must be the first thing in the text segment!
     78       1.2      matt  */
     79       1.6      matt 	mr	%r8,%r6		/* cmdline (char *) */
     80       1.6      matt 	mr	%r7,%r5		/* consdev (char *) */
     81       1.6      matt 	mr	%r6,%r4		/* os_hdr * */
     82       1.6      matt 	mr	%r5,%r3		/* board info * */
     83       1.2      matt #ifdef DEBUG
     84       1.2      matt 	/*
     85       1.2      matt 	 * Set all the registers we don't care about to a known junk value.
     86       1.2      matt 	 */
     87       1.8     joerg 	lis	%r2,0xdeadbeef@h
     88       1.7     joerg 	ori	%r2,%r2,0xdeadbeef@l
     89       1.2      matt 	mr	%r9,%r2
     90       1.2      matt 	mr	%r10,%r9
     91       1.2      matt 	mr	%r11,%r9
     92       1.2      matt 	mr	%r12,%r9
     93       1.2      matt 	mr	%r13,%r9
     94       1.2      matt 	mr	%r14,%r9
     95       1.2      matt 	mr	%r15,%r9
     96       1.2      matt 	mr	%r16,%r9
     97       1.2      matt 	mr	%r17,%r9
     98       1.2      matt 	mr	%r18,%r9
     99       1.2      matt 	mr	%r19,%r9
    100       1.2      matt 	mr	%r20,%r9
    101       1.2      matt 	mr	%r21,%r9
    102       1.2      matt 	mr	%r22,%r9
    103       1.2      matt 	mr	%r23,%r9
    104       1.2      matt 	mr	%r24,%r9
    105       1.2      matt 	mr	%r25,%r9
    106       1.2      matt 	mr	%r26,%r9
    107       1.2      matt 	mr	%r27,%r9
    108       1.2      matt 	mr	%r28,%r9
    109       1.2      matt 	mr	%r29,%r9
    110       1.2      matt 	mr	%r30,%r9
    111       1.2      matt 	mr	%r31,%r9
    112       1.2      matt #endif /* DEBUG */
    113       1.2      matt 
    114       1.2      matt 	li	%r0,0
    115       1.2      matt 	mtmsr	%r0			/* Disable FPU/MMU/exceptions */
    116       1.2      matt 	isync
    117       1.2      matt 
    118       1.2      matt /* get start of bss */
    119       1.2      matt 	lis	%r15,_C_LABEL(_edata)-4@ha
    120       1.2      matt 	addi	%r15,%r15,_C_LABEL(_edata)-4@l
    121       1.2      matt /* get end of kernel memory */
    122       1.2      matt 	lis	%r16,_C_LABEL(end)@ha
    123       1.2      matt 	addi	%r16,%r16,_C_LABEL(end)@l
    124       1.2      matt /* zero bss */
    125       1.2      matt 	sub	%r17,%r16,%r15
    126       1.2      matt 	addi	%r17,%r17,3+USPACE
    127       1.4      matt 	rlwinm	%r3,%r17,32-2,2,31	/* srwl	%r3,%r17,2 */
    128       1.2      matt 	mtctr	%r3
    129       1.2      matt 	li	%r0,0
    130       1.2      matt 2:	stwu	%r0,4(%r15)
    131       1.2      matt 	bdnz	2b
    132       1.2      matt 
    133       1.2      matt #if NKSYMS || defined(DDB) || defined(MODULAR)
    134       1.2      matt 	/* If we had symbol table location we'd store it here and would've adjusted r8 here */
    135       1.4      matt 	lis	%r17,_C_LABEL(startsym)@ha
    136       1.4      matt 	stw	%r18,_C_LABEL(startsym)@l(%r17)
    137       1.4      matt 	lis	%r17,_C_LABEL(endsym)@ha
    138       1.4      matt 	stw	%r18,_C_LABEL(endsym)@l(%r17)
    139       1.2      matt #endif
    140       1.2      matt 
    141       1.2      matt 	/* Set kernel MMU context. */
    142       1.2      matt 	li	%r0,KERNEL_PID
    143       1.2      matt 	mtpid	%r0
    144       1.2      matt 	isync
    145       1.2      matt 
    146       1.4      matt 	INIT_CPUINFO(16,1,18,17)	/* r16 has &_end */
    147       1.4      matt 	mr	%r4,%r16		/* remember kernelend */
    148       1.4      matt 	mtsprg2	%r13			/* r13 has &lwp0, put into sprg2 */
    149       1.4      matt 	GET_CPUINFO(%r17)
    150       1.4      matt 	addi	%r17,%r17,CI_SAVELIFO
    151       1.4      matt 	mtsprg3 %r17
    152       1.4      matt 	mr	%r18,%r31		/* make deadbeef again */
    153       1.4      matt 	mr	%r17,%r31		/* make deadbeef again */
    154       1.4      matt 	mr	%r16,%r31		/* make deadbeef again */
    155       1.4      matt 	mr	%r15,%r31		/* make deadbeef again */
    156       1.2      matt 
    157       1.2      matt #if defined(GXEMUL)
    158       1.2      matt 	/*
    159       1.2      matt 	 * This is used to step through the external interrupt vector
    160       1.2      matt 	 * to validate it.
    161       1.2      matt 	 */
    162       1.2      matt 	lis	%r29,3f@ha
    163       1.2      matt 	addi	%r29,%r29,3f@l
    164       1.2      matt 	mtsrr0	%r29
    165       1.2      matt 	mfmsr	%r0
    166       1.2      matt 	mtsrr1	%r0
    167       1.2      matt 	lis	%r31,0xdeadf231@ha
    168       1.2      matt 	addi	%r31,%r31,0xdeadf231@l
    169       1.2      matt 	mtlr	%r31
    170       1.2      matt 	addi	%r31,%r31,-0x10
    171       1.2      matt 	mtcr	%r31
    172       1.2      matt 	addi	%r31,%r31,-0x10
    173       1.2      matt 	mtctr	%r31
    174       1.2      matt 	addi	%r31,%r31,-0x10
    175       1.2      matt 	mtxer	%r31
    176       1.2      matt 	addi	%r31,%r31,-0x10
    177       1.2      matt 	addi	%r30,%r31,-0x10
    178       1.2      matt 	addi	%r29,%r30,-0x10
    179       1.2      matt 	addi	%r28,%r29,-0x10
    180       1.2      matt 	addi	%r27,%r28,-0x10
    181       1.2      matt 	addi	%r26,%r27,-0x10
    182       1.2      matt 	addi	%r25,%r26,-0x10
    183       1.2      matt 	addi	%r24,%r25,-0x10
    184       1.2      matt 	addi	%r23,%r24,-0x10
    185       1.2      matt 	addi	%r22,%r23,-0x10
    186       1.2      matt 	addi	%r21,%r22,-0x10
    187       1.2      matt 	addi	%r20,%r21,-0x10
    188       1.2      matt 	addi	%r19,%r20,-0x10
    189       1.2      matt 	addi	%r18,%r19,-0x10
    190       1.2      matt 	addi	%r17,%r18,-0x10
    191       1.2      matt 	addi	%r16,%r17,-0x10
    192       1.2      matt 	addi	%r15,%r16,-0x10
    193       1.2      matt 	addi	%r14,%r15,-0x10
    194       1.2      matt 	addi	%r13,%r14,-0x10
    195       1.2      matt 	addi	%r12,%r13,-0x10
    196       1.2      matt 	addi	%r11,%r12,-0x10
    197       1.2      matt 	addi	%r10,%r11,-0x10
    198       1.2      matt 	addi	%r9,%r10,-0x10
    199       1.2      matt 	addi	%r8,%r9,-0x10
    200       1.2      matt 	addi	%r7,%r8,-0x10
    201       1.2      matt 	addi	%r6,%r7,-0x10
    202       1.2      matt 	addi	%r5,%r6,-0x10
    203       1.2      matt 	addi	%r4,%r5,-0x10
    204       1.2      matt 	addi	%r3,%r4,-0x10
    205       1.2      matt 	addi	%r2,%r3,-0x10
    206       1.2      matt 	/* leave r1 alone */
    207       1.2      matt 	addi	%r0,%r2,-0x20
    208       1.2      matt 	b	_C_LABEL(instruction_tlb_error_vector)
    209       1.2      matt 	//b	_C_LABEL(program_vector)
    210       1.2      matt 	//b	_C_LABEL(external_input_vector)
    211       1.2      matt 3:
    212       1.2      matt #endif
    213       1.2      matt 
    214       1.2      matt 	/*
    215       1.2      matt 	 * TB is 50Mhz, watchdog should be ~10 seconds which makes that
    216       1.2      matt 	 * 500 million or 0x20000000.  Since it takes 3 bit transitions
    217       1.2      matt 	 * we really want 0x10000000.   That's bit 63-28 or 35.  This
    218       1.2      matt 	 * means we want WPEXT,WP to be 0b10_0011.
    219       1.2      matt 	 */
    220       1.2      matt 	lis	%r3,(TCR_WRC_RESET|TCR_WP_2_N(0x23))@ha
    221       1.2      matt 	addi	%r3,%r3,(TCR_WRC_RESET|TCR_WP_2_N(0x23))@l
    222       1.2      matt 	mtspr	SPR_TCR, %r3
    223       1.2      matt 	li	%r0, 0
    224       1.2      matt 	mtspr	SPR_TBL, %r0
    225       1.2      matt 	mtspr	SPR_TBU, %r0
    226       1.2      matt 	mtspr	SPR_DBCR0, %r0
    227       1.2      matt 
    228       1.2      matt #if 0
    229       1.2      matt 	/*
    230       1.2      matt 	 * Force all dirty lines in the kernel area to memory.
    231       1.2      matt 	 */
    232       1.6      matt 	lis	%r9,kernel_text@ha
    233       1.6      matt 	addi	%r9,%r9,kernel_text@l
    234       1.6      matt 4:	dcbst	%r0,%r9
    235       1.6      matt 	addi	%r9,%r9,32
    236       1.6      matt 	cmplw	%r9,%r4
    237       1.2      matt 	blt	%cr0,4b
    238       1.2      matt 	mbar	1
    239       1.2      matt 	msync
    240       1.2      matt 
    241       1.2      matt 	/*
    242       1.2      matt 	 * Turn off the data cache, and then invalidate it.
    243       1.2      matt 	 */
    244       1.2      matt 	li	%r3, 0
    245       1.2      matt 	mtspr	SPR_L1CSR0, %r3
    246       1.2      matt 	li	%r3, L1CSR_CFI
    247       1.2      matt 	mtspr	SPR_L1CSR0, %r3
    248       1.2      matt #endif
    249       1.2      matt 
    250       1.2      matt #if 1
    251       1.2      matt 	/*
    252       1.2      matt 	 * Clear any locks from the data or instruction caches.
    253       1.2      matt 	 */
    254       1.2      matt 	mfspr	%r3, SPR_L1CSR0
    255       1.2      matt 	ori	%r3, %r3, L1CSR_CLFR
    256       1.2      matt 	mtspr	SPR_L1CSR0, %r3
    257       1.2      matt 	mfspr	%r3, SPR_L1CSR1
    258       1.2      matt 	ori	%r3, %r3, L1CSR_CLFR
    259       1.2      matt 	mtspr	SPR_L1CSR1, %r3
    260       1.2      matt #endif
    261       1.2      matt 
    262       1.2      matt 	lis	%r3,__start@ha
    263       1.2      matt 	addi	%r3,%r3,__start@l
    264       1.2      matt 
    265       1.2      matt 	bl	_C_LABEL(initppc)
    266       1.2      matt 	bl	_C_LABEL(main)
    267       1.2      matt 
    268       1.2      matt loop:	b	loop			/* XXX not reached */
    269       1.2      matt 
    270       1.2      matt #include <powerpc/booke/trap_subr.S>
    271       1.2      matt #include <powerpc/powerpc/locore_subr.S>
    272       1.2      matt #include <powerpc/powerpc/pio_subr.S>
    273       1.2      matt #ifdef PPC_HAVE_SPE
    274       1.2      matt #include <powerpc/booke/spe_subr.S>
    275       1.2      matt #endif
    276       1.3      matt #if defined(MULTIPROCESSOR)
    277       1.3      matt #include <powerpc/booke/e500_mpsubr.S>
    278       1.3      matt #endif
    279       1.2      matt 
    280       1.2      matt #if 0
    281       1.2      matt 	.p2align 5
    282       1.2      matt ENTRY(tlbwe)
    283       1.2      matt 	isync
    284       1.2      matt 	tlbwe
    285       1.2      matt 	isync
    286       1.2      matt 	blr
    287       1.2      matt #endif
    288