19 #ifndef _COBALT_KERNEL_PIPE_H
20 #define _COBALT_KERNEL_PIPE_H
22 #include <linux/types.h>
23 #include <linux/poll.h>
24 #include <cobalt/kernel/synch.h>
25 #include <cobalt/kernel/thread.h>
26 #include <cobalt/uapi/kernel/pipe.h>
28 #define XNPIPE_NDEVS CONFIG_XENO_OPT_PIPE_NRDEV
29 #define XNPIPE_DEV_MAJOR 150
31 #define XNPIPE_KERN_CONN 0x1
32 #define XNPIPE_KERN_LCLOSE 0x2
33 #define XNPIPE_USER_CONN 0x4
34 #define XNPIPE_USER_SIGIO 0x8
35 #define XNPIPE_USER_WREAD 0x10
36 #define XNPIPE_USER_WREAD_READY 0x20
37 #define XNPIPE_USER_WSYNC 0x40
38 #define XNPIPE_USER_WSYNC_READY 0x80
39 #define XNPIPE_USER_LCONN 0x100
41 #define XNPIPE_USER_ALL_WAIT \
42 (XNPIPE_USER_WREAD|XNPIPE_USER_WSYNC)
44 #define XNPIPE_USER_ALL_READY \
45 (XNPIPE_USER_WREAD_READY|XNPIPE_USER_WSYNC_READY)
50 struct list_head link;
55 struct xnpipe_operations {
56 void (*output)(
struct xnpipe_mh *mh,
void *xstate);
57 int (*input)(
struct xnpipe_mh *mh,
int retval,
void *xstate);
58 void *(*alloc_ibuf)(
size_t size,
void *xstate);
59 void (*free_ibuf)(
void *buf,
void *xstate);
60 void (*free_obuf)(
void *buf,
void *xstate);
61 void (*release)(
void *xstate);
65 struct list_head slink;
66 struct list_head alink;
70 struct list_head outq;
72 struct xnsynch synchbase;
73 struct xnpipe_operations ops;
78 struct fasync_struct *asyncq;
79 wait_queue_head_t readq;
80 wait_queue_head_t syncq;
85 extern struct xnpipe_state xnpipe_states[];
87 #define xnminor_from_state(s) (s - xnpipe_states)
89 #ifdef CONFIG_XENO_OPT_PIPE
90 int xnpipe_mount(
void);
91 void xnpipe_umount(
void);
93 static inline int xnpipe_mount(
void) {
return 0; }
94 static inline void xnpipe_umount(
void) { }
99 int xnpipe_connect(
int minor,
100 struct xnpipe_operations *ops,
void *xstate);
102 int xnpipe_disconnect(
int minor);
104 ssize_t xnpipe_send(
int minor,
105 struct xnpipe_mh *mh,
size_t size,
int flags);
107 ssize_t xnpipe_mfixup(
int minor,
struct xnpipe_mh *mh, ssize_t size);
109 ssize_t xnpipe_recv(
int minor,
110 struct xnpipe_mh **pmh, xnticks_t timeout);
112 int xnpipe_flush(
int minor,
int mode);
114 int xnpipe_pollstate(
int minor,
unsigned int *mask_r);
116 static inline unsigned int __xnpipe_pollstate(
int minor)
118 struct xnpipe_state *state = xnpipe_states + minor;
119 unsigned int mask = POLLOUT;
121 if (!list_empty(&state->inq))
127 static inline char *xnpipe_m_data(
struct xnpipe_mh *mh)
129 return (
char *)(mh + 1);
132 #define xnpipe_m_size(mh) ((mh)->size)
134 #define xnpipe_m_rdoff(mh) ((mh)->rdoff)