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