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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2012-2017 Genode Labs GmbH
|
2012-05-30 20:13:09 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2012-05-30 20:13:09 +02:00
|
|
|
*/
|
|
|
|
|
2013-11-14 17:29:34 +01:00
|
|
|
/* base-hw includes */
|
2019-09-26 14:24:28 +02:00
|
|
|
#include "kernel/core_interface.h"
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
/* core includes */
|
2019-09-26 14:24:28 +02: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);
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01: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
|
|
|
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01:00
|
|
|
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
|
|
|
|
const char * const args)
|
2015-03-17 15:41:47 +01:00
|
|
|
:
|
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)
|
Streamline exception types
This patch reduces the number of exception types by facilitating
globally defined exceptions for common usage patterns shared by most
services. In particular, RPC functions that demand a session-resource
upgrade not longer reflect this condition via a session-specific
exception but via the 'Out_of_ram' or 'Out_of_caps' types.
Furthermore, the 'Parent::Service_denied', 'Parent::Unavailable',
'Root::Invalid_args', 'Root::Unavailable', 'Service::Invalid_args',
'Service::Unavailable', and 'Local_service::Factory::Denied' types have
been replaced by the single 'Service_denied' exception type defined in
'session/session.h'.
This consolidation eases the error handling (there are fewer exceptions
to handle), alleviates the need to convert exceptions along the
session-creation call chain, and avoids possible aliasing problems
(catching the wrong type with the same name but living in a different
scope).
2017-05-07 22:03:22 +02:00
|
|
|
throw Service_denied();
|
2016-02-16 16:51:50 +01:00
|
|
|
}
|
2015-05-09 21:48:12 +02:00
|
|
|
|
2013-10-30 13:56:57 +01:00
|
|
|
/* allocate interrupt */
|
base/core: use references instead of pointers
This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:
* The contract between caller and callee becomes more obvious. When
passing a reference, the contract says that the argument cannot be
a null pointer. The caller is responsible to ensure that. Therefore,
the use of reference eliminates the need to add defensive null-pointer
checks at the callee site, which sometimes merely exist to be on the
safe side. The bottom line is that the code becomes easier to follow.
* Reference members must be initialized via an object initializer,
which promotes a programming style that avoids intermediate object-
construction states. Within core, there are still a few pointers
as member variables left though. E.g., caused by the late association
of 'Platform_thread' objects with their 'Platform_pd' objects.
* If no pointers are present as member variables, we don't need to
manually provide declarations of a private copy constructor and
an assignment operator to avoid -Weffc++ errors "class ... has
pointer data members [-Werror=effc++]".
This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.
Fixes #3135
2019-01-24 22:00:01 +01: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");
|
Streamline exception types
This patch reduces the number of exception types by facilitating
globally defined exceptions for common usage patterns shared by most
services. In particular, RPC functions that demand a session-resource
upgrade not longer reflect this condition via a session-specific
exception but via the 'Out_of_ram' or 'Out_of_caps' types.
Furthermore, the 'Parent::Service_denied', 'Parent::Unavailable',
'Root::Invalid_args', 'Root::Unavailable', 'Service::Invalid_args',
'Service::Unavailable', and 'Local_service::Factory::Denied' types have
been replaced by the single 'Service_denied' exception type defined in
'session/session.h'.
This consolidation eases the error handling (there are fewer exceptions
to handle), alleviates the need to convert exceptions along the
session-creation call chain, and avoids possible aliasing problems
(catching the wrong type with the same name but living in a different
scope).
2017-05-07 22:03:22 +02:00
|
|
|
throw Service_denied();
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
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
|
|
|
|
2019-08-15 14:41:09 +02:00
|
|
|
Kernel::irq_mode(_irq_number, irq_args.trigger(), irq_args.polarity());
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|