Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / boot / alpha / libalpha / getsecs.c
1 /*
2  * $FreeBSD: src/sys/boot/alpha/libalpha/getsecs.c,v 1.2 1999/08/28 00:39:27 peter Exp $
3  * $DragonFly: src/sys/boot/alpha/libalpha/Attic/getsecs.c,v 1.2 2003/06/17 04:28:16 dillon Exp $
4  * From:        $NetBSD: getsecs.c,v 1.5 1998/01/05 07:02:49 perry Exp $        
5  */
6
7 #include <sys/param.h>
8 #include <machine/prom.h>
9 #include <machine/rpb.h>
10
11 int
12 getsecs()
13 {
14         static long tnsec;
15         static long lastpcc, wrapsecs;
16         long curpcc;
17
18         if (tnsec == 0) {
19                 tnsec = 1;
20                 lastpcc = alpha_rpcc() & 0xffffffff;
21                 wrapsecs = (0xffffffff /
22                     ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
23
24 #if 0
25                 printf("getsecs: cc freq = %d, time to wrap = %d\n",
26                     ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
27 #endif
28         }
29
30         curpcc = alpha_rpcc() & 0xffffffff;
31         if (curpcc < lastpcc)
32                 curpcc += 0x100000000;
33
34         tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
35         lastpcc = curpcc;
36
37         return (tnsec / 1000000000);
38 }