Add support for RFC 3390, which allows for a variable-sized
[dragonfly.git] / sys / sys / msgport.h
CommitLineData
ece04fd0
MD
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
a64ba182 6 * $DragonFly: src/sys/sys/msgport.h,v 1.3 2003/07/24 01:41:27 dillon Exp $
ece04fd0
MD
7 */
8
9#ifndef _SYS_MSGPORT_H_
10#define _SYS_MSGPORT_H_
11
12#ifndef _SYS_QUEUE_H_
13#include <sys/queue.h> /* TAILQ_* macros */
14#endif
15
16struct lwkt_msg;
17struct lwkt_port;
335dda38 18struct thread;
ece04fd0
MD
19
20typedef struct lwkt_msg *lwkt_msg_t;
21typedef struct lwkt_port *lwkt_port_t;
22
335dda38
MD
23typedef TAILQ_HEAD(lwkt_msg_queue, lwkt_msg) lwkt_msg_queue;
24
ece04fd0
MD
25/*
26 * The standard message and port structure for communications between
27 * threads. See kern/lwkt_msgport.c for documentation on how messages and
28 * ports work.
a64ba182
MD
29 *
30 * NOTE! 64-bit-align this structure.
ece04fd0
MD
31 */
32typedef struct lwkt_msg {
33 TAILQ_ENTRY(lwkt_msg) ms_node; /* link node (not always used) */
34 lwkt_port_t ms_target_port; /* only used in certain situations */
35 lwkt_port_t ms_reply_port; /* asynch replies returned here */
36 int ms_abortreq; /* set asynchronously */
37 int ms_cmd;
38 int ms_flags;
39 int ms_error;
a64ba182
MD
40 union {
41 void *ms_resultp;
42 int32_t ms_result32;
43 int64_t ms_result64;
44 } u;
45 int ms_pad[2]; /* future use */
ece04fd0
MD
46} lwkt_msg;
47
48#define MSGF_DONE 0x0001 /* asynch message is complete */
49#define MSGF_REPLY 0x0002 /* asynch message has been returned */
50#define MSGF_QUEUED 0x0004 /* message has been queued sanitychk */
51#define MSGF_ASYNC 0x0008 /* sync/async hint */
52
335dda38
MD
53#define MSG_CMD_CDEV 0x00010000
54#define MSG_CMD_VFS 0x00020000
55#define MSG_CMD_SYSCALL 0x00030000
56#define MSG_SUBCMD_MASK 0x0000FFFF
57
ece04fd0
MD
58typedef struct lwkt_port {
59 lwkt_msg_queue mp_msgq;
60 int mp_flags;
335dda38 61 struct thread *mp_td;
ece04fd0
MD
62 int (*mp_beginmsg)(lwkt_port_t port, lwkt_msg_t msg);
63 void (*mp_abortmsg)(lwkt_port_t port, lwkt_msg_t msg);
64 void (*mp_returnmsg)(lwkt_port_t port, lwkt_msg_t msg);
65} lwkt_port;
66
67#define MSGPORTF_WAITING 0x0001
68
69#ifdef _KERNEL
70
335dda38 71extern void lwkt_init_port(lwkt_port_t port, struct thread *td);
ece04fd0
MD
72extern void lwkt_sendmsg(lwkt_port_t port, lwkt_msg_t msg);
73extern int lwkt_domsg(lwkt_port_t port, lwkt_msg_t msg);
74extern int lwkt_waitmsg(lwkt_msg_t msg);
75extern void lwkt_replyport(lwkt_port_t port, lwkt_msg_t msg);
76extern void lwkt_abortport(lwkt_port_t port, lwkt_msg_t msg);
77extern int lwkt_putport(lwkt_port_t port, lwkt_msg_t msg);
78extern void *lwkt_getport(lwkt_port_t port);
79extern void *lwkt_waitport(lwkt_port_t port);
80
81#endif
82
83#endif