コード例 #1
0
ファイル: ixp425_timer.c プロジェクト: MarginC/kame
/*
 * resettodr:
 *
 *	Reset the time-of-day register with the current time.
 */
void
resettodr(void)
{

	if (time.tv_sec == 0)
		return;

	if (todr_handle != NULL &&
	    todr_settime(todr_handle, (struct timeval *)&time) != 0)
		printf("resettodr: failed to set time\n");
}
コード例 #2
0
ファイル: intr.c プロジェクト: bradla/OpenBSD-Hammer2
/*
 * resettodr:
 *
 *      Reset the time-of-day register with the current time.
 */
void
resettodr(void)
{
	struct timeval rtctime;

	if (rtctime.tv_sec == 0)
		return;

	microtime(&rtctime);

	if (todr_handle != NULL &&
	   todr_settime(todr_handle, &rtctime) != 0)
		printf("resettodr: failed to set time\n");
}
コード例 #3
0
ファイル: mkclock_isa.c プロジェクト: MarginC/kame
void
mkclock_isa_set(struct device *self, struct clocktime *ct)
{
	struct mkclock_isa_softc *sc = (struct mkclock_isa_softc *)self;
	struct clock_ymdhms dt;
	struct timeval tv;

	dt.dt_year = ct->year + 1900;
	if (dt.dt_year < 1970)
		dt.dt_year += 100;
	dt.dt_mon  = ct->mon;
	dt.dt_day  = ct->day;
	dt.dt_wday = ct->dow;
	dt.dt_hour = ct->hour;
	dt.dt_min  = ct->min;
	dt.dt_sec  = ct->sec;
	
	tv.tv_sec = clock_ymdhms_to_secs(&dt);
	tv.tv_usec = 0;

	todr_settime(sc->sc_todr, &tv);
}
コード例 #4
0
/*
 * Reset the TODR based on the time value; used when the TODR
 * has a preposterous value and also when the time is reset
 * by the stime system call.  Also called when the TODR goes past
 * TODRZERO + 100*(SECS_PER_COMMON_YEAR+2*SECS_PER_DAY)
 * (e.g. on Jan 2 just after midnight) to wrap the TODR around.
 */
void
resettodr(void)
{
	struct timeval tv;

	/*
	 * We might have been called by boot() due to a crash early
	 * on.  Don't reset the clock chip if we don't know what time
	 * it is.
	 */
	if (!timeset)
		return;

	getmicrotime(&tv);

	if (tv.tv_sec == 0)
		return;

	if (todr_handle)
		if (todr_settime(todr_handle, &tv) != 0)
			printf("Cannot set TOD clock time\n");
}