diff options
Diffstat (limited to 'sys/boot/alpha/libalpha/getsecs.c')
-rw-r--r-- | sys/boot/alpha/libalpha/getsecs.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sys/boot/alpha/libalpha/getsecs.c b/sys/boot/alpha/libalpha/getsecs.c new file mode 100644 index 0000000..13f1e53 --- /dev/null +++ b/sys/boot/alpha/libalpha/getsecs.c @@ -0,0 +1,37 @@ +/* + * $FreeBSD$ + * From: $NetBSD: getsecs.c,v 1.5 1998/01/05 07:02:49 perry Exp $ + */ + +#include <sys/param.h> +#include <machine/prom.h> +#include <machine/rpb.h> + +int +getsecs() +{ + static long tnsec; + static long lastpcc, wrapsecs; + long curpcc; + + if (tnsec == 0) { + tnsec = 1; + lastpcc = alpha_rpcc() & 0xffffffff; + wrapsecs = (0xffffffff / + ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1; + +#if 0 + printf("getsecs: cc freq = %d, time to wrap = %d\n", + ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs); +#endif + } + + curpcc = alpha_rpcc() & 0xffffffff; + if (curpcc < lastpcc) + curpcc += 0x100000000; + + tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq; + lastpcc = curpcc; + + return (tnsec / 1000000000); +} |