]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/irqs.h
update
[l4.git] / l4 / pkg / io / server / src / irqs.h
1 /*
2  * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9
10 #pragma once
11
12 #include <l4/sys/irq>
13
14 class Io_irq_pin
15 {
16 public:
17   enum Flags
18   {
19     F_shareable = 0x1,
20     F_chained   = 0x2,
21   };
22
23 private:
24   int _sw_irqs;
25   L4::Cap<L4::Irq> _irq;
26   unsigned short _flags;
27   unsigned short _max_sw_irqs;
28
29   void chg_flags(bool set, unsigned flags)
30   {
31     if (set)
32       _flags |= flags;
33     else
34       _flags &= ~flags;
35   }
36
37 public:
38   L4::Cap<L4::Irq> irq() const { return _irq; }
39   void irq(L4::Cap<L4::Irq> i) { _irq = i; }
40
41   Io_irq_pin() : _sw_irqs(0), _irq(), _flags(0), _max_sw_irqs(0) {}
42
43   void set_shareable(bool s)
44   { chg_flags(s, F_shareable); }
45
46   void set_chained(bool s)
47   { chg_flags(s, F_chained); }
48
49 public:
50   void add_sw_irq() { ++_max_sw_irqs; }
51   int sw_irqs() const { return _sw_irqs; }
52   void inc_sw_irqs() { ++_sw_irqs; }
53   void dec_sw_irqs() { ++_sw_irqs; }
54   virtual int bind(L4::Cap<L4::Irq> irq, unsigned mode) = 0;
55   virtual int unmask() = 0;
56   virtual int unbind() = 0;
57   virtual ~Io_irq_pin() {}
58
59   bool shared() const { return _max_sw_irqs > 1; }
60   bool shareable() const { return _flags & F_shareable; }
61   bool chained() const { return _flags & F_chained; }
62 };
63
64 class Kernel_irq_pin : public Io_irq_pin
65 {
66 private:
67   unsigned _idx;
68 public:
69   Kernel_irq_pin(unsigned idx) : Io_irq_pin(), _idx(idx) {}
70   int bind(L4::Cap<L4::Irq> irq, unsigned mode);
71   int unmask();
72   int unbind();
73 };
74