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:
24 0: al %r5,21f-0b(%r5) /* get &_vdso_data */
25 chi %r2,__CLOCK_REALTIME_COARSE
27 chi %r2,__CLOCK_REALTIME
29 chi %r2,__CLOCK_MONOTONIC_COARSE
31 chi %r2,__CLOCK_MONOTONIC
35 1: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
36 tml %r4,0x0001 /* pending update ? loop */
38 stcke 0(%r15) /* Store TOD clock */
40 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
41 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
44 2: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
46 l %r0,__VDSO_TK_MULT(%r5)
50 a %r0,__VDSO_TK_MULT(%r5)
52 al %r0,__VDSO_WTOM_NSEC(%r5)
53 al %r1,__VDSO_WTOM_NSEC+4(%r5)
56 5: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
57 srdl %r0,0(%r2) /* >> tk->shift */
58 l %r2,__VDSO_WTOM_SEC+4(%r5)
59 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
71 8: st %r2,0(%r3) /* store tp->tv_sec */
72 st %r1,4(%r3) /* store tp->tv_nsec */
77 /* CLOCK_MONOTONIC_COARSE */
78 9: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
79 tml %r4,0x0001 /* pending update ? loop */
81 l %r2,__VDSO_WTOM_CRS_SEC+4(%r5)
82 l %r1,__VDSO_WTOM_CRS_NSEC+4(%r5)
83 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
87 /* CLOCK_REALTIME_COARSE */
88 10: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
89 tml %r4,0x0001 /* pending update ? loop */
91 l %r2,__VDSO_XTIME_CRS_SEC+4(%r5)
92 l %r1,__VDSO_XTIME_CRS_NSEC+4(%r5)
93 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
98 11: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
99 tml %r4,0x0001 /* pending update ? loop */
101 stcke 0(%r15) /* Store TOD clock */
103 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
104 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
107 12: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
109 l %r0,__VDSO_TK_MULT(%r5)
113 a %r0,__VDSO_TK_MULT(%r5)
115 al %r0,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
116 al %r1,__VDSO_XTIME_NSEC+4(%r5)
119 14: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
120 srdl %r0,0(%r2) /* >> tk->shift */
121 l %r2,__VDSO_XTIME_SEC+4(%r5)
122 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
134 17: st %r2,0(%r3) /* store tp->tv_sec */
135 st %r1,4(%r3) /* store tp->tv_nsec */
140 /* Fallback to system call */
141 19: lhi %r1,__NR_clock_gettime
147 21: .long _vdso_data - 0b
149 .size __kernel_clock_gettime,.-__kernel_clock_gettime