2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Session
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2011-05-15
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2011-2017 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-20 19:52:51 +00:00
|
|
|
#ifndef _INCLUDE__SESSION__SESSION_H_
|
|
|
|
#define _INCLUDE__SESSION__SESSION_H_
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2017-05-07 21:44:48 +00:00
|
|
|
#include <base/quota_guard.h>
|
|
|
|
#include <base/session_label.h>
|
|
|
|
#include <util/arg_string.h>
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* Each session interface declares an RPC interface and, therefore, relies on
|
|
|
|
* the RPC framework. By including 'base/rpc.h' here, we relieve the interfaces
|
|
|
|
* from including 'base/rpc.h' in addition to 'session/session.h'.
|
|
|
|
*/
|
|
|
|
#include <base/rpc.h>
|
|
|
|
|
2017-05-07 21:44:48 +00:00
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
struct Session;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exceptions that may occur during the session creation
|
|
|
|
*/
|
|
|
|
struct Insufficient_ram_quota : Exception { };
|
|
|
|
struct Insufficient_cap_quota : Exception { };
|
|
|
|
}
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
/**
|
|
|
|
* Base class of session interfaces
|
|
|
|
*/
|
2016-11-06 13:26:34 +00:00
|
|
|
struct Genode::Session
|
2015-03-20 16:50:41 +00:00
|
|
|
{
|
2017-05-07 21:44:48 +00:00
|
|
|
struct Resources
|
|
|
|
{
|
|
|
|
Ram_quota ram_quota;
|
|
|
|
Cap_quota cap_quota;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Diag { bool enabled; };
|
|
|
|
|
|
|
|
typedef Session_label Label;
|
|
|
|
|
2015-03-20 16:50:41 +00:00
|
|
|
/*
|
|
|
|
* Each session interface must implement the class function 'service_name'
|
|
|
|
* ! static const char *service_name();
|
|
|
|
* This function returns the name of the service provided via the session
|
|
|
|
* interface.
|
|
|
|
*/
|
2016-11-06 13:26:34 +00:00
|
|
|
|
|
|
|
virtual ~Session() { }
|
2015-03-20 16:50:41 +00:00
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2017-05-07 21:44:48 +00:00
|
|
|
|
|
|
|
namespace Genode {
|
|
|
|
|
|
|
|
static inline Ram_quota ram_quota_from_args(char const *args)
|
|
|
|
{
|
|
|
|
return { Arg_string::find_arg(args, "ram_quota").ulong_value(0) };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Cap_quota cap_quota_from_args(char const *args)
|
|
|
|
{
|
|
|
|
return { Arg_string::find_arg(args, "cap_quota").ulong_value(0) };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Session::Label session_label_from_args(char const *args)
|
|
|
|
{
|
|
|
|
return label_from_args(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Session::Resources session_resources_from_args(char const *args)
|
|
|
|
{
|
|
|
|
return { ram_quota_from_args(args), cap_quota_from_args(args) };
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Session::Diag session_diag_from_args(char const *args)
|
|
|
|
{
|
|
|
|
return { Arg_string::find_arg(args, "diag").bool_value(false) };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-20 19:52:51 +00:00
|
|
|
#endif /* _INCLUDE__SESSION__SESSION_H_ */
|