2 * Userland implementation of clock_gettime() for 64 bits processes in a
3 * s390 kernel for use in the vDSO
5 * Copyright IBM Corp. 2008
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
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.
13 #include <asm/asm-offsets.h>
14 #include <asm/unistd.h>
18 .globl __kernel_clock_gettime
19 .type __kernel_clock_gettime,@function
20 __kernel_clock_gettime:
23 cghi %r2,CLOCK_REALTIME
25 cghi %r2,CLOCK_MONOTONIC
30 jz 3f /* tp == NULL */
31 0: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
32 tmll %r4,0x0001 /* pending update ? loop */
34 stck 48(%r15) /* Store TOD clock */
36 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
38 srlg %r1,%r1,12 /* cyc2ns(clock,cycle_delta) */
39 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + xtime */
40 lg %r0,__VDSO_XTIME_SEC(%r5)
41 alg %r1,__VDSO_WTOM_NSEC(%r5) /* + wall_to_monotonic */
42 alg %r0,__VDSO_WTOM_SEC(%r5)
43 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
51 2: stg %r0,0(%r3) /* store tp->tv_sec */
52 stg %r1,8(%r3) /* store tp->tv_nsec */
57 4: ltr %r3,%r3 /* tp == NULL */
59 5: lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
60 tmll %r4,0x0001 /* pending update ? loop */
62 stck 48(%r15) /* Store TOD clock */
64 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
66 srlg %r1,%r1,12 /* cyc2ns(clock,cycle_delta) */
67 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + xtime */
68 lg %r0,__VDSO_XTIME_SEC(%r5)
69 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
77 7: stg %r0,0(%r3) /* store tp->tv_sec */
78 stg %r1,8(%r3) /* store tp->tv_nsec */
82 /* Fallback to system call */
83 9: lghi %r1,__NR_clock_gettime
89 .size __kernel_clock_gettime,.-__kernel_clock_gettime