ofwstart.S revision 1.1 1 /* $NetBSD: ofwstart.S,v 1.1 2008/01/09 19:34:45 garbled Exp $ */
2
3 /*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tim Rightnour
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 #ifdef XCOFF_GLUE
40 .text
41 .globl _entry
42 _entry:
43 .long _start,0,0
44 #endif /* XCOFF_GLUE */
45
46 .text
47 .globl _start
48 /* This is the magical note section that IBM machines require
49 * to boot. This should be a note, but gnu ld will not let us
50 * position it at the start of the file.
51 */
52 # length of name
53 .long 8
54 # note descriptor size
55 .long 24
56 # note type (IEEE 1275)
57 .long 0x1275
58 # name of owner
59 .asciz "PowerPC"
60 .balign 4
61
62 # note descriptor
63 # real mode (-1) or virtual mode (0)
64 .long 0
65 # real-base
66 .long -1
67 # real-size
68 .long -1
69 # virt-base
70 .long -1
71 # virt-size
72 .long -1
73 # load-base
74 .long 0x4000
75
76 /* note for dealing with IBM LPARs */
77 # length of name
78 .long 24
79 # note descriptor size
80 .long 28
81 # note type
82 .long 0x12759999
83 # name of owner
84 .asciz "IBM,RPA-Client-Config"
85 .balign 4
86
87 # lpar affinity
88 .long 0
89 # minimum size in megabytes
90 .long 64
91 # minimum percentage size
92 .long 0
93 # max pft size ( 2^48 bytes )
94 .long 48
95 # splpar
96 .long 1
97 # min load ?
98 .long -1
99 # new mem def ?
100 .long 0
101
102 _start:
103 sync
104 isync
105 lis %r1,stack@ha
106 addi %r1,%r1,stack@l
107 addi %r1,%r1,8192
108
109 mfmsr %r8
110 li %r0,0
111 mtmsr %r0
112 isync
113
114 mtibatu 0,%r0
115 mtibatu 1,%r0
116 mtibatu 2,%r0
117 mtibatu 3,%r0
118 mtdbatu 0,%r0
119 mtdbatu 1,%r0
120 mtdbatu 2,%r0
121 mtdbatu 3,%r0
122
123 li %r9,0x12 /* BATL(0, BAT_M, BAT_PP_RW) */
124 mtibatl 0,%r9
125 mtdbatl 0,%r9
126 li %r9,0x1ffe /* BATU(0, BAT_BL_256M, BAT_Vs) */
127 mtibatu 0,%r9
128 mtdbatu 0,%r9
129 isync
130
131 mtmsr %r8
132 isync
133
134 /*
135 * Make sure that .bss is zeroed
136 */
137
138 li %r0,0
139 lis %r8,_edata@ha
140 addi %r8,%r8,_edata@l
141 lis %r9,_end@ha
142 addi %r9,%r9,_end@l
143
144 5: cmpw 0,%r8,%r9
145 bge 6f
146 stw %r0,0(%r8)
147 addi %r8,%r8,4
148 b 5b
149
150 6: b startup
151