2014-09-30 16:46:55 +02:00
|
|
|
/*
|
|
|
|
* \brief Slave used for toggling the visibility of a nitpicker session
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2014-09-30
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-09-30 16:46:55 +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.
|
2014-09-30 16:46:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NIT_FADER_SLAVE_H_
|
|
|
|
#define _NIT_FADER_SLAVE_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
2017-02-01 14:04:53 +01:00
|
|
|
#include <os/static_parent_services.h>
|
2014-09-30 16:46:55 +02:00
|
|
|
#include <os/slave.h>
|
|
|
|
#include <nitpicker_session/nitpicker_session.h>
|
|
|
|
|
|
|
|
/* local includes */
|
|
|
|
#include <types.h>
|
|
|
|
|
|
|
|
namespace Launcher { class Nit_fader_slave; }
|
|
|
|
|
|
|
|
|
|
|
|
class Launcher::Nit_fader_slave
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2017-02-01 14:04:53 +01:00
|
|
|
class Policy
|
|
|
|
:
|
|
|
|
private Genode::Static_parent_services<Genode::Ram_session,
|
|
|
|
Genode::Cpu_session,
|
|
|
|
Genode::Pd_session,
|
|
|
|
Genode::Rom_session,
|
|
|
|
Genode::Log_session,
|
|
|
|
Timer::Session>,
|
|
|
|
public Slave::Policy
|
2014-09-30 16:46:55 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
Genode::Service &_nitpicker_service;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2017-05-08 01:33:40 +02:00
|
|
|
static Name _name() { return "nit_fader"; }
|
|
|
|
static Genode::Ram_quota _quota() { return { 2*1024*1024 }; }
|
Capability quota accounting and trading
This patch mirrors the accounting and trading scheme that Genode employs
for physical memory to the accounting of capability allocations.
Capability quotas must now be explicitly assigned to subsystems by
specifying a 'caps=<amount>' attribute to init's start nodes.
Analogously to RAM quotas, cap quotas can be traded between clients and
servers as part of the session protocol. The capability budget of each
component is maintained by the component's corresponding PD session at
core.
At the current stage, the accounting is applied to RPC capabilities,
signal-context capabilities, and dataspace capabilities. Capabilities
that are dynamically allocated via core's CPU and TRACE service are not
yet covered. Also, the capabilities allocated by resource multiplexers
outside of core (like nitpicker) must be accounted by the respective
servers, which is not covered yet.
If a component runs out of capabilities, core's PD service prints a
warning to the log. To observe the consumption of capabilities per
component in detail, the PD service is equipped with a diagnostic
mode, which can be enabled via the 'diag' attribute in the target
node of init's routing rules. E.g., the following route enables the
diagnostic mode for the PD session of the "timer" component:
<default-route>
<service name="PD" unscoped_label="timer">
<parent diag="yes"/>
</service>
...
</default-route>
For subsystems based on a sub-init instance, init can be configured
to report the capability-quota information of its subsystems by
adding the attribute 'child_caps="yes"' to init's '<report>'
config node. Init's own capability quota can be reported by adding
the attribute 'init_caps="yes"'.
Fixes #2398
2017-05-08 21:35:43 +02:00
|
|
|
static Genode::Cap_quota _caps() { return { 25 }; }
|
2016-11-23 17:07:49 +01:00
|
|
|
|
2014-09-30 16:46:55 +02:00
|
|
|
public:
|
|
|
|
|
2017-05-11 20:03:28 +02:00
|
|
|
Policy(Rpc_entrypoint &ep,
|
|
|
|
Region_map &rm,
|
|
|
|
Pd_session &ref_pd,
|
|
|
|
Pd_session_capability ref_pd_cap,
|
|
|
|
Genode::Service &nitpicker_service)
|
2014-09-30 16:46:55 +02:00
|
|
|
:
|
2017-05-08 16:49:00 +02:00
|
|
|
Genode::Slave::Policy(_name(), _name(), *this, ep, rm,
|
2017-05-11 20:03:28 +02:00
|
|
|
ref_pd, ref_pd_cap, _caps(), _quota()),
|
2014-09-30 16:46:55 +02:00
|
|
|
_nitpicker_service(nitpicker_service)
|
|
|
|
{
|
|
|
|
visible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void visible(bool visible)
|
|
|
|
{
|
|
|
|
char config[256];
|
|
|
|
snprintf(config, sizeof(config),
|
|
|
|
"<config alpha=\"%d\" />", visible ? 255 : 0);
|
|
|
|
configure(config, strlen(config) + 1);
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
Genode::Service &resolve_session_request(Genode::Service::Name const &service,
|
|
|
|
Genode::Session_state::Args const &args) override
|
2014-09-30 16:46:55 +02:00
|
|
|
{
|
2016-11-23 17:07:49 +01:00
|
|
|
if (service == Nitpicker::Session::service_name())
|
|
|
|
return _nitpicker_service;
|
2014-09-30 16:46:55 +02:00
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
return Genode::Slave::Policy::resolve_session_request(service, args);
|
2014-09-30 16:46:55 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
Policy _policy;
|
|
|
|
Child _child;
|
2014-09-30 16:46:55 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2017-05-08 16:49:00 +02:00
|
|
|
* \param ep entrypoint used for nitpicker child thread
|
|
|
|
* \param ref_ram RAM session used to allocate the configuration
|
|
|
|
* dataspace and child memory
|
2014-09-30 16:46:55 +02:00
|
|
|
*/
|
2016-11-23 17:07:49 +01:00
|
|
|
Nit_fader_slave(Rpc_entrypoint &ep,
|
|
|
|
Genode::Region_map &rm,
|
Capability quota accounting and trading
This patch mirrors the accounting and trading scheme that Genode employs
for physical memory to the accounting of capability allocations.
Capability quotas must now be explicitly assigned to subsystems by
specifying a 'caps=<amount>' attribute to init's start nodes.
Analogously to RAM quotas, cap quotas can be traded between clients and
servers as part of the session protocol. The capability budget of each
component is maintained by the component's corresponding PD session at
core.
At the current stage, the accounting is applied to RPC capabilities,
signal-context capabilities, and dataspace capabilities. Capabilities
that are dynamically allocated via core's CPU and TRACE service are not
yet covered. Also, the capabilities allocated by resource multiplexers
outside of core (like nitpicker) must be accounted by the respective
servers, which is not covered yet.
If a component runs out of capabilities, core's PD service prints a
warning to the log. To observe the consumption of capabilities per
component in detail, the PD service is equipped with a diagnostic
mode, which can be enabled via the 'diag' attribute in the target
node of init's routing rules. E.g., the following route enables the
diagnostic mode for the PD session of the "timer" component:
<default-route>
<service name="PD" unscoped_label="timer">
<parent diag="yes"/>
</service>
...
</default-route>
For subsystems based on a sub-init instance, init can be configured
to report the capability-quota information of its subsystems by
adding the attribute 'child_caps="yes"' to init's '<report>'
config node. Init's own capability quota can be reported by adding
the attribute 'init_caps="yes"'.
Fixes #2398
2017-05-08 21:35:43 +02:00
|
|
|
Pd_session &ref_pd,
|
|
|
|
Pd_session_capability ref_pd_cap,
|
2016-11-23 17:07:49 +01:00
|
|
|
Genode::Service &nitpicker_service)
|
2014-09-30 16:46:55 +02:00
|
|
|
:
|
2017-05-11 20:03:28 +02:00
|
|
|
_policy(ep, rm, ref_pd, ref_pd_cap, nitpicker_service),
|
2016-11-23 17:07:49 +01:00
|
|
|
_child(rm, ep, _policy)
|
2014-09-30 16:46:55 +02:00
|
|
|
{
|
|
|
|
visible(false);
|
|
|
|
}
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
Genode::Slave::Policy &policy() { return _policy; }
|
2014-09-30 16:46:55 +02:00
|
|
|
|
|
|
|
void visible(bool visible)
|
|
|
|
{
|
|
|
|
_policy.visible(visible);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _NIT_FADER_SLAVE_H_ */
|