Fix CPU stats percentages formatting
[dragonfly.git] / sys / sys / msgport.h
CommitLineData
ece04fd0
MD
1/*
2 * SYS/MSGPORT.H
3 *
4 * Implements LWKT messages and ports.
5 *
90b9818c 6 * $DragonFly: src/sys/sys/msgport.h,v 1.5 2003/07/26 18:12:46 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 45 union {
90b9818c
MD
46 void *ms_resultp; /* misc pointer result */
47 int ms_result; /* standard 'int'eger result */
48 long ms_lresult; /* long result */
49 int ms_fds[2]; /* two int bit results */
50 int32_t ms_result32; /* 32 bit result */
51 int64_t ms_result64; /* 64 bit result */
52 off_t ms_offset; /* off_t result */
a64ba182
MD
53 } u;
54 int ms_pad[2]; /* future use */
ece04fd0
MD
55} lwkt_msg;
56
57#define MSGF_DONE 0x0001 /* asynch message is complete */
58#define MSGF_REPLY 0x0002 /* asynch message has been returned */
59#define MSGF_QUEUED 0x0004 /* message has been queued sanitychk */
60#define MSGF_ASYNC 0x0008 /* sync/async hint */
61
335dda38
MD
62#define MSG_CMD_CDEV 0x00010000
63#define MSG_CMD_VFS 0x00020000
64#define MSG_CMD_SYSCALL 0x00030000
65#define MSG_SUBCMD_MASK 0x0000FFFF
66
ece04fd0
MD
67typedef struct lwkt_port {
68 lwkt_msg_queue mp_msgq;
69 int mp_flags;
335dda38 70 struct thread *mp_td;
ece04fd0
MD
71 int (*mp_beginmsg)(lwkt_port_t port, lwkt_msg_t msg);
72 void (*mp_abortmsg)(lwkt_port_t port, lwkt_msg_t msg);
73 void (*mp_returnmsg)(lwkt_port_t port, lwkt_msg_t msg);
74} lwkt_port;
75
76#define MSGPORTF_WAITING 0x0001
77
78#ifdef _KERNEL
79
335dda38 80extern void lwkt_init_port(lwkt_port_t port, struct thread *td);
4fd10eb6 81extern void lwkt_initmsg_td(lwkt_msg_t msg, struct thread *td);
ece04fd0
MD
82extern void lwkt_sendmsg(lwkt_port_t port, lwkt_msg_t msg);
83extern int lwkt_domsg(lwkt_port_t port, lwkt_msg_t msg);
84extern int lwkt_waitmsg(lwkt_msg_t msg);
85extern void lwkt_replyport(lwkt_port_t port, lwkt_msg_t msg);
86extern void lwkt_abortport(lwkt_port_t port, lwkt_msg_t msg);
87extern int lwkt_putport(lwkt_port_t port, lwkt_msg_t msg);
88extern void *lwkt_getport(lwkt_port_t port);
89extern void *lwkt_waitport(lwkt_port_t port);
90
91#endif
92
93#endif