source: mainline/kernel/arch/sparc64/src/asm.S

Last change on this file was 28a5ebd, checked in by Martin Decky <martin@…>, 5 years ago

Use char32_t instead of wchat_t to represent UTF-32 strings

The intention of the native HelenOS string API has been always to
support Unicode in the UTF-8 and UTF-32 encodings as the sole character
representations and ignore the obsolete mess of older single-byte and
multibyte character encodings. Before C11, the wchar_t type has been
slightly misused for the purpose of the UTF-32 strings. The newer
char32_t type is obviously a much more suitable option. The standard
defines char32_t as uint_least32_t, thus we can take the liberty to fix
it to uint32_t.

To maintain compatilibity with the C Standard, the putwchar(wchar_t)
functions has been replaced by our custom putuchar(char32_t) functions
where appropriate.

  • Property mode set to 100644
File size: 3.8 KB
RevLine 
[dbd4ae5]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 */
[437ee6a4]28
[a52e2f4]29#include <abi/asmtool.h>
[fd85ae5]30#include <arch/arch.h>
[0ffa3ef5]31#include <arch/stack.h>
32
[437ee6a4]33.text
34
[dbd4ae5]35.register %g2, #scratch
36.register %g3, #scratch
[0ffa3ef5]37
[fd85ae5]38/*
39 * Almost the same as memcpy() except the loads are from userspace.
40 */
[a52e2f4]41FUNCTION_BEGIN(memcpy_from_uspace)
[dbd4ae5]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
[a35b458]49
[dbd4ae5]50 0:
[a35b458]51
[dbd4ae5]52 brz,pn %o2, 2f
53 mov 0, %g2
[a35b458]54
[dbd4ae5]55 1:
[a35b458]56
[dbd4ae5]57 lduba [%g3 + %o1] ASI_AIUS, %g1
58 add %g2, 1, %g2
59 cmp %o2, %g2
60 stb %g1, [%g3 + %o0]
61 bne,pt %xcc, 1b
62 mov %g2, %g3
[a35b458]63
[dbd4ae5]64 2:
[a35b458]65
[dbd4ae5]66 jmp %o7 + 8 /* exit point */
67 mov %o3, %o0
[a35b458]68
[dbd4ae5]69 3:
[a35b458]70
[dbd4ae5]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
[a35b458]78
[dbd4ae5]79 4:
[a35b458]80
[dbd4ae5]81 sllx %g3, 3, %g2
82 add %g5, 1, %g3
83 ldxa [%o1 + %g2] ASI_AIUS, %g1
84 mov %g3, %g5
85 cmp %g4, %g3
86 bne,pt %xcc, 4b
87 stx %g1, [%o0 + %g2]
[a35b458]88
[dbd4ae5]89 5:
[a35b458]90
[dbd4ae5]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
[a35b458]98
[dbd4ae5]99 6:
[a35b458]100
[dbd4ae5]101 lduba [%g2 + %g4] ASI_AIUS, %g1
102 stb %g1, [%g2 + %o0]
103 add %g3, 1, %g2
104 cmp %o2, %g2
105 bne,pt %xcc, 6b
106 mov %g2, %g3
[a35b458]107
[dbd4ae5]108 jmp %o7 + 8 /* exit point */
109 mov %o3, %o0
[a52e2f4]110FUNCTION_END(memcpy_from_uspace)
[fd85ae5]111
112/*
113 * Almost the same as memcpy() except the stores are to userspace.
114 */
[a52e2f4]115FUNCTION_BEGIN(memcpy_to_uspace)
[dbd4ae5]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
[a35b458]123
[dbd4ae5]124 0:
[a35b458]125
[dbd4ae5]126 brz,pn %o2, 2f
127 mov 0, %g2
[a35b458]128
[dbd4ae5]129 1:
[a35b458]130
[dbd4ae5]131 ldub [%g3 + %o1], %g1
132 add %g2, 1, %g2
133 cmp %o2, %g2
134 stba %g1, [%g3 + %o0] ASI_AIUS
135 bne,pt %xcc, 1b
136 mov %g2, %g3
[a35b458]137
[dbd4ae5]138 2:
[a35b458]139
[dbd4ae5]140 jmp %o7 + 8 /* exit point */
141 mov %o3, %o0
[a35b458]142
[dbd4ae5]143 3:
[a35b458]144
[dbd4ae5]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
[a35b458]152
[dbd4ae5]153 4:
[a35b458]154
[dbd4ae5]155 sllx %g3, 3, %g2
156 add %g5, 1, %g3
157 ldx [%o1 + %g2], %g1
158 mov %g3, %g5
159 cmp %g4, %g3
160 bne,pt %xcc, 4b
161 stxa %g1, [%o0 + %g2] ASI_AIUS
[a35b458]162
[dbd4ae5]163 5:
[a35b458]164
[dbd4ae5]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
[a35b458]172
[dbd4ae5]173 6:
[a35b458]174
[dbd4ae5]175 ldub [%g2 + %g4], %g1
176 stba %g1, [%g2 + %o0] ASI_AIUS
177 add %g3, 1, %g2
178 cmp %o2, %g2
179 bne,pt %xcc, 6b
180 mov %g2, %g3
[a35b458]181
[dbd4ae5]182 jmp %o7 + 8 /* exit point */
183 mov %o3, %o0
[a52e2f4]184FUNCTION_END(memcpy_to_uspace)
[fd85ae5]185
[a52e2f4]186SYMBOL(memcpy_from_uspace_failover_address)
187SYMBOL(memcpy_to_uspace_failover_address)
[dbd4ae5]188 jmp %o7 + 8 /* exit point */
189 mov %g0, %o0 /* return 0 on failure */
[e3c762cd]190
[28a5ebd]191FUNCTION_BEGIN(early_putuchar)
[da52547]192 retl
193 nop
[28a5ebd]194FUNCTION_END(early_putuchar)
Note: See TracBrowser for help on using the repository browser.