source: mainline/kernel/arch/sparc64/src/asm.S@ 5ea37b1

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

add early_putchar() which can be used to do early kernel console output for debugging purposes
(the availability of this feature depends on each platform and specific configuration, currently it works only on ia32/amd64 with EGA and no framebuffer)
instrument more kernel functions
mark some functions as no_instrument (context_restore(), overlaps(), main_bsp())

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2005 Jakub Jermar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <arch/arch.h>
30#include <arch/stack.h>
31
32.text
33
34.register %g2, #scratch
35.register %g3, #scratch
36
37/*
38 * This is the assembly language version of our _memcpy() generated by gcc.
39 */
40.global memcpy
41memcpy:
42 mov %o0, %o3 /* save dst */
43 add %o1, 7, %g1
44 and %g1, -8, %g1
45 cmp %o1, %g1
46 be,pn %xcc, 3f
47 add %o0, 7, %g1
48 mov 0, %g3
49
50 0:
51
52 brz,pn %o2, 2f
53 mov 0, %g2
54
55 1:
56
57 ldub [%g3 + %o1], %g1
58 add %g2, 1, %g2
59 cmp %o2, %g2
60 stb %g1, [%g3 + %o0]
61 bne,pt %xcc, 1b
62 mov %g2, %g3
63
64 2:
65
66 jmp %o7 + 8 /* exit point */
67 mov %o3, %o0
68
69 3:
70
71 and %g1, -8, %g1
72 cmp %o0, %g1
73 bne,pt %xcc, 0b
74 mov 0, %g3
75 srlx %o2, 3, %g4
76 brz,pn %g4, 5f
77 mov 0, %g5
78
79 4:
80
81 sllx %g3, 3, %g2
82 add %g5, 1, %g3
83 ldx [%o1 + %g2], %g1
84 mov %g3, %g5
85 cmp %g4, %g3
86 bne,pt %xcc, 4b
87 stx %g1, [%o0 + %g2]
88
89 5:
90
91 and %o2, 7, %o2
92 brz,pn %o2, 2b
93 sllx %g4, 3, %g1
94 mov 0, %g2
95 add %g1, %o0, %o0
96 add %g1, %o1, %g4
97 mov 0, %g3
98
99 6:
100
101 ldub [%g2 + %g4], %g1
102 stb %g1, [%g2 + %o0]
103 add %g3, 1, %g2
104 cmp %o2, %g2
105 bne,pt %xcc, 6b
106 mov %g2, %g3
107
108 jmp %o7 + 8 /* exit point */
109 mov %o3, %o0
110
111/*
112 * Almost the same as memcpy() except the loads are from userspace.
113 */
114.global memcpy_from_uspace
115memcpy_from_uspace:
116 mov %o0, %o3 /* save dst */
117 add %o1, 7, %g1
118 and %g1, -8, %g1
119 cmp %o1, %g1
120 be,pn %xcc, 3f
121 add %o0, 7, %g1
122 mov 0, %g3
123
124 0:
125
126 brz,pn %o2, 2f
127 mov 0, %g2
128
129 1:
130
131 lduba [%g3 + %o1] ASI_AIUS, %g1
132 add %g2, 1, %g2
133 cmp %o2, %g2
134 stb %g1, [%g3 + %o0]
135 bne,pt %xcc, 1b
136 mov %g2, %g3
137
138 2:
139
140 jmp %o7 + 8 /* exit point */
141 mov %o3, %o0
142
143 3:
144
145 and %g1, -8, %g1
146 cmp %o0, %g1
147 bne,pt %xcc, 0b
148 mov 0, %g3
149 srlx %o2, 3, %g4
150 brz,pn %g4, 5f
151 mov 0, %g5
152
153 4:
154
155 sllx %g3, 3, %g2
156 add %g5, 1, %g3
157 ldxa [%o1 + %g2] ASI_AIUS, %g1
158 mov %g3, %g5
159 cmp %g4, %g3
160 bne,pt %xcc, 4b
161 stx %g1, [%o0 + %g2]
162
163 5:
164
165 and %o2, 7, %o2
166 brz,pn %o2, 2b
167 sllx %g4, 3, %g1
168 mov 0, %g2
169 add %g1, %o0, %o0
170 add %g1, %o1, %g4
171 mov 0, %g3
172
173 6:
174
175 lduba [%g2 + %g4] ASI_AIUS, %g1
176 stb %g1, [%g2 + %o0]
177 add %g3, 1, %g2
178 cmp %o2, %g2
179 bne,pt %xcc, 6b
180 mov %g2, %g3
181
182 jmp %o7 + 8 /* exit point */
183 mov %o3, %o0
184
185/*
186 * Almost the same as memcpy() except the stores are to userspace.
187 */
188.global memcpy_to_uspace
189memcpy_to_uspace:
190 mov %o0, %o3 /* save dst */
191 add %o1, 7, %g1
192 and %g1, -8, %g1
193 cmp %o1, %g1
194 be,pn %xcc, 3f
195 add %o0, 7, %g1
196 mov 0, %g3
197
198 0:
199
200 brz,pn %o2, 2f
201 mov 0, %g2
202
203 1:
204
205 ldub [%g3 + %o1], %g1
206 add %g2, 1, %g2
207 cmp %o2, %g2
208 stba %g1, [%g3 + %o0] ASI_AIUS
209 bne,pt %xcc, 1b
210 mov %g2, %g3
211
212 2:
213
214 jmp %o7 + 8 /* exit point */
215 mov %o3, %o0
216
217 3:
218
219 and %g1, -8, %g1
220 cmp %o0, %g1
221 bne,pt %xcc, 0b
222 mov 0, %g3
223 srlx %o2, 3, %g4
224 brz,pn %g4, 5f
225 mov 0, %g5
226
227 4:
228
229 sllx %g3, 3, %g2
230 add %g5, 1, %g3
231 ldx [%o1 + %g2], %g1
232 mov %g3, %g5
233 cmp %g4, %g3
234 bne,pt %xcc, 4b
235 stxa %g1, [%o0 + %g2] ASI_AIUS
236
237 5:
238
239 and %o2, 7, %o2
240 brz,pn %o2, 2b
241 sllx %g4, 3, %g1
242 mov 0, %g2
243 add %g1, %o0, %o0
244 add %g1, %o1, %g4
245 mov 0, %g3
246
247 6:
248
249 ldub [%g2 + %g4], %g1
250 stba %g1, [%g2 + %o0] ASI_AIUS
251 add %g3, 1, %g2
252 cmp %o2, %g2
253 bne,pt %xcc, 6b
254 mov %g2, %g3
255
256 jmp %o7 + 8 /* exit point */
257 mov %o3, %o0
258
259.global memcpy_from_uspace_failover_address
260.global memcpy_to_uspace_failover_address
261memcpy_from_uspace_failover_address:
262memcpy_to_uspace_failover_address:
263 jmp %o7 + 8 /* exit point */
264 mov %g0, %o0 /* return 0 on failure */
265
266.global memsetb
267memsetb:
268 ba %xcc, _memsetb
269 nop
270
271.global memsetw
272memsetw:
273 ba %xcc, _memsetw
274 nop
275
276.global early_putchar
277early_putchar:
278 retl
279 nop
Note: See TracBrowser for help on using the repository browser.