'Building databases' has 10 seconds worth of sleeps that it doesn't need.
[dragonfly.git] / sys / sys / msgport.h
... / ...
CommitLineData
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
6 * $DragonFly: src/sys/sys/msgport.h,v 1.9 2003/11/20 06:05:31 dillon Exp $
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;
18struct thread;
19
20typedef struct lwkt_msg *lwkt_msg_t;
21typedef struct lwkt_port *lwkt_port_t;
22
23typedef TAILQ_HEAD(lwkt_msg_queue, lwkt_msg) lwkt_msg_queue;
24
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.
29 *
30 * NOTE! 64-bit-align this structure.
31 */
32typedef struct lwkt_msg {
33 TAILQ_ENTRY(lwkt_msg) ms_node; /* link node (not always used) */
34 union {
35 struct lwkt_msg *ms_next; /* chaining / cache */
36 union sysunion *ms_sysunnext; /* chaining / cache */
37 struct lwkt_msg *ms_umsg; /* user message (UVA address) */
38 } opaque;
39 lwkt_port_t ms_target_port; /* current target or relay port */
40 lwkt_port_t ms_reply_port; /* asynch replies returned here */
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 */
47 union {
48 void *ms_resultp; /* misc pointer data or result */
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 */
55 } u;
56#define ms_copyout_end ms_pad[0]
57 int ms_pad[2]; /* future use */
58} lwkt_msg;
59
60#define ms_copyout_size (offsetof(struct lwkt_msg, ms_copyout_end) - offsetof(struct lwkt_msg, ms_copyout_start))
61
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 */
66#define MSGF_ABORTED 0x0010 /* message was aborted flag */
67
68#define MSG_CMD_CDEV 0x00010000
69#define MSG_CMD_VFS 0x00020000
70#define MSG_CMD_SYSCALL 0x00030000
71#define MSG_CMD_NETMSG 0x00040000
72#define MSG_SUBCMD_MASK 0x0000FFFF
73
74typedef struct lwkt_port {
75 lwkt_msg_queue mp_msgq;
76 int mp_flags;
77 int mp_refs; /* references to port structure */
78 struct thread *mp_td;
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);
83} lwkt_port;
84
85#define MSGPORTF_WAITING 0x0001
86
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);
97
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);
102
103#endif