146d4e165SJordan Gordeev /* 2b6871f55SYonghong Yan * Kernel interface to machine-dependent clock driver. 3b6871f55SYonghong Yan * Garrett Wollman, September 1994. 4b6871f55SYonghong Yan * This file is in the public domain. 5b6871f55SYonghong Yan * 646d4e165SJordan Gordeev * $FreeBSD: src/sys/i386/include/clock.h,v 1.38.2.1 2002/11/02 04:41:50 iwasaki Exp $ 7b6871f55SYonghong Yan */ 8b6871f55SYonghong Yan 9b6871f55SYonghong Yan #ifndef _MACHINE_CLOCK_H_ 10b6871f55SYonghong Yan #define _MACHINE_CLOCK_H_ 11b6871f55SYonghong Yan 1246d4e165SJordan Gordeev #ifndef _SYS_TYPES_H_ 1346d4e165SJordan Gordeev #include <sys/types.h> 1446d4e165SJordan Gordeev #endif 15fe45ae1aSMatthew Dillon 16fe45ae1aSMatthew Dillon #ifdef _KERNEL 17fe45ae1aSMatthew Dillon 18d8129ed3SMatthew Dillon #ifndef _SYS_SYSTIMER_H_ 19d8129ed3SMatthew Dillon #include <sys/systimer.h> 20d8129ed3SMatthew Dillon #endif 21d8129ed3SMatthew Dillon 22d8129ed3SMatthew Dillon typedef struct TOTALDELAY { 23d8129ed3SMatthew Dillon int us; 24d8129ed3SMatthew Dillon int started; 25d8129ed3SMatthew Dillon sysclock_t last_clock; 26d8129ed3SMatthew Dillon } TOTALDELAY; 2746d4e165SJordan Gordeev 28fe45ae1aSMatthew Dillon #endif 29fe45ae1aSMatthew Dillon 305b49787bSMatthew Dillon typedef uint64_t tsc_uclock_t; 315b49787bSMatthew Dillon typedef int64_t tsc_sclock_t; 325b49787bSMatthew Dillon 33fe45ae1aSMatthew Dillon #ifdef _KERNEL 34fe45ae1aSMatthew Dillon 35b6871f55SYonghong Yan /* 36466d4f43Szrj * x86 to clock driver interface. 37b6871f55SYonghong Yan * XXX large parts of the driver and its interface are misplaced. 38b6871f55SYonghong Yan */ 39b6871f55SYonghong Yan extern int adjkerntz; 4046d4e165SJordan Gordeev extern int disable_rtc_set; 41b6871f55SYonghong Yan extern int tsc_present; 425a81b19fSSepherosa Ziehau extern int tsc_invariant; 43dda44f1eSSepherosa Ziehau extern int tsc_mpsync; 44b6871f55SYonghong Yan extern int wall_cmos_clock; 455b49787bSMatthew Dillon extern tsc_uclock_t tsc_frequency; 465b49787bSMatthew Dillon extern tsc_uclock_t tsc_oneus_approx; /* do not use for fine calc, min 1 */ 47*db2ec6f8SSascha Wildner extern int i8254_cputimer_disable; /* No need to initialize i8254 cputimer. */ 48b6871f55SYonghong Yan 49b6871f55SYonghong Yan /* 50b6871f55SYonghong Yan * Driver to clock driver interface. 51b6871f55SYonghong Yan */ 52b6871f55SYonghong Yan 53d8129ed3SMatthew Dillon int CHECKTIMEOUT(TOTALDELAY *); 5446d4e165SJordan Gordeev int rtcin (int val); 55b6871f55SYonghong Yan int acquire_timer2 (int mode); 56b6871f55SYonghong Yan int release_timer2 (void); 57b6871f55SYonghong Yan int sysbeep (int pitch, int period); 5846d4e165SJordan Gordeev void timer_restore (void); 59b6871f55SYonghong Yan 601a3a6ceeSImre Vadász /* 611a3a6ceeSImre Vadász * Allow registering timecounter initialization code. 621a3a6ceeSImre Vadász */ 631a3a6ceeSImre Vadász typedef struct timecounter_init { 641a3a6ceeSImre Vadász char *name; 651a3a6ceeSImre Vadász void (*configure)(void); 661a3a6ceeSImre Vadász } timecounter_init_t; 671a3a6ceeSImre Vadász 681a3a6ceeSImre Vadász #define TIMECOUNTER_INIT(name, config) \ 691a3a6ceeSImre Vadász static struct timecounter_init name##_timer = { \ 701a3a6ceeSImre Vadász #name, config \ 711a3a6ceeSImre Vadász }; \ 721a3a6ceeSImre Vadász DATA_SET(timecounter_init_set, name##_timer); 731a3a6ceeSImre Vadász 74b6871f55SYonghong Yan #endif /* _KERNEL */ 75b6871f55SYonghong Yan 76b6871f55SYonghong Yan #endif /* !_MACHINE_CLOCK_H_ */ 77