Cross Reference: getsecs.c
xref: /src/sys/arch/alpha/stand/netboot/getsecs.c
  • Home
  • History
  • AnnotateAnnotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /src/sys/arch/alpha/stand/netboot/
11.11Schristos/*	$NetBSD: getsecs.c,v 1.11 2013/11/03 01:02:37 christos Exp $	*/
21.5Sperry
31.1Scgd#include <sys/param.h>
41.6Sthorpej
51.10She#include <machine/cpu.h>
61.6Sthorpej#include <netinet/in.h>
71.6Sthorpej#include <netinet/in_systm.h>
81.6Sthorpej
91.6Sthorpej#include <lib/libsa/stand.h>
101.6Sthorpej#include <lib/libsa/net.h>
111.6Sthorpej
121.1Scgd#include "include/prom.h"
131.1Scgd#include "include/rpb.h"
141.1Scgd
151.9Stsutsuisatime_t
161.6Sthorpejgetsecs(void)
171.1Scgd{
181.8Stsutsui	static uint64_t tnsec;
191.11Schristos	static uint64_t lastpcc;
201.8Stsutsui	uint64_t curpcc;
211.1Scgd
221.1Scgd	if (tnsec == 0) {
231.3Scgd		tnsec = 1;
241.1Scgd		lastpcc = alpha_rpcc() & 0xffffffff;
251.1Scgd
261.2Scgd#if 0
271.11Schristos		uint64_t wrapsecs = (0xffffffff /
281.11Schristos		    ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;
291.8Stsutsui		printf("getsecs: cc freq = %lu, time to wrap = %lu\n",
301.1Scgd		    ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq, wrapsecs);
311.2Scgd#endif
321.1Scgd	}
331.1Scgd
341.1Scgd	curpcc = alpha_rpcc() & 0xffffffff;
351.1Scgd	if (curpcc < lastpcc)
361.1Scgd		curpcc += 0x100000000;
371.1Scgd
381.1Scgd	tnsec += ((curpcc - lastpcc) * 1000000000) / ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
391.1Scgd	lastpcc = curpcc;
401.1Scgd
411.1Scgd	return (tnsec / 1000000000);
421.1Scgd}
43

Indexes created Mon Nov 10 17:20:41 GMT 2025