nova: remove native_cpu interface

Issue #2173
This commit is contained in:
Alexander Boettcher 2016-12-01 13:26:14 +01:00 committed by Norman Feske
parent e93ef168a1
commit f613cd2aa9
12 changed files with 25 additions and 479 deletions

View File

@ -1,32 +0,0 @@
/*
* \brief Client-side NOVA-specific CPU session interface
* \author Norman Feske
* \date 2016-04-21
*/
/*
* 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 _INCLUDE__NOVA_NATIVE_CPU__CLIENT_H_
#define _INCLUDE__NOVA_NATIVE_CPU__CLIENT_H_
#include <nova_native_cpu/nova_native_cpu.h>
#include <base/rpc_client.h>
namespace Genode { struct Nova_native_cpu_client; }
struct Genode::Nova_native_cpu_client : Rpc_client<Nova_native_cpu>
{
explicit Nova_native_cpu_client(Capability<Native_cpu> cap)
: Rpc_client<Nova_native_cpu>(static_cap_cast<Nova_native_cpu>(cap)) { }
Native_capability pager_cap(Thread_capability cap) {
return call<Rpc_pager_cap>(cap); }
};
#endif /* _INCLUDE__NOVA_NATIVE_CPU__CLIENT_H_ */

View File

@ -1,36 +0,0 @@
/*
* \brief NOVA-specific part of the CPU session interface
* \author Norman Feske
* \date 2016-04-21
*/
/*
* 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 _INCLUDE__NOVA_NATIVE_CPU__FOC_NATIVE_CPU_H_
#define _INCLUDE__NOVA_NATIVE_CPU__FOC_NATIVE_CPU_H_
#include <base/rpc.h>
#include <cpu_session/cpu_session.h>
namespace Genode { struct Nova_native_cpu; }
struct Genode::Nova_native_cpu : Cpu_session::Native_cpu
{
virtual Native_capability pager_cap(Thread_capability) = 0;
/*********************
** RPC declaration **
*********************/
GENODE_RPC(Rpc_pager_cap, Native_capability, pager_cap, Thread_capability);
GENODE_RPC_INTERFACE(Rpc_pager_cap);
};
#endif /* _INCLUDE__NOVA_NATIVE_CPU__FOC_NATIVE_CPU_H_ */

View File

@ -24,7 +24,6 @@ SRC_CC += stack_area.cc \
pager.cc \
pd_session_component.cc \
native_pd_component.cc \
native_cpu_component.cc \
pd_upgrade_ram_quota.cc \
pd_assign_pci.cc \
rpc_cap_factory.cc \

View File

@ -1,151 +0,0 @@
/*
* \brief Core-specific instance of the CPU session/thread interfaces
* \author Christian Helmuth
* \author Norman Feske
* \author Alexander Boettcher
* \date 2006-07-17
*/
/*
* Copyright (C) 2006-2016 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#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 <base/session_label.h>
/* core includes */
#include <pager.h>
#include <cpu_thread_component.h>
#include <cpu_thread_allocator.h>
#include <pd_session_component.h>
#include <platform_thread.h>
#include <trace/control_area.h>
#include <trace/source_registry.h>
#include <native_cpu_component.h>
namespace Genode { class Cpu_session_component; }
class Genode::Cpu_session_component : public Rpc_object<Cpu_session>
{
private:
Session_label const _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;
/*
* Members for quota accounting
*/
size_t _weight;
size_t _quota;
Cpu_session_component * _ref;
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;
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 to be invoked unless overridden by a
* thread-specific handler via 'Cpu_thread::exception_sigh'
*/
Signal_context_capability _exception_sigh;
/**
* 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);
/**
* Convert session-local affinity location to physical location
*/
Affinity::Location _thread_affinity(Affinity::Location) const;
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(Capability<Pd_session>, Name const &,
Affinity::Location, Weight, addr_t) override;
void kill_thread(Thread_capability) override;
void exception_sigh(Signal_context_capability) override;
Affinity::Space affinity_space() const override;
Dataspace_capability trace_control() override;
int ref_account(Cpu_session_capability c) override;
int transfer_quota(Cpu_session_capability, size_t) override;
Quota quota() override;
Capability<Native_cpu> native_cpu() { return _native_cpu.cap(); }
};
#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */

View File

@ -1,44 +0,0 @@
/*
* \brief Kernel-specific part of the CPU-session interface
* \author Norman Feske
* \date 2016-04-21
*/
/*
* 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 <nova_native_cpu/nova_native_cpu.h>
namespace Genode {
class Cpu_session_component;
class Native_cpu_component;
}
class Genode::Native_cpu_component : public Rpc_object<Nova_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();
Native_capability pager_cap(Thread_capability) override;
};
#endif /* _CORE__INCLUDE__NATIVE_CPU_COMPONENT_H_ */

View File

@ -1,48 +0,0 @@
/*
* \brief Core implementation of the CPU session interface extension
* \author Norman Feske
* \date 2016-04-21
*/
/*
* 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.
*/
/* Genode includes */
#include <base/stdint.h>
/* core-local includes */
#include <native_cpu_component.h>
#include <cpu_session_component.h>
using namespace Genode;
Native_capability
Native_cpu_component::pager_cap(Thread_capability thread_cap)
{
auto lambda = [] (Cpu_thread_component *thread) {
if (!thread)
return Native_capability();
return thread->platform_thread().pager()->cap();
};
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);
}
Genode::Native_cpu_component::~Native_cpu_component()
{
_thread_ep.dissolve(this);
}

View File

@ -1,83 +0,0 @@
/*
* \brief NOVA-specific 'Native_cpu' setup
* \author Christian Prochaska
* \date 2016-05-13
*/
/*
* 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.
*/
/* Genode includes */
#include <nova_native_cpu/client.h>
/* Cpu_sampler includes */
#include "cpu_session_component.h"
#include "cpu_thread_component.h"
namespace Cpu_sampler {
class Native_cpu_component;
}
using namespace Genode;
class Cpu_sampler::Native_cpu_component : public Rpc_object<Nova_native_cpu,
Native_cpu_component>
{
private:
Cpu_session_component &_cpu_session_component;
Nova_native_cpu_client _nova_native_cpu;
public:
Native_cpu_component(Cpu_session_component &cpu_session_component)
: _cpu_session_component(cpu_session_component),
_nova_native_cpu(_cpu_session_component.parent_cpu_session().native_cpu())
{
_cpu_session_component.thread_ep().manage(this);
}
~Native_cpu_component()
{
_cpu_session_component.thread_ep().dissolve(this);
}
Native_capability pager_cap(Thread_capability thread_cap) override
{
auto lambda = [&] (Cpu_sampler::Cpu_thread_component *cpu_thread) {
return _nova_native_cpu.pager_cap(cpu_thread->parent_thread());
};
return _cpu_session_component.thread_ep().apply(thread_cap, lambda);
}
};
Capability<Cpu_session::Native_cpu>
Cpu_sampler::Cpu_session_component::_setup_native_cpu()
{
Native_cpu_component *native_cpu_component =
new (_md_alloc) Native_cpu_component(*this);
return native_cpu_component->cap();
}
void Cpu_sampler::Cpu_session_component::_cleanup_native_cpu()
{
Native_cpu_component *native_cpu_component = nullptr;
_thread_ep.apply(_native_cpu_cap,
[&] (Native_cpu_component *c) { native_cpu_component = c; });
if (!native_cpu_component) return;
destroy(_md_alloc, native_cpu_component);
}

View File

@ -2,6 +2,6 @@ REQUIRES += nova
SRC_CC += native_cpu.cc
vpath native_cpu.cc $(PRG_DIR)
vpath native_cpu.cc $(PRG_DIR)/../..
include $(PRG_DIR)/../../target.inc

View File

@ -1,4 +1,3 @@
SRC_CC = spec/nova_x86_32/low.cc \
spec/nova/native_cpu.cc
SRC_CC = spec/nova_x86_32/low.cc native_cpu.cc
include $(REP_DIR)/lib/mk/spec/x86_32/gdbserver_platform.inc

View File

@ -1,4 +1,3 @@
SRC_CC = spec/nova_x86_64/low.cc \
spec/nova/native_cpu.cc
SRC_CC = spec/nova_x86_64/low.cc native_cpu.cc
include $(REP_DIR)/lib/mk/spec/x86_64/gdbserver_platform.inc

View File

@ -0,0 +1,22 @@
/*
* \brief Generic dummy 'Native_cpu' setup
* \author Christian Prochaska
* \date 2016-05-13
*/
/*
* 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.
*/
/* GDB monitor includes */
#include "cpu_session_component.h"
Genode::Capability<Genode::Cpu_session::Native_cpu>
Gdb_monitor::Cpu_session_component::_setup_native_cpu() {
return Genode::Capability<Genode::Cpu_session::Native_cpu>(); }
void Gdb_monitor::Cpu_session_component::_cleanup_native_cpu() { }

View File

@ -1,79 +0,0 @@
/*
* \brief NOVA-specific 'Native_cpu' setup
* \author Christian Prochaska
* \date 2016-05-13
*/
/*
* 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.
*/
/* Genode includes */
#include <nova_native_cpu/client.h>
/* GDB monitor includes */
#include "cpu_session_component.h"
#include "cpu_thread_component.h"
namespace Gdb_monitor {
class Native_cpu_component;
}
using namespace Genode;
class Gdb_monitor::Native_cpu_component : public Rpc_object<Nova_native_cpu,
Native_cpu_component>
{
private:
Cpu_session_component &_cpu_session_component;
Nova_native_cpu_client _nova_native_cpu;
public:
Native_cpu_component(Cpu_session_component &cpu_session_component)
: _cpu_session_component(cpu_session_component),
_nova_native_cpu(_cpu_session_component.parent_cpu_session().native_cpu())
{
_cpu_session_component.thread_ep().manage(this);
}
~Native_cpu_component()
{
_cpu_session_component.thread_ep().dissolve(this);
}
Native_capability pager_cap(Thread_capability thread_cap) override
{
Cpu_thread_component *cpu_thread = _cpu_session_component.lookup_cpu_thread(thread_cap);
return _nova_native_cpu.pager_cap(cpu_thread->parent_thread_cap());
}
};
Capability<Cpu_session::Native_cpu>
Gdb_monitor::Cpu_session_component::_setup_native_cpu()
{
Native_cpu_component *native_cpu_component =
new (_md_alloc) Native_cpu_component(*this);
return native_cpu_component->cap();
}
void Gdb_monitor::Cpu_session_component::_cleanup_native_cpu()
{
Native_cpu_component *native_cpu_component = nullptr;
_ep.apply(_native_cpu_cap, [&] (Native_cpu_component *c) { native_cpu_component = c; });
if (!native_cpu_component) return;
destroy(_md_alloc, native_cpu_component);
}