base/include/asm-i386/rtai_emulate_tsc.h

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2004 Paolo Mantegazza (mantegazza@aero.polimi.it)
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
00007  *   USA; either version 2 of the License, or (at your option) any later
00008  *   version.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018  */
00019 
00020 
00021 //#define EMULATE_TSC  /* to force emulation even if CONFIG_X86_TSC */
00022 
00023 #ifndef _RTAI_ASM_EMULATE_TSC_H
00024 #define _RTAI_ASM_EMULATE_TSC_H
00025 
00026 #if defined(EMULATE_TSC) || !defined(CONFIG_X86_TSC)
00027 
00028 #undef RTAI_CPU_FREQ
00029 #undef RTAI_CALIBRATED_CPU_FREQ
00030 #undef rdtsc
00031 #undef rtai_rdtsc
00032 #undef DECLR_8254_TSC_EMULATION
00033 #undef TICK_8254_TSC_EMULATION
00034 #undef SETUP_8254_TSC_EMULATION
00035 #undef CLEAR_8254_TSC_EMULATION
00036 
00037 #define RTAI_CPU_FREQ             RTAI_FREQ_8254
00038 #define RTAI_CALIBRATED_CPU_FREQ  RTAI_FREQ_8254
00039 #define rtai_rdtsc()              rd_8254_ts()
00040 #define rdtsc()                   rd_8254_ts()
00041 
00042 #define TICK_8254_TSC_EMULATION()  rd_8254_ts()
00043 
00044 #include <linux/version.h>
00045 #if defined(CONFIG_VT) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00046 
00047 #define DECLR_8254_TSC_EMULATION \
00048 extern void *kd_mksound; \
00049 static void *linux_mksound; \
00050 static void rtai_mksound(void) { } \
00051 const int TSC_EMULATION_GUARD_FREQ = 20; \
00052 static struct timer_list timer;
00053 
00054 #define SETUP_8254_TSC_EMULATION \
00055     do { \
00056         linux_mksound = kd_mksound; \
00057         kd_mksound = rtai_mksound; \
00058         rt_setup_8254_tsc(); \
00059         init_timer(&timer); \
00060         timer.function = timer_fun; \
00061         timer_fun(0); \
00062     } while (0)
00063 
00064 #define CLEAR_8254_TSC_EMULATION \
00065     do { \
00066         del_timer(&timer); \
00067         if (linux_mksound) { \
00068             kd_mksound = linux_mksound; \
00069         } \
00070     } while (0)
00071 
00072 #else /* !CONFIG_VT */
00073 
00074 #define DECLR_8254_TSC_EMULATION \
00075 const int TSC_EMULATION_GUARD_FREQ = 20; \
00076 static struct timer_list timer;
00077 
00078 #define SETUP_8254_TSC_EMULATION \
00079     do { \
00080         rt_setup_8254_tsc(); \
00081         init_timer(&timer); \
00082         timer.function = timer_fun; \
00083         timer_fun(0); \
00084     } while (0)
00085 
00086 #define CLEAR_8254_TSC_EMULATION del_timer(&timer)
00087 
00088 #endif /* !CONFIG_VT */
00089 
00090 #endif
00091 
00092 #endif /* !_RTAI_ASM_EMULATE_TSC_H */

Generated on Tue Feb 2 17:46:04 2010 for RTAI API by  doxygen 1.4.7