# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
-#
# ====================================================================
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
# project. The module is, however, dual licensed under OpenSSL and
# CRYPTOGAMS licenses depending on where you obtain it. For further
# details see http://www.openssl.org/~appro/cryptogams/.
+#
+# Permission to use under GPLv2 terms is granted.
# ====================================================================
#
# SHA256/512 for ARMv8.
# generated with -mgeneral-regs-only is significanty faster
# and the gap is only 40-90%.
-$flavour=shift;
-$output=shift;
+$output=pop;
+$flavour=pop;
-$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
-( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
-( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
-die "can't locate arm-xlate.pl";
+if ($flavour && $flavour ne "void") {
+ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+ ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
+ ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
+ die "can't locate arm-xlate.pl";
-open OUT,"| \"$^X\" $xlate $flavour $output";
-*STDOUT=*OUT;
+ open OUT,"| \"$^X\" $xlate $flavour $output";
+ *STDOUT=*OUT;
+} else {
+ open STDOUT,">$output";
+}
if ($output =~ /512/) {
$BITS=512;
}
$code.=<<___;
-#include "arm_arch.h"
+#ifndef __KERNEL__
+# include "arm_arch.h"
+#endif
.text
$func:
___
$code.=<<___ if ($SZ==4);
-#ifdef __ILP32__
+#ifndef __KERNEL__
+# ifdef __ILP32__
ldrsw x16,.LOPENSSL_armcap_P
-#else
+# else
ldr x16,.LOPENSSL_armcap_P
-#endif
+# endif
adr x17,.LOPENSSL_armcap_P
add x16,x16,x17
ldr w16,[x16]
tst w16,#ARMV8_SHA256
b.ne .Lv8_entry
+#endif
___
$code.=<<___;
stp x29,x30,[sp,#-128]!
___
$code.=<<___;
.size .LK$BITS,.-.LK$BITS
+#ifndef __KERNEL__
.align 3
.LOPENSSL_armcap_P:
-#ifdef __ILP32__
+# ifdef __ILP32__
.long OPENSSL_armcap_P-.
-#else
+# else
.quad OPENSSL_armcap_P-.
+# endif
#endif
.asciz "SHA$BITS block transform for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
.align 2
my ($ABCD_SAVE,$EFGH_SAVE)=("v18.16b","v19.16b");
$code.=<<___;
+#ifndef __KERNEL__
.type sha256_block_armv8,%function
.align 6
sha256_block_armv8:
ldr x29,[sp],#16
ret
.size sha256_block_armv8,.-sha256_block_armv8
+#endif
___
}
$code.=<<___;
+#ifndef __KERNEL__
.comm OPENSSL_armcap_P,4,4
+#endif
___
{ my %opcode = (
}
}
+open SELF,$0;
+while(<SELF>) {
+ next if (/^#!/);
+ last if (!s/^#/\/\// and !/^$/);
+ print;
+}
+close SELF;
+
foreach(split("\n",$code)) {
s/\`([^\`]*)\`/eval($1)/geo;