pipe.h

Go to the documentation of this file.
00001 
00022 #ifndef _RTAI_PIPE_H
00023 #define _RTAI_PIPE_H
00024 
00025 #include <nucleus/pipe.h>
00026 #include <rtai/types.h>
00027 
00028 /* Operation flags. */
00029 #define P_NORMAL  XNPIPE_NORMAL
00030 #define P_URGENT  XNPIPE_URGENT
00031 
00032 typedef struct rt_pipe_placeholder {
00033     rt_handle_t opaque;
00034 } RT_PIPE_PLACEHOLDER;
00035 
00036 #ifdef __KERNEL__
00037 
00038 #define RTAI_PIPE_MAGIC 0x55550202
00039 
00040 typedef xnpipe_mh_t RT_PIPE_MSG;
00041 
00042 #define P_MSGPTR(msg)  xnpipe_m_data(msg)
00043 #define P_MSGSIZE(msg) xnpipe_m_size(msg)
00044 
00045 typedef struct rt_pipe {
00046 
00047     unsigned magic;             /* !< Magic code -- must be first. */
00048 
00049     xnholder_t link;            /* !< Link in flush queue. */
00050 
00051 #define link2rtpipe(laddr) \
00052 ((RT_PIPE *)(((char *)laddr) - (int)(&((RT_PIPE *)0)->link)))
00053 
00054     int minor;                  /* !< Device minor number.  */
00055 
00056     RT_PIPE_MSG *buffer;        /* !< Buffer used in byte stream mode. */
00057 
00058     size_t fillsz;              /* !< Bytes written to the buffer.  */
00059 
00060     u_long flushable;           /* !< Flush request flag. */
00061 
00062     rt_handle_t handle;         /* !< Handle in registry -- zero if unregistered. */
00063 
00064     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00065 
00066 #ifdef CONFIG_RTAI_OPT_FUSION
00067     pid_t cpid;                 /* !< Creator's pid. */
00068 #endif /* CONFIG_RTAI_OPT_FUSION */
00069 
00070 } RT_PIPE;
00071 
00072 #else /* !__KERNEL__ */
00073 
00074 typedef RT_PIPE_PLACEHOLDER RT_PIPE;
00075 
00076 #endif /* __KERNEL__ */
00077 
00078 #ifdef __cplusplus
00079 extern "C" {
00080 #endif
00081 
00082 /* Public interface. */
00083 
00084 int rt_pipe_create(RT_PIPE *pipe,
00085                    const char *name,
00086                    int minor);
00087 
00088 int rt_pipe_delete(RT_PIPE *pipe);
00089 
00090 ssize_t rt_pipe_read(RT_PIPE *pipe,
00091                      void *buf,
00092                      size_t size,
00093                      RTIME timeout);
00094 
00095 ssize_t rt_pipe_write(RT_PIPE *pipe,
00096                       const void *buf,
00097                       size_t size,
00098                       int mode);
00099 
00100 ssize_t rt_pipe_stream(RT_PIPE *pipe,
00101                        const void *buf,
00102                        size_t size);
00103 #ifdef __KERNEL__
00104 
00105 ssize_t rt_pipe_receive(RT_PIPE *pipe,
00106                         RT_PIPE_MSG **msg,
00107                         RTIME timeout);
00108 
00109 ssize_t rt_pipe_send(RT_PIPE *pipe,
00110                      RT_PIPE_MSG *msg,
00111                      size_t size,
00112                      int mode);
00113 
00114 RT_PIPE_MSG *rt_pipe_alloc(size_t size);
00115 
00116 int rt_pipe_free(RT_PIPE_MSG *msg);
00117 
00118 int __pipe_pkg_init(void);
00119 
00120 void __pipe_pkg_cleanup(void);
00121 
00122 #else /* !__KERNEL__ */
00123 
00124 int rt_pipe_bind(RT_PIPE *pipe,
00125                  const char *name);
00126 
00127 static inline int rt_pipe_unbind (RT_PIPE *pipe)
00128 
00129 {
00130     pipe->opaque = RT_HANDLE_INVALID;
00131     return 0;
00132 }
00133 
00134 #endif /* __KERNEL__ */
00135 
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139 
00140 #endif /* !_RTAI_PIPE_H */

Generated on Wed Jun 22 22:54:02 2005 for RTAI Fusion API by  doxygen 1.4.1