NetBSD/sys/arch/alpha/stand/netboot/getsecs.c

35 lines
728 B
C
Raw Normal View History

1998-01-05 10:02:46 +03:00
/* $NetBSD: getsecs.c,v 1.5 1998/01/05 07:02:49 perry Exp $ */
#include <sys/param.h>
#include "include/prom.h"
#include "include/rpb.h"
int
getsecs()
{
static long tnsec;
static long lastpcc, wrapsecs;
1997-09-06 18:08:27 +04:00
long curpcc;
if (tnsec == 0) {
1996-10-03 01:18:45 +04:00
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);
}