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
|
|
|
*
|
1996-10-10 10:25:26 +00:00
|
|
|
* $Id: clock.h,v 1.17 1996/10/09 19:47:26 bde Exp $
|
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
|
|
|
|
1995-12-24 08:10:52 +00:00
|
|
|
#if defined(I586_CPU) || defined(I686_CPU)
|
1995-10-12 20:39:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* When we update the clock, we also update this bias value which is
|
|
|
|
* automatically subtracted in microtime(). We assume that CPU_THISTICKLEN()
|
|
|
|
* has been called at some point in the past, so that an appropriate value is
|
|
|
|
* set up in i586_last_tick. (This works even if we are not being called
|
|
|
|
* from hardclock because hardclock will have run before and will made the
|
|
|
|
* call.)
|
|
|
|
*/
|
1994-09-18 20:40:01 +00:00
|
|
|
#define CPU_CLOCKUPDATE(otime, ntime) \
|
|
|
|
do { \
|
1996-08-02 21:16:13 +00:00
|
|
|
if (i586_ctr_freq != 0) { \
|
1995-10-12 20:39:49 +00:00
|
|
|
disable_intr(); \
|
|
|
|
i586_ctr_bias = i586_last_tick; \
|
|
|
|
*(otime) = *(ntime); \
|
|
|
|
enable_intr(); \
|
1994-09-18 20:40:01 +00:00
|
|
|
} else { \
|
|
|
|
*(otime) = *(ntime); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
1995-10-12 20:39:49 +00:00
|
|
|
#define CPU_THISTICKLEN(dflt) cpu_thisticklen(dflt)
|
1994-09-18 20:40:01 +00:00
|
|
|
#else
|
|
|
|
#define CPU_CLOCKUPDATE(otime, ntime) \
|
|
|
|
(*(otime) = *(ntime))
|
1995-10-12 20:39:49 +00:00
|
|
|
#define CPU_THISTICKLEN(dflt) dflt
|
1994-09-18 20:40:01 +00:00
|
|
|
#endif
|
|
|
|
|
1996-07-30 19:26:55 +00:00
|
|
|
#define I586_CTR_COMULTIPLIER_SHIFT 20
|
|
|
|
#define I586_CTR_MULTIPLIER_SHIFT 32
|
1995-11-29 19:57:22 +00:00
|
|
|
|
1994-11-05 22:51:17 +00:00
|
|
|
#if defined(KERNEL) && !defined(LOCORE)
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <machine/frame.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* i386 to clock driver interface.
|
|
|
|
* XXX almost all of it is misplaced. i586 stuff is done in isa/clock.c
|
|
|
|
* and isa stuff is done in i386/microtime.s and i386/support.s.
|
|
|
|
*/
|
|
|
|
extern int adjkerntz;
|
|
|
|
extern int disable_rtc_set;
|
1996-04-22 19:40:28 +00:00
|
|
|
extern int statclock_disable;
|
1996-04-05 03:36:31 +00:00
|
|
|
extern int wall_cmos_clock;
|
|
|
|
|
1995-12-24 08:10:52 +00:00
|
|
|
#if defined(I586_CPU) || defined(I686_CPU)
|
1996-08-02 21:16:13 +00:00
|
|
|
extern u_int i586_ctr_bias;
|
1996-07-30 19:26:55 +00:00
|
|
|
extern u_int i586_ctr_comultiplier;
|
|
|
|
extern u_int i586_ctr_freq;
|
|
|
|
extern u_int i586_ctr_multiplier;
|
1995-10-12 20:39:49 +00:00
|
|
|
extern long long i586_last_tick;
|
1996-01-30 18:56:47 +00:00
|
|
|
extern unsigned long i586_avg_tick;
|
1994-11-05 22:51:17 +00:00
|
|
|
#endif
|
|
|
|
extern int timer0_max_count;
|
|
|
|
extern u_int timer0_overflow_threshold;
|
|
|
|
extern u_int timer0_prescaler_count;
|
|
|
|
|
|
|
|
|
1995-12-24 08:10:52 +00:00
|
|
|
#if defined(I586_CPU) || defined(I686_CPU)
|
1995-10-12 20:39:49 +00:00
|
|
|
static __inline u_long
|
|
|
|
cpu_thisticklen(u_long dflt)
|
|
|
|
{
|
|
|
|
long long old;
|
1996-01-30 18:56:47 +00:00
|
|
|
long len;
|
1996-05-01 08:39:02 +00:00
|
|
|
|
1996-08-02 21:16:13 +00:00
|
|
|
if (i586_ctr_freq != 0) {
|
1995-10-12 20:39:49 +00:00
|
|
|
old = i586_last_tick;
|
1996-05-01 08:39:02 +00:00
|
|
|
i586_last_tick = rdtsc();
|
1996-08-02 21:16:13 +00:00
|
|
|
len = ((i586_last_tick - old) * i586_ctr_multiplier)
|
|
|
|
>> I586_CTR_MULTIPLIER_SHIFT;
|
1996-01-30 18:56:47 +00:00
|
|
|
i586_avg_tick = i586_avg_tick * 15 / 16 + len / 16;
|
1995-10-12 20:39:49 +00:00
|
|
|
}
|
1996-01-30 18:56:47 +00:00
|
|
|
return dflt;
|
1995-10-12 20:39:49 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1994-11-05 22:51:17 +00:00
|
|
|
/*
|
|
|
|
* Driver to clock driver interface.
|
|
|
|
*/
|
|
|
|
void DELAY __P((int usec));
|
|
|
|
int acquire_timer0 __P((int rate,
|
|
|
|
void (*function)(struct clockframe *frame)));
|
|
|
|
int acquire_timer2 __P((int mode));
|
|
|
|
int release_timer0 __P((void));
|
|
|
|
int release_timer2 __P((void));
|
1996-06-14 11:02:28 +00:00
|
|
|
#ifndef PC98
|
1996-03-31 04:05:36 +00:00
|
|
|
int rtcin __P((int val));
|
1996-06-14 11:02:28 +00:00
|
|
|
#else
|
|
|
|
int acquire_timer1 __P((int mode));
|
|
|
|
int release_timer1 __P((void));
|
|
|
|
void rtc_serialcombit __P((int i));
|
|
|
|
void rtc_serialcom __P((int i));
|
|
|
|
void rtc_outb __P((int val));
|
|
|
|
#endif
|
1994-11-05 22:51:17 +00:00
|
|
|
int sysbeep __P((int pitch, int period));
|
|
|
|
|
|
|
|
#endif /* KERNEL && !LOCORE */
|
|
|
|
|
|
|
|
#endif /* !_MACHINE_CLOCK_H_ */
|