00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _RTAI_NUCLEUS_PIPE_H
00021 #define _RTAI_NUCLEUS_PIPE_H
00022
00023 #define XNPIPE_NDEVS CONFIG_RTAI_OPT_PIPE_NRDEV
00024 #define XNPIPE_DEV_MAJOR 150
00025
00026 #define XNPIPE_IOCTL_BASE 'p'
00027 #define XNPIPEIOC_GET_NRDEV _IOW(XNPIPE_IOCTL_BASE,0,int)
00028 #define XNPIPEIOC_FLUSH _IO(XNPIPE_IOCTL_BASE,1)
00029
00030 #define XNPIPE_NORMAL 0x0
00031 #define XNPIPE_URGENT 0x1
00032
00033 #ifdef __KERNEL__
00034
00035 #include <nucleus/queue.h>
00036 #include <nucleus/synch.h>
00037 #include <nucleus/thread.h>
00038 #include <linux/types.h>
00039 #include <linux/poll.h>
00040
00041 #define XNPIPE_WAIT 0x0
00042 #define XNPIPE_NOWAIT 0x1
00043
00044 #define XNPIPE_KERN_CONN 0x1
00045 #define XNPIPE_USER_CONN 0x2
00046 #define XNPIPE_USER_SIGIO 0x4
00047 #define XNPIPE_USER_WREAD 0x08
00048 #define XNPIPE_USER_WREAD_READY 0x10
00049
00050 #define XNPIPE_USER_WMASK \
00051 (XNPIPE_USER_WREAD)
00052
00053 #define XNPIPE_USER_WREADY \
00054 (XNPIPE_USER_WREAD_READY)
00055
00056 typedef struct xnpipe_mh {
00057
00058 xnholder_t link;
00059 unsigned size;
00060
00061 } xnpipe_mh_t;
00062
00063 static inline xnpipe_mh_t *link2mh (xnholder_t *laddr)
00064 {
00065 return laddr ? ((xnpipe_mh_t *)(((char *)laddr) - (int)(&((xnpipe_mh_t *)0)->link))) : 0;
00066 }
00067
00068 typedef int xnpipe_io_handler(int minor,
00069 struct xnpipe_mh *mh,
00070 int onerror,
00071 void *cookie);
00072
00073 typedef int xnpipe_session_handler(int minor,
00074 void *cookie);
00075
00076 typedef void *xnpipe_alloc_handler(int minor,
00077 size_t size,
00078 void *cookie);
00079 typedef struct xnpipe_state {
00080
00081 xnholder_t slink;
00082 xnholder_t alink;
00083 #define link2xnpipe(laddr,link) \
00084 ((struct xnpipe_state *)(((char *)laddr) - (int)(&((struct xnpipe_state *)0)->link)))
00085
00086 xnqueue_t inq;
00087 xnqueue_t outq;
00088 xnpipe_io_handler *output_handler;
00089 xnpipe_io_handler *input_handler;
00090 xnpipe_alloc_handler *alloc_handler;
00091 xnsynch_t synchbase;
00092 void *cookie;
00093
00094
00095 xnflags_t status;
00096 struct fasync_struct *asyncq;
00097 wait_queue_head_t readq;
00098 unsigned int readw;
00099 size_t ionrd;
00100
00101 } xnpipe_state_t;
00102
00103 extern xnpipe_state_t xnpipe_states[];
00104
00105 #define xnminor_from_state(s) (s - xnpipe_states)
00106
00107 #ifdef __cplusplus
00108 extern "C" {
00109 #endif
00110
00111 int xnpipe_mount(void);
00112
00113 void xnpipe_umount(void);
00114
00115
00116
00117 void xnpipe_setup(xnpipe_session_handler *open_handler,
00118 xnpipe_session_handler *close_handler);
00119
00120 int xnpipe_connect(int minor,
00121 xnpipe_io_handler *output_handler,
00122 xnpipe_io_handler *input_handler,
00123 xnpipe_alloc_handler *alloc_handler,
00124 void *cookie);
00125
00126 int xnpipe_disconnect(int minor);
00127
00128 ssize_t xnpipe_send(int minor,
00129 struct xnpipe_mh *mh,
00130 size_t size,
00131 int flags);
00132
00133 ssize_t xnpipe_recv(int minor,
00134 struct xnpipe_mh **pmh,
00135 xnticks_t timeout);
00136
00137 int xnpipe_inquire(int minor);
00138
00139 #ifdef __cplusplus
00140 }
00141 #endif
00142
00143 static inline xnholder_t *xnpipe_m_link(xnpipe_mh_t *mh)
00144 {
00145 return &mh->link;
00146 }
00147
00148 static inline char *xnpipe_m_data(xnpipe_mh_t *mh)
00149 {
00150 return (char *)(mh + 1);
00151 }
00152
00153 #define xnpipe_m_size(mh) ((mh)->size)
00154
00155 #endif
00156
00157 #endif