00001
00008
00009
00010
00011
00012 #ifndef __RT_MON_INCLUDE_CLOCK_H_
00013 #define __RT_MON_INCLUDE_CLOCK_H_
00014
00015 #include <l4/rt_mon/types.h>
00016
00017 #include <l4/sigma0/kip.h>
00018 #include <l4/util/rdtsc.h>
00019 #include <l4/util/thread_time.h>
00020
00021 #define RT_MON_GET_TIME(clock_type, time_val) \
00022 do \
00023 { \
00024 switch (clock_type) \
00025 { \
00026 case RT_MON_THREAD_TIME: \
00027 { \
00028 int ret; \
00029 l4_threadid_t next; \
00030 l4_umword_t prio; \
00031 \
00032 ret = fiasco_get_cputime(l4_myself(), &next, &(time_val), &prio); \
00033 break; \
00034 } \
00035 case RT_MON_TSC_TIME: \
00036 (time_val) = l4_rdtsc(); \
00037 break; \
00038 case RT_MON_TSC_TO_US_TIME: \
00039 (time_val) = l4_tsc_to_us(l4_rdtsc()); \
00040 break; \
00041 case RT_MON_FAST_THREAD_TIME: \
00042 (time_val) = l4_tsc_to_us(l4util_thread_time(l4sigma0_kip())); \
00043 break; \
00044 case RT_MON_FAST_THREAD_TIME_TSC: \
00045 (time_val) = l4util_thread_time(l4sigma0_kip()); \
00046 break; \
00047 default: \
00048 LOG("corrupted CLOCKTYPE"); \
00049 } \
00050 } while (0)
00051
00052
00058 L4_INLINE void rt_mon_calibrate_clock(int clock);
00059 L4_INLINE void rt_mon_calibrate_clock(int clock)
00060 {
00061 if (clock == RT_MON_TSC_TO_US_TIME || clock == RT_MON_FAST_THREAD_TIME)
00062 if (l4_scaler_tsc_to_us == 0)
00063 l4_calibrate_tsc();
00064 }
00065
00066 #endif