base: make irq_session asynchronous

second step

options: factor out common parts of irq_session_component.cc
options: use on foc arm no proxy threads

Fixes #1456
This commit is contained in:
Alexander Boettcher
2015-03-17 15:41:47 +01:00
committed by Christian Helmuth
parent e2cbc7c5b3
commit faa25e1df6
36 changed files with 872 additions and 1132 deletions

View File

@@ -1,75 +0,0 @@
/*
* \brief IRQ session interface for NOVA
* \author Norman Feske
* \date 2010-01-30
*/
/*
* Copyright (C) 2010-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
#define _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_
#include <base/lock.h>
#include <base/rpc_server.h>
#include <util/list.h>
#include <irq_session/capability.h>
namespace Genode {
class Irq_proxy_component;
class Irq_session_component : public Rpc_object<Irq_session>,
public List<Irq_session_component>::Element
{
private:
/*
* Each IRQ session uses a dedicated server activation
*/
enum { STACK_SIZE = 2048 };
Rpc_entrypoint _ep;
Irq_session_capability _irq_cap;
Irq_proxy_component *_proxy;
public:
/**
* Constructor
*
* \param cap_session capability session to use
* \param irq_alloc platform-dependent IRQ allocator
* \param args session construction arguments
*/
Irq_session_component(Cap_session *cap_session,
Range_allocator *irq_alloc,
const char *args);
/**
* Destructor
*/
~Irq_session_component();
/**
* Return capability to this session
*
* If an initialization error occurs, returned capability is invalid.
*/
Irq_session_capability cap() const { return _irq_cap; }
/***************************
** Irq session interface **
***************************/
void wait_for_irq();
Irq_signal signal();
};
}
#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */

View File

@@ -170,43 +170,68 @@ class Genode::Irq_proxy_component : public Irq_proxy<Irq_thread>
};
typedef Irq_proxy<Irq_thread> Proxy;
void Irq_session_component::wait_for_irq()
/***************************
** IRQ session component **
***************************/
void Irq_session_component::ack_irq()
{
_proxy->wait_for_irq();
/* interrupt ocurred and proxy woke us up */
if (!_proxy) {
PERR("Expected to find IRQ proxy for IRQ %02x", _irq_number);
return;
}
_proxy->ack_irq();
}
Irq_session_component::Irq_session_component(Cap_session *cap_session,
Range_allocator *irq_alloc,
Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
const char *args)
:
_ep(cap_session, STACK_SIZE, "irq")
{
long irq_number = Arg_string::find_arg(args, "irq_number").long_value(-1);
/* check if IRQ thread was started before */
_proxy = Proxy::get_irq_proxy<Irq_proxy_component>(irq_number, irq_alloc);
if (irq_number == -1 || !_proxy) {
PERR("Unavailable IRQ %lx requested", irq_number);
if (irq_number == -1) {
PERR("invalid IRQ number requested");
throw Root::Unavailable();
}
_proxy->add_sharer();
/* check if IRQ thread was started before */
typedef Irq_proxy<Irq_thread> Proxy;
_proxy = Proxy::get_irq_proxy<Irq_proxy_component>(irq_number, irq_alloc);
if (!_proxy) {
PERR("unavailable IRQ %lx requested", irq_number);
throw Root::Unavailable();
}
/* initialize capability */
_irq_cap = _ep.manage(this);
_irq_number = irq_number;
}
Irq_session_component::~Irq_session_component() { }
Irq_signal Irq_session_component::signal()
Irq_session_component::~Irq_session_component()
{
PDBG("not implemented;");
return Irq_signal();
if (_proxy) return;
if (_irq_sigh.valid())
_proxy->remove_sharer(&_irq_sigh);
}
void Irq_session_component::sigh(Genode::Signal_context_capability sigh)
{
if (!_proxy) {
PERR("signal handler got not registered - irq thread unavailable");
return;
}
Genode::Signal_context_capability old = _irq_sigh;
if (old.valid() && !sigh.valid())
_proxy->remove_sharer(&_irq_sigh);
_irq_sigh = sigh;
if (!old.valid() && sigh.valid())
_proxy->add_sharer(&_irq_sigh);
}