include/native/pipe.h

Go to the documentation of this file.
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 typedef struct rt_pipe_placeholder {
00036     xnhandle_t opaque;
00037 } RT_PIPE_PLACEHOLDER;
00038 
00039 #ifdef __KERNEL__
00040 
00041 #define XENO_PIPE_MAGIC  0x55550202
00042 
00043 #define P_SYNCWAIT  0
00044 
00045 typedef xnpipe_mh_t RT_PIPE_MSG;
00046 
00047 #define P_MSGPTR(msg)  xnpipe_m_data(msg)
00048 #define P_MSGSIZE(msg) xnpipe_m_size(msg)
00049 
00050 typedef struct rt_pipe {
00051 
00052     unsigned magic;             /* !< Magic code -- must be first. */
00053 
00054     xnholder_t link;            /* !< Link in flush queue. */
00055 
00056 #define link2rtpipe(laddr) \
00057 ((RT_PIPE *)(((char *)laddr) - (int)(&((RT_PIPE *)0)->link)))
00058 
00059     int minor;                  /* !< Device minor number.  */
00060 
00061     RT_PIPE_MSG *buffer;        /* !< Buffer used in byte stream mode. */
00062 
00063     xnheap_t *bufpool;         /* !< Current buffer pool. */
00064 
00065     xnheap_t privpool;         /* !< Private buffer pool. */
00066 
00067     size_t fillsz;              /* !< Bytes written to the buffer.  */
00068 
00069     u_long status;              /* !< Status information. */
00070 
00071     xnhandle_t handle;          /* !< Handle in registry -- zero if unregistered. */
00072 
00073     char name[XNOBJECT_NAME_LEN]; /* !< Symbolic name. */
00074 
00075 #ifdef CONFIG_XENO_OPT_PERVASIVE
00076     pid_t cpid;                 /* !< Creator's pid. */
00077 #endif /* CONFIG_XENO_OPT_PERVASIVE */
00078 
00079 } RT_PIPE;
00080 
00081 #else /* !__KERNEL__ */
00082 
00083 typedef RT_PIPE_PLACEHOLDER RT_PIPE;
00084 
00085 #endif /* __KERNEL__ */
00086 
00087 #ifdef __cplusplus
00088 extern "C" {
00089 #endif
00090 
00091 /* Public interface. */
00092 
00093 int rt_pipe_create(RT_PIPE *pipe,
00094                    const char *name,
00095                    int minor,
00096                    size_t poolsize);
00097 
00098 int rt_pipe_delete(RT_PIPE *pipe);
00099 
00100 ssize_t rt_pipe_read(RT_PIPE *pipe,
00101                      void *buf,
00102                      size_t size,
00103                      RTIME timeout);
00104 
00105 ssize_t rt_pipe_write(RT_PIPE *pipe,
00106                       const void *buf,
00107                       size_t size,
00108                       int mode);
00109 
00110 ssize_t rt_pipe_stream(RT_PIPE *pipe,
00111                        const void *buf,
00112                        size_t size);
00113 
00114 #ifdef __KERNEL__
00115 
00116 ssize_t rt_pipe_receive(RT_PIPE *pipe,
00117                         RT_PIPE_MSG **msg,
00118                         RTIME timeout);
00119 
00120 ssize_t rt_pipe_send(RT_PIPE *pipe,
00121                      RT_PIPE_MSG *msg,
00122                      size_t size,
00123                      int mode);
00124 
00125 RT_PIPE_MSG *rt_pipe_alloc(RT_PIPE *pipe,
00126                            size_t size);
00127 
00128 int rt_pipe_free(RT_PIPE *pipe,
00129                  RT_PIPE_MSG *msg);
00130 
00131 ssize_t __deprecated_call__ rt_pipe_flush(RT_PIPE *pipe);
00132 
00133 int __native_pipe_pkg_init(void);
00134 
00135 void __native_pipe_pkg_cleanup(void);
00136 
00137 #else /* !__KERNEL__ */
00138 
00139 int rt_pipe_bind(RT_PIPE *pipe,
00140                  const char *name,
00141                  RTIME timeout);
00142 
00143 static inline int rt_pipe_unbind(RT_PIPE *pipe)
00144 {
00145     pipe->opaque = XN_NO_HANDLE;
00146     return 0;
00147 }
00148 
00149 #endif /* __KERNEL__ */
00150 
00151 #ifdef __cplusplus
00152 }
00153 #endif
00154 
00155 #endif /* !_XENO_PIPE_H */

Generated on Mon Dec 25 13:57:10 2006 for Xenomai API by  doxygen 1.4.6