getsecs.c revision 1.6
1/* $NetBSD: getsecs.c,v 1.6 2002/11/09 06:34:38 thorpej Exp $ */ 2 3#include <sys/param.h> 4 5#include <netinet/in.h> 6#include <netinet/in_systm.h> 7 8#include <lib/libsa/stand.h> 9#include <lib/libsa/net.h> 10 11#include "include/prom.h" 12#include "include/rpb.h" 13 14int 15getsecs(void) 16{ 17 static long tnsec; 18 static long lastpcc, wrapsecs; 19 long curpcc; 20 21 if (tnsec == 0) { 22 tnsec = 1; 23 lastpcc = alpha_rpcc() & 0xffffffff; 24 wrapsecs = (0xffffffff / 25 ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1; 26 27#if 0 28 printf("getsecs: cc freq = %d, time to wrap = %d\n", 29 ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs); 30#endif 31 } 32 33 curpcc = alpha_rpcc() & 0xffffffff; 34 if (curpcc < lastpcc) 35 curpcc += 0x100000000; 36 37 tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq; 38 lastpcc = curpcc; 39 40 return (tnsec / 1000000000); 41} 42