Xenomai API  2.6.5
alarm.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_ALARM_H
23 #define _XENO_ALARM_H
24 
25 #include <native/types.h>
26 
27 typedef struct rt_alarm_info {
28 
29  RTIME expiration; /* !< Expiration date. */
30 
31  unsigned long expiries; /* !< Number of expiries. */
32 
33  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
34 
35 } RT_ALARM_INFO;
36 
37 typedef struct rt_alarm_placeholder {
38  xnhandle_t opaque;
39 } RT_ALARM_PLACEHOLDER;
40 
41 #if defined(__KERNEL__) || defined(__XENO_SIM__)
42 
43 #include <nucleus/timer.h>
44 #include <nucleus/synch.h>
45 #include <native/ppd.h>
46 
47 #define XENO_ALARM_MAGIC 0x55550909
48 
49 typedef struct rt_alarm {
50 
51  unsigned magic; /* !< Magic code - must be first */
52 
53  xntimer_t timer_base; /* !< Base timer object. */
54 
55  xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */
56 
57  rt_alarm_t handler; /* !< Alarm handler. */
58 
59  void *cookie; /* !< Opaque cookie. */
60 
61  unsigned long expiries; /* !< Number of expiries. */
62 
63 #ifdef CONFIG_XENO_OPT_PERVASIVE
64  pid_t cpid; /* !< Creator's pid. */
65 
66  xnsynch_t synch_base; /* !< Synch. base for user-space tasks. */
67 #endif /* CONFIG_XENO_OPT_PERVASIVE */
68 
69  xnholder_t rlink; /* !< Link in resource queue. */
70 
71 #define rlink2alarm(ln) container_of(ln, RT_ALARM, rlink)
72 
73  xnqueue_t *rqueue; /* !< Backpointer to resource queue. */
74 
75  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
76 
77 } RT_ALARM;
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 #ifdef CONFIG_XENO_OPT_NATIVE_ALARM
84 
85 int __native_alarm_pkg_init(void);
86 
87 void __native_alarm_pkg_cleanup(void);
88 
89 static inline void __native_alarm_flush_rq(xnqueue_t *rq)
90 {
91  xeno_flush_rq(RT_ALARM, rq, alarm);
92 }
93 
94 #else /* !CONFIG_XENO_OPT_NATIVE_ALARM */
95 
96 #define __native_alarm_pkg_init() ({ 0; })
97 #define __native_alarm_pkg_cleanup() do { } while(0)
98 #define __native_alarm_flush_rq(rq) do { } while(0)
99 
100 #endif /* !CONFIG_XENO_OPT_NATIVE_ALARM */
101 
102 int rt_alarm_create(RT_ALARM *alarm,
103  const char *name,
104  rt_alarm_t handler,
105  void *cookie);
106 
107 #ifdef CONFIG_XENO_OPT_PERVASIVE
108 
109 void rt_alarm_handler(RT_ALARM *alarm,
110  void *cookie);
111 
112 #endif /* CONFIG_XENO_OPT_PERVASIVE */
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #else /* !(__KERNEL__ || __XENO_SIM__) */
119 
120 typedef RT_ALARM_PLACEHOLDER RT_ALARM;
121 
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 
126 int rt_alarm_create(RT_ALARM *alarm,
127  const char *name);
128 
129 int rt_alarm_wait(RT_ALARM *alarm);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 /* No binding for alarms. */
136 
137 #endif /* __KERNEL__ || __XENO_SIM__ */
138 
139 #ifdef __cplusplus
140 extern "C" {
141 #endif
142 
143 /* Public interface. */
144 
145 int rt_alarm_delete(RT_ALARM *alarm);
146 
147 int rt_alarm_start(RT_ALARM *alarm,
148  RTIME value,
149  RTIME interval);
150 
151 int rt_alarm_stop(RT_ALARM *alarm);
152 
153 int rt_alarm_inquire(RT_ALARM *alarm,
154  RT_ALARM_INFO *info);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* !_XENO_ALARM_H */
int rt_alarm_stop(RT_ALARM *alarm)
Stop an alarm.
Definition: alarm.c:47
int rt_alarm_inquire(RT_ALARM *alarm, RT_ALARM_INFO *info)
Inquire about an alarm.
Definition: alarm.c:52
int rt_alarm_wait(RT_ALARM *alarm)
Wait for the next alarm shot.
Definition: alarm.c:35
This file is part of the Xenomai project.
int rt_alarm_create(RT_ALARM *alarm, const char *name, rt_alarm_t handler, void *cookie)
Create an alarm object from kernel space.
Definition: alarm.c:229
int rt_alarm_start(RT_ALARM *alarm, RTIME value, RTIME interval)
Start an alarm.
Definition: alarm.c:40
int rt_alarm_delete(RT_ALARM *alarm)
Delete an alarm.
Definition: alarm.c:30
This file is part of the Xenomai project.