mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
parent
c437255d96
commit
b3dd45942e
@ -20,22 +20,6 @@
|
||||
|
||||
#include "routine.h"
|
||||
|
||||
/**
|
||||
* Context base for IRQ, Timer, etc.
|
||||
*/
|
||||
class Driver_context : public Genode::Signal_context
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Perform context operation
|
||||
*/
|
||||
virtual void handle() = 0;
|
||||
|
||||
virtual char const *debug() = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This singelton currently received all signals
|
||||
*/
|
||||
@ -78,8 +62,7 @@ class Service_handler
|
||||
Genode::Signal s = _receiver->wait_for_signal();
|
||||
|
||||
/* handle signal IRQ, timer, or event signals */
|
||||
Driver_context *ctx = static_cast<Driver_context *>(s.context());
|
||||
ctx->handle();
|
||||
static_cast<Genode::Signal_dispatcher_base *>(s.context())->dispatch(s.num());
|
||||
block = false;
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,18 @@ static Signal_helper *_signal = 0;
|
||||
/**
|
||||
* Context for events
|
||||
*/
|
||||
class Event_context : public Driver_context
|
||||
class Event_context
|
||||
{
|
||||
private:
|
||||
|
||||
Genode::Signal_context_capability _ctx_cap;
|
||||
|
||||
Genode::Signal_dispatcher<Event_context> _dispatcher;
|
||||
|
||||
void _handle(unsigned) {
|
||||
Routine::schedule_all(); }
|
||||
|
||||
Event_context()
|
||||
: _ctx_cap(_signal->receiver()->manage(this)) {
|
||||
_signal->sender()->context(_ctx_cap); }
|
||||
: _dispatcher(*_signal->receiver(), *this, &Event_context::_handle) {
|
||||
_signal->sender()->context(_dispatcher); }
|
||||
|
||||
public:
|
||||
|
||||
@ -40,9 +43,6 @@ class Event_context : public Driver_context
|
||||
void submit() {
|
||||
_signal->sender()->submit(); }
|
||||
|
||||
void handle() {
|
||||
Routine::schedule_all(); }
|
||||
|
||||
char const *debug() { return "Event_context"; }
|
||||
};
|
||||
|
||||
|
@ -40,16 +40,15 @@ struct Irq_handler : Genode::List<Irq_handler>::Element
|
||||
/**
|
||||
* Signal context for IRQs
|
||||
*/
|
||||
class Irq_context : public Driver_context,
|
||||
public Genode::List<Irq_context>::Element
|
||||
class Irq_context : public Genode::List<Irq_context>::Element
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Genode::List<Irq_context>::Element LE;
|
||||
|
||||
unsigned int _irq; /* IRQ number */
|
||||
Genode::List<Irq_handler> _handler_list; /* List of registered handlers */
|
||||
Genode::Signal_context_capability _ctx_cap; /* capability for this context */
|
||||
unsigned int _irq; /* IRQ number */
|
||||
Genode::List<Irq_handler> _handler_list; /* List of registered handlers */
|
||||
Genode::Signal_dispatcher<Irq_context> _dispatcher;
|
||||
|
||||
static Genode::List<Irq_context> *_list()
|
||||
{
|
||||
@ -83,7 +82,7 @@ class Irq_context : public Driver_context,
|
||||
Irq_context *ctx = static_cast<Irq_context *>(irq);
|
||||
|
||||
/* set context & submit signal */
|
||||
_signal->sender()->context(ctx->_ctx_cap);
|
||||
_signal->sender()->context(ctx->_dispatcher);
|
||||
_signal->sender()->submit();
|
||||
|
||||
/* wait for interrupt to get acked at device side */
|
||||
@ -135,11 +134,13 @@ class Irq_context : public Driver_context,
|
||||
return handled;
|
||||
}
|
||||
|
||||
void _handle(unsigned) { _handle(); }
|
||||
|
||||
public:
|
||||
|
||||
Irq_context(unsigned int irq)
|
||||
: _irq(irq),
|
||||
_ctx_cap(_signal->receiver()->manage(this))
|
||||
_dispatcher(*_signal->receiver(), *this, &Irq_context::_handle)
|
||||
{
|
||||
/* register at DDE (shared) */
|
||||
int ret = dde_kit_interrupt_attach(_irq, 0, 0, _dde_handler, this);
|
||||
@ -151,7 +152,6 @@ class Irq_context : public Driver_context,
|
||||
}
|
||||
|
||||
|
||||
inline void handle() { _handle(); }
|
||||
const char *debug() { return "Irq_context"; }
|
||||
|
||||
/**
|
||||
|
@ -27,28 +27,22 @@ static Signal_helper *_signal = 0;
|
||||
/**
|
||||
* Signal context for time-outs
|
||||
*/
|
||||
class Timer_context : public Driver_context
|
||||
class Timer_context
|
||||
{
|
||||
private:
|
||||
|
||||
timer_list *_timer; /* Linux timer */
|
||||
dde_kit_timer *_dde_timer; /* DDE kit timer */
|
||||
Genode::Signal_context_capability _ctx_cap; /* Signal-context cap
|
||||
for this timer */
|
||||
timer_list *_timer; /* Linux timer */
|
||||
dde_kit_timer *_dde_timer; /* DDE kit timer */
|
||||
Genode::Signal_dispatcher<Timer_context> _dispatcher;
|
||||
|
||||
/* call timer function */
|
||||
void _handle(unsigned) { _timer->function(_timer->data); }
|
||||
|
||||
public:
|
||||
|
||||
Timer_context(timer_list *timer)
|
||||
: _timer(timer), _dde_timer(0),
|
||||
_ctx_cap(_signal->receiver()->manage(this)) { }
|
||||
|
||||
~Timer_context()
|
||||
{
|
||||
_signal->receiver()->dissolve(this);
|
||||
}
|
||||
|
||||
/* call timer function */
|
||||
void handle() { _timer->function(_timer->data); }
|
||||
_dispatcher(*_signal->receiver(), *this, &Timer_context::_handle) {}
|
||||
|
||||
/* schedule next timeout */
|
||||
void schedule(unsigned long expires)
|
||||
@ -71,7 +65,7 @@ class Timer_context : public Driver_context
|
||||
/**
|
||||
* Return internal signal cap
|
||||
*/
|
||||
Genode::Signal_context_capability cap() const { return _ctx_cap; }
|
||||
Genode::Signal_context_capability cap() const { return _dispatcher; }
|
||||
|
||||
/**
|
||||
* Convert 'timer_list' to 'Timer_conext'
|
||||
|
Loading…
x
Reference in New Issue
Block a user