/home/hillier_g/checkout/most4linux/most-kernel/most-measurements.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright(c) Siemens AG, Muenchen, Germany, 2005, 2006, 2007
00003  *                           Bernhard Walle <bernhard.walle@gmx.de>
00004  *                           Gernot Hillier <gernot.hillier@siemens.com>
00005  *
00006  * ----------------------------------------------------------------------------
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License version 2 as 
00009  * published by the Free Software Foundation;
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  * ----------------------------------------------------------------------------
00020  */
00021 #ifndef MOST_MEASUREMENTS_H
00022 #define MOST_MEASUREMENTS_H
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include "config/config.h"
00026 #endif
00027 #ifdef __KERNEL__
00028 #  include "most-rxbuf.h"
00029 #endif
00030 
00042 /* print a compiler warning if measuring are turned on */
00043 #if defined(MEASURING_PCI) || defined(MEASURING_SCHED)
00044 #   warning "Driver is compiled with measurements turned on. This may give strange results!"
00045 #endif
00046 
00053 #define MEASUREMENT_MAGIC_START_HIGH        0x90520000
00054 
00061 #define MEASUREMENT_MAGIC_END_HIGH          0x52900000
00062 
00068 #define MEASUREMENT_MAGIC_START_REC_ISR                \
00069     (0x243A | MEASUREMENT_MAGIC_START_HIGH)
00070 
00076 #define MEASUREMENT_MAGIC_END_REC_ISR                  \
00077     (0x3A24 | MEASUREMENT_MAGIC_END_HIGH)
00078 
00079 #if defined(RT_RTDM) || defined(DOXYGEN)
00080 
00087 #define MEASUREMENT_INT_CONSTANT                       \
00088     MOST_PCI_RESERVED_5
00089 #else
00090 #define MEASUREMENT_INT_CONSTANT                       \
00091     MOST_PCI_RESERVED_4
00092 #endif
00093 
00097 #define MOST_LH(low, high)                             \
00098     ((((high) & 0xFFFF) << 16) | ((low) & 0xFFFF))
00099 
00103 #define MOST_LOW(value)                                \
00104     ((value) & 0xFFFF)
00105 
00109 #define MOST_HIGH(value)                               \
00110     (((value) & 0xFFFF0000) > 16)
00111 
00112 
00113 #ifdef __KERNEL__
00114 
00115 #if defined(MEASURING_PCI) || defined(DOXYGEN) 
00116 
00121 #define measuring_int_begin()                                               \
00122         do {                                                                \
00123             readreg_int(dev, MEASUREMENT_INT_CONSTANT);                     \
00124         } while (0)
00125 
00130 #define measuring_int_end()                                                 \
00131         do {                                                                \
00132             udelay(1);                                                      \
00133             readreg_int(dev, MOST_PCI_RESERVED_6);                          \
00134         } while (0)
00135 
00141 #define measuring_int_error_sharing()                                       \
00142         rtnrt_warn("IRQ sharing is not supported with measurements\n")
00143 
00144 #else
00145 #define measuring_int_begin()                                               \
00146         do { } while (0)
00147 #define measuring_int_end()                                                 \
00148         do { } while (0)
00149 #define measuring_int_error_sharing()                                       \
00150         do { } while (0)
00151 #endif
00152 
00153 #endif /* __KERNEL__ */
00154 
00160 struct measuring_schedlat_data {
00161     unsigned int        magic_start;    
00162     unsigned int        counter;        
00164     unsigned long long  tsc;            
00165     unsigned int        magic_end;      
00166 } __attribute__((packed));
00167 
00168 
00169 #ifdef __KERNEL__
00170 #if defined(MEASURING_SCHED) || defined(DOXYGEN)
00171 
00177 static struct rx_buffer rxbuf_copy;
00178 
00187 static inline void measuring_receive_isr_start(struct rx_buffer *buffer)
00188 {
00189     rxbuf_copy = *buffer;
00190 }
00191 
00198 static inline void measuring_receive_isr_wakeup(void)
00199 {
00200     static unsigned int                cnt = 0;
00201     struct measuring_schedlat_data     data;
00202 
00203     data.magic_start = MEASUREMENT_MAGIC_START_REC_ISR;
00204     data.counter = cnt++;
00205     data.magic_end = MEASUREMENT_MAGIC_END_REC_ISR;
00206     rdtscll(data.tsc);
00207     rxbuf_put(&rxbuf_copy, (void *)&data, sizeof(data));
00208 }
00209 #else
00210 static inline void measuring_receive_isr_start(struct rx_buffer *buffer)
00211 {}
00212 static inline void measuring_receive_isr_wakeup(void)
00213 {}
00214 #endif
00215 #endif /* __KERNEL__ */
00216 
00217 
00218 #if defined(MEASURING_SCHED) || defined(MEASURING_PCI) || defined(DOXYGEN)
00219 
00223 static inline void print_measuring_warning(void)
00224 {
00225     rtnrt_warn("Measuring turned on. This may give strange "
00226             "results in normal operation!\n");
00227 }
00228 #else
00229 static inline void print_measuring_warning(void)
00230 {}
00231 #endif
00232 
00233 #endif /* MOST_MEASUREMENTS_H */
00234 

Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0