// -*- Mode: C++ -*-
// vim:ft=cpp
/**
 * \file
 * \brief   Parent interface
 */
/*
 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
 *               Alexander Warg <warg@os.inf.tu-dresden.de>
 *     economic rights: Technische Universität Dresden (Germany)
 *
 * License: see LICENSE.spdx (in this directory or the directories above)
 */
#pragma once

#include <l4/sys/capability>
#include <l4/re/protocols.h>
#include <l4/sys/cxx/ipc_iface>

namespace L4Re {

/**
 * \defgroup api_l4re_parent Parent API
 * \ingroup api_l4re
 * \brief Parent interface.
 *
 * The parent interface provides means for an L4 task to signal changes in its
 * execution state. The main purpose is to signal program termination to the
 * program that started it, so that its resources can be reclaimed. In a typical
 * L4Re system, this program will be Moe or Ned.
 *
 * \see L4Re::Parent for information about the concrete interface.
 */

/**
 * \brief Parent interface
 * \ingroup api_l4re_parent
 *
 * \see \link api_l4re_parent Parent API \endlink for more details about
 *      the purpose.
 */
class L4_EXPORT Parent :
  public L4::Kobject_t<Parent, L4::Kobject, L4RE_PROTO_PARENT>
{
public:
  /**
   * Send a signal to the parent.
   *
   * \param sig Signal to send
   * \param val Value of the signal
   *
   * \retval 0   Success
   * \retval <0  IPC error
   *
   * \note The implementations of this interface in Moe and Ned only recognize
   * the signal 0, in which case they will terminate the application from which
   * the interface was invoked and not return. In this case, `val` is treated as
   * the application's return code. For any other value of `sig`, the method
   * just returns successfully.
   */
  L4_INLINE_RPC(long, signal, (unsigned long sig, unsigned long val));
  typedef L4::Typeid::Rpcs<signal_t> Rpcs;
};
};

