base: separate native CPU from CPU session
This patch unifies the CPU session interface across all platforms. The former differences are moved to respective "native-CPU" interfaces. NOVA is not covered by the patch and still relies on a custom version of the core-internal 'cpu_session_component.h'. However, this will soon be removed once the ongoing rework of pause/single-step on NOVA is completed. Fixes #1922
This commit is contained in:
committed by
Christian Helmuth
parent
e9dec93f4b
commit
0c299c5e08
21
repos/base-linux/src/base/env/platform_env.cc
vendored
21
repos/base-linux/src/base/env/platform_env.cc
vendored
@@ -169,8 +169,8 @@ Platform_env::Platform_env()
|
||||
env_stack_area_rm_session = &_stack_area;
|
||||
|
||||
/* register TID and PID of the main thread at core */
|
||||
cpu_session()->thread_id(parent()->main_thread_cap(),
|
||||
lx_getpid(), lx_gettid());
|
||||
Linux_native_cpu_client native_cpu(cpu_session()->native_cpu());
|
||||
native_cpu.thread_id(parent()->main_thread_cap(), lx_getpid(), lx_gettid());
|
||||
}
|
||||
|
||||
|
||||
@@ -182,25 +182,14 @@ namespace Genode {
|
||||
|
||||
Native_connection_state server_socket_pair()
|
||||
{
|
||||
/*
|
||||
* Obtain access to Linux-specific extension of the CPU session
|
||||
* interface. We can cast to the specific type because the Linux
|
||||
* version of 'Platform_env' is hosting a 'Linux_cpu_client' object.
|
||||
*/
|
||||
Linux_cpu_session *cpu = dynamic_cast<Linux_cpu_session *>(env()->cpu_session());
|
||||
|
||||
if (!cpu) {
|
||||
PERR("could not obtain Linux extension to CPU session interface");
|
||||
struct Could_not_access_linux_cpu_session { };
|
||||
throw Could_not_access_linux_cpu_session();
|
||||
}
|
||||
Linux_native_cpu_client native_cpu(env()->cpu_session()->native_cpu());
|
||||
|
||||
Native_connection_state ncs;
|
||||
|
||||
Thread_base *thread = Thread_base::myself();
|
||||
if (thread) {
|
||||
ncs.server_sd = cpu->server_sd(thread->cap()).dst().socket;
|
||||
ncs.client_sd = cpu->client_sd(thread->cap()).dst().socket;
|
||||
ncs.server_sd = native_cpu.server_sd(thread->cap()).dst().socket;
|
||||
ncs.client_sd = native_cpu.client_sd(thread->cap()).dst().socket;
|
||||
}
|
||||
return ncs;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <base/thread.h>
|
||||
#include <base/blocking.h>
|
||||
#include <base/env.h>
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
#include <linux_native_cpu/linux_native_cpu.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/socket_descriptor_registry.h>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <base/thread.h>
|
||||
#include <base/snprintf.h>
|
||||
#include <base/sleep.h>
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
#include <linux_native_cpu/client.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/stack.h>
|
||||
@@ -60,9 +60,8 @@ void Thread_base::_thread_start()
|
||||
Thread_base * const thread = Thread_base::myself();
|
||||
|
||||
/* inform core about the new thread and process ID of the new thread */
|
||||
Linux_cpu_session *cpu = dynamic_cast<Linux_cpu_session *>(thread->_cpu_session);
|
||||
if (cpu)
|
||||
cpu->thread_id(thread->cap(), thread->native_thread().pid, thread->native_thread().tid);
|
||||
Linux_native_cpu_client native_cpu(thread->_cpu_session->native_cpu());
|
||||
native_cpu.thread_id(thread->cap(), thread->native_thread().pid, thread->native_thread().tid);
|
||||
|
||||
/* wakeup 'start' function */
|
||||
startup_lock().unlock();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* \brief Linux-specific extension of the CPU session implementation
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-09
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <cpu_session_component.h>
|
||||
|
||||
/* Linux includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Cpu_session_component::thread_id(Thread_capability thread_cap, int pid, int tid)
|
||||
{
|
||||
_thread_ep->apply(thread_cap, [&] (Cpu_thread_component *thread) {
|
||||
if (thread) thread->platform_thread()->thread_id(pid, tid); });
|
||||
}
|
||||
|
||||
|
||||
Untyped_capability Cpu_session_component::server_sd(Thread_capability thread_cap)
|
||||
{
|
||||
auto lambda = [] (Cpu_thread_component *thread) {
|
||||
if (!thread) return Untyped_capability();
|
||||
|
||||
enum { DUMMY_LOCAL_NAME = 0 };
|
||||
typedef Native_capability::Dst Dst;
|
||||
return Untyped_capability(Dst(thread->platform_thread()->server_sd()),
|
||||
DUMMY_LOCAL_NAME);
|
||||
};
|
||||
return _thread_ep->apply(thread_cap, lambda);
|
||||
}
|
||||
|
||||
|
||||
Untyped_capability Cpu_session_component::client_sd(Thread_capability thread_cap)
|
||||
{
|
||||
auto lambda = [] (Cpu_thread_component *thread) {
|
||||
if (!thread) return Untyped_capability();
|
||||
|
||||
enum { DUMMY_LOCAL_NAME = 0 };
|
||||
typedef Native_capability::Dst Dst;
|
||||
return Untyped_capability(Dst(thread->platform_thread()->client_sd()),
|
||||
DUMMY_LOCAL_NAME);
|
||||
};
|
||||
return _thread_ep->apply(thread_cap, lambda);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* \brief Platform-specific parts of cores CPU-service
|
||||
* \author Martin Stein
|
||||
* \date 2012-04-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2009-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.
|
||||
*/
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/printf.h>
|
||||
|
||||
/* Core includes */
|
||||
#include <cpu_session_component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Ram_dataspace_capability Cpu_session_component::utcb(Thread_capability thread_cap)
|
||||
{
|
||||
PERR("%s: Not implemented", __PRETTY_FUNCTION__);
|
||||
return Ram_dataspace_capability();
|
||||
}
|
||||
|
||||
|
||||
Cpu_session::Quota Cpu_session_component::quota() { return Quota(); }
|
||||
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* \brief Core-specific instance of the CPU session/thread interfaces
|
||||
* \author Christian Helmuth
|
||||
* \author Norman Feske
|
||||
* \date 2006-07-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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 _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_
|
||||
#define _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <util/list.h>
|
||||
#include <base/allocator_guard.h>
|
||||
#include <base/lock.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
|
||||
/* core includes */
|
||||
#include <pager.h>
|
||||
#include <cpu_thread_allocator.h>
|
||||
#include <platform_thread.h>
|
||||
#include <trace/control_area.h>
|
||||
#include <trace/source_registry.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* RPC interface of CPU thread
|
||||
*
|
||||
* We make 'Cpu_thread' a RPC object only to be able to lookup CPU threads
|
||||
* from thread capabilities supplied as arguments to CPU-session functions.
|
||||
* A CPU thread does not provide an actual RPC interface.
|
||||
*/
|
||||
struct Cpu_thread
|
||||
{
|
||||
GENODE_RPC_INTERFACE();
|
||||
};
|
||||
|
||||
|
||||
class Cpu_thread_component : public Rpc_object<Cpu_thread>,
|
||||
public List<Cpu_thread_component>::Element,
|
||||
public Trace::Source::Info_accessor
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Trace::Session_label Session_label;
|
||||
typedef Trace::Thread_name Thread_name;
|
||||
|
||||
private:
|
||||
|
||||
Session_label const _session_label;
|
||||
Thread_name const _name;
|
||||
Platform_thread _platform_thread;
|
||||
bool _bound; /* pd binding flag */
|
||||
Signal_context_capability _sigh; /* exception handler */
|
||||
unsigned const _trace_control_index;
|
||||
Trace::Source _trace_source;
|
||||
|
||||
public:
|
||||
|
||||
Cpu_thread_component(size_t const weight,
|
||||
size_t const quota,
|
||||
Session_label const &label,
|
||||
Thread_name const &name,
|
||||
unsigned priority, addr_t utcb,
|
||||
Signal_context_capability sigh,
|
||||
unsigned trace_control_index,
|
||||
Trace::Control &trace_control)
|
||||
:
|
||||
_session_label(label), _name(name),
|
||||
_platform_thread(name.string(), priority, utcb), _bound(false),
|
||||
_sigh(sigh), _trace_control_index(trace_control_index),
|
||||
_trace_source(*this, trace_control)
|
||||
{
|
||||
update_exception_sigh();
|
||||
}
|
||||
|
||||
|
||||
/********************************************
|
||||
** Trace::Source::Info_accessor interface **
|
||||
********************************************/
|
||||
|
||||
Trace::Source::Info trace_source_info() const
|
||||
{
|
||||
return { _session_label, _name,
|
||||
_platform_thread.execution_time(),
|
||||
_platform_thread.affinity() };
|
||||
}
|
||||
|
||||
|
||||
/************************
|
||||
** Accessor functions **
|
||||
************************/
|
||||
|
||||
Platform_thread *platform_thread() { return &_platform_thread; }
|
||||
bool bound() const { return _bound; }
|
||||
void bound(bool b) { _bound = b; }
|
||||
Trace::Source *trace_source() { return &_trace_source; }
|
||||
|
||||
size_t weight() const { return Cpu_session::DEFAULT_WEIGHT; }
|
||||
|
||||
void sigh(Signal_context_capability sigh)
|
||||
{
|
||||
_sigh = sigh;
|
||||
update_exception_sigh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Propagate exception handler to platform thread
|
||||
*/
|
||||
void update_exception_sigh();
|
||||
|
||||
/**
|
||||
* Return index within the CPU-session's trace control area
|
||||
*/
|
||||
unsigned trace_control_index() const { return _trace_control_index; }
|
||||
};
|
||||
|
||||
|
||||
class Cpu_session_component : public Rpc_object<Linux_cpu_session>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Cpu_thread_component::Session_label Session_label;
|
||||
|
||||
private:
|
||||
|
||||
Session_label _label;
|
||||
Rpc_entrypoint *_session_ep;
|
||||
Rpc_entrypoint *_thread_ep;
|
||||
Pager_entrypoint *_pager_ep;
|
||||
Allocator_guard _md_alloc; /* guarded meta-data allocator */
|
||||
Cpu_thread_allocator _thread_alloc; /* meta-data allocator */
|
||||
Lock _thread_alloc_lock; /* protect allocator access */
|
||||
List<Cpu_thread_component> _thread_list;
|
||||
Lock _thread_list_lock; /* protect thread list */
|
||||
unsigned _priority; /* priority of threads
|
||||
created with this
|
||||
session */
|
||||
Affinity::Location _location; /* CPU affinity of this
|
||||
session */
|
||||
Trace::Source_registry &_trace_sources;
|
||||
Trace::Control_area _trace_control_area;
|
||||
|
||||
size_t _weight;
|
||||
size_t _quota;
|
||||
Cpu_session_component * _ref;
|
||||
List<Cpu_session_component> _ref_members;
|
||||
Lock _ref_members_lock;
|
||||
|
||||
void _incr_weight(size_t);
|
||||
void _decr_weight(size_t);
|
||||
size_t _weight_to_quota(size_t) const;
|
||||
void _decr_quota(size_t);
|
||||
void _incr_quota(size_t);
|
||||
void _update_thread_quota(Cpu_thread_component *) const;
|
||||
void _update_each_thread_quota();
|
||||
void _transfer_quota(Cpu_session_component *, size_t);
|
||||
void _insert_ref_member(Cpu_session_component *) { }
|
||||
void _unsync_remove_ref_member(Cpu_session_component *) { }
|
||||
void _remove_ref_member(Cpu_session_component *) { }
|
||||
void _deinit_ref_account();
|
||||
void _deinit_threads();
|
||||
|
||||
/**
|
||||
* Exception handler that will be invoked unless overridden by a
|
||||
* call of 'Cpu_session::exception_handler'.
|
||||
*/
|
||||
Signal_context_capability _default_exception_handler;
|
||||
|
||||
/**
|
||||
* Raw thread-killing functionality
|
||||
*
|
||||
* This function is called from the 'kill_thread' function and
|
||||
* the destructor. Each these functions grab the list lock
|
||||
* by themselves and call this function to perform the actual
|
||||
* killing.
|
||||
*/
|
||||
void _unsynchronized_kill_thread(Thread_capability cap);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Cpu_session_component(Rpc_entrypoint *session_ep,
|
||||
Rpc_entrypoint *thread_ep,
|
||||
Pager_entrypoint *pager_ep,
|
||||
Allocator *md_alloc,
|
||||
Trace::Source_registry &trace_sources,
|
||||
const char *args, Affinity const &affinity,
|
||||
size_t quota);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Cpu_session_component();
|
||||
|
||||
/**
|
||||
* Register quota donation at allocator guard
|
||||
*/
|
||||
void upgrade_ram_quota(size_t ram_quota) { _md_alloc.upgrade(ram_quota); }
|
||||
|
||||
|
||||
/***************************
|
||||
** CPU session interface **
|
||||
***************************/
|
||||
|
||||
Thread_capability create_thread(size_t, Name const &, addr_t);
|
||||
Ram_dataspace_capability utcb(Thread_capability thread);
|
||||
void kill_thread(Thread_capability);
|
||||
int set_pager(Thread_capability, Pager_capability);
|
||||
int start(Thread_capability, addr_t, addr_t);
|
||||
void pause(Thread_capability thread_cap);
|
||||
void resume(Thread_capability thread_cap);
|
||||
void cancel_blocking(Thread_capability);
|
||||
int name(Thread_capability, char *, size_t);
|
||||
Thread_state state(Thread_capability);
|
||||
void state(Thread_capability, Thread_state const &);
|
||||
void exception_handler(Thread_capability, Signal_context_capability);
|
||||
Affinity::Space affinity_space() const;
|
||||
void affinity(Thread_capability, Affinity::Location);
|
||||
Dataspace_capability trace_control();
|
||||
unsigned trace_control_index(Thread_capability);
|
||||
Dataspace_capability trace_buffer(Thread_capability);
|
||||
Dataspace_capability trace_policy(Thread_capability);
|
||||
int ref_account(Cpu_session_capability c);
|
||||
int transfer_quota(Cpu_session_capability, size_t);
|
||||
Quota quota() override;
|
||||
|
||||
|
||||
/*******************************
|
||||
** Linux-specific extensions **
|
||||
*******************************/
|
||||
|
||||
void thread_id(Thread_capability, int, int);
|
||||
Untyped_capability server_sd(Thread_capability);
|
||||
Untyped_capability client_sd(Thread_capability);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */
|
||||
47
repos/base-linux/src/core/include/native_cpu_component.h
Normal file
47
repos/base-linux/src/core/include/native_cpu_component.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* \brief Kernel-specific part of the CPU-session interface
|
||||
* \author Norman Feske
|
||||
* \date 2016-01-19
|
||||
*
|
||||
* This definition is used on platforms with no kernel-specific PD functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 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.
|
||||
*/
|
||||
|
||||
#ifndef _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_
|
||||
#define _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <linux_native_cpu/linux_native_cpu.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
class Cpu_session_component;
|
||||
class Native_cpu_component;
|
||||
}
|
||||
|
||||
|
||||
class Genode::Native_cpu_component : public Rpc_object<Linux_native_cpu,
|
||||
Native_cpu_component>
|
||||
{
|
||||
private:
|
||||
|
||||
Cpu_session_component &_cpu_session;
|
||||
Rpc_entrypoint &_thread_ep;
|
||||
|
||||
public:
|
||||
|
||||
Native_cpu_component(Cpu_session_component &, char const *);
|
||||
~Native_cpu_component();
|
||||
|
||||
void thread_id(Thread_capability, int, int) override;
|
||||
Untyped_capability server_sd(Thread_capability) override;
|
||||
Untyped_capability client_sd(Thread_capability) override;
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_ */
|
||||
@@ -81,7 +81,7 @@ namespace Genode {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Platform_thread(const char *name, unsigned priority, addr_t);
|
||||
Platform_thread(size_t, const char *name, unsigned priority, addr_t);
|
||||
|
||||
~Platform_thread();
|
||||
|
||||
@@ -95,6 +95,11 @@ namespace Genode {
|
||||
*/
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Enable/disable single stepping
|
||||
*/
|
||||
void single_step(bool) { }
|
||||
|
||||
/**
|
||||
* Resume this thread
|
||||
*/
|
||||
|
||||
68
repos/base-linux/src/core/native_cpu_component.cc
Normal file
68
repos/base-linux/src/core/native_cpu_component.cc
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* \brief Core implementation of the CPU session interface
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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.
|
||||
*/
|
||||
|
||||
/* core-local includes */
|
||||
#include <cpu_session_component.h>
|
||||
#include <native_cpu_component.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
void Native_cpu_component::thread_id(Thread_capability thread_cap, int pid, int tid)
|
||||
{
|
||||
_thread_ep.apply(thread_cap, [&] (Cpu_thread_component *thread) {
|
||||
if (thread) thread->platform_thread()->thread_id(pid, tid); });
|
||||
}
|
||||
|
||||
|
||||
Untyped_capability Native_cpu_component::server_sd(Thread_capability thread_cap)
|
||||
{
|
||||
auto lambda = [] (Cpu_thread_component *thread) {
|
||||
if (!thread) return Untyped_capability();
|
||||
|
||||
enum { DUMMY_LOCAL_NAME = 0 };
|
||||
typedef Native_capability::Dst Dst;
|
||||
return Untyped_capability(Dst(thread->platform_thread()->server_sd()),
|
||||
DUMMY_LOCAL_NAME);
|
||||
};
|
||||
return _thread_ep.apply(thread_cap, lambda);
|
||||
}
|
||||
|
||||
|
||||
Untyped_capability Native_cpu_component::client_sd(Thread_capability thread_cap)
|
||||
{
|
||||
auto lambda = [] (Cpu_thread_component *thread) {
|
||||
if (!thread) return Untyped_capability();
|
||||
|
||||
enum { DUMMY_LOCAL_NAME = 0 };
|
||||
typedef Native_capability::Dst Dst;
|
||||
return Untyped_capability(Dst(thread->platform_thread()->client_sd()),
|
||||
DUMMY_LOCAL_NAME);
|
||||
};
|
||||
return _thread_ep.apply(thread_cap, lambda);
|
||||
}
|
||||
|
||||
|
||||
Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_session, char const *)
|
||||
:
|
||||
_cpu_session(cpu_session), _thread_ep(*_cpu_session._thread_ep)
|
||||
{
|
||||
_thread_ep.manage(this);
|
||||
}
|
||||
|
||||
|
||||
Native_cpu_component::~Native_cpu_component()
|
||||
{
|
||||
_thread_ep.dissolve(this);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ Platform_thread::Registry *Platform_thread::_registry()
|
||||
** Platform_thread **
|
||||
*********************/
|
||||
|
||||
Platform_thread::Platform_thread(const char *name, unsigned, addr_t)
|
||||
Platform_thread::Platform_thread(size_t, const char *name, unsigned, addr_t)
|
||||
: _tid(-1), _pid(-1)
|
||||
{
|
||||
strncpy(_name, name, min(sizeof(_name), strlen(name) + 1));
|
||||
|
||||
@@ -12,12 +12,12 @@ SRC_CC = main.cc \
|
||||
ram_session_support.cc \
|
||||
rom_session_component.cc \
|
||||
cpu_session_component.cc \
|
||||
cpu_session_extension.cc \
|
||||
cpu_session_support.cc \
|
||||
pd_session_component.cc \
|
||||
pd_upgrade_ram_quota.cc \
|
||||
dataspace_component.cc \
|
||||
native_pd_component.cc \
|
||||
native_cpu_component.cc \
|
||||
rpc_cap_factory.cc \
|
||||
core_rpc_cap_alloc.cc \
|
||||
io_mem_session_component.cc \
|
||||
@@ -41,6 +41,7 @@ include $(GEN_CORE_DIR)/version.inc
|
||||
vpath main.cc $(GEN_CORE_DIR)
|
||||
vpath ram_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath cpu_session_component.cc $(GEN_CORE_DIR)
|
||||
vpath cpu_session_support.cc $(GEN_CORE_DIR)
|
||||
vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)
|
||||
vpath rpc_cap_factory.cc $(GEN_CORE_DIR)
|
||||
vpath platform_services.cc $(GEN_CORE_DIR)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
/* Genode includes */
|
||||
#include <util/misc_math.h>
|
||||
#include <base/heap.h>
|
||||
#include <linux_cpu_session/client.h>
|
||||
#include <linux_native_cpu/client.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/local_capability.h>
|
||||
@@ -39,15 +39,15 @@ namespace Genode {
|
||||
|
||||
struct Genode::Expanding_cpu_session_client
|
||||
:
|
||||
Upgradeable_client<Genode::Linux_cpu_session_client>
|
||||
Upgradeable_client<Genode::Cpu_session_client>
|
||||
{
|
||||
Expanding_cpu_session_client(Genode::Capability<Linux_cpu_session> cap)
|
||||
: Upgradeable_client<Genode::Linux_cpu_session_client>(cap) { }
|
||||
Expanding_cpu_session_client(Genode::Capability<Cpu_session> cap)
|
||||
: Upgradeable_client<Genode::Cpu_session_client>(cap) { }
|
||||
|
||||
Thread_capability create_thread(size_t weight, Name const &name, addr_t utcb)
|
||||
{
|
||||
return retry<Cpu_session::Out_of_metadata>(
|
||||
[&] () { return Linux_cpu_session_client::create_thread(weight, name, utcb); },
|
||||
[&] () { return Cpu_session_client::create_thread(weight, name, utcb); },
|
||||
[&] () { upgrade_ram(8*1024); });
|
||||
}
|
||||
};
|
||||
@@ -334,7 +334,7 @@ namespace Genode {
|
||||
_ram_session_cap(ram_cap),
|
||||
_ram_session_client(_ram_session_cap),
|
||||
_cpu_session_cap(cpu_cap),
|
||||
_cpu_session_client(static_cap_cast<Linux_cpu_session>(cpu_cap)),
|
||||
_cpu_session_client(cpu_cap),
|
||||
_rm_session_mmap(false),
|
||||
_pd_session_cap(pd_cap),
|
||||
_pd_session_client(_pd_session_cap)
|
||||
@@ -348,7 +348,7 @@ namespace Genode {
|
||||
Ram_session *ram_session() override { return &_ram_session_client; }
|
||||
Ram_session_capability ram_session_cap() override { return _ram_session_cap; }
|
||||
Rm_session *rm_session() override { return &_rm_session_mmap; }
|
||||
Linux_cpu_session *cpu_session() override { return &_cpu_session_client; }
|
||||
Cpu_session *cpu_session() override { return &_cpu_session_client; }
|
||||
Cpu_session_capability cpu_session_cap() override { return _cpu_session_cap; }
|
||||
Pd_session *pd_session() override { return &_pd_session_client; }
|
||||
Pd_session_capability pd_session_cap() override { return _pd_session_cap; }
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* \brief Client-side CPU session interface
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-09
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__LINUX_CPU_SESSION__CLIENT_H_
|
||||
#define _INCLUDE__LINUX_CPU_SESSION__CLIENT_H_
|
||||
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
#include <base/rpc_client.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Linux_cpu_session_client : Rpc_client<Linux_cpu_session>
|
||||
{
|
||||
explicit Linux_cpu_session_client(Capability<Linux_cpu_session> session)
|
||||
: Rpc_client<Linux_cpu_session>(session) { }
|
||||
|
||||
Thread_capability create_thread(size_t weight, Name const &name, addr_t utcb = 0) {
|
||||
return call<Rpc_create_thread>(weight, name, utcb); }
|
||||
|
||||
Ram_dataspace_capability utcb(Thread_capability thread) {
|
||||
return call<Rpc_utcb>(thread); }
|
||||
|
||||
void kill_thread(Thread_capability thread) {
|
||||
call<Rpc_kill_thread>(thread); }
|
||||
|
||||
int set_pager(Thread_capability thread, Pager_capability pager) {
|
||||
return call<Rpc_set_pager>(thread, pager); }
|
||||
|
||||
int start(Thread_capability thread, addr_t ip, addr_t sp) {
|
||||
return call<Rpc_start>(thread, ip, sp); }
|
||||
|
||||
void pause(Thread_capability thread) {
|
||||
call<Rpc_pause>(thread); }
|
||||
|
||||
void resume(Thread_capability thread) {
|
||||
call<Rpc_resume>(thread); }
|
||||
|
||||
void cancel_blocking(Thread_capability thread) {
|
||||
call<Rpc_cancel_blocking>(thread); }
|
||||
|
||||
Thread_state state(Thread_capability thread) {
|
||||
return call<Rpc_get_state>(thread); }
|
||||
|
||||
void state(Thread_capability thread, Thread_state const &state) {
|
||||
call<Rpc_set_state>(thread, state); }
|
||||
|
||||
void exception_handler(Thread_capability thread, Signal_context_capability handler) {
|
||||
call<Rpc_exception_handler>(thread, handler); }
|
||||
|
||||
void single_step(Thread_capability thread, bool enable) {
|
||||
call<Rpc_single_step>(thread, enable); }
|
||||
|
||||
Affinity::Space affinity_space() const {
|
||||
return call<Rpc_affinity_space>(); }
|
||||
|
||||
void affinity(Thread_capability thread, Affinity::Location location) {
|
||||
call<Rpc_affinity>(thread, location); }
|
||||
|
||||
Dataspace_capability trace_control() {
|
||||
return call<Rpc_trace_control>(); }
|
||||
|
||||
unsigned trace_control_index(Thread_capability thread) {
|
||||
return call<Rpc_trace_control_index>(thread); }
|
||||
|
||||
Dataspace_capability trace_buffer(Thread_capability thread) {
|
||||
return call<Rpc_trace_buffer>(thread); }
|
||||
|
||||
Dataspace_capability trace_policy(Thread_capability thread) {
|
||||
return call<Rpc_trace_policy>(thread); }
|
||||
|
||||
int ref_account(Cpu_session_capability session) {
|
||||
return call<Rpc_ref_account>(session); }
|
||||
|
||||
int transfer_quota(Cpu_session_capability session, size_t amount) {
|
||||
return call<Rpc_transfer_quota>(session, amount); }
|
||||
|
||||
Quota quota() override { return call<Rpc_quota>(); }
|
||||
|
||||
/*****************************
|
||||
* Linux-specific extension **
|
||||
*****************************/
|
||||
|
||||
void thread_id(Thread_capability thread, int pid, int tid) {
|
||||
call<Rpc_thread_id>(thread, pid, tid); }
|
||||
|
||||
Untyped_capability server_sd(Thread_capability thread) {
|
||||
return call<Rpc_server_sd>(thread); }
|
||||
|
||||
Untyped_capability client_sd(Thread_capability thread) {
|
||||
return call<Rpc_client_sd>(thread); }
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__LINUX_CPU_SESSION__CLIENT_H_ */
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* \brief Linux-specific extension of the CPU session interface
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-09
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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__LINUX_CPU_SESSION__LINUX_CPU_SESSION_H_
|
||||
#define _INCLUDE__LINUX_CPU_SESSION__LINUX_CPU_SESSION_H_
|
||||
|
||||
#include <cpu_session/cpu_session.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
struct Linux_cpu_session : Cpu_session
|
||||
{
|
||||
virtual ~Linux_cpu_session() { }
|
||||
|
||||
/**
|
||||
* Register Linux PID and TID of the specified thread
|
||||
*/
|
||||
virtual void thread_id(Thread_capability, int pid, int tid) = 0;
|
||||
|
||||
/*
|
||||
* If a thread plays the role of an entrypoint, core creates a bound
|
||||
* socket pair for the thread and passes both makes the socket
|
||||
* descriptors of both ends available to the owner of the thread's
|
||||
* CPU session via the 'server_sd' and 'client_sd' function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Request server-side socket descriptor
|
||||
*
|
||||
* The socket descriptor returned by this function is meant to be used
|
||||
* exclusively by the server for receiving incoming requests. It should
|
||||
* never leave the server process.
|
||||
*/
|
||||
virtual Untyped_capability server_sd(Thread_capability thread) = 0;
|
||||
|
||||
/**
|
||||
* Request client-side socket descriptor
|
||||
*
|
||||
* The returned socket descriptor enables a client to send messages to
|
||||
* the thread. It is already connected to the 'server_sd' descriptor.
|
||||
* In contrast to 'server_sd', the 'client_sd' is expected to be passed
|
||||
* around via capability delegations.
|
||||
*/
|
||||
virtual Untyped_capability client_sd(Thread_capability thread) = 0;
|
||||
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
|
||||
GENODE_RPC(Rpc_thread_id, void, thread_id, Thread_capability, int, int);
|
||||
GENODE_RPC(Rpc_server_sd, Untyped_capability, server_sd, Thread_capability);
|
||||
GENODE_RPC(Rpc_client_sd, Untyped_capability, client_sd, Thread_capability);
|
||||
|
||||
GENODE_RPC_INTERFACE_INHERIT(Cpu_session,
|
||||
Rpc_thread_id, Rpc_server_sd, Rpc_client_sd);
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* _INCLUDE__LINUX_CPU_SESSION__LINUX_CPU_SESSION_H_ */
|
||||
37
repos/base-linux/src/include/linux_native_cpu/client.h
Normal file
37
repos/base-linux/src/include/linux_native_cpu/client.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* \brief Client-side of the Linux-specific CPU session interface
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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__LINUX_NATIVE_CPU__CLIENT_H_
|
||||
#define _INCLUDE__LINUX_NATIVE_CPU__CLIENT_H_
|
||||
|
||||
#include <linux_native_cpu/linux_native_cpu.h>
|
||||
#include <base/rpc_client.h>
|
||||
|
||||
namespace Genode { struct Linux_native_cpu_client; }
|
||||
|
||||
struct Genode::Linux_native_cpu_client : Rpc_client<Linux_native_cpu>
|
||||
{
|
||||
explicit Linux_native_cpu_client(Capability<Native_cpu> cap)
|
||||
: Rpc_client<Linux_native_cpu>(static_cap_cast<Linux_native_cpu>(cap)) { }
|
||||
|
||||
void thread_id(Thread_capability thread, int pid, int tid) {
|
||||
call<Rpc_thread_id>(thread, pid, tid); }
|
||||
|
||||
Untyped_capability server_sd(Thread_capability thread) {
|
||||
return call<Rpc_server_sd>(thread); }
|
||||
|
||||
Untyped_capability client_sd(Thread_capability thread) {
|
||||
return call<Rpc_client_sd>(thread); }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__LINUX_NATIVE_CPU__CLIENT_H_ */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* \brief Linux-specific extension of the CPU session interface
|
||||
* \author Norman Feske
|
||||
* \date 2012-08-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2012-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.
|
||||
*/
|
||||
|
||||
#ifndef _INCLUDE__LINUX_NATIVE_CPU__LINUX_NATIVE_CPU_H_
|
||||
#define _INCLUDE__LINUX_NATIVE_CPU__LINUX_NATIVE_CPU_H_
|
||||
|
||||
#include <base/rpc.h>
|
||||
#include <cpu_session/cpu_session.h>
|
||||
|
||||
namespace Genode { struct Linux_native_cpu; }
|
||||
|
||||
|
||||
struct Genode::Linux_native_cpu : Cpu_session::Native_cpu
|
||||
{
|
||||
/**
|
||||
* Register Linux PID and TID of the specified thread
|
||||
*/
|
||||
virtual void thread_id(Thread_capability, int pid, int tid) = 0;
|
||||
|
||||
/*
|
||||
* If a thread plays the role of an entrypoint, core creates a bound
|
||||
* socket pair for the thread and passes both makes the socket
|
||||
* descriptors of both ends available to the owner of the thread's
|
||||
* CPU session via the 'server_sd' and 'client_sd' function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Request server-side socket descriptor
|
||||
*
|
||||
* The socket descriptor returned by this function is meant to be used
|
||||
* exclusively by the server for receiving incoming requests. It should
|
||||
* never leave the server process.
|
||||
*/
|
||||
virtual Untyped_capability server_sd(Thread_capability thread) = 0;
|
||||
|
||||
/**
|
||||
* Request client-side socket descriptor
|
||||
*
|
||||
* The returned socket descriptor enables a client to send messages to
|
||||
* the thread. It is already connected to the 'server_sd' descriptor.
|
||||
* In contrast to 'server_sd', the 'client_sd' is expected to be passed
|
||||
* around via capability delegations.
|
||||
*/
|
||||
virtual Untyped_capability client_sd(Thread_capability thread) = 0;
|
||||
|
||||
|
||||
/*********************
|
||||
** RPC declaration **
|
||||
*********************/
|
||||
|
||||
GENODE_RPC(Rpc_thread_id, void, thread_id, Thread_capability, int, int);
|
||||
GENODE_RPC(Rpc_server_sd, Untyped_capability, server_sd, Thread_capability);
|
||||
GENODE_RPC(Rpc_client_sd, Untyped_capability, client_sd, Thread_capability);
|
||||
|
||||
GENODE_RPC_INTERFACE(Rpc_thread_id, Rpc_server_sd, Rpc_client_sd);
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__LINUX_NATIVE_CPU__LINUX_NATIVE_CPU_H_ */
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <base/printf.h>
|
||||
#include <base/component.h>
|
||||
#include <linux_syscalls.h>
|
||||
#include <linux_cpu_session/linux_cpu_session.h>
|
||||
#include <linux_native_cpu/client.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/native_thread.h>
|
||||
@@ -336,23 +336,6 @@ namespace Genode {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return Linux-specific extension of the Env::CPU session interface
|
||||
*/
|
||||
Linux_cpu_session *cpu_session(Cpu_session * cpu_session)
|
||||
{
|
||||
Linux_cpu_session *cpu = dynamic_cast<Linux_cpu_session *>(cpu_session);
|
||||
|
||||
if (!cpu) {
|
||||
PERR("could not obtain Linux extension to CPU session interface");
|
||||
struct Could_not_access_linux_cpu_session { };
|
||||
throw Could_not_access_linux_cpu_session();
|
||||
}
|
||||
|
||||
return cpu;
|
||||
}
|
||||
|
||||
|
||||
static void adopt_thread(Native_thread::Meta_data *meta_data)
|
||||
{
|
||||
lx_sigaltstack(signal_stack, sizeof(signal_stack));
|
||||
@@ -487,10 +470,10 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
|
||||
|
||||
native_thread().meta_data->wait_for_construction();
|
||||
|
||||
Linux_cpu_session *cpu = cpu_session(_cpu_session);
|
||||
_thread_cap = _cpu_session->create_thread(weight, name);
|
||||
|
||||
_thread_cap = cpu->create_thread(weight, name);
|
||||
cpu->thread_id(_thread_cap, native_thread().pid, native_thread().tid);
|
||||
Linux_native_cpu_client native_cpu(_cpu_session->native_cpu());
|
||||
native_cpu.thread_id(_thread_cap, native_thread().pid, native_thread().tid);
|
||||
}
|
||||
|
||||
|
||||
@@ -526,5 +509,5 @@ Thread_base::~Thread_base()
|
||||
_native_thread = nullptr;
|
||||
|
||||
/* inform core about the killed thread */
|
||||
cpu_session(_cpu_session)->kill_thread(_thread_cap);
|
||||
_cpu_session->kill_thread(_thread_cap);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user