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:
Norman Feske 2016-03-30 15:34:37 +02:00 committed by Christian Helmuth
parent e9dec93f4b
commit 0c299c5e08
63 changed files with 668 additions and 1207 deletions

View File

@ -77,6 +77,11 @@ namespace Genode {
*/
void pause();
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/

View File

@ -50,6 +50,7 @@ vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cap_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath rpc_cap_factory.cc $(GEN_CORE_DIR)
vpath core_rpc_cap_alloc.cc $(GEN_CORE_DIR)

View File

@ -1,108 +0,0 @@
/*
* \brief Client-side cpu session Fiasco.OC extension
* \author Stefan Kalkowski
* \date 2011-04-04
*/
/*
* 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__FOC_CPU_SESSION__CLIENT_H_
#define _INCLUDE__FOC_CPU_SESSION__CLIENT_H_
#include <cpu_session/client.h>
#include <foc_cpu_session/foc_cpu_session.h>
#include <base/printf.h>
namespace Genode {
struct Foc_cpu_session_client : Rpc_client<Foc_cpu_session>
{
explicit Foc_cpu_session_client(Cpu_session_capability session)
: Rpc_client<Foc_cpu_session>(static_cap_cast<Foc_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); }
int name(Thread_capability thread, char *name_dst, size_t name_len)
{
PWRN("name called, this function is deprecated");
return -1;
}
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); }
void enable_vcpu(Thread_capability cap, addr_t vcpu_state) {
call<Rpc_enable_vcpu>(cap, vcpu_state); }
Native_capability native_cap(Thread_capability cap) {
return call<Rpc_native_cap>(cap); }
Native_capability alloc_irq() {
return call<Rpc_alloc_irq>(); }
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>(); }
};
}
#endif /* _INCLUDE__FOC_CPU_SESSION__CLIENT_H_ */

View File

@ -1,41 +0,0 @@
/*
* \brief Connection to Fiasco.OC specific cpu service
* \author Stefan Kalkowski
* \date 2011-04-04
*/
/*
* 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__FOC_CPU_SESSION__CONNECTION_H_
#define _INCLUDE__FOC_CPU_SESSION__CONNECTION_H_
#include <foc_cpu_session/client.h>
#include <base/connection.h>
namespace Genode {
struct Foc_cpu_connection : Connection<Cpu_session>, Foc_cpu_session_client
{
/**
* Constructor
*
* \param label initial session label
* \param priority designated priority of all threads created
* with this CPU session
*/
Foc_cpu_connection(const char *label = "",
long priority = DEFAULT_PRIORITY)
:
Connection<Cpu_session>(
session("priority=0x%lx, ram_quota=32K, label=\"%s\"",
priority, label)),
Foc_cpu_session_client(cap()) { }
};
}
#endif /* _INCLUDE__FOC_CPU_SESSION__CONNECTION_H_ */

View File

@ -1,46 +0,0 @@
/*
* \brief Cpu session interface extension for Fiasco.OC
* \author Stefan Kalkowski
* \date 2011-04-04
*/
/*
* 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__FOC_CPU_SESSION__FOC_CPU_SESSION_H_
#define _INCLUDE__FOC_CPU_SESSION__FOC_CPU_SESSION_H_
#include <base/stdint.h>
#include <cpu_session/cpu_session.h>
namespace Genode {
struct Foc_cpu_session : Cpu_session
{
virtual ~Foc_cpu_session() { }
virtual void enable_vcpu(Thread_capability cap, addr_t vcpu_state) = 0;
virtual Native_capability native_cap(Thread_capability cap) = 0;
virtual Native_capability alloc_irq() = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_enable_vcpu, void, enable_vcpu, Thread_capability, addr_t);
GENODE_RPC(Rpc_native_cap, Native_capability, native_cap, Thread_capability);
GENODE_RPC(Rpc_alloc_irq, Native_capability, alloc_irq);
GENODE_RPC_INTERFACE_INHERIT(Cpu_session,
Rpc_enable_vcpu, Rpc_native_cap, Rpc_alloc_irq);
};
}
#endif /* _INCLUDE__FOC_CPU_SESSION__FOC_CPU_SESSION_H_ */

View File

@ -0,0 +1,39 @@
/*
* \brief Client-side Fiasco.OC specific CPU session interface
* \author Stefan Kalkowski
* \author Norman Feske
* \date 2011-04-14
*/
/*
* 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__FOC_NATIVE_CPU__CLIENT_H_
#define _INCLUDE__FOC_NATIVE_CPU__CLIENT_H_
#include <foc_native_cpu/foc_native_cpu.h>
#include <base/rpc_client.h>
namespace Genode { struct Foc_native_cpu_client; }
struct Genode::Foc_native_cpu_client : Rpc_client<Foc_native_cpu>
{
explicit Foc_native_cpu_client(Capability<Native_cpu> cap)
: Rpc_client<Foc_native_cpu>(static_cap_cast<Foc_native_cpu>(cap)) { }
void enable_vcpu(Thread_capability cap, addr_t vcpu_state) {
call<Rpc_enable_vcpu>(cap, vcpu_state); }
Native_capability native_cap(Thread_capability cap) {
return call<Rpc_native_cap>(cap); }
Native_capability alloc_irq() {
return call<Rpc_alloc_irq>(); }
};
#endif /* _INCLUDE__FOC_NATIVE_CPU__CLIENT_H_ */

View File

@ -0,0 +1,42 @@
/*
* \brief Fiasco.OC-specific part of the CPU session interface
* \author Stefan Kalkowski
* \author Norman Feske
* \date 2011-04-14
*/
/*
* 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.
*/
#ifndef _INCLUDE__FOC_NATIVE_CPU__FOC_NATIVE_CPU_H_
#define _INCLUDE__FOC_NATIVE_CPU__FOC_NATIVE_CPU_H_
#include <base/rpc.h>
#include <cpu_session/cpu_session.h>
namespace Genode { struct Foc_native_cpu; }
struct Genode::Foc_native_cpu : Cpu_session::Native_cpu
{
virtual void enable_vcpu(Thread_capability cap, addr_t vcpu_state) = 0;
virtual Native_capability native_cap(Thread_capability cap) = 0;
virtual Native_capability alloc_irq() = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_enable_vcpu, void, enable_vcpu, Thread_capability, addr_t);
GENODE_RPC(Rpc_native_cap, Native_capability, native_cap, Thread_capability);
GENODE_RPC(Rpc_alloc_irq, Native_capability, alloc_irq);
GENODE_RPC_INTERFACE(Rpc_enable_vcpu, Rpc_native_cap, Rpc_alloc_irq);
};
#endif /* _INCLUDE__FOC_NATIVE_CPU__FOC_NATIVE_CPU_H_ */

View File

@ -1,298 +0,0 @@
/*
* \brief Core-specific instance of the CPU session/thread interfaces
* \author Christian Helmuth
* \author Norman Feske
* \author Stefan Kalkowski
* \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/tslab.h>
#include <base/lock.h>
#include <base/rpc_server.h>
#include <foc_cpu_session/foc_cpu_session.h>
/* core includes */
#include <pager.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<Foc_cpu_session>
{
public:
typedef Cpu_thread_component::Session_label Session_label;
private:
/**
* Allocator used for managing the CPU threads associated with the
* CPU session
*/
typedef Tslab<Cpu_thread_component, 1024> Cpu_thread_allocator;
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);
Thread_capability first();
Thread_capability next(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 single_step(Thread_capability thread_cap, bool enable);
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;
/***********************************
** Fiasco.OC specific extensions **
***********************************/
void enable_vcpu(Thread_capability, addr_t);
Native_capability native_cap(Thread_capability);
Native_capability alloc_irq();
};
class Cpu_session_irqs : public Avl_node<Cpu_session_irqs>
{
private:
enum { IRQ_MAX = 20 };
Cpu_session_component* _owner;
Native_capability _irqs[IRQ_MAX];
unsigned _cnt;
public:
Cpu_session_irqs(Cpu_session_component *owner)
: _owner(owner), _cnt(0) {}
bool add(Native_capability irq)
{
if (_cnt >= (IRQ_MAX - 1))
return false;
_irqs[_cnt++] = irq;
return true;
}
/************************
** Avl node interface **
************************/
bool higher(Cpu_session_irqs *c) { return (c->_owner > _owner); }
Cpu_session_irqs *find_by_session(Cpu_session_component *o)
{
if (o == _owner) return this;
Cpu_session_irqs *c = Avl_node<Cpu_session_irqs>::child(o > _owner);
return c ? c->find_by_session(o) : 0;
}
};
}
#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */

View File

@ -0,0 +1,66 @@
/*
* \brief Fiasco.OC-specific implementation of core's CPU service
* \author Christian Helmuth
* \author Norman Feske
* \author Stefan Kalkowski
* \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_IRQS_H_
#define _CORE__INCLUDE__CPU_SESSION_IRQS_H_
/* Genode includes */
#include <util/avl_tree.h>
/* core includes */
#include <cpu_session_component.h>
namespace Genode { class Cpu_session_irqs; }
class Genode::Cpu_session_irqs : public Avl_node<Cpu_session_irqs>
{
private:
enum { IRQ_MAX = 20 };
Cpu_session_component* _owner;
Native_capability _irqs[IRQ_MAX];
unsigned _cnt;
public:
Cpu_session_irqs(Cpu_session_component *owner)
: _owner(owner), _cnt(0) {}
bool add(Native_capability irq)
{
if (_cnt >= (IRQ_MAX - 1))
return false;
_irqs[_cnt++] = irq;
return true;
}
/************************
** Avl node interface **
************************/
bool higher(Cpu_session_irqs *c) { return (c->_owner > _owner); }
Cpu_session_irqs *find_by_session(Cpu_session_component *o)
{
if (o == _owner) return this;
Cpu_session_irqs *c = Avl_node<Cpu_session_irqs>::child(o > _owner);
return c ? c->find_by_session(o) : 0;
}
};
#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */

View File

@ -0,0 +1,48 @@
/*
* \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 <base/rpc_server.h>
#include <foc_native_cpu/foc_native_cpu.h>
namespace Genode {
class Cpu_session_component;
class Native_cpu_component;
}
class Genode::Native_cpu_component : public Rpc_object<Foc_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 enable_vcpu(Thread_capability, addr_t) override;
Native_capability native_cap(Thread_capability) override;
Native_capability alloc_irq() override;
};
#endif /* _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_ */

View File

@ -64,7 +64,7 @@ namespace Genode {
/**
* Constructor for non-core threads
*/
Platform_thread(const char *name, unsigned priority, addr_t);
Platform_thread(size_t, const char *name, unsigned priority, addr_t);
/**
* Constructor for core main-thread
@ -98,6 +98,11 @@ namespace Genode {
*/
void pause();
/**
* Enable/disable single stepping
*/
void single_step(bool);
/**
* Resume this thread
*/

View File

@ -14,8 +14,9 @@
/* Genode includes */
#include <base/printf.h>
/* Core includes */
#include <cpu_session_component.h>
/* core includes */
#include <native_cpu_component.h>
#include <cpu_session_irqs.h>
#include <platform.h>
/* Fiasco.OC includes */
@ -26,15 +27,9 @@ namespace Fiasco {
static Genode::Avl_tree<Genode::Cpu_session_irqs> _irq_tree;
Genode::Ram_dataspace_capability Genode::Cpu_session_component::utcb(Genode::Thread_capability thread_cap)
{
using namespace Genode;
PERR("%s: Not implemented", __PRETTY_FUNCTION__);
return Ram_dataspace_capability();
}
void Genode::Cpu_session_component::enable_vcpu(Genode::Thread_capability thread_cap,
void Genode::Native_cpu_component::enable_vcpu(Genode::Thread_capability thread_cap,
Genode::addr_t vcpu_state)
{
using namespace Genode;
@ -49,12 +44,12 @@ void Genode::Cpu_session_component::enable_vcpu(Genode::Thread_capability thread
if (l4_msgtag_has_error(tag))
PWRN("l4_thread_vcpu_control failed");
};
_thread_ep->apply(thread_cap, lambda);
_thread_ep.apply(thread_cap, lambda);
}
Genode::Native_capability
Genode::Cpu_session_component::native_cap(Genode::Thread_capability cap)
Genode::Native_cpu_component::native_cap(Genode::Thread_capability cap)
{
using namespace Genode;
@ -62,11 +57,11 @@ Genode::Cpu_session_component::native_cap(Genode::Thread_capability cap)
return (!thread) ? Native_capability()
: thread->platform_thread()->thread().local;
};
return _thread_ep->apply(cap, lambda);
return _thread_ep.apply(cap, lambda);
}
Genode::Native_capability Genode::Cpu_session_component::alloc_irq()
Genode::Native_capability Genode::Native_cpu_component::alloc_irq()
{
using namespace Fiasco;
using namespace Genode;
@ -74,11 +69,11 @@ Genode::Native_capability Genode::Cpu_session_component::alloc_irq()
/* find irq object container of this cpu-session */
Cpu_session_irqs* node = _irq_tree.first();
if (node)
node = node->find_by_session(this);
node = node->find_by_session(&_cpu_session);
/* if not found, we've to create one */
if (!node) {
node = new (&_md_alloc) Cpu_session_irqs(this);
node = new (&_cpu_session._md_alloc) Cpu_session_irqs(&_cpu_session);
_irq_tree.insert(node);
}
@ -96,22 +91,15 @@ Genode::Native_capability Genode::Cpu_session_component::alloc_irq()
}
void Genode::Cpu_session_component::single_step(Genode::Thread_capability thread_cap, bool enable)
Genode::Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_session, char const *)
:
_cpu_session(cpu_session), _thread_ep(*_cpu_session._thread_ep)
{
using namespace Genode;
auto lambda = [&] (Cpu_thread_component *thread) {
if (!thread) return;
Fiasco::l4_cap_idx_t tid = thread->platform_thread()->thread().local.dst();
enum { THREAD_SINGLE_STEP = 0x40000 };
int flags = enable ? THREAD_SINGLE_STEP : 0;
Fiasco::l4_thread_ex_regs(tid, ~0UL, ~0UL, flags);
};
_thread_ep->apply(thread_cap, lambda);
_thread_ep.manage(this);
}
Genode::Cpu_session::Quota Genode::Cpu_session_component::quota() { return Quota(); }
Genode::Native_cpu_component::~Native_cpu_component()
{
_thread_ep.dissolve(this);
}

View File

@ -116,6 +116,17 @@ void Platform_thread::pause()
}
void Platform_thread::single_step(bool enabled)
{
Fiasco::l4_cap_idx_t const tid = thread().local.dst();
enum { THREAD_SINGLE_STEP = 0x40000 };
int const flags = enabled ? THREAD_SINGLE_STEP : 0;
Fiasco::l4_thread_ex_regs(tid, ~0UL, ~0UL, flags);
}
void Platform_thread::resume()
{
if (!_pager_obj)
@ -268,7 +279,7 @@ Weak_ptr<Address_space> Platform_thread::address_space()
}
Platform_thread::Platform_thread(const char *name, unsigned prio, addr_t)
Platform_thread::Platform_thread(size_t, const char *name, unsigned prio, addr_t)
: _state(DEAD),
_core_thread(false),
_thread(true),

View File

@ -9,7 +9,7 @@ SRC_CC += stack_area.cc \
core_printf.cc \
core_rpc_cap_alloc.cc \
cpu_session_component.cc \
cpu_session_extension.cc \
cpu_session_support.cc \
dataspace_component.cc \
dump_alloc.cc \
io_mem_session_component.cc \
@ -24,6 +24,7 @@ SRC_CC += stack_area.cc \
pd_assign_pci.cc \
pd_upgrade_ram_quota.cc \
native_pd_component.cc \
native_cpu_component.cc \
rpc_cap_factory.cc \
platform.cc \
platform_pd.cc \
@ -47,6 +48,7 @@ include $(GEN_CORE_DIR)/version.inc
vpath stack_area.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath dataspace_component.cc $(GEN_CORE_DIR)
vpath dump_alloc.cc $(GEN_CORE_DIR)
vpath io_mem_session_component.cc $(GEN_CORE_DIR)

View File

@ -134,6 +134,11 @@ namespace Genode {
*/
void pause() { Kernel::pause_thread(kernel_object()); }
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/

View File

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

View File

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

View File

@ -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();

View File

@ -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);
}

View File

@ -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(); }

View File

@ -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_ */

View 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_ */

View File

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

View 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);
}

View File

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

View File

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

View File

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

View File

@ -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_ */

View File

@ -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_ */

View 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_ */

View File

@ -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_ */

View File

@ -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);
}

View File

@ -102,6 +102,8 @@ namespace Genode {
Quota quota() override { return call<Rpc_quota>(); }
Capability<Native_cpu> native_cpu() override { return call<Rpc_native_cpu>(); }
private:
Native_capability pause_sync(Thread_capability) {

View File

@ -42,10 +42,7 @@ Cpu_session_component::single_step_sync(Thread_capability thread_cap, bool enabl
if (!thread || !thread->platform_thread())
return Native_capability();
return thread->platform_thread()->single_step(enable);
return thread->platform_thread()->single_step_sync(enable);
};
return _thread_ep->apply(thread_cap, lambda);
}
void Cpu_session_component::single_step(Thread_capability, bool) { return; }

View File

@ -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(); }

View File

@ -29,6 +29,7 @@
#include <platform_thread.h>
#include <trace/control_area.h>
#include <trace/source_registry.h>
#include <native_cpu_component.h>
namespace Genode {
@ -166,6 +167,10 @@ namespace Genode {
List<Cpu_session_component> _ref_members;
Lock _ref_members_lock;
Native_cpu_component _native_cpu;
friend class Native_cpu_component;
void _incr_weight(size_t);
void _decr_weight(size_t);
size_t _weight_to_quota(size_t) const;
@ -246,6 +251,7 @@ namespace Genode {
int ref_account(Cpu_session_capability c);
int transfer_quota(Cpu_session_capability, size_t);
Quota quota() override;
Capability<Native_cpu> native_cpu() { return Capability<Native_cpu>(); }
/******************************

View File

@ -93,6 +93,11 @@ namespace Genode {
*/
Native_capability pause();
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/
@ -167,7 +172,7 @@ namespace Genode {
if (main_thread) _features |= MAIN_THREAD;
}
Native_capability single_step(bool on);
Native_capability single_step_sync(bool on);
/**
* Set CPU quota of the thread to 'quota'

View File

@ -303,7 +303,7 @@ void Platform_thread::cancel_blocking()
}
Native_capability Platform_thread::single_step(bool on)
Native_capability Platform_thread::single_step_sync(bool on)
{
if (!_pager) return Native_capability();

View File

@ -50,6 +50,7 @@ vpath main.cc $(GEN_CORE_DIR)
vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)
vpath rm_session_component.cc $(GEN_CORE_DIR)

View File

@ -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(); }

View File

@ -74,6 +74,11 @@ namespace Genode {
*/
void pause();
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/

View File

@ -46,6 +46,7 @@ vpath main.cc $(GEN_CORE_DIR)
vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)
vpath pd_assign_pci.cc $(GEN_CORE_DIR)

View File

@ -90,6 +90,11 @@ namespace Genode {
*/
void pause();
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/

View File

@ -46,6 +46,7 @@ vpath main.cc $(GEN_CORE_DIR)
vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath rpc_cap_factory.cc $(GEN_CORE_DIR)
vpath pd_assign_pci.cc $(GEN_CORE_DIR)

View File

@ -46,6 +46,7 @@ vpath main.cc $(GEN_CORE_DIR)
vpath ram_session_component.cc $(GEN_CORE_DIR)
vpath rom_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_component.cc $(GEN_CORE_DIR)
vpath cpu_session_support.cc $(GEN_CORE_DIR)
vpath pd_session_component.cc $(GEN_CORE_DIR)
vpath pd_assign_pci.cc $(GEN_CORE_DIR)
vpath pd_upgrade_ram_quota.cc $(GEN_CORE_DIR)

View File

@ -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)
{
PDBG("not implemented");
return Ram_dataspace_capability();
}
Cpu_session::Quota Cpu_session_component::quota() { return Quota(); }

View File

@ -97,6 +97,11 @@ class Genode::Platform_thread : public List<Platform_thread>::Element
*/
void pause();
/**
* Enable/disable single stepping
*/
void single_step(bool) { }
/**
* Resume this thread
*/

View File

@ -87,6 +87,8 @@ struct Genode::Cpu_session_client : Rpc_client<Cpu_session>
return call<Rpc_transfer_quota>(session, amount); }
Quota quota() override { return call<Rpc_quota>(); }
Capability<Native_cpu> native_cpu() override { return call<Rpc_native_cpu>(); }
};
#endif /* _INCLUDE__CPU_SESSION__CLIENT_H_ */

View File

@ -299,6 +299,22 @@ struct Genode::Cpu_session : Session
static size_t quota_lim_downscale(size_t const value, size_t const limit) {
return ((T)value * limit) >> Cpu_session::QUOTA_LIMIT_LOG2; }
/*****************************************
** Access to kernel-specific interface **
*****************************************/
/**
* Common base class of kernel-specific CPU interfaces
*/
struct Native_cpu { };
/**
* Return capability to kernel-specific CPU operations
*/
virtual Capability<Native_cpu> native_cpu() = 0;
/*********************
** RPC declaration **
*********************/
@ -331,6 +347,7 @@ struct Genode::Cpu_session : Session
GENODE_RPC(Rpc_ref_account, int, ref_account, Cpu_session_capability);
GENODE_RPC(Rpc_transfer_quota, int, transfer_quota, Cpu_session_capability, size_t);
GENODE_RPC(Rpc_quota, Quota, quota);
GENODE_RPC(Rpc_native_cpu, Capability<Native_cpu>, native_cpu);
/*
* 'GENODE_RPC_INTERFACE' declaration done manually
@ -361,8 +378,9 @@ struct Genode::Cpu_session : Session
Meta::Type_tuple<Rpc_ref_account,
Meta::Type_tuple<Rpc_transfer_quota,
Meta::Type_tuple<Rpc_quota,
Meta::Type_tuple<Rpc_native_cpu,
Meta::Empty>
> > > > > > > > > > > > > > > > > > > > Rpc_functions;
> > > > > > > > > > > > > > > > > > > > > Rpc_functions;
};
struct Genode::Cpu_session::Quota

View File

@ -166,6 +166,17 @@ void Cpu_session_component::pause(Thread_capability thread_cap)
}
void Cpu_session_component::single_step(Thread_capability thread_cap, bool enabled)
{
auto lambda = [this, enabled] (Cpu_thread_component *thread) {
if (!thread) return;
thread->platform_thread()->single_step(enabled);
};
_thread_ep->apply(thread_cap, lambda);
}
void Cpu_session_component::resume(Thread_capability thread_cap)
{
auto lambda = [this] (Cpu_thread_component *thread) {
@ -416,7 +427,8 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint *session_ep,
/* map affinity to a location within the physical affinity space */
_location(affinity.scale_to(platform()->affinity_space())),
_trace_sources(trace_sources), _quota(quota), _ref(0)
_trace_sources(trace_sources), _quota(quota), _ref(0),
_native_cpu(*this, args)
{
/* remember session label */
char buf[Session_label::size()];

View File

@ -1,5 +1,5 @@
/*
* \brief Platform-specific parts of cores CPU-service
* \brief Platform-specific parts of core's CPU-service
* \author Martin Stein
* \date 2012-04-17
*/

View File

@ -27,6 +27,7 @@
#include <platform_thread.h>
#include <trace/control_area.h>
#include <trace/source_registry.h>
#include <native_cpu_component.h>
namespace Genode {
@ -172,24 +173,21 @@ namespace Genode {
List<Cpu_session_component> _ref_members;
Lock _ref_members_lock;
Native_cpu_component _native_cpu;
friend class Native_cpu_component;
/*
* Utilities for quota accounting
*/
void _incr_weight(size_t const weight);
void _decr_weight(size_t const weight);
size_t _weight_to_quota(size_t const weight) const;
void _decr_quota(size_t const quota);
void _incr_quota(size_t const quota);
void _update_thread_quota(Cpu_thread_component *) const;
void _update_each_thread_quota();
void _transfer_quota(Cpu_session_component * const dst,
size_t const quota);
@ -213,7 +211,6 @@ namespace Genode {
}
void _deinit_ref_account();
void _deinit_threads();
/**
@ -267,6 +264,7 @@ namespace Genode {
int start(Thread_capability, addr_t, addr_t);
void pause(Thread_capability thread_cap);
void resume(Thread_capability thread_cap);
void single_step(Thread_capability thread_cap, bool enable);
void cancel_blocking(Thread_capability);
int name(Thread_capability, char *, size_t);
Thread_state state(Thread_capability);
@ -281,6 +279,8 @@ namespace Genode {
int ref_account(Cpu_session_capability c);
int transfer_quota(Cpu_session_capability, size_t);
Quota quota() override;
Capability<Native_cpu> native_cpu() { return _native_cpu.cap(); }
};
}

View File

@ -0,0 +1,42 @@
/*
* \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 <cpu_session/cpu_session.h>
/* core-local includes */
#include <rpc_cap_factory.h>
namespace Genode {
class Cpu_session_component;
class Native_cpu_component;
}
struct Genode::Native_cpu_component
{
Native_cpu_component(Cpu_session_component &, char const *) { }
Capability<Cpu_session::Native_cpu> cap()
{
return Capability<Cpu_session::Native_cpu>();
}
};
#endif /* _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_ */

View File

@ -97,12 +97,20 @@ namespace {
Genode::Signal_context _tx;
char _name[32];
Genode::Native_capability _alloc_irq()
{
Genode::Foc_native_cpu_client
native_cpu(L4lx::cpu_connection()->native_cpu());
return native_cpu.alloc_irq();
}
public:
Block_device(const char *label)
: _alloc(Genode::env()->heap()),
_session(&_alloc, TX_BUF_SIZE, label),
_irq_cap(L4lx::vcpu_connection()->alloc_irq())
_irq_cap(_alloc_irq())
{
_session.info(&_blk_cnt, &_blk_size, &_blk_ops);
Genode::strncpy(_name, label, sizeof(_name));

View File

@ -149,7 +149,9 @@ extern "C" {
l4_cap_idx_t genode_net_irq_cap()
{
Linux::Irq_guard guard;
static Genode::Native_capability cap = L4lx::vcpu_connection()->alloc_irq();
Genode::Foc_native_cpu_client
native_cpu(L4lx::cpu_connection()->native_cpu());
static Genode::Native_capability cap = native_cpu.alloc_irq();
static Genode::Lock lock(Genode::Lock::LOCKED);
static Signal_thread th(cap.dst(), &lock);
lock.lock();

View File

@ -95,7 +95,11 @@ extern "C" {
l4_cap_idx_t genode_terminal_irq(unsigned idx) {
static Genode::Native_capability cap = L4lx::vcpu_connection()->alloc_irq();
Genode::Foc_native_cpu_client
native_cpu(L4lx::cpu_connection()->native_cpu());
static Genode::Native_capability cap = native_cpu.alloc_irq();
if (!signal_thread)
signal_thread = new (Genode::env()->heap()) Signal_thread(cap.dst());
return cap.dst();

View File

@ -19,7 +19,8 @@
#include <base/sleep.h>
#include <base/thread.h>
#include <base/cap_map.h>
#include <foc_cpu_session/connection.h>
#include <foc_native_cpu/client.h>
#include <cpu_session/client.h>
#include <timer_session/connection.h>
#include <foc/native_thread.h>
@ -29,7 +30,7 @@ namespace Fiasco {
namespace L4lx {
extern Genode::Foc_cpu_session_client *vcpu_connection();
extern Genode::Cpu_session *cpu_connection();
class Vcpu : public Genode::Thread_base
@ -68,8 +69,10 @@ namespace L4lx {
l4_utcb_tcr_u(_utcb)->user[0] = native_thread().kcap;
/* enable vcpu functionality respectively */
if (_vcpu_state)
vcpu_connection()->enable_vcpu(_thread_cap, _vcpu_state);
if (_vcpu_state) {
Genode::Foc_native_cpu_client native_cpu(cpu_connection()->native_cpu());
native_cpu.enable_vcpu(_thread_cap, _vcpu_state);
}
/* set cpu affinity */
set_affinity(_cpu_nr);
@ -94,8 +97,8 @@ namespace L4lx {
void set_affinity(unsigned i)
{
vcpu_connection()->affinity(_thread_cap,
Genode::Affinity::Location(i, 0));
cpu_connection()->affinity(_thread_cap,
Genode::Affinity::Location(i, 0));
}
};

View File

@ -13,7 +13,7 @@
/* Genode includes */
#include <base/printf.h>
#include <foc_cpu_session/connection.h>
#include <cpu_session/connection.h>
#include <env.h>
#include <vcpu.h>
@ -48,12 +48,9 @@ static l4_addr_t utcb_base_addr()
return _addr;
}
Genode::Foc_cpu_session_client* L4lx::vcpu_connection()
Genode::Cpu_session* L4lx::cpu_connection()
{
using namespace Genode;
static Foc_cpu_session_client _client(Genode::env()->cpu_session_cap());
return &_client;
return Genode::env()->cpu_session();
}
@ -102,7 +99,11 @@ void l4lx_thread_alloc_irq(l4_cap_idx_t c)
{
Linux::Irq_guard guard;
Genode::Native_capability cap = L4lx::vcpu_connection()->alloc_irq();
Genode::Foc_native_cpu_client
native_cpu(L4lx::cpu_connection()->native_cpu());
Genode::Native_capability cap = native_cpu.alloc_irq();
l4_task_map(L4_BASE_TASK_CAP, L4_BASE_TASK_CAP,
l4_obj_fpage(cap.dst(), 0, L4_FPAGE_RWX), c | L4_ITEM_MAP);
}

View File

@ -91,7 +91,8 @@ Fiasco::l4_cap_idx_t genode_balloon_irq_cap()
{
Linux::Irq_guard guard;
static Genode::Native_capability cap = L4lx::vcpu_connection()->alloc_irq();
static Genode::Foc_native_cpu_client native_cpu(L4lx::cpu_connection()->native_cpu());
static Genode::Native_capability cap = native_cpu.alloc_irq();
static Genode::Lock lock(Genode::Lock::LOCKED);
static Signal_thread th(cap.dst(), &lock);
lock.lock();

View File

@ -17,9 +17,10 @@
#include <base/native_types.h>
#include <dataspace/client.h>
#include <rom_session/connection.h>
#include <foc_cpu_session/connection.h>
#include <cpu_session/connection.h>
#include <util/misc_math.h>
#include <os/config.h>
#include <foc_native_cpu/client.h>
/* L4lx includes */
#include <env.h>
@ -102,10 +103,13 @@ static void prepare_l4re_env()
{
using namespace Fiasco;
Genode::Foc_cpu_session_client cpu(Genode::env()->cpu_session_cap());
Genode::Cpu_session &cpu = *Genode::env()->cpu_session();
Genode::Foc_native_cpu_client native_cpu(cpu.native_cpu());
Genode::Thread_capability main_thread = Genode::Thread_base::myself()->cap();
static Genode::Native_capability main_thread_cap = cpu.native_cap(main_thread);
static Genode::Native_capability main_thread_cap = native_cpu.native_cap(main_thread);
l4re_env_t *env = l4re_env();
env->first_free_utcb = (l4_addr_t)l4_utcb() + L4_UTCB_OFFSET;

View File

@ -230,6 +230,12 @@ Dataspace_capability Cpu_session_component::trace_policy(Thread_capability threa
}
Capability<Cpu_session::Native_cpu> Cpu_session_component::native_cpu()
{
return _parent_cpu_session.native_cpu();
}
Cpu_session_component::Cpu_session_component(Signal_receiver *exception_signal_receiver, const char *args)
: _parent_cpu_session(env()->parent()->session<Cpu_session>(args)),
_exception_signal_receiver(exception_signal_receiver)

View File

@ -79,6 +79,7 @@ class Cpu_session_component : public Rpc_object<Cpu_session>
int ref_account(Cpu_session_capability c);
int transfer_quota(Cpu_session_capability c, size_t q);
Quota quota() override;
Capability<Native_cpu> native_cpu() override;
};
#endif /* _CPU_SESSION_COMPONENT_H_ */

View File

@ -149,6 +149,9 @@ namespace Noux {
int transfer_quota(Cpu_session_capability c, size_t q) override {
return _cpu.transfer_quota(c, q); }
Capability<Native_cpu> native_cpu() override {
return _cpu.native_cpu(); }
};
}