Home | History | Annotate | Line # | Download | only in ppcboot
      1 /*	$NetBSD: kickstart.S,v 1.3 2008/04/28 20:23:13 martin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Ignatios Souvatzis.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #define PPC_CACHESIZE 16384
     33 #define PPC_LINESIZE 32
     34 
     35 /*
     36 Memst:	.long	0x08000000
     37 Krnst:	.long	0x082f3400
     38 Krnsz:	.long	0x00100000
     39  */
     40 	.globl _start
     41 _start:
     42 	bl	L2	/* we start with this address @ 0xfff00100 */
     43 L2:
     44 	lis	13,0xf60000@ha
     45 	li	14,0x08
     46 	stb	14,0xf60000@l(13)
     47 #ifdef DEBUG
     48 	lis	13,0xdff180@h
     49 	ori	13,13,0xdff180@l
     50 
     51 	lis	12,1000000@h
     52 	ori	12,12,1000000@l
     53 	mtctr	12
     54 L2a:
     55 	li	14,0x00f
     56 	sth	14,0(13)
     57 	sync
     58 	li	14,0xf0f
     59 	sth	14,0(13)
     60 	sync
     61 	bdnz	L2a
     62 #endif
     63 	mflr	3
     64 	lwz	4,-16(3)
     65 	lwz	5,-12(3)
     66 	lwz	6,-8(3)
     67 	li	7,3
     68 	addi	8,6,3
     69 	cmplw	4,5
     70 	andc	8,8,7
     71 	srwi	9,8,2
     72 	mtctr	9
     73 	bgt	Lb0
     74 /* here: copying downwards and forwards */
     75 	lwz	9,0(5)
     76 	stw	9,0(4)
     77 	bdz	Lflush
     78 Lf1:	lwzu	7,4(5)
     79 	stwu	7,4(4)
     80 	bdnz	Lf1
     81 	b	Lflush
     82 
     83 Lb0:	add	4,4,8	/* add the rounded up length */
     84 	add	5,5,8	/* add the rounded up length */
     85 Lb1:	lwzu	7,-4(5)
     86 	stwu	7,-4(4)
     87 	bdnz	Lb1
     88 
     89 Lflush:
     90 #ifdef DEBUG
     91 	li	14,0xff0
     92 	sth	14,0(13)
     93 	sync
     94 #endif
     95 	li	10,PPC_CACHESIZE/PPC_LINESIZE
     96 	li	11,PPC_LINESIZE
     97 /* dcbst loop */
     98 	mtctr	10
     99 	lwz	12,-8(3)
    100 Lfl1:	dcbst	0,12
    101 	add	12,12,11
    102 	bdnz	Lfl1
    103 	sync		/* and wait for past instructions to finish */
    104 /* icbi loop */
    105 	mtctr	10
    106 	lwz	12,-8(3)
    107 Lfl2:	icbi	0,12
    108 	add	12,12,11
    109 	bdnz	Lfl2
    110 	sync		/* and wait for past instructions to finish */
    111 	isync		/* and flush instruction queue */
    112 Ljump:
    113 #ifdef DEBUG
    114 	li	14,0x0f0
    115 	sth	14,0(13)
    116 	sync
    117 #endif
    118 	lwz	3,-16(3)
    119 	mtlr	3
    120 	blr
    121 /* NOTREACHED */
    122