# rtai_emulate_tsc.h

    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 DECLR_8254_TSC_EMULATION \
    00043 extern void *kd_mksound; \
    00044 static void *linux_mksound; \
    00045 static void rtai_mksound(void) { } \
    00046 const int TSC_EMULATION_GUARD_FREQ = 20; \
    00047 static struct timer_list timer;
    00048
    00049 #define TICK_8254_TSC_EMULATION()  rd_8254_ts()
    00050
    00051 #define SETUP_8254_TSC_EMULATION \
    00052         do { \
    00053                 linux_mksound = kd_mksound; \
    00054                 kd_mksound = rtai_mksound; \
    00055                 rt_setup_8254_tsc(); \
    00056                 init_timer(&timer); \
    00057                 timer.function = timer_fun; \
    00058                 timer_fun(0); \
    00059         } while (0)
    00060
    00061 #define CLEAR_8254_TSC_EMULATION \
    00062         do { \
    00063                 del_timer(&timer); \
    00064                 if (linux_mksound) { \
    00065                         kd_mksound = linux_mksound; \
    00066                 } \
    00067         } while (0)
    00068
    00069 #endif
    00070
    00071 #endif /* !_RTAI_ASM_EMULATE_TSC_H */