arm64cpuid.pl 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the OpenSSL license (the "License"). You may not use
  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. $flavour = shift;
  9. $output = shift;
  10. $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
  11. ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or
  12. ( $xlate="${dir}perlasm/arm-xlate.pl" and -f $xlate) or
  13. die "can't locate arm-xlate.pl";
  14. open OUT,"| \"$^X\" $xlate $flavour $output";
  15. *STDOUT=*OUT;
  16. $code.=<<___;
  17. #include "arm_arch.h"
  18. .text
  19. .arch armv8-a+crypto
  20. .align 5
  21. .globl _armv7_neon_probe
  22. .type _armv7_neon_probe,%function
  23. _armv7_neon_probe:
  24. orr v15.16b, v15.16b, v15.16b
  25. ret
  26. .size _armv7_neon_probe,.-_armv7_neon_probe
  27. .globl _armv7_tick
  28. .type _armv7_tick,%function
  29. _armv7_tick:
  30. #ifdef __APPLE__
  31. mrs x0, CNTPCT_EL0
  32. #else
  33. mrs x0, CNTVCT_EL0
  34. #endif
  35. ret
  36. .size _armv7_tick,.-_armv7_tick
  37. .globl _armv8_aes_probe
  38. .type _armv8_aes_probe,%function
  39. _armv8_aes_probe:
  40. aese v0.16b, v0.16b
  41. ret
  42. .size _armv8_aes_probe,.-_armv8_aes_probe
  43. .globl _armv8_sha1_probe
  44. .type _armv8_sha1_probe,%function
  45. _armv8_sha1_probe:
  46. sha1h s0, s0
  47. ret
  48. .size _armv8_sha1_probe,.-_armv8_sha1_probe
  49. .globl _armv8_sha256_probe
  50. .type _armv8_sha256_probe,%function
  51. _armv8_sha256_probe:
  52. sha256su0 v0.4s, v0.4s
  53. ret
  54. .size _armv8_sha256_probe,.-_armv8_sha256_probe
  55. .globl _armv8_pmull_probe
  56. .type _armv8_pmull_probe,%function
  57. _armv8_pmull_probe:
  58. pmull v0.1q, v0.1d, v0.1d
  59. ret
  60. .size _armv8_pmull_probe,.-_armv8_pmull_probe
  61. .globl OPENSSL_cleanse
  62. .type OPENSSL_cleanse,%function
  63. .align 5
  64. OPENSSL_cleanse:
  65. cbz x1,.Lret // len==0?
  66. cmp x1,#15
  67. b.hi .Lot // len>15
  68. nop
  69. .Little:
  70. strb wzr,[x0],#1 // store byte-by-byte
  71. subs x1,x1,#1
  72. b.ne .Little
  73. .Lret: ret
  74. .align 4
  75. .Lot: tst x0,#7
  76. b.eq .Laligned // inp is aligned
  77. strb wzr,[x0],#1 // store byte-by-byte
  78. sub x1,x1,#1
  79. b .Lot
  80. .align 4
  81. .Laligned:
  82. str xzr,[x0],#8 // store word-by-word
  83. sub x1,x1,#8
  84. tst x1,#-8
  85. b.ne .Laligned // len>=8
  86. cbnz x1,.Little // len!=0?
  87. ret
  88. .size OPENSSL_cleanse,.-OPENSSL_cleanse
  89. .globl CRYPTO_memcmp
  90. .type CRYPTO_memcmp,%function
  91. .align 4
  92. CRYPTO_memcmp:
  93. eor w3,w3,w3
  94. cbz x2,.Lno_data // len==0?
  95. .Loop_cmp:
  96. ldrb w4,[x0],#1
  97. ldrb w5,[x1],#1
  98. eor w4,w4,w5
  99. orr w3,w3,w4
  100. subs x2,x2,#1
  101. b.ne .Loop_cmp
  102. .Lno_data:
  103. neg w0,w3
  104. lsr w0,w0,#31
  105. ret
  106. .size CRYPTO_memcmp,.-CRYPTO_memcmp
  107. ___
  108. print $code;
  109. close STDOUT;