From f645b0b51cd22b129405c2c32dba1d051ae3d99c Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 2 Oct 2006 12:59:59 +0000 Subject: [PATCH] First part of a little cleanup in the calendar/timezone/RTC handling. Move relevant variables to and fix #includes as necessary. Use libkern's much more time- & spamce-efficient BCD routines. --- sys/amd64/amd64/machdep.c | 1 + sys/amd64/include/clock.h | 3 --- sys/amd64/isa/clock.c | 1 + sys/amd64/linux32/linux32_machdep.c | 1 + sys/arm/include/clock.h | 3 --- sys/compat/freebsd32/freebsd32_misc.c | 1 + sys/dev/twa/tw_osl_includes.h | 2 +- sys/dev/twa/tw_osl_share.h | 2 +- sys/fs/msdosfs/msdosfs_conv.c | 2 +- sys/fs/nwfs/nwfs_subr.c | 1 + sys/i386/bios/apm.c | 1 + sys/i386/i386/machdep.c | 1 + sys/i386/ibcs2/ibcs2_xenix.c | 1 + sys/i386/include/clock.h | 3 --- sys/i386/isa/clock.c | 1 + sys/i386/isa/pmtimer.c | 1 + sys/ia64/ia64/clock.c | 1 + sys/ia64/include/clock.h | 4 ---- sys/isa/atrtc.c | 1 + sys/kern/kern_time.c | 1 + sys/kern/vfs_mount.c | 1 + sys/nfsclient/nfs_vfsops.c | 1 + sys/pc98/cbus/clock.c | 1 + sys/pc98/cbus/pcrtc.c | 1 + sys/pc98/pc98/machdep.c | 1 + sys/powerpc/include/clock.h | 4 ---- sys/sparc64/include/clock.h | 3 --- sys/sys/clock.h | 24 ++++++++++++++++++++++-- sys/sys/kernel.h | 3 --- sys/sys/systm.h | 7 ------- 30 files changed, 43 insertions(+), 35 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 544b9fb4b55..13161868cc1 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index f091b17d8e2..36d0bebe00c 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -14,9 +14,7 @@ * i386 to clock driver interface. * XXX large parts of the driver and its interface are misplaced. */ -extern int adjkerntz; extern int clkintr_pending; -extern int disable_rtc_set; extern int pscnt; extern int psdiv; extern int statclock_disable; @@ -24,7 +22,6 @@ extern u_int timer_freq; extern int timer0_max_count; extern uint64_t tsc_freq; extern int tsc_is_broken; -extern int wall_cmos_clock; extern struct mtx clock_lock; /* diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 28116dc0842..81082819f79 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c index a5536028631..42f413dcbc9 100644 --- a/sys/amd64/linux32/linux32_machdep.c +++ b/sys/amd64/linux32/linux32_machdep.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/arm/include/clock.h b/sys/arm/include/clock.h index 9d90ff7e062..61922f4daa9 100644 --- a/sys/arm/include/clock.h +++ b/sys/arm/include/clock.h @@ -29,7 +29,4 @@ #ifndef _MACHINE_CLOCK_H_ #define _MACHINE_CLOCK_H_ -#define wall_cmos_clock 0 -#define adjkerntz 0 - #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 2c5668782ab..461e8c0c4eb 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/dev/twa/tw_osl_includes.h b/sys/dev/twa/tw_osl_includes.h index 48455e1776b..c2c77b789f7 100644 --- a/sys/dev/twa/tw_osl_includes.h +++ b/sys/dev/twa/tw_osl_includes.h @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -60,7 +61,6 @@ #include #include -#include #include #include diff --git a/sys/dev/twa/tw_osl_share.h b/sys/dev/twa/tw_osl_share.h index 49c6e77d383..f17d49d9679 100644 --- a/sys/dev/twa/tw_osl_share.h +++ b/sys/dev/twa/tw_osl_share.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,6 @@ #include #include -#include #include #include diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c index 9fc666d1ad8..21836f29429 100644 --- a/sys/fs/msdosfs/msdosfs_conv.c +++ b/sys/fs/msdosfs/msdosfs_conv.c @@ -52,7 +52,7 @@ * System include files. */ #include -#include +#include #include /* defines tz */ #include #include diff --git a/sys/fs/nwfs/nwfs_subr.c b/sys/fs/nwfs/nwfs_subr.c index e983b13aa58..eabcc5f01b7 100644 --- a/sys/fs/nwfs/nwfs_subr.c +++ b/sys/fs/nwfs/nwfs_subr.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index 4e3dba31947..f23099fbc80 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -22,6 +22,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index ee7ed43db28..d877f4b17a4 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/ibcs2/ibcs2_xenix.c b/sys/i386/ibcs2/ibcs2_xenix.c index 94a4eaed0dd..8ff59972142 100644 --- a/sys/i386/ibcs2/ibcs2_xenix.c +++ b/sys/i386/ibcs2/ibcs2_xenix.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index 9550fab49b8..74679b9210c 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -14,9 +14,7 @@ * i386 to clock driver interface. * XXX large parts of the driver and its interface are misplaced. */ -extern int adjkerntz; extern int clkintr_pending; -extern int disable_rtc_set; extern int pscnt; extern int psdiv; extern int statclock_disable; @@ -24,7 +22,6 @@ extern u_int timer_freq; extern int timer0_max_count; extern uint64_t tsc_freq; extern int tsc_is_broken; -extern int wall_cmos_clock; extern struct mtx clock_lock; /* diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 652cc0144cd..9a80d8385ab 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/isa/pmtimer.c b/sys/i386/isa/pmtimer.c index 1eeac6ddf46..87eda2d4b0a 100644 --- a/sys/i386/isa/pmtimer.c +++ b/sys/i386/isa/pmtimer.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/ia64/ia64/clock.c b/sys/ia64/ia64/clock.c index 24b7917d36d..c7e5ccf4091 100644 --- a/sys/ia64/ia64/clock.c +++ b/sys/ia64/ia64/clock.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/sys/ia64/include/clock.h b/sys/ia64/include/clock.h index b0581583063..31a8ed2f8fc 100644 --- a/sys/ia64/include/clock.h +++ b/sys/ia64/include/clock.h @@ -13,10 +13,6 @@ #define CLOCK_VECTOR 254 -extern int adjkerntz; -extern int disable_rtc_set; -extern int wall_cmos_clock; - extern uint64_t ia64_clock_reload; extern uint64_t itc_frequency; diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 652cc0144cd..9a80d8385ab 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index 0569c4b980f..f6cd8ec0852 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 592daf3aabb..c89a5fa35fb 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 69476bcac52..ee4c977c62a 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c index 1bc70b09887..2e2fc2ed93f 100644 --- a/sys/pc98/cbus/clock.c +++ b/sys/pc98/cbus/clock.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c index 1bc70b09887..2e2fc2ed93f 100644 --- a/sys/pc98/cbus/pcrtc.c +++ b/sys/pc98/cbus/pcrtc.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 089d3a732a5..6c1adda7dc9 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/powerpc/include/clock.h b/sys/powerpc/include/clock.h index 820a0d7d4ee..ead37ac149a 100644 --- a/sys/powerpc/include/clock.h +++ b/sys/powerpc/include/clock.h @@ -11,10 +11,6 @@ #ifdef _KERNEL -extern int disable_rtc_set; -extern int wall_cmos_clock; -extern int adjkerntz; - struct trapframe; int sysbeep(int pitch, int period); diff --git a/sys/sparc64/include/clock.h b/sys/sparc64/include/clock.h index fbedfea57de..c98b024437e 100644 --- a/sys/sparc64/include/clock.h +++ b/sys/sparc64/include/clock.h @@ -33,9 +33,6 @@ extern u_long tick_increment; extern u_long tick_freq; extern u_long tick_MHz; -extern int adjkerntz; -extern int wall_cmos_clock; - int sysbeep(int, int); #endif /* !_MACHINE_CLOCK_H_ */ diff --git a/sys/sys/clock.h b/sys/sys/clock.h index 1b61b1948c0..be0de57ba62 100644 --- a/sys/sys/clock.h +++ b/sys/sys/clock.h @@ -41,6 +41,24 @@ #ifndef _SYS_CLOCK_H_ #define _SYS_CLOCK_H_ +#ifdef _KERNEL /* No user serviceable parts */ + +/* + * Kernel to clock driver interface. + */ +void inittodr(time_t base); +void resettodr(void); +void startrtclock(void); +extern int wall_cmos_clock; +extern int adjkerntz; +extern int disable_rtc_set; + +/* + * Timezone info from settimeofday(2), usually not used + */ +extern int tz_minuteswest; +extern int tz_dsttime; + /* * Structure to hold the values typically reported by time-of-day clocks. * This can be passed to the generic conversion functions to be converted @@ -64,8 +82,8 @@ void clock_register(device_t, long); /* * BCD to decimal and decimal to BCD. */ -#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) -#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) +#define FROMBCD(x) bcd2bin(x) +#define TOBCD(x) bin2bcd(x) /* Some handy constants. */ #define SECDAY (24 * 60 * 60) @@ -74,4 +92,6 @@ void clock_register(device_t, long); /* Traditional POSIX base year */ #define POSIX_BASE_YEAR 1970 +#endif /* _KERNEL */ + #endif /* !_SYS_CLOCK_H_ */ diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index cc36ede1107..1bee3fa8525 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -69,9 +69,6 @@ extern int profprocs; /* number of process's profiling */ extern int ticks; extern int lbolt; /* once a second sleep address */ -extern int tz_minuteswest; -extern int tz_dsttime; - #endif /* _KERNEL */ /* diff --git a/sys/sys/systm.h b/sys/sys/systm.h index bc2c65d7c5b..150df1758f9 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -266,13 +266,6 @@ void usrinfoinit(void); /* Finalize the world. */ void shutdown_nice(int); -/* - * Kernel to clock driver interface. - */ -void inittodr(time_t base); -void resettodr(void); -void startrtclock(void); - /* Timeouts */ typedef void timeout_t(void *); /* timeout function type */ #define CALLOUT_HANDLE_INITIALIZER(handle) \