Xenomai API  2.5.6.1
include/native/alarm.h
Go to the documentation of this file.
00001 
00022 #ifndef _XENO_ALARM_H
00023 #define _XENO_ALARM_H
00024 
00025 #include <native/types.h>
00026 
00027 typedef struct rt_alarm_info {
00028 
00029     RTIME expiration;           /* !< Expiration date. */
00030 
00031     unsigned long expiries;     /* !< Number of expiries. */
00032 
00033     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00034 
00035 } RT_ALARM_INFO;
00036 
00037 typedef struct rt_alarm_placeholder {
00038     xnhandle_t opaque;
00039 } RT_ALARM_PLACEHOLDER;
00040 
00041 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00042 
00043 #include <nucleus/timer.h>
00044 #include <nucleus/synch.h>
00045 #include <native/ppd.h>
00046 
00047 #define XENO_ALARM_MAGIC 0x55550909
00048 
00049 typedef struct rt_alarm {
00050 
00051     unsigned magic;   /* !< Magic code - must be first */
00052 
00053     xntimer_t timer_base; /* !< Base timer object. */
00054 
00055     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00056 
00057     rt_alarm_t handler;         /* !< Alarm handler. */
00058 
00059     void *cookie;               /* !< Opaque cookie. */
00060 
00061     unsigned long expiries;     /* !< Number of expiries. */
00062 
00063 #ifdef CONFIG_XENO_OPT_PERVASIVE
00064     pid_t cpid;                 /* !< Creator's pid. */
00065 
00066     xnsynch_t synch_base;       /* !< Synch. base for user-space tasks. */
00067 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00068 
00069     xnholder_t rlink;           /* !< Link in resource queue. */
00070 
00071 #define rlink2alarm(ln) container_of(ln, RT_ALARM, rlink)
00072 
00073     xnqueue_t *rqueue;          /* !< Backpointer to resource queue. */
00074 
00075     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00076 
00077 } RT_ALARM;
00078 
00079 #ifdef __cplusplus
00080 extern "C" {
00081 #endif
00082 
00083 #ifdef CONFIG_XENO_OPT_NATIVE_ALARM
00084 
00085 int __native_alarm_pkg_init(void);
00086 
00087 void __native_alarm_pkg_cleanup(void);
00088 
00089 static inline void __native_alarm_flush_rq(xnqueue_t *rq)
00090 {
00091         xeno_flush_rq(RT_ALARM, rq, alarm);
00092 }
00093 
00094 #else /* !CONFIG_XENO_OPT_NATIVE_ALARM */
00095 
00096 #define __native_alarm_pkg_init()               ({ 0; })
00097 #define __native_alarm_pkg_cleanup()            do { } while(0)
00098 #define __native_alarm_flush_rq(rq)             do { } while(0)
00099 
00100 #endif /* !CONFIG_XENO_OPT_NATIVE_ALARM */
00101 
00102 int rt_alarm_create(RT_ALARM *alarm,
00103                     const char *name,
00104                     rt_alarm_t handler,
00105                     void *cookie);
00106 
00107 #ifdef CONFIG_XENO_OPT_PERVASIVE
00108 
00109 void rt_alarm_handler(RT_ALARM *alarm,
00110                       void *cookie);
00111 
00112 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00113 
00114 #ifdef __cplusplus
00115 }
00116 #endif
00117 
00118 #else /* !(__KERNEL__ || __XENO_SIM__) */
00119 
00120 typedef RT_ALARM_PLACEHOLDER RT_ALARM;
00121 
00122 #ifdef __cplusplus
00123 extern "C" {
00124 #endif
00125 
00126 int rt_alarm_create(RT_ALARM *alarm,
00127                     const char *name);
00128 
00129 int rt_alarm_wait(RT_ALARM *alarm);
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 
00135 /* No binding for alarms. */
00136 
00137 #endif /* __KERNEL__ || __XENO_SIM__ */
00138 
00139 #ifdef __cplusplus
00140 extern "C" {
00141 #endif
00142 
00143 /* Public interface. */
00144 
00145 int rt_alarm_delete(RT_ALARM *alarm);
00146 
00147 int rt_alarm_start(RT_ALARM *alarm,
00148                    RTIME value,
00149                    RTIME interval);
00150 
00151 int rt_alarm_stop(RT_ALARM *alarm);
00152 
00153 int rt_alarm_inquire(RT_ALARM *alarm,
00154                      RT_ALARM_INFO *info);
00155 
00156 #ifdef __cplusplus
00157 }
00158 #endif
00159 
00160 #endif /* !_XENO_ALARM_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines