1// vi:set ft=cpp: -*- Mode: C++ -*-
2/**
3 * \file
4 * The C++ Receive endpoint interface.
5 */
6/*
7 * (c) 2017 Alexander Warg <alexander.warg@kernkonzept.com>
8 *
9 * This file is part of TUD:OS and distributed under the terms of the
10 * GNU General Public License 2.
11 * Please see the COPYING-GPL-2 file for details.
12 *
13 * As a special exception, you may use this file as part of a free software
14 * library without restriction.  Specifically, if other files instantiate
15 * templates or use macros or inline functions from this file, or you compile
16 * this file and link it with other files to produce an executable, this
17 * file does not by itself cause the resulting executable to be covered by
18 * the GNU General Public License.  This exception does not however
19 * invalidate any other reasons why the executable file might be covered by
20 * the GNU General Public License.
21 */
22#pragma once
23
24#include <l4/sys/rcv_endpoint.h>
25#include <l4/sys/types.h>
26#include <l4/sys/capability>
27#include <l4/sys/cxx/ipc_iface>
28
29namespace L4 {
30
31class Thread;
32
33/**
34 * Interface for kernel objects that allow to receive IPC from them.
35 *
36 * Such an object is for example an Ipc_gate (with server rights) or an
37 * Irq_sender. Those objects allow to bind a thread that shall receive IPC from
38 * these object via bind_thread().
39 */
40class L4_EXPORT Rcv_endpoint :
41  public Kobject_t<Rcv_endpoint, Kobject, L4_PROTO_KOBJECT,
42                   Type_info::Demand_t<1> >
43{
44public:
45  /**
46   * Bind a thread to an IPC receive endpoint.
47   *
48   * \param t      Thread object that shall be bound to this receive endpoint.
49   * \param label  Label to assign to `this` receive endpoint. The two least
50   *               significant bits should usually be set to zero.
51   *
52   * \return Syscall return tag containing one of the following return codes.
53   *
54   * \retval L4_EOK      Operation successful.
55   * \retval -L4_EINVAL  `t` is not a thread object or other arguments were
56   *                     malformed.
57   * \retval -L4_EPERM   No #L4_CAP_FPAGE_S rights on `t` or the capability used
58   *                     to invoke this operation.
59   */
60  L4_INLINE_RPC_OP(L4_RCV_EP_BIND_OP,
61      l4_msgtag_t, bind_thread, (Ipc::Opt<Ipc::Cap<Thread> > t, l4_umword_t label));
62
63  typedef L4::Typeid::Rpcs_sys<bind_thread_t> Rpcs;
64};
65
66}
67