2012-05-30 20:13:09 +02:00
|
|
|
/*
|
|
|
|
* \brief Implementations of the signaling framework specific for HW-core
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2012-05-05
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 21:44:47 +01:00
|
|
|
* Copyright (C) 2012-2013 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
2016-01-14 13:22:00 +01:00
|
|
|
#include <util/retry.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
#include <base/thread.h>
|
|
|
|
#include <base/signal.h>
|
2016-01-14 13:22:00 +01:00
|
|
|
#include <base/env.h>
|
|
|
|
#include <base/trace/events.h>
|
2013-11-14 17:29:34 +01:00
|
|
|
|
2016-03-08 16:59:43 +01:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/native_utcb.h>
|
2016-06-15 15:04:54 +02:00
|
|
|
#include <base/internal/capability_space.h>
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
2015-12-23 15:22:33 +01:00
|
|
|
|
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On base-hw, no signal thread is needed.
|
|
|
|
*/
|
2016-05-04 12:27:17 +02:00
|
|
|
void init_signal_thread(Env &) __attribute__((weak));
|
|
|
|
void init_signal_thread(Env &) { }
|
2015-12-23 15:22:33 +01:00
|
|
|
void destroy_signal_thread() { }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-27 14:47:58 +01:00
|
|
|
/********************
|
|
|
|
** Signal context **
|
|
|
|
********************/
|
|
|
|
|
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
|
|
|
void Signal_context::submit(unsigned) { Genode::error("not implemented"); }
|
2013-11-27 14:47:58 +01:00
|
|
|
|
2015-12-23 15:22:33 +01:00
|
|
|
|
2013-02-18 13:58:09 +01:00
|
|
|
/************************
|
|
|
|
** Signal transmitter **
|
|
|
|
************************/
|
|
|
|
|
2015-06-22 14:04:28 +02:00
|
|
|
void Signal_transmitter::submit(unsigned cnt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Trace::Signal_submit trace_event(cnt);
|
|
|
|
}
|
2016-06-15 15:04:54 +02:00
|
|
|
Kernel::submit_signal(Capability_space::capid(_context), cnt);
|
2015-06-22 14:04:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
/*********************
|
|
|
|
** Signal_receiver **
|
|
|
|
*********************/
|
|
|
|
|
2012-11-23 16:47:42 +01:00
|
|
|
Signal_receiver::Signal_receiver()
|
2012-05-30 20:13:09 +02:00
|
|
|
{
|
2016-01-14 13:22:00 +01:00
|
|
|
retry<Pd_session::Out_of_metadata>(
|
|
|
|
[&] () {
|
|
|
|
_cap = env()->pd_session()->alloc_signal_source();
|
|
|
|
},
|
|
|
|
[&] () {
|
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
|
|
|
log("upgrading quota donation for PD session");
|
2016-01-14 13:22:00 +01:00
|
|
|
env()->parent()->upgrade(env()->pd_session_cap(), "ram_quota=8K");
|
2012-11-23 16:47:42 +01:00
|
|
|
}
|
2016-01-14 13:22:00 +01:00
|
|
|
);
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-09-12 00:48:27 +02:00
|
|
|
void Signal_receiver::_platform_destructor()
|
|
|
|
{
|
|
|
|
/* release server resources of receiver */
|
2016-01-14 13:22:00 +01:00
|
|
|
env()->pd_session()->free_signal_source(_cap);
|
2013-09-12 00:48:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-13 15:49:11 +01:00
|
|
|
void Signal_receiver::_platform_begin_dissolve(Signal_context * const c)
|
2012-05-30 20:13:09 +02:00
|
|
|
{
|
2016-06-15 15:04:54 +02:00
|
|
|
Kernel::kill_signal_context(Capability_space::capid(c->_cap));
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
2015-11-13 15:49:11 +01:00
|
|
|
void Signal_receiver::_platform_finish_dissolve(Signal_context *) { }
|
|
|
|
|
2012-05-30 20:13:09 +02:00
|
|
|
|
|
|
|
Signal_context_capability Signal_receiver::manage(Signal_context * const c)
|
|
|
|
{
|
2013-11-14 13:29:47 +01:00
|
|
|
/* ensure that the context isn't managed already */
|
2012-05-30 20:13:09 +02:00
|
|
|
Lock::Guard contexts_guard(_contexts_lock);
|
|
|
|
Lock::Guard context_guard(c->_lock);
|
2013-09-12 00:48:27 +02:00
|
|
|
if (c->_receiver) { throw Context_already_in_use(); }
|
2012-05-30 20:13:09 +02:00
|
|
|
|
2016-01-14 13:22:00 +01:00
|
|
|
retry<Pd_session::Out_of_metadata>(
|
|
|
|
[&] () {
|
|
|
|
/* use signal context as imprint */
|
|
|
|
c->_cap = env()->pd_session()->alloc_context(_cap, (unsigned long)c);
|
2013-08-08 20:18:41 +02:00
|
|
|
c->_receiver = this;
|
|
|
|
_contexts.insert(&c->_receiver_le);
|
|
|
|
return c->_cap;
|
2016-01-14 13:22:00 +01:00
|
|
|
},
|
|
|
|
[&] () {
|
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
|
|
|
log("upgrading quota donation for PD session");
|
2016-01-14 13:22:00 +01:00
|
|
|
env()->parent()->upgrade(env()->pd_session_cap(), "ram_quota=8K");
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
2016-01-14 13:22:00 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return c->_cap;
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-08 17:45:12 +02:00
|
|
|
void Signal_receiver::block_for_signal()
|
|
|
|
{
|
2015-11-13 15:49:11 +01:00
|
|
|
/* wait for a signal */
|
2016-06-15 15:04:54 +02:00
|
|
|
if (Kernel::await_signal(Capability_space::capid(_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
|
|
|
Genode::error("failed to receive signal");
|
2015-10-08 17:45:12 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-11-13 15:49:11 +01:00
|
|
|
/* read signal data */
|
2016-05-04 12:27:17 +02:00
|
|
|
const void * const utcb = Thread::myself()->utcb()->data();
|
2015-11-13 15:49:11 +01:00
|
|
|
Signal::Data * const data = (Signal::Data *)utcb;
|
|
|
|
Signal_context * const context = data->context;
|
|
|
|
{
|
|
|
|
/* update signal context */
|
|
|
|
Lock::Guard lock_guard(context->_lock);
|
|
|
|
unsigned const num = context->_curr_signal.num + data->num;
|
|
|
|
context->_pending = true;
|
|
|
|
context->_curr_signal = Signal::Data(context, num);
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
2015-11-13 15:49:11 +01:00
|
|
|
/* end kernel-aided life-time management */
|
2016-06-15 15:04:54 +02:00
|
|
|
Kernel::ack_signal(Capability_space::capid(data->context->_cap));
|
2012-05-30 20:13:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
void Signal_receiver::local_submit(Signal::Data) { Genode::error("not implemented"); }
|