alphacpuid.pl 3.1 KB

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