00001 
00022 #ifndef _XENO_INTR_H
00023 #define _XENO_INTR_H
00024 
00025 #include <nucleus/intr.h>
00026 #include <native/types.h>
00027 
00028 
00029 #define I_NOAUTOENA  XN_ISR_NOENABLE  
00030 
00031 #define I_PROPAGATE  XN_ISR_PROPAGATE 
00032 
00033 
00034 typedef struct rt_intr_info {
00035 
00036     unsigned irq;       
00037 
00038     unsigned long hits; 
00039 
00040 
00041     char name[XNOBJECT_NAME_LEN]; 
00042 
00043 } RT_INTR_INFO;
00044 
00045 typedef struct rt_intr_placeholder {
00046     xnhandle_t opaque;
00047 } RT_INTR_PLACEHOLDER;
00048 
00049 #if (defined(__KERNEL__) || defined(__XENO_SIM__)) && !defined(DOXYGEN_CPP)
00050 
00051 #include <nucleus/synch.h>
00052 #include <native/ppd.h>
00053 
00054 #define XENO_INTR_MAGIC 0x55550a0a
00055 
00056 
00057 #define I_SHARED        XN_ISR_SHARED
00058 #define I_EDGE          XN_ISR_EDGE
00059 
00060 #define RT_INTR_HANDLED         XN_ISR_HANDLED
00061 #define RT_INTR_NONE            XN_ISR_NONE
00062 #define RT_INTR_PROPAGATE       XN_ISR_PROPAGATE
00063 #define RT_INTR_NOENABLE        XN_ISR_NOENABLE
00064 
00065 #define I_DESC(xintr)  ((RT_INTR *)(xintr)->cookie)
00066 
00067 typedef struct rt_intr {
00068 
00069     unsigned magic;             
00070 
00071     xnintr_t intr_base;         
00072 
00073     void *private_data;         
00074 
00075     xnhandle_t handle;          
00076 
00077     char name[XNOBJECT_NAME_LEN]; 
00078 
00079 #ifdef CONFIG_XENO_OPT_PERVASIVE
00080     int mode;                   
00081 
00082     int pending;                
00083 
00084     xnsynch_t synch_base;       
00085 
00086     pid_t cpid;                 
00087 #endif 
00088 
00089     xnholder_t rlink;           
00090 
00091 #define rlink2intr(ln)          container_of(ln, RT_INTR, rlink)
00092 
00093     xnqueue_t *rqueue;          
00094 
00095 } RT_INTR;
00096 
00097 #define rt_intr_save(x)    splhigh(x)
00098 #define rt_intr_restore(x) splexit(x)
00099 #define rt_intr_unmask()   splnone()
00100 #define rt_intr_flags(x)   splget(x)
00101 
00102 #ifdef __cplusplus
00103 extern "C" {
00104 #endif
00105 
00106 #ifdef CONFIG_XENO_OPT_NATIVE_INTR
00107 
00108 int __native_intr_pkg_init(void);
00109 
00110 void __native_intr_pkg_cleanup(void);
00111 
00112 static inline void __native_intr_flush_rq(xnqueue_t *rq)
00113 {
00114         xeno_flush_rq(RT_INTR, rq, intr);
00115 }
00116 
00117 #else 
00118 
00119 #define __native_intr_pkg_init()                ({ 0; })
00120 #define __native_intr_pkg_cleanup()             do { } while(0)
00121 #define __native_intr_flush_rq(rq)              do { } while(0)
00122 
00123 #endif 
00124 
00125 int rt_intr_create(RT_INTR *intr,
00126                    const char *name,
00127                    unsigned irq,
00128                    rt_isr_t isr,
00129                    rt_iack_t iack,
00130                    int mode);
00131 
00132 #ifdef CONFIG_XENO_OPT_PERVASIVE
00133 int rt_intr_handler(xnintr_t *cookie);
00134 #endif 
00135 
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139 
00140 #else 
00141 
00142 typedef RT_INTR_PLACEHOLDER RT_INTR;
00143 
00144 #ifdef __cplusplus
00145 extern "C" {
00146 #endif
00147 
00148 int rt_intr_bind(RT_INTR *intr,
00149                  const char *name,
00150                  RTIME timeout);
00151 
00152 static inline int rt_intr_unbind (RT_INTR *intr)
00153 
00154 {
00155     intr->opaque = XN_NO_HANDLE;
00156     return 0;
00157 }
00158 
00159 int rt_intr_create(RT_INTR *intr,
00160                    const char *name,
00161                    unsigned irq,
00162                    int mode);
00163 
00164 int rt_intr_wait(RT_INTR *intr,
00165                  RTIME timeout);
00166 
00167 #ifdef __cplusplus
00168 }
00169 #endif
00170 
00171 #endif 
00172 
00173 #ifdef __cplusplus
00174 extern "C" {
00175 #endif
00176 
00177 
00178 
00179 int rt_intr_delete(RT_INTR *intr);
00180 
00181 int rt_intr_enable(RT_INTR *intr);
00182 
00183 int rt_intr_disable(RT_INTR *intr);
00184 
00185 int rt_intr_inquire(RT_INTR *intr,
00186                     RT_INTR_INFO *info);
00187 
00188 #ifdef __cplusplus
00189 }
00190 #endif
00191 
00192 #endif