00001
00022 #ifndef _XENO_TIMER_H
00023 #define _XENO_TIMER_H
00024
00025 #include <native/types.h>
00026
00027 #define TM_ONESHOT XN_APERIODIC_TICK
00028
00029 typedef struct rt_timer_info {
00030
00031 RTIME period;
00032 RTIME date;
00033 RTIME tsc;
00034
00035 } RT_TIMER_INFO;
00036
00037 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00038
00039 #include <nucleus/timer.h>
00040
00041 extern xntbase_t *__native_tbase;
00042
00043 #endif
00044
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048
00049 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00050 static inline SRTIME rt_timer_ns2tsc(SRTIME ns)
00051 {
00052 return xnarch_ns_to_tsc(ns);
00053 }
00054
00055 static inline SRTIME rt_timer_tsc2ns(SRTIME ticks)
00056 {
00057 return xnarch_tsc_to_ns(ticks);
00058 }
00059
00060 static inline RTIME rt_timer_tsc(void)
00061 {
00062 return xnarch_get_cpu_tsc();
00063 }
00064
00065 static inline RTIME rt_timer_read(void)
00066 {
00067 return xntbase_get_time(__native_tbase);
00068 }
00069
00070 static inline SRTIME rt_timer_ns2ticks(SRTIME ns)
00071 {
00072 return xntbase_ns2ticks(__native_tbase, ns);
00073 }
00074
00075 static inline SRTIME rt_timer_ticks2ns(SRTIME ticks)
00076 {
00077 return xntbase_ticks2ns(__native_tbase, ticks);
00078 }
00079
00080 #else
00081
00105 SRTIME rt_timer_ns2tsc(SRTIME ns);
00106
00130 SRTIME rt_timer_tsc2ns(SRTIME ticks);
00131
00153 RTIME rt_timer_tsc(void);
00154
00179 RTIME rt_timer_read(void);
00180
00204 SRTIME rt_timer_ns2ticks(SRTIME ns);
00205
00229 SRTIME rt_timer_ticks2ns(SRTIME ticks);
00230
00231 #endif
00232
00233 int rt_timer_inquire(RT_TIMER_INFO *info);
00234
00235 RTIME rt_timer_read(void);
00236
00237 void rt_timer_spin(RTIME ns);
00238
00239 int rt_timer_set_mode(RTIME nstick);
00240
00241 static inline int __deprecated_call__
00242 rt_timer_start(RTIME nstick __attribute__((unused)))
00243 {
00244 return 0;
00245 }
00246
00247 static inline void __deprecated_call__ rt_timer_stop(void)
00248 {
00249 }
00250
00251 #ifdef __cplusplus
00252 }
00253 #endif
00254
00255 #endif