1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/linkage.h>
14#include <asm/assembler.h>
15#include <asm/cache.h>
16
17
18
19
20
21
22
23
24
25
26
27
28dstin .req x0
29val .req w1
30count .req x2
31tmp1 .req x3
32tmp1w .req w3
33tmp2 .req x4
34tmp2w .req w4
35zva_len_x .req x5
36zva_len .req w5
37zva_bits_x .req x6
38
39A_l .req x7
40A_lw .req w7
41dst .req x8
42tmp3w .req w9
43tmp3 .req x9
44
45SYM_FUNC_START_ALIAS(__memset)
46SYM_FUNC_START_WEAK_PI(memset)
47 mov dst, dstin
48 and A_lw, val,
49 orr A_lw, A_lw, A_lw, lsl
50 orr A_lw, A_lw, A_lw, lsl
51 orr A_l, A_l, A_l, lsl
52
53 cmp count,
54 b.hi .Lover16_proc
55
56 tbz count,
57 str A_l, [dst],
581:
59 tbz count,
60 str A_lw, [dst],
612:
62 tbz count,
63 strh A_lw, [dst],
643:
65 tbz count,
66 strb A_lw, [dst]
674:
68 ret
69
70.Lover16_proc:
71
72 neg tmp2, dst
73 ands tmp2, tmp2,
74 b.eq .Laligned
75
76
77
78
79
80 stp A_l, A_l, [dst]
81
82 sub count, count, tmp2
83 add dst, dst, tmp2
84
85.Laligned:
86 cbz A_l, .Lzero_mem
87
88.Ltail_maybe_long:
89 cmp count,
90 b.ge .Lnot_short
91.Ltail63:
92 ands tmp1, count,
93 b.eq 3f
94 cmp tmp1w,
95 b.eq 1f
96 b.lt 2f
97 stp A_l, A_l, [dst],
981:
99 stp A_l, A_l, [dst],
1002:
101 stp A_l, A_l, [dst],
102
103
104
105
1063:
107 ands count, count,
108 cbz count, 4f
109 add dst, dst, count
110 stp A_l, A_l, [dst,
1114:
112 ret
113
114
115
116
117
118 .p2align L1_CACHE_SHIFT
119.Lnot_short:
120 sub dst, dst,
121 sub count, count,
1221:
123 stp A_l, A_l, [dst,
124 stp A_l, A_l, [dst,
125 stp A_l, A_l, [dst,
126 stp A_l, A_l, [dst,
127 subs count, count,
128 b.ge 1b
129 tst count,
130 add dst, dst,
131 b.ne .Ltail63
132.Lexitfunc:
133 ret
134
135
136
137
138
139.Lzero_mem:
140 cmp count,
141 b.le .Ltail63
142
143
144
145
146 cmp count,
147 b.lt .Lnot_short
148
149 mrs tmp1, dczid_el0
150 tbnz tmp1,
151 mov tmp3w,
152 and zva_len, tmp1w,
153 lsl zva_len, tmp3w, zva_len
154
155 ands tmp3w, zva_len,
156
157
158
159
160 b.ne .Lnot_short
161.Lzero_by_line:
162
163
164
165
166 cmp count, zva_len_x
167 b.lt .Lnot_short
168 sub zva_bits_x, zva_len_x,
169 neg tmp2, dst
170 ands tmp2, tmp2, zva_bits_x
171 b.eq 2f
172
173 sub tmp1, count, tmp2
174
175
176
177 cmp tmp1,
178 ccmp tmp1, zva_len_x,
179 b.lt .Lnot_short
180
181
182
183
184 mov count, tmp1
1851:
186 stp A_l, A_l, [dst]
187 stp A_l, A_l, [dst,
188 stp A_l, A_l, [dst,
189 subs tmp2, tmp2,
190 stp A_l, A_l, [dst,
191 add dst, dst,
192 b.ge 1b
193
194 add dst, dst, tmp2
1952:
196 sub count, count, zva_len_x
1973:
198 dc zva, dst
199 add dst, dst, zva_len_x
200 subs count, count, zva_len_x
201 b.ge 3b
202 ands count, count, zva_bits_x
203 b.ne .Ltail_maybe_long
204 ret
205SYM_FUNC_END_PI(memset)
206EXPORT_SYMBOL(memset)
207SYM_FUNC_END_ALIAS(__memset)
208EXPORT_SYMBOL(__memset)
209