Fix minor bug in last commit, add the required register keyword back in
[dragonfly.git] / sys / sys / msgport.h
CommitLineData
ece04fd0
MD
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
4fd10eb6 6 * $DragonFly: src/sys/sys/msgport.h,v 1.4 2003/07/24 23:52:39 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
MD
34 union {
35 struct lwkt_msg *ms_next; /* chaining / cache */
36 union sysunion *ms_sysnext; /* chaining / cache */
37 struct lwkt_msg *ms_umsg; /* user message (UVA address) */
38 } opaque;
ece04fd0
MD
39 lwkt_port_t ms_target_port; /* only used in certain situations */
40 lwkt_port_t ms_reply_port; /* asynch replies returned here */
41 int ms_abortreq; /* set asynchronously */
42 int ms_cmd;
43 int ms_flags;
44 int ms_error;
a64ba182
MD
45 union {
46 void *ms_resultp;
47 int32_t ms_result32;
48 int64_t ms_result64;
49 } u;
50 int ms_pad[2]; /* future use */
ece04fd0
MD
51} lwkt_msg;
52
53#define MSGF_DONE 0x0001 /* asynch message is complete */
54#define MSGF_REPLY 0x0002 /* asynch message has been returned */
55#define MSGF_QUEUED 0x0004 /* message has been queued sanitychk */
56#define MSGF_ASYNC 0x0008 /* sync/async hint */
57
335dda38
MD
58#define MSG_CMD_CDEV 0x00010000
59#define MSG_CMD_VFS 0x00020000
60#define MSG_CMD_SYSCALL 0x00030000
61#define MSG_SUBCMD_MASK 0x0000FFFF
62
ece04fd0
MD
63typedef struct lwkt_port {
64 lwkt_msg_queue mp_msgq;
65 int mp_flags;
335dda38 66 struct thread *mp_td;
ece04fd0
MD
67 int (*mp_beginmsg)(lwkt_port_t port, lwkt_msg_t msg);
68 void (*mp_abortmsg)(lwkt_port_t port, lwkt_msg_t msg);
69 void (*mp_returnmsg)(lwkt_port_t port, lwkt_msg_t msg);
70} lwkt_port;
71
72#define MSGPORTF_WAITING 0x0001
73
74#ifdef _KERNEL
75
335dda38 76extern void lwkt_init_port(lwkt_port_t port, struct thread *td);
4fd10eb6 77extern void lwkt_initmsg_td(lwkt_msg_t msg, struct thread *td);
ece04fd0
MD
78extern void lwkt_sendmsg(lwkt_port_t port, lwkt_msg_t msg);
79extern int lwkt_domsg(lwkt_port_t port, lwkt_msg_t msg);
80extern int lwkt_waitmsg(lwkt_msg_t msg);
81extern void lwkt_replyport(lwkt_port_t port, lwkt_msg_t msg);
82extern void lwkt_abortport(lwkt_port_t port, lwkt_msg_t msg);
83extern int lwkt_putport(lwkt_port_t port, lwkt_msg_t msg);
84extern void *lwkt_getport(lwkt_port_t port);
85extern void *lwkt_waitport(lwkt_port_t port);
86
87#endif
88
89#endif