4 * Implements Inlines for LWKT messages and ports.
7 #ifndef _SYS_MSGPORT2_H_
8 #define _SYS_MSGPORT2_H_
11 #error "This file should not be included by userland programs."
15 #include <sys/systm.h>
19 MALLOC_DECLARE(M_LWKTMSG
);
23 * Initialize a LWKT message structure. Note that if the message supports
24 * an abort MSGF_ABORTABLE must be passed in flags.
26 * Note that other areas of the LWKT msg may already be initialized, so we
27 * do not zero the message here.
29 * Messages are marked as DONE until sent.
33 lwkt_initmsg(lwkt_msg_t msg
, lwkt_port_t rport
, int flags
)
35 msg
->ms_flags
= MSGF_DONE
| flags
;
36 msg
->ms_reply_port
= rport
;
41 lwkt_initmsg_abortable(lwkt_msg_t msg
, lwkt_port_t rport
, int flags
,
42 void (*abortfn
)(lwkt_msg_t
))
44 lwkt_initmsg(msg
, rport
, flags
| MSGF_ABORTABLE
);
45 msg
->ms_abortfn
= abortfn
;
50 lwkt_replymsg(lwkt_msg_t msg
, int error
)
54 msg
->ms_error
= error
;
55 port
= msg
->ms_reply_port
;
56 port
->mp_replyport(port
, msg
);
60 * Retrieve the next message from the port's message queue, return NULL
61 * if no messages are pending. The retrieved message will either be a
62 * request or a reply based on the MSGF_REPLY bit.
64 * If the backend port is a thread port, the the calling thread MUST
69 lwkt_getport(lwkt_port_t port
)
71 return(port
->mp_getport(port
));
76 lwkt_waitport(lwkt_port_t port
, int flags
)
78 return(port
->mp_waitport(port
, flags
));
83 lwkt_waitmsg(lwkt_msg_t msg
, int flags
)
85 return(msg
->ms_reply_port
->mp_waitmsg(msg
, flags
));
91 lwkt_checkmsg(lwkt_msg_t msg
)
93 return(msg
->ms_flags
& MSGF_DONE
);
98 lwkt_dropmsg(lwkt_msg_t msg
)
103 KKASSERT(msg
->ms_flags
& MSGF_DROPABLE
);
104 port
= msg
->ms_target_port
;
106 error
= port
->mp_dropmsg(port
, msg
);
112 lwkt_setmsg_receipt(lwkt_msg_t msg
, void (*receiptfn
)(lwkt_msg_t
, lwkt_port_t
))
114 msg
->ms_flags
|= MSGF_RECEIPT
;
115 msg
->ms_receiptfn
= receiptfn
;
118 #endif /* _SYS_MSGPORT2_H_ */