3 * \brief UMP endpoint declarations
7 * Copyright (c) 2009, 2010, 2011, ETH Zurich.
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
15 #ifndef LIBBARRELFISH_UMP_ENDPOINT_H
16 #define LIBBARRELFISH_UMP_ENDPOINT_H
18 #include <sys/cdefs.h>
20 #include <barrelfish/waitset.h>
21 #include <barrelfish/ump_impl.h>
25 /// Incoming UMP endpoint
27 struct waitset_chanstate waitset_state; ///< Waitset per-channel state
28 struct ump_chan_state chan; ///< Incoming UMP channel state to poll
31 errval_t ump_endpoint_init(struct ump_endpoint *ep, volatile void *buf,
33 void ump_endpoint_destroy(struct ump_endpoint *ep);
34 errval_t ump_endpoint_register(struct ump_endpoint *ep, struct waitset *ws,
35 struct event_closure closure);
36 errval_t ump_endpoint_deregister(struct ump_endpoint *ep);
37 void ump_endpoint_migrate(struct ump_endpoint *ep, struct waitset *ws);
40 * \brief Returns true if there is a message pending on the given UMP endpoint
42 static inline bool ump_endpoint_can_recv(struct ump_endpoint *ep)
44 return ump_impl_poll(&ep->chan) != NULL;
48 * \brief Retrieve a message from the given UMP endpoint, if possible
50 * Non-blocking, may fail if there are no messages available.
52 * \param ep UMP endpoint
53 * \param retmsg Storage for incoming message
55 static inline errval_t ump_endpoint_recv(struct ump_endpoint *ep,
56 volatile struct ump_message **msg)
58 *msg = ump_impl_recv(&ep->chan);
63 return LIB_ERR_NO_UMP_MSG;
68 * \brief Return true if there's a message available
70 * \param channel UMP channal
72 static inline bool ump_endpoint_poll(struct waitset_chanstate *channel)
74 struct ump_endpoint *ep = (struct ump_endpoint *)
75 ((char *)channel - offsetof(struct ump_endpoint, waitset_state));
77 return ump_endpoint_can_recv(ep);
83 #endif // LIBBARRELFISH_UMP_ENDPOINT_H