From b62492837d39596179a85e1889c5523b925d2c9e Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 5 Oct 2012 17:12:20 +0200 Subject: [PATCH] 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. --- os/include/os/static_root.h | 64 +++++++++++++++++++++++ os/src/drivers/framebuffer/omap4/main.cc | 34 +----------- os/src/server/nit_fb/main.cc | 35 +------------ os/src/test/dynamic_config/server/main.cc | 38 +------------- 4 files changed, 67 insertions(+), 104 deletions(-) create mode 100644 os/include/os/static_root.h diff --git a/os/include/os/static_root.h b/os/include/os/static_root.h new file mode 100644 index 000000000..44a724ff9 --- /dev/null +++ b/os/include/os/static_root.h @@ -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 +#include +#include + + +namespace Genode { template class Static_root; } + + +/** + * Root interface that hands out a statically created session + */ +template +class Genode::Static_root : public Genode::Rpc_object > +{ + private: + + Capability _session; + + public: + + /** + * Constructor + * + * \param session session to be provided to the client + */ + Static_root(Capability session) : _session(session) { } + + + /******************** + ** Root interface ** + ********************/ + + Capability session(Root::Session_args const &args) + { + return _session; + } + + void upgrade(Capability, Root::Upgrade_args const &) { } + + void close(Capability) { } +}; + +#endif /* _INCLUDE__OS__STATIC_ROOT_H_ */ diff --git a/os/src/drivers/framebuffer/omap4/main.cc b/os/src/drivers/framebuffer/omap4/main.cc index 1f0718d54..df7460bdd 100644 --- a/os/src/drivers/framebuffer/omap4/main.cc +++ b/os/src/drivers/framebuffer/omap4/main.cc @@ -17,44 +17,12 @@ #include #include #include -#include +#include /* local includes */ #include -/** - * Root interface that hands out a statically created session - */ -template -class Static_root : public Genode::Rpc_object > -{ - private: - - typedef Genode::Capability 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; diff --git a/os/src/server/nit_fb/main.cc b/os/src/server/nit_fb/main.cc index 2297d4c1a..283f66723 100644 --- a/os/src/server/nit_fb/main.cc +++ b/os/src/server/nit_fb/main.cc @@ -13,50 +13,17 @@ /* Genode includes */ #include -#include #include #include #include #include #include #include -#include #include +#include #include -/** - * Root interface that hands out a statically created session - */ -template -class Static_root : public Genode::Rpc_object > -{ - private: - - typedef Genode::Capability 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 { /** diff --git a/os/src/test/dynamic_config/server/main.cc b/os/src/test/dynamic_config/server/main.cc index dc48ea300..58c3e5192 100644 --- a/os/src/test/dynamic_config/server/main.cc +++ b/os/src/test/dynamic_config/server/main.cc @@ -15,49 +15,13 @@ */ /* Genode includes */ -#include #include -#include #include +#include #include #include #include -/** - * Root interface that hands out a statically created session - */ -template -class Static_root : public Genode::Rpc_object > -{ - private: - - typedef Genode::Capability 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