Beispiel #1
0
/*
 * Wait approximately `n' microseconds.
 */
void
xen_delay(int n)
{
	u_int64_t when;

	get_time_values_from_xen();
	when = shadow_system_time + n * 1000;
	while (shadow_system_time < when)
		get_time_values_from_xen();
}
Beispiel #2
0
void
xen_initclocks()
{

	get_time_values_from_xen();
	processed_system_time = shadow_system_time;
	
	event_set_handler(_EVENT_TIMER, (int (*)(void *))xen_timer_handler,
	    NULL, IPL_CLOCK);
	hypervisor_enable_event(_EVENT_TIMER);
}
Beispiel #3
0
void time_init(void)		// UTC
{
	get_time_values_from_xen();

	uint32_t version;
	uint32_t wc_sec;
	uint32_t wc_nsec;
	do {
		version = shared_info.wc_version;
		rmb();
		wc_sec = shared_info.wc_sec;
		wc_nsec = shared_info.wc_nsec;
		rmb();
	} while ((version & 1) | (version ^ shared_info.wc_version));

	wall_clock_base = (uint64_t)wc_sec * 1000000000ULL +wc_nsec;
	start_of_day_wall_clock = wall_clock();
}
Beispiel #4
0
static int
xen_timer_handler(void *arg, struct trapframe *regs)
{
	int64_t delta;

#if defined(I586_CPU) || defined(I686_CPU)
	static int microset_iter; /* call cc_microset once/sec */
	struct cpu_info *ci = curcpu();
	
	/*
	 * If we have a cycle counter, do the microset thing.
	 */
	if (ci->ci_feature_flags & CPUID_TSC) {
		if (
#if defined(MULTIPROCESSOR)
		    CPU_IS_PRIMARY(ci) &&
#endif
		    (microset_iter--) == 0) {
			microset_iter = hz - 1;
#if defined(MULTIPROCESSOR)
			x86_broadcast_ipi(X86_IPI_MICROSET);
#endif
			cc_microset_time = time;
			cc_microset(ci);
		}
	}
#endif

	get_time_values_from_xen();

	delta = (int64_t)(shadow_system_time + get_tsc_offset_ns() -
			  processed_system_time);
	while (delta >= NS_PER_TICK) {
		hardclock((struct clockframe *)regs);
		delta -= NS_PER_TICK;
		processed_system_time += NS_PER_TICK;
	}

	return 0;
}
Beispiel #5
0
void
inittodr(time_t base)
{
	int s;

	/*
	 * if the file system time is more than a year older than the
	 * kernel, warn and then set the base time to the CONFIG_TIME.
	 */
	if (base && base < (CONFIG_TIME-SECYR)) {
		printf("WARNING: preposterous time in file system\n");
		base = CONFIG_TIME;
	}

	s = splclock();
	get_time_values_from_xen();
	splx(s);

	time.tv_usec = shadow_tv.tv_usec;
	time.tv_sec = shadow_tv.tv_sec + rtc_offset * 60;
#ifdef DEBUG_CLOCK
	printf("readclock: %ld (%ld)\n", time.tv_sec, base);
#endif
	if (base != 0 && base < time.tv_sec - 5*SECYR)
		printf("WARNING: file system time much less than clock time\n");
	else if (base > time.tv_sec + 5*SECYR) {
		printf("WARNING: clock time much less than file system time\n");
		printf("WARNING: using file system time\n");
		goto fstime;
	}

	timeset = 1;
	return;

fstime:
	timeset = 1;
	time.tv_sec = base;
	printf("WARNING: CHECK AND RESET THE DATE!\n");
}
Beispiel #6
0
uint64_t monotonic_clock(void)
{
	if (shared_info.vcpu_info[0].time.version != shadow.version)
		get_time_values_from_xen();
	return shadow.system_time + get_nsec_offset();
}