Xenomai API  2.5.6.1
include/native/event.h
Go to the documentation of this file.
00001 
00022 #ifndef _XENO_EVENT_H
00023 #define _XENO_EVENT_H
00024 
00025 #include <nucleus/synch.h>
00026 #include <native/types.h>
00027 
00028 /* Creation flags. */
00029 #define EV_PRIO  XNSYNCH_PRIO   /* Pend by task priority order. */
00030 #define EV_FIFO  XNSYNCH_FIFO   /* Pend by FIFO order. */
00031 
00032 /* Operation flags. */
00033 #define EV_ANY  0x1     /* Disjunctive wait. */
00034 #define EV_ALL  0x0     /* Conjunctive wait. */
00035 
00036 typedef struct rt_event_info {
00037 
00038     unsigned long value; /* !< Current event group value. */
00039 
00040     int nwaiters;       /* !< Number of pending tasks. */
00041 
00042     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00043 
00044 } RT_EVENT_INFO;
00045 
00046 typedef struct rt_event_placeholder {
00047     xnhandle_t opaque;
00048 } RT_EVENT_PLACEHOLDER;
00049 
00050 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
00051 
00052 #include <native/ppd.h>
00053 
00054 #define XENO_EVENT_MAGIC 0x55550404
00055 
00056 typedef struct rt_event {
00057 
00058     unsigned magic;   /* !< Magic code - must be first */
00059 
00060     xnsynch_t synch_base; /* !< Base synchronization object. */
00061 
00062     unsigned long value; /* !< Event group value. */
00063 
00064     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00065 
00066     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00067 
00068 #ifdef CONFIG_XENO_OPT_PERVASIVE
00069     pid_t cpid;                 /* !< Creator's pid. */
00070 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00071 
00072     xnholder_t rlink;           /* !< Link in resource queue. */
00073 
00074 #define rlink2event(ln) container_of(ln, RT_EVENT, rlink)
00075 
00076     xnqueue_t *rqueue;          /* !< Backpointer to resource queue. */
00077 
00078 } RT_EVENT;
00079 
00080 #ifdef __cplusplus
00081 extern "C" {
00082 #endif
00083 
00084 #ifdef CONFIG_XENO_OPT_NATIVE_EVENT
00085 
00086 int __native_event_pkg_init(void);
00087 
00088 void __native_event_pkg_cleanup(void);
00089 
00090 static inline void __native_event_flush_rq(xnqueue_t *rq)
00091 {
00092         xeno_flush_rq(RT_EVENT, rq, event);
00093 }
00094 
00095 int rt_event_wait_inner(RT_EVENT *event,
00096                         unsigned long mask,
00097                         unsigned long *mask_r,
00098                         int mode, xntmode_t timeout_mode, RTIME timeout);
00099 
00100 #else /* !CONFIG_XENO_OPT_NATIVE_EVENT */
00101 
00102 #define __native_event_pkg_init()               ({ 0; })
00103 #define __native_event_pkg_cleanup()            do { } while(0)
00104 #define __native_event_flush_rq(rq)             do { } while(0)
00105 
00106 #endif /* !CONFIG_XENO_OPT_NATIVE_EVENT */
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif
00111 
00112 #else /* !(__KERNEL__ || __XENO_SIM__) */
00113 
00114 typedef RT_EVENT_PLACEHOLDER RT_EVENT;
00115 
00116 #ifdef __cplusplus
00117 extern "C" {
00118 #endif
00119 
00120 int rt_event_bind(RT_EVENT *event,
00121                   const char *name,
00122                   RTIME timeout);
00123 
00124 static inline int rt_event_unbind (RT_EVENT *event)
00125 
00126 {
00127     event->opaque = XN_NO_HANDLE;
00128     return 0;
00129 }
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 
00135 #endif /* __KERNEL__ || __XENO_SIM__ */
00136 
00137 #ifdef __cplusplus
00138 extern "C" {
00139 #endif
00140 
00141 /* Public interface. */
00142 
00143 int rt_event_create(RT_EVENT *event,
00144                     const char *name,
00145                     unsigned long ivalue,
00146                     int mode);
00147 
00148 int rt_event_delete(RT_EVENT *event);
00149 
00150 int rt_event_signal(RT_EVENT *event,
00151                     unsigned long mask);
00152 
00153 int rt_event_wait(RT_EVENT *event,
00154                   unsigned long mask,
00155                   unsigned long *mask_r,
00156                   int mode,
00157                   RTIME timeout);
00158 
00159 int rt_event_wait_until(RT_EVENT *event,
00160                         unsigned long mask,
00161                         unsigned long *mask_r,
00162                         int mode,
00163                         RTIME timeout);
00164 
00165 int rt_event_clear(RT_EVENT *event,
00166                    unsigned long mask,
00167                    unsigned long *mask_r);
00168 
00169 int rt_event_inquire(RT_EVENT *event,
00170                      RT_EVENT_INFO *info);
00171 
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175 
00176 #endif /* !_XENO_EVENT_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines