Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / alpha / stand / netboot / getsecs.c
blobc40d053813a755356786bc1849c2fb874ebdb9a1
1 /* $NetBSD: getsecs.c,v 1.8 2009/01/12 11:04:00 tsutsui Exp $ */
3 #include <sys/param.h>
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"
14 satime_t
15 getsecs(void)
17 static uint64_t tnsec;
18 static uint64_t lastpcc, wrapsecs;
19 uint64_t curpcc;
21 if (tnsec == 0) {
22 tnsec = 1;
23 lastpcc = alpha_rpcc() & 0xffffffff;
24 wrapsecs = (0xffffffff /
25 ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
27 #if 0
28 printf("getsecs: cc freq = %lu, time to wrap = %lu\n",
29 ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
30 #endif
33 curpcc = alpha_rpcc() & 0xffffffff;
34 if (curpcc < lastpcc)
35 curpcc += 0x100000000;
37 tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
38 lastpcc = curpcc;
40 return (tnsec / 1000000000);