~ubuntu-branches/ubuntu/lucid/openssl/lucid-proposed

« back to all changes in this revision

Viewing changes to crypto/ppccpuid.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2009-06-13 18:15:46 UTC
  • mto: (11.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090613181546-vbfntai3b009dl1u
Tags: upstream-0.9.8k
ImportĀ upstreamĀ versionĀ 0.9.8k

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
 
 
3
$flavour = shift;
 
4
 
 
5
$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
 
6
( $xlate="${dir}ppc-xlate.pl" and -f $xlate ) or
 
7
( $xlate="${dir}perlasm/ppc-xlate.pl" and -f $xlate) or
 
8
die "can't locate ppc-xlate.pl";
 
9
 
 
10
open STDOUT,"| $^X $xlate $flavour ".shift || die "can't call $xlate: $!";
 
11
 
 
12
if ($flavour=~/64/) {
 
13
    $CMPLI="cmpldi";
 
14
    $SHRLI="srdi";
 
15
    $SIGNX="extsw";
 
16
} else {
 
17
    $CMPLI="cmplwi";
 
18
    $SHRLI="srwi";
 
19
    $SIGNX="mr";
 
20
}
 
21
 
 
22
$code=<<___;
 
23
.machine        "any"
 
24
.text
 
25
 
 
26
.globl  .OPENSSL_cpuid_setup
 
27
.align  4
 
28
.OPENSSL_cpuid_setup:
 
29
        blr
 
30
 
 
31
.globl  .OPENSSL_wipe_cpu
 
32
.align  4
 
33
.OPENSSL_wipe_cpu:
 
34
        xor     r0,r0,r0
 
35
        mr      r3,r1
 
36
        xor     r4,r4,r4
 
37
        xor     r5,r5,r5
 
38
        xor     r6,r6,r6
 
39
        xor     r7,r7,r7
 
40
        xor     r8,r8,r8
 
41
        xor     r9,r9,r9
 
42
        xor     r10,r10,r10
 
43
        xor     r11,r11,r11
 
44
        xor     r12,r12,r12
 
45
        blr
 
46
 
 
47
.globl  .OPENSSL_atomic_add
 
48
.align  4
 
49
.OPENSSL_atomic_add:
 
50
Loop:   lwarx   r5,0,r3
 
51
        add     r0,r4,r5
 
52
        stwcx.  r0,0,r3
 
53
        bne-    Loop
 
54
        $SIGNX  r3,r0
 
55
        blr
 
56
 
 
57
.globl  .OPENSSL_rdtsc
 
58
.align  4
 
59
.OPENSSL_rdtsc:
 
60
        mftb    r3
 
61
        mftbu   r4
 
62
        blr
 
63
 
 
64
.globl  .OPENSSL_cleanse
 
65
.align  4
 
66
.OPENSSL_cleanse:
 
67
        $CMPLI  r4,7
 
68
        li      r0,0
 
69
        bge     Lot
 
70
Little: mtctr   r4
 
71
        stb     r0,0(r3)
 
72
        addi    r3,r3,1
 
73
        bdnz-   \$-8
 
74
        blr
 
75
Lot:    andi.   r5,r3,3
 
76
        beq     Laligned
 
77
        stb     r0,0(r3)
 
78
        subi    r4,r4,1
 
79
        addi    r3,r3,1
 
80
        b       Lot
 
81
Laligned:
 
82
        $SHRLI  r5,r4,2
 
83
        mtctr   r5
 
84
        stw     r0,0(r3)
 
85
        addi    r3,r3,4
 
86
        bdnz-   \$-8
 
87
        andi.   r4,r4,3
 
88
        bne     Little
 
89
        blr
 
90
___
 
91
 
 
92
$code =~ s/\`([^\`]*)\`/eval $1/gem;
 
93
print $code;
 
94
close STDOUT;