Xenomai  3.0.8
internal.h
1 
20 #ifndef _RTIPC_INTERNAL_H
21 #define _RTIPC_INTERNAL_H
22 
23 #include <linux/uio.h>
24 #include <cobalt/kernel/registry.h>
25 #include <cobalt/kernel/clock.h>
26 #include <cobalt/kernel/select.h>
27 #include <rtdm/rtdm.h>
28 #include <rtdm/compat.h>
29 #include <rtdm/driver.h>
30 
31 struct rtipc_protocol;
32 
33 struct rtipc_private {
34  struct rtipc_protocol *proto;
35  DECLARE_XNSELECT(send_block);
36  DECLARE_XNSELECT(recv_block);
37  void *state;
38 };
39 
40 struct rtipc_protocol {
41  const char *proto_name;
42  int proto_statesz;
43  int (*proto_init)(void);
44  void (*proto_exit)(void);
45  struct {
46  int (*socket)(struct rtdm_fd *fd);
47  void (*close)(struct rtdm_fd *fd);
48  ssize_t (*recvmsg)(struct rtdm_fd *fd,
49  struct user_msghdr *msg, int flags);
50  ssize_t (*sendmsg)(struct rtdm_fd *fd,
51  const struct user_msghdr *msg, int flags);
52  ssize_t (*read)(struct rtdm_fd *fd,
53  void *buf, size_t len);
54  ssize_t (*write)(struct rtdm_fd *fd,
55  const void *buf, size_t len);
56  int (*ioctl)(struct rtdm_fd *fd,
57  unsigned int request, void *arg);
58  unsigned int (*pollstate)(struct rtdm_fd *fd);
59  } proto_ops;
60 };
61 
62 static inline void *rtipc_fd_to_state(struct rtdm_fd *fd)
63 {
64  struct rtipc_private *p = rtdm_fd_to_private(fd);
65  return p->state;
66 }
67 
68 static inline nanosecs_rel_t rtipc_timeval_to_ns(const struct timeval *tv)
69 {
70  nanosecs_rel_t ns = tv->tv_usec * 1000;
71 
72  if (tv->tv_sec)
73  ns += (nanosecs_rel_t)tv->tv_sec * 1000000000UL;
74 
75  return ns;
76 }
77 
78 static inline void rtipc_ns_to_timeval(struct timeval *tv, nanosecs_rel_t ns)
79 {
80  unsigned long nsecs;
81 
82  tv->tv_sec = xnclock_divrem_billion(ns, &nsecs);
83  tv->tv_usec = nsecs / 1000;
84 }
85 
86 int rtipc_get_sockaddr(struct rtdm_fd *fd,
87  struct sockaddr_ipc **saddrp,
88  const void *arg);
89 
90 int rtipc_put_sockaddr(struct rtdm_fd *fd, void *arg,
91  const struct sockaddr_ipc *saddr);
92 
93 int rtipc_get_sockoptout(struct rtdm_fd *fd,
94  struct _rtdm_getsockopt_args *sopt,
95  const void *arg);
96 
97 int rtipc_put_sockoptout(struct rtdm_fd *fd, void *arg,
98  const struct _rtdm_getsockopt_args *sopt);
99 
100 int rtipc_get_sockoptin(struct rtdm_fd *fd,
101  struct _rtdm_setsockopt_args *sopt,
102  const void *arg);
103 
104 int rtipc_get_timeval(struct rtdm_fd *fd, struct timeval *tv,
105  const void *arg, size_t arglen);
106 
107 int rtipc_put_timeval(struct rtdm_fd *fd, void *arg,
108  const struct timeval *tv, size_t arglen);
109 
110 int rtipc_get_length(struct rtdm_fd *fd, size_t *lenp,
111  const void *arg, size_t arglen);
112 
113 int rtipc_get_arg(struct rtdm_fd *fd, void *dst, const void *src,
114  size_t len);
115 
116 int rtipc_put_arg(struct rtdm_fd *fd, void *dst, const void *src,
117  size_t len);
118 
119 extern struct rtipc_protocol xddp_proto_driver;
120 
121 extern struct rtipc_protocol iddp_proto_driver;
122 
123 extern struct rtipc_protocol bufp_proto_driver;
124 
125 extern struct xnptree rtipc_ptree;
126 
127 #define rtipc_wait_context xnthread_wait_context
128 #define rtipc_prepare_wait xnthread_prepare_wait
129 #define rtipc_get_wait_context xnthread_get_wait_context
130 #define rtipc_peek_wait_head(obj) xnsynch_peek_pendq(&(obj)->synch_base)
131 
132 #define COMPAT_CASE(__op) case __op __COMPAT_CASE(__op ## _COMPAT)
133 
134 #endif /* !_RTIPC_INTERNAL_H */
Socket address structure for the RTIPC address family.
Definition: ipc.h:480
static void * rtdm_fd_to_private(struct rtdm_fd *fd)
Locate the driver private area associated to a device context structure.
Definition: driver.h:161
int64_t nanosecs_rel_t
RTDM type for representing relative intervals.
Definition: rtdm.h:49
Real-Time Driver Model for Xenomai, driver API header.