'Building databases' has 10 seconds worth of sleeps that it doesn't need.
[dragonfly.git] / sys / sys / msgport.h
CommitLineData
ece04fd0
MD
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
df2244e3 6 * $DragonFly: src/sys/sys/msgport.h,v 1.9 2003/11/20 06:05:31 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) */
4fd10eb6 34 union {
c7114eea 35 struct lwkt_msg *ms_next; /* chaining / cache */
245e4f17 36 union sysunion *ms_sysunnext; /* chaining / cache */
c7114eea 37 struct lwkt_msg *ms_umsg; /* user message (UVA address) */
4fd10eb6 38 } opaque;
df2244e3 39 lwkt_port_t ms_target_port; /* current target or relay port */
ece04fd0 40 lwkt_port_t ms_reply_port; /* asynch replies returned here */
df2244e3
MD
41 int ms_maxsize; /* maximum returned message size */
42 int ms_cmd; /* message command */
43 int ms_flags; /* message flags */
44#define ms_copyout_start ms_msgsize
45 int ms_msgsize; /* sent/returned size of message */
46 int ms_error; /* positive error code or 0 */
a64ba182 47 union {
df2244e3 48 void *ms_resultp; /* misc pointer data or result */
90b9818c
MD
49 int ms_result; /* standard 'int'eger result */
50 long ms_lresult; /* long result */
51 int ms_fds[2]; /* two int bit results */
52 int32_t ms_result32; /* 32 bit result */
53 int64_t ms_result64; /* 64 bit result */
54 off_t ms_offset; /* off_t result */
a64ba182 55 } u;
245e4f17 56#define ms_copyout_end ms_pad[0]
a64ba182 57 int ms_pad[2]; /* future use */
ece04fd0
MD
58} lwkt_msg;
59
245e4f17
MD
60#define ms_copyout_size (offsetof(struct lwkt_msg, ms_copyout_end) - offsetof(struct lwkt_msg, ms_copyout_start))
61
ece04fd0
MD
62#define MSGF_DONE 0x0001 /* asynch message is complete */
63#define MSGF_REPLY 0x0002 /* asynch message has been returned */
64#define MSGF_QUEUED 0x0004 /* message has been queued sanitychk */
65#define MSGF_ASYNC 0x0008 /* sync/async hint */
df2244e3 66#define MSGF_ABORTED 0x0010 /* message was aborted flag */
ece04fd0 67
335dda38
MD
68#define MSG_CMD_CDEV 0x00010000
69#define MSG_CMD_VFS 0x00020000
70#define MSG_CMD_SYSCALL 0x00030000
bf82f9b7 71#define MSG_CMD_NETMSG 0x00040000
335dda38
MD
72#define MSG_SUBCMD_MASK 0x0000FFFF
73
ece04fd0
MD
74typedef struct lwkt_port {
75 lwkt_msg_queue mp_msgq;
76 int mp_flags;
245e4f17 77 int mp_refs; /* references to port structure */
335dda38 78 struct thread *mp_td;
df2244e3
MD
79 int (*mp_putport)(lwkt_port_t, lwkt_msg_t);
80 void * (*mp_waitport)(lwkt_port_t, lwkt_msg_t);
81 void (*mp_replyport)(lwkt_port_t, lwkt_msg_t);
82 void (*mp_abortport)(lwkt_port_t, lwkt_msg_t);
ece04fd0
MD
83} lwkt_port;
84
85#define MSGPORTF_WAITING 0x0001
86
df2244e3
MD
87/*
88 * These functions are good for userland as well as the kernel. The
89 * messaging function support for userland is provided by the kernel's
90 * kern/lwkt_msgport.c. The port functions are provided by userland.
91 */
92extern void lwkt_init_port(lwkt_port_t, struct thread *);
93extern void lwkt_initmsg_td(lwkt_msg_t, struct thread *);
94extern void lwkt_sendmsg(lwkt_port_t, lwkt_msg_t);
95extern int lwkt_domsg(lwkt_port_t, lwkt_msg_t);
96extern void *lwkt_getport(lwkt_port_t);
ece04fd0 97
df2244e3
MD
98extern int lwkt_putport(lwkt_port_t, lwkt_msg_t);
99extern void *lwkt_waitport(lwkt_port_t, lwkt_msg_t);
100extern void lwkt_replyport(lwkt_port_t, lwkt_msg_t);
101extern void lwkt_abortport(lwkt_port_t, lwkt_msg_t);
ece04fd0
MD
102
103#endif