Home | History | Annotate | Line # | Download | only in explora
explora_start.S revision 1.3.4.1
      1  1.3.4.1   rpaulo /*	$NetBSD: explora_start.S,v 1.3.4.1 2006/09/09 02:39:05 rpaulo Exp $	*/
      2      1.1  hannken 
      3      1.1  hannken /*-
      4      1.1  hannken  * Copyright (c) 2003 The NetBSD Foundation, Inc.
      5      1.1  hannken  * All rights reserved.
      6      1.1  hannken  *
      7      1.1  hannken  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  hannken  * by Juergen Hannken-Illjes.
      9      1.1  hannken  *
     10      1.1  hannken  * Redistribution and use in source and binary forms, with or without
     11      1.1  hannken  * modification, are permitted provided that the following conditions
     12      1.1  hannken  * are met:
     13      1.1  hannken  * 1. Redistributions of source code must retain the above copyright
     14      1.1  hannken  *    notice, this list of conditions and the following disclaimer.
     15      1.1  hannken  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  hannken  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  hannken  *    documentation and/or other materials provided with the distribution.
     18      1.1  hannken  * 3. All advertising materials mentioning features or use of this software
     19      1.1  hannken  *    must display the following acknowledgement:
     20      1.1  hannken  *      This product includes software developed by the NetBSD
     21      1.1  hannken  *      Foundation, Inc. and its contributors.
     22      1.1  hannken  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.1  hannken  *    contributors may be used to endorse or promote products derived
     24      1.1  hannken  *    from this software without specific prior written permission.
     25      1.1  hannken  *
     26      1.1  hannken  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.1  hannken  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.1  hannken  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.1  hannken  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.1  hannken  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.1  hannken  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.1  hannken  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.1  hannken  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.1  hannken  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.1  hannken  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.1  hannken  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1  hannken  */
     38      1.1  hannken 
     39      1.1  hannken /*
     40      1.1  hannken  * Initial state:
     41      1.1  hannken  *
     42      1.1  hannken  * iccr = 0x00008001 0x80000000-0x87ffffff 0xf80000000-0xffffffff
     43      1.1  hannken  * dccr = 0x00008001 0x80000000-0x87ffffff 0xf80000000-0xffffffff
     44      1.1  hannken  * dcwr = 0x00000000
     45      1.1  hannken  * msr  = 0x00001000 ME=machine check enable
     46      1.1  hannken  *
     47      1.1  hannken  */
     48      1.1  hannken 
     49      1.1  hannken #include "assym.h"
     50      1.1  hannken 
     51      1.2      chs #define _NOREGNAMES
     52      1.2      chs 
     53      1.1  hannken #include <machine/param.h>
     54      1.1  hannken #include <machine/psl.h>
     55      1.1  hannken #include <machine/trap.h>
     56      1.1  hannken #include <machine/asm.h>
     57      1.1  hannken 
     58      1.1  hannken #include <powerpc/spr.h>
     59      1.1  hannken #include <powerpc/ibm4xx/dcr403cgx.h>
     60      1.1  hannken #include <powerpc/ibm4xx/pmap.h>
     61      1.1  hannken 
     62      1.1  hannken #include "opt_ddb.h"
     63      1.1  hannken #include "opt_ppcparam.h"
     64      1.1  hannken 
     65      1.1  hannken GLOBAL(proc0paddr)
     66      1.1  hannken 	.long	0			/* proc0 p_addr */
     67      1.1  hannken 
     68      1.1  hannken /*
     69      1.1  hannken  * Initially the dram starts at 0x01000000. This is way too high.
     70      1.1  hannken  * We relocate dram to 0x00000000. We use the video ram at 0xf0000000
     71      1.1  hannken  * as a temporary staging area.
     72      1.1  hannken  */
     73      1.1  hannken 
     74      1.1  hannken #define STAGE1_BASE	0xf0000000
     75      1.1  hannken 
     76      1.1  hannken 	.text
     77      1.1  hannken 	.globl	__start
     78      1.1  hannken __start:
     79      1.1  hannken 	b	1f
     80      1.1  hannken 	nop
     81      1.1  hannken 	nop
     82      1.1  hannken 	.long	0
     83      1.1  hannken 	.ascii	"XncdPPC\0"
     84      1.1  hannken 	.long	0
     85      1.1  hannken 	.long	0
     86      1.1  hannken 
     87      1.1  hannken 1:
     88      1.1  hannken 	/* Disable exceptions, caches, invalidate all TLB's. */
     89      1.1  hannken 
     90      1.1  hannken 	li	0,0
     91      1.1  hannken 	mtmsr	0
     92      1.1  hannken 	mttcr	0
     93      1.1  hannken 	mtdccr	0
     94      1.1  hannken 	mticcr	0
     95      1.1  hannken 	sync
     96      1.1  hannken 	isync
     97      1.1  hannken 
     98      1.1  hannken /* Clear caches and invalidate tlbs */
     99      1.1  hannken 	li	7,256
    100      1.1  hannken 	mtctr	7
    101      1.1  hannken 	li	6,0
    102      1.1  hannken 1:
    103      1.1  hannken 	dccci	0,6
    104      1.1  hannken 	addi	6,6,16
    105      1.1  hannken 	bdnz	1b
    106      1.1  hannken 
    107      1.1  hannken 	li	7,512
    108      1.1  hannken 	mtctr	7
    109      1.1  hannken 	li	6,0
    110      1.1  hannken 1:
    111      1.1  hannken 	iccci	0,6
    112      1.1  hannken 	addi	6,6,16
    113      1.1  hannken 	bdnz	1b
    114      1.1  hannken 
    115      1.1  hannken 	tlbia
    116      1.1  hannken 	sync
    117      1.1  hannken 	isync
    118      1.1  hannken 
    119      1.1  hannken /* Get current address -- NOT the same as . */
    120      1.1  hannken 
    121      1.1  hannken 	bl	_next
    122      1.1  hannken _next:
    123      1.1  hannken 	mflr	3
    124      1.1  hannken 	subi	3,3,_next-__start
    125      1.1  hannken 	lis	4,STAGE1_BASE@h
    126      1.1  hannken 	ori	4,4,STAGE1_BASE@l
    127      1.1  hannken 	li	5,stage1size
    128      1.1  hannken 
    129      1.1  hannken 1:
    130      1.1  hannken 	lbz	1,0(3)
    131      1.1  hannken 	mr	0,5
    132      1.1  hannken 	cmpwi	0,0
    133      1.1  hannken 	stb	1,0(4)
    134      1.1  hannken 	addi	3,3,1
    135      1.1  hannken 	addi	4,4,1
    136      1.1  hannken 	addi	5,5,-1
    137      1.1  hannken 	bgt	1b
    138      1.1  hannken 
    139      1.1  hannken /* Jump into the staging area so we can remap the dram. */
    140      1.1  hannken 
    141      1.1  hannken 	lis	0,stage1reloc@h
    142      1.1  hannken 	ori	0,0,stage1reloc@l
    143      1.1  hannken 	mtlr	0
    144      1.1  hannken 	blr
    145      1.1  hannken 
    146      1.1  hannken stage1reloc = .-__start+STAGE1_BASE
    147      1.1  hannken 
    148      1.1  hannken /* Remap the dram from 0x01000000 to 0x00000000. */
    149      1.1  hannken 
    150      1.1  hannken #define REMAP(r, tmp1, tmp2) \
    151      1.1  hannken 	mfbr##r	tmp1 ; \
    152      1.1  hannken 	lis	tmp2,0xff ; \
    153      1.1  hannken 	ori	tmp2,tmp2,0xffff ; \
    154      1.1  hannken 	cmplw	tmp1,tmp2 ; \
    155      1.1  hannken 	ble	1f ; \
    156      1.1  hannken 	addis	tmp1,tmp1,0xf000 ; \
    157      1.1  hannken 	mtbr##r	tmp1 ; \
    158      1.1  hannken 1:
    159      1.1  hannken 
    160      1.1  hannken 	REMAP(4, 1, 2)
    161      1.1  hannken 	REMAP(5, 1, 2)
    162      1.1  hannken 	REMAP(6, 1, 2)
    163      1.1  hannken 	REMAP(7, 1, 2)
    164      1.1  hannken 
    165      1.1  hannken #undef REMAP
    166      1.1  hannken 
    167      1.1  hannken /* Initial setup. */
    168      1.1  hannken 
    169      1.1  hannken 	ba	stage2
    170      1.1  hannken 
    171      1.1  hannken stage2:
    172      1.1  hannken 
    173      1.1  hannken #ifdef PPC_4XX_NOCACHE
    174      1.1  hannken 	li	0,0
    175      1.1  hannken #else
    176      1.1  hannken 	lis	0,0xfffc
    177      1.1  hannken #endif
    178      1.1  hannken 	mtdccr	0
    179      1.1  hannken 	mticcr	0
    180      1.1  hannken 	sync
    181      1.1  hannken 	isync
    182      1.1  hannken 
    183      1.1  hannken /* get start of bss */
    184      1.1  hannken 	lis	7,_C_LABEL(edata)-4@h
    185      1.1  hannken 	ori	7,7,_C_LABEL(edata)-4@l
    186      1.1  hannken /* get end of kernel */
    187      1.1  hannken 	lis	4,_C_LABEL(end)@h
    188      1.1  hannken 	ori	4,4,_C_LABEL(end)@l
    189      1.1  hannken /* clear bss */
    190      1.1  hannken 	li	3,0
    191      1.1  hannken 1:
    192      1.1  hannken 	stwu	3,4(7)
    193      1.1  hannken 	cmpw	7,4
    194      1.1  hannken 	bne+	1b
    195      1.1  hannken 
    196      1.1  hannken 	INIT_CPUINFO(4,1,9,0)
    197      1.1  hannken 
    198      1.1  hannken 	lis	3,__start@h
    199      1.1  hannken 	ori	3,3,__start@l
    200      1.1  hannken 
    201      1.1  hannken /* Run the remaining setup in C. */
    202      1.1  hannken 	bl	_C_LABEL(bootstrap)
    203      1.1  hannken 
    204      1.1  hannken 	bl	_C_LABEL(main)
    205      1.1  hannken 
    206      1.1  hannken 	/* NOTREACHED */
    207      1.1  hannken 2:	nop
    208      1.1  hannken 	b	2b
    209      1.1  hannken 
    210      1.1  hannken stage1size = .-__start
    211      1.1  hannken 
    212      1.1  hannken #include <powerpc/ibm4xx/4xx_locore.S>
    213