dde_kit: use async IRQ session interface

Up to now, dde_kit used the synchronous IRQ session interface. This
interface is going to get deprectated very soon.

Issue #1456.
This commit is contained in:
Josef Söntgen 2015-04-02 14:52:36 +02:00 committed by Christian Helmuth
parent faa25e1df6
commit 09e96dfdcd
1 changed files with 27 additions and 6 deletions

View File

@ -54,6 +54,9 @@ class Irq_handler : Dde_kit::Thread, public Avl_node<Irq_handler>
int _handle_irq; /* nested irq disable counter */
Lock _lock; /* synchronize access to counter */
Genode::Signal_receiver _sig_rec;
Genode::Signal_dispatcher<Irq_handler> _irq_dispatcher;
const char * _compose_thread_name(unsigned irq)
{
@ -61,6 +64,16 @@ class Irq_handler : Dde_kit::Thread, public Avl_node<Irq_handler>
return _thread_name;
}
void _handle(unsigned)
{
_irq.ack_irq();
/* only call registered handler function, if IRQ is not disabled */
_lock.lock();
if (_handle_irq) _handler(_priv);
_lock.unlock();
}
public:
Irq_handler(unsigned irq, void (*handler)(void *), void *priv,
@ -68,12 +81,18 @@ class Irq_handler : Dde_kit::Thread, public Avl_node<Irq_handler>
:
Dde_kit::Thread(_compose_thread_name(irq)), _irq_number(irq),
_irq(irq), _handler(handler), _init(init), _priv(priv),
_shared(shared), _handle_irq(1), _lock(Lock::LOCKED)
_shared(shared), _handle_irq(1), _lock(Lock::LOCKED),
_irq_dispatcher(_sig_rec, *this, &Irq_handler::_handle)
{
_irq.sigh(_irq_dispatcher);
start();
/* wait until thread is started */
Lock::Guard guard(_lock);
/* initial ack so that we will receive further interrupts */
_irq.ack_irq();
}
/** Enable IRQ handling */
@ -102,12 +121,14 @@ class Irq_handler : Dde_kit::Thread, public Avl_node<Irq_handler>
_lock.unlock();
while (1) {
_irq.wait_for_irq();
using namespace Genode;
/* only call registered handler function, if IRQ is not disabled */
_lock.lock();
if (_handle_irq) _handler(_priv);
_lock.unlock();
Signal sig = _sig_rec.wait_for_signal();
int num = sig.num();
Signal_dispatcher_base *dispatcher;
dispatcher = dynamic_cast<Signal_dispatcher_base *>(sig.context());
dispatcher->dispatch(num);
}
}