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
00052 extern xntbase_t *__native_tbase;
00053
00054 #endif
00055
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059
00060 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
00061 static inline SRTIME rt_timer_ns2tsc(SRTIME ns)
00062 {
00063 return xnarch_ns_to_tsc(ns);
00064 }
00065
00066 static inline SRTIME rt_timer_tsc2ns(SRTIME ticks)
00067 {
00068 return xnarch_tsc_to_ns(ticks);
00069 }
00070
00071 static inline RTIME rt_timer_tsc(void)
00072 {
00073 return xnarch_get_cpu_tsc();
00074 }
00075
00076 static inline RTIME rt_timer_read(void)
00077 {
00078 return xntbase_get_time(__native_tbase);
00079 }
00080
00081 static inline SRTIME rt_timer_ns2ticks(SRTIME ns)
00082 {
00083 return xntbase_ns2ticks(__native_tbase, ns);
00084 }
00085
00086 static inline SRTIME rt_timer_ticks2ns(SRTIME ticks)
00087 {
00088 return xntbase_ticks2ns(__native_tbase, ticks);
00089 }
00090
00091 #else
00092
00116 SRTIME rt_timer_ns2tsc(SRTIME ns);
00117
00141 SRTIME rt_timer_tsc2ns(SRTIME ticks);
00142
00164 RTIME rt_timer_tsc(void);
00165
00190 RTIME rt_timer_read(void);
00191
00215 SRTIME rt_timer_ns2ticks(SRTIME ns);
00216
00240 SRTIME rt_timer_ticks2ns(SRTIME ticks);
00241
00242 #endif
00243
00244 int rt_timer_inquire(RT_TIMER_INFO *info);
00245
00246 RTIME rt_timer_read(void);
00247
00248 void rt_timer_spin(RTIME ns);
00249
00250 int rt_timer_set_mode(RTIME nstick);
00251
00252 static inline int __deprecated_call__
00253 rt_timer_start(RTIME nstick __attribute__((unused)))
00254 {
00255 return 0;
00256 }
00257
00258 static inline void __deprecated_call__ rt_timer_stop(void)
00259 {
00260 }
00261
00262 #ifdef __cplusplus
00263 }
00264 #endif
00265
00268 #endif