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 <nucleus/timer.h>
00026 #include <nucleus/synch.h>
00027 #include <native/types.h>
00028 
00029 typedef struct rt_alarm_info {
00030 
00031     RTIME expiration;           /* !< Expiration date. */
00032 
00033     unsigned long expiries;     /* !< Number of expiries. */
00034 
00035     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00036 
00037 } RT_ALARM_INFO;
00038 
00039 typedef struct rt_alarm_placeholder {
00040     xnhandle_t opaque;
00041 } RT_ALARM_PLACEHOLDER;
00042 
00043 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00044 
00045 #define XENO_ALARM_MAGIC 0x55550909
00046 
00047 typedef struct rt_alarm {
00048 
00049     unsigned magic;   /* !< Magic code - must be first */
00050 
00051     xntimer_t timer_base; /* !< Base timer object. */
00052 
00053     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00054 
00055     rt_alarm_t handler;         /* !< Alarm handler. */
00056     
00057     void *cookie;               /* !< Opaque cookie. */
00058 
00059     unsigned long expiries;     /* !< Number of expiries. */
00060 
00061 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
00062 
00063     pid_t cpid;                 /* !< Creator's pid. */
00064 
00065     xnsynch_t synch_base;       /* !< Synch. base for user-space tasks. */
00066 
00067 #endif /* __KERNEL__ && CONFIG_XENO_OPT_PERVASIVE */
00068 
00069     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00070 
00071 } RT_ALARM;
00072 
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076 
00077 int __native_alarm_pkg_init(void);
00078 
00079 void __native_alarm_pkg_cleanup(void);
00080 
00081 int rt_alarm_create(RT_ALARM *alarm,
00082                     const char *name,
00083                     rt_alarm_t handler,
00084                     void *cookie);
00085 
00086 #ifdef CONFIG_XENO_OPT_PERVASIVE
00087 
00088 void rt_alarm_handler(RT_ALARM *alarm,
00089                       void *cookie);
00090 
00091 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00092 
00093 #ifdef __cplusplus
00094 }
00095 #endif
00096 
00097 #else /* !(__KERNEL__ || __XENO_SIM__) */
00098 
00099 typedef RT_ALARM_PLACEHOLDER RT_ALARM;
00100 
00101 #ifdef __cplusplus
00102 extern "C" {
00103 #endif
00104 
00105 int rt_alarm_create(RT_ALARM *alarm,
00106                     const char *name);
00107 
00108 int rt_alarm_wait(RT_ALARM *alarm);
00109 
00110 #ifdef __cplusplus
00111 }
00112 #endif
00113 
00114 /* No binding for alarms. */
00115 
00116 #endif /* __KERNEL__ || __XENO_SIM__ */
00117 
00118 #ifdef __cplusplus
00119 extern "C" {
00120 #endif
00121 
00122 /* Public interface. */
00123 
00124 int rt_alarm_delete(RT_ALARM *alarm);
00125 
00126 int rt_alarm_start(RT_ALARM *alarm,
00127                    RTIME value,
00128                    RTIME interval);
00129 
00130 int rt_alarm_stop(RT_ALARM *alarm);
00131 
00132 int rt_alarm_inquire(RT_ALARM *alarm,
00133                      RT_ALARM_INFO *info);
00134 
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138 
00139 #endif /* !_XENO_ALARM_H */

Generated on Mon Dec 25 13:57:10 2006 for Xenomai API by  doxygen 1.4.6