]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/arm64cpuid.pl
Add NEWS entry about deprecation of command line public tools
[thirdparty/openssl.git] / crypto / arm64cpuid.pl
CommitLineData
e0a65194 1#! /usr/bin/env perl
6738bf14 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
9b05cbc3 9
1aa89a7a
RL
10# $output is the last argument if it looks like a file (it has an extension)
11# $flavour is the first argument if it doesn't look like a file
12$output = $#ARGV >= 0 && $ARGV[$#ARGV] =~ m|\.\w+$| ? pop : undef;
13$flavour = $#ARGV >= 0 && $ARGV[0] !~ m|\.| ? shift : undef;
9b05cbc3
AP
14
15$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
16( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
17( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
18die "can't locate arm-xlate.pl";
19
1aa89a7a
RL
20open OUT,"| \"$^X\" $xlate $flavour \"$output\""
21 or die "can't call $xlate: $!";
9b05cbc3
AP
22*STDOUT=*OUT;
23
24$code.=<<___;
e8d93e34
AP
25#include "arm_arch.h"
26
27.text
28.arch armv8-a+crypto
29
30.align 5
9b05cbc3 31.globl _armv7_neon_probe
e8d93e34
AP
32.type _armv7_neon_probe,%function
33_armv7_neon_probe:
34 orr v15.16b, v15.16b, v15.16b
35 ret
36.size _armv7_neon_probe,.-_armv7_neon_probe
37
9b05cbc3 38.globl _armv7_tick
e8d93e34
AP
39.type _armv7_tick,%function
40_armv7_tick:
9b05cbc3
AP
41#ifdef __APPLE__
42 mrs x0, CNTPCT_EL0
43#else
e8d93e34 44 mrs x0, CNTVCT_EL0
9b05cbc3 45#endif
e8d93e34
AP
46 ret
47.size _armv7_tick,.-_armv7_tick
48
9b05cbc3 49.globl _armv8_aes_probe
e8d93e34
AP
50.type _armv8_aes_probe,%function
51_armv8_aes_probe:
52 aese v0.16b, v0.16b
53 ret
54.size _armv8_aes_probe,.-_armv8_aes_probe
55
9b05cbc3 56.globl _armv8_sha1_probe
e8d93e34
AP
57.type _armv8_sha1_probe,%function
58_armv8_sha1_probe:
59 sha1h s0, s0
60 ret
61.size _armv8_sha1_probe,.-_armv8_sha1_probe
62
9b05cbc3 63.globl _armv8_sha256_probe
e8d93e34
AP
64.type _armv8_sha256_probe,%function
65_armv8_sha256_probe:
66 sha256su0 v0.4s, v0.4s
67 ret
68.size _armv8_sha256_probe,.-_armv8_sha256_probe
77f3612e 69
9b05cbc3 70.globl _armv8_pmull_probe
e8d93e34
AP
71.type _armv8_pmull_probe,%function
72_armv8_pmull_probe:
73 pmull v0.1q, v0.1d, v0.1d
74 ret
75.size _armv8_pmull_probe,.-_armv8_pmull_probe
6133b4ed 76
77f3612e
AP
77.globl _armv8_sha512_probe
78.type _armv8_sha512_probe,%function
79_armv8_sha512_probe:
80 .long 0xcec08000 // sha512su0 v0.2d,v0.2d
81 ret
82.size _armv8_sha512_probe,.-_armv8_sha512_probe
83
6133b4ed
AP
84.globl OPENSSL_cleanse
85.type OPENSSL_cleanse,%function
86.align 5
87OPENSSL_cleanse:
88 cbz x1,.Lret // len==0?
89 cmp x1,#15
90 b.hi .Lot // len>15
91 nop
92.Little:
93 strb wzr,[x0],#1 // store byte-by-byte
94 subs x1,x1,#1
95 b.ne .Little
96.Lret: ret
97
98.align 4
99.Lot: tst x0,#7
100 b.eq .Laligned // inp is aligned
101 strb wzr,[x0],#1 // store byte-by-byte
102 sub x1,x1,#1
103 b .Lot
104
105.align 4
106.Laligned:
107 str xzr,[x0],#8 // store word-by-word
108 sub x1,x1,#8
109 tst x1,#-8
110 b.ne .Laligned // len>=8
111 cbnz x1,.Little // len!=0?
112 ret
113.size OPENSSL_cleanse,.-OPENSSL_cleanse
e33826f0
AP
114
115.globl CRYPTO_memcmp
116.type CRYPTO_memcmp,%function
117.align 4
118CRYPTO_memcmp:
119 eor w3,w3,w3
120 cbz x2,.Lno_data // len==0?
9a708bf9
AP
121 cmp x2,#16
122 b.ne .Loop_cmp
123 ldp x8,x9,[x0]
124 ldp x10,x11,[x1]
125 eor x8,x8,x10
126 eor x9,x9,x11
127 orr x8,x8,x9
128 mov x0,#1
129 cmp x8,#0
130 csel x0,xzr,x0,eq
131 ret
132
133.align 4
e33826f0
AP
134.Loop_cmp:
135 ldrb w4,[x0],#1
136 ldrb w5,[x1],#1
137 eor w4,w4,w5
138 orr w3,w3,w4
139 subs x2,x2,#1
140 b.ne .Loop_cmp
141
142.Lno_data:
143 neg w0,w3
144 lsr w0,w0,#31
145 ret
146.size CRYPTO_memcmp,.-CRYPTO_memcmp
9b05cbc3
AP
147___
148
149print $code;
32be631c 150close STDOUT or die "error closing STDOUT";