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

Generated on Mon Mar 24 18:02:40 2008 for Xenomai API by  doxygen 1.5.3