base-linux/nova: unify include/rm_session/client.h

By moving the stub implementation to rm_session_client.cc, we can use
the generic base/include/rm_session/client.h for base-linux and
base-nova and merely use platform-specific implementations.

Issue #1832
This commit is contained in:
Norman Feske 2016-01-22 15:36:25 +01:00 committed by Christian Helmuth
parent 6e7f7bdad4
commit 3473955212
14 changed files with 209 additions and 174 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <base/local_capability.h>
#include <rm_session/capability.h>
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<Rm_session>::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_ */

View File

@ -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

View File

@ -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 <base/local_capability.h>
#include <rm_session/client.h>
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<Rm_session>::deref(cap);
}
Rm_session_client::Rm_session_client(Rm_session_capability session)
: Rpc_client<Rm_session>(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(); }

View File

@ -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 <rm_session/capability.h>
#include <base/rpc_client.h>
namespace Genode { struct Rm_session_client; }
struct Genode::Rm_session_client : Rpc_client<Rm_session>
{
/*
* 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<Rm_session>(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<Rpc_attach>(ds, size, offset,
use_local_addr, local_addr,
executable);
}
void detach(Local_addr local_addr) override {
call<Rpc_detach>(local_addr); }
Pager_capability add_client(Thread_capability thread) override {
return call<Rpc_add_client>(thread); }
void remove_client(Pager_capability pager) override {
call<Rpc_remove_client>(pager); }
void fault_handler(Signal_context_capability handler) override {
call<Rpc_fault_handler>(handler); }
State state() override {
return call<Rpc_state>(); }
Dataspace_capability dataspace() override
{
if (!_rm_ds_cap.valid())
_rm_ds_cap = call<Rpc_dataspace>();
return _rm_ds_cap;
}
};
#endif /* _INCLUDE__RM_SESSION__CLIENT_H_ */

View File

@ -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

View File

@ -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 <rm_session/client.h>
using namespace Genode;
Rm_session_client::Rm_session_client(Rm_session_capability session)
: Rpc_client<Rm_session>(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<Rpc_attach>(ds, size, offset, use_local_addr, local_addr,
executable);
}
void Rm_session_client::detach(Local_addr local_addr) {
call<Rpc_detach>(local_addr); }
Pager_capability Rm_session_client::add_client(Thread_capability thread)
{
return call<Rpc_add_client>(thread);
}
void Rm_session_client::remove_client(Pager_capability pager) {
call<Rpc_remove_client>(pager); }
void Rm_session_client::fault_handler(Signal_context_capability cap) {
call<Rpc_fault_handler>(cap); }
Rm_session::State Rm_session_client::state() { return call<Rpc_state>(); }
Dataspace_capability Rm_session_client::dataspace()
{
if (!_rm_ds_cap.valid())
_rm_ds_cap = call<Rpc_dataspace>();
return _rm_ds_cap;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <rm_session/capability.h>
#include <base/rpc_client.h>
namespace Genode { struct Rm_session_client; }
namespace Genode { class Rm_session_client; }
struct Genode::Rm_session_client : Rpc_client<Rm_session>
class Genode::Rm_session_client : public Rpc_client<Rm_session>
{
explicit Rm_session_client(Rm_session_capability session)
: Rpc_client<Rm_session>(session) { }
private:
/*
* 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;
public:
explicit Rm_session_client(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) override
{
return call<Rpc_attach>(ds, size, offset,
use_local_addr, local_addr,
executable);
}
bool executable = false) override;
void detach(Local_addr local_addr) override {
call<Rpc_detach>(local_addr); }
Pager_capability add_client(Thread_capability thread) override {
return call<Rpc_add_client>(thread); }
void remove_client(Pager_capability pager) override {
call<Rpc_remove_client>(pager); }
void fault_handler(Signal_context_capability handler) override {
call<Rpc_fault_handler>(handler); }
State state() override {
return call<Rpc_state>(); }
Dataspace_capability dataspace() override {
return call<Rpc_dataspace>(); }
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_ */

View File

@ -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 <rm_session/client.h>
using namespace Genode;
Rm_session_client::Rm_session_client(Rm_session_capability session)
: Rpc_client<Rm_session>(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<Rpc_attach>(ds, size, offset, use_local_addr, local_addr,
executable);
}
void Rm_session_client::detach(Local_addr local_addr) {
call<Rpc_detach>(local_addr); }
Pager_capability Rm_session_client::add_client(Thread_capability thread)
{
return call<Rpc_add_client>(thread);
}
void Rm_session_client::remove_client(Pager_capability pager) {
call<Rpc_remove_client>(pager); }
void Rm_session_client::fault_handler(Signal_context_capability cap) {
call<Rpc_fault_handler>(cap); }
Rm_session::State Rm_session_client::state() { return call<Rpc_state>(); }
Dataspace_capability Rm_session_client::dataspace() { return call<Rpc_dataspace>(); }