2 * Userland implementation of clock_gettime() for 32 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 0: al %r5,21f-0b(%r5) /* get &_vdso_data */
24 chi %r2,__CLOCK_REALTIME
26 chi %r2,__CLOCK_MONOTONIC
31 jz 9f /* tp == NULL */
32 1: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
33 tml %r4,0x0001 /* pending update ? loop */
35 stck 24(%r15) /* Store TOD clock */
37 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
38 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
41 2: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
43 l %r0,__VDSO_TK_MULT(%r5)
47 a %r0,__VDSO_TK_MULT(%r5)
49 al %r0,__VDSO_WTOM_NSEC(%r5)
50 al %r1,__VDSO_WTOM_NSEC+4(%r5)
53 5: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
54 srdl %r0,0(%r2) /* >> tk->shift */
55 l %r2,__VDSO_WTOM_SEC+4(%r5)
56 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
68 8: st %r2,0(%r3) /* store tp->tv_sec */
69 st %r1,4(%r3) /* store tp->tv_nsec */
74 10: ltr %r3,%r3 /* tp == NULL */
76 11: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
77 tml %r4,0x0001 /* pending update ? loop */
79 stck 24(%r15) /* Store TOD clock */
81 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
82 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
85 12: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
87 l %r0,__VDSO_TK_MULT(%r5)
91 a %r0,__VDSO_TK_MULT(%r5)
93 al %r0,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
94 al %r1,__VDSO_XTIME_NSEC+4(%r5)
97 14: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
98 srdl %r0,0(%r2) /* >> tk->shift */
99 l %r2,__VDSO_XTIME_SEC+4(%r5)
100 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
112 17: st %r2,0(%r3) /* store tp->tv_sec */
113 st %r1,4(%r3) /* store tp->tv_nsec */
117 /* Fallback to system call */
118 19: lhi %r1,__NR_clock_gettime
123 21: .long _vdso_data - 0b
125 .size __kernel_clock_gettime,.-__kernel_clock_gettime