2005-01-05 20:17:21 +00:00
|
|
|
/*-
|
1994-09-18 20:40:01 +00:00
|
|
|
* Kernel interface to machine-dependent clock driver.
|
|
|
|
* Garrett Wollman, September 1994.
|
|
|
|
* This file is in the public domain.
|
1995-11-29 19:57:22 +00:00
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-09-18 20:40:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MACHINE_CLOCK_H_
|
1994-11-05 22:51:17 +00:00
|
|
|
#define _MACHINE_CLOCK_H_
|
1994-09-18 20:40:01 +00:00
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1994-11-05 22:51:17 +00:00
|
|
|
/*
|
|
|
|
* i386 to clock driver interface.
|
1998-02-25 02:20:30 +00:00
|
|
|
* XXX large parts of the driver and its interface are misplaced.
|
1994-11-05 22:51:17 +00:00
|
|
|
*/
|
2003-11-17 08:58:16 +00:00
|
|
|
extern int clkintr_pending;
|
2008-03-26 15:03:24 +00:00
|
|
|
extern u_int i8254_freq;
|
|
|
|
extern int i8254_max_count;
|
2003-01-29 11:36:39 +00:00
|
|
|
extern uint64_t tsc_freq;
|
2008-10-21 00:38:00 +00:00
|
|
|
extern int tsc_is_invariant;
|
2011-04-12 22:22:01 +00:00
|
|
|
extern int tsc_perf_stat;
|
2013-04-10 05:59:07 +00:00
|
|
|
#ifdef SMP
|
|
|
|
extern int smp_tsc;
|
|
|
|
#endif
|
2007-01-23 08:01:20 +00:00
|
|
|
|
|
|
|
void i8254_init(void);
|
2014-03-11 10:20:42 +00:00
|
|
|
void i8254_delay(int);
|
|
|
|
void clock_init(void);
|
1994-11-05 22:51:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Driver to clock driver interface.
|
|
|
|
*/
|
1996-10-25 13:01:56 +00:00
|
|
|
|
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.
2008-04-22 19:38:30 +00:00
|
|
|
void startrtclock(void);
|
2003-02-05 09:20:40 +00:00
|
|
|
void init_TSC(void);
|
2018-05-25 07:33:20 +00:00
|
|
|
void resume_TSC(void);
|
1994-11-05 22:51:17 +00:00
|
|
|
|
The "free-lance" timer in the i8254 is only used for the speaker
these days, so de-generalize the acquire_timer/release_timer api
to just deal with speakers.
The new (optional) MD functions are:
timer_spkr_acquire()
timer_spkr_release()
and
timer_spkr_setfreq()
the last of which configures the timer to generate a tone of a given
frequency, in Hz instead of 1/1193182th of seconds.
Drop entirely timer2 on pc98, it is not used anywhere at all.
Move sysbeep() to kern/tty_cons.c and use the timer_spkr*() if
they exist, and do nothing otherwise.
Remove prototypes and empty acquire-/release-timer() and sysbeep()
functions from the non-beeping archs.
This eliminate the need for the speaker driver to know about
i8254frequency at all. In theory this makes the speaker driver MI,
contingent on the timer_spkr_*() functions existing but the driver
does not know this yet and still attaches to the ISA bus.
Syscons is more tricky, in one function, sc_tone(), it knows the hz
and things are just fine.
In the other function, sc_bell() it seems to get the period from
the KDMKTONE ioctl in terms if 1/1193182th second, so we hardcode
the 1193182 and leave it at that. It's probably not important.
Change a few other sysbeep() uses which obviously knew that the
argument was in terms of i8254 frequency, and leave alone those
that look like people thought sysbeep() took frequency in hertz.
This eliminates the knowledge of i8254_freq from all but the actual
clock.c code and the prof_machdep.c on amd64 and i386, where I think
it would be smart to ask for help from the timecounters anyway [TBD].
2008-03-26 20:09:21 +00:00
|
|
|
#define HAS_TIMER_SPKR 1
|
|
|
|
int timer_spkr_acquire(void);
|
|
|
|
int timer_spkr_release(void);
|
|
|
|
void timer_spkr_setfreq(int freq);
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-11-05 22:51:17 +00:00
|
|
|
|
|
|
|
#endif /* !_MACHINE_CLOCK_H_ */
|