committed by
Norman Feske
parent
dd15d65800
commit
9c7df24e20
22
include/regulator_session/capability.h
Normal file
22
include/regulator_session/capability.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* \brief Regulator session capability type
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__REGULATOR_SESSION__CAPABILITY_H_
|
||||
#define _INCLUDE__REGULATOR_SESSION__CAPABILITY_H_
|
||||
|
||||
#include <base/capability.h>
|
||||
#include <regulator_session/regulator_session.h>
|
||||
|
||||
namespace Regulator { typedef Genode::Capability<Session> Session_capability; }
|
||||
|
||||
#endif /* _INCLUDE__REGULATOR_SESSION__CAPABILITY_H_ */
|
||||
44
include/regulator_session/client.h
Normal file
44
include/regulator_session/client.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* \brief Client-side regulator session interface
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__REGULATOR_SESSION__CLIENT_H_
|
||||
#define _INCLUDE__REGULATOR_SESSION__CLIENT_H_
|
||||
|
||||
#include <base/rpc_client.h>
|
||||
#include <regulator_session/capability.h>
|
||||
|
||||
namespace Regulator { struct Session_client; }
|
||||
|
||||
|
||||
struct Regulator::Session_client : public Genode::Rpc_client<Session>
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param session session capability
|
||||
*/
|
||||
Session_client(Session_capability session)
|
||||
: Genode::Rpc_client<Session>(session) { }
|
||||
|
||||
|
||||
/*********************************
|
||||
** Regulator session interface **
|
||||
*********************************/
|
||||
|
||||
void level(unsigned long level) override { call<Rpc_set_level>(level); }
|
||||
unsigned long level() override { return call<Rpc_level>(); }
|
||||
void state(bool enable) override { call<Rpc_set_state>(enable); }
|
||||
bool state() override { return call<Rpc_state>(); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__REGULATOR_SESSION__CLIENT_H_ */
|
||||
42
include/regulator_session/connection.h
Normal file
42
include/regulator_session/connection.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* \brief Connection to regulator service
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__REGULATOR_SESSION__CONNECTION_H_
|
||||
#define _INCLUDE__REGULATOR_SESSION__CONNECTION_H_
|
||||
|
||||
#include <regulator_session/client.h>
|
||||
#include <regulator/consts.h>
|
||||
#include <base/connection.h>
|
||||
|
||||
namespace Regulator { struct Connection; }
|
||||
|
||||
|
||||
struct Regulator::Connection : Genode::Connection<Session>, Session_client
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param regulator identifier for the specific regulator
|
||||
* \param label string identifier of the client
|
||||
*/
|
||||
Connection(Genode::Env &env, Regulator_id regulator, const char * label = "")
|
||||
:
|
||||
Genode::Connection<Session>(env,
|
||||
session(env.parent(),
|
||||
"ram_quota=8K, cap_quota=%ld, regulator=\"%s\", label=\"%s\"",
|
||||
CAP_QUOTA, regulator_name_by_id(regulator), label)),
|
||||
Session_client(cap())
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__REGULATOR_SESSION__CONNECTION_H_ */
|
||||
65
include/regulator_session/regulator_session.h
Normal file
65
include/regulator_session/regulator_session.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* \brief Abstract regulator session interface.
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__REGULATOR_SESSION__REGULATOR_SESSION_H_
|
||||
#define _INCLUDE__REGULATOR_SESSION__REGULATOR_SESSION_H_
|
||||
|
||||
#include <session/session.h>
|
||||
|
||||
namespace Regulator { struct Session; }
|
||||
|
||||
|
||||
struct Regulator::Session : public Genode::Session
|
||||
{
|
||||
/**
|
||||
* \noapi
|
||||
*/
|
||||
static const char *service_name() { return "Regulator"; }
|
||||
|
||||
enum { CAP_QUOTA = 2 };
|
||||
|
||||
virtual ~Session() { }
|
||||
|
||||
/**
|
||||
* Set regulator specific level
|
||||
*/
|
||||
virtual void level(unsigned long level) = 0;
|
||||
|
||||
/**
|
||||
* Returns current regulator level
|
||||
*/
|
||||
virtual unsigned long level() = 0;
|
||||
|
||||
/**
|
||||
* Enable/disable regulator
|
||||
*/
|
||||
virtual void state(bool enable) = 0;
|
||||
|
||||
/**
|
||||
* Returns whether regulator is enabled or not
|
||||
*/
|
||||
virtual bool state() = 0;
|
||||
|
||||
|
||||
/*******************
|
||||
** RPC interface **
|
||||
*******************/
|
||||
|
||||
GENODE_RPC(Rpc_set_level, void, level, unsigned long);
|
||||
GENODE_RPC(Rpc_level, unsigned long, level);
|
||||
GENODE_RPC(Rpc_set_state, void, state, bool);
|
||||
GENODE_RPC(Rpc_state, bool, state);
|
||||
GENODE_RPC_INTERFACE(Rpc_set_level, Rpc_level, Rpc_set_state, Rpc_state);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__REGULATOR_SESSION__REGULATOR_SESSION_H_ */
|
||||
40
include/regulator_session/rpc_object.h
Normal file
40
include/regulator_session/rpc_object.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* \brief Server-side block regulator interface
|
||||
* \author Stefan Kalkowski
|
||||
* \date 2013-06-13
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2017 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU Affero General Public License version 3.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__REGULATOR_SESSION__SERVER_H_
|
||||
#define _INCLUDE__REGULATOR_SESSION__SERVER_H_
|
||||
|
||||
#include <base/rpc_server.h>
|
||||
#include <regulator/consts.h>
|
||||
#include <regulator_session/regulator_session.h>
|
||||
|
||||
namespace Regulator { class Session_rpc_object; }
|
||||
|
||||
|
||||
class Regulator::Session_rpc_object : public Genode::Rpc_object<Session, Session_rpc_object>
|
||||
{
|
||||
protected:
|
||||
|
||||
Regulator_id _id; /* regulator identifier */
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param id identifies the specific regulator
|
||||
*/
|
||||
Session_rpc_object(Regulator_id id) : _id(id) { }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__REGULATOR_SESSION__SERVER_H_ */
|
||||
Reference in New Issue
Block a user