alphacpuid.pl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. #! /usr/bin/env perl
  2. # Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License 2.0 (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. $output = pop and open STDOUT,">$output";
  9. print <<'___';
  10. .text
  11. .set noat
  12. .globl OPENSSL_cpuid_setup
  13. .ent OPENSSL_cpuid_setup
  14. OPENSSL_cpuid_setup:
  15. .frame $30,0,$26
  16. .prologue 0
  17. ret ($26)
  18. .end OPENSSL_cpuid_setup
  19. .globl OPENSSL_wipe_cpu
  20. .ent OPENSSL_wipe_cpu
  21. OPENSSL_wipe_cpu:
  22. .frame $30,0,$26
  23. .prologue 0
  24. clr $1
  25. clr $2
  26. clr $3
  27. clr $4
  28. clr $5
  29. clr $6
  30. clr $7
  31. clr $8
  32. clr $16
  33. clr $17
  34. clr $18
  35. clr $19
  36. clr $20
  37. clr $21
  38. clr $22
  39. clr $23
  40. clr $24
  41. clr $25
  42. clr $27
  43. clr $at
  44. clr $29
  45. fclr $f0
  46. fclr $f1
  47. fclr $f10
  48. fclr $f11
  49. fclr $f12
  50. fclr $f13
  51. fclr $f14
  52. fclr $f15
  53. fclr $f16
  54. fclr $f17
  55. fclr $f18
  56. fclr $f19
  57. fclr $f20
  58. fclr $f21
  59. fclr $f22
  60. fclr $f23
  61. fclr $f24
  62. fclr $f25
  63. fclr $f26
  64. fclr $f27
  65. fclr $f28
  66. fclr $f29
  67. fclr $f30
  68. mov $sp,$0
  69. ret ($26)
  70. .end OPENSSL_wipe_cpu
  71. .globl OPENSSL_atomic_add
  72. .ent OPENSSL_atomic_add
  73. OPENSSL_atomic_add:
  74. .frame $30,0,$26
  75. .prologue 0
  76. 1: ldl_l $0,0($16)
  77. addl $0,$17,$1
  78. stl_c $1,0($16)
  79. beq $1,1b
  80. addl $0,$17,$0
  81. ret ($26)
  82. .end OPENSSL_atomic_add
  83. .globl OPENSSL_rdtsc
  84. .ent OPENSSL_rdtsc
  85. OPENSSL_rdtsc:
  86. .frame $30,0,$26
  87. .prologue 0
  88. rpcc $0
  89. ret ($26)
  90. .end OPENSSL_rdtsc
  91. .globl OPENSSL_cleanse
  92. .ent OPENSSL_cleanse
  93. OPENSSL_cleanse:
  94. .frame $30,0,$26
  95. .prologue 0
  96. beq $17,.Ldone
  97. and $16,7,$0
  98. bic $17,7,$at
  99. beq $at,.Little
  100. beq $0,.Laligned
  101. .Little:
  102. subq $0,8,$0
  103. ldq_u $1,0($16)
  104. mov $16,$2
  105. .Lalign:
  106. mskbl $1,$16,$1
  107. lda $16,1($16)
  108. subq $17,1,$17
  109. addq $0,1,$0
  110. beq $17,.Lout
  111. bne $0,.Lalign
  112. .Lout: stq_u $1,0($2)
  113. beq $17,.Ldone
  114. bic $17,7,$at
  115. beq $at,.Little
  116. .Laligned:
  117. stq $31,0($16)
  118. subq $17,8,$17
  119. lda $16,8($16)
  120. bic $17,7,$at
  121. bne $at,.Laligned
  122. bne $17,.Little
  123. .Ldone: ret ($26)
  124. .end OPENSSL_cleanse
  125. .globl CRYPTO_memcmp
  126. .ent CRYPTO_memcmp
  127. CRYPTO_memcmp:
  128. .frame $30,0,$26
  129. .prologue 0
  130. xor $0,$0,$0
  131. beq $18,.Lno_data
  132. xor $1,$1,$1
  133. nop
  134. .Loop_cmp:
  135. ldq_u $2,0($16)
  136. subq $18,1,$18
  137. ldq_u $3,0($17)
  138. extbl $2,$16,$2
  139. lda $16,1($16)
  140. extbl $3,$17,$3
  141. lda $17,1($17)
  142. xor $3,$2,$2
  143. or $2,$0,$0
  144. bne $18,.Loop_cmp
  145. subq $31,$0,$0
  146. srl $0,63,$0
  147. .Lno_data:
  148. ret ($26)
  149. .end CRYPTO_memcmp
  150. ___
  151. {
  152. my ($out,$cnt,$max)=("\$16","\$17","\$18");
  153. my ($tick,$lasttick)=("\$19","\$20");
  154. my ($diff,$lastdiff)=("\$21","\$22");
  155. my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31");
  156. print <<___;
  157. .globl OPENSSL_instrument_bus
  158. .ent OPENSSL_instrument_bus
  159. OPENSSL_instrument_bus:
  160. .frame $sp,0,$ra
  161. .prologue 0
  162. mov $cnt,$v0
  163. rpcc $lasttick
  164. mov 0,$diff
  165. ecb ($out)
  166. ldl_l $tick,0($out)
  167. addl $diff,$tick,$tick
  168. mov $tick,$diff
  169. stl_c $tick,0($out)
  170. stl $diff,0($out)
  171. .Loop: rpcc $tick
  172. subq $tick,$lasttick,$diff
  173. mov $tick,$lasttick
  174. ecb ($out)
  175. ldl_l $tick,0($out)
  176. addl $diff,$tick,$tick
  177. mov $tick,$diff
  178. stl_c $tick,0($out)
  179. stl $diff,0($out)
  180. subl $cnt,1,$cnt
  181. lda $out,4($out)
  182. bne $cnt,.Loop
  183. ret ($ra)
  184. .end OPENSSL_instrument_bus
  185. .globl OPENSSL_instrument_bus2
  186. .ent OPENSSL_instrument_bus2
  187. OPENSSL_instrument_bus2:
  188. .frame $sp,0,$ra
  189. .prologue 0
  190. mov $cnt,$v0
  191. rpcc $lasttick
  192. mov 0,$diff
  193. ecb ($out)
  194. ldl_l $tick,0($out)
  195. addl $diff,$tick,$tick
  196. mov $tick,$diff
  197. stl_c $tick,0($out)
  198. stl $diff,0($out)
  199. rpcc $tick
  200. subq $tick,$lasttick,$diff
  201. mov $tick,$lasttick
  202. mov $diff,$lastdiff
  203. .Loop2:
  204. ecb ($out)
  205. ldl_l $tick,0($out)
  206. addl $diff,$tick,$tick
  207. mov $tick,$diff
  208. stl_c $tick,0($out)
  209. stl $diff,0($out)
  210. subl $max,1,$max
  211. beq $max,.Ldone2
  212. rpcc $tick
  213. subq $tick,$lasttick,$diff
  214. mov $tick,$lasttick
  215. subq $lastdiff,$diff,$tick
  216. mov $diff,$lastdiff
  217. cmovne $tick,1,$tick
  218. subl $cnt,$tick,$cnt
  219. s4addq $tick,$out,$out
  220. bne $cnt,.Loop2
  221. .Ldone2:
  222. subl $v0,$cnt,$v0
  223. ret ($ra)
  224. .end OPENSSL_instrument_bus2
  225. ___
  226. }
  227. close STDOUT or die "error closing STDOUT: $!";