engines/asm/e_padlock*: add support for Zhaoxin's x86 platform
[oweals/openssl.git] / engines / asm / e_padlock-x86_64.pl
index f8ba1e909f3d9420bcf81c27a96411c07f4fa301..9eff881e66d686db1378130454f4dfd5d8d07105 100644 (file)
@@ -1,4 +1,11 @@
-#!/usr/bin/env perl
+#! /usr/bin/env perl
+# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# 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
@@ -23,7 +30,7 @@ $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 ( $xlate="${dir}../../crypto/perlasm/x86_64-xlate.pl" and -f $xlate) or
 die "can't locate x86_64-xlate.pl";
 
-open OUT,"| \"$^X\" $xlate $flavour $output";
+open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\"";
 *STDOUT=*OUT;
 
 $code=".text\n";
@@ -50,11 +57,20 @@ padlock_capability:
        cpuid
        xor     %eax,%eax
        cmp     \$`"0x".unpack("H*",'tneC')`,%ebx
-       jne     .Lnoluck
+       jne     .Lzhaoxin
        cmp     \$`"0x".unpack("H*",'Hrua')`,%edx
        jne     .Lnoluck
        cmp     \$`"0x".unpack("H*",'slua')`,%ecx
        jne     .Lnoluck
+       jmp     .LzhaoxinEnd
+.Lzhaoxin:
+       cmp     \$`"0x".unpack("H*",'hS  ')`,%ebx
+       jne     .Lnoluck
+       cmp     \$`"0x".unpack("H*",'hgna')`,%edx
+       jne     .Lnoluck
+       cmp     \$`"0x".unpack("H*",'  ia')`,%ecx
+       jne     .Lnoluck
+.LzhaoxinEnd:
        mov     \$0xC0000000,%eax
        cpuid
        mov     %eax,%edx
@@ -377,7 +393,7 @@ $code.=<<___                                if ($mode eq "ctr32");
 .L${mode}_no_carry:
 ___
 $code.=<<___;
-       mov     %r8,$out                # restore paramters
+       mov     %r8,$out                # restore parameters
        mov     %r11,$chunk
        test    \$0x0f,$out
        jz      .L${mode}_out_aligned
@@ -485,7 +501,7 @@ $code.=<<___                                if ($mode eq "ctr32");
        bswap   %eax
        mov     %eax,-4($ctx)
 
-       mov     %r10,$len               # restore paramters
+       mov     %r10,$len               # restore parameters
        sub     %r11,$len
        mov     \$`16*0x10000`,$chunk
        jz      .L${mode}_exit
@@ -528,7 +544,7 @@ $code.=<<___                                if ($PADLOCK_PREFETCH{$mode});
        sub     $len,%rsp
        shr     \$3,$len
        lea     (%rsp),$out
-       .byte   0xf3,0x48,0xa5          # rep movsq     
+       .byte   0xf3,0x48,0xa5          # rep movsq
        lea     (%r8),$out
        lea     (%rsp),$inp
        mov     $chunk,$len