File Index
Files and directories
Sign in
FILE

gettimeofday.S

File preview with syntax highlighting.

linux-6.19.14/arch/powerpc/kernel/vdso/gettimeofday.S GAS
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 * Userland implementation of gettimeofday() for processes
  4 * 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
 16/*
 17 * The macro sets two stack frames, one for the caller and one for the callee
 18 * because there are no requirement for the caller to set a stack frame when
 19 * calling VDSO so it may have omitted to set one, especially on PPC64
 20 */
 21
 22.macro cvdso_call funct call_time=0
 23  .cfi_startproc
 24	PPC_STLU	r1, -PPC_MIN_STKFRM(r1)
 25  .cfi_adjust_cfa_offset PPC_MIN_STKFRM
 26	mflr		r0
 27	PPC_STLU	r1, -PPC_MIN_STKFRM(r1)
 28  .cfi_adjust_cfa_offset PPC_MIN_STKFRM
 29	PPC_STL		r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
 30  .cfi_rel_offset lr, PPC_MIN_STKFRM + PPC_LR_STKOFF
 31#ifdef __powerpc64__
 32	PPC_STL		r2, PPC_MIN_STKFRM + STK_GOT(r1)
 33  .cfi_rel_offset r2, PPC_MIN_STKFRM + STK_GOT
 34#endif
 35	.ifeq	\call_time
 36		get_datapage	r5 vdso_u_time_data
 37	.else
 38		get_datapage	r4 vdso_u_time_data
 39	.endif
 40	bl		CFUNC(DOTSYM(\funct))
 41	PPC_LL		r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
 42#ifdef __powerpc64__
 43	PPC_LL		r2, PPC_MIN_STKFRM + STK_GOT(r1)
 44  .cfi_restore r2
 45#endif
 46	.ifeq	\call_time
 47	cmpwi		r3, 0
 48	.endif
 49	mtlr		r0
 50	addi		r1, r1, 2 * PPC_MIN_STKFRM
 51  .cfi_restore lr
 52  .cfi_def_cfa_offset 0
 53	crclr		so
 54	.ifeq	\call_time
 55	beqlr+
 56	crset		so
 57	neg		r3, r3
 58	.endif
 59	blr
 60  .cfi_endproc
 61.endm
 62
 63	.text
 64/*
 65 * Exact prototype of gettimeofday
 66 *
 67 * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz);
 68 *
 69 */
 70V_FUNCTION_BEGIN(__kernel_gettimeofday)
 71	cvdso_call __c_kernel_gettimeofday
 72V_FUNCTION_END(__kernel_gettimeofday)
 73
 74/*
 75 * Exact prototype of clock_gettime()
 76 *
 77 * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp);
 78 *
 79 */
 80V_FUNCTION_BEGIN(__kernel_clock_gettime)
 81	cvdso_call __c_kernel_clock_gettime
 82V_FUNCTION_END(__kernel_clock_gettime)
 83
 84/*
 85 * Exact prototype of clock_gettime64()
 86 *
 87 * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
 88 *
 89 */
 90#ifndef __powerpc64__
 91V_FUNCTION_BEGIN(__kernel_clock_gettime64)
 92	cvdso_call __c_kernel_clock_gettime64
 93V_FUNCTION_END(__kernel_clock_gettime64)
 94#endif
 95
 96/*
 97 * Exact prototype of clock_getres()
 98 *
 99 * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res);
100 *
101 */
102V_FUNCTION_BEGIN(__kernel_clock_getres)
103	cvdso_call __c_kernel_clock_getres
104V_FUNCTION_END(__kernel_clock_getres)
105
106
107/*
108 * Exact prototype of time()
109 *
110 * time_t time(time *t);
111 *
112 */
113V_FUNCTION_BEGIN(__kernel_time)
114	cvdso_call __c_kernel_time call_time=1
115V_FUNCTION_END(__kernel_time)
~/ Read-only file preview.