rdtsc_timer.h

Go to the documentation of this file.
00001 #ifndef _GPXE_RDTSC_TIMER_H
00002 #define _GPXE_RDTSC_TIMER_H
00003 
00004 /** @file
00005  *
00006  * RDTSC timer
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER );
00011 
00012 #ifdef TIMER_RDTSC
00013 #define TIMER_PREFIX_rdtsc
00014 #else
00015 #define TIMER_PREFIX_rdtsc __rdtsc_
00016 #endif
00017 
00018 /**
00019  * RDTSC values can easily overflow an unsigned long.  We discard the
00020  * low-order bits in order to obtain sensibly-scaled values.
00021  */
00022 #define TSC_SHIFT 8
00023 
00024 /**
00025  * Get current system time in ticks
00026  *
00027  * @ret ticks           Current time, in ticks
00028  */
00029 static inline __always_inline unsigned long
00030 TIMER_INLINE ( rdtsc, currticks ) ( void ) {
00031         unsigned long ticks;
00032 
00033         __asm__ __volatile__ ( "rdtsc\n\t"
00034                                "shrdl %1, %%edx, %%eax\n\t"
00035                                : "=a" ( ticks ) : "i" ( TSC_SHIFT ) : "edx" );
00036         return ticks;
00037 }
00038 
00039 #endif /* _GPXE_RDTSC_TIMER_H */

Generated on Tue Apr 6 20:00:50 2010 for gPXE by  doxygen 1.5.7.1