blob: 5a99dab30bd22d15ac888ff42681a895a4530254 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* $NetBSD: getsecs.c,v 1.11 2013/11/03 01:02:37 christos Exp $ */
#include <sys/param.h>
#include <machine/cpu.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <lib/libsa/stand.h>
#include <lib/libsa/net.h>
#include "include/prom.h"
#include "include/rpb.h"
satime_t
getsecs(void)
{
static uint64_t tnsec;
static uint64_t lastpcc;
uint64_t curpcc;
if (tnsec == 0) {
tnsec = 1;
lastpcc = alpha_rpcc() & 0xffffffff;
#if 0
uint64_t wrapsecs = (0xffffffff /
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
printf("getsecs: cc freq = %lu, time to wrap = %lu\n",
((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
#endif
}
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);
}
|