2013-07-18 16:27:42 +02:00
|
|
|
/*
|
|
|
|
* \brief ROM service provided to Noux processes
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2013-07-18
|
|
|
|
*
|
|
|
|
* The local ROM service has the sole purpose of tracking ROM dataspaces
|
|
|
|
* so that they are properly detached from RM sessions when the corresponding
|
|
|
|
* ROM sessions are closed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2013-2017 Genode Labs GmbH
|
2013-07-18 16:27:42 +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-07-18 16:27:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NOUX__LOCAL_ROM_SERVICE_H_
|
|
|
|
#define _NOUX__LOCAL_ROM_SERVICE_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <base/service.h>
|
|
|
|
|
|
|
|
/* Noux includes */
|
|
|
|
#include <dataspace_registry.h>
|
|
|
|
#include <rom_session_component.h>
|
|
|
|
|
|
|
|
namespace Noux {
|
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
typedef Local_service<Rom_session_component> Local_rom_service;
|
|
|
|
class Local_rom_factory;
|
|
|
|
}
|
|
|
|
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
class Noux::Local_rom_factory : public Local_rom_service::Factory
|
|
|
|
{
|
|
|
|
private:
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2017-01-06 12:12:39 +01:00
|
|
|
Allocator &_alloc;
|
|
|
|
Env &_env;
|
2016-11-23 17:07:49 +01:00
|
|
|
Rpc_entrypoint &_ep;
|
|
|
|
Vfs::Dir_file_system &_root_dir;
|
|
|
|
Dataspace_registry &_registry;
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
public:
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2017-01-06 12:12:39 +01:00
|
|
|
Local_rom_factory(Allocator &alloc, Env &env, Rpc_entrypoint &ep,
|
|
|
|
Vfs::Dir_file_system &root_dir,
|
2016-11-23 17:07:49 +01:00
|
|
|
Dataspace_registry ®istry)
|
|
|
|
:
|
2017-01-06 12:12:39 +01:00
|
|
|
_alloc(alloc), _env(env), _ep(ep), _root_dir(root_dir), _registry(registry)
|
2016-11-23 17:07:49 +01:00
|
|
|
{ }
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2016-11-23 17:07:49 +01:00
|
|
|
Rom_session_component &create(Args const &args, Affinity) override
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
Rom_session_component::Name const rom_name =
|
|
|
|
label_from_args(args.string()).last_element();
|
2013-07-18 16:27:42 +02:00
|
|
|
|
2017-01-06 12:12:39 +01:00
|
|
|
return *new (_alloc)
|
|
|
|
Rom_session_component(_alloc, _env, _ep, _root_dir, _registry, rom_name);
|
2013-07-18 16:27:42 +02:00
|
|
|
}
|
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
|
|
|
catch (Rom_connection::Rom_connection_failed) {
|
|
|
|
throw Service_denied(); }
|
2016-11-23 17:07:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void upgrade(Rom_session_component &, Args const &) override { }
|
|
|
|
|
|
|
|
void destroy(Rom_session_component &session) override
|
|
|
|
{
|
2017-01-06 12:12:39 +01:00
|
|
|
Genode::destroy(_alloc, &session);
|
2016-11-23 17:07:49 +01:00
|
|
|
}
|
|
|
|
};
|
2013-07-18 16:27:42 +02:00
|
|
|
|
|
|
|
#endif /* _NOUX__LOCAL_ROM_SERVICE_H_ */
|