Multiple assembler packs: add experimental memory bus instrumentation.
[openssl.git] / crypto / alphacpuid.pl
index c9474ff..11f2e30 100644 (file)
@@ -126,3 +126,93 @@ OPENSSL_cleanse:
 .Ldone: ret    ($26)
 .end   OPENSSL_cleanse
 ___
+{
+my ($out,$cnt,$max)=("\$16","\$17","\$18");
+my ($tick,$lasttick)=("\$19","\$20");
+my ($diff,$lastdiff)=("\$21","\$22");
+my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31");
+
+print <<___;
+.globl OPENSSL_instrument_bus
+.ent   OPENSSL_instrument_bus
+OPENSSL_instrument_bus:
+       .frame  $sp,0,$ra
+       .prologue 0
+       mov     $cnt,$v0
+
+       rpcc    $lasttick
+       mov     0,$diff
+
+       ecb     ($out)
+       ldl_l   $tick,0($out)
+       addl    $diff,$tick,$tick
+       mov     $tick,$diff
+       stl_c   $tick,0($out)
+       stl     $diff,0($out)
+
+.Loop: rpcc    $tick
+       subq    $tick,$lasttick,$diff
+       mov     $tick,$lasttick
+
+       ecb     ($out)
+       ldl_l   $tick,0($out)
+       addl    $diff,$tick,$tick
+       mov     $tick,$diff
+       stl_c   $tick,0($out)
+       stl     $diff,0($out)
+
+       subl    $cnt,1,$cnt
+       lda     $out,4($out)
+       bne     $cnt,.Loop
+
+       ret     ($ra)
+.end   OPENSSL_instrument_bus
+
+.globl OPENSSL_instrument_bus2
+.ent   OPENSSL_instrument_bus2
+OPENSSL_instrument_bus2:
+       .frame  $sp,0,$ra
+       .prologue 0
+       mov     $cnt,$v0
+
+       rpcc    $lasttick
+       mov     0,$diff
+
+       ecb     ($out)
+       ldl_l   $tick,0($out)
+       addl    $diff,$tick,$tick
+       mov     $tick,$diff
+       stl_c   $tick,0($out)
+       stl     $diff,0($out)
+
+       rpcc    $tick
+       subq    $tick,$lasttick,$diff
+       mov     $tick,$lasttick
+       mov     $diff,$lastdiff
+.Loop2:
+       ecb     ($out)
+       ldl_l   $tick,0($out)
+       addl    $diff,$tick,$tick
+       mov     $tick,$diff
+       stl_c   $tick,0($out)
+       stl     $diff,0($out)
+
+       subl    $max,1,$max
+       beq     $max,.Ldone2
+
+       rpcc    $tick
+       subq    $tick,$lasttick,$diff
+       mov     $tick,$lasttick
+       subq    $lastdiff,$diff,$tick
+       mov     $diff,$lastdiff
+       cmovne  $tick,1,$tick
+       subl    $cnt,$tick,$cnt
+       s4addq  $tick,$out,$out
+       bne     $cnt,.Loop2
+
+.Ldone2:
+       subl    $v0,$cnt,$v0
+       ret     ($ra)
+.end   OPENSSL_instrument_bus2
+___
+}