1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Userland implementation of gettimeofday() for 32 bits processes in a
4 * ppc64 kernel for use in the vDSO
5 *
6 * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org,
7 *                    IBM Corp.
8 */
9#include <asm/processor.h>
10#include <asm/ppc_asm.h>
11#include <asm/vdso.h>
12#include <asm/vdso_datapage.h>
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
15#include <asm/vdso/gettimeofday.h>
16
17	.text
18/*
19 * Exact prototype of gettimeofday
20 *
21 * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz);
22 *
23 */
24V_FUNCTION_BEGIN(__kernel_gettimeofday)
25	cvdso_call __c_kernel_gettimeofday
26V_FUNCTION_END(__kernel_gettimeofday)
27
28/*
29 * Exact prototype of clock_gettime()
30 *
31 * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp);
32 *
33 */
34V_FUNCTION_BEGIN(__kernel_clock_gettime)
35	cvdso_call __c_kernel_clock_gettime
36V_FUNCTION_END(__kernel_clock_gettime)
37
38/*
39 * Exact prototype of clock_gettime64()
40 *
41 * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
42 *
43 */
44V_FUNCTION_BEGIN(__kernel_clock_gettime64)
45	cvdso_call __c_kernel_clock_gettime64
46V_FUNCTION_END(__kernel_clock_gettime64)
47
48/*
49 * Exact prototype of clock_getres()
50 *
51 * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res);
52 *
53 */
54V_FUNCTION_BEGIN(__kernel_clock_getres)
55	cvdso_call __c_kernel_clock_getres
56V_FUNCTION_END(__kernel_clock_getres)
57
58
59/*
60 * Exact prototype of time()
61 *
62 * time_t time(time *t);
63 *
64 */
65V_FUNCTION_BEGIN(__kernel_time)
66	cvdso_call_time __c_kernel_time
67V_FUNCTION_END(__kernel_time)
68
69/* Routines for restoring integer registers, called by the compiler.  */
70/* Called with r11 pointing to the stack header word of the caller of the */
71/* function, just beyond the end of the integer restore area.  */
72_GLOBAL(_restgpr_31_x)
73_GLOBAL(_rest32gpr_31_x)
74	lwz	r0,4(r11)
75	lwz	r31,-4(r11)
76	mtlr	r0
77	mr	r1,r11
78	blr
79