Esempio n. 1
0
void
rtcput(mc_todregs *regs)
{
	struct rtc_softc *sc = rtc_sc;

	rtcinit();
	MC146818_PUTTOD(sc, regs);
}
Esempio n. 2
0
/*
 * Reset the TODR based on the time value.
 */
int
mcclock_set(todr_chip_handle_t tch, struct timeval *tvp)
{
	struct mcclock_softc *sc = tch->cookie;
	struct clock_ymdhms dt;
	uint32_t yearsecs;
	mc_todregs regs;
	int s;

	/*
	 * calculate seconds relative to this year
	 */
	clock_secs_to_ymdhms(tvp->tv_sec, &dt); /* get the year */
	dt.dt_mon = 1;
	dt.dt_day = 1;
	dt.dt_hour = 0;
	dt.dt_min = 0;
	dt.dt_sec = 0;
	yearsecs = tvp->tv_sec - clock_ymdhms_to_secs(&dt);

#define first72 ((72 - 70) * SECYR)
	clock_secs_to_ymdhms(first72 + yearsecs, &dt);

#ifdef DEBUG
	if (dt.dt_year != 1972)
		printf("resettodr: botch (%d, %" PRId64 ")\n",
		    yearsecs, time_second);
#endif

	s = splclock();
	MC146818_GETTOD(sc, &regs);
	splx(s);

	regs[MC_SEC] = dt.dt_sec;
	regs[MC_MIN] = dt.dt_min;
	regs[MC_HOUR] = dt.dt_hour;
	regs[MC_DOW] = dt.dt_wday;
	regs[MC_DOM] = dt.dt_day;
	regs[MC_MONTH] = dt.dt_mon;
	regs[MC_YEAR] = dt.dt_year - 1900;	/* rt clock wants 2 digits */

	s = splclock();
	MC146818_PUTTOD(sc, &regs);
	splx(s);

	return 0;
}
Esempio n. 3
0
/*
 * Reset the TODR based on the time value.
 */
void
mcclock_set(device_t dev, struct clocktime *ct)
{
	mc_todregs regs;
	int s;

	s = splclock();
	MC146818_GETTOD(dev, &regs);
	splx(s);

	regs[MC_SEC] = ct->sec;
	regs[MC_MIN] = ct->min;
	regs[MC_HOUR] = ct->hour;
	regs[MC_DOW] = ct->dow;
	regs[MC_DOM] = ct->day;
	regs[MC_MONTH] = ct->mon;
	regs[MC_YEAR] = ct->year;

	s = splclock();
	MC146818_PUTTOD(dev, &regs);
	splx(s);
}
Esempio n. 4
0
/*
 * Reset the TODR based on the time value.
 */
void
mcclock_set(struct device *dev, struct clocktime *ct)
{
    struct mcclock_softc *sc = (struct mcclock_softc *)dev;
    mc_todregs regs;
    int s;

    s = splclock();
    MC146818_GETTOD(sc, &regs);
    splx(s);

    regs[MC_SEC] = ct->sec;
    regs[MC_MIN] = ct->min;
    regs[MC_HOUR] = ct->hour;
    regs[MC_DOW] = ct->dow;
    regs[MC_DOM] = ct->day;
    regs[MC_MONTH] = ct->mon;
    regs[MC_YEAR] = ct->year + ALGOR_YEAR_OFFSET;

    s = splclock();
    MC146818_PUTTOD(sc, &regs);
    splx(s);
}