clock.h revision 7090
1/* 2 * Kernel interface to machine-dependent clock driver. 3 * Garrett Wollman, September 1994. 4 * This file is in the public domain. 5 */ 6 7#ifndef _MACHINE_CLOCK_H_ 8#define _MACHINE_CLOCK_H_ 9 10#ifdef I586_CPU 11 /* 12 * This resets the CPU cycle counter to zero, to make our 13 * job easier in microtime(). Some fancy ifdefs could speed 14 * this up for Pentium-only kernels. 15 * We want this to be done as close as possible to the actual 16 * timer incrementing in hardclock(), because there is a window 17 * between the two where the value is no longer valid. Experimentation 18 * may reveal a good precompensation to apply in microtime(). 19 */ 20#define CPU_CLOCKUPDATE(otime, ntime) \ 21 do { \ 22 if(pentium_mhz) { \ 23 __asm __volatile("cli\n" \ 24 "movl (%2),%%eax\n" \ 25 "movl %%eax,(%1)\n" \ 26 "movl 4(%2),%%eax\n" \ 27 "movl %%eax,4(%1)\n" \ 28 "movl $0x10,%%ecx\n" \ 29 "xorl %%eax,%%eax\n" \ 30 "movl %%eax,%%edx\n" \ 31 ".byte 0x0f, 0x30\n" \ 32 "sti\n" \ 33 "#%0%1%2" \ 34 : "=m"(*otime) /* no outputs */ \ 35 : "c"(otime), "b"(ntime) /* fake input */ \ 36 : "ax", "cx", "dx"); \ 37 } else { \ 38 *(otime) = *(ntime); \ 39 } \ 40 } while(0) 41 42#else 43#define CPU_CLOCKUPDATE(otime, ntime) \ 44 (*(otime) = *(ntime)) 45#endif 46 47#if defined(KERNEL) && !defined(LOCORE) 48#include <sys/cdefs.h> 49#include <machine/frame.h> 50 51/* 52 * i386 to clock driver interface. 53 * XXX almost all of it is misplaced. i586 stuff is done in isa/clock.c 54 * and isa stuff is done in i386/microtime.s and i386/support.s. 55 */ 56extern int adjkerntz; 57extern int disable_rtc_set; 58#ifdef I586_CPU 59extern int pentium_mhz; 60#endif 61extern int timer0_max_count; 62extern u_int timer0_overflow_threshold; 63extern u_int timer0_prescaler_count; 64 65#ifdef I586_CPU 66void calibrate_cyclecounter __P((void)); 67#endif 68void clkintr __P((struct clockframe frame)); 69void rtcintr __P((struct clockframe frame)); 70 71/* 72 * Driver to clock driver interface. 73 */ 74void DELAY __P((int usec)); 75int acquire_timer0 __P((int rate, 76 void (*function)(struct clockframe *frame))); 77int acquire_timer2 __P((int mode)); 78int release_timer0 __P((void)); 79int release_timer2 __P((void)); 80int sysbeep __P((int pitch, int period)); 81 82#endif /* KERNEL && !LOCORE */ 83 84#endif /* !_MACHINE_CLOCK_H_ */ 85