1#if defined(__i386__)
2.file	"crypto/cpu-x86-asm.S"
3.text
4.globl	_OPENSSL_ia32_cpuid
5.private_extern	_OPENSSL_ia32_cpuid
6.align	4
7_OPENSSL_ia32_cpuid:
8L_OPENSSL_ia32_cpuid_begin:
9	pushl	%ebp
10	pushl	%ebx
11	pushl	%esi
12	pushl	%edi
13	xorl	%edx,%edx
14	pushfl
15	popl	%eax
16	movl	%eax,%ecx
17	xorl	$2097152,%eax
18	pushl	%eax
19	popfl
20	pushfl
21	popl	%eax
22	xorl	%eax,%ecx
23	xorl	%eax,%eax
24	btl	$21,%ecx
25	jnc	L000nocpuid
26	movl	20(%esp),%esi
27	movl	%eax,8(%esi)
28	.byte	0x0f,0xa2
29	movl	%eax,%edi
30	xorl	%eax,%eax
31	cmpl	$1970169159,%ebx
32	setne	%al
33	movl	%eax,%ebp
34	cmpl	$1231384169,%edx
35	setne	%al
36	orl	%eax,%ebp
37	cmpl	$1818588270,%ecx
38	setne	%al
39	orl	%eax,%ebp
40	jz	L001intel
41	cmpl	$1752462657,%ebx
42	setne	%al
43	movl	%eax,%esi
44	cmpl	$1769238117,%edx
45	setne	%al
46	orl	%eax,%esi
47	cmpl	$1145913699,%ecx
48	setne	%al
49	orl	%eax,%esi
50	jnz	L001intel
51	movl	$2147483648,%eax
52	.byte	0x0f,0xa2
53	cmpl	$2147483649,%eax
54	jb	L001intel
55	movl	%eax,%esi
56	movl	$2147483649,%eax
57	.byte	0x0f,0xa2
58	orl	%ecx,%ebp
59	andl	$2049,%ebp
60	cmpl	$2147483656,%esi
61	jb	L001intel
62	movl	$2147483656,%eax
63	.byte	0x0f,0xa2
64	movzbl	%cl,%esi
65	incl	%esi
66	movl	$1,%eax
67	xorl	%ecx,%ecx
68	.byte	0x0f,0xa2
69	btl	$28,%edx
70	jnc	L002generic
71	shrl	$16,%ebx
72	andl	$255,%ebx
73	cmpl	%esi,%ebx
74	ja	L002generic
75	andl	$4026531839,%edx
76	jmp	L002generic
77L001intel:
78	cmpl	$7,%edi
79	jb	L003cacheinfo
80	movl	20(%esp),%esi
81	movl	$7,%eax
82	xorl	%ecx,%ecx
83	.byte	0x0f,0xa2
84	movl	%ebx,8(%esi)
85L003cacheinfo:
86	cmpl	$4,%edi
87	movl	$-1,%edi
88	jb	L004nocacheinfo
89	movl	$4,%eax
90	movl	$0,%ecx
91	.byte	0x0f,0xa2
92	movl	%eax,%edi
93	shrl	$14,%edi
94	andl	$4095,%edi
95L004nocacheinfo:
96	movl	$1,%eax
97	xorl	%ecx,%ecx
98	.byte	0x0f,0xa2
99	andl	$3220176895,%edx
100	cmpl	$0,%ebp
101	jne	L005notintel
102	orl	$1073741824,%edx
103L005notintel:
104	btl	$28,%edx
105	jnc	L002generic
106	andl	$4026531839,%edx
107	cmpl	$0,%edi
108	je	L002generic
109	orl	$268435456,%edx
110	shrl	$16,%ebx
111	cmpb	$1,%bl
112	ja	L002generic
113	andl	$4026531839,%edx
114L002generic:
115	andl	$2048,%ebp
116	andl	$4294965247,%ecx
117	movl	%edx,%esi
118	orl	%ecx,%ebp
119	btl	$27,%ecx
120	jnc	L006clear_avx
121	xorl	%ecx,%ecx
122.byte	15,1,208
123	andl	$6,%eax
124	cmpl	$6,%eax
125	je	L007done
126	cmpl	$2,%eax
127	je	L006clear_avx
128L008clear_xmm:
129	andl	$4261412861,%ebp
130	andl	$4278190079,%esi
131L006clear_avx:
132	andl	$4026525695,%ebp
133	movl	20(%esp),%edi
134	andl	$4294967263,8(%edi)
135L007done:
136	movl	%esi,%eax
137	movl	%ebp,%edx
138L000nocpuid:
139	popl	%edi
140	popl	%esi
141	popl	%ebx
142	popl	%ebp
143	ret
144.globl	_OPENSSL_rdtsc
145.private_extern	_OPENSSL_rdtsc
146.align	4
147_OPENSSL_rdtsc:
148L_OPENSSL_rdtsc_begin:
149	xorl	%eax,%eax
150	xorl	%edx,%edx
151	call	L009PIC_me_up
152L009PIC_me_up:
153	popl	%ecx
154	movl	L_OPENSSL_ia32cap_P$non_lazy_ptr-L009PIC_me_up(%ecx),%ecx
155	btl	$4,(%ecx)
156	jnc	L010notsc
157	.byte	0x0f,0x31
158L010notsc:
159	ret
160.globl	_OPENSSL_instrument_halt
161.private_extern	_OPENSSL_instrument_halt
162.align	4
163_OPENSSL_instrument_halt:
164L_OPENSSL_instrument_halt_begin:
165	call	L011PIC_me_up
166L011PIC_me_up:
167	popl	%ecx
168	movl	L_OPENSSL_ia32cap_P$non_lazy_ptr-L011PIC_me_up(%ecx),%ecx
169	btl	$4,(%ecx)
170	jnc	L012nohalt
171.long	2421723150
172	andl	$3,%eax
173	jnz	L012nohalt
174	pushfl
175	popl	%eax
176	btl	$9,%eax
177	jnc	L012nohalt
178	.byte	0x0f,0x31
179	pushl	%edx
180	pushl	%eax
181	hlt
182	.byte	0x0f,0x31
183	subl	(%esp),%eax
184	sbbl	4(%esp),%edx
185	addl	$8,%esp
186	ret
187L012nohalt:
188	xorl	%eax,%eax
189	xorl	%edx,%edx
190	ret
191.globl	_OPENSSL_far_spin
192.private_extern	_OPENSSL_far_spin
193.align	4
194_OPENSSL_far_spin:
195L_OPENSSL_far_spin_begin:
196	pushfl
197	popl	%eax
198	btl	$9,%eax
199	jnc	L013nospin
200	movl	4(%esp),%eax
201	movl	8(%esp),%ecx
202.long	2430111262
203	xorl	%eax,%eax
204	movl	(%ecx),%edx
205	jmp	L014spin
206.align	4,0x90
207L014spin:
208	incl	%eax
209	cmpl	(%ecx),%edx
210	je	L014spin
211.long	529567888
212	ret
213L013nospin:
214	xorl	%eax,%eax
215	xorl	%edx,%edx
216	ret
217.globl	_OPENSSL_wipe_cpu
218.private_extern	_OPENSSL_wipe_cpu
219.align	4
220_OPENSSL_wipe_cpu:
221L_OPENSSL_wipe_cpu_begin:
222	xorl	%eax,%eax
223	xorl	%edx,%edx
224	call	L015PIC_me_up
225L015PIC_me_up:
226	popl	%ecx
227	movl	L_OPENSSL_ia32cap_P$non_lazy_ptr-L015PIC_me_up(%ecx),%ecx
228	movl	(%ecx),%ecx
229	btl	$1,(%ecx)
230	jnc	L016no_x87
231	andl	$83886080,%ecx
232	cmpl	$83886080,%ecx
233	jne	L017no_sse2
234	pxor	%xmm0,%xmm0
235	pxor	%xmm1,%xmm1
236	pxor	%xmm2,%xmm2
237	pxor	%xmm3,%xmm3
238	pxor	%xmm4,%xmm4
239	pxor	%xmm5,%xmm5
240	pxor	%xmm6,%xmm6
241	pxor	%xmm7,%xmm7
242L017no_sse2:
243.long	4007259865,4007259865,4007259865,4007259865,2430851995
244L016no_x87:
245	leal	4(%esp),%eax
246	ret
247.globl	_OPENSSL_atomic_add
248.private_extern	_OPENSSL_atomic_add
249.align	4
250_OPENSSL_atomic_add:
251L_OPENSSL_atomic_add_begin:
252	movl	4(%esp),%edx
253	movl	8(%esp),%ecx
254	pushl	%ebx
255	nop
256	movl	(%edx),%eax
257L018spin:
258	leal	(%eax,%ecx,1),%ebx
259	nop
260.long	447811568
261	jne	L018spin
262	movl	%ebx,%eax
263	popl	%ebx
264	ret
265.globl	_OPENSSL_indirect_call
266.private_extern	_OPENSSL_indirect_call
267.align	4
268_OPENSSL_indirect_call:
269L_OPENSSL_indirect_call_begin:
270	pushl	%ebp
271	movl	%esp,%ebp
272	subl	$28,%esp
273	movl	12(%ebp),%ecx
274	movl	%ecx,(%esp)
275	movl	16(%ebp),%edx
276	movl	%edx,4(%esp)
277	movl	20(%ebp),%eax
278	movl	%eax,8(%esp)
279	movl	24(%ebp),%eax
280	movl	%eax,12(%esp)
281	movl	28(%ebp),%eax
282	movl	%eax,16(%esp)
283	movl	32(%ebp),%eax
284	movl	%eax,20(%esp)
285	movl	36(%ebp),%eax
286	movl	%eax,24(%esp)
287	call	*8(%ebp)
288	movl	%ebp,%esp
289	popl	%ebp
290	ret
291.globl	_OPENSSL_ia32_rdrand
292.private_extern	_OPENSSL_ia32_rdrand
293.align	4
294_OPENSSL_ia32_rdrand:
295L_OPENSSL_ia32_rdrand_begin:
296	movl	$8,%ecx
297L019loop:
298.byte	15,199,240
299	jc	L020break
300	loop	L019loop
301L020break:
302	cmpl	$0,%eax
303	cmovel	%ecx,%eax
304	ret
305.section __IMPORT,__pointers,non_lazy_symbol_pointers
306L_OPENSSL_ia32cap_P$non_lazy_ptr:
307.indirect_symbol	_OPENSSL_ia32cap_P
308.long	0
309#endif
310