]>
Commit | Line | Data |
---|---|---|
ae6b8730 RH |
1 | /* Set a block of memory to some byte value. |
2 | For SPARC v7. | |
2b778ceb | 3 | Copyright (C) 1996-2021 Free Software Foundation, Inc. |
ae6b8730 RH |
4 | This file is part of the GNU C Library. |
5 | Contributed by David S. Miller <davem@caip.rutgers.edu> and | |
6 | Jakub Jelinek <jj@ultra.linux.cz>. | |
7 | ||
8 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
9 | modify it under the terms of the GNU Lesser General Public |
10 | License as published by the Free Software Foundation; either | |
11 | version 2.1 of the License, or (at your option) any later version. | |
ae6b8730 RH |
12 | |
13 | The GNU C Library is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 16 | Lesser General Public License for more details. |
ae6b8730 | 17 | |
41bdb6e2 | 18 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 19 | License along with the GNU C Library; if not, see |
5a82c748 | 20 | <https://www.gnu.org/licenses/>. */ |
ae6b8730 RH |
21 | |
22 | #include <sysdep.h> | |
23 | ||
24 | /* Store 64 bytes at (BASE + OFFSET) using value SOURCE. */ | |
25 | #define ZERO_BIG_BLOCK(base, offset, source) \ | |
26 | std source, [base + offset + 0x00]; \ | |
27 | std source, [base + offset + 0x08]; \ | |
28 | std source, [base + offset + 0x10]; \ | |
29 | std source, [base + offset + 0x18]; \ | |
30 | std source, [base + offset + 0x20]; \ | |
31 | std source, [base + offset + 0x28]; \ | |
32 | std source, [base + offset + 0x30]; \ | |
33 | std source, [base + offset + 0x38]; | |
34 | ||
35 | #define ZERO_LAST_BLOCKS(base, offset, source) \ | |
36 | std source, [base - offset - 0x38]; \ | |
37 | std source, [base - offset - 0x30]; \ | |
38 | std source, [base - offset - 0x28]; \ | |
39 | std source, [base - offset - 0x20]; \ | |
40 | std source, [base - offset - 0x18]; \ | |
41 | std source, [base - offset - 0x10]; \ | |
42 | std source, [base - offset - 0x08]; \ | |
43 | std source, [base - offset - 0x00]; | |
44 | ||
45 | .text | |
46 | .align 4 | |
47 | ENTRY(__bzero) | |
48 | b 1f | |
49 | mov %g0, %g3 | |
50 | ||
51 | 3: cmp %o2, 3 | |
52 | be 2f | |
53 | stb %g3, [%o0] | |
54 | ||
55 | cmp %o2, 2 | |
56 | be 2f | |
57 | stb %g3, [%o0 + 0x01] | |
58 | ||
59 | stb %g3, [%o0 + 0x02] | |
60 | 2: sub %o2, 4, %o2 | |
61 | add %o1, %o2, %o1 | |
62 | b 4f | |
63 | sub %o0, %o2, %o0 | |
64 | END(__bzero) | |
65 | ||
66 | ENTRY(memset) | |
67 | and %o1, 0xff, %g3 | |
68 | sll %g3, 8, %g2 | |
69 | or %g3, %g2, %g3 | |
70 | sll %g3, 16, %g2 | |
71 | or %g3, %g2, %g3 | |
72 | orcc %o2, %g0, %o1 | |
73 | 1: cmp %o1, 7 | |
74 | bleu 7f | |
75 | mov %o0, %g1 | |
76 | ||
77 | andcc %o0, 3, %o2 | |
78 | bne 3b | |
79 | 4: andcc %o0, 4, %g0 | |
80 | ||
81 | be 2f | |
82 | mov %g3, %g2 | |
83 | ||
84 | st %g3, [%o0] | |
85 | sub %o1, 4, %o1 | |
86 | add %o0, 4, %o0 | |
87 | 2: andcc %o1, 0xffffff80, %o3 | |
88 | be 9f | |
89 | andcc %o1, 0x78, %o2 | |
90 | 4: ZERO_BIG_BLOCK (%o0, 0x00, %g2) | |
91 | subcc %o3, 128, %o3 | |
92 | ZERO_BIG_BLOCK (%o0, 0x40, %g2) | |
93 | bne 4b | |
94 | add %o0, 128, %o0 | |
95 | ||
96 | orcc %o2, %g0, %g0 | |
97 | 9: be 6f | |
98 | andcc %o1, 7, %o1 | |
99 | ||
100 | mov %o7, %g4 | |
101 | 101: call 100f | |
102 | srl %o2, 1, %o3 | |
103 | mov %g4, %o7 | |
104 | jmpl %o4 + (20f + 64 - 101b), %g0 | |
105 | add %o0, %o2, %o0 | |
106 | ||
107 | 100: retl | |
108 | sub %o7, %o3, %o4 | |
109 | ||
110 | 20: ZERO_LAST_BLOCKS(%o0, 0x48, %g2) | |
111 | ZERO_LAST_BLOCKS(%o0, 0x08, %g2) | |
112 | ||
113 | 6: be 8f | |
114 | andcc %o1, 4, %g0 | |
115 | be 1f | |
116 | andcc %o1, 2, %g0 | |
117 | st %g3, [%o0] | |
118 | add %o0, 4, %o0 | |
119 | 1: be 1f | |
120 | andcc %o1, 1, %g0 | |
121 | sth %g3, [%o0] | |
122 | add %o0, 2, %o0 | |
123 | 1: bne,a 8f | |
124 | stb %g3, [%o0] | |
125 | 8: retl | |
126 | mov %g1, %o0 | |
127 | 7: orcc %o1, 0, %g0 | |
128 | be 0f | |
129 | subcc %o1, 1, %o1 | |
130 | stb %g3, [%o0] | |
131 | be 0f | |
132 | subcc %o1, 1, %o1 | |
133 | stb %g3, [%o0 + 1] | |
134 | be 0f | |
135 | subcc %o1, 1, %o1 | |
136 | stb %g3, [%o0 + 2] | |
137 | be 0f | |
138 | subcc %o1, 1, %o1 | |
139 | stb %g3, [%o0 + 3] | |
140 | be 0f | |
141 | subcc %o1, 1, %o1 | |
142 | stb %g3, [%o0 + 4] | |
143 | be 0f | |
144 | subcc %o1, 1, %o1 | |
145 | stb %g3, [%o0 + 5] | |
146 | be 0f | |
147 | subcc %o1, 1, %o1 | |
148 | stb %g3, [%o0 + 6] | |
149 | 0: retl | |
150 | nop | |
151 | END(memset) | |
85dd1003 | 152 | libc_hidden_builtin_def (memset) |
ae6b8730 | 153 | |
1ab18a5b | 154 | weak_alias (__bzero, bzero) |