diff --git a/repos/base-fiasco/lib/mk/base-common.mk b/repos/base-fiasco/lib/mk/base-common.mk index e035876823..1b612a46ef 100644 --- a/repos/base-fiasco/lib/mk/base-common.mk +++ b/repos/base-fiasco/lib/mk/base-common.mk @@ -23,6 +23,7 @@ SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc SRC_CC += thread/myself.cc SRC_CC += thread/context_allocator.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-foc/lib/mk/base-common.mk b/repos/base-foc/lib/mk/base-common.mk index 083daa0151..1a183ef543 100644 --- a/repos/base-foc/lib/mk/base-common.mk +++ b/repos/base-foc/lib/mk/base-common.mk @@ -23,6 +23,7 @@ SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc SRC_CC += thread/myself.cc SRC_CC += thread/context_allocator.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-hw/lib/mk/base-common.inc b/repos/base-hw/lib/mk/base-common.inc index 2e4320f6af..dcba144e8a 100644 --- a/repos/base-hw/lib/mk/base-common.inc +++ b/repos/base-hw/lib/mk/base-common.inc @@ -28,6 +28,7 @@ SRC_CC += thread/trace.cc SRC_CC += thread/context_allocator.cc SRC_CC += kernel/interface.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-linux/include/rm_session/client.h b/repos/base-linux/include/rm_session/client.h deleted file mode 100644 index b7e5d0f722..0000000000 --- a/repos/base-linux/include/rm_session/client.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * \brief Pseudo RM-session client stub targeting the process-local RM service - * \author Norman Feske - * \date 2011-11-21 - */ - -/* - * Copyright (C) 2011-2013 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__RM_SESSION__CLIENT_H_ -#define _INCLUDE__RM_SESSION__CLIENT_H_ - -/* Genode includes */ -#include -#include - -namespace Genode { - - struct Rm_session_client : Rm_session, Rm_session_capability - { - typedef Rm_session Rpc_interface; - - /** - * Return pointer to locally implemented RM session - * - * \throw Local_interface::Non_local_capability - */ - Rm_session *_local() const { - return Local_capability::deref(*this); } - - explicit Rm_session_client(Rm_session_capability session) - : Rm_session_capability(session) { } - - Local_addr attach(Dataspace_capability ds, size_t size = 0, - off_t offset = 0, bool use_local_addr = false, - Local_addr local_addr = (void *)0, - bool executable = false) - { - return _local()->attach(ds, size, offset, use_local_addr, - local_addr, executable); - } - - void detach(Local_addr local_addr) { - return _local()->detach(local_addr); } - - Pager_capability add_client(Thread_capability thread) { - return _local()->add_client(thread); } - - void remove_client(Pager_capability pager) { - _local()->remove_client(pager); } - - void fault_handler(Signal_context_capability /*handler*/) - { - /* - * On Linux, page faults are never reflected to RM clients. They - * are always handled by the kernel. If a segmentation fault - * occurs, this condition is being reflected as a CPU exception - * to the handler registered via 'Cpu_session::exception_handler'. - */ - } - - State state() { - return _local()->state(); } - - Dataspace_capability dataspace() { - return _local()->dataspace(); } - }; -} - -#endif /* _INCLUDE__RM_SESSION__CLIENT_H_ */ diff --git a/repos/base-linux/lib/mk/base-common.mk b/repos/base-linux/lib/mk/base-common.mk index 0d5b2ae762..4d754f701a 100644 --- a/repos/base-linux/lib/mk/base-common.mk +++ b/repos/base-linux/lib/mk/base-common.mk @@ -22,6 +22,7 @@ SRC_CC += server/server.cc server/common.cc SRC_CC += thread/trace.cc thread/thread_env.cc thread/context_allocator.cc SRC_CC += irq/platform.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-linux/src/base/rm_session_client.cc b/repos/base-linux/src/base/rm_session_client.cc new file mode 100644 index 0000000000..5df0fc9057 --- /dev/null +++ b/repos/base-linux/src/base/rm_session_client.cc @@ -0,0 +1,72 @@ +/* + * \brief Pseudo RM-session client stub targeting the process-local RM service + * \author Norman Feske + * \date 2011-11-21 + */ + +/* + * Copyright (C) 2011-2016 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. + */ + +#include +#include + +using namespace Genode; + +/** + * Return pointer to locally implemented RM session + * + * \throw Local_interface::Non_local_capability + */ +static Rm_session *_local(Rm_session_capability cap) +{ + return Local_capability::deref(cap); +} + + +Rm_session_client::Rm_session_client(Rm_session_capability session) +: Rpc_client(session) { } + + +Rm_session::Local_addr +Rm_session_client::attach(Dataspace_capability ds, size_t size, + off_t offset, bool use_local_addr, + Rm_session::Local_addr local_addr, + bool executable) +{ + return _local(*this)->attach(ds, size, offset, use_local_addr, + local_addr, executable); +} + +void Rm_session_client::detach(Local_addr local_addr) { + return _local(*this)->detach(local_addr); } + + +Pager_capability Rm_session_client::add_client(Thread_capability thread) { + return _local(*this)->add_client(thread); } + + +void Rm_session_client::remove_client(Pager_capability pager) { + _local(*this)->remove_client(pager); } + + +void Rm_session_client::fault_handler(Signal_context_capability /*handler*/) +{ + /* + * On Linux, page faults are never reflected to RM clients. They + * are always handled by the kernel. If a segmentation fault + * occurs, this condition is being reflected as a CPU exception + * to the handler registered via 'Cpu_session::exception_handler'. + */ +} + + +Rm_session::State Rm_session_client::state() { return _local(*this)->state(); } + + +Dataspace_capability Rm_session_client::dataspace() { + return _local(*this)->dataspace(); } + diff --git a/repos/base-nova/include/rm_session/client.h b/repos/base-nova/include/rm_session/client.h deleted file mode 100644 index 22cd240cf3..0000000000 --- a/repos/base-nova/include/rm_session/client.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * \brief Client-side region manager session interface - * \author Christian Helmuth - * \author Alexander Boettcher - * \date 2006-07-11 - */ - -/* - * Copyright (C) 2006-2013 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__RM_SESSION__CLIENT_H_ -#define _INCLUDE__RM_SESSION__CLIENT_H_ - -#include -#include - -namespace Genode { struct Rm_session_client; } - - -struct Genode::Rm_session_client : Rpc_client -{ - /* - * Multiple calls to get the dataspace capability on NOVA lead to the - * situation that the caller gets each time a new mapping of the same - * capability at different indexes. But the client/caller assumes to get - * every time the very same index, e.g. in Noux the index is used to look - * up data structures attached to the capability. Therefore, we cache the - * dataspace capability on the first request. - */ - Dataspace_capability _rm_ds_cap; - - explicit Rm_session_client(Rm_session_capability session) - : Rpc_client(session) { } - - Local_addr attach(Dataspace_capability ds, size_t size = 0, - off_t offset = 0, bool use_local_addr = false, - Local_addr local_addr = (void *)0, - bool executable = false) override - { - return call(ds, size, offset, - use_local_addr, local_addr, - executable); - } - - void detach(Local_addr local_addr) override { - call(local_addr); } - - Pager_capability add_client(Thread_capability thread) override { - return call(thread); } - - void remove_client(Pager_capability pager) override { - call(pager); } - - void fault_handler(Signal_context_capability handler) override { - call(handler); } - - State state() override { - return call(); } - - Dataspace_capability dataspace() override - { - if (!_rm_ds_cap.valid()) - _rm_ds_cap = call(); - return _rm_ds_cap; - } -}; - -#endif /* _INCLUDE__RM_SESSION__CLIENT_H_ */ diff --git a/repos/base-nova/lib/mk/base-common.mk b/repos/base-nova/lib/mk/base-common.mk index 88b6fbd261..b5b7533920 100644 --- a/repos/base-nova/lib/mk/base-common.mk +++ b/repos/base-nova/lib/mk/base-common.mk @@ -22,6 +22,7 @@ SRC_CC += thread/thread.cc thread/thread_context.cc thread/trace.cc SRC_CC += thread/myself.cc SRC_CC += thread/context_allocator.cc env/cap_map.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-nova/src/base/rm_session_client.cc b/repos/base-nova/src/base/rm_session_client.cc new file mode 100644 index 0000000000..0f2b3bcb4b --- /dev/null +++ b/repos/base-nova/src/base/rm_session_client.cc @@ -0,0 +1,55 @@ +/* + * \brief Client-side region manager session interface + * \author Norman Feske + * \author Alexander Boettcher + * \date 2016-01-22 + */ + +/* + * Copyright (C) 2006-2013 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. + */ + +#include + +using namespace Genode; + + +Rm_session_client::Rm_session_client(Rm_session_capability session) +: Rpc_client(session) { } + +Rm_session::Local_addr +Rm_session_client::attach(Dataspace_capability ds, size_t size, off_t offset, + bool use_local_addr, Local_addr local_addr, + bool executable) +{ + return call(ds, size, offset, use_local_addr, local_addr, + executable); +} + +void Rm_session_client::detach(Local_addr local_addr) { + call(local_addr); } + +Pager_capability Rm_session_client::add_client(Thread_capability thread) +{ + return call(thread); +} + +void Rm_session_client::remove_client(Pager_capability pager) { + call(pager); } + +void Rm_session_client::fault_handler(Signal_context_capability cap) { + call(cap); } + + Rm_session::State Rm_session_client::state() { return call(); } + +Dataspace_capability Rm_session_client::dataspace() +{ + if (!_rm_ds_cap.valid()) + _rm_ds_cap = call(); + + return _rm_ds_cap; +} + diff --git a/repos/base-okl4/lib/mk/base-common.mk b/repos/base-okl4/lib/mk/base-common.mk index e035876823..1b612a46ef 100644 --- a/repos/base-okl4/lib/mk/base-common.mk +++ b/repos/base-okl4/lib/mk/base-common.mk @@ -23,6 +23,7 @@ SRC_CC += thread/thread.cc thread/thread_bootstrap.cc thread/trace.cc SRC_CC += thread/myself.cc SRC_CC += thread/context_allocator.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-pistachio/lib/mk/base-common.mk b/repos/base-pistachio/lib/mk/base-common.mk index ab9809275c..ea6a5cab48 100644 --- a/repos/base-pistachio/lib/mk/base-common.mk +++ b/repos/base-pistachio/lib/mk/base-common.mk @@ -23,6 +23,7 @@ SRC_CC += thread/thread.cc thread/trace.cc thread/thread_bootstrap.cc SRC_CC += thread/myself.cc SRC_CC += thread/context_allocator.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base-sel4/lib/mk/base-common.inc b/repos/base-sel4/lib/mk/base-common.inc index 3a6856d6e8..9907bc746d 100644 --- a/repos/base-sel4/lib/mk/base-common.inc +++ b/repos/base-sel4/lib/mk/base-common.inc @@ -25,6 +25,7 @@ SRC_CC += thread/context_allocator.cc SRC_CC += thread/thread_bootstrap.cc SRC_CC += env/capability.cc SRC_CC += sleep.cc +SRC_CC += rm_session_client.cc INC_DIR += $(REP_DIR)/src/include $(BASE_DIR)/src/include diff --git a/repos/base/include/rm_session/client.h b/repos/base/include/rm_session/client.h index 235c961419..6065ae3241 100644 --- a/repos/base/include/rm_session/client.h +++ b/repos/base/include/rm_session/client.h @@ -1,11 +1,12 @@ /* * \brief Client-side region manager session interface * \author Christian Helmuth + * \author Norman Feske * \date 2006-07-11 */ /* - * Copyright (C) 2006-2013 Genode Labs GmbH + * Copyright (C) 2006-2016 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. @@ -17,41 +18,40 @@ #include #include -namespace Genode { struct Rm_session_client; } +namespace Genode { class Rm_session_client; } -struct Genode::Rm_session_client : Rpc_client +class Genode::Rm_session_client : public Rpc_client { - explicit Rm_session_client(Rm_session_capability session) - : Rpc_client(session) { } + private: - Local_addr attach(Dataspace_capability ds, size_t size = 0, - off_t offset = 0, bool use_local_addr = false, - Local_addr local_addr = (void *)0, - bool executable = false) override - { - return call(ds, size, offset, - use_local_addr, local_addr, - executable); - } + /* + * Multiple calls to get the dataspace capability on NOVA lead to the + * situation that the caller gets each time a new mapping of the same + * capability at different indices. But the client/caller assumes to + * get every time the very same index, e.g., in Noux the index is used + * to look up data structures attached to the capability. Therefore, we + * cache the dataspace capability on the first request. + * + * On all other base platforms, this member variable remains unused. + */ + Dataspace_capability _rm_ds_cap; - void detach(Local_addr local_addr) override { - call(local_addr); } + public: - Pager_capability add_client(Thread_capability thread) override { - return call(thread); } + explicit Rm_session_client(Rm_session_capability session); - void remove_client(Pager_capability pager) override { - call(pager); } + Local_addr attach(Dataspace_capability ds, size_t size = 0, + off_t offset = 0, bool use_local_addr = false, + Local_addr local_addr = (void *)0, + bool executable = false) override; - void fault_handler(Signal_context_capability handler) override { - call(handler); } - - State state() override { - return call(); } - - Dataspace_capability dataspace() override { - return call(); } + void detach(Local_addr) override; + Pager_capability add_client(Thread_capability) override; + void remove_client(Pager_capability) override; + void fault_handler(Signal_context_capability) override; + State state() override; + Dataspace_capability dataspace() override; }; #endif /* _INCLUDE__RM_SESSION__CLIENT_H_ */ diff --git a/repos/base/src/base/rm_session_client.cc b/repos/base/src/base/rm_session_client.cc new file mode 100644 index 0000000000..b5a19694c6 --- /dev/null +++ b/repos/base/src/base/rm_session_client.cc @@ -0,0 +1,46 @@ +/* + * \brief Client-side region manager session interface + * \author Norman Feske + * \date 2016-01-22 + */ + +/* + * Copyright (C) 2006-2013 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. + */ + +#include + +using namespace Genode; + +Rm_session_client::Rm_session_client(Rm_session_capability session) +: Rpc_client(session) { } + +Rm_session::Local_addr +Rm_session_client::attach(Dataspace_capability ds, size_t size, off_t offset, + bool use_local_addr, Local_addr local_addr, + bool executable) +{ + return call(ds, size, offset, use_local_addr, local_addr, + executable); +} + +void Rm_session_client::detach(Local_addr local_addr) { + call(local_addr); } + +Pager_capability Rm_session_client::add_client(Thread_capability thread) +{ + return call(thread); +} + +void Rm_session_client::remove_client(Pager_capability pager) { + call(pager); } + +void Rm_session_client::fault_handler(Signal_context_capability cap) { + call(cap); } + + Rm_session::State Rm_session_client::state() { return call(); } + +Dataspace_capability Rm_session_client::dataspace() { return call(); }