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