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
RevLine 
[b7b5f83]1#
[df4ed85]2# Copyright (c) 2006 Martin Decky
[4872160]3# Copyright (c) 2006 Jakub Jermar
[b7b5f83]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
[4872160]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
[2e672fd]36
[e731b0d]37.register %g2, #scratch
38.register %g3, #scratch
[4872160]39.register %g6, #scratch
40.register %g7, #scratch
[da349da0]41
[4872160]42.global start
[b7b5f83]43.global halt
44.global memcpy
45.global jump_to_kernel
46
[4872160]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
[b7b5f83]97halt:
[a1a83e5e]98 ba %xcc, halt
[b7b5f83]99 nop
[c82950a]100
[e731b0d]101memcpy:
[4872160]102 ! Save dst
103
104 mov %o0, %o3
[e731b0d]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:
[4872160]125 ! Exit point
126
127 jmp %o7 + 8
[e731b0d]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
[4872160]165 ! Exit point
166
167 jmp %o7 + 8
[e731b0d]168 mov %o3, %o0
[b7b5f83]169
170jump_to_kernel:
[0af4f9e]171 /*
[4872160]172 * Guarantee cache coherence:
[1eb154f]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.
[965dc18]176 */
[e731b0d]177
[965dc18]178 /*
179 * US3 processors have a write-invalidate cache, so explicitly
180 * invalidating it is not required. Whether to invalidate I-cache
[4872160]181 * or not is decided according to the value of the 3rd argument
182 * (subarch).
[965dc18]183 */
[b97b348]184 cmp %o2, SUBARCH_US3
[a1a83e5e]185 be %xcc, 1f
[965dc18]186 nop
[e731b0d]187
188 0:
189 call icache_flush
190 nop
[4872160]191
[e731b0d]192 1:
193 membar #StoreStore
[965dc18]194
195 /*
196 * Flush the instruction pipeline.
197 */
[e731b0d]198 flush %i7
199
[4872160]200 ! Jump to kernel
[b97b348]201 jmp %o3
[94d614e]202 nop
[2e672fd]203
[1eb154f]204# Flush I-cache
205icache_flush:
[e731b0d]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
[1eb154f]216 retl
[4872160]217
[1eb154f]218 ! SF Erratum #51
[4872160]219
[1eb154f]220 nop
[e731b0d]221
[2e672fd]222.global ofw
223ofw:
224 save %sp, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
225 set ofw_cif, %l0
226 ldx [%l0], %l0
[e731b0d]227
[4872160]228 rdpr %pstate, %l1
229 and %l1, ~PSTATE_AM_BIT, %l2
230 wrpr %l2, 0, %pstate
[e731b0d]231
[2e672fd]232 jmpl %l0, %o7
233 mov %i0, %o0
[e731b0d]234
[2e672fd]235 wrpr %l1, 0, %pstate
[e731b0d]236
[2e672fd]237 ret
238 restore %o0, 0, %o0
Note: See TracBrowser for help on using the repository browser.