PACKETise ServerHello processing
[openssl.git] / crypto / armv4cpuid.pl
1 #!/usr/bin/env perl
2
3 $flavour = shift;
4 $output  = shift;
5
6 $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
7 ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
8 ( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
9 die "can't locate arm-xlate.pl";
10
11 open OUT,"| \"$^X\" $xlate $flavour $output";
12 *STDOUT=*OUT;
13
14 $code.=<<___;
15 #include "arm_arch.h"
16
17 .text
18 .code   32
19
20 .align  5
21 .global OPENSSL_atomic_add
22 .type   OPENSSL_atomic_add,%function
23 OPENSSL_atomic_add:
24 #if __ARM_ARCH__>=6
25 .Ladd:  ldrex   r2,[r0]
26         add     r3,r2,r1
27         strex   r2,r3,[r0]
28         cmp     r2,#0
29         bne     .Ladd
30         mov     r0,r3
31         bx      lr
32 #else
33         stmdb   sp!,{r4-r6,lr}
34         ldr     r2,.Lspinlock
35         adr     r3,.Lspinlock
36         mov     r4,r0
37         mov     r5,r1
38         add     r6,r3,r2        @ &spinlock
39         b       .+8
40 .Lspin: bl      sched_yield
41         mov     r0,#-1
42         swp     r0,r0,[r6]
43         cmp     r0,#0
44         bne     .Lspin
45
46         ldr     r2,[r4]
47         add     r2,r2,r5
48         str     r2,[r4]
49         str     r0,[r6]         @ release spinlock
50         ldmia   sp!,{r4-r6,lr}
51         tst     lr,#1
52         moveq   pc,lr
53         .word   0xe12fff1e      @ bx    lr
54 #endif
55 .size   OPENSSL_atomic_add,.-OPENSSL_atomic_add
56
57 .global OPENSSL_cleanse
58 .type   OPENSSL_cleanse,%function
59 OPENSSL_cleanse:
60         eor     ip,ip,ip
61         cmp     r1,#7
62         subhs   r1,r1,#4
63         bhs     .Lot
64         cmp     r1,#0
65         beq     .Lcleanse_done
66 .Little:
67         strb    ip,[r0],#1
68         subs    r1,r1,#1
69         bhi     .Little
70         b       .Lcleanse_done
71
72 .Lot:   tst     r0,#3
73         beq     .Laligned
74         strb    ip,[r0],#1
75         sub     r1,r1,#1
76         b       .Lot
77 .Laligned:
78         str     ip,[r0],#4
79         subs    r1,r1,#4
80         bhs     .Laligned
81         adds    r1,r1,#4
82         bne     .Little
83 .Lcleanse_done:
84 #if __ARM_ARCH__>=5
85         bx      lr
86 #else
87         tst     lr,#1
88         moveq   pc,lr
89         .word   0xe12fff1e      @ bx    lr
90 #endif
91 .size   OPENSSL_cleanse,.-OPENSSL_cleanse
92
93 #if __ARM_MAX_ARCH__>=7
94 .arch   armv7-a
95 .fpu    neon
96
97 .align  5
98 .global _armv7_neon_probe
99 .type   _armv7_neon_probe,%function
100 _armv7_neon_probe:
101         vorr    q0,q0,q0
102         bx      lr
103 .size   _armv7_neon_probe,.-_armv7_neon_probe
104
105 .global _armv7_tick
106 .type   _armv7_tick,%function
107 _armv7_tick:
108 #ifdef  __APPLE__
109         mrrc    p15,0,r0,r1,c14         @ CNTPCT
110 #else
111         mrrc    p15,1,r0,r1,c14         @ CNTVCT
112 #endif
113         bx      lr
114 .size   _armv7_tick,.-_armv7_tick
115
116 .global _armv8_aes_probe
117 .type   _armv8_aes_probe,%function
118 _armv8_aes_probe:
119         .byte   0x00,0x03,0xb0,0xf3     @ aese.8        q0,q0
120         bx      lr
121 .size   _armv8_aes_probe,.-_armv8_aes_probe
122
123 .global _armv8_sha1_probe
124 .type   _armv8_sha1_probe,%function
125 _armv8_sha1_probe:
126         .byte   0x40,0x0c,0x00,0xf2     @ sha1c.32      q0,q0,q0
127         bx      lr
128 .size   _armv8_sha1_probe,.-_armv8_sha1_probe
129
130 .global _armv8_sha256_probe
131 .type   _armv8_sha256_probe,%function
132 _armv8_sha256_probe:
133         .byte   0x40,0x0c,0x00,0xf3     @ sha256h.32    q0,q0,q0
134         bx      lr
135 .size   _armv8_sha256_probe,.-_armv8_sha256_probe
136 .global _armv8_pmull_probe
137 .type   _armv8_pmull_probe,%function
138 _armv8_pmull_probe:
139         .byte   0x00,0x0e,0xa0,0xf2     @ vmull.p64     q0,d0,d0
140         bx      lr
141 .size   _armv8_pmull_probe,.-_armv8_pmull_probe
142 #endif
143
144 .global OPENSSL_wipe_cpu
145 .type   OPENSSL_wipe_cpu,%function
146 OPENSSL_wipe_cpu:
147 #if __ARM_MAX_ARCH__>=7
148         ldr     r0,.LOPENSSL_armcap
149         adr     r1,.LOPENSSL_armcap
150         ldr     r0,[r1,r0]
151 #ifdef  __APPLE__
152         ldr     r0,[r0]
153 #endif
154 #endif
155         eor     r2,r2,r2
156         eor     r3,r3,r3
157         eor     ip,ip,ip
158 #if __ARM_MAX_ARCH__>=7
159         tst     r0,#1
160         beq     .Lwipe_done
161         veor    q0, q0, q0
162         veor    q1, q1, q1
163         veor    q2, q2, q2
164         veor    q3, q3, q3
165         veor    q8, q8, q8
166         veor    q9, q9, q9
167         veor    q10, q10, q10
168         veor    q11, q11, q11
169         veor    q12, q12, q12
170         veor    q13, q13, q13
171         veor    q14, q14, q14
172         veor    q15, q15, q15
173 .Lwipe_done:
174 #endif
175         mov     r0,sp
176 #if __ARM_ARCH__>=5
177         bx      lr
178 #else
179         tst     lr,#1
180         moveq   pc,lr
181         .word   0xe12fff1e      @ bx    lr
182 #endif
183 .size   OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
184
185 .global OPENSSL_instrument_bus
186 .type   OPENSSL_instrument_bus,%function
187 OPENSSL_instrument_bus:
188         eor     r0,r0,r0
189 #if __ARM_ARCH__>=5
190         bx      lr
191 #else
192         tst     lr,#1
193         moveq   pc,lr
194         .word   0xe12fff1e      @ bx    lr
195 #endif
196 .size   OPENSSL_instrument_bus,.-OPENSSL_instrument_bus
197
198 .global OPENSSL_instrument_bus2
199 .type   OPENSSL_instrument_bus2,%function
200 OPENSSL_instrument_bus2:
201         eor     r0,r0,r0
202 #if __ARM_ARCH__>=5
203         bx      lr
204 #else
205         tst     lr,#1
206         moveq   pc,lr
207         .word   0xe12fff1e      @ bx    lr
208 #endif
209 .size   OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
210
211 .align  5
212 #if __ARM_MAX_ARCH__>=7
213 .LOPENSSL_armcap:
214 .word   OPENSSL_armcap_P-.
215 #endif
216 #if __ARM_ARCH__>=6
217 .align  5
218 #else
219 .Lspinlock:
220 .word   atomic_add_spinlock-.Lspinlock
221 .align  5
222
223 .data
224 .align  2
225 atomic_add_spinlock:
226 .word   0
227 #endif
228
229 .comm   OPENSSL_armcap_P,4,4
230 .hidden OPENSSL_armcap_P
231 ___
232
233 print $code;
234 close STDOUT;