Xenomai API
2.5.6.1
|
00001 00022 #ifndef _XENO_PIPE_H 00023 #define _XENO_PIPE_H 00024 00025 #include <nucleus/pipe.h> 00026 #include <nucleus/heap.h> 00027 #include <native/types.h> 00028 00029 /* Operation flags. */ 00030 #define P_NORMAL XNPIPE_NORMAL 00031 #define P_URGENT XNPIPE_URGENT 00032 00033 #define P_MINOR_AUTO XNPIPE_MINOR_AUTO 00034 00035 #define P_EVENT_INPUT 1 00036 #define P_EVENT_OUTPUT 2 00037 #define P_EVENT_CLOSE 3 00038 #define P_EVENT_NOBUF 4 00039 00040 typedef struct rt_pipe_placeholder { 00041 xnhandle_t opaque; 00042 } RT_PIPE_PLACEHOLDER; 00043 00044 #ifdef __KERNEL__ 00045 00046 #include <native/ppd.h> 00047 00048 #define XENO_PIPE_MAGIC 0x55550202 00049 00050 #define P_SYNCWAIT 0 00051 #define P_ATOMIC 1 00052 00053 typedef xnpipe_mh_t RT_PIPE_MSG; 00054 00055 #define P_MSGPTR(msg) xnpipe_m_data(msg) 00056 #define P_MSGSIZE(msg) xnpipe_m_size(msg) 00057 00058 typedef struct rt_pipe { 00059 00060 unsigned magic; /* !< Magic code -- must be first. */ 00061 00062 xnholder_t link; /* !< Link in flush queue. */ 00063 00064 #define link2rtpipe(ln) container_of(ln, RT_PIPE, link) 00065 00066 int minor; /* !< Device minor number. */ 00067 00068 RT_PIPE_MSG *buffer; /* !< Buffer used in byte stream mode. */ 00069 00070 xnheap_t *bufpool; /* !< Current buffer pool. */ 00071 00072 int (*monitor)(struct rt_pipe *pipe, int event, long arg); 00073 00074 xnheap_t privpool; /* !< Private buffer pool. */ 00075 00076 size_t fillsz; /* !< Bytes written to the buffer. */ 00077 00078 u_long status; /* !< Status information. */ 00079 00080 xnhandle_t handle; /* !< Handle in registry -- zero if unregistered. */ 00081 00082 char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */ 00083 00084 #ifdef CONFIG_XENO_OPT_PERVASIVE 00085 pid_t cpid; /* !< Creator's pid. */ 00086 #endif /* CONFIG_XENO_OPT_PERVASIVE */ 00087 00088 xnholder_t rlink; /* !< Link in resource queue. */ 00089 00090 #define rlink2pipe(ln) container_of(ln, RT_PIPE, rlink) 00091 00092 xnqueue_t *rqueue; /* !< Backpointer to resource queue. */ 00093 00094 } RT_PIPE; 00095 00096 #else /* !__KERNEL__ */ 00097 00098 typedef RT_PIPE_PLACEHOLDER RT_PIPE; 00099 00100 #endif /* __KERNEL__ */ 00101 00102 #ifdef __cplusplus 00103 extern "C" { 00104 #endif 00105 00106 /* Public interface. */ 00107 00108 int rt_pipe_create(RT_PIPE *pipe, 00109 const char *name, 00110 int minor, 00111 size_t poolsize); 00112 00113 int rt_pipe_delete(RT_PIPE *pipe); 00114 00115 ssize_t rt_pipe_read(RT_PIPE *pipe, 00116 void *buf, 00117 size_t size, 00118 RTIME timeout); 00119 00120 ssize_t rt_pipe_write(RT_PIPE *pipe, 00121 const void *buf, 00122 size_t size, 00123 int mode); 00124 00125 ssize_t rt_pipe_stream(RT_PIPE *pipe, 00126 const void *buf, 00127 size_t size); 00128 00129 #ifdef __KERNEL__ 00130 00131 ssize_t rt_pipe_receive(RT_PIPE *pipe, 00132 RT_PIPE_MSG **msg, 00133 RTIME timeout); 00134 00135 ssize_t rt_pipe_send(RT_PIPE *pipe, 00136 RT_PIPE_MSG *msg, 00137 size_t size, 00138 int mode); 00139 00140 RT_PIPE_MSG *rt_pipe_alloc(RT_PIPE *pipe, 00141 size_t size); 00142 00143 int rt_pipe_free(RT_PIPE *pipe, 00144 RT_PIPE_MSG *msg); 00145 00146 int rt_pipe_flush(RT_PIPE *pipe, 00147 int mode); 00148 00149 int rt_pipe_monitor(RT_PIPE *pipe, 00150 int (*fn)(RT_PIPE *pipe, int event, long arg)); 00151 00152 #else /* !__KERNEL__ */ 00153 00154 int rt_pipe_bind(RT_PIPE *pipe, 00155 const char *name, 00156 RTIME timeout); 00157 00158 static inline int rt_pipe_unbind(RT_PIPE *pipe) 00159 { 00160 pipe->opaque = XN_NO_HANDLE; 00161 return 0; 00162 } 00163 00164 #endif /* __KERNEL__ */ 00165 00166 #ifdef CONFIG_XENO_OPT_NATIVE_PIPE 00167 00168 int __native_pipe_pkg_init(void); 00169 00170 void __native_pipe_pkg_cleanup(void); 00171 00172 static inline void __native_pipe_flush_rq(xnqueue_t *rq) 00173 { 00174 xeno_flush_rq_norelease(RT_PIPE, rq, pipe); 00175 } 00176 00177 #else /* !CONFIG_XENO_OPT_NATIVE_PIPE */ 00178 00179 #define __native_pipe_pkg_init() ({ 0; }) 00180 #define __native_pipe_pkg_cleanup() do { } while(0) 00181 #define __native_pipe_flush_rq(rq) do { } while(0) 00182 00183 #endif /* !CONFIG_XENO_OPT_NATIVE_PIPE */ 00184 00185 #ifdef __cplusplus 00186 } 00187 #endif 00188 00189 #endif /* !_XENO_PIPE_H */