kickstart.S revision 1.2.6.2 1 /* $NetBSD: kickstart.S,v 1.2.6.2 2000/11/20 19:58:51 bouyer 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 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #define PPC_CACHESIZE 16384
40 #define PPC_LINESIZE 32
41
42 /*
43 Memst: .long 0x08000000
44 Krnst: .long 0x082f3400
45 Krnsz: .long 0x00100000
46 */
47 .globl _start
48 _start:
49 bl L2 /* we start with this address @ 0xfff00100 */
50 L2:
51 lis 13,0xf60000@ha
52 li 14,0x08
53 stb 14,0xf60000@l(13)
54 #ifdef DEBUG
55 lis 13,0xdff180@h
56 ori 13,13,0xdff180@l
57
58 lis 12,1000000@h
59 ori 12,12,1000000@l
60 mtctr 12
61 L2a:
62 li 14,0x00f
63 sth 14,0(13)
64 sync
65 li 14,0xf0f
66 sth 14,0(13)
67 sync
68 bdnz L2a
69 #endif
70 mflr 3
71 lwz 4,-16(3)
72 lwz 5,-12(3)
73 lwz 6,-8(3)
74 li 7,3
75 addi 8,6,3
76 cmplw 4,5
77 andc 8,8,7
78 srwi 9,8,2
79 mtctr 9
80 bgt Lb0
81 /* here: copying downwards and forwards */
82 lwz 9,0(5)
83 stw 9,0(4)
84 bdz Lflush
85 Lf1: lwzu 7,4(5)
86 stwu 7,4(4)
87 bdnz Lf1
88 b Lflush
89
90 Lb0: add 4,4,8 /* add the rounded up length */
91 add 5,5,8 /* add the rounded up length */
92 Lb1: lwzu 7,-4(5)
93 stwu 7,-4(4)
94 bdnz Lb1
95
96 Lflush:
97 #ifdef DEBUG
98 li 14,0xff0
99 sth 14,0(13)
100 sync
101 #endif
102 li 10,PPC_CACHESIZE/PPC_LINESIZE
103 li 11,PPC_LINESIZE
104 /* dcbst loop */
105 mtctr 10
106 lwz 12,-8(3)
107 Lfl1: dcbst 0,12
108 add 12,12,11
109 bdnz Lfl1
110 sync /* and wait for past instructions to finish */
111 /* icbi loop */
112 mtctr 10
113 lwz 12,-8(3)
114 Lfl2: icbi 0,12
115 add 12,12,11
116 bdnz Lfl2
117 sync /* and wait for past instructions to finish */
118 isync /* and flush instruction queue */
119 Ljump:
120 #ifdef DEBUG
121 li 14,0x0f0
122 sth 14,0(13)
123 sync
124 #endif
125 lwz 3,-16(3)
126 mtlr 3
127 blr
128 /* NOTREACHED */
129