mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
Move 'Static_root' to public place
The 'Static_root' class template has proven to be useful for more than one program. So we expose it as part of the API in the os repository.
This commit is contained in:
parent
64245dde3a
commit
b62492837d
64
os/include/os/static_root.h
Normal file
64
os/include/os/static_root.h
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* \brief Root component for singleton services
|
||||
* \author Norman Feske
|
||||
* \date 2012-10-05
|
||||
*
|
||||
* Many components, in particular device drivers, support only one client
|
||||
* at a time. In this case, one single session may be created right at the
|
||||
* start of the program and handed out via the 'Root::session' function.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__OS__STATIC_ROOT_H_
|
||||
#define _INCLUDE__OS__STATIC_ROOT_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/rpc_server.h>
|
||||
#include <session/session.h>
|
||||
#include <root/root.h>
|
||||
|
||||
|
||||
namespace Genode { template <typename> class Static_root; }
|
||||
|
||||
|
||||
/**
|
||||
* Root interface that hands out a statically created session
|
||||
*/
|
||||
template <typename SESSION>
|
||||
class Genode::Static_root : public Genode::Rpc_object<Genode::Typed_root<SESSION> >
|
||||
{
|
||||
private:
|
||||
|
||||
Capability<SESSION> _session;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param session session to be provided to the client
|
||||
*/
|
||||
Static_root(Capability<SESSION> session) : _session(session) { }
|
||||
|
||||
|
||||
/********************
|
||||
** Root interface **
|
||||
********************/
|
||||
|
||||
Capability<Session> session(Root::Session_args const &args)
|
||||
{
|
||||
return _session;
|
||||
}
|
||||
|
||||
void upgrade(Capability<Session>, Root::Upgrade_args const &) { }
|
||||
|
||||
void close(Capability<Session>) { }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__OS__STATIC_ROOT_H_ */
|
@ -17,44 +17,12 @@
|
||||
#include <dataspace/client.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/sleep.h>
|
||||
#include <root/component.h>
|
||||
#include <os/static_root.h>
|
||||
|
||||
/* local includes */
|
||||
#include <driver.h>
|
||||
|
||||
|
||||
/**
|
||||
* Root interface that hands out a statically created session
|
||||
*/
|
||||
template <typename SESSION_TYPE>
|
||||
class Static_root : public Genode::Rpc_object<Genode::Typed_root<SESSION_TYPE> >
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Genode::Capability<SESSION_TYPE> Session_capability;
|
||||
|
||||
Session_capability _session;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param session session to be provided to the client
|
||||
*/
|
||||
Static_root(Session_capability session) : _session(session) { }
|
||||
|
||||
|
||||
/********************
|
||||
** Root interface **
|
||||
********************/
|
||||
|
||||
Genode::Session_capability session(Genode::Root::Session_args const &args) { return _session; }
|
||||
void upgrade(Genode::Session_capability, Genode::Root::Upgrade_args const &) { }
|
||||
void close(Genode::Session_capability) { }
|
||||
};
|
||||
|
||||
|
||||
namespace Framebuffer {
|
||||
using namespace Genode;
|
||||
class Session_component;
|
||||
|
@ -13,50 +13,17 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/sleep.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <nitpicker_view/client.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <nitpicker_session/connection.h>
|
||||
#include <dataspace/client.h>
|
||||
#include <input_session/input_session.h>
|
||||
#include <input/event.h>
|
||||
#include <root/root.h>
|
||||
#include <os/config.h>
|
||||
#include <os/static_root.h>
|
||||
#include <timer_session/connection.h>
|
||||
|
||||
|
||||
/**
|
||||
* Root interface that hands out a statically created session
|
||||
*/
|
||||
template <typename SESSION_TYPE>
|
||||
class Static_root : public Genode::Rpc_object<Genode::Typed_root<SESSION_TYPE> >
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Genode::Capability<SESSION_TYPE> Session_capability;
|
||||
|
||||
Session_capability _session;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param session session to be provided to the client
|
||||
*/
|
||||
Static_root(Session_capability session) : _session(session) { }
|
||||
|
||||
|
||||
/********************
|
||||
** Root interface **
|
||||
********************/
|
||||
|
||||
Genode::Session_capability session(Genode::Root::Session_args const &args) { return _session; }
|
||||
void upgrade(Genode::Session_capability, Genode::Root::Upgrade_args const &) { }
|
||||
void close(Genode::Session_capability) { }
|
||||
};
|
||||
|
||||
|
||||
namespace Input {
|
||||
|
||||
/**
|
||||
|
@ -15,49 +15,13 @@
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/signal.h>
|
||||
#include <root/root.h>
|
||||
#include <os/attached_ram_dataspace.h>
|
||||
#include <os/static_root.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <rom_session/rom_session.h>
|
||||
#include <cap_session/connection.h>
|
||||
|
||||
/**
|
||||
* Root interface that hands out a statically created session
|
||||
*/
|
||||
template <typename SESSION_TYPE>
|
||||
class Static_root : public Genode::Rpc_object<Genode::Typed_root<SESSION_TYPE> >
|
||||
{
|
||||
private:
|
||||
|
||||
typedef Genode::Capability<SESSION_TYPE> Session_capability;
|
||||
|
||||
Session_capability _session;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* \param session session to be provided to the client
|
||||
*/
|
||||
Static_root(Session_capability session) : _session(session) { }
|
||||
|
||||
|
||||
/********************
|
||||
** Root interface **
|
||||
********************/
|
||||
|
||||
Genode::Session_capability session(Genode::Root::Session_args const &)
|
||||
{
|
||||
return _session;
|
||||
}
|
||||
|
||||
void upgrade(Genode::Session_capability, Genode::Root::Upgrade_args const &) { }
|
||||
void close(Genode::Session_capability) { }
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The implementation of this class follows the lines of
|
||||
|
Loading…
x
Reference in New Issue
Block a user