Remove some functions that are no longer used and break the build with:
[openssl.git] / crypto / ppccpuid.pl
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_ppc64_probe
27 .align  4
28 .OPENSSL_ppc64_probe:
29         fcfid   f1,f1
30         extrdi  r0,r0,32,0
31         blr
32         .long   0
33         .byte   0,12,0x14,0,0,0,0,0
34 .size   .OPENSSL_ppc64_probe,.-.OPENSSL_ppc64_probe
35
36 .globl  .OPENSSL_altivec_probe
37 .align  4
38 .OPENSSL_altivec_probe:
39         .long   0x10000484      # vor   v0,v0,v0
40         blr
41         .long   0
42         .byte   0,12,0x14,0,0,0,0,0
43 .size   .OPENSSL_altivec_probe,.-..OPENSSL_altivec_probe
44
45 .globl  .OPENSSL_crypto207_probe
46 .align  4
47 .OPENSSL_crypto207_probe:
48         lvx_u   v0,0,r1
49         vcipher v0,v0,v0
50         blr
51         .long   0
52         .byte   0,12,0x14,0,0,0,0,0
53 .size   .OPENSSL_crypto207_probe,.-.OPENSSL_crypto207_probe
54
55 .globl  .OPENSSL_wipe_cpu
56 .align  4
57 .OPENSSL_wipe_cpu:
58         xor     r0,r0,r0
59         fmr     f0,f31
60         fmr     f1,f31
61         fmr     f2,f31
62         mr      r3,r1
63         fmr     f3,f31
64         xor     r4,r4,r4
65         fmr     f4,f31
66         xor     r5,r5,r5
67         fmr     f5,f31
68         xor     r6,r6,r6
69         fmr     f6,f31
70         xor     r7,r7,r7
71         fmr     f7,f31
72         xor     r8,r8,r8
73         fmr     f8,f31
74         xor     r9,r9,r9
75         fmr     f9,f31
76         xor     r10,r10,r10
77         fmr     f10,f31
78         xor     r11,r11,r11
79         fmr     f11,f31
80         xor     r12,r12,r12
81         fmr     f12,f31
82         fmr     f13,f31
83         blr
84         .long   0
85         .byte   0,12,0x14,0,0,0,0,0
86 .size   .OPENSSL_wipe_cpu,.-.OPENSSL_wipe_cpu
87
88 .globl  .OPENSSL_atomic_add
89 .align  4
90 .OPENSSL_atomic_add:
91 Ladd:   lwarx   r5,0,r3
92         add     r0,r4,r5
93         stwcx.  r0,0,r3
94         bne-    Ladd
95         $SIGNX  r3,r0
96         blr
97         .long   0
98         .byte   0,12,0x14,0,0,0,2,0
99         .long   0
100 .size   .OPENSSL_atomic_add,.-.OPENSSL_atomic_add
101
102 .globl  .OPENSSL_rdtsc
103 .align  4
104 .OPENSSL_rdtsc:
105         mftb    r3
106         mftbu   r4
107         blr
108         .long   0
109         .byte   0,12,0x14,0,0,0,0,0
110 .size   .OPENSSL_rdtsc,.-.OPENSSL_rdtsc
111
112 .globl  .OPENSSL_cleanse
113 .align  4
114 .OPENSSL_cleanse:
115         $CMPLI  r4,7
116         li      r0,0
117         bge     Lot
118         $CMPLI  r4,0
119         beqlr-
120 Little: mtctr   r4
121         stb     r0,0(r3)
122         addi    r3,r3,1
123         bdnz    \$-8
124         blr
125 Lot:    andi.   r5,r3,3
126         beq     Laligned
127         stb     r0,0(r3)
128         subi    r4,r4,1
129         addi    r3,r3,1
130         b       Lot
131 Laligned:
132         $SHRLI  r5,r4,2
133         mtctr   r5
134         stw     r0,0(r3)
135         addi    r3,r3,4
136         bdnz    \$-8
137         andi.   r4,r4,3
138         bne     Little
139         blr
140         .long   0
141         .byte   0,12,0x14,0,0,0,2,0
142         .long   0
143 .size   .OPENSSL_cleanse,.-.OPENSSL_cleanse
144 ___
145 {
146 my ($out,$cnt,$max)=("r3","r4","r5");
147 my ($tick,$lasttick)=("r6","r7");
148 my ($diff,$lastdiff)=("r8","r9");
149
150 $code.=<<___;
151 .globl  .OPENSSL_instrument_bus
152 .align  4
153 .OPENSSL_instrument_bus:
154         mtctr   $cnt
155
156         mftb    $lasttick               # collect 1st tick
157         li      $diff,0
158
159         dcbf    0,$out                  # flush cache line
160         lwarx   $tick,0,$out            # load and lock
161         add     $tick,$tick,$diff
162         stwcx.  $tick,0,$out
163         stwx    $tick,0,$out
164
165 Loop:   mftb    $tick
166         sub     $diff,$tick,$lasttick
167         mr      $lasttick,$tick
168         dcbf    0,$out                  # flush cache line
169         lwarx   $tick,0,$out            # load and lock
170         add     $tick,$tick,$diff
171         stwcx.  $tick,0,$out
172         stwx    $tick,0,$out
173         addi    $out,$out,4             # ++$out
174         bdnz    Loop
175
176         mr      r3,$cnt
177         blr
178         .long   0
179         .byte   0,12,0x14,0,0,0,2,0
180         .long   0
181 .size   .OPENSSL_instrument_bus,.-.OPENSSL_instrument_bus
182
183 .globl  .OPENSSL_instrument_bus2
184 .align  4
185 .OPENSSL_instrument_bus2:
186         mr      r0,$cnt
187         slwi    $cnt,$cnt,2
188
189         mftb    $lasttick               # collect 1st tick
190         li      $diff,0
191
192         dcbf    0,$out                  # flush cache line
193         lwarx   $tick,0,$out            # load and lock
194         add     $tick,$tick,$diff
195         stwcx.  $tick,0,$out
196         stwx    $tick,0,$out
197
198         mftb    $tick                   # collect 1st diff
199         sub     $diff,$tick,$lasttick
200         mr      $lasttick,$tick
201         mr      $lastdiff,$diff
202 Loop2:
203         dcbf    0,$out                  # flush cache line
204         lwarx   $tick,0,$out            # load and lock
205         add     $tick,$tick,$diff
206         stwcx.  $tick,0,$out
207         stwx    $tick,0,$out
208
209         addic.  $max,$max,-1
210         beq     Ldone2
211
212         mftb    $tick
213         sub     $diff,$tick,$lasttick
214         mr      $lasttick,$tick
215         cmplw   7,$diff,$lastdiff
216         mr      $lastdiff,$diff
217
218         mfcr    $tick                   # pull cr
219         not     $tick,$tick             # flip bits
220         rlwinm  $tick,$tick,1,29,29     # isolate flipped eq bit and scale
221
222         sub.    $cnt,$cnt,$tick         # conditional --$cnt
223         add     $out,$out,$tick         # conditional ++$out
224         bne     Loop2
225
226 Ldone2:
227         srwi    $cnt,$cnt,2
228         sub     r3,r0,$cnt
229         blr
230         .long   0
231         .byte   0,12,0x14,0,0,0,3,0
232         .long   0
233 .size   .OPENSSL_instrument_bus2,.-.OPENSSL_instrument_bus2
234 ___
235 }
236
237 $code =~ s/\`([^\`]*)\`/eval $1/gem;
238 print $code;
239 close STDOUT;