1*0d6cc87bSBrooks Davis /*-
2*0d6cc87bSBrooks Davis * Copyright (c) 2021 Jessica Clarke
3*0d6cc87bSBrooks Davis *
4*0d6cc87bSBrooks Davis * Redistribution and use in source and binary forms, with or without
5*0d6cc87bSBrooks Davis * modification, are permitted provided that the following conditions
6*0d6cc87bSBrooks Davis * are met:
7*0d6cc87bSBrooks Davis * 1. Redistributions of source code must retain the above copyright
8*0d6cc87bSBrooks Davis * notice, this list of conditions and the following disclaimer.
9*0d6cc87bSBrooks Davis * 2. Redistributions in binary form must reproduce the above copyright
10*0d6cc87bSBrooks Davis * notice, this list of conditions and the following disclaimer in the
11*0d6cc87bSBrooks Davis * documentation and/or other materials provided with the distribution.
12*0d6cc87bSBrooks Davis *
13*0d6cc87bSBrooks Davis * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14*0d6cc87bSBrooks Davis * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15*0d6cc87bSBrooks Davis * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16*0d6cc87bSBrooks Davis * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17*0d6cc87bSBrooks Davis * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18*0d6cc87bSBrooks Davis * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19*0d6cc87bSBrooks Davis * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20*0d6cc87bSBrooks Davis * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21*0d6cc87bSBrooks Davis * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22*0d6cc87bSBrooks Davis * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23*0d6cc87bSBrooks Davis * SUCH DAMAGE.
24*0d6cc87bSBrooks Davis */
25*0d6cc87bSBrooks Davis
26*0d6cc87bSBrooks Davis #include <sys/types.h>
27*0d6cc87bSBrooks Davis #include <sys/elf.h>
28*0d6cc87bSBrooks Davis #include <sys/time.h>
29*0d6cc87bSBrooks Davis #include <sys/vdso.h>
30*0d6cc87bSBrooks Davis
31*0d6cc87bSBrooks Davis #include <machine/riscvreg.h>
32*0d6cc87bSBrooks Davis
33*0d6cc87bSBrooks Davis #include <errno.h>
34*0d6cc87bSBrooks Davis
35*0d6cc87bSBrooks Davis #include "libc_private.h"
36*0d6cc87bSBrooks Davis
37*0d6cc87bSBrooks Davis #pragma weak __vdso_gettc
38*0d6cc87bSBrooks Davis int
__vdso_gettc(const struct vdso_timehands * th,u_int * tc)39*0d6cc87bSBrooks Davis __vdso_gettc(const struct vdso_timehands *th, u_int *tc)
40*0d6cc87bSBrooks Davis {
41*0d6cc87bSBrooks Davis if (th->th_algo != VDSO_TH_ALGO_RISCV_RDTIME)
42*0d6cc87bSBrooks Davis return (ENOSYS);
43*0d6cc87bSBrooks Davis
44*0d6cc87bSBrooks Davis *tc = csr_read(time);
45*0d6cc87bSBrooks Davis return (0);
46*0d6cc87bSBrooks Davis }
47*0d6cc87bSBrooks Davis
48*0d6cc87bSBrooks Davis #pragma weak __vdso_gettimekeep
49*0d6cc87bSBrooks Davis int
__vdso_gettimekeep(struct vdso_timekeep ** tk)50*0d6cc87bSBrooks Davis __vdso_gettimekeep(struct vdso_timekeep **tk)
51*0d6cc87bSBrooks Davis {
52*0d6cc87bSBrooks Davis return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
53*0d6cc87bSBrooks Davis }
54