A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

295 lines
5.3 KiB

  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. #if defined(__thumb2__) && !defined(__APPLE__)
  20. .syntax unified
  21. .thumb
  22. #else
  23. .code 32
  24. #endif
  25. .align 5
  26. .global OPENSSL_atomic_add
  27. .type OPENSSL_atomic_add,%function
  28. OPENSSL_atomic_add:
  29. #if __ARM_ARCH__>=6
  30. .Ladd: ldrex r2,[r0]
  31. add r3,r2,r1
  32. strex r2,r3,[r0]
  33. cmp r2,#0
  34. bne .Ladd
  35. mov r0,r3
  36. bx lr
  37. #else
  38. stmdb sp!,{r4-r6,lr}
  39. ldr r2,.Lspinlock
  40. adr r3,.Lspinlock
  41. mov r4,r0
  42. mov r5,r1
  43. add r6,r3,r2 @ &spinlock
  44. b .+8
  45. .Lspin: bl sched_yield
  46. mov r0,#-1
  47. swp r0,r0,[r6]
  48. cmp r0,#0
  49. bne .Lspin
  50. ldr r2,[r4]
  51. add r2,r2,r5
  52. str r2,[r4]
  53. str r0,[r6] @ release spinlock
  54. ldmia sp!,{r4-r6,lr}
  55. tst lr,#1
  56. moveq pc,lr
  57. .word 0xe12fff1e @ bx lr
  58. #endif
  59. .size OPENSSL_atomic_add,.-OPENSSL_atomic_add
  60. .global OPENSSL_cleanse
  61. .type OPENSSL_cleanse,%function
  62. OPENSSL_cleanse:
  63. eor ip,ip,ip
  64. cmp r1,#7
  65. #ifdef __thumb2__
  66. itt hs
  67. #endif
  68. subhs r1,r1,#4
  69. bhs .Lot
  70. cmp r1,#0
  71. beq .Lcleanse_done
  72. .Little:
  73. strb ip,[r0],#1
  74. subs r1,r1,#1
  75. bhi .Little
  76. b .Lcleanse_done
  77. .Lot: tst r0,#3
  78. beq .Laligned
  79. strb ip,[r0],#1
  80. sub r1,r1,#1
  81. b .Lot
  82. .Laligned:
  83. str ip,[r0],#4
  84. subs r1,r1,#4
  85. bhs .Laligned
  86. adds r1,r1,#4
  87. bne .Little
  88. .Lcleanse_done:
  89. #if __ARM_ARCH__>=5
  90. bx lr
  91. #else
  92. tst lr,#1
  93. moveq pc,lr
  94. .word 0xe12fff1e @ bx lr
  95. #endif
  96. .size OPENSSL_cleanse,.-OPENSSL_cleanse
  97. .global CRYPTO_memcmp
  98. .type CRYPTO_memcmp,%function
  99. .align 4
  100. CRYPTO_memcmp:
  101. eor ip,ip,ip
  102. cmp r2,#0
  103. beq .Lno_data
  104. stmdb sp!,{r4,r5}
  105. .Loop_cmp:
  106. ldrb r4,[r0],#1
  107. ldrb r5,[r1],#1
  108. eor r4,r4,r5
  109. orr ip,ip,r4
  110. subs r2,r2,#1
  111. bne .Loop_cmp
  112. ldmia sp!,{r4,r5}
  113. .Lno_data:
  114. neg r0,ip
  115. mov r0,r0,lsr#31
  116. #if __ARM_ARCH__>=5
  117. bx lr
  118. #else
  119. tst lr,#1
  120. moveq pc,lr
  121. .word 0xe12fff1e @ bx lr
  122. #endif
  123. .size CRYPTO_memcmp,.-CRYPTO_memcmp
  124. #if __ARM_MAX_ARCH__>=7
  125. .arch armv7-a
  126. .fpu neon
  127. .align 5
  128. .global _armv7_neon_probe
  129. .type _armv7_neon_probe,%function
  130. _armv7_neon_probe:
  131. vorr q0,q0,q0
  132. bx lr
  133. .size _armv7_neon_probe,.-_armv7_neon_probe
  134. .global _armv7_tick
  135. .type _armv7_tick,%function
  136. _armv7_tick:
  137. #ifdef __APPLE__
  138. mrrc p15,0,r0,r1,c14 @ CNTPCT
  139. #else
  140. mrrc p15,1,r0,r1,c14 @ CNTVCT
  141. #endif
  142. bx lr
  143. .size _armv7_tick,.-_armv7_tick
  144. .global _armv8_aes_probe
  145. .type _armv8_aes_probe,%function
  146. _armv8_aes_probe:
  147. #if defined(__thumb2__) && !defined(__APPLE__)
  148. .byte 0xb0,0xff,0x00,0x03 @ aese.8 q0,q0
  149. #else
  150. .byte 0x00,0x03,0xb0,0xf3 @ aese.8 q0,q0
  151. #endif
  152. bx lr
  153. .size _armv8_aes_probe,.-_armv8_aes_probe
  154. .global _armv8_sha1_probe
  155. .type _armv8_sha1_probe,%function
  156. _armv8_sha1_probe:
  157. #if defined(__thumb2__) && !defined(__APPLE__)
  158. .byte 0x00,0xef,0x40,0x0c @ sha1c.32 q0,q0,q0
  159. #else
  160. .byte 0x40,0x0c,0x00,0xf2 @ sha1c.32 q0,q0,q0
  161. #endif
  162. bx lr
  163. .size _armv8_sha1_probe,.-_armv8_sha1_probe
  164. .global _armv8_sha256_probe
  165. .type _armv8_sha256_probe,%function
  166. _armv8_sha256_probe:
  167. #if defined(__thumb2__) && !defined(__APPLE__)
  168. .byte 0x00,0xff,0x40,0x0c @ sha256h.32 q0,q0,q0
  169. #else
  170. .byte 0x40,0x0c,0x00,0xf3 @ sha256h.32 q0,q0,q0
  171. #endif
  172. bx lr
  173. .size _armv8_sha256_probe,.-_armv8_sha256_probe
  174. .global _armv8_pmull_probe
  175. .type _armv8_pmull_probe,%function
  176. _armv8_pmull_probe:
  177. #if defined(__thumb2__) && !defined(__APPLE__)
  178. .byte 0xa0,0xef,0x00,0x0e @ vmull.p64 q0,d0,d0
  179. #else
  180. .byte 0x00,0x0e,0xa0,0xf2 @ vmull.p64 q0,d0,d0
  181. #endif
  182. bx lr
  183. .size _armv8_pmull_probe,.-_armv8_pmull_probe
  184. #endif
  185. .global OPENSSL_wipe_cpu
  186. .type OPENSSL_wipe_cpu,%function
  187. OPENSSL_wipe_cpu:
  188. #if __ARM_MAX_ARCH__>=7
  189. ldr r0,.LOPENSSL_armcap
  190. adr r1,.LOPENSSL_armcap
  191. ldr r0,[r1,r0]
  192. #ifdef __APPLE__
  193. ldr r0,[r0]
  194. #endif
  195. #endif
  196. eor r2,r2,r2
  197. eor r3,r3,r3
  198. eor ip,ip,ip
  199. #if __ARM_MAX_ARCH__>=7
  200. tst r0,#1
  201. beq .Lwipe_done
  202. veor q0, q0, q0
  203. veor q1, q1, q1
  204. veor q2, q2, q2
  205. veor q3, q3, q3
  206. veor q8, q8, q8
  207. veor q9, q9, q9
  208. veor q10, q10, q10
  209. veor q11, q11, q11
  210. veor q12, q12, q12
  211. veor q13, q13, q13
  212. veor q14, q14, q14
  213. veor q15, q15, q15
  214. .Lwipe_done:
  215. #endif
  216. mov r0,sp
  217. #if __ARM_ARCH__>=5
  218. bx lr
  219. #else
  220. tst lr,#1
  221. moveq pc,lr
  222. .word 0xe12fff1e @ bx lr
  223. #endif
  224. .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
  225. .global OPENSSL_instrument_bus
  226. .type OPENSSL_instrument_bus,%function
  227. OPENSSL_instrument_bus:
  228. eor r0,r0,r0
  229. #if __ARM_ARCH__>=5
  230. bx lr
  231. #else
  232. tst lr,#1
  233. moveq pc,lr
  234. .word 0xe12fff1e @ bx lr
  235. #endif
  236. .size OPENSSL_instrument_bus,.-OPENSSL_instrument_bus
  237. .global OPENSSL_instrument_bus2
  238. .type OPENSSL_instrument_bus2,%function
  239. OPENSSL_instrument_bus2:
  240. eor r0,r0,r0
  241. #if __ARM_ARCH__>=5
  242. bx lr
  243. #else
  244. tst lr,#1
  245. moveq pc,lr
  246. .word 0xe12fff1e @ bx lr
  247. #endif
  248. .size OPENSSL_instrument_bus2,.-OPENSSL_instrument_bus2
  249. .align 5
  250. #if __ARM_MAX_ARCH__>=7
  251. .LOPENSSL_armcap:
  252. .word OPENSSL_armcap_P-.
  253. #endif
  254. #if __ARM_ARCH__>=6
  255. .align 5
  256. #else
  257. .Lspinlock:
  258. .word atomic_add_spinlock-.Lspinlock
  259. .align 5
  260. .data
  261. .align 2
  262. atomic_add_spinlock:
  263. .word 0
  264. #endif
  265. .comm OPENSSL_armcap_P,4,4
  266. .hidden OPENSSL_armcap_P
  267. ___
  268. print $code;
  269. close STDOUT;