4 * Implements LWKT messages and ports.
6 * $DragonFly: src/sys/sys/msgport.h,v 1.14 2004/03/06 19:40:32 dillon Exp $
9 #ifndef _SYS_MSGPORT_H_
10 #define _SYS_MSGPORT_H_
13 #include <sys/queue.h> /* TAILQ_* macros */
15 #ifndef _SYS_STDINT_H_
16 #include <sys/stdint.h>
23 typedef struct lwkt_msg *lwkt_msg_t;
24 typedef struct lwkt_port *lwkt_port_t;
26 typedef TAILQ_HEAD(lwkt_msg_queue, lwkt_msg) lwkt_msg_queue;
29 * The standard message and port structure for communications between
30 * threads. See kern/lwkt_msgport.c for documentation on how messages and
33 * NOTE! 64-bit-align this structure.
35 typedef struct lwkt_msg {
36 TAILQ_ENTRY(lwkt_msg) ms_node; /* link node (not always used) */
38 struct lwkt_msg *ms_next; /* chaining / cache */
39 union sysunion *ms_sysunnext; /* chaining / cache */
40 struct lwkt_msg *ms_umsg; /* user message (UVA address) */
42 lwkt_port_t ms_target_port; /* current target or relay port */
43 lwkt_port_t ms_reply_port; /* asynch replies returned here */
45 int ms_cmd; /* message command */
46 int ms_flags; /* message flags */
47 #define ms_copyout_start ms_msgsize
48 int ms_msgsize; /* size of message */
49 int ms_error; /* positive error code or 0 */
51 void *ms_resultp; /* misc pointer data or result */
52 int ms_result; /* standard 'int'eger result */
53 long ms_lresult; /* long result */
54 int ms_fds[2]; /* two int bit results */
55 __int32_t ms_result32; /* 32 bit result */
56 __int64_t ms_result64; /* 64 bit result */
57 __off_t ms_offset; /* off_t result */
59 #define ms_copyout_end ms_pad[0]
60 int ms_pad[2]; /* future use */
63 #define ms_copyout_size (offsetof(struct lwkt_msg, ms_copyout_end) - offsetof(struct lwkt_msg, ms_copyout_start))
65 #define MSGF_DONE 0x0001 /* asynch message is complete */
66 #define MSGF_REPLY 0x0002 /* asynch message has been returned */
67 #define MSGF_QUEUED 0x0004 /* message has been queued sanitychk */
68 #define MSGF_ASYNC 0x0008 /* sync/async hint */
69 #define MSGF_ABORTED 0x0010 /* message was aborted flag */
71 #define MSG_CMD_CDEV 0x00010000
72 #define MSG_CMD_VFS 0x00020000
73 #define MSG_CMD_SYSCALL 0x00030000
74 #define MSG_CMD_NETMSG 0x00040000
75 #define MSG_SUBCMD_MASK 0x0000FFFF
79 MALLOC_DECLARE(M_LWKTMSG);
83 typedef struct lwkt_port {
84 lwkt_msg_queue mp_msgq;
86 int mp_refs; /* references to port structure */
88 int (*mp_putport)(lwkt_port_t, lwkt_msg_t);
89 void * (*mp_waitport)(lwkt_port_t, lwkt_msg_t);
90 void (*mp_replyport)(lwkt_port_t, lwkt_msg_t);
91 void (*mp_abortport)(lwkt_port_t, lwkt_msg_t);
94 #define MSGPORTF_WAITING 0x0001
97 * These functions are good for userland as well as the kernel. The
98 * messaging function support for userland is provided by the kernel's
99 * kern/lwkt_msgport.c. The port functions are provided by userland.
101 extern void lwkt_initport(lwkt_port_t, struct thread *);
102 extern void lwkt_sendmsg(lwkt_port_t, lwkt_msg_t);
103 extern int lwkt_domsg(lwkt_port_t, lwkt_msg_t);
104 extern void *lwkt_getport(lwkt_port_t);