summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libc/arch/sparc64/gen/Makefile.inc4
-rw-r--r--lib/libc/arch/sparc64/gen/usertc.c41
-rw-r--r--sys/arch/sparc64/include/timetc.h5
-rw-r--r--sys/arch/sparc64/sparc64/clock.c11
4 files changed, 50 insertions, 11 deletions
diff --git a/lib/libc/arch/sparc64/gen/Makefile.inc b/lib/libc/arch/sparc64/gen/Makefile.inc
index cbad435a89c..6d19faf9502 100644
--- a/lib/libc/arch/sparc64/gen/Makefile.inc
+++ b/lib/libc/arch/sparc64/gen/Makefile.inc
@@ -1,7 +1,9 @@
-# $OpenBSD: Makefile.inc,v 1.15 2020/07/06 13:33:05 pirofti Exp $
+# $OpenBSD: Makefile.inc,v 1.16 2020/07/08 09:20:28 kettenis Exp $
SRCS+= _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpclassifyl.c \
fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
fpsetround.c fpsetsticky.c infinity.c isfinitel.c \
isinfl.c isnanl.c isnormall.c ldexp.c usertc.c modf.S \
mul.S nan.c setjmp.S signbitl.c sigsetjmp.S umul.S
+
+CFLAGS += -Wa,-Av9b
diff --git a/lib/libc/arch/sparc64/gen/usertc.c b/lib/libc/arch/sparc64/gen/usertc.c
index f73831f742e..c45374aa82d 100644
--- a/lib/libc/arch/sparc64/gen/usertc.c
+++ b/lib/libc/arch/sparc64/gen/usertc.c
@@ -1,6 +1,6 @@
-/* $OpenBSD: usertc.c,v 1.1 2020/07/06 13:33:05 pirofti Exp $ */
+/* $OpenBSD: usertc.c,v 1.2 2020/07/08 09:20:28 kettenis Exp $ */
/*
- * Copyright (c) 2020 Paul Irofti <paul@irofti.net>
+ * Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,4 +18,39 @@
#include <sys/types.h>
#include <sys/timetc.h>
-int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL;
+static inline u_int
+tick_get_timecount(struct timecounter *tc)
+{
+ u_int64_t tick;
+
+ __asm volatile("rd %%tick, %0" : "=r" (tick));
+
+ return (tick & ~0u);
+}
+
+static inline u_int
+sys_tick_get_timecount(struct timecounter *tc)
+{
+ u_int64_t tick;
+
+ __asm volatile("rd %%sys_tick, %0" : "=r" (tick));
+
+ return (tick & ~0u);
+}
+
+static int
+tc_get_timecount(struct timekeep *tk, u_int *tc)
+{
+ switch (tk->tk_user) {
+ case TC_TICK:
+ *tc = tick_get_timecount(NULL);
+ return 0;
+ case TC_SYS_TICK:
+ *tc = sys_tick_get_timecount(NULL);
+ return 0;
+ }
+
+ return -1;
+}
+
+int (*const _tc_get_timecount)(struct timekeep *, u_int *) = tc_get_timecount;
diff --git a/sys/arch/sparc64/include/timetc.h b/sys/arch/sparc64/include/timetc.h
index ec63af16d18..ac680ab4729 100644
--- a/sys/arch/sparc64/include/timetc.h
+++ b/sys/arch/sparc64/include/timetc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: timetc.h,v 1.1 2020/07/06 13:33:08 pirofti Exp $ */
+/* $OpenBSD: timetc.h,v 1.2 2020/07/08 09:20:28 kettenis Exp $ */
/*
* Copyright (c) 2020 Paul Irofti <paul@irofti.net>
*
@@ -18,6 +18,7 @@
#ifndef _MACHINE_TIMETC_H_
#define _MACHINE_TIMETC_H_
-#define TC_LAST 0
+#define TC_TICK 1
+#define TC_SYS_TICK 2
#endif /* _MACHINE_TIMETC_H_ */
diff --git a/sys/arch/sparc64/sparc64/clock.c b/sys/arch/sparc64/sparc64/clock.c
index fa3ff46718c..f8c43cd87c7 100644
--- a/sys/arch/sparc64/sparc64/clock.c
+++ b/sys/arch/sparc64/sparc64/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.62 2020/07/06 13:33:08 pirofti Exp $ */
+/* $OpenBSD: clock.c,v 1.63 2020/07/08 09:20:28 kettenis Exp $ */
/* $NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp $ */
/*
@@ -109,13 +109,14 @@ struct cfdriver clock_cd = {
u_int tick_get_timecount(struct timecounter *);
struct timecounter tick_timecounter = {
- tick_get_timecount, NULL, ~0u, 0, "tick", 0, NULL, 0
+ tick_get_timecount, NULL, ~0u, 0, "tick", 0, NULL, TC_TICK
};
u_int sys_tick_get_timecount(struct timecounter *);
struct timecounter sys_tick_timecounter = {
- sys_tick_get_timecount, NULL, ~0u, 0, "sys_tick", 1000, NULL, 0
+ sys_tick_get_timecount, NULL, ~0u, 0, "sys_tick", 1000, NULL,
+ TC_SYS_TICK
};
/*
@@ -940,7 +941,7 @@ tick_get_timecount(struct timecounter *tc)
{
u_int64_t tick;
- __asm volatile("rd %%tick, %0" : "=r" (tick) :);
+ __asm volatile("rd %%tick, %0" : "=r" (tick));
return (tick & ~0u);
}
@@ -950,7 +951,7 @@ sys_tick_get_timecount(struct timecounter *tc)
{
u_int64_t tick;
- __asm volatile("rd %%sys_tick, %0" : "=r" (tick) :);
+ __asm volatile("rd %%sys_tick, %0" : "=r" (tick));
return (tick & ~0u);
}