mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 00:24:51 +00:00
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:
parent
faa25e1df6
commit
09e96dfdcd
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user