1 /* $NetBSD: getsecs.c,v 1.8 2009/01/12 11:04:00 tsutsui Exp $ */
5 #include <netinet/in.h>
6 #include <netinet/in_systm.h>
8 #include <lib/libsa/stand.h>
9 #include <lib/libsa/net.h>
11 #include "include/prom.h"
12 #include "include/rpb.h"
17 static uint64_t tnsec
;
18 static uint64_t lastpcc
, wrapsecs
;
23 lastpcc
= alpha_rpcc() & 0xffffffff;
24 wrapsecs
= (0xffffffff /
25 ((struct rpb
*)HWRPB_ADDR
)->rpb_cc_freq
) + 1;
28 printf("getsecs: cc freq = %lu, time to wrap = %lu\n",
29 ((struct rpb
*)HWRPB_ADDR
)->rpb_cc_freq
, wrapsecs
);
33 curpcc
= alpha_rpcc() & 0xffffffff;
35 curpcc
+= 0x100000000;
37 tnsec
+= ((curpcc
- lastpcc
) * 1000000000) / ((struct rpb
*)HWRPB_ADDR
)->rpb_cc_freq
;
40 return (tnsec
/ 1000000000);