2012-05-30 20:13:09 +02:00
|
|
|
/*
|
2013-10-30 13:56:57 +01:00
|
|
|
* \brief Backend for IRQ sessions served by core
|
2012-05-30 20:13:09 +02:00
|
|
|
* \author Martin Stein
|
2015-03-19 16:55:21 +01:00
|
|
|
* \author Reto Buerki
|
2012-05-30 20:13:09 +02:00
|
|
|
* \date 2012-02-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2015-03-19 16:55:21 +01:00
|
|
|
* Copyright (C) 2012-2015 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
2013-11-14 17:29:34 +01:00
|
|
|
/* base-hw includes */
|
2014-03-15 01:26:53 +01:00
|
|
|
#include <kernel/core_interface.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* core includes */
|
2013-10-30 13:56:57 +01:00
|
|
|
#include <kernel/irq.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <irq_root.h>
|
2016-07-26 11:34:29 +02:00
|
|
|
#include <irq_args.h>
|
2013-10-30 13:56:57 +01:00
|
|
|
#include <core_env.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/capability_space.h>
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
using namespace Genode;
|
|
|
|
|
2015-03-17 15:41:47 +01:00
|
|
|
|
|
|
|
unsigned Irq_session_component::_find_irq_number(const char * const args)
|
|
|
|
{
|
|
|
|
return Arg_string::find_arg(args, "irq_number").long_value(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Irq_session_component::ack_irq()
|
2013-10-30 13:56:57 +01:00
|
|
|
{
|
2015-04-28 12:56:59 +02:00
|
|
|
using Kernel::User_irq;
|
|
|
|
if (!_sig_cap.valid()) { return; }
|
|
|
|
User_irq * const kirq = reinterpret_cast<User_irq*>(&_kernel_object);
|
|
|
|
Kernel::ack_irq(kirq);
|
2013-10-30 13:56:57 +01:00
|
|
|
}
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
|
2015-03-17 15:41:47 +01:00
|
|
|
void Irq_session_component::sigh(Signal_context_capability cap)
|
|
|
|
{
|
|
|
|
if (_sig_cap.valid()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
warning("signal handler already registered for IRQ ", _irq_number);
|
2015-03-17 15:41:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_sig_cap = cap;
|
|
|
|
|
2016-06-15 15:04:54 +02:00
|
|
|
if (Kernel::new_irq((addr_t)&_kernel_object, _irq_number,
|
|
|
|
Capability_space::capid(_sig_cap)))
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
warning("invalid signal handler for IRQ ", _irq_number);
|
2015-03-17 15:41:47 +01:00
|
|
|
}
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-03-18 19:05:31 +01:00
|
|
|
Irq_session_component::~Irq_session_component()
|
|
|
|
{
|
2015-04-03 17:22:16 +02:00
|
|
|
using namespace Kernel;
|
|
|
|
|
|
|
|
User_irq * kirq = reinterpret_cast<User_irq*>(&_kernel_object);
|
2015-08-28 10:18:59 +02:00
|
|
|
_irq_alloc->free((void *)(addr_t)_irq_number);
|
2015-03-17 15:41:47 +01:00
|
|
|
if (_sig_cap.valid())
|
|
|
|
Kernel::delete_irq(kirq);
|
2015-03-18 19:05:31 +01:00
|
|
|
}
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2015-04-03 17:22:16 +02:00
|
|
|
|
2015-03-17 15:41:47 +01:00
|
|
|
Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc,
|
|
|
|
const char * const args)
|
|
|
|
:
|
2016-02-16 16:41:08 +01:00
|
|
|
_irq_number(Platform::irq(_find_irq_number(args))), _irq_alloc(irq_alloc),
|
|
|
|
_is_msi(false), _address(0), _value(0)
|
2015-03-17 15:41:47 +01:00
|
|
|
{
|
2016-02-16 16:51:50 +01:00
|
|
|
const long mmconf =
|
|
|
|
Arg_string::find_arg(args, "device_config_phys").long_value(0);
|
|
|
|
|
|
|
|
if (mmconf) {
|
|
|
|
_is_msi =
|
|
|
|
Platform::get_msi_params(mmconf, _address, _value, _irq_number);
|
|
|
|
if (!_is_msi)
|
|
|
|
throw Root::Unavailable();
|
|
|
|
}
|
2015-05-09 21:48:12 +02:00
|
|
|
|
2013-10-30 13:56:57 +01:00
|
|
|
/* allocate interrupt */
|
2016-05-11 18:21:47 +02:00
|
|
|
if (_irq_alloc->alloc_addr(1, _irq_number).error()) {
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
error("unavailable interrupt ", _irq_number, " requested");
|
2012-05-30 20:13:09 +02:00
|
|
|
throw Root::Invalid_args();
|
|
|
|
}
|
2015-05-16 02:34:45 +02:00
|
|
|
|
2016-07-26 11:34:29 +02:00
|
|
|
Irq_args const irq_args(args);
|
2015-05-16 02:34:45 +02:00
|
|
|
|
2016-07-26 11:34:29 +02:00
|
|
|
Platform::setup_irq_mode(_irq_number, irq_args.trigger(), irq_args.polarity());
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|