alphacpuid.pl 3.9 KB

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