include/native/intr.h

Go to the documentation of this file.
00001 
00022 #ifndef _XENO_INTR_H
00023 #define _XENO_INTR_H
00024 
00025 #include <nucleus/synch.h>
00026 #include <nucleus/intr.h>
00027 #include <native/types.h>
00028 
00029 /* Creation flag. */
00030 #define I_NOAUTOENA  XN_ISR_NOENABLE  /* Do not auto-enable interrupt channel
00031                                         after each IRQ. */
00032 #define I_PROPAGATE  XN_ISR_PROPAGATE /* Propagate IRQs down the
00033                                        pipeline after processing; IOW,
00034                                        pass them to Linux. */
00035 typedef struct rt_intr_info {
00036 
00037     unsigned irq;       /* !< Interrupt request number. */
00038 
00039     unsigned long hits; /* !< Number of receipts (since attachment), 0 if
00040                               statistics support is disable in the nucleus. */
00041 
00042     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00043 
00044 } RT_INTR_INFO;
00045 
00046 typedef struct rt_intr_placeholder {
00047     xnhandle_t opaque;
00048 } RT_INTR_PLACEHOLDER;
00049 
00050 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00051 
00052 #define XENO_INTR_MAGIC 0x55550a0a
00053 
00054 /* Creation flags. */
00055 #define I_SHARED        XN_ISR_SHARED
00056 #define I_EDGE          XN_ISR_EDGE
00057 
00058 #define RT_INTR_HANDLED         XN_ISR_HANDLED
00059 #define RT_INTR_NONE            XN_ISR_NONE
00060 #define RT_INTR_PROPAGATE       XN_ISR_PROPAGATE
00061 #define RT_INTR_NOENABLE        XN_ISR_NOENABLE
00062 
00063 #define I_DESC(xintr)  ((RT_INTR *)(xintr)->cookie)
00064 
00065 typedef struct rt_intr {
00066 
00067     unsigned magic;   /* !< Magic code - must be first */
00068 
00069     xnholder_t link;    /* !< Link in global interrupt queue. */
00070 
00071 #define link2intr(laddr) \
00072 ((RT_INTR *)(((char *)laddr) - (int)(&((RT_INTR *)0)->link)))
00073 
00074     xnintr_t intr_base;   /* !< Base interrupt object. */
00075 
00076     void *private_data; /* !< Private user-defined data. */
00077 
00078     xnhandle_t handle;  /* !< Handle in registry -- zero if unregistered. */
00079 
00080     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00081 
00082 #if defined(__KERNEL__) && defined(CONFIG_XENO_OPT_PERVASIVE)
00083 
00084     int mode;           /* !< Interrupt control mode. */
00085 
00086     int pending;        /* !< Pending hits to process. */
00087 
00088     xnsynch_t synch_base; /* !< Base synchronization object. */
00089 
00090     pid_t cpid;         /* !< Creator's pid. */
00091 
00092 #endif /* __KERNEL__ && CONFIG_XENO_OPT_PERVASIVE */
00093 
00094 } RT_INTR;
00095 
00096 #define rt_intr_save(x)    splhigh(x)
00097 #define rt_intr_restore(x) splexit(x)
00098 #define rt_intr_unmask()   splnone()
00099 #define rt_intr_flags(x)   splget(x)
00100 
00101 #ifdef __cplusplus
00102 extern "C" {
00103 #endif
00104 
00105 int __native_intr_pkg_init(void);
00106 
00107 void __native_intr_pkg_cleanup(void);
00108 
00109 int rt_intr_create(RT_INTR *intr,
00110                    const char *name,
00111                    unsigned irq,
00112                    rt_isr_t isr,
00113                    rt_iack_t iack,
00114                    int mode);
00115 
00116 #ifdef CONFIG_XENO_OPT_PERVASIVE
00117 int rt_intr_handler(xnintr_t *cookie);
00118 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00119 
00120 #ifdef __cplusplus
00121 }
00122 #endif
00123 
00124 #else /* !(__KERNEL__ || __XENO_SIM__) */
00125 
00126 typedef RT_INTR_PLACEHOLDER RT_INTR;
00127 
00128 #ifdef __cplusplus
00129 extern "C" {
00130 #endif
00131 
00132 int rt_intr_bind(RT_INTR *intr,
00133                  const char *name,
00134                  RTIME timeout);
00135 
00136 static inline int rt_intr_unbind (RT_INTR *intr)
00137 
00138 {
00139     intr->opaque = XN_NO_HANDLE;
00140     return 0;
00141 }
00142 
00143 int rt_intr_create(RT_INTR *intr,
00144                    const char *name,
00145                    unsigned irq,
00146                    int mode);
00147 
00148 int rt_intr_wait(RT_INTR *intr,
00149                  RTIME timeout);
00150 
00151 #ifdef __cplusplus
00152 }
00153 #endif
00154 
00155 #endif /* __KERNEL__ || __XENO_SIM__ */
00156 
00157 #ifdef __cplusplus
00158 extern "C" {
00159 #endif
00160 
00161 /* Public interface. */
00162 
00163 int rt_intr_delete(RT_INTR *intr);
00164 
00165 int rt_intr_enable(RT_INTR *intr);
00166 
00167 int rt_intr_disable(RT_INTR *intr);
00168 
00169 int rt_intr_inquire(RT_INTR *intr,
00170                     RT_INTR_INFO *info);
00171 
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175 
00176 #endif /* !_XENO_INTR_H */

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