1/*
2 * Userland implementation of clock_getres() for 64 bits processes in a
3 * s390 kernel for use in the vDSO
4 *
5 *  Copyright IBM Corp. 2008
6 *  Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#include <asm/vdso.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15
16	.text
17	.align 4
18	.globl __kernel_clock_getres
19	.type  __kernel_clock_getres,@function
20__kernel_clock_getres:
21	.cfi_startproc
22	larl	%r1,4f
23	cghi	%r2,__CLOCK_REALTIME_COARSE
24	je	0f
25	cghi	%r2,__CLOCK_MONOTONIC_COARSE
26	je	0f
27	larl	%r1,3f
28	cghi	%r2,__CLOCK_REALTIME
29	je	0f
30	cghi	%r2,__CLOCK_MONOTONIC
31	je	0f
32	cghi	%r2,__CLOCK_THREAD_CPUTIME_ID
33	je	0f
34	cghi	%r2,-2		/* Per-thread CPUCLOCK with PID=0, VIRT=1 */
35	jne	2f
36	larl	%r5,_vdso_data
37	icm	%r0,15,__LC_ECTG_OK(%r5)
38	jz	2f
390:	ltgr	%r3,%r3
40	jz	1f				/* res == NULL */
41	lg	%r0,0(%r1)
42	xc	0(8,%r3),0(%r3)			/* set tp->tv_sec to zero */
43	stg	%r0,8(%r3)			/* store tp->tv_usec */
441:	lghi	%r2,0
45	br	%r14
462:	lghi	%r1,__NR_clock_getres		/* fallback to svc */
47	svc	0
48	br	%r14
493:	.quad	__CLOCK_REALTIME_RES
504:	.quad	__CLOCK_COARSE_RES
51	.cfi_endproc
52	.size	__kernel_clock_getres,.-__kernel_clock_getres
53