base: make CAP session upgradeable

* Introduce 'Out_of_metadata' exception for capability allocation

Ref #1443
This commit is contained in:
Stefan Kalkowski 2015-05-05 13:31:11 +02:00 committed by Christian Helmuth
parent 73c3a81e0b
commit 64bfe233d7
7 changed files with 24 additions and 1 deletions

View File

@ -26,6 +26,8 @@ namespace Genode {
Cap_session_component(Allocator *md_alloc, const char *args) {}
void upgrade_ram_quota(size_t ram_quota) { }
Native_capability alloc(Native_capability ep);
void free(Native_capability cap);

View File

@ -36,6 +36,8 @@ namespace Genode {
Cap_session_component(Allocator *md_alloc, const char *args) {}
void upgrade_ram_quota(size_t ram_quota) { }
Native_capability alloc(Native_capability ep)
{
Lock::Guard lock_guard(_lock());

View File

@ -62,6 +62,8 @@ namespace Genode {
}
}
void upgrade_ram_quota(size_t ram_quota) { }
Native_capability alloc(Native_capability ep, addr_t entry,
addr_t mtd)
{

View File

@ -24,6 +24,8 @@ struct Genode::Cap_session_component : Rpc_object<Cap_session>
{
Cap_session_component(Allocator *md_alloc, const char *args) {}
void upgrade_ram_quota(size_t ram_quota) { }
Native_capability alloc(Native_capability ep);
void free(Native_capability cap);

View File

@ -18,6 +18,7 @@
#ifndef _INCLUDE__CAP_SESSION__CAP_SESSION_H_
#define _INCLUDE__CAP_SESSION__CAP_SESSION_H_
#include <base/exception.h>
#include <base/native_types.h>
#include <session/session.h>
@ -26,6 +27,8 @@ namespace Genode { struct Cap_session; }
struct Genode::Cap_session : Session
{
class Out_of_metadata : public Exception { };
static const char *service_name() { return "CAP"; }
virtual ~Cap_session() { }
@ -35,6 +38,8 @@ struct Genode::Cap_session : Session
*
* \param ep entry point that will use this capability
*
* \throw Out_of_metadata if meta-data backing store is exhausted
*
* \return new userland capability
*/
virtual Native_capability alloc(Native_capability ep) = 0;
@ -51,7 +56,8 @@ struct Genode::Cap_session : Session
** RPC declaration **
*********************/
GENODE_RPC(Rpc_alloc, Native_capability, alloc, Native_capability);
GENODE_RPC_THROW(Rpc_alloc, Native_capability, alloc,
GENODE_TYPE_LIST(Out_of_metadata), Native_capability);
GENODE_RPC(Rpc_free, void, free, Native_capability);
GENODE_RPC_INTERFACE(Rpc_alloc, Rpc_free);
};

View File

@ -33,6 +33,13 @@ namespace Genode {
Cap_session_component *_create_session(const char *args) {
return new (md_alloc()) Cap_session_component(_md_alloc, args); }
void _upgrade_session(Cap_session_component *c, const char *args)
{
size_t ram_quota =
Arg_string::find_arg(args, "ram_quota").ulong_value(0);
c->upgrade_ram_quota(ram_quota);
}
public:
/**

View File

@ -36,6 +36,8 @@ namespace Genode {
Cap_session_component(Allocator *md_alloc, const char *args) {}
void upgrade_ram_quota(size_t ram_quota) { }
Native_capability alloc(Native_capability ep)
{
Lock::Guard lock_guard(_lock());