2013-08-10 03:44:55 +02:00
|
|
|
/*
|
|
|
|
* \brief TRACE root interface
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2013-08-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2013-2017 Genode Labs GmbH
|
2013-08-10 03:44: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.
|
2013-08-10 03:44:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _CORE__INCLUDE__TRACE__ROOT_H_
|
|
|
|
#define _CORE__INCLUDE__TRACE__ROOT_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <root/component.h>
|
|
|
|
|
|
|
|
/* core-internal includes */
|
|
|
|
#include <trace/session_component.h>
|
|
|
|
|
|
|
|
namespace Genode { namespace Trace { class Root; } }
|
|
|
|
|
|
|
|
|
|
|
|
class Genode::Trace::Root : public Genode::Root_component<Session_component>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2019-01-30 17:53:16 +01:00
|
|
|
Ram_allocator &_ram;
|
|
|
|
Region_map &_local_rm;
|
2013-08-10 03:44:55 +02:00
|
|
|
Source_registry &_sources;
|
|
|
|
Policy_registry &_policies;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2019-02-14 22:39:08 +01:00
|
|
|
Session_component *_create_session(const char *args) override
|
2013-08-10 03:44:55 +02:00
|
|
|
{
|
2015-03-27 14:02:04 +01:00
|
|
|
size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0);
|
2013-08-10 03:44:55 +02:00
|
|
|
size_t arg_buffer_size = Arg_string::find_arg(args, "arg_buffer_size").ulong_value(0);
|
|
|
|
unsigned parent_levels = Arg_string::find_arg(args, "parent_levels").ulong_value(0);
|
|
|
|
|
|
|
|
if (arg_buffer_size > ram_quota)
|
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();
|
2013-08-10 03:44:55 +02:00
|
|
|
|
|
|
|
return new (md_alloc())
|
2019-01-30 17:53:16 +01:00
|
|
|
Session_component(_ram, _local_rm, *md_alloc(), ram_quota,
|
|
|
|
arg_buffer_size, parent_levels,
|
|
|
|
label_from_args(args).string(), _sources, _policies);
|
2013-08-10 03:44:55 +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
|
|
|
void _upgrade_session(Session_component *s, const char *args) override
|
2013-08-10 03:44:55 +02:00
|
|
|
{
|
2015-03-27 14:02:04 +01:00
|
|
|
size_t ram_quota = Arg_string::find_arg(args, "ram_quota").ulong_value(0);
|
2013-08-10 03:44:55 +02:00
|
|
|
s->upgrade_ram_quota(ram_quota);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
2019-01-30 17:53:16 +01:00
|
|
|
* \param session_ep entry point for managing session objects
|
2013-08-10 03:44:55 +02:00
|
|
|
*/
|
2019-01-30 17:53:16 +01:00
|
|
|
Root(Ram_allocator &ram, Region_map &local_rm,
|
|
|
|
Rpc_entrypoint &session_ep, Allocator &md_alloc,
|
2013-08-10 03:44:55 +02:00
|
|
|
Source_registry &sources, Policy_registry &policies)
|
|
|
|
:
|
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
|
|
|
Root_component<Session_component>(&session_ep, &md_alloc),
|
2019-01-30 17:53:16 +01:00
|
|
|
_ram(ram), _local_rm(local_rm), _sources(sources), _policies(policies)
|
2013-08-10 03:44:55 +02:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _CORE__INCLUDE__TRACE__ROOT_H_ */
|