Fix EVP CCM decrypt. Add decrypt support to algorithm test program.
[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         ldq_u   $1,0($16)
103         mov     $16,$2
104 .Lalign:
105         mskbl   $1,$16,$1
106         lda     $16,1($16)
107         subq    $17,1,$17
108         subq    $0,1,$0
109         beq     $17,.Lout
110         bne     $0,.Lalign
111 .Lout:  stq_u   $1,0($2)
112         beq     $17,.Ldone
113         bic     $17,7,$at
114         mov     $17,$0
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         beq     $17,.Ldone
124         mov     $17,$0
125         br      .Little
126 .Ldone: ret     ($26)
127 .end    OPENSSL_cleanse
128 ___
129 {
130 my ($out,$cnt,$max)=("\$16","\$17","\$18");
131 my ($tick,$lasttick)=("\$19","\$20");
132 my ($diff,$lastdiff)=("\$21","\$22");
133 my ($v0,$ra,$sp,$zero)=("\$0","\$26","\$30","\$31");
134
135 print <<___;
136 .globl  OPENSSL_instrument_bus
137 .ent    OPENSSL_instrument_bus
138 OPENSSL_instrument_bus:
139         .frame  $sp,0,$ra
140         .prologue 0
141         mov     $cnt,$v0
142
143         rpcc    $lasttick
144         mov     0,$diff
145
146         ecb     ($out)
147         ldl_l   $tick,0($out)
148         addl    $diff,$tick,$tick
149         mov     $tick,$diff
150         stl_c   $tick,0($out)
151         stl     $diff,0($out)
152
153 .Loop:  rpcc    $tick
154         subq    $tick,$lasttick,$diff
155         mov     $tick,$lasttick
156
157         ecb     ($out)
158         ldl_l   $tick,0($out)
159         addl    $diff,$tick,$tick
160         mov     $tick,$diff
161         stl_c   $tick,0($out)
162         stl     $diff,0($out)
163
164         subl    $cnt,1,$cnt
165         lda     $out,4($out)
166         bne     $cnt,.Loop
167
168         ret     ($ra)
169 .end    OPENSSL_instrument_bus
170
171 .globl  OPENSSL_instrument_bus2
172 .ent    OPENSSL_instrument_bus2
173 OPENSSL_instrument_bus2:
174         .frame  $sp,0,$ra
175         .prologue 0
176         mov     $cnt,$v0
177
178         rpcc    $lasttick
179         mov     0,$diff
180
181         ecb     ($out)
182         ldl_l   $tick,0($out)
183         addl    $diff,$tick,$tick
184         mov     $tick,$diff
185         stl_c   $tick,0($out)
186         stl     $diff,0($out)
187
188         rpcc    $tick
189         subq    $tick,$lasttick,$diff
190         mov     $tick,$lasttick
191         mov     $diff,$lastdiff
192 .Loop2:
193         ecb     ($out)
194         ldl_l   $tick,0($out)
195         addl    $diff,$tick,$tick
196         mov     $tick,$diff
197         stl_c   $tick,0($out)
198         stl     $diff,0($out)
199
200         subl    $max,1,$max
201         beq     $max,.Ldone2
202
203         rpcc    $tick
204         subq    $tick,$lasttick,$diff
205         mov     $tick,$lasttick
206         subq    $lastdiff,$diff,$tick
207         mov     $diff,$lastdiff
208         cmovne  $tick,1,$tick
209         subl    $cnt,$tick,$cnt
210         s4addq  $tick,$out,$out
211         bne     $cnt,.Loop2
212
213 .Ldone2:
214         subl    $v0,$cnt,$v0
215         ret     ($ra)
216 .end    OPENSSL_instrument_bus2
217 ___
218 }