source: mainline/boot/arch/sparc64/src/asm.S@ 339249f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 339249f was b97b348, checked in by Martin Decky <martin@…>, 15 years ago

do not use ofw_quiesce() (it can actually make more harm than good)
fix the order of arguments passed from the bootloader to kernel on sparc64 (this fixes booting on machines with non-zero physical address start)
remove separate cache.S, use the code directly in start.S

  • Property mode set to 100644
File size: 4.7 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
3# Copyright (c) 2006 Jakub Jermar
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# - Redistributions of source code must retain the above copyright
11# notice, this list of conditions and the following disclaimer.
12# - Redistributions in binary form must reproduce the above copyright
13# notice, this list of conditions and the following disclaimer in the
14# documentation and/or other materials provided with the distribution.
15# - The name of the author may not be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30#include <arch/arch.h>
31
32#define ICACHE_SIZE 8192
33#define ICACHE_LINE_SIZE 32
34#define ICACHE_SET_BIT (1 << 13)
35#define ASI_ICACHE_TAG 0x67
36
37.register %g2, #scratch
38.register %g3, #scratch
39.register %g6, #scratch
40.register %g7, #scratch
41
42.global start
43.global halt
44.global memcpy
45.global jump_to_kernel
46
47.section BOOTSTRAP, "ax"
48
49start:
50 ba %xcc, 1f
51 nop
52
53/*
54 * This header forces SILO to load the image at 0x4000.
55 * More precisely, SILO will think this is an old version of Linux.
56 */
57.ascii "HdrS"
58.word 0
59.half 0
60.half 0
61.half 0
62.half 0
63.word 0
64.word 0
65
66.align 8
671:
68 ! Disable interrupts and disable address masking.
69
70 wrpr %g0, PSTATE_PRIV_BIT, %pstate
71
72 wrpr %g0, NWINDOWS - 2, %cansave ! Set maximum saveable windows
73 wrpr %g0, 0, %canrestore ! Get rid of windows we will never need again
74 wrpr %g0, 0, %otherwin ! Make sure the window state is consistent
75 wrpr %g0, NWINDOWS - 1, %cleanwin ! Prevent needless clean_window traps for kernel
76
77 set initial_stack, %sp
78 add %sp, -STACK_BIAS, %sp
79
80 set ofw_cif, %l0
81
82 ! Initialize OpenFirmware
83
84 call ofw_init
85 stx %o4, [%l0]
86
87 ba %xcc, bootstrap
88 nop
89
90.align STACK_ALIGNMENT
91 .space STACK_SIZE
92initial_stack:
93 .space STACK_WINDOW_SAVE_AREA_SIZE
94
95.text
96
97halt:
98 ba %xcc, halt
99 nop
100
101memcpy:
102 ! Save dst
103
104 mov %o0, %o3
105 add %o1, 7, %g1
106 and %g1, -8, %g1
107 cmp %o1, %g1
108 be,pn %xcc, 3f
109 add %o0, 7, %g1
110 mov 0, %g3
111
112 0:
113 brz,pn %o2, 2f
114 mov 0, %g2
115
116 1:
117 ldub [%g3 + %o1], %g1
118 add %g2, 1, %g2
119 cmp %o2, %g2
120 stb %g1, [%g3 + %o0]
121 bne,pt %xcc, 1b
122 mov %g2, %g3
123
124 2:
125 ! Exit point
126
127 jmp %o7 + 8
128 mov %o3, %o0
129
130 3:
131 and %g1, -8, %g1
132 cmp %o0, %g1
133 bne,pt %xcc, 0b
134 mov 0, %g3
135 srlx %o2, 3, %g4
136 brz,pn %g4, 5f
137 mov 0, %g5
138
139 4:
140 sllx %g3, 3, %g2
141 add %g5, 1, %g3
142 ldx [%o1 + %g2], %g1
143 mov %g3, %g5
144 cmp %g4, %g3
145 bne,pt %xcc, 4b
146 stx %g1, [%o0 + %g2]
147
148 5:
149 and %o2, 7, %o2
150 brz,pn %o2, 2b
151 sllx %g4, 3, %g1
152 mov 0, %g2
153 add %g1, %o0, %o0
154 add %g1, %o1, %g4
155 mov 0, %g3
156
157 6:
158 ldub [%g2 + %g4], %g1
159 stb %g1, [%g2 + %o0]
160 add %g3, 1, %g2
161 cmp %o2, %g2
162 bne,pt %xcc, 6b
163 mov %g2, %g3
164
165 ! Exit point
166
167 jmp %o7 + 8
168 mov %o3, %o0
169
170jump_to_kernel:
171 /*
172 * Guarantee cache coherence:
173 * 1. Make sure that the code we have moved has drained to main memory.
174 * 2. Invalidate I-cache.
175 * 3. Flush instruction pipeline.
176 */
177
178 /*
179 * US3 processors have a write-invalidate cache, so explicitly
180 * invalidating it is not required. Whether to invalidate I-cache
181 * or not is decided according to the value of the 3rd argument
182 * (subarch).
183 */
184 cmp %o2, SUBARCH_US3
185 be %xcc, 1f
186 nop
187
188 0:
189 call icache_flush
190 nop
191
192 1:
193 membar #StoreStore
194
195 /*
196 * Flush the instruction pipeline.
197 */
198 flush %i7
199
200 ! Jump to kernel
201 jmp %o3
202 nop
203
204# Flush I-cache
205icache_flush:
206 set ((ICACHE_SIZE - ICACHE_LINE_SIZE) | ICACHE_SET_BIT), %g1
207 stxa %g0, [%g1] ASI_ICACHE_TAG
208
209 0:
210 membar #Sync
211 subcc %g1, ICACHE_LINE_SIZE, %g1
212 bnz,pt %xcc, 0b
213
214 stxa %g0, [%g1] ASI_ICACHE_TAG
215 membar #Sync
216 retl
217
218 ! SF Erratum #51
219
220 nop
221
222.global ofw
223ofw:
224 save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
225 set ofw_cif, %l0
226 ldx [%l0], %l0
227
228 rdpr %pstate, %l1
229 and %l1, ~PSTATE_AM_BIT, %l2
230 wrpr %l2, 0, %pstate
231
232 jmpl %l0, %o7
233 mov %i0, %o0
234
235 wrpr %l1, 0, %pstate
236
237 ret
238 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.