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_KERN_CONN 0x1
00042 #define XNPIPE_USER_CONN 0x2
00043 #define XNPIPE_USER_SIGIO 0x4
00044 #define XNPIPE_USER_WREAD 0x08
00045 #define XNPIPE_USER_WREAD_READY 0x10
00046
00047 #define XNPIPE_USER_WMASK \
00048 (XNPIPE_USER_WREAD)
00049
00050 #define XNPIPE_USER_WREADY \
00051 (XNPIPE_USER_WREAD_READY)
00052
00053 typedef struct xnpipe_mh {
00054
00055 xnholder_t link;
00056 unsigned size;
00057
00058 } xnpipe_mh_t;
00059
00060 static inline xnpipe_mh_t *link2mh (xnholder_t *laddr)
00061 {
00062 return laddr ? ((xnpipe_mh_t *)(((char *)laddr) - (int)(&((xnpipe_mh_t *)0)->link))) : 0;
00063 }
00064
00065 typedef int xnpipe_io_handler(int minor,
00066 struct xnpipe_mh *mh,
00067 int retval,
00068 void *cookie);
00069
00070 typedef int xnpipe_session_handler(int minor,
00071 void *cookie);
00072
00073 typedef void *xnpipe_alloc_handler(int minor,
00074 size_t size,
00075 void *cookie);
00076 typedef struct xnpipe_state {
00077
00078 xnholder_t slink;
00079 xnholder_t alink;
00080 #define link2xnpipe(laddr,link) \
00081 ((struct xnpipe_state *)(((char *)laddr) - (int)(&((struct xnpipe_state *)0)->link)))
00082
00083 xnqueue_t inq;
00084 xnqueue_t outq;
00085 xnpipe_io_handler *output_handler;
00086 xnpipe_io_handler *input_handler;
00087 xnpipe_alloc_handler *alloc_handler;
00088 xnsynch_t synchbase;
00089 void *cookie;
00090
00091
00092 xnflags_t status;
00093 struct fasync_struct *asyncq;
00094 wait_queue_head_t readq;
00095 unsigned int readw;
00096 size_t ionrd;
00097
00098 } xnpipe_state_t;
00099
00100 extern xnpipe_state_t xnpipe_states[];
00101
00102 #define xnminor_from_state(s) (s - xnpipe_states)
00103
00104 #ifdef __cplusplus
00105 extern "C" {
00106 #endif
00107
00108 int xnpipe_mount(void);
00109
00110 void xnpipe_umount(void);
00111
00112
00113
00114 void xnpipe_setup(xnpipe_session_handler *open_handler,
00115 xnpipe_session_handler *close_handler);
00116
00117 int xnpipe_connect(int minor,
00118 xnpipe_io_handler *output_handler,
00119 xnpipe_io_handler *input_handler,
00120 xnpipe_alloc_handler *alloc_handler,
00121 void *cookie);
00122
00123 int xnpipe_disconnect(int minor);
00124
00125 ssize_t xnpipe_send(int minor,
00126 struct xnpipe_mh *mh,
00127 size_t size,
00128 int flags);
00129
00130 ssize_t xnpipe_recv(int minor,
00131 struct xnpipe_mh **pmh,
00132 xnticks_t timeout);
00133
00134 int xnpipe_inquire(int minor);
00135
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139
00140 static inline xnholder_t *xnpipe_m_link(xnpipe_mh_t *mh)
00141 {
00142 return &mh->link;
00143 }
00144
00145 static inline char *xnpipe_m_data(xnpipe_mh_t *mh)
00146 {
00147 return (char *)(mh + 1);
00148 }
00149
00150 #define xnpipe_m_size(mh) ((mh)->size)
00151
00152 #endif
00153
00154 #endif