]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/s390/kernel/vdso32/clock_gettime.S
Merge tag 'pwm/for-3.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry...
[mirror_ubuntu-artful-kernel.git] / arch / s390 / kernel / vdso32 / clock_gettime.S
1 /*
2 * Userland implementation of clock_gettime() for 32 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_gettime
19 .type __kernel_clock_gettime,@function
20 __kernel_clock_gettime:
21 .cfi_startproc
22 basr %r5,0
23 0: al %r5,21f-0b(%r5) /* get &_vdso_data */
24 chi %r2,__CLOCK_REALTIME_COARSE
25 je 10f
26 chi %r2,__CLOCK_REALTIME
27 je 11f
28 chi %r2,__CLOCK_MONOTONIC_COARSE
29 je 9f
30 chi %r2,__CLOCK_MONOTONIC
31 jne 19f
32
33 /* CLOCK_MONOTONIC */
34 1: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
35 tml %r4,0x0001 /* pending update ? loop */
36 jnz 1b
37 stcke 24(%r15) /* Store TOD clock */
38 lm %r0,%r1,25(%r15)
39 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
40 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
41 brc 3,2f
42 ahi %r0,-1
43 2: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
44 lr %r2,%r0
45 l %r0,__VDSO_TK_MULT(%r5)
46 ltr %r1,%r1
47 mr %r0,%r0
48 jnm 3f
49 a %r0,__VDSO_TK_MULT(%r5)
50 3: alr %r0,%r2
51 al %r0,__VDSO_WTOM_NSEC(%r5)
52 al %r1,__VDSO_WTOM_NSEC+4(%r5)
53 brc 12,5f
54 ahi %r0,1
55 5: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
56 srdl %r0,0(%r2) /* >> tk->shift */
57 l %r2,__VDSO_WTOM_SEC+4(%r5)
58 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
59 jne 1b
60 basr %r5,0
61 6: ltr %r0,%r0
62 jnz 7f
63 cl %r1,20f-6b(%r5)
64 jl 8f
65 7: ahi %r2,1
66 sl %r1,20f-6b(%r5)
67 brc 3,6b
68 ahi %r0,-1
69 j 6b
70 8: st %r2,0(%r3) /* store tp->tv_sec */
71 st %r1,4(%r3) /* store tp->tv_nsec */
72 lhi %r2,0
73 br %r14
74
75 /* CLOCK_MONOTONIC_COARSE */
76 9: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
77 tml %r4,0x0001 /* pending update ? loop */
78 jnz 9b
79 l %r2,__VDSO_WTOM_CRS_SEC+4(%r5)
80 l %r1,__VDSO_WTOM_CRS_NSEC+4(%r5)
81 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
82 jne 9b
83 j 8b
84
85 /* CLOCK_REALTIME_COARSE */
86 10: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
87 tml %r4,0x0001 /* pending update ? loop */
88 jnz 10b
89 l %r2,__VDSO_XTIME_CRS_SEC+4(%r5)
90 l %r1,__VDSO_XTIME_CRS_NSEC+4(%r5)
91 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
92 jne 10b
93 j 17f
94
95 /* CLOCK_REALTIME */
96 11: l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
97 tml %r4,0x0001 /* pending update ? loop */
98 jnz 11b
99 stcke 24(%r15) /* Store TOD clock */
100 lm %r0,%r1,25(%r15)
101 s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
102 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
103 brc 3,12f
104 ahi %r0,-1
105 12: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
106 lr %r2,%r0
107 l %r0,__VDSO_TK_MULT(%r5)
108 ltr %r1,%r1
109 mr %r0,%r0
110 jnm 13f
111 a %r0,__VDSO_TK_MULT(%r5)
112 13: alr %r0,%r2
113 al %r0,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
114 al %r1,__VDSO_XTIME_NSEC+4(%r5)
115 brc 12,14f
116 ahi %r0,1
117 14: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
118 srdl %r0,0(%r2) /* >> tk->shift */
119 l %r2,__VDSO_XTIME_SEC+4(%r5)
120 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
121 jne 11b
122 basr %r5,0
123 15: ltr %r0,%r0
124 jnz 16f
125 cl %r1,20f-15b(%r5)
126 jl 17f
127 16: ahi %r2,1
128 sl %r1,20f-15b(%r5)
129 brc 3,15b
130 ahi %r0,-1
131 j 15b
132 17: st %r2,0(%r3) /* store tp->tv_sec */
133 st %r1,4(%r3) /* store tp->tv_nsec */
134 lhi %r2,0
135 br %r14
136
137 /* Fallback to system call */
138 19: lhi %r1,__NR_clock_gettime
139 svc 0
140 br %r14
141
142 20: .long 1000000000
143 21: .long _vdso_data - 0b
144 .cfi_endproc
145 .size __kernel_clock_gettime,.-__kernel_clock_gettime