Commit | Line | Data |
---|---|---|
a17ae4c3 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
b020632e MS |
2 | /* |
3 | * Userland implementation of gettimeofday() for 64 bits processes in a | |
4 | * s390 kernel for use in the vDSO | |
5 | * | |
6 | * Copyright IBM Corp. 2008 | |
7 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) | |
b020632e MS |
8 | */ |
9 | #include <asm/vdso.h> | |
10 | #include <asm/asm-offsets.h> | |
11 | #include <asm/unistd.h> | |
bc3703f2 | 12 | #include <asm/dwarf.h> |
b020632e MS |
13 | |
14 | .text | |
15 | .align 4 | |
16 | .globl __kernel_gettimeofday | |
17 | .type __kernel_gettimeofday,@function | |
18 | __kernel_gettimeofday: | |
19 | .cfi_startproc | |
9b2efe03 | 20 | aghi %r15,-16 |
b020632e MS |
21 | larl %r5,_vdso_data |
22 | 0: ltgr %r3,%r3 /* check if tz is NULL */ | |
23 | je 1f | |
24 | mvc 0(8,%r3),__VDSO_TIMEZONE(%r5) | |
25 | 1: ltgr %r2,%r2 /* check if tv is NULL */ | |
26 | je 4f | |
27 | lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */ | |
28 | tmll %r4,0x0001 /* pending update ? loop */ | |
29 | jnz 0b | |
9b2efe03 HC |
30 | stcke 0(%r15) /* Store TOD clock */ |
31 | lg %r1,1(%r15) | |
75c7b6f3 MS |
32 | lg %r0,__VDSO_TS_END(%r5) /* TOD steering end time */ |
33 | slgr %r0,%r1 /* now - ts_steering_end */ | |
34 | ltgr %r0,%r0 /* past end of steering ? */ | |
35 | jm 6f | |
36 | srlg %r0,%r0,15 /* 1 per 2^16 */ | |
37 | tm __VDSO_TS_DIR+3(%r5),0x01 /* steering direction? */ | |
38 | jz 7f | |
39 | lcgr %r0,%r0 /* negative TOD offset */ | |
40 | 7: algr %r1,%r0 /* add steering offset */ | |
41 | 6: sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ | |
79c74ecb MS |
42 | msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */ |
43 | alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */ | |
44 | lg %r0,__VDSO_XTIME_SEC(%r5) /* tk->xtime_sec */ | |
b020632e MS |
45 | clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ |
46 | jne 0b | |
79c74ecb MS |
47 | lgf %r5,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ |
48 | srlg %r1,%r1,0(%r5) /* >> tk->shift */ | |
b020632e MS |
49 | larl %r5,5f |
50 | 2: clg %r1,0(%r5) | |
51 | jl 3f | |
52 | slg %r1,0(%r5) | |
53 | aghi %r0,1 | |
54 | j 2b | |
55 | 3: stg %r0,0(%r2) /* store tv->tv_sec */ | |
56 | slgr %r0,%r0 /* tv_nsec -> tv_usec */ | |
57 | ml %r0,8(%r5) | |
58 | srlg %r0,%r0,6 | |
59 | stg %r0,8(%r2) /* store tv->tv_usec */ | |
60 | 4: lghi %r2,0 | |
9b2efe03 | 61 | aghi %r15,16 |
b020632e MS |
62 | br %r14 |
63 | 5: .quad 1000000000 | |
64 | .long 274877907 | |
65 | .cfi_endproc | |
66 | .size __kernel_gettimeofday,.-__kernel_gettimeofday |