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