00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __jack_cycles_h__
00023 #define __jack_cycles_h__
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifdef __x86_64__
00041
00042 typedef unsigned long cycles_t;
00043 extern cycles_t cacheflush_time;
00044
00045 static inline unsigned long get_cycles(void)
00046 {
00047 unsigned int hi, lo;
00048 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
00049 return (((unsigned long)hi)<<32) | ((unsigned long)lo);
00050 }
00051
00052 #endif
00053
00054 #ifdef __sparc_v9__
00055
00056 static inline unsigned long long get_cycles(void)
00057 {
00058 unsigned long long res;
00059 __asm__ __volatile__("rd %%tick, %0" : "=r"(res));
00060 return res;
00061 }
00062 #endif
00063
00064 #ifdef __sparc_v9__
00065
00066 static inline unsigned long long get_cycles(void)
00067 {
00068 unsigned long long res;
00069 __asm__ __volatile__("rd %%tick, %0" : "=r"(res));
00070 return res;
00071 }
00072 #endif
00073
00074 #ifdef __PPC__
00075
00076
00077
00078 #define CPU_FTR_601 0x00000100
00079
00080 typedef unsigned long cycles_t;
00081
00082
00083
00084 extern cycles_t cacheflush_time;
00085
00086 static inline cycles_t get_cycles(void)
00087 {
00088 cycles_t ret = 0;
00089
00090 __asm__ __volatile__(
00091 "98: mftb %0\n"
00092 "99:\n"
00093 ".section __ftr_fixup,\"a\"\n"
00094 " .long %1\n"
00095 " .long 0\n"
00096 " .long 98b\n"
00097 " .long 99b\n"
00098 ".previous"
00099 : "=r" (ret) : "i" (CPU_FTR_601));
00100 return ret;
00101 }
00102
00103 #endif
00104
00105 #ifdef __i386__
00106
00107 typedef unsigned long long cycles_t;
00108
00109 extern cycles_t cacheflush_time;
00110
00111 #define rdtscll(val) \
00112 __asm__ __volatile__("rdtsc" : "=A" (val))
00113
00114 static inline cycles_t get_cycles (void)
00115 {
00116 unsigned long long ret;
00117
00118 rdtscll(ret);
00119 return ret;
00120 }
00121
00122 #endif
00123
00124
00125 #if !defined (__PPC__) && !defined (__x86_64__) && !defined (__i386__) && !defined (__sparc_v9__)
00126
00127 #warning No suitable get_cycles() implementation. Returning 0 instead
00128
00129 typedef unsigned long long cycles_t;
00130
00131 static inline cycles_t get_cycles(void)
00132 {
00133 return 0;
00134 }
00135
00136 #endif
00137
00138
00139 #endif