2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* \brief Core main program
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2006-07-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2011-12-22 16:19:25 +01: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.
|
2011-12-22 16:19:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/snprintf.h>
|
|
|
|
#include <base/sleep.h>
|
|
|
|
#include <base/service.h>
|
|
|
|
#include <base/child.h>
|
2016-05-03 16:31:17 +02:00
|
|
|
#include <base/log.h>
|
2015-05-05 08:50:16 +02:00
|
|
|
#include <rm_session/connection.h>
|
|
|
|
#include <pd_session/connection.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
#include <rom_session/connection.h>
|
|
|
|
#include <cpu_session/connection.h>
|
|
|
|
|
2016-05-04 12:27:17 +02:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/globals.h>
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/* core includes */
|
|
|
|
#include <platform.h>
|
|
|
|
#include <core_env.h>
|
|
|
|
#include <ram_root.h>
|
|
|
|
#include <rom_root.h>
|
|
|
|
#include <rm_root.h>
|
|
|
|
#include <cpu_root.h>
|
|
|
|
#include <pd_root.h>
|
|
|
|
#include <log_root.h>
|
|
|
|
#include <io_mem_root.h>
|
|
|
|
#include <irq_root.h>
|
2013-08-10 03:44:55 +02:00
|
|
|
#include <trace/root.h>
|
2012-10-02 13:11:58 +02:00
|
|
|
#include <platform_services.h>
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
using namespace Genode;
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************
|
|
|
|
** Core environment/platform support **
|
|
|
|
***************************************/
|
|
|
|
|
|
|
|
Core_env * Genode::core_env()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Make sure to initialize the platform before constructing the core
|
|
|
|
* environment.
|
|
|
|
*/
|
|
|
|
platform();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* By placing the environment as static object here, we ensure that its
|
|
|
|
* constructor gets called when this function is used the first time.
|
|
|
|
*/
|
|
|
|
static Core_env _env;
|
|
|
|
return &_env;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 15:18:49 +01:00
|
|
|
Env_deprecated * Genode::env_deprecated() {
|
2011-12-22 16:19:25 +01:00
|
|
|
return core_env(); }
|
|
|
|
|
|
|
|
|
|
|
|
Platform *Genode::platform_specific()
|
|
|
|
{
|
|
|
|
static Platform _platform;
|
|
|
|
return &_platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Platform_generic *Genode::platform() { return platform_specific(); }
|
|
|
|
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
** Core parent support **
|
|
|
|
*************************/
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Session_capability Core_parent::session(Parent::Client::Id id,
|
|
|
|
Parent::Service_name const &name,
|
2013-08-07 23:10:28 +02:00
|
|
|
Parent::Session_args const &args,
|
|
|
|
Affinity const &affinity)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2016-11-06 14:26:34 +01:00
|
|
|
Session_capability cap;
|
|
|
|
|
|
|
|
_services.for_each([&] (Service &service) {
|
|
|
|
|
|
|
|
if ((service.name() != name.string()) || cap.valid())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Session_state &session = *new (_alloc)
|
2017-02-14 17:38:09 +01:00
|
|
|
Session_state(service, _id_space, id, label_from_args(args.string()),
|
|
|
|
args.string(), affinity);
|
2016-11-06 14:26:34 +01:00
|
|
|
|
|
|
|
service.initiate_request(session);
|
|
|
|
|
|
|
|
cap = session.cap;
|
|
|
|
});
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
if (!cap.valid())
|
|
|
|
error("unexpected core-parent ", name.string(), " session request");
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
return cap;
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************
|
|
|
|
** Core child **
|
|
|
|
****************/
|
|
|
|
|
|
|
|
class Core_child : public Child_policy
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Entry point used for serving the parent interface
|
|
|
|
*/
|
|
|
|
Rpc_entrypoint _entrypoint;
|
2017-02-27 10:20:39 +01:00
|
|
|
enum { STACK_SIZE = 4 * 1024 * sizeof(Genode::addr_t)};
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Registry<Service> &_services;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
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
|
|
|
Capability<Pd_session> _core_pd_cap;
|
|
|
|
Pd_session &_core_pd;
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Capability<Ram_session> _core_ram_cap;
|
|
|
|
Ram_session &_core_ram;
|
2016-04-27 16:04:58 +02:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Capability<Cpu_session> _core_cpu_cap;
|
|
|
|
Cpu_session &_core_cpu;
|
2016-04-27 16:04:58 +02:00
|
|
|
|
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
|
|
|
Cap_quota const _cap_quota;
|
2017-05-08 01:33:40 +02:00
|
|
|
Ram_quota const _ram_quota;
|
2016-04-20 21:12:57 +02:00
|
|
|
|
2013-01-30 17:00:00 +01:00
|
|
|
Child _child;
|
2011-12-22 16:19:25 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2017-05-08 19:55:54 +02:00
|
|
|
Core_child(Registry<Service> &services,
|
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 &core_pd, Capability<Pd_session> core_pd_cap,
|
2017-05-08 19:55:54 +02:00
|
|
|
Ram_session &core_ram, Capability<Ram_session> core_ram_cap,
|
|
|
|
Cpu_session &core_cpu, Capability<Cpu_session> core_cpu_cap,
|
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
|
|
|
Cap_quota cap_quota, Ram_quota ram_quota)
|
2011-12-22 16:19:25 +01:00
|
|
|
:
|
2016-07-20 08:41:52 +02:00
|
|
|
_entrypoint(nullptr, STACK_SIZE, "init_child", false),
|
2016-11-06 14:26:34 +01:00
|
|
|
_services(services),
|
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
|
|
|
_core_pd_cap (core_pd_cap), _core_pd (core_pd),
|
2016-11-06 14:26:34 +01:00
|
|
|
_core_ram_cap(core_ram_cap), _core_ram(core_ram),
|
|
|
|
_core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu),
|
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
|
|
|
_cap_quota(Child::effective_quota(cap_quota)),
|
2017-05-08 01:33:40 +02:00
|
|
|
_ram_quota(Child::effective_quota(ram_quota)),
|
2017-01-09 15:18:49 +01:00
|
|
|
_child(*env_deprecated()->rm_session(), _entrypoint, *this)
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
|
|
|
_entrypoint.activate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************
|
|
|
|
** Child-policy interface **
|
|
|
|
****************************/
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Name name() const { return "init"; }
|
|
|
|
|
|
|
|
Service &resolve_session_request(Service::Name const &name,
|
|
|
|
Session_state::Args const &args) override
|
|
|
|
{
|
|
|
|
Service *service = nullptr;
|
|
|
|
_services.for_each([&] (Service &s) {
|
|
|
|
if (!service && s.name() == name)
|
|
|
|
service = &s; });
|
|
|
|
|
|
|
|
if (!service)
|
|
|
|
throw Parent::Service_denied();
|
|
|
|
|
|
|
|
return *service;
|
|
|
|
}
|
2013-05-08 11:10:35 +02:00
|
|
|
|
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
|
|
|
void init(Pd_session &session, Capability<Pd_session> cap) override
|
|
|
|
{
|
|
|
|
session.ref_account(_core_pd_cap);
|
|
|
|
_core_pd.transfer_quota(cap, _cap_quota);
|
|
|
|
}
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
void init(Ram_session &session, Capability<Ram_session> cap) override
|
|
|
|
{
|
|
|
|
session.ref_account(_core_ram_cap);
|
|
|
|
_core_ram.transfer_quota(cap, _ram_quota);
|
|
|
|
}
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
void init(Cpu_session &session, Capability<Cpu_session> cap) override
|
2011-12-22 16:19:25 +01:00
|
|
|
{
|
2016-11-06 14:26:34 +01:00
|
|
|
session.ref_account(_core_cpu_cap);
|
|
|
|
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
|
2011-12-22 16:19:25 +01:00
|
|
|
}
|
2016-11-06 14:26:34 +01:00
|
|
|
|
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() { return _core_pd; }
|
|
|
|
Pd_session_capability ref_pd_cap() const { return _core_pd_cap; }
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Ram_session &ref_ram() { return _core_ram; }
|
|
|
|
Ram_session_capability ref_ram_cap() const { return _core_ram_cap; }
|
base: remove Child::heap
This patch improves the accounting for the backing store of
session-state meta data. Originally, the session state used to be
allocated by a child-local heap partition fed from the child's RAM
session. However, whereas this approach was somehow practical from a
runtime's (parent's) point of view, the child component could not count
on the quota in its own RAM session. I.e., if the Child::heap grew at
the parent side, the child's RAM session would magically diminish. This
caused two problems. First, it violates assumptions of components like
init that carefully manage their RAM resources (and giving most of them
away their children). Second, if a child transfers most of its RAM
session quota to another RAM session (like init does), the child's RAM
session may actually not allow the parent's heap to grow, which is a
very difficult error condition to deal with.
In the new version, there is no Child::heap anymore. Instead, session
states are allocated from the runtime's RAM session. In order to let
children pay for these costs, the parent withdraws the local session
costs from the session quota donated from the child when the child
initiates a new session. Hence, in principle, all components on the
route of the session request take a small bite from the session quota to
pay for their local book keeping
Consequently, the session quota that ends up at the server may become
depleted more or less, depending on the route. In the case where the
remaining quota is insufficient for the server, the server responds with
'QUOTA_EXCEEDED'. Since this behavior must generally be expected, this
patch equips the client-side 'Env::session' implementation with the
ability to re-issue session requests with successively growing quota
donations.
For several of core's services (ROM, IO_MEM, IRQ), the default session
quota has now increased by 2 KiB, which should suffice for session
requests to up to 3 hops as is the common case for most run scripts. For
longer routes, the retry mechanism as described above comes into effect.
For the time being, we give a warning whenever the server-side quota
check triggers the retry mechanism. The warning may eventually be
removed at a later stage.
2017-02-19 10:31:50 +01:00
|
|
|
|
|
|
|
size_t session_alloc_batch_size() const override { return 128; }
|
2011-12-22 16:19:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-12-23 15:22:33 +01:00
|
|
|
/****************
|
|
|
|
** Signal API **
|
|
|
|
****************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In contrast to the 'Platform_env' used by non-core components, core disables
|
|
|
|
* the signal thread but overriding 'Genode::init_signal_thread' with a dummy.
|
|
|
|
* Within core, the signal thread is not needed as core is never supposed to
|
|
|
|
* receive any signals. Otherwise, the signal thread would be the only
|
|
|
|
* non-entrypoint thread within core, which would be a problem on NOVA where
|
|
|
|
* the creation of regular threads within core is unsupported.
|
|
|
|
*/
|
|
|
|
|
2016-05-04 12:27:17 +02:00
|
|
|
namespace Genode { void init_signal_thread(Env &) { } }
|
2015-12-23 15:22:33 +01:00
|
|
|
|
|
|
|
|
2015-06-16 20:39:09 +02:00
|
|
|
/*******************
|
|
|
|
** Trace support **
|
|
|
|
*******************/
|
|
|
|
|
|
|
|
Trace::Source_registry &Trace::sources()
|
|
|
|
{
|
|
|
|
static Trace::Source_registry inst;
|
|
|
|
return inst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/***************
|
|
|
|
** Core main **
|
|
|
|
***************/
|
|
|
|
|
2014-04-11 13:59:18 +02:00
|
|
|
namespace Genode {
|
|
|
|
extern bool inhibit_tracing;
|
|
|
|
extern char const *version_string;
|
|
|
|
}
|
2013-08-09 20:48:32 +02:00
|
|
|
|
2015-12-23 15:22:33 +01:00
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
int main()
|
|
|
|
{
|
2013-08-09 20:48:32 +02:00
|
|
|
/**
|
|
|
|
* Disable tracing within core because it is currently not fully implemented.
|
|
|
|
*/
|
|
|
|
inhibit_tracing = true;
|
|
|
|
|
2016-05-03 16:31:17 +02:00
|
|
|
log("Genode ", Genode::version_string);
|
2014-03-18 16:23:52 +01:00
|
|
|
|
2013-08-10 03:44:55 +02:00
|
|
|
static Trace::Policy_registry trace_policies;
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* Initialize root interfaces for our services
|
|
|
|
*/
|
|
|
|
Rpc_entrypoint *e = core_env()->entrypoint();
|
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
Registry<Service> &services = core_env()->services();
|
|
|
|
|
2017-05-08 19:55:54 +02:00
|
|
|
static Ram_allocator &core_ram_alloc = *core_env()->ram_session();
|
|
|
|
static Region_map &local_rm = *core_env()->rm_session();
|
|
|
|
|
2011-12-22 16:19:25 +01:00
|
|
|
/*
|
|
|
|
* Allocate session meta data on distinct dataspaces to enable independent
|
|
|
|
* destruction (to enable quota trading) of session component objects.
|
|
|
|
*/
|
2017-05-08 19:55:54 +02:00
|
|
|
static Sliced_heap sliced_heap(core_ram_alloc, local_rm);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-01-19 20:24:22 +01:00
|
|
|
/*
|
|
|
|
* Factory for creating RPC capabilities within core
|
|
|
|
*/
|
|
|
|
static Rpc_cap_factory rpc_cap_factory(sliced_heap);
|
|
|
|
|
2016-04-15 15:19:22 +02:00
|
|
|
static Pager_entrypoint pager_ep(rpc_cap_factory);
|
|
|
|
|
2017-05-08 19:55:54 +02:00
|
|
|
static Ram_root ram_root (*e, *platform()->ram_alloc(), local_rm, sliced_heap);
|
2011-12-22 16:19:25 +01:00
|
|
|
static Rom_root rom_root (e, e, platform()->rom_fs(), &sliced_heap);
|
2016-04-15 15:19:22 +02:00
|
|
|
static Rm_root rm_root (e, &sliced_heap, pager_ep);
|
|
|
|
static Cpu_root cpu_root (e, e, &pager_ep, &sliced_heap,
|
2015-06-16 20:39:09 +02:00
|
|
|
Trace::sources());
|
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 Pd_root pd_root (*e, pager_ep, core_ram_alloc, local_rm, sliced_heap);
|
2011-12-22 16:19:25 +01:00
|
|
|
static Log_root log_root (e, &sliced_heap);
|
|
|
|
static Io_mem_root io_mem_root (e, e, platform()->io_mem_alloc(),
|
|
|
|
platform()->ram_alloc(), &sliced_heap);
|
2016-01-19 20:24:22 +01:00
|
|
|
static Irq_root irq_root (core_env()->pd_session(),
|
2015-06-09 12:42:39 +02:00
|
|
|
platform()->irq_alloc(), &sliced_heap);
|
2015-06-16 20:39:09 +02:00
|
|
|
static Trace::Root trace_root (e, &sliced_heap, Trace::sources(), trace_policies);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
static Core_service<Rom_session_component> rom_service (services, rom_root);
|
|
|
|
static Core_service<Ram_session_component> ram_service (services, ram_root);
|
|
|
|
static Core_service<Rm_session_component> rm_service (services, rm_root);
|
|
|
|
static Core_service<Cpu_session_component> cpu_service (services, cpu_root);
|
|
|
|
static Core_service<Pd_session_component> pd_service (services, pd_root);
|
|
|
|
static Core_service<Log_session_component> log_service (services, log_root);
|
|
|
|
static Core_service<Io_mem_session_component> io_mem_service (services, io_mem_root);
|
|
|
|
static Core_service<Irq_session_component> irq_service (services, irq_root);
|
|
|
|
static Core_service<Trace::Session_component> trace_service (services, trace_root);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2012-10-02 13:11:58 +02:00
|
|
|
/* make platform-specific services known to service pool */
|
2016-11-06 14:26:34 +01:00
|
|
|
platform_add_local_services(e, &sliced_heap, &services);
|
|
|
|
|
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
|
|
|
/* calculate number of capabilities to be assigned to init */
|
|
|
|
size_t const preservered_cap_quota = 1000;
|
|
|
|
|
|
|
|
if (platform()->max_caps() < preservered_cap_quota) {
|
|
|
|
error("platform cap limit lower than preservation for core");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t const avail_cap_quota = platform()->max_caps() - preservered_cap_quota;
|
|
|
|
|
|
|
|
/* PD session representing core */
|
|
|
|
static Pd_session_component
|
|
|
|
core_pd(*e,
|
|
|
|
Session::Resources { Ram_quota { 16*1024 },
|
|
|
|
Cap_quota { avail_cap_quota } },
|
|
|
|
Session::Label("core"), Session::Diag{false},
|
|
|
|
core_ram_alloc, local_rm, pager_ep, "");
|
|
|
|
|
|
|
|
core_pd.init_cap_account();
|
|
|
|
|
|
|
|
/* CPU session representing core */
|
2014-10-16 11:15:46 +02:00
|
|
|
static Cpu_session_component
|
2016-11-06 14:26:34 +01:00
|
|
|
core_cpu(e, e, &pager_ep, &sliced_heap, Trace::sources(),
|
|
|
|
"label=\"core\"", Affinity(), Cpu_session::QUOTA_LIMIT);
|
|
|
|
Cpu_session_capability core_cpu_cap = core_env()->entrypoint()->manage(&core_cpu);
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2017-05-08 01:33:40 +02:00
|
|
|
/* calculate RAM to be assigned to init */
|
|
|
|
size_t const platform_ram_limit = platform()->ram_alloc()->avail();
|
|
|
|
size_t const preserved_ram_quota = 224*1024;
|
|
|
|
|
|
|
|
if (platform_ram_limit < preserved_ram_quota) {
|
|
|
|
error("platform RAM limit lower than preservation for core");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t const avail_ram_quota = platform_ram_limit - preserved_ram_quota;
|
2016-11-06 14:26:34 +01:00
|
|
|
|
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
|
|
|
log("", avail_ram_quota / (1024*1024), " MiB RAM and ", avail_cap_quota, " caps "
|
2017-05-08 01:33:40 +02:00
|
|
|
"assigned to init");
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-12-01 17:37:08 +01:00
|
|
|
static Reconstructible<Core_child>
|
2017-05-08 19:55:54 +02:00
|
|
|
init(services,
|
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
|
|
|
core_pd, core_pd.cap(),
|
2017-05-08 19:55:54 +02:00
|
|
|
*env_deprecated()->ram_session(), env_deprecated()->ram_session_cap(),
|
|
|
|
core_cpu, core_cpu_cap,
|
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
|
|
|
core_pd.cap_quota(), Ram_quota{avail_ram_quota});
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
platform()->wait_for_exit();
|
2011-12-22 16:19:25 +01:00
|
|
|
|
2016-11-06 14:26:34 +01:00
|
|
|
init.destruct();
|
2011-12-22 16:19:25 +01:00
|
|
|
return 0;
|
|
|
|
}
|