]>
Commit | Line | Data |
---|---|---|
3e181369 AP |
1 | #!/usr/bin/env perl |
2 | # | |
3 | ||
4 | while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} | |
5 | open STDOUT,">$output"; | |
6 | ||
7 | $code.=<<___; | |
8 | .text | |
bd227733 AP |
9 | |
10 | .if .ASSEMBLER_VERSION<7000000 | |
11 | .asg 0,__TI_EABI__ | |
12 | .endif | |
904732f6 AP |
13 | .if __TI_EABI__ |
14 | .asg OPENSSL_rdtsc,_OPENSSL_rdtsc | |
15 | .asg OPENSSL_cleanse,_OPENSSL_cleanse | |
16 | .asg OPENSSL_atomic_add,_OPENSSL_atomic_add | |
17 | .asg OPENSSL_wipe_cpu,_OPENSSL_wipe_cpu | |
18 | .asg OPENSSL_instrument_bus,_OPENSSL_instrument_bus | |
19 | .asg OPENSSL_instrument_bus2,_OPENSSL_instrument_bus2 | |
20 | .endif | |
3e181369 AP |
21 | |
22 | .asg B3,RA | |
23 | ||
24 | .global _OPENSSL_rdtsc | |
25 | _OPENSSL_rdtsc: | |
26 | .asmfunc | |
27 | B RA | |
28 | MVC TSCL,B0 | |
29 | MVC TSCH,B1 | |
30 | [!B0] MVC B0,TSCL ; start TSC | |
31 | MV B0,A4 | |
32 | MV B1,A5 | |
33 | .endasmfunc | |
34 | ||
35 | .global _OPENSSL_cleanse | |
36 | _OPENSSL_cleanse: | |
37 | .asmfunc | |
38 | ZERO A3:A2 | |
39 | || ZERO B2 | |
40 | || SHRU B4,3,B0 ; is length >= 8 | |
41 | || ADD 1,A4,B6 | |
42 | [!B0] BNOP RA | |
43 | || ZERO A1 | |
44 | || ZERO B1 | |
45 | [B0] MVC B0,ILC | |
46 | ||[!B0] CMPLT 0,B4,A1 | |
47 | ||[!B0] CMPLT 1,B4,B1 | |
48 | [A1] STB A2,*A4++[2] | |
49 | || [B1] STB B2,*B6++[2] | |
50 | ||[!B0] CMPLT 2,B4,A1 | |
51 | ||[!B0] CMPLT 3,B4,B1 | |
52 | [A1] STB A2,*A4++[2] | |
53 | || [B1] STB B2,*B6++[2] | |
54 | ||[!B0] CMPLT 4,B4,A1 | |
55 | ||[!B0] CMPLT 5,B4,B1 | |
56 | [A1] STB A2,*A4++[2] | |
57 | || [B1] STB B2,*B6++[2] | |
58 | ||[!B0] CMPLT 6,B4,A1 | |
59 | [A1] STB A2,*A4++[2] | |
60 | ||
61 | SPLOOP 1 | |
62 | STNDW A3:A2,*A4++ | |
63 | || SUB B4,8,B4 | |
64 | SPKERNEL | |
65 | ||
66 | MV B4,B0 ; remaining bytes | |
67 | || ADD 1,A4,B6 | |
68 | || BNOP RA | |
69 | [B0] CMPLT 0,B0,A1 | |
70 | || [B0] CMPLT 1,B0,B1 | |
71 | [A1] STB A2,*A4++[2] | |
72 | || [B1] STB B2,*B6++[2] | |
73 | || [B0] CMPLT 2,B0,A1 | |
74 | || [B0] CMPLT 3,B0,B1 | |
75 | [A1] STB A2,*A4++[2] | |
76 | || [B1] STB B2,*B6++[2] | |
77 | || [B0] CMPLT 4,B0,A1 | |
78 | || [B0] CMPLT 5,B0,B1 | |
79 | [A1] STB A2,*A4++[2] | |
80 | || [B1] STB B2,*B6++[2] | |
81 | || [B0] CMPLT 6,B0,A1 | |
82 | [A1] STB A2,*A4++[2] | |
83 | .endasmfunc | |
84 | ||
85 | .global _OPENSSL_atomic_add | |
86 | _OPENSSL_atomic_add: | |
87 | .asmfunc | |
88 | MV A4,B0 | |
89 | atomic_add?: | |
90 | LL *B0,B5 | |
91 | NOP 4 | |
92 | ADD B4,B5,B5 | |
93 | SL B5,*B0 | |
94 | CMTL *B0,B1 | |
95 | NOP 4 | |
96 | [!B1] B atomic_add? | |
97 | [B1] BNOP RA,4 | |
98 | MV B5,A4 | |
99 | .endasmfunc | |
100 | ||
101 | .global _OPENSSL_wipe_cpu | |
102 | _OPENSSL_wipe_cpu: | |
103 | .asmfunc | |
104 | ZERO A0 | |
105 | || ZERO B0 | |
106 | || ZERO A1 | |
107 | || ZERO B1 | |
108 | ZERO A3:A2 | |
109 | || MVD B0,B2 | |
110 | || ZERO A4 | |
111 | || ZERO B4 | |
112 | || ZERO A5 | |
113 | || ZERO B5 | |
114 | || BNOP RA | |
115 | ZERO A7:A6 | |
116 | || ZERO B7:B6 | |
117 | || ZERO A8 | |
118 | || ZERO B8 | |
119 | || ZERO A9 | |
120 | || ZERO B9 | |
121 | ZERO A17:A16 | |
122 | || ZERO B17:B16 | |
123 | || ZERO A18 | |
124 | || ZERO B18 | |
125 | || ZERO A19 | |
126 | || ZERO B19 | |
127 | ZERO A21:A20 | |
128 | || ZERO B21:B20 | |
129 | || ZERO A22 | |
130 | || ZERO B22 | |
131 | || ZERO A23 | |
132 | || ZERO B23 | |
133 | ZERO A25:A24 | |
134 | || ZERO B25:B24 | |
135 | || ZERO A26 | |
136 | || ZERO B26 | |
137 | || ZERO A27 | |
138 | || ZERO B27 | |
139 | ZERO A29:A28 | |
140 | || ZERO B29:B28 | |
141 | || ZERO A30 | |
142 | || ZERO B30 | |
143 | || ZERO A31 | |
144 | || ZERO B31 | |
145 | .endasmfunc | |
146 | ||
147 | CLFLUSH .macro CONTROL,ADDR,LEN | |
148 | B passthrough? | |
149 | || STW ADDR,*CONTROL[0] | |
150 | STW LEN,*CONTROL[1] | |
151 | spinlock?: | |
152 | LDW *CONTROL[1],A0 | |
153 | NOP 3 | |
154 | passthrough?: | |
155 | NOP | |
156 | [A0] BNOP spinlock?,5 | |
157 | .endm | |
158 | ||
159 | .global _OPENSSL_instrument_bus | |
160 | _OPENSSL_instrument_bus: | |
161 | .asmfunc | |
162 | MV B4,B0 ; reassign sizeof(output) | |
163 | || MV A4,B4 ; reassign output | |
164 | || MVK 0x00004030,A3 | |
165 | MV B0,A4 ; return value | |
166 | || MVK 1,A1 | |
167 | || MVKH 0x01840000,A3 ; L1DWIBAR | |
168 | MVC TSCL,B8 ; collect 1st tick | |
169 | || MVK 0x00004010,A5 | |
170 | MV B8,B9 ; lasttick = tick | |
171 | || MVK 0,B7 ; lastdiff = 0 | |
172 | || MVKH 0x01840000,A5 ; L2WIBAR | |
173 | CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line | |
174 | CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line | |
175 | LL *B4,B5 | |
176 | NOP 4 | |
177 | ADD B7,B5,B5 | |
178 | SL B5,*B4 | |
179 | CMTL *B4,B1 | |
180 | NOP 4 | |
181 | STW B5,*B4 | |
182 | bus_loop1?: | |
183 | MVC TSCL,B8 | |
184 | || [B0] SUB B0,1,B0 | |
185 | SUB B8,B9,B7 ; lastdiff = tick - lasttick | |
186 | || MV B8,B9 ; lasttick = tick | |
187 | CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line | |
188 | CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line | |
189 | LL *B4,B5 | |
190 | NOP 4 | |
191 | ADD B7,B5,B5 | |
192 | SL B5,*B4 | |
193 | CMTL *B4,B1 | |
194 | STW B5,*B4 ; [!B1] is removed to flatten samples | |
195 | || ADDK 4,B4 | |
196 | || [B0] BNOP bus_loop1?,5 | |
197 | ||
198 | BNOP RA,5 | |
199 | .endasmfunc | |
200 | ||
201 | .global _OPENSSL_instrument_bus2 | |
202 | _OPENSSL_instrument_bus2: | |
203 | .asmfunc | |
204 | MV A6,B0 ; reassign max | |
205 | || MV B4,A6 ; reassing sizeof(output) | |
206 | || MVK 0x00004030,A3 | |
207 | MV A4,B4 ; reassign output | |
208 | || MVK 0,A4 ; return value | |
209 | || MVK 1,A1 | |
210 | || MVKH 0x01840000,A3 ; L1DWIBAR | |
211 | ||
212 | MVC TSCL,B8 ; collect 1st tick | |
213 | || MVK 0x00004010,A5 | |
214 | MV B8,B9 ; lasttick = tick | |
215 | || MVK 0,B7 ; lastdiff = 0 | |
216 | || MVKH 0x01840000,A5 ; L2WIBAR | |
217 | CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line | |
218 | CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line | |
219 | LL *B4,B5 | |
220 | NOP 4 | |
221 | ADD B7,B5,B5 | |
222 | SL B5,*B4 | |
223 | CMTL *B4,B1 | |
224 | NOP 4 | |
225 | STW B5,*B4 | |
226 | ||
227 | MVC TSCL,B8 ; collect 1st diff | |
228 | SUB B8,B9,B7 ; lastdiff = tick - lasttick | |
229 | || MV B8,B9 ; lasttick = tick | |
230 | || SUB B0,1,B0 | |
231 | bus_loop2?: | |
232 | CLFLUSH A3,B4,A1 ; write-back and invalidate L1D line | |
233 | CLFLUSH A5,B4,A1 ; write-back and invalidate L2 line | |
234 | LL *B4,B5 | |
235 | NOP 4 | |
236 | ADD B7,B5,B5 | |
237 | SL B5,*B4 | |
238 | CMTL *B4,B1 | |
239 | STW B5,*B4 ; [!B1] is removed to flatten samples | |
240 | ||[!B0] BNOP bus_loop2_done?,2 | |
241 | || SUB B0,1,B0 | |
242 | MVC TSCL,B8 | |
243 | SUB B8,B9,B8 | |
244 | || MV B8,B9 | |
245 | CMPEQ B8,B7,B2 | |
246 | || MV B8,B7 | |
247 | [!B2] ADDAW B4,1,B4 | |
248 | ||[!B2] ADDK 1,A4 | |
249 | CMPEQ A4,A6,A2 | |
250 | [!A2] BNOP bus_loop2?,5 | |
251 | ||
252 | bus_loop2_done?: | |
253 | BNOP RA,5 | |
254 | .endasmfunc | |
255 | ___ | |
256 | ||
257 | print $code; | |
258 | close STDOUT; |