1/** 2 * \file 3 * \brief LMP endpoints declarations 4 */ 5 6/* 7 * Copyright (c) 2009, 2010, 2011, ETH Zurich. 8 * All rights reserved. 9 * 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. 13 */ 14 15#ifndef LIBBARRELFISH_LMP_ENDPOINTS_H 16#define LIBBARRELFISH_LMP_ENDPOINTS_H 17 18#include <sys/cdefs.h> 19 20#include <barrelfish/waitset.h> 21#include <barrelfish_kpi/lmp.h> 22#include <barrelfish/caddr.h> 23#include <barrelfish_kpi/dispatcher_handle.h> 24 25__BEGIN_DECLS 26 27/// In-endpoint size of a maximum-sized LMP message plus header 28#define LMP_RECV_LENGTH (LMP_MSG_LENGTH + LMP_RECV_HEADER_LENGTH) 29 30/// Default size of LMP endpoint buffer (in words), must be >= LMP_RECV_LENGTH 31#define DEFAULT_LMP_BUF_WORDS (LMP_RECV_LENGTH * 2) 32 33/// LMP endpoint structure (including data accessed only by user code) 34struct lmp_endpoint { 35 struct lmp_endpoint *next, *prev; ///< Next/prev endpoint in poll list 36 struct capref recv_slot;///< Receive slot 37 struct waitset_chanstate waitset_state; ///< Waitset per-channel state 38 uint32_t buflen; ///< Length of endpoint buffer (in words) 39 uint32_t seen; ///< Position in buffer processed by poll loop, but 40 ///< not necessarily consumed by the user 41 struct lmp_endpoint_kern k; ///< Public part (shared with kernel) 42 /* buffer beyond end of struct */ 43}; 44 45 46/** 47 * \brief Message layout in user's buffer. 48 * 49 * Note that the kernel never delivers a message like this. 50 */ 51struct lmp_recv_buf { 52 size_t msglen; ///< Length of message payload (in words) 53 size_t buflen; ///< Length of entire buffer (in words) 54 uintptr_t words[0]; ///< Payload (variable length) 55}; 56 57/// Compute the size needed for an lmp_recv_buf buffer 58#define LMP_RECV_BUF_SIZE(n) (sizeof(struct lmp_recv_buf) + ((n)*sizeof(uintptr_t))) 59 60/// Fixed-length version of #lmp_recv_buf 61struct lmp_recv_msg { 62 struct lmp_recv_buf buf; 63 uintptr_t words[LMP_MSG_LENGTH]; ///< Payload (fixed length) 64}; 65 66/// Static initialiser for lmp_recv_msg 67#define LMP_RECV_MSG_INIT { .buf.buflen = LMP_MSG_LENGTH }; 68 69errval_t lmp_endpoint_alloc(size_t buflen, struct lmp_endpoint **retep); 70void lmp_endpoint_free(struct lmp_endpoint *ep); 71errval_t lmp_endpoint_create_in_slot(size_t buflen, struct capref dest, 72 struct lmp_endpoint **retep); 73void lmp_endpoint_set_recv_slot(struct lmp_endpoint *ep, struct capref slot); 74bool lmp_endpoint_can_recv(struct lmp_endpoint *ep); 75void lmp_endpoints_poll_disabled(dispatcher_handle_t handle); 76errval_t lmp_endpoint_recv(struct lmp_endpoint *ep, struct lmp_recv_buf *buf, 77 struct capref *cap); 78errval_t lmp_endpoint_register(struct lmp_endpoint *ep, struct waitset *ws, 79 struct event_closure closure); 80errval_t lmp_endpoint_deregister(struct lmp_endpoint *ep); 81void lmp_endpoint_migrate(struct lmp_endpoint *ep, struct waitset *ws); 82void lmp_endpoint_store_lrpc_disabled(struct lmp_endpoint *ep, uint32_t bufpos, 83 uintptr_t arg1, uintptr_t arg2, 84 uintptr_t arg3, uintptr_t arg4); 85void lmp_endpoint_init(void); 86 87__END_DECLS 88 89#endif // LIBBARRELFISH_LMP_ENDPOINTS_H 90