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 *==========================================================================*/
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) */
22 char *m1p1
, *m1p2
, *m1p3
, *m1p4
;
25 _ASSERT_MSG_SIZE(mess_1
);
36 _ASSERT_MSG_SIZE(mess_2
);
41 char m3ca1
[M3_LONG_STRING
];
43 _ASSERT_MSG_SIZE(mess_3
);
47 long m4l1
, m4l2
, m4l3
, m4l4
, m4l5
;
50 _ASSERT_MSG_SIZE(mess_4
);
55 long m5l1
, m5l2
, m5l3
;
58 _ASSERT_MSG_SIZE(mess_5
);
61 long m6l1
, m6l2
, m6l3
;
62 short m6s1
, m6s2
, m6s3
;
67 _ASSERT_MSG_SIZE(mess_6
);
70 int m7i1
, m7i2
, m7i3
, m7i4
, m7i5
;
74 _ASSERT_MSG_SIZE(mess_7
);
78 char *m8p1
, *m8p2
, *m8p3
, *m8p4
;
81 _ASSERT_MSG_SIZE(mess_8
);
84 uint64_t m9ull1
, m9ull2
;
85 long m9l1
, m9l2
, m9l3
, m9l4
, m9l5
;
86 short m9s1
, m9s2
, m9s3
, m9s4
;
89 _ASSERT_MSG_SIZE(mess_9
);
93 int m10i1
, m10i2
, m10i3
, m10i4
;
94 long m10l1
, m10l2
, m10l3
;
97 _ASSERT_MSG_SIZE(mess_10
);
101 short m11s1
, m11s2
, m11s3
, m11s4
;
102 char *m11p1
, *m11p2
, *m11p3
, *m11p4
;
105 _ASSERT_MSG_SIZE(mess_11
);
118 _ASSERT_MSG_SIZE(mess_mmap
);
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 */
126 _ASSERT_MSG_SIZE(mess_notify
);
128 /* For SYS_GETKSIG, _ENDKSIG, _KILL, _SIGSEND, _SIGRETURN. */
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 */
136 _ASSERT_MSG_SIZE(mess_sigcalls
);
149 _ASSERT_MSG_SIZE(mess_vfs_utimens
);
163 _ASSERT_MSG_SIZE(mess_vm_vfs_mmap
);
166 dev_t dev
; /* 64bits long. */
176 _ASSERT_MSG_SIZE(mess_vmmcp
);
183 _ASSERT_MSG_SIZE(mess_vmmcp_reply
);
186 endpoint_t m_source
; /* who sent the message */
187 int m_type
; /* what kind of message is it */
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
;
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
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
);