1.text
2
3.globl	OPENSSL_s390x_facilities
4.type	OPENSSL_s390x_facilities,@function
5.align	16
6OPENSSL_s390x_facilities:
7	lghi	%r0,0
8	larl	%r2,OPENSSL_s390xcap_P
9	stg	%r0,8(%r2)
10	.long	0xb2b02000	# stfle	0(%r2)
11	brc	8,.Ldone
12	lghi	%r0,1
13	.long	0xb2b02000	# stfle 0(%r2)
14.Ldone:
15	lg	%r2,0(%r2)
16	br	%r14
17.size	OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities
18
19.globl	OPENSSL_rdtsc
20.type	OPENSSL_rdtsc,@function
21.align	16
22OPENSSL_rdtsc:
23	stck	16(%r15)
24	lg	%r2,16(%r15)
25	br	%r14
26.size	OPENSSL_rdtsc,.-OPENSSL_rdtsc
27
28.globl	OPENSSL_atomic_add
29.type	OPENSSL_atomic_add,@function
30.align	16
31OPENSSL_atomic_add:
32	l	%r1,0(%r2)
33.Lspin:	lr	%r0,%r1
34	ar	%r0,%r3
35	cs	%r1,%r0,0(%r2)
36	brc	4,.Lspin
37	lgfr	%r2,%r0		# OpenSSL expects the new value
38	br	%r14
39.size	OPENSSL_atomic_add,.-OPENSSL_atomic_add
40
41.globl	OPENSSL_wipe_cpu
42.type	OPENSSL_wipe_cpu,@function
43.align	16
44OPENSSL_wipe_cpu:
45	xgr	%r0,%r0
46	xgr	%r1,%r1
47	lgr	%r2,%r15
48	xgr	%r3,%r3
49	xgr	%r4,%r4
50	lzdr	%f0
51	lzdr	%f1
52	lzdr	%f2
53	lzdr	%f3
54	lzdr	%f4
55	lzdr	%f5
56	lzdr	%f6
57	lzdr	%f7
58	br	%r14
59.size	OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
60
61.globl	OPENSSL_cleanse
62.type	OPENSSL_cleanse,@function
63.align	16
64OPENSSL_cleanse:
65#if !defined(__s390x__) && !defined(__s390x)
66	llgfr	%r3,%r3
67#endif
68	lghi	%r4,15
69	lghi	%r0,0
70	clgr	%r3,%r4
71	jh	.Lot
72	clgr	%r3,%r0
73	bcr	8,%r14
74.Little:
75	stc	%r0,0(%r2)
76	la	%r2,1(%r2)
77	brctg	%r3,.Little
78	br	%r14
79.align	4
80.Lot:	tmll	%r2,7
81	jz	.Laligned
82	stc	%r0,0(%r2)
83	la	%r2,1(%r2)
84	brctg	%r3,.Lot
85.Laligned:
86	srlg	%r4,%r3,3
87.Loop:	stg	%r0,0(%r2)
88	la	%r2,8(%r2)
89	brctg	%r4,.Loop
90	lghi	%r4,7
91	ngr	%r3,%r4
92	jnz	.Little
93	br	%r14
94.size	OPENSSL_cleanse,.-OPENSSL_cleanse
95
96.section	.init
97	brasl	%r14,OPENSSL_cpuid_setup
98
99.comm	OPENSSL_s390xcap_P,16,8
100