20 #ifndef _XENO_NUCLEUS_PIPE_H
21 #define _XENO_NUCLEUS_PIPE_H
23 #define XNPIPE_NDEVS CONFIG_XENO_OPT_PIPE_NRDEV
24 #define XNPIPE_DEV_MAJOR 150
26 #define XNPIPE_IOCTL_BASE 'p'
27 #define XNPIPEIOC_GET_NRDEV _IOW(XNPIPE_IOCTL_BASE, 0, int)
28 #define XNPIPEIOC_IFLUSH _IO(XNPIPE_IOCTL_BASE,1)
29 #define XNPIPEIOC_OFLUSH _IO(XNPIPE_IOCTL_BASE,2)
30 #define XNPIPEIOC_FLUSH XNPIPEIOC_OFLUSH
31 #define XNPIPEIOC_SETSIG _IO(XNPIPE_IOCTL_BASE,3)
33 #define XNPIPE_NORMAL 0x0
34 #define XNPIPE_URGENT 0x1
36 #define XNPIPE_IFLUSH 0x1
37 #define XNPIPE_OFLUSH 0x2
39 #define XNPIPE_MINOR_AUTO -1
43 #include <nucleus/queue.h>
44 #include <nucleus/synch.h>
45 #include <nucleus/thread.h>
46 #include <linux/types.h>
47 #include <linux/poll.h>
49 #define XNPIPE_KERN_CONN 0x1
50 #define XNPIPE_KERN_LCLOSE 0x2
51 #define XNPIPE_USER_CONN 0x4
52 #define XNPIPE_USER_SIGIO 0x8
53 #define XNPIPE_USER_WREAD 0x10
54 #define XNPIPE_USER_WREAD_READY 0x20
55 #define XNPIPE_USER_WSYNC 0x40
56 #define XNPIPE_USER_WSYNC_READY 0x80
58 #define XNPIPE_USER_ALL_WAIT \
59 (XNPIPE_USER_WREAD|XNPIPE_USER_WSYNC)
61 #define XNPIPE_USER_ALL_READY \
62 (XNPIPE_USER_WREAD_READY|XNPIPE_USER_WSYNC_READY)
64 typedef struct xnpipe_mh {
72 static inline xnpipe_mh_t *link2mh(
struct xnholder *ln)
74 return ln ? container_of(ln, xnpipe_mh_t, link) : NULL;
79 struct xnpipe_operations {
80 void (*output)(
struct xnpipe_mh *mh,
void *xstate);
81 int (*input)(
struct xnpipe_mh *mh,
int retval,
void *xstate);
82 void *(*alloc_ibuf)(
size_t size,
void *xstate);
83 void (*free_ibuf)(
void *buf,
void *xstate);
84 void (*free_obuf)(
void *buf,
void *xstate);
85 void (*release)(
void *xstate);
90 struct xnholder slink;
91 struct xnholder alink;
92 #define link2xnpipe(ln, fld) container_of(ln, struct xnpipe_state, fld)
96 struct xnsynch synchbase;
97 struct xnpipe_operations ops;
102 struct fasync_struct *asyncq;
103 wait_queue_head_t readq;
104 wait_queue_head_t syncq;
110 extern struct xnpipe_state xnpipe_states[];
112 #define xnminor_from_state(s) (s - xnpipe_states)
118 int xnpipe_mount(
void);
120 void xnpipe_umount(
void);
124 int xnpipe_connect(
int minor,
125 struct xnpipe_operations *ops,
void *xstate);
127 int xnpipe_disconnect(
int minor);
129 ssize_t xnpipe_send(
int minor,
130 struct xnpipe_mh *mh,
size_t size,
int flags);
132 ssize_t xnpipe_mfixup(
int minor,
struct xnpipe_mh *mh, ssize_t size);
134 ssize_t xnpipe_recv(
int minor,
135 struct xnpipe_mh **pmh, xnticks_t timeout);
137 int xnpipe_flush(
int minor,
int mode);
143 static inline struct xnholder *xnpipe_m_link(xnpipe_mh_t *mh)
148 static inline char *xnpipe_m_data(xnpipe_mh_t *mh)
150 return (
char *)(mh + 1);
153 #define xnpipe_m_size(mh) ((mh)->size)
155 #define xnpipe_m_rdoff(mh) ((mh)->rdoff)