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
@@ -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_ */
|
||||
@@ -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_ */
|
||||
@@ -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_ */
|
||||
39
repos/base-foc/include/foc_native_cpu/client.h
Normal file
39
repos/base-foc/include/foc_native_cpu/client.h
Normal 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_ */
|
||||
42
repos/base-foc/include/foc_native_cpu/foc_native_cpu.h
Normal file
42
repos/base-foc/include/foc_native_cpu/foc_native_cpu.h
Normal 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_ */
|
||||
@@ -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_ */
|
||||
66
repos/base-foc/src/core/include/cpu_session_irqs.h
Normal file
66
repos/base-foc/src/core/include/cpu_session_irqs.h
Normal 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_ */
|
||||
48
repos/base-foc/src/core/include/native_cpu_component.h
Normal file
48
repos/base-foc/src/core/include/native_cpu_component.h
Normal 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_ */
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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),
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user