make vfs & filesystems use failable copying
[minix3.git] / include / minix / ipc.h
blob11282305d6b186b404349d21ee6c0927e4a7ac37
1 #ifndef _IPC_H
2 #define _IPC_H
4 #include <minix/ipcconst.h>
5 #include <minix/type.h>
6 #include <minix/const.h>
7 #include <sys/signal.h>
9 /*==========================================================================*
10 * Types relating to messages. *
11 *==========================================================================*/
13 #define M1 1
14 #define M3 3
15 #define M4 4
16 #define M3_STRING 44 /* legacy m3_ca1 size (must not be changed) */
17 #define M3_LONG_STRING 44 /* current m3_ca1 size (may be increased) */
19 typedef struct {
20 uint64_t m1ull1;
21 int m1i1, m1i2, m1i3;
22 char *m1p1, *m1p2, *m1p3, *m1p4;
23 uint8_t padding[20];
24 } mess_1;
25 _ASSERT_MSG_SIZE(mess_1);
27 typedef struct {
28 int64_t m2ll1;
29 int m2i1, m2i2, m2i3;
30 long m2l1, m2l2;
31 char *m2p1;
32 sigset_t sigset;
33 short m2s1;
34 uint8_t padding[6];
35 } mess_2;
36 _ASSERT_MSG_SIZE(mess_2);
38 typedef struct {
39 int m3i1, m3i2;
40 char *m3p1;
41 char m3ca1[M3_LONG_STRING];
42 } mess_3;
43 _ASSERT_MSG_SIZE(mess_3);
45 typedef struct {
46 int64_t m4ll1;
47 long m4l1, m4l2, m4l3, m4l4, m4l5;
48 uint8_t padding[28];
49 } mess_4;
50 _ASSERT_MSG_SIZE(mess_4);
52 typedef struct {
53 short m5s1, m5s2;
54 int m5i1, m5i2;
55 long m5l1, m5l2, m5l3;
56 uint8_t padding[32];
57 } mess_5;
58 _ASSERT_MSG_SIZE(mess_5);
60 typedef struct {
61 long m6l1, m6l2, m6l3;
62 short m6s1, m6s2, m6s3;
63 char m6c1, m6c2;
64 char *m6p1, *m6p2;
65 uint8_t padding[28];
66 } mess_6;
67 _ASSERT_MSG_SIZE(mess_6);
69 typedef struct {
70 int m7i1, m7i2, m7i3, m7i4, m7i5;
71 char *m7p1, *m7p2;
72 uint8_t padding[28];
73 } mess_7;
74 _ASSERT_MSG_SIZE(mess_7);
76 typedef struct {
77 int m8i1, m8i2;
78 char *m8p1, *m8p2, *m8p3, *m8p4;
79 uint8_t padding[32];
80 } mess_8;
81 _ASSERT_MSG_SIZE(mess_8);
83 typedef struct {
84 uint64_t m9ull1, m9ull2;
85 long m9l1, m9l2, m9l3, m9l4, m9l5;
86 short m9s1, m9s2, m9s3, m9s4;
87 uint8_t padding[12];
88 } mess_9;
89 _ASSERT_MSG_SIZE(mess_9);
91 typedef struct {
92 u64_t m10ull1;
93 int m10i1, m10i2, m10i3, m10i4;
94 long m10l1, m10l2, m10l3;
95 uint8_t padding[20];
96 } mess_10;
97 _ASSERT_MSG_SIZE(mess_10);
99 typedef struct {
100 int m11i1;
101 short m11s1, m11s2, m11s3, m11s4;
102 char *m11p1, *m11p2, *m11p3, *m11p4;
103 uint8_t padding[28];
104 } mess_11;
105 _ASSERT_MSG_SIZE(mess_11);
107 typedef struct {
108 off_t offset;
109 void *addr;
110 size_t len;
111 int prot;
112 int flags;
113 int fd;
114 endpoint_t forwhom;
115 void *retaddr;
116 u32_t padding[5];
117 } mess_mmap;
118 _ASSERT_MSG_SIZE(mess_mmap);
120 typedef struct {
121 u64_t timestamp; /* valid for every notify msg */
122 u64_t interrupts; /* raised interrupts; valid if from HARDWARE */
123 sigset_t sigset; /* raised signals; valid if from SYSTEM */
124 uint8_t padding[24];
125 } mess_notify;
126 _ASSERT_MSG_SIZE(mess_notify);
128 /* For SYS_GETKSIG, _ENDKSIG, _KILL, _SIGSEND, _SIGRETURN. */
129 typedef struct {
130 sigset_t map; /* used to pass signal bit map */
131 endpoint_t endpt; /* process number for inform */
132 int sig; /* signal number to send */
133 void *sigctx; /* pointer to signal context */
134 uint8_t padding[28];
135 } mess_sigcalls;
136 _ASSERT_MSG_SIZE(mess_sigcalls);
138 typedef struct {
139 time_t atime;
140 time_t mtime;
141 long ansec;
142 long mnsec;
143 size_t len;
144 char *name;
145 int fd;
146 int flags;
147 uint8_t padding[16];
148 } mess_vfs_utimens;
149 _ASSERT_MSG_SIZE(mess_vfs_utimens);
151 typedef struct {
152 off_t offset;
153 dev_t dev;
154 ino_t ino;
155 endpoint_t who;
156 u32_t vaddr;
157 u32_t len;
158 u32_t flags;
159 u32_t fd;
160 u16_t clearend;
161 uint8_t padding[8];
162 } mess_vm_vfs_mmap;
163 _ASSERT_MSG_SIZE(mess_vm_vfs_mmap);
165 typedef struct {
166 dev_t dev; /* 64bits long. */
167 off_t dev_offset;
168 off_t ino_offset;
169 ino_t ino;
170 void *block;
171 u32_t *flags_ptr;
172 u8_t pages;
173 u8_t flags;
174 uint8_t padding[12];
175 } mess_vmmcp;
176 _ASSERT_MSG_SIZE(mess_vmmcp);
178 typedef struct {
179 void *addr;
180 u8_t flags;
181 uint8_t padding[51];
182 } mess_vmmcp_reply;
183 _ASSERT_MSG_SIZE(mess_vmmcp_reply);
185 typedef struct {
186 endpoint_t m_source; /* who sent the message */
187 int m_type; /* what kind of message is it */
188 union {
189 mess_1 m_m1;
190 mess_2 m_m2;
191 mess_3 m_m3;
192 mess_4 m_m4;
193 mess_5 m_m5;
194 mess_7 m_m7;
195 mess_8 m_m8;
196 mess_6 m_m6;
197 mess_9 m_m9;
198 mess_10 m_m10;
199 mess_11 m_m11;
200 mess_mmap m_mmap;
201 mess_notify m_notify;
202 mess_sigcalls m_sigcalls;
203 mess_vfs_utimens m_vfs_utimens;
204 mess_vm_vfs_mmap m_vm_vfs_mmap;
205 mess_vmmcp m_vmmcp;
206 mess_vmmcp_reply m_vmmcp_reply;
207 u8_t size[56]; /* message payload may have 56 bytes at most */
209 } message __aligned(16);
211 /* Ensure the complete union respects the IPC assumptions. */
212 typedef int _ASSERT_message[/* CONSTCOND */sizeof(message) == 64 ? 1 : -1];
214 /* The following defines provide names for useful members. */
215 #define m1_i1 m_m1.m1i1
216 #define m1_i2 m_m1.m1i2
217 #define m1_i3 m_m1.m1i3
218 #define m1_p1 m_m1.m1p1
219 #define m1_p2 m_m1.m1p2
220 #define m1_p3 m_m1.m1p3
221 #define m1_p4 m_m1.m1p4
222 #define m1_ull1 m_m1.m1ull1
224 #define m2_ll1 m_m2.m2ll1
225 #define m2_i1 m_m2.m2i1
226 #define m2_i2 m_m2.m2i2
227 #define m2_i3 m_m2.m2i3
228 #define m2_l1 m_m2.m2l1
229 #define m2_l2 m_m2.m2l2
230 #define m2_p1 m_m2.m2p1
231 #define m2_sigset m_m2.sigset
233 #define m2_s1 m_m2.m2s1
235 #define m3_i1 m_m3.m3i1
236 #define m3_i2 m_m3.m3i2
237 #define m3_p1 m_m3.m3p1
238 #define m3_ca1 m_m3.m3ca1
240 #define m4_ll1 m_m4.m4ll1
241 #define m4_l1 m_m4.m4l1
242 #define m4_l2 m_m4.m4l2
243 #define m4_l3 m_m4.m4l3
244 #define m4_l4 m_m4.m4l4
245 #define m4_l5 m_m4.m4l5
247 #define m5_s1 m_m5.m5s1
248 #define m5_s2 m_m5.m5s2
249 #define m5_i1 m_m5.m5i1
250 #define m5_i2 m_m5.m5i2
251 #define m5_l1 m_m5.m5l1
252 #define m5_l2 m_m5.m5l2
253 #define m5_l3 m_m5.m5l3
255 #define m6_l1 m_m6.m6l1
256 #define m6_l2 m_m6.m6l2
257 #define m6_l3 m_m6.m6l3
258 #define m6_s1 m_m6.m6s1
259 #define m6_s2 m_m6.m6s2
260 #define m6_s3 m_m6.m6s3
261 #define m6_c1 m_m6.m6c1
262 #define m6_c2 m_m6.m6c2
263 #define m6_p1 m_m6.m6p1
264 #define m6_p2 m_m6.m6p2
266 #define m7_i1 m_m7.m7i1
267 #define m7_i2 m_m7.m7i2
268 #define m7_i3 m_m7.m7i3
269 #define m7_i4 m_m7.m7i4
270 #define m7_i5 m_m7.m7i5
271 #define m7_p1 m_m7.m7p1
272 #define m7_p2 m_m7.m7p2
274 #define m8_i1 m_m8.m8i1
275 #define m8_i2 m_m8.m8i2
276 #define m8_p1 m_m8.m8p1
277 #define m8_p2 m_m8.m8p2
278 #define m8_p3 m_m8.m8p3
279 #define m8_p4 m_m8.m8p4
281 #define m9_l1 m_m9.m9l1
282 #define m9_l2 m_m9.m9l2
283 #define m9_l3 m_m9.m9l3
284 #define m9_l4 m_m9.m9l4
285 #define m9_l5 m_m9.m9l5
286 #define m9_s1 m_m9.m9s1
287 #define m9_s2 m_m9.m9s2
288 #define m9_s3 m_m9.m9s3
289 #define m9_s4 m_m9.m9s4
290 #define m9_ull1 m_m9.m9ull1
291 #define m9_ull2 m_m9.m9ull2
293 #define m10_i1 m_m10.m10i1
294 #define m10_i2 m_m10.m10i2
295 #define m10_i3 m_m10.m10i3
296 #define m10_i4 m_m10.m10i4
297 #define m10_l1 m_m10.m10l1
298 #define m10_l2 m_m10.m10l2
299 #define m10_l3 m_m10.m10l3
300 #define m10_ull1 m_m10.m10ull1
302 #define m11_i1 m_m11.m11i1
303 #define m11_s1 m_m11.m11s1
304 #define m11_s2 m_m11.m11s2
305 #define m11_s3 m_m11.m11s3
306 #define m11_s4 m_m11.m11s4
307 #define m11_p1 m_m11.m11p1
308 #define m11_p2 m_m11.m11p2
309 #define m11_p3 m_m11.m11p3
310 #define m11_p4 m_m11.m11p4
312 /*==========================================================================*
313 * Minix run-time system (IPC). *
314 *==========================================================================*/
316 /* Datastructure for asynchronous sends */
317 typedef struct asynmsg
319 unsigned flags;
320 endpoint_t dst;
321 int result;
322 message msg;
323 } asynmsg_t;
325 /* Defines for flags field */
326 #define AMF_EMPTY 000 /* slot is not inuse */
327 #define AMF_VALID 001 /* slot contains message */
328 #define AMF_DONE 002 /* Kernel has processed the message. The
329 * result is stored in 'result'
331 #define AMF_NOTIFY 004 /* Send a notification when AMF_DONE is set */
332 #define AMF_NOREPLY 010 /* Not a reply message for a SENDREC */
333 #define AMF_NOTIFY_ERR 020 /* Send a notification when AMF_DONE is set and
334 * delivery of the message failed */
336 int _ipc_send_intr(endpoint_t dest, message *m_ptr);
337 int _ipc_receive_intr(endpoint_t src, message *m_ptr, int *status_ptr);
338 int _ipc_sendrec_intr(endpoint_t src_dest, message *m_ptr);
339 int _ipc_sendnb_intr(endpoint_t dest, message *m_ptr);
340 int _ipc_notify_intr(endpoint_t dest);
341 int _ipc_senda_intr(asynmsg_t *table, size_t count);
343 int _do_kernel_call_intr(message *m_ptr);
345 int get_minix_kerninfo(struct minix_kerninfo **);
347 /* Hide names to avoid name space pollution. */
348 #define ipc_notify _ipc_notify
349 #define ipc_sendrec _ipc_sendrec
350 #define ipc_receive _ipc_receive
351 #define ipc_receivenb _ipc_receivenb
352 #define ipc_send _ipc_send
353 #define ipc_sendnb _ipc_sendnb
354 #define ipc_senda _ipc_senda
356 #define do_kernel_call _do_kernel_call
358 struct minix_ipcvecs {
359 int (*send)(endpoint_t dest, message *m_ptr);
360 int (*receive)(endpoint_t src, message *m_ptr, int *st);
361 int (*sendrec)(endpoint_t src_dest, message *m_ptr);
362 int (*sendnb)(endpoint_t dest, message *m_ptr);
363 int (*notify)(endpoint_t dest);
364 int (*do_kernel_call)(message *m_ptr);
365 int (*senda)(asynmsg_t *table, size_t count);
368 /* kernel-set IPC vectors retrieved by a constructor in libc/sys-minix/init.c */
369 extern struct minix_ipcvecs _minix_ipcvecs;
371 static inline int _ipc_send(endpoint_t dest, message *m_ptr)
373 return _minix_ipcvecs.send(dest, m_ptr);
376 static inline int _ipc_receive(endpoint_t src, message *m_ptr, int *st)
378 return _minix_ipcvecs.receive(src, m_ptr, st);
381 static inline int _ipc_sendrec(endpoint_t src_dest, message *m_ptr)
383 return _minix_ipcvecs.sendrec(src_dest, m_ptr);
386 static inline int _ipc_sendnb(endpoint_t dest, message *m_ptr)
388 return _minix_ipcvecs.sendnb(dest, m_ptr);
391 static inline int _ipc_notify(endpoint_t dest)
393 return _minix_ipcvecs.notify(dest);
396 static inline int _do_kernel_call(message *m_ptr)
398 return _minix_ipcvecs.do_kernel_call(m_ptr);
401 static inline int _ipc_senda(asynmsg_t *table, size_t count)
403 return _minix_ipcvecs.senda(table, count);
406 #endif /* _IPC_H */