2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
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.
11 #include <l4/sys/capability>
15 #include <l4/cxx/ipc_server>
16 #include <l4/cxx/avl_tree>
17 #include <l4/cxx/list>
19 #include <l4/re/util/cap_alloc>
26 class Sw_icu : public Device, public Dev_feature, public L4::Server_object
32 int dispatch(l4_umword_t obj, L4::Ipc::Iostream &ios);
34 char const *hid() const { return "L40009"; }
35 int dispatch(l4_umword_t, l4_uint32_t func, L4::Ipc::Iostream &ios);
36 bool match_hw_feature(Hw::Dev_feature const *) const { return false; }
38 bool add_irqs(Resource const *r);
39 bool add_irq(unsigned n, unsigned flags, Io_irq_pin *be);
40 int alloc_irq(unsigned flags, Io_irq_pin *be);
41 bool irqs_allocated(Resource const *r);
44 int bind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &irqc);
45 int unbind_irq(l4_msgtag_t tag, unsigned irqn, L4::Ipc::Snd_fpage const &irqc);
46 int unmask_irq(l4_msgtag_t tag, unsigned irqn);
47 int set_mode(l4_msgtag_t tag, unsigned irqn, l4_umword_t mode);
50 class Sw_irq_pin : public cxx::Avl_tree_node
62 L4Re::Util::Auto_cap<L4::Irq>::Cap _irq;
67 S_irq_type_mask = Resource::Irq_type_mask,
73 S_user_mask = S_irq_type_mask | S_allow_set_mode
76 typedef unsigned Key_type;
78 static unsigned key_of(Sw_irq_pin const *o) { return o->_irqn; }
80 Sw_irq_pin(Io_irq_pin *master, unsigned irqn, unsigned flags)
81 : _state(flags & S_user_mask), _irqn(irqn), _master(master)
86 unsigned irqn() const { return _irqn; }
87 L4::Cap<L4::Irq> irq() const { return _irq.get(); }
89 bool bound() const { return _state & S_bound; }
90 bool unmask_via_icu() const { return _state & S_unmask_via_icu; }
91 unsigned type() const { return _state & S_irq_type_mask; }
92 unsigned l4_type() const;
93 int bind(L4::Cap<void> rc);
94 int unmask() { return _master->unmask(); }
96 int set_mode(l4_umword_t mode);
101 // int share(L4Re::Util::Auto_cap<L4::Irq>::Cap const &irq);
102 void allocate_master_irq();
105 typedef cxx::Avl_tree<Sw_irq_pin, Sw_irq_pin> Irq_set;
109 static Kernel_irq_pin *real_irq(unsigned n);
113 S_allow_set_mode = Sw_irq_pin::S_allow_set_mode,
116 static void *irq_loop(void*);
117 void set_host(Device *d) { _host = d; }
118 Device *host() const { return _host; }