Пример #1
0
int
getsecs()
{
	static long tnsec;
	static long lastpcc, wrapsecs;
	long curpcc;

	if (tnsec == 0) {
		tnsec = 1;
		lastpcc = alpha_rpcc() & 0xffffffff;
		wrapsecs = (0xffffffff /
		    ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq) + 1;

#if 0
		printf("getsecs: cc freq = %d, time to wrap = %d\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);
}
Пример #2
0
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);
}
Пример #3
0
void
delay(int usecs)
{
    struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR;
    unsigned long start = alpha_rpcc();
    unsigned long end = start + (hwrpb->rpb_cc_freq * usecs) / 1000000;
    while (alpha_rpcc() < end)
	;
}
Пример #4
0
static void
handleclock(void* arg)
{
	u_int32_t now = alpha_rpcc();
	u_int32_t delta = now - last_time;
	last_time = now;

	if (delta > max_cycles_per_tick) {
		int i, missed_ticks;
		missed_ticks = (delta * scaled_ticks_per_cycle) >> FIX_SHIFT;
		for (i = 0; i < missed_ticks; i++)
			hardclock(arg);
	}
Пример #5
0
/*
 * Start the real-time and statistics clocks. Leave stathz 0 since there
 * are no other timers available.
 */
void
cpu_initclocks()
{
	if (clockdev == NULL)
		panic("cpu_initclocks: no clock attached");

	tick = 1000000 / hz;	/* number of microseconds between interrupts */
	tickfix = 1000000 - (hz * tick);
	if (tickfix) {
		int ftp;

		ftp = min(ffs(tickfix), ffs(hz));
		tickfix >>= (ftp - 1);
		tickfixinterval = hz >> (ftp - 1);
        }

	/*
	 * Establish the clock interrupt; it's a special case.
	 *
	 * We establish the clock interrupt this late because if
	 * we do it at clock attach time, we may have never been at
	 * spl0() since taking over the system.  Some versions of
	 * PALcode save a clock interrupt, which would get delivered
	 * when we spl0() in autoconf.c.  If established the clock
	 * interrupt handler earlier, that interrupt would go to
	 * hardclock, which would then fall over because p->p_stats
	 * isn't set at that time.
	 */
	last_time = alpha_rpcc();
	scaled_ticks_per_cycle = ((u_int64_t)hz << FIX_SHIFT) / cycles_per_sec;
	max_cycles_per_tick = 2*cycles_per_sec / hz;

	alpha_timecounter.tc_frequency = cycles_per_sec;
	init_timecounter(&alpha_timecounter);

	platform.clockintr = (void (*) __P((void *))) handleclock;

	/*
	 * Get the clock started.
	 */
	CLOCK_INIT(clockdev);
}