2016-04-29 22:58:59 +02:00
|
|
|
/*
|
|
|
|
* \brief Region-map client that upgrades PD-session quota on demand
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2013-09-25
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2016-04-29 22:58:59 +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.
|
2016-04-29 22:58:59 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__BASE__INTERNAL__EXPANDING_REGION_MAP_CLIENT_H_
|
|
|
|
#define _INCLUDE__BASE__INTERNAL__EXPANDING_REGION_MAP_CLIENT_H_
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <util/retry.h>
|
|
|
|
#include <region_map/client.h>
|
|
|
|
#include <pd_session/client.h>
|
|
|
|
|
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/upgradeable_client.h>
|
|
|
|
|
|
|
|
namespace Genode { class Expanding_region_map_client; }
|
|
|
|
|
|
|
|
|
|
|
|
struct Genode::Expanding_region_map_client : Region_map_client
|
|
|
|
{
|
|
|
|
Upgradeable_client<Genode::Pd_session_client> _pd_client;
|
|
|
|
|
2019-01-30 17:53:16 +01:00
|
|
|
Expanding_region_map_client(Parent &parent, Pd_session_capability pd,
|
|
|
|
Capability<Region_map> rm,
|
2016-11-06 14:26:34 +01:00
|
|
|
Parent::Client::Id pd_id)
|
2019-01-30 17:53:16 +01:00
|
|
|
: Region_map_client(rm), _pd_client(parent, pd, pd_id) { }
|
2016-04-29 22:58:59 +02:00
|
|
|
|
|
|
|
Local_addr attach(Dataspace_capability ds, size_t size, off_t offset,
|
|
|
|
bool use_local_addr, Local_addr local_addr,
|
2018-05-08 11:21:10 +02:00
|
|
|
bool executable, bool writeable) override
|
2016-04-29 22:58:59 +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
|
|
|
return retry<Out_of_ram>(
|
2016-04-29 22:58:59 +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
|
|
|
return retry<Out_of_caps>(
|
|
|
|
[&] {
|
|
|
|
return Region_map_client::attach(ds, size, offset,
|
|
|
|
use_local_addr,
|
|
|
|
local_addr,
|
2018-05-08 11:21:10 +02:00
|
|
|
executable,
|
|
|
|
writeable); },
|
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
|
|
|
[&] { _pd_client.upgrade_caps(2); });
|
|
|
|
},
|
2016-04-29 22:58:59 +02:00
|
|
|
[&] () { _pd_client.upgrade_ram(8*1024); });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__BASE__INTERNAL__EXPANDING_REGION_MAP_CLIENT_H__ */
|