1996-09-19 00:03:04 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include "include/prom.h"
|
|
|
|
#include "include/rpb.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
getsecs()
|
|
|
|
{
|
|
|
|
static long tnsec;
|
|
|
|
static long lastpcc, wrapsecs;
|
|
|
|
long curpcc, pccdiff;
|
|
|
|
|
|
|
|
if (tnsec == 0) {
|
|
|
|
tnsec = 1;
|
|
|
|
lastpcc = alpha_rpcc() & 0xffffffff;
|
|
|
|
wrapsecs = (0xffffffff /
|
|
|
|
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
|
|
|
|
|
1996-09-23 08:30:56 +04:00
|
|
|
#if 0
|
1996-09-19 00:03:04 +04:00
|
|
|
printf("getsecs: cc freq = %d, time to wrap = %d\n",
|
|
|
|
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
|
1996-09-23 08:30:56 +04:00
|
|
|
#endif
|
1996-09-19 00:03:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|