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 __linux__
00041
00042 #ifdef __x86_64__
00043
00044 typedef unsigned long cycles_t;
00045 extern cycles_t cacheflush_time;
00046
00047 static inline unsigned long get_cycles(void)
00048 {
00049 unsigned int hi, lo;
00050 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
00051 return (((unsigned long)hi)<<32) | ((unsigned long)lo);
00052 }
00053
00054 #endif
00055
00056 #ifdef __PPC__
00057
00058
00059
00060 #define CPU_FTR_601 0x00000100
00061
00062 typedef unsigned long cycles_t;
00063
00064
00065
00066 extern cycles_t cacheflush_time;
00067
00068 static inline cycles_t get_cycles(void)
00069 {
00070 cycles_t ret = 0;
00071
00072 __asm__ __volatile__(
00073 "98: mftb %0\n"
00074 "99:\n"
00075 ".section __ftr_fixup,\"a\"\n"
00076 " .long %1\n"
00077 " .long 0\n"
00078 " .long 98b\n"
00079 " .long 99b\n"
00080 ".previous"
00081 : "=r" (ret) : "i" (CPU_FTR_601));
00082 return ret;
00083 }
00084
00085 #endif
00086
00087 #ifdef __i386__
00088
00089 typedef unsigned long long cycles_t;
00090
00091 extern cycles_t cacheflush_time;
00092
00093 #define rdtscll(val) \
00094 __asm__ __volatile__("rdtsc" : "=A" (val))
00095
00096 static inline cycles_t get_cycles (void)
00097 {
00098 unsigned long long ret;
00099
00100 rdtscll(ret);
00101 return ret;
00102 }
00103
00104 #endif
00105
00106 #endif
00107
00108 #endif