aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64/kernel/vdso64/gettimeofday.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ppc64/kernel/vdso64/gettimeofday.S')
-rw-r--r--arch/ppc64/kernel/vdso64/gettimeofday.S91
1 files changed, 91 insertions, 0 deletions
diff --git a/arch/ppc64/kernel/vdso64/gettimeofday.S b/arch/ppc64/kernel/vdso64/gettimeofday.S
new file mode 100644
index 000000000000..ed3f970ff05e
--- /dev/null
+++ b/arch/ppc64/kernel/vdso64/gettimeofday.S
@@ -0,0 +1,91 @@
1/*
2 * Userland implementation of gettimeofday() for 64 bits processes in a
3 * ppc64 kernel for use in the vDSO
4 *
5 * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
6 * IBM Corp.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13#include <linux/config.h>
14#include <asm/processor.h>
15#include <asm/ppc_asm.h>
16#include <asm/vdso.h>
17#include <asm/offsets.h>
18
19 .text
20/*
21 * Exact prototype of gettimeofday
22 *
23 * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz);
24 *
25 */
26V_FUNCTION_BEGIN(__kernel_gettimeofday)
27 .cfi_startproc
28 mflr r12
29 .cfi_register lr,r12
30
31 mr r11,r3 /* r11 holds tv */
32 mr r10,r4 /* r10 holds tz */
33 bl V_LOCAL_FUNC(__get_datapage) /* get data page */
34 bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */
35 lis r7,15 /* r7 = 1000000 = USEC_PER_SEC */
36 ori r7,r7,16960
37 rldicl r5,r4,44,20 /* r5 = sec = xsec / XSEC_PER_SEC */
38 rldicr r6,r5,20,43 /* r6 = sec * XSEC_PER_SEC */
39 std r5,TVAL64_TV_SEC(r11) /* store sec in tv */
40 subf r0,r6,r4 /* r0 = xsec = (xsec - r6) */
41 mulld r0,r0,r7 /* usec = (xsec * USEC_PER_SEC) / XSEC_PER_SEC */
42 rldicl r0,r0,44,20
43 cmpldi cr0,r10,0 /* check if tz is NULL */
44 std r0,TVAL64_TV_USEC(r11) /* store usec in tv */
45 beq 1f
46 lwz r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */
47 lwz r5,CFG_TZ_DSTTIME(r3)
48 stw r4,TZONE_TZ_MINWEST(r10)
49 stw r5,TZONE_TZ_DSTTIME(r10)
501: mtlr r12
51 li r3,0 /* always success */
52 blr
53 .cfi_endproc
54V_FUNCTION_END(__kernel_gettimeofday)
55
56
57/*
58 * This is the core of gettimeofday(), it returns the xsec
59 * value in r4 and expects the datapage ptr (non clobbered)
60 * in r3. clobbers r0,r4,r5,r6,r7,r8
61*/
62V_FUNCTION_BEGIN(__do_get_xsec)
63 .cfi_startproc
64 /* check for update count & load values */
651: ld r7,CFG_TB_UPDATE_COUNT(r3)
66 andi. r0,r4,1 /* pending update ? loop */
67 bne- 1b
68 xor r0,r4,r4 /* create dependency */
69 add r3,r3,r0
70
71 /* Get TB & offset it */
72 mftb r8
73 ld r9,CFG_TB_ORIG_STAMP(r3)
74 subf r8,r9,r8
75
76 /* Scale result */
77 ld r5,CFG_TB_TO_XS(r3)
78 mulhdu r8,r8,r5
79
80 /* Add stamp since epoch */
81 ld r6,CFG_STAMP_XSEC(r3)
82 add r4,r6,r8
83
84 xor r0,r4,r4
85 add r3,r3,r0
86 ld r0,CFG_TB_UPDATE_COUNT(r3)
87 cmpld cr0,r0,r7 /* check if updated */
88 bne- 1b
89 blr
90 .cfi_endproc
91V_FUNCTION_END(__do_get_xsec)