Readd _G_config.h and the missing std headers. This brings C++ back to where
[dragonfly.git] / sys / sys / msgport.h
CommitLineData
ece04fd0
MD
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
3227f1b8 6 * $DragonFly: src/sys/sys/msgport.h,v 1.14 2004/03/06 19:40:32 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
05220613
MD
15#ifndef _SYS_STDINT_H_
16#include <sys/stdint.h>
17#endif
ece04fd0
MD
18
19struct lwkt_msg;
20struct lwkt_port;
335dda38 21struct thread;
ece04fd0
MD
22
23typedef struct lwkt_msg *lwkt_msg_t;
24typedef struct lwkt_port *lwkt_port_t;
25
335dda38
MD
26typedef TAILQ_HEAD(lwkt_msg_queue, lwkt_msg) lwkt_msg_queue;
27
ece04fd0
MD
28/*
29 * The standard message and port structure for communications between
30 * threads. See kern/lwkt_msgport.c for documentation on how messages and
31 * ports work.
a64ba182
MD
32 *
33 * NOTE! 64-bit-align this structure.
ece04fd0
MD
34 */
35typedef struct lwkt_msg {
36 TAILQ_ENTRY(lwkt_msg) ms_node; /* link node (not always used) */
4fd10eb6 37 union {
c7114eea 38 struct lwkt_msg *ms_next; /* chaining / cache */
245e4f17 39 union sysunion *ms_sysunnext; /* chaining / cache */
c7114eea 40 struct lwkt_msg *ms_umsg; /* user message (UVA address) */
4fd10eb6 41 } opaque;
df2244e3 42 lwkt_port_t ms_target_port; /* current target or relay port */
ece04fd0 43 lwkt_port_t ms_reply_port; /* asynch replies returned here */
f6bf3af1 44 int ms_unused1;
df2244e3
MD
45 int ms_cmd; /* message command */
46 int ms_flags; /* message flags */
47#define ms_copyout_start ms_msgsize
f6bf3af1 48 int ms_msgsize; /* size of message */
df2244e3 49 int ms_error; /* positive error code or 0 */
a64ba182 50 union {
df2244e3 51 void *ms_resultp; /* misc pointer data or result */
90b9818c
MD
52 int ms_result; /* standard 'int'eger result */
53 long ms_lresult; /* long result */
54 int ms_fds[2]; /* two int bit results */
05220613
MD
55 __int32_t ms_result32; /* 32 bit result */
56 __int64_t ms_result64; /* 64 bit result */
57 __off_t ms_offset; /* off_t result */
a64ba182 58 } u;
245e4f17 59#define ms_copyout_end ms_pad[0]
a64ba182 60 int ms_pad[2]; /* future use */
ece04fd0
MD
61} lwkt_msg;
62
245e4f17
MD
63#define ms_copyout_size (offsetof(struct lwkt_msg, ms_copyout_end) - offsetof(struct lwkt_msg, ms_copyout_start))
64
ece04fd0
MD
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 */
df2244e3 69#define MSGF_ABORTED 0x0010 /* message was aborted flag */
ece04fd0 70
335dda38
MD
71#define MSG_CMD_CDEV 0x00010000
72#define MSG_CMD_VFS 0x00020000
73#define MSG_CMD_SYSCALL 0x00030000
bf82f9b7 74#define MSG_CMD_NETMSG 0x00040000
335dda38
MD
75#define MSG_SUBCMD_MASK 0x0000FFFF
76
9eeaa8a9
JH
77#ifdef _KERNEL
78#ifdef MALLOC_DECLARE
79MALLOC_DECLARE(M_LWKTMSG);
80#endif
81#endif
82
ece04fd0
MD
83typedef struct lwkt_port {
84 lwkt_msg_queue mp_msgq;
85 int mp_flags;
245e4f17 86 int mp_refs; /* references to port structure */
335dda38 87 struct thread *mp_td;
df2244e3
MD
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);
ece04fd0
MD
92} lwkt_port;
93
94#define MSGPORTF_WAITING 0x0001
95
df2244e3
MD
96/*
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.
100 */
c95cd171 101extern void lwkt_initport(lwkt_port_t, struct thread *);
df2244e3
MD
102extern void lwkt_sendmsg(lwkt_port_t, lwkt_msg_t);
103extern int lwkt_domsg(lwkt_port_t, lwkt_msg_t);
104extern void *lwkt_getport(lwkt_port_t);
ece04fd0 105
ece04fd0 106#endif