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
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 #define P_ATOMIC 1
00045
00046 typedef xnpipe_mh_t RT_PIPE_MSG;
00047
00048 #define P_MSGPTR(msg) xnpipe_m_data(msg)
00049 #define P_MSGSIZE(msg) xnpipe_m_size(msg)
00050
00051 typedef struct rt_pipe {
00052
00053 unsigned magic;
00054
00055 xnholder_t link;
00056
00057 #define link2rtpipe(laddr) \
00058 ((RT_PIPE *)(((char *)laddr) - (int)(&((RT_PIPE *)0)->link)))
00059
00060 int minor;
00061
00062 RT_PIPE_MSG *buffer;
00063
00064 xnheap_t *bufpool;
00065
00066 xnheap_t privpool;
00067
00068 size_t fillsz;
00069
00070 u_long status;
00071
00072 xnhandle_t handle;
00073
00074 char name[XNOBJECT_NAME_LEN];
00075
00076 #ifdef CONFIG_XENO_OPT_PERVASIVE
00077 pid_t cpid;
00078 #endif
00079
00080 } RT_PIPE;
00081
00082 #else
00083
00084 typedef RT_PIPE_PLACEHOLDER RT_PIPE;
00085
00086 #endif
00087
00088 #ifdef __cplusplus
00089 extern "C" {
00090 #endif
00091
00092
00093
00094 int rt_pipe_create(RT_PIPE *pipe,
00095 const char *name,
00096 int minor,
00097 size_t poolsize);
00098
00099 int rt_pipe_delete(RT_PIPE *pipe);
00100
00101 ssize_t rt_pipe_read(RT_PIPE *pipe,
00102 void *buf,
00103 size_t size,
00104 RTIME timeout);
00105
00106 ssize_t rt_pipe_write(RT_PIPE *pipe,
00107 const void *buf,
00108 size_t size,
00109 int mode);
00110
00111 ssize_t rt_pipe_stream(RT_PIPE *pipe,
00112 const void *buf,
00113 size_t size);
00114
00115 #ifdef __KERNEL__
00116
00117 ssize_t rt_pipe_receive(RT_PIPE *pipe,
00118 RT_PIPE_MSG **msg,
00119 RTIME timeout);
00120
00121 ssize_t rt_pipe_send(RT_PIPE *pipe,
00122 RT_PIPE_MSG *msg,
00123 size_t size,
00124 int mode);
00125
00126 RT_PIPE_MSG *rt_pipe_alloc(RT_PIPE *pipe,
00127 size_t size);
00128
00129 int rt_pipe_free(RT_PIPE *pipe,
00130 RT_PIPE_MSG *msg);
00131
00132 ssize_t __deprecated_call__ rt_pipe_flush(RT_PIPE *pipe);
00133
00134 int __native_pipe_pkg_init(void);
00135
00136 void __native_pipe_pkg_cleanup(void);
00137
00138 #else
00139
00140 int rt_pipe_bind(RT_PIPE *pipe,
00141 const char *name,
00142 RTIME timeout);
00143
00144 static inline int rt_pipe_unbind(RT_PIPE *pipe)
00145 {
00146 pipe->opaque = XN_NO_HANDLE;
00147 return 0;
00148 }
00149
00150 #endif
00151
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155
00156 #endif