Xenomai API  2.6.5
intr.h
Go to the documentation of this file.
1 
22 #ifndef _XENO_INTR_H
23 #define _XENO_INTR_H
24 
25 #include <nucleus/intr.h>
26 #include <native/types.h>
27 
28 /* Creation flag. */
29 #define I_NOAUTOENA XN_ISR_NOENABLE /* Do not auto-enable interrupt channel
30  after each IRQ. */
31 #define I_PROPAGATE XN_ISR_PROPAGATE /* Propagate IRQs down the
32  pipeline after processing; IOW,
33  pass them to Linux. */
34 typedef struct rt_intr_info {
35 
36  unsigned irq; /* !< Interrupt request number. */
37 
38  unsigned long hits; /* !< Number of receipts (since attachment), 0 if
39  statistics support is disable in the nucleus. */
40 
41  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
42 
43 } RT_INTR_INFO;
44 
45 typedef struct rt_intr_placeholder {
46  xnhandle_t opaque;
47 } RT_INTR_PLACEHOLDER;
48 
49 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
50 
51 #include <nucleus/synch.h>
52 #include <native/ppd.h>
53 
54 #define XENO_INTR_MAGIC 0x55550a0a
55 
56 /* Creation flags. */
57 #define I_SHARED XN_ISR_SHARED
58 #define I_EDGE XN_ISR_EDGE
59 
60 #define RT_INTR_HANDLED XN_ISR_HANDLED
61 #define RT_INTR_NONE XN_ISR_NONE
62 #define RT_INTR_PROPAGATE XN_ISR_PROPAGATE
63 #define RT_INTR_NOENABLE XN_ISR_NOENABLE
64 
65 #define I_DESC(xintr) ((RT_INTR *)(xintr)->cookie)
66 
67 typedef struct rt_intr {
68 
69  unsigned magic; /* !< Magic code - must be first */
70 
71  xnintr_t intr_base; /* !< Base interrupt object. */
72 
73  void *private_data; /* !< Private user-defined data. */
74 
75  xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */
76 
77  char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
78 
79 #ifdef CONFIG_XENO_OPT_PERVASIVE
80  int mode; /* !< Interrupt control mode. */
81 
82  int pending; /* !< Pending hits to process. */
83 
84  xnsynch_t synch_base; /* !< Base synchronization object. */
85 
86  pid_t cpid; /* !< Creator's pid. */
87 #endif /* CONFIG_XENO_OPT_PERVASIVE */
88 
89  xnholder_t rlink; /* !< Link in resource queue. */
90 
91 #define rlink2intr(ln) container_of(ln, RT_INTR, rlink)
92 
93  xnqueue_t *rqueue; /* !< Backpointer to resource queue. */
94 
95 } RT_INTR;
96 
97 #define rt_intr_save(x) splhigh(x)
98 #define rt_intr_restore(x) splexit(x)
99 #define rt_intr_unmask() splnone()
100 #define rt_intr_flags(x) splget(x)
101 
102 #ifdef __cplusplus
103 extern "C" {
104 #endif
105 
106 #ifdef CONFIG_XENO_OPT_NATIVE_INTR
107 
108 int __native_intr_pkg_init(void);
109 
110 void __native_intr_pkg_cleanup(void);
111 
112 static inline void __native_intr_flush_rq(xnqueue_t *rq)
113 {
114  xeno_flush_rq(RT_INTR, rq, intr);
115 }
116 
117 #else /* !CONFIG_XENO_OPT_NATIVE_INTR */
118 
119 #define __native_intr_pkg_init() ({ 0; })
120 #define __native_intr_pkg_cleanup() do { } while(0)
121 #define __native_intr_flush_rq(rq) do { } while(0)
122 
123 #endif /* !CONFIG_XENO_OPT_NATIVE_INTR */
124 
125 int rt_intr_create(RT_INTR *intr,
126  const char *name,
127  unsigned irq,
128  rt_isr_t isr,
129  rt_iack_t iack,
130  int mode);
131 
132 #ifdef CONFIG_XENO_OPT_PERVASIVE
133 int rt_intr_handler(xnintr_t *cookie);
134 #endif /* CONFIG_XENO_OPT_PERVASIVE */
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #else /* !(__KERNEL__ || __XENO_SIM__) */
141 
142 typedef RT_INTR_PLACEHOLDER RT_INTR;
143 
144 #ifdef __cplusplus
145 extern "C" {
146 #endif
147 
148 int rt_intr_bind(RT_INTR *intr,
149  const char *name,
150  RTIME timeout);
151 
152 static inline int rt_intr_unbind (RT_INTR *intr)
153 
154 {
155  intr->opaque = XN_NO_HANDLE;
156  return 0;
157 }
158 
159 int rt_intr_create(RT_INTR *intr,
160  const char *name,
161  unsigned irq,
162  int mode);
163 
164 int rt_intr_wait(RT_INTR *intr,
165  RTIME timeout);
166 
167 #ifdef __cplusplus
168 }
169 #endif
170 
171 #endif /* __KERNEL__ || __XENO_SIM__ */
172 
173 #ifdef __cplusplus
174 extern "C" {
175 #endif
176 
177 /* Public interface. */
178 
179 int rt_intr_delete(RT_INTR *intr);
180 
181 int rt_intr_enable(RT_INTR *intr);
182 
183 int rt_intr_disable(RT_INTR *intr);
184 
185 int rt_intr_inquire(RT_INTR *intr,
186  RT_INTR_INFO *info);
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif /* !_XENO_INTR_H */
int rt_intr_inquire(RT_INTR *intr, RT_INTR_INFO *info)
Inquire about an interrupt object.
Definition: intr.c:68
static int rt_intr_unbind(RT_INTR *intr)
Unbind from an interrupt object.
Definition: intr.h:152
int rt_intr_bind(RT_INTR *intr, const char *name, RTIME timeout)
Bind to an interrupt object.
Definition: intr.c:33
int rt_intr_enable(RT_INTR *intr)
Enable an interrupt object.
Definition: intr.c:58
int rt_intr_delete(RT_INTR *intr)
Delete an interrupt object.
Definition: intr.c:39
This file is part of the Xenomai project.
int rt_intr_create(RT_INTR *intr, const char *name, unsigned irq, int mode)
Create an interrupt object from user-space.
Definition: intr.c:27
int rt_intr_wait(RT_INTR *intr, RTIME timeout)
Wait for the next interrupt.
Definition: intr.c:44
This file is part of the Xenomai project.
int rt_intr_disable(RT_INTR *intr)
Disable an interrupt object.
Definition: intr.c:63