]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4sys/include/irq
d18997a91d9df868a5b88f07b51b1ef94e46c24d
[l4.git] / l4 / pkg / l4sys / include / irq
1 // vi:ft=cpp
2 /**
3  * \file
4  * \brief Interrupt functionality
5  * \ingroup l4_api
6  */
7 /*
8  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9  *               Alexander Warg <warg@os.inf.tu-dresden.de>
10  *     economic rights: Technische Universität Dresden (Germany)
11  *
12  * This file is part of TUD:OS and distributed under the terms of the
13  * GNU General Public License 2.
14  * Please see the COPYING-GPL-2 file for details.
15  *
16  * As a special exception, you may use this file as part of a free software
17  * library without restriction.  Specifically, if other files instantiate
18  * templates or use macros or inline functions from this file, or you compile
19  * this file and link it with other files to produce an executable, this
20  * file does not by itself cause the resulting executable to be covered by
21  * the GNU General Public License.  This exception does not however
22  * invalidate any other reasons why the executable file might be covered by
23  * the GNU General Public License.
24  */
25
26 #pragma once
27
28 #include <l4/sys/icu.h>
29 #include <l4/sys/irq.h>
30 #include <l4/sys/capability>
31
32 namespace L4 {
33 namespace Protocol { enum { Icu = L4_PROTO_IRQ }; }
34 namespace Protocol { enum { Irq = L4_PROTO_IRQ }; }
35
36 class Irq_eio : public Kobject_t<Irq_eio, Kobject, L4_PROTO_IRQ>
37 {
38   L4_KOBJECT_DISABLE_COPY(Irq_eio)
39
40 public:
41   l4_msgtag_t unmask(unsigned irqnum, l4_umword_t *label, l4_timeout_t to,
42                      l4_utcb_t *utcb = l4_utcb()) throw()
43   { return l4_icu_control_u(cap(), irqnum, L4_ICU_CTL_UNMASK, label, to, utcb); }
44 };
45
46 /**
47  * \brief C++ version of an L4 IRQ.
48  * \ingroup l4_irq_api
49  *
50  * <c>\#include <l4/sys/irq></c>
51  *
52  * \see \ref l4_irq_api for an overview and C bindings.
53  */
54 class Irq : public Kobject_t<Irq, Irq_eio, L4_PROTO_IRQ>
55 {
56   L4_KOBJECT(Irq);
57
58 public:
59
60   /**
61    * \copydoc l4_irq_attach()
62    * \note \a irq is the implicit \a this pointer.
63    */
64   l4_msgtag_t attach(l4_umword_t label, Cap<Thread> const &thread,
65                      l4_utcb_t *utcb = l4_utcb()) throw()
66   { return l4_irq_attach_u(cap(), label, thread.cap(), utcb); }
67
68   /**
69    * \copydoc l4_irq_chain()
70    * \note \a irq is the implicit \a this pointer.
71    */
72   l4_msgtag_t chain(l4_umword_t label, Cap<Irq> const &slave,
73                     l4_utcb_t *utcb = l4_utcb()) throw()
74   { return l4_irq_chain_u(cap(), label, slave.cap(), utcb); }
75
76   /**
77    * \copydoc l4_irq_detach()
78    * \note \a irq is the implicit \a this pointer.
79    */
80   l4_msgtag_t detach(l4_utcb_t *utcb = l4_utcb()) throw()
81   { return l4_irq_detach_u(cap(), utcb); }
82
83
84   /**
85    * \copydoc l4_irq_receive()
86    * \note \a irq is the implicit \a this pointer.
87    */
88   l4_msgtag_t receive(l4_timeout_t to = L4_IPC_NEVER,
89                       l4_utcb_t *utcb = l4_utcb()) throw()
90   { return l4_irq_receive_u(cap(), to, utcb); }
91
92   /**
93    * \copydoc l4_irq_wait()
94    * \note \a irq is the implicit \a this pointer.
95    */
96   l4_msgtag_t wait(l4_umword_t *label, l4_timeout_t to = L4_IPC_NEVER,
97                    l4_utcb_t *utcb = l4_utcb()) throw()
98   { return l4_irq_wait_u(cap(), label, to, utcb); }
99
100   /**
101    * \copydoc l4_irq_unmask()
102    * \note \a irq is the implicit \a this pointer.
103    */
104   l4_msgtag_t unmask(l4_utcb_t *utcb = l4_utcb()) throw()
105   { return l4_irq_unmask_u(cap(), utcb); }
106
107   /**
108    * \copydoc l4_irq_trigger()
109    * \note \a irq is the implicit \a this pointer.
110    */
111   l4_msgtag_t trigger(l4_utcb_t *utcb = l4_utcb()) throw()
112   { return l4_irq_trigger_u(cap(), utcb); }
113
114 };
115
116
117 /**
118  * \brief C++ version of an interrupt controller.
119  * \ingroup l4_icu_api
120  *
121  * <c>\#include <l4/sys/icu></c>
122  *
123  * \see \ref l4_icu_api for an overview and C bindings.
124  */
125 class Icu : public Kobject_t<Icu, Irq_eio, L4_PROTO_IRQ>
126 {
127   L4_KOBJECT(Icu);
128
129 public:
130   enum Flow_type
131   {
132     F_none       = L4_IRQ_F_NONE,
133     F_level_high = L4_IRQ_F_LEVEL_HIGH,
134     F_level_low  = L4_IRQ_F_LEVEL_LOW,
135     F_pos_edge   = L4_IRQ_F_POS_EDGE,
136     F_neg_edge   = L4_IRQ_F_NEG_EDGE,
137     F_mask       = L4_IRQ_F_MASK,
138   };
139
140   enum Flags
141   {
142     F_msi = L4_ICU_FLAG_MSI
143   };
144
145   /**
146    * \brief Info for an ICU.
147    * \ingroup l4_icu_api
148    *
149    * This class adds access functions.
150    * \see l4_icu_info().
151    */
152   class Info : public l4_icu_info_t
153   {
154   public:
155     bool supports_msi() const { return features & F_msi; }
156   };
157
158   /**
159    * \copydoc l4_icu_bind()
160    * \note \a the icu argument is the implicit \a this pointer.
161    */
162   l4_msgtag_t bind(unsigned irqnum, L4::Cap<Irq> irq,
163                    l4_utcb_t *utcb = l4_utcb()) throw()
164   { return l4_icu_bind_u(cap(), irqnum, irq.cap(), utcb); }
165
166   /**
167    * \copydoc l4_icu_unbind()
168    * \note \a the icu argument is the implicit \a this pointer.
169    */
170   l4_msgtag_t unbind(unsigned irqnum, L4::Cap<Irq> irq,
171                      l4_utcb_t *utcb = l4_utcb()) throw()
172   { return l4_icu_unbind_u(cap(), irqnum, irq.cap(), utcb); }
173
174   /**
175    * \copydoc l4_icu_info()
176    * \note \a the icu argument is the implicit \a this pointer.
177    */
178   l4_msgtag_t info(l4_icu_info_t *info, l4_utcb_t *utcb = l4_utcb()) throw()
179   { return l4_icu_info_u(cap(), info, utcb); }
180
181   /**
182    * \copydoc l4_icu_msi_info()
183    * \note \a the icu argument is the implicit \a this pointer.
184    */
185   l4_msgtag_t msi_info(unsigned irqnum, l4_umword_t *msg,
186                        l4_utcb_t *utcb = l4_utcb()) throw()
187   { return l4_icu_msi_info_u(cap(), irqnum, msg, utcb); }
188
189   l4_msgtag_t control(unsigned irqnum, unsigned op, l4_umword_t *label,
190                       l4_timeout_t to, l4_utcb_t *utcb = l4_utcb()) throw()
191   { return l4_icu_control_u(cap(), irqnum, op, label, to, utcb); }
192
193   l4_msgtag_t mask(unsigned irqnum, l4_umword_t *label, l4_timeout_t to,
194                    l4_utcb_t *utcb = l4_utcb()) throw()
195   { return l4_icu_control_u(cap(), irqnum, L4_ICU_CTL_MASK, label, to, utcb); }
196
197   l4_msgtag_t set_mode(unsigned irqnum, l4_umword_t mode,
198                        l4_utcb_t *utcb = l4_utcb()) throw()
199   { return l4_icu_set_mode_u(cap(), irqnum, mode, utcb); }
200 };
201
202 }