4 * Implements Inlines for LWKT messages and ports.
7 #ifndef _SYS_MSGPORT2_H_
8 #define _SYS_MSGPORT2_H_
12 #error "This file should not be included by userland programs."
16 #include <sys/systm.h>
19 * Initialize a LWKT message structure. Note that if the message supports
20 * an abort MSGF_ABORTABLE must be passed in flags.
22 * Note that other areas of the LWKT msg may already be initialized, so we
23 * do not zero the message here.
25 * Messages are marked as DONE until sent.
29 lwkt_initmsg(lwkt_msg_t msg, lwkt_port_t rport, int flags)
31 msg->ms_flags = MSGF_DONE | flags;
32 msg->ms_reply_port = rport;
37 lwkt_initmsg_abortable(lwkt_msg_t msg, lwkt_port_t rport, int flags,
38 void (*abortfn)(lwkt_msg_t))
40 lwkt_initmsg(msg, rport, flags | MSGF_ABORTABLE);
41 msg->ms_abortfn = abortfn;
46 lwkt_replymsg(lwkt_msg_t msg, int error)
50 msg->ms_error = error;
51 port = msg->ms_reply_port;
52 port->mp_replyport(port, msg);
56 * Retrieve the next message from the port's message queue, return NULL
57 * if no messages are pending. The retrieved message will either be a
58 * request or a reply based on the MSGF_REPLY bit.
60 * If the backend port is a thread port, the the calling thread MUST
65 lwkt_getport(lwkt_port_t port)
67 return(port->mp_getport(port));
72 lwkt_waitport(lwkt_port_t port, int flags)
74 return(port->mp_waitport(port, flags));
79 lwkt_waitmsg(lwkt_msg_t msg, int flags)
81 return(msg->ms_reply_port->mp_waitmsg(msg, flags));
87 lwkt_checkmsg(lwkt_msg_t msg)
89 return(msg->ms_flags & MSGF_DONE);
94 lwkt_dropmsg(lwkt_msg_t msg)
99 KKASSERT(msg->ms_flags & MSGF_DROPABLE);
100 port = msg->ms_target_port;
102 error = port->mp_dropmsg(port, msg);
108 lwkt_setmsg_receipt(lwkt_msg_t msg, void (*receiptfn)(lwkt_msg_t, lwkt_port_t))
110 msg->ms_flags |= MSGF_RECEIPT;
111 msg->ms_receiptfn = receiptfn;
115 #endif /* _SYS_MSGPORT2_H_ */