00001
00029 #ifndef _XENO_TIMER_H
00030 #define _XENO_TIMER_H
00031
00032 #include <native/types.h>
00033
00034 #define TM_ONESHOT XN_APERIODIC_TICK
00035
00040 typedef struct rt_timer_info {
00041
00042 RTIME period;
00043 RTIME date;
00044 RTIME tsc;
00045
00046 } RT_TIMER_INFO;
00047
00048 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00049
00050 #include <nucleus/timer.h>
00051 #include <asm-generic/xenomai/timeconv.h>
00052
00053 extern xntbase_t *__native_tbase;
00054
00055 #endif
00056
00057 #ifdef __cplusplus
00058 extern "C" {
00059 #endif
00060
00061 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
00062 static inline SRTIME rt_timer_ns2tsc(SRTIME ns)
00063 {
00064 return xnarch_ns_to_tsc(ns);
00065 }
00066
00067 static inline SRTIME rt_timer_tsc2ns(SRTIME ticks)
00068 {
00069 return xnarch_tsc_to_ns(ticks);
00070 }
00071
00072 static inline RTIME rt_timer_tsc(void)
00073 {
00074 return xnarch_get_cpu_tsc();
00075 }
00076
00077 static inline RTIME rt_timer_read(void)
00078 {
00079 return xntbase_get_time(__native_tbase);
00080 }
00081
00082 static inline SRTIME rt_timer_ns2ticks(SRTIME ns)
00083 {
00084 return xntbase_ns2ticks(__native_tbase, ns);
00085 }
00086
00087 static inline SRTIME rt_timer_ticks2ns(SRTIME ticks)
00088 {
00089 return xntbase_ticks2ns(__native_tbase, ticks);
00090 }
00091
00092 #else
00093
00117 SRTIME rt_timer_ns2tsc(SRTIME ns);
00118
00142 SRTIME rt_timer_tsc2ns(SRTIME ticks);
00143
00165 RTIME rt_timer_tsc(void);
00166
00191 RTIME rt_timer_read(void);
00192
00216 SRTIME rt_timer_ns2ticks(SRTIME ns);
00217
00241 SRTIME rt_timer_ticks2ns(SRTIME ticks);
00242
00243 #endif
00244
00245 int rt_timer_inquire(RT_TIMER_INFO *info);
00246
00247 RTIME rt_timer_read(void);
00248
00249 void rt_timer_spin(RTIME ns);
00250
00251 int rt_timer_set_mode(RTIME nstick);
00252
00253 #ifdef __cplusplus
00254 }
00255 #endif
00256
00259 #endif