]>
Commit | Line | Data |
---|---|---|
e0a65194 | 1 | #! /usr/bin/env perl |
6ec5fce2 | 2 | # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. |
e0a65194 | 3 | # |
0e9725bc | 4 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
e0a65194 RS |
5 | # this file except in compliance with the License. You can obtain a copy |
6 | # in the file LICENSE in the source distribution or at | |
7 | # https://www.openssl.org/source/license.html | |
8 | ||
313e6ec1 AP |
9 | |
10 | $flavour = shift; | |
11 | $output = shift; | |
12 | ||
13 | $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; | |
14 | ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or | |
15 | ( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or | |
16 | die "can't locate arm-xlate.pl"; | |
17 | ||
18 | open OUT,"| \"$^X\" $xlate $flavour $output"; | |
19 | *STDOUT=*OUT; | |
20 | ||
21 | $code.=<<___; | |
87873f43 AP |
22 | #include "arm_arch.h" |
23 | ||
11208dcf AP |
24 | #if defined(__thumb2__) && !defined(__APPLE__) |
25 | .syntax unified | |
26 | .thumb | |
27 | #else | |
87873f43 | 28 | .code 32 |
c93f06c1 | 29 | #undef __thumb2__ |
11208dcf | 30 | #endif |
87873f43 | 31 | |
3405db97 AP |
32 | .text |
33 | ||
4afa9f03 | 34 | .align 5 |
87873f43 AP |
35 | .global OPENSSL_atomic_add |
36 | .type OPENSSL_atomic_add,%function | |
37 | OPENSSL_atomic_add: | |
38 | #if __ARM_ARCH__>=6 | |
39 | .Ladd: ldrex r2,[r0] | |
40 | add r3,r2,r1 | |
41 | strex r2,r3,[r0] | |
42 | cmp r2,#0 | |
43 | bne .Ladd | |
44 | mov r0,r3 | |
5dcf70a1 | 45 | bx lr |
87873f43 AP |
46 | #else |
47 | stmdb sp!,{r4-r6,lr} | |
48 | ldr r2,.Lspinlock | |
49 | adr r3,.Lspinlock | |
50 | mov r4,r0 | |
51 | mov r5,r1 | |
52 | add r6,r3,r2 @ &spinlock | |
53 | b .+8 | |
54 | .Lspin: bl sched_yield | |
55 | mov r0,#-1 | |
56 | swp r0,r0,[r6] | |
57 | cmp r0,#0 | |
58 | bne .Lspin | |
59 | ||
60 | ldr r2,[r4] | |
29fd6746 | 61 | add r2,r2,r5 |
87873f43 AP |
62 | str r2,[r4] |
63 | str r0,[r6] @ release spinlock | |
64 | ldmia sp!,{r4-r6,lr} | |
65 | tst lr,#1 | |
66 | moveq pc,lr | |
67 | .word 0xe12fff1e @ bx lr | |
68 | #endif | |
69 | .size OPENSSL_atomic_add,.-OPENSSL_atomic_add | |
70 | ||
71 | .global OPENSSL_cleanse | |
72 | .type OPENSSL_cleanse,%function | |
73 | OPENSSL_cleanse: | |
74 | eor ip,ip,ip | |
75 | cmp r1,#7 | |
11208dcf AP |
76 | #ifdef __thumb2__ |
77 | itt hs | |
78 | #endif | |
29fd6746 | 79 | subhs r1,r1,#4 |
87873f43 AP |
80 | bhs .Lot |
81 | cmp r1,#0 | |
82 | beq .Lcleanse_done | |
83 | .Little: | |
84 | strb ip,[r0],#1 | |
29fd6746 | 85 | subs r1,r1,#1 |
87873f43 AP |
86 | bhi .Little |
87 | b .Lcleanse_done | |
88 | ||
89 | .Lot: tst r0,#3 | |
90 | beq .Laligned | |
91 | strb ip,[r0],#1 | |
29fd6746 | 92 | sub r1,r1,#1 |
87873f43 AP |
93 | b .Lot |
94 | .Laligned: | |
95 | str ip,[r0],#4 | |
29fd6746 | 96 | subs r1,r1,#4 |
87873f43 | 97 | bhs .Laligned |
29fd6746 | 98 | adds r1,r1,#4 |
87873f43 AP |
99 | bne .Little |
100 | .Lcleanse_done: | |
5dcf70a1 AP |
101 | #if __ARM_ARCH__>=5 |
102 | bx lr | |
103 | #else | |
87873f43 AP |
104 | tst lr,#1 |
105 | moveq pc,lr | |
106 | .word 0xe12fff1e @ bx lr | |
5dcf70a1 | 107 | #endif |
87873f43 AP |
108 | .size OPENSSL_cleanse,.-OPENSSL_cleanse |
109 | ||
e33826f0 AP |
110 | .global CRYPTO_memcmp |
111 | .type CRYPTO_memcmp,%function | |
112 | .align 4 | |
113 | CRYPTO_memcmp: | |
114 | eor ip,ip,ip | |
115 | cmp r2,#0 | |
116 | beq .Lno_data | |
117 | stmdb sp!,{r4,r5} | |
118 | ||
119 | .Loop_cmp: | |
120 | ldrb r4,[r0],#1 | |
121 | ldrb r5,[r1],#1 | |
122 | eor r4,r4,r5 | |
123 | orr ip,ip,r4 | |
124 | subs r2,r2,#1 | |
125 | bne .Loop_cmp | |
126 | ||
127 | ldmia sp!,{r4,r5} | |
128 | .Lno_data: | |
198a2ed7 | 129 | rsb r0,ip,#0 |
e33826f0 AP |
130 | mov r0,r0,lsr#31 |
131 | #if __ARM_ARCH__>=5 | |
132 | bx lr | |
133 | #else | |
134 | tst lr,#1 | |
135 | moveq pc,lr | |
136 | .word 0xe12fff1e @ bx lr | |
137 | #endif | |
138 | .size CRYPTO_memcmp,.-CRYPTO_memcmp | |
139 | ||
c1669e1c AP |
140 | #if __ARM_MAX_ARCH__>=7 |
141 | .arch armv7-a | |
142 | .fpu neon | |
143 | ||
144 | .align 5 | |
145 | .global _armv7_neon_probe | |
146 | .type _armv7_neon_probe,%function | |
147 | _armv7_neon_probe: | |
148 | vorr q0,q0,q0 | |
149 | bx lr | |
150 | .size _armv7_neon_probe,.-_armv7_neon_probe | |
151 | ||
152 | .global _armv7_tick | |
153 | .type _armv7_tick,%function | |
154 | _armv7_tick: | |
313e6ec1 AP |
155 | #ifdef __APPLE__ |
156 | mrrc p15,0,r0,r1,c14 @ CNTPCT | |
157 | #else | |
c1669e1c | 158 | mrrc p15,1,r0,r1,c14 @ CNTVCT |
313e6ec1 | 159 | #endif |
c1669e1c AP |
160 | bx lr |
161 | .size _armv7_tick,.-_armv7_tick | |
162 | ||
163 | .global _armv8_aes_probe | |
164 | .type _armv8_aes_probe,%function | |
165 | _armv8_aes_probe: | |
11208dcf AP |
166 | #if defined(__thumb2__) && !defined(__APPLE__) |
167 | .byte 0xb0,0xff,0x00,0x03 @ aese.8 q0,q0 | |
168 | #else | |
c1669e1c | 169 | .byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0 |
11208dcf | 170 | #endif |
c1669e1c AP |
171 | bx lr |
172 | .size _armv8_aes_probe,.-_armv8_aes_probe | |
173 | ||
174 | .global _armv8_sha1_probe | |
175 | .type _armv8_sha1_probe,%function | |
176 | _armv8_sha1_probe: | |
11208dcf AP |
177 | #if defined(__thumb2__) && !defined(__APPLE__) |
178 | .byte 0x00,0xef,0x40,0x0c @ sha1c.32 q0,q0,q0 | |
179 | #else | |
c1669e1c | 180 | .byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0 |
11208dcf | 181 | #endif |
c1669e1c AP |
182 | bx lr |
183 | .size _armv8_sha1_probe,.-_armv8_sha1_probe | |
184 | ||
185 | .global _armv8_sha256_probe | |
186 | .type _armv8_sha256_probe,%function | |
187 | _armv8_sha256_probe: | |
11208dcf AP |
188 | #if defined(__thumb2__) && !defined(__APPLE__) |
189 | .byte 0x00,0xff,0x40,0x0c @ sha256h.32 q0,q0,q0 | |
190 | #else | |
c1669e1c | 191 | .byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0 |
11208dcf | 192 | #endif |
c1669e1c AP |
193 | bx lr |
194 | .size _armv8_sha256_probe,.-_armv8_sha256_probe | |
195 | .global _armv8_pmull_probe | |
196 | .type _armv8_pmull_probe,%function | |
197 | _armv8_pmull_probe: | |
11208dcf AP |
198 | #if defined(__thumb2__) && !defined(__APPLE__) |
199 | .byte 0xa0,0xef,0x00,0x0e @ vmull.p64 q0,d0,d0 | |
200 | #else | |
c1669e1c | 201 | .byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0 |
11208dcf | 202 | #endif |
c1669e1c AP |
203 | bx lr |
204 | .size _armv8_pmull_probe,.-_armv8_pmull_probe | |
205 | #endif | |
206 | ||
87873f43 AP |
207 | .global OPENSSL_wipe_cpu |
208 | .type OPENSSL_wipe_cpu,%function | |
209 | OPENSSL_wipe_cpu: | |
c1669e1c | 210 | #if __ARM_MAX_ARCH__>=7 |
87873f43 AP |
211 | ldr r0,.LOPENSSL_armcap |
212 | adr r1,.LOPENSSL_armcap | |
213 | ldr r0,[r1,r0] | |
313e6ec1 AP |
214 | #ifdef __APPLE__ |
215 | ldr r0,[r0] | |
216 | #endif | |
c1669e1c | 217 | #endif |
87873f43 AP |
218 | eor r2,r2,r2 |
219 | eor r3,r3,r3 | |
220 | eor ip,ip,ip | |
c1669e1c | 221 | #if __ARM_MAX_ARCH__>=7 |
87873f43 AP |
222 | tst r0,#1 |
223 | beq .Lwipe_done | |
c1669e1c AP |
224 | veor q0, q0, q0 |
225 | veor q1, q1, q1 | |
226 | veor q2, q2, q2 | |
227 | veor q3, q3, q3 | |
228 | veor q8, q8, q8 | |
229 | veor q9, q9, q9 | |
230 | veor q10, q10, q10 | |
231 | veor q11, q11, q11 | |
232 | veor q12, q12, q12 | |
233 | veor q13, q13, q13 | |
234 | veor q14, q14, q14 | |
235 | veor q15, q15, q15 | |
87873f43 | 236 | .Lwipe_done: |
c1669e1c | 237 | #endif |
87873f43 | 238 | mov r0,sp |
5dcf70a1 AP |
239 | #if __ARM_ARCH__>=5 |
240 | bx lr | |
241 | #else | |
87873f43 AP |
242 | tst lr,#1 |
243 | moveq pc,lr | |
244 | .word 0xe12fff1e @ bx lr | |
5dcf70a1 | 245 | #endif |
87873f43 AP |
246 | .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu |
247 | ||
248 | .global OPENSSL_instrument_bus | |
249 | .type OPENSSL_instrument_bus,%function | |
250 | OPENSSL_instrument_bus: | |
251 | eor r0,r0,r0 | |
5dcf70a1 AP |
252 | #if __ARM_ARCH__>=5 |
253 | bx lr | |
254 | #else | |
87873f43 AP |
255 | tst lr,#1 |
256 | moveq pc,lr | |
257 | .word 0xe12fff1e @ bx lr | |
5dcf70a1 | 258 | #endif |
87873f43 AP |
259 | .size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus |
260 | ||
261 | .global OPENSSL_instrument_bus2 | |
262 | .type OPENSSL_instrument_bus2,%function | |
263 | OPENSSL_instrument_bus2: | |
264 | eor r0,r0,r0 | |
5dcf70a1 AP |
265 | #if __ARM_ARCH__>=5 |
266 | bx lr | |
267 | #else | |
87873f43 AP |
268 | tst lr,#1 |
269 | moveq pc,lr | |
270 | .word 0xe12fff1e @ bx lr | |
5dcf70a1 | 271 | #endif |
87873f43 AP |
272 | .size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2 |
273 | ||
274 | .align 5 | |
c1669e1c | 275 | #if __ARM_MAX_ARCH__>=7 |
87873f43 | 276 | .LOPENSSL_armcap: |
313e6ec1 | 277 | .word OPENSSL_armcap_P-. |
c1669e1c | 278 | #endif |
87873f43 AP |
279 | #if __ARM_ARCH__>=6 |
280 | .align 5 | |
281 | #else | |
282 | .Lspinlock: | |
283 | .word atomic_add_spinlock-.Lspinlock | |
284 | .align 5 | |
285 | ||
286 | .data | |
287 | .align 2 | |
288 | atomic_add_spinlock: | |
289 | .word 0 | |
290 | #endif | |
291 | ||
292 | .comm OPENSSL_armcap_P,4,4 | |
293 | .hidden OPENSSL_armcap_P | |
313e6ec1 AP |
294 | ___ |
295 | ||
296 | print $code; | |
297 | close STDOUT; |