1// vi:set ft=cpp: -*- Mode: C++ -*-
2/**
3 * \file
4 * Exception C++ interface.
5 */
6/*
7 * (c) 2014 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
23#pragma once
24
25#include <l4/sys/capability>
26#include <l4/sys/types.h>
27#include <l4/sys/cxx/ipc_types>
28#include <l4/sys/cxx/ipc_iface>
29
30namespace L4 {
31
32/**
33 * Exception interface.
34 *
35 * This class defines the interface for handling exception IPC. When an
36 * exception occurs during program execution, for example due to a division by
37 * zero, the kernel will synthesise an exception IPC and send it to the
38 * thread's exception handler, who can then handle it.
39 *
40 * The exception handler is set with the L4::Thread::control interface.
41 */
42class L4_EXPORT Exception :
43  public Kobject_0t<Exception, L4_PROTO_EXCEPTION>
44{
45public:
46  // TODO: pass a reference/pointer to the UTCB not copy the regs
47  /**
48   * Exception call
49   *
50   * \param      regs  Register state of the faulting thread.
51   * \param      rwin  Receive window in the address space.
52   * \param[out] fp    Optional flex-page to resolve the exception.
53   *
54   * \return  Message tag containing error code.
55   *
56   */
57  L4_INLINE_RPC(
58      l4_msgtag_t, exception, (L4::Ipc::In_out<l4_exc_regs_t *> regs,
59                               L4::Ipc::Rcv_fpage rwin,
60                               L4::Ipc::Opt<L4::Ipc::Snd_fpage &> fp));
61
62  typedef L4::Typeid::Rpc_nocode<exception_t> Rpcs;
63};
64
65}
66