Now that all platforms use genclock, shuffle things around slightly

for better structure.

Much of this is related to <sys/clock.h>, which should really have
been called <sys/calendar.h>, but unless and until we need the name,
the repocopy can wait.

In general the kernel does not know about minutes, hours, days,
timezones, daylight savings time, leap-years and such.  All that
is theoretically a matter for userland only.

Parts of kernel code does however care: badly designed filesystems
store timestamps in local time and RTC chips almost universally
track time in a YY-MM-DD HH:MM:SS format, and sometimes in local
timezone instead of UTC.  For this we have <sys/clock.h>

<sys/time.h> on the other hand, deals with time_t, timeval, timespec
and so on.  These know only seconds and fractions thereof.

Move inittodr() and resettodr() prototypes to <sys/time.h>.
Retain the names as it is one of the few surviving PDP/VAX references.

Move startrtclock() to <machine/clock.h> on relevant platforms, it
is a MD call between machdep.c/clock.c.  Remove references to it
elsewhere.

Remove a lot of unnecessary <sys/clock.h> includes.

Move the machdep.disable_rtc_set sysctl to subr_rtc.c where it belongs.
XXX: should be kern.disable_rtc_set really, it's not MD.
This commit is contained in:
Poul-Henning Kamp 2008-04-22 19:38:30 +00:00
parent dbef86ad30
commit 9b4a8ab7ba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178429
22 changed files with 31 additions and 33 deletions

View File

@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <sys/buf.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/clock.h>
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/eventhandler.h>

View File

@ -27,6 +27,7 @@ void i8254_init(void);
* Driver to clock driver interface.
*/
void startrtclock(void);
void init_TSC(void);
void init_TSC_tc(void);

View File

@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/kdb.h>
#include <sys/mutex.h>

View File

@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/module.h>
#include <machine/bus.h>

View File

@ -22,7 +22,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/conf.h>
#include <sys/condvar.h>
#include <sys/eventhandler.h>

View File

@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <sys/buf.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/clock.h>
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/eventhandler.h>

View File

@ -27,6 +27,7 @@ void i8254_init(void);
* Driver to clock driver interface.
*/
void startrtclock(void);
void timer_restore(void);
void init_TSC(void);
void init_TSC_tc(void);

View File

@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/kdb.h>
#include <sys/mutex.h>

View File

@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/syslog.h>

View File

@ -29,12 +29,10 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/clock.h>
#include <sys/queue.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/timetc.h>
#include <sys/pcpu.h>

View File

@ -261,7 +261,6 @@ cpu_startup(dummy)
*/
identifycpu();
/* startrtclock(); */
#ifdef PERFMON
perfmon_init();
#endif

View File

@ -52,18 +52,14 @@ __FBSDID("$FreeBSD$");
#define ct_debug bootverbose
static int adjkerntz; /* local offset from GMT in seconds */
static int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
int disable_rtc_set; /* disable resettodr() if != 0 */
int tz_minuteswest;
int tz_dsttime;
/*
* These have traditionally been in machdep, but should probably be moved to
* This have traditionally been in machdep, but should probably be moved to
* kern.
*/
SYSCTL_INT(_machdep, OID_AUTO, disable_rtc_set,
CTLFLAG_RW, &disable_rtc_set, 0, "");
SYSCTL_INT(_machdep, OID_AUTO, wall_cmos_clock,
CTLFLAG_RW, &wall_cmos_clock, 0, "");
@ -71,8 +67,7 @@ static int
sysctl_machdep_adjkerntz(SYSCTL_HANDLER_ARGS)
{
int error;
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
req);
error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req);
if (!error && req->newptr)
resettodr();
return (error);

View File

@ -63,6 +63,11 @@ __FBSDID("$FreeBSD$");
static device_t clock_dev = NULL;
static long clock_res;
/* XXX: should be kern. now, it's no longer machdep. */
static int disable_rtc_set;
SYSCTL_INT(_machdep, OID_AUTO, disable_rtc_set,
CTLFLAG_RW, &disable_rtc_set, 0, "");
void
clock_register(device_t dev, long res) /* res has units of microseconds */
{
@ -118,6 +123,7 @@ inittodr(time_t base)
"will not be set accurately\n");
return;
}
/* XXX: We should poll all registered RTCs in case of failure */
error = CLOCK_GETTIME(clock_dev, &ts);
if (error != 0 && error != EINVAL) {
printf("warning: clock_gettime failed (%d), the system time "
@ -158,6 +164,7 @@ resettodr()
getnanotime(&ts);
ts.tv_sec -= utc_offset();
/* XXX: We should really set all registered RTCs */
if ((error = CLOCK_SETTIME(clock_dev, &ts)) != 0) {
printf("warning: clock_settime failed (%d), time-of-day clock "
"not adjusted to system time\n", error);

View File

@ -39,7 +39,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/clock.h>
#include <sys/fcntl.h>
#include <sys/jail.h>
#include <sys/kernel.h>

View File

@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/lock.h>
#include <sys/kdb.h>
#include <sys/mutex.h>

View File

@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
#include <sys/buf.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/clock.h>
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/eventhandler.h>

View File

@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/timetc.h>
#include <sys/interrupt.h>

View File

@ -196,7 +196,6 @@ cpu_startup(void *dummy)
*/
cpu_setup(PCPU_GET(cpuid));
/* startrtclock(); */
#ifdef PERFMON
perfmon_init();
#endif

View File

@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/timetc.h>
#include <sys/interrupt.h>

View File

@ -35,6 +35,19 @@
*
* $NetBSD: clock_subr.h,v 1.7 2000/10/03 13:41:07 tsutsui Exp $
*
*
* This file is the central clearing-house for calendrical issues.
*
* In general the kernel does not know about minutes, hours, days, timezones,
* daylight savings time, leap-years and such. All that is theoretically a
* matter for userland only.
*
* Parts of kernel code does however care: badly designed filesystems store
* timestamps in local time and RTC chips sometimes track time in a local
* timezone instead of UTC and so on.
*
* All that code should go here for service.
*
* $FreeBSD$
*/
@ -43,15 +56,6 @@
#ifdef _KERNEL /* No user serviceable parts */
/*
* Kernel to clock driver interface.
*/
void inittodr(time_t base);
void resettodr(void);
void startrtclock(void);
extern int disable_rtc_set;
/*
* Timezone info from settimeofday(2), usually not used
*/

View File

@ -255,6 +255,13 @@ struct clockinfo {
#endif
#ifdef _KERNEL
/*
* Kernel to clock driver interface.
*/
void inittodr(time_t base);
void resettodr(void);
extern time_t time_second;
extern time_t time_uptime;
extern struct timeval boottime;