diff options
author | 2020-07-17 20:15:43 +0000 | |
---|---|---|
committer | 2020-07-17 20:15:43 +0000 | |
commit | 8e8a48ab347160c3f7dbc7b04eb87983a0a1eddc (patch) | |
tree | 3aeccbaba947731b18aad93d5c20147055445279 | |
parent | "wroute" allows changes to the routing table; ok deraadt (diff) | |
download | wireguard-openbsd-8e8a48ab347160c3f7dbc7b04eb87983a0a1eddc.tar.xz wireguard-openbsd-8e8a48ab347160c3f7dbc7b04eb87983a0a1eddc.zip |
Userland timecounter for macppc
Tested by cwen@ and myself. Thanks to pirofti@ for creating the
userland timecounter feature.
ok kettenis@ pirofti@ deraadt@ cheloha@
-rw-r--r-- | lib/libc/arch/powerpc/gen/usertc.c | 24 | ||||
-rw-r--r-- | sys/arch/macppc/include/timetc.h | 4 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/clock.c | 4 |
3 files changed, 26 insertions, 6 deletions
diff --git a/lib/libc/arch/powerpc/gen/usertc.c b/lib/libc/arch/powerpc/gen/usertc.c index f73831f742e..108fff0f54f 100644 --- a/lib/libc/arch/powerpc/gen/usertc.c +++ b/lib/libc/arch/powerpc/gen/usertc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usertc.c,v 1.1 2020/07/06 13:33:05 pirofti Exp $ */ +/* $OpenBSD: usertc.c,v 1.2 2020/07/17 20:15:43 gkoehler Exp $ */ /* * Copyright (c) 2020 Paul Irofti <paul@irofti.net> * @@ -18,4 +18,24 @@ #include <sys/types.h> #include <sys/timetc.h> -int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL; +static __inline u_int32_t +ppc_mftbl (void) +{ + int ret; + __asm volatile ("mftb %0" : "=r" (ret)); + return ret; +} + +static int +tc_get_timecount(struct timekeep *tk, u_int *tc) +{ + switch (tk->tk_user) { + case TC_TB: + *tc = ppc_mftbl(); + return 0; + } + + return -1; +} + +int (*const _tc_get_timecount)(struct timekeep *, u_int *) = tc_get_timecount; diff --git a/sys/arch/macppc/include/timetc.h b/sys/arch/macppc/include/timetc.h index be5be950d4d..267f3201017 100644 --- a/sys/arch/macppc/include/timetc.h +++ b/sys/arch/macppc/include/timetc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timetc.h,v 1.1 2020/07/06 13:33:07 pirofti Exp $ */ +/* $OpenBSD: timetc.h,v 1.2 2020/07/17 20:15:43 gkoehler Exp $ */ /* * Copyright (c) 2020 Paul Irofti <paul@irofti.net> * @@ -18,6 +18,6 @@ #ifndef _MACHINE_TIMETC_H_ #define _MACHINE_TIMETC_H_ -#define TC_LAST 0 +#define TC_TB 1 #endif /* _MACHINE_TIMETC_H_ */ diff --git a/sys/arch/macppc/macppc/clock.c b/sys/arch/macppc/macppc/clock.c index a858912699b..c582edac1b9 100644 --- a/sys/arch/macppc/macppc/clock.c +++ b/sys/arch/macppc/macppc/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.45 2020/07/12 20:32:20 naddy Exp $ */ +/* $OpenBSD: clock.c,v 1.46 2020/07/17 20:15:43 gkoehler Exp $ */ /* $NetBSD: clock.c,v 1.1 1996/09/30 16:34:40 ws Exp $ */ /* @@ -57,7 +57,7 @@ u_int32_t ns_per_tick = 320; static int32_t ticks_per_intr; static struct timecounter tb_timecounter = { - tb_get_timecount, NULL, 0xffffffff, 0, "tb", 0, NULL, 0 + tb_get_timecount, NULL, 0xffffffff, 0, "tb", 0, NULL, TC_TB }; /* calibrate the timecounter frequency for the listed models */ |