base/core: use references instead of pointers

This patch replaces the former prominent use of pointers by references
wherever feasible. This has the following benefits:

* The contract between caller and callee becomes more obvious. When
  passing a reference, the contract says that the argument cannot be
  a null pointer. The caller is responsible to ensure that. Therefore,
  the use of reference eliminates the need to add defensive null-pointer
  checks at the callee site, which sometimes merely exist to be on the
  safe side. The bottom line is that the code becomes easier to follow.

* Reference members must be initialized via an object initializer,
  which promotes a programming style that avoids intermediate object-
  construction states. Within core, there are still a few pointers
  as member variables left though. E.g., caused by the late association
  of 'Platform_thread' objects with their 'Platform_pd' objects.

* If no pointers are present as member variables, we don't need to
  manually provide declarations of a private copy constructor and
  an assignment operator to avoid -Weffc++ errors "class ... has
  pointer data members [-Werror=effc++]".

This patch also changes a few system bindings on NOVA and Fiasco.OC,
e.g., the return value of the global 'cap_map' accessor has become a
reference. Hence, the patch touches a few places outside of core.

Fixes #3135
This commit is contained in:
Norman Feske 2019-01-24 22:00:01 +01:00
parent f9373b4430
commit 6b289a1423
242 changed files with 2390 additions and 2434 deletions

View File

@ -40,7 +40,7 @@ namespace Genode {
*/
inline bool map_local(addr_t from_addr, addr_t to_addr, size_t num_pages)
{
Fiasco::l4_threadid_t core_pager = platform_specific()->core_pager()->native_thread_id();
Fiasco::l4_threadid_t core_pager = platform_specific().core_pager().native_thread_id();
addr_t offset = 0;
size_t page_size = get_page_size();

View File

@ -18,11 +18,12 @@
#include <base/allocator_avl.h>
#include <base/internal/capability_space.h>
#include "synced_range_allocator.h"
#include "platform_generic.h"
#include "platform_thread.h"
#include "platform_pd.h"
#include "boot_modules.h"
#include <synced_range_allocator.h>
#include <platform_generic.h>
#include <platform_thread.h>
#include <platform_pd.h>
#include <boot_modules.h>
#include <assertion.h>
namespace Genode {
@ -113,7 +114,7 @@ namespace Genode {
/**
* Return singleton instance of Sigma0 pager object
*/
static Sigma0 *sigma0();
static Sigma0 &sigma0();
/**
* Core pager thread that handles core-internal page-faults
@ -123,7 +124,7 @@ namespace Genode {
/**
* Constructor
*/
Core_pager(Platform_pd *core_pd);
Core_pager(Platform_pd &core_pd);
int pager(Ipc_pager &) { /* never called */ return -1; }
};
@ -131,7 +132,7 @@ namespace Genode {
/**
* Return singleton instance of core pager object
*/
Core_pager *core_pager();
Core_pager &core_pager();
/**
* Constructor
@ -141,22 +142,28 @@ namespace Genode {
/**
* Accessor for core pd object
*/
Platform_pd *core_pd() { return _core_pd; }
Platform_pd &core_pd()
{
if (_core_pd)
return *_core_pd;
ASSERT_NEVER_CALLED;
}
/********************************
** Generic platform interface **
********************************/
Range_allocator *core_mem_alloc() override { return &_ram_alloc; }
Range_allocator *ram_alloc() override { return &_ram_alloc; }
Range_allocator *io_mem_alloc() override { return &_io_mem_alloc; }
Range_allocator *io_port_alloc() override { return &_io_port_alloc; }
Range_allocator *irq_alloc() override { return &_irq_alloc; }
Range_allocator *region_alloc() override { return &_region_alloc; }
Range_allocator &core_mem_alloc() override { return _ram_alloc; }
Range_allocator &ram_alloc() override { return _ram_alloc; }
Range_allocator &io_mem_alloc() override { return _io_mem_alloc; }
Range_allocator &io_port_alloc() override { return _io_port_alloc; }
Range_allocator &irq_alloc() override { return _irq_alloc; }
Range_allocator &region_alloc() override { return _region_alloc; }
addr_t vm_start() const override { return _vm_start; }
size_t vm_size() const override { return _vm_size; }
Rom_fs *rom_fs() override { return &_rom_fs; }
Rom_fs &rom_fs() override { return _rom_fs; }
size_t max_caps() const { return Capability_space::max_caps(); }

View File

@ -74,7 +74,7 @@ namespace Genode {
*
* Again a special case for Core thread0.
*/
int _alloc_thread(int thread_id, Platform_thread *thread);
int _alloc_thread(int thread_id, Platform_thread &thread);
/**
* Thread deallocation
@ -149,8 +149,12 @@ namespace Genode {
/**
* Constructor
*/
Platform_pd(Allocator * md_alloc, char const *,
signed pd_id = PD_INVALID, bool create = true);
Platform_pd(Allocator &md_alloc, char const *name);
/**
* Constructor used for core's PD
*/
Platform_pd(char const *name, signed pd_id);
/**
* Destructor
@ -172,14 +176,14 @@ namespace Genode {
*
* \return true on success
*/
bool bind_thread(Platform_thread *thread);
bool bind_thread(Platform_thread &thread);
/**
* Unbind thread from protection domain
*
* Free the thread's slot and update thread object.
*/
void unbind_thread(Platform_thread *thread);
void unbind_thread(Platform_thread &thread);
/**
* Assign parent interface to protection domain

View File

@ -21,6 +21,7 @@
/* core includes */
#include <pager.h>
#include <platform_pd.h>
#include <assertion.h>
/* Fiasco includes */
namespace Fiasco {
@ -40,14 +41,17 @@ namespace Genode {
Platform_thread(Platform_thread const &);
Platform_thread &operator = (Platform_thread const &);
int _thread_id; /* plain thread number */
Fiasco::l4_threadid_t _l4_thread_id; /* L4 thread ID */
char _name[32]; /* thread name that will be
int _thread_id = THREAD_INVALID; /* plain thread number */
Fiasco::l4_threadid_t _l4_thread_id;
typedef String<32> Name;
Name const _name; /* thread name that will be
registered at the kernel
debugger */
Platform_pd *_platform_pd = nullptr; /* protection domain thread
is bound to */
Pager_object *_pager;
Pager_object *_pager = nullptr;
public:
@ -58,9 +62,13 @@ namespace Genode {
/**
* Constructor
*/
Platform_thread(size_t, const char *name = 0, unsigned priority = 0,
Affinity::Location = Affinity::Location(),
addr_t utcb = 0, int thread_id = THREAD_INVALID);
Platform_thread(size_t, const char *name, unsigned priority,
Affinity::Location, addr_t utcb);
/**
* Constructor used for core-internal threads
*/
Platform_thread(const char *name);
/**
* Destructor
@ -106,7 +114,7 @@ namespace Genode {
* \param pd platform pd, thread is bound to
*/
void bind(int thread_id, Fiasco::l4_threadid_t l4_thread_id,
Platform_pd *pd);
Platform_pd &pd);
/**
* Unbind this thread
@ -146,8 +154,15 @@ namespace Genode {
/**
* Return/set pager
*/
Pager_object *pager() const { return _pager; }
void pager(Pager_object *pager) { _pager = pager; }
Pager_object &pager() const
{
if (_pager)
return *_pager;
ASSERT_NEVER_CALLED;
}
void pager(Pager_object &pager) { _pager = &pager; }
/**
* Return identification of thread when faulting
@ -172,7 +187,7 @@ namespace Genode {
int thread_id() const { return _thread_id; }
Fiasco::l4_threadid_t native_thread_id() const { return _l4_thread_id; }
const char *name() const { return _name; }
Name name() const { return _name; }
};
}

View File

@ -24,7 +24,7 @@ class Genode::Rpc_cap_factory
{
private:
static Native_capability _alloc(Rpc_cap_factory *owner,
static Native_capability _alloc(Rpc_cap_factory &owner,
Native_capability ep);
public:

View File

@ -27,7 +27,7 @@ using namespace Genode;
void Io_mem_session_component::_unmap_local(addr_t base, size_t)
{
platform()->region_alloc()->free(reinterpret_cast<void *>(base));
platform().region_alloc().free(reinterpret_cast<void *>(base));
}
@ -51,7 +51,7 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
/* find appropriate region for mapping */
void *local_base = 0;
if (platform()->region_alloc()->alloc_aligned(size, &local_base, alignment).error())
if (platform().region_alloc().alloc_aligned(size, &local_base, alignment).error())
return 0;
/* call sigma0 for I/O region */

View File

@ -121,7 +121,7 @@ Irq_object::Irq_object(unsigned irq)
{ }
Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
const char *args)
:
_irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
@ -132,7 +132,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
if (msi)
throw Service_denied();
if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) {
if (irq_alloc.alloc_addr(1, _irq_number).error()) {
error("unavailable IRQ ", _irq_number, " requested");
throw Service_denied();
}

View File

@ -140,27 +140,27 @@ Platform::Sigma0::Sigma0()
}
Platform::Sigma0 *Platform::sigma0()
Platform::Sigma0 &Platform::sigma0()
{
static Sigma0 _sigma0;
return &_sigma0;
return _sigma0;
}
Platform::Core_pager::Core_pager(Platform_pd *core_pd)
Platform::Core_pager::Core_pager(Platform_pd &core_pd)
:
Platform_thread(0, "core.pager"),
Platform_thread("core.pager"),
Pager_object(Cpu_session_capability(), Thread_capability(),
0, Affinity::Location(), Session_label(),
Cpu_session::Name(name()))
{
Platform_thread::pager(sigma0());
core_pd->bind_thread(this);
core_pd.bind_thread(*this);
cap(Capability_space::import(native_thread_id(), Rpc_obj_key()));
/* pager needs to know core's pd ID */
_core_pager_arg = core_pd->pd_id();
_core_pager_arg = core_pd.pd_id();
/* stack begins at the top end of the '_core_pager_stack' array */
void *sp = (void *)&_core_pager_stack[PAGER_STACK_ELEMENTS - 1];
@ -176,10 +176,10 @@ Platform::Core_pager::Core_pager(Platform_pd *core_pd)
}
Platform::Core_pager *Platform::core_pager()
Platform::Core_pager &Platform::core_pager()
{
static Core_pager _core_pager(core_pd());
return &_core_pager;
return _core_pager;
}
@ -412,9 +412,9 @@ void Platform::_setup_basics()
Platform::Platform() :
_ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()),
_io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()),
_region_alloc(core_mem_alloc()),
_ram_alloc(nullptr), _io_mem_alloc(&core_mem_alloc()),
_io_port_alloc(&core_mem_alloc()), _irq_alloc(&core_mem_alloc()),
_region_alloc(&core_mem_alloc()),
_kip_rom((addr_t)get_kip(), L4_PAGESIZE, "l4v2_kip")
{
/*
@ -438,20 +438,21 @@ Platform::Platform() :
/* setup pd object for core pd */
_core_label[0] = 0;
_core_pd = new(core_mem_alloc()) Platform_pd(nullptr, _core_label,
myself.id.task, false);
_core_pd = new (core_mem_alloc()) Platform_pd(_core_label, myself.id.task);
/*
* We setup the thread object for thread0 in core pd using a special
* interface that allows us to specify the lthread number.
*/
Platform_thread *core_thread = new(core_mem_alloc())
Platform_thread(0, "core.main", myself.id.lthread);
core_thread->pager(sigma0());
Platform_thread &core_thread = *new (core_mem_alloc())
Platform_thread("core.main");
core_thread.pager(sigma0());
_core_pd->bind_thread(core_thread);
/* we never call _core_thread.start(), so set name directly */
Fiasco::fiasco_register_thread_name(core_thread->native_thread_id(), core_thread->name());
Fiasco::fiasco_register_thread_name(core_thread.native_thread_id(),
core_thread.name().string());
/* core log as ROM module */
{
@ -459,14 +460,14 @@ Platform::Platform() :
unsigned const pages = 1;
size_t const log_size = pages << get_page_size_log2();
ram_alloc()->alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
ram_alloc().alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
void * const core_local_ptr = phys_ptr;
void * const core_local_ptr = phys_ptr;
addr_t const core_local_addr = phys_addr;
/* let one page free after the log buffer */
region_alloc()->remove_range(core_local_addr, log_size + get_page_size());
region_alloc().remove_range(core_local_addr, log_size + get_page_size());
memset(core_local_ptr, 0, log_size);

View File

@ -162,7 +162,7 @@ Platform_thread* Platform_pd::_next_thread()
}
int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread)
int Platform_pd::_alloc_thread(int thread_id, Platform_thread &thread)
{
int i = thread_id;
@ -177,7 +177,7 @@ int Platform_pd::_alloc_thread(int thread_id, Platform_thread *thread)
if (_threads[i]) return -2;
}
_threads[i] = thread;
_threads[i] = &thread;
return i;
}
@ -196,10 +196,10 @@ void Platform_pd::_free_thread(int thread_id)
** Public object members **
***************************/
bool Platform_pd::bind_thread(Platform_thread *thread)
bool Platform_pd::bind_thread(Platform_thread &thread)
{
/* thread_id is THREAD_INVALID by default - only core is the special case */
int thread_id = thread->thread_id();
int thread_id = thread.thread_id();
l4_threadid_t l4_thread_id;
int t = _alloc_thread(thread_id, thread);
@ -213,18 +213,18 @@ bool Platform_pd::bind_thread(Platform_thread *thread)
l4_thread_id.id.lthread = thread_id;
/* finally inform thread about binding */
thread->bind(thread_id, l4_thread_id, this);
thread.bind(thread_id, l4_thread_id, *this);
return true;
}
void Platform_pd::unbind_thread(Platform_thread *thread)
void Platform_pd::unbind_thread(Platform_thread &thread)
{
int thread_id = thread->thread_id();
int thread_id = thread.thread_id();
/* unbind thread before proceeding */
thread->unbind();
thread.unbind();
_free_thread(thread_id);
}
@ -246,7 +246,25 @@ void Platform_pd::flush(addr_t, size_t size, Core_local_addr core_local_base)
L4_FP_FLUSH_PAGE);
}
Platform_pd::Platform_pd(Allocator *, char const *, signed pd_id, bool create)
Platform_pd::Platform_pd(Allocator &, char const *)
{
/* check correct init */
if (!_init)
panic("init pd facility via Platform_pd::init() before using it!");
/* init threads */
_init_threads();
int ret = _alloc_pd(PD_INVALID);
if (ret < 0) {
panic("pd alloc failed");
}
_create_pd(true);
}
Platform_pd::Platform_pd(char const *, signed pd_id)
{
/* check correct init */
if (!_init)
@ -260,14 +278,14 @@ Platform_pd::Platform_pd(Allocator *, char const *, signed pd_id, bool create)
panic("pd alloc failed");
}
_create_pd(create);
_create_pd(false);
}
Platform_pd::~Platform_pd()
{
/* unbind all threads */
while (Platform_thread *t = _next_thread()) unbind_thread(t);
while (Platform_thread *t = _next_thread()) unbind_thread(*t);
_destroy_pd();
_free_pd();

View File

@ -55,7 +55,7 @@ int Platform_thread::start(void *ip, void *sp)
warning("old eflags == ~0 on ex_regs ",
Hex(thread.id.task), ".", Hex(thread.id.lthread));
fiasco_register_thread_name(thread, _name);
fiasco_register_thread_name(thread, _name.string());
return 0;
}
@ -72,11 +72,11 @@ void Platform_thread::resume()
}
void Platform_thread::bind(int thread_id, l4_threadid_t l4_thread_id, Platform_pd *pd)
void Platform_thread::bind(int thread_id, l4_threadid_t l4_thread_id, Platform_pd &pd)
{
_thread_id = thread_id;
_l4_thread_id = l4_thread_id;
_platform_pd = pd;
_platform_pd = &pd;
}
@ -154,12 +154,12 @@ void Platform_thread::cancel_blocking()
Platform_thread::Platform_thread(size_t, const char *name, unsigned,
Affinity::Location, addr_t,
int thread_id)
: _thread_id(thread_id), _l4_thread_id(L4_INVALID_ID), _pager(0)
{
strncpy(_name, name, sizeof(_name));
}
Affinity::Location, addr_t)
: _l4_thread_id(L4_INVALID_ID), _name(name) { }
Platform_thread::Platform_thread(const char *name)
: _l4_thread_id(L4_INVALID_ID), _name(name) { }
Platform_thread::~Platform_thread()
@ -169,5 +169,5 @@ Platform_thread::~Platform_thread()
* Thread::unbind()
*/
if (_platform_pd)
_platform_pd->unbind_thread(this);
_platform_pd->unbind_thread(*this);
}

View File

@ -18,10 +18,10 @@
using namespace Genode;
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_clear_ds(Dataspace_component *ds)
void Ram_dataspace_factory::_clear_ds(Dataspace_component &ds)
{
memset((void *)ds->phys_addr(), 0, ds->size());
memset((void *)ds.phys_addr(), 0, ds.size());
}

View File

@ -37,12 +37,12 @@ void Thread::_thread_start()
void Thread::start()
{
/* create and start platform thread */
native_thread().pt = new(platform()->core_mem_alloc())
Platform_thread(0, _stack->name().string());
native_thread().pt = new (platform().core_mem_alloc())
Platform_thread(_stack->name().string());
platform_specific()->core_pd()->bind_thread(native_thread().pt);
platform_specific().core_pd().bind_thread(*native_thread().pt);
native_thread().pt->pager(platform_specific()->core_pager());
native_thread().pt->pager(platform_specific().core_pager());
native_thread().l4id = native_thread().pt->native_thread_id();
native_thread().pt->start((void *)_thread_start, stack_top());
@ -60,5 +60,5 @@ void Thread::cancel_blocking()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), native_thread().pt);
destroy(platform().core_mem_alloc(), native_thread().pt);
}

View File

@ -42,7 +42,7 @@ namespace Genode {
class Out_of_ids : Exception {};
Cap_id_allocator(Allocator*);
Cap_id_allocator(Allocator &);
unsigned long alloc();
void free(unsigned long id);

View File

@ -36,7 +36,7 @@ namespace Genode {
*
* \return pointer to newly constructed Core_cap_index object
*/
inline Core_cap_index* _get_cap();
inline Core_cap_index *_get_cap();
public:

View File

@ -1,72 +0,0 @@
/*
* \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-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#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:
/*
* Noncopyable
*/
Cpu_session_irqs(Cpu_session_irqs const &);
Cpu_session_irqs &operator = (Cpu_session_irqs const &);
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

@ -202,13 +202,13 @@ class Genode::Ipc_pager : public Native_capability
* Copy the exception registers from the last exception
* to the given Thread_state object.
*/
void get_regs(Foc_thread_state *state);
void get_regs(Foc_thread_state &state) const;
/*
* Copy the exception reply registers from the given
* Thread_state object
*/
void set_regs(Foc_thread_state state);
void set_regs(Foc_thread_state const &state);
};
#endif /* _CORE__INCLUDE__IPC_PAGER_H_ */

View File

@ -26,6 +26,7 @@
#include <platform_generic.h>
#include <platform_thread.h>
#include <platform_pd.h>
#include <assertion.h>
namespace Genode {
@ -123,7 +124,7 @@ namespace Genode {
/**
* Constructor
*/
Core_pager(Platform_pd *core_pd, Sigma0*);
Core_pager(Platform_pd &core_pd, Sigma0 &);
int pager(Ipc_pager &) { /* never called */ return -1; }
};
@ -131,7 +132,7 @@ namespace Genode {
/**
* Return singleton instance of core pager object
*/
Core_pager *core_pager();
Core_pager &core_pager();
/**
* Set interrupt trigger/polarity (e.g., level or edge, high or low)
@ -147,26 +148,33 @@ namespace Genode {
/**
* Accessor for core pd object
*/
Platform_pd *core_pd() { return _core_pd; }
Platform_pd &core_pd()
{
if (_core_pd)
return *_core_pd;
ASSERT_NEVER_CALLED;
}
/********************************
** Generic platform interface **
********************************/
Range_allocator *core_mem_alloc() { return &_ram_alloc; }
Range_allocator *ram_alloc() { return &_ram_alloc; }
Range_allocator *io_mem_alloc() { return &_io_mem_alloc; }
Range_allocator *io_port_alloc() { return &_io_port_alloc; }
Range_allocator *irq_alloc() { return &_irq_alloc; }
Range_allocator *region_alloc() { return &_region_alloc; }
Cap_id_allocator *cap_id_alloc() { return &_cap_id_alloc; }
addr_t vm_start() const { return _vm_start; }
size_t vm_size() const { return _vm_size; }
Rom_fs *rom_fs() { return &_rom_fs; }
Affinity::Space affinity_space() const;
Range_allocator &core_mem_alloc() override { return _ram_alloc; }
Range_allocator &ram_alloc() override { return _ram_alloc; }
Range_allocator &io_mem_alloc() override { return _io_mem_alloc; }
Range_allocator &io_port_alloc() override { return _io_port_alloc; }
Range_allocator &irq_alloc() override { return _irq_alloc; }
Range_allocator &region_alloc() override { return _region_alloc; }
addr_t vm_start() const override { return _vm_start; }
size_t vm_size() const override { return _vm_size; }
Rom_fs &rom_fs() override { return _rom_fs; }
Affinity::Space affinity_space() const override;
size_t max_caps() const override { return cap_idx_alloc()->max_caps(); }
size_t max_caps() const override { return cap_idx_alloc().max_caps(); }
Cap_id_allocator &cap_id_alloc() { return _cap_id_alloc; }
void wait_for_exit();
};

View File

@ -65,7 +65,7 @@ namespace Genode {
Cap_mapping _task;
Cap_mapping _parent { };
Cap_mapping _debug { };
Platform_thread *_threads[THREAD_MAX];
Platform_thread *_threads[THREAD_MAX] { };
public:
@ -73,14 +73,14 @@ namespace Genode {
/**
* Constructor for core.
* Constructor for core
*/
Platform_pd(Core_cap_index*);
Platform_pd(Core_cap_index &);
/**
* Constructor for all tasks except core.
*/
Platform_pd(Allocator *, char const *label);
Platform_pd(Allocator &, char const *label);
/**
* Destructor
@ -90,14 +90,14 @@ namespace Genode {
/**
* Bind thread to protection domain
*/
bool bind_thread(Platform_thread *thread);
bool bind_thread(Platform_thread &);
/**
* Unbind thread from protection domain
*
* Free the thread's slot and update thread object.
*/
void unbind_thread(Platform_thread *thread);
void unbind_thread(Platform_thread &);
/**
* Assign parent interface to protection domain

View File

@ -23,6 +23,7 @@
#include <pager.h>
#include <platform_pd.h>
#include <cap_mapping.h>
#include <assertion.h>
namespace Genode {
@ -39,8 +40,11 @@ namespace Genode {
enum State { DEAD, RUNNING };
typedef String<32> Name;
friend class Platform_pd;
Name const _name; /* name at kernel debugger */
State _state;
bool _core_thread;
Cap_mapping _thread;
@ -48,9 +52,6 @@ namespace Genode {
Cap_mapping _pager { };
Cap_mapping _irq;
addr_t _utcb;
char _name[32]; /* thread name that will be
registered at the kernel
debugger */
Platform_pd *_platform_pd; /* protection domain thread
is bound to */
Pager_object *_pager_obj;
@ -59,7 +60,7 @@ namespace Genode {
Affinity::Location _location { };
void _create_thread(void);
void _finalize_construction(const char *name);
void _finalize_construction();
bool _in_syscall(Fiasco::l4_umword_t flags);
public:
@ -75,8 +76,8 @@ namespace Genode {
/**
* Constructor for core main-thread
*/
Platform_thread(Core_cap_index* thread,
Core_cap_index* irq, const char *name);
Platform_thread(Core_cap_index& thread,
Core_cap_index& irq, const char *name);
/**
* Constructor for core threads
@ -124,7 +125,7 @@ namespace Genode {
*
* \param pd platform pd, thread is bound to
*/
void bind(Platform_pd *pd);
void bind(Platform_pd &pd);
/**
* Unbind this thread
@ -162,8 +163,15 @@ namespace Genode {
/**
* Return/set pager
*/
Pager_object *pager() const { return _pager_obj; }
void pager(Pager_object *pager);
Pager_object &pager() const
{
if (_pager_obj)
return *_pager_obj;
ASSERT_NEVER_CALLED;
}
void pager(Pager_object &pager);
/**
* Return identification of thread when faulting
@ -188,7 +196,7 @@ namespace Genode {
Cap_mapping const & thread() const { return _thread; }
Cap_mapping & gate() { return _gate; }
const char *name() const { return _name; }
Name name() const { return _name; }
bool core_thread() const { return _core_thread; }
addr_t utcb() const { return _utcb; }
};

View File

@ -23,7 +23,7 @@ using namespace Genode;
void Io_mem_session_component::_unmap_local(addr_t base, size_t)
{
platform()->region_alloc()->free(reinterpret_cast<void *>(base));
platform().region_alloc().free(reinterpret_cast<void *>(base));
}
@ -35,7 +35,7 @@ addr_t Io_mem_session_component::_map_local(addr_t base, size_t size)
/* find appropriate region for mapping */
void *local_base = 0;
if (platform()->region_alloc()->alloc_aligned(size, &local_base, alignment).error())
if (platform().region_alloc().alloc_aligned(size, &local_base, alignment).error())
return 0;
if (!map_local_io(base, (addr_t)local_base, size >> get_page_size_log2())) {

View File

@ -147,7 +147,7 @@ void Genode::Irq_object::ack_irq()
Genode::Irq_object::Irq_object()
:
_cap(cap_map()->insert(platform_specific()->cap_id_alloc()->alloc())),
_cap(cap_map().insert(platform_specific().cap_id_alloc().alloc())),
_trigger(Irq_session::TRIGGER_UNCHANGED),
_polarity(Irq_session::POLARITY_UNCHANGED),
_irq(~0U), _msi_addr(0), _msi_data(0)
@ -170,7 +170,7 @@ Genode::Irq_object::~Irq_object()
if (l4_error(l4_icu_unbind(L4_BASE_ICU_CAP, irq, _capability())))
error("cannot unbind IRQ");
cap_map()->remove(_cap);
cap_map().remove(_cap);
}
@ -179,7 +179,7 @@ Genode::Irq_object::~Irq_object()
***************************/
Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
const char *args)
: _irq_number(Arg_string::find_arg(args, "irq_number").long_value(-1)),
_irq_alloc(irq_alloc), _irq_object()
@ -192,7 +192,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
}
msi_alloc.set(_irq_number, 1);
} else {
if (!irq_alloc || irq_alloc->alloc_addr(1, _irq_number).error()) {
if (irq_alloc.alloc_addr(1, _irq_number).error()) {
error("unavailable IRQ ", _irq_number, " requested");
throw Service_denied();
}
@ -208,7 +208,7 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
msi_alloc.clear(_irq_number, 1);
else {
addr_t const free_irq = _irq_number;
_irq_alloc->free((void *)free_irq);
_irq_alloc.free((void *)free_irq);
}
throw Service_denied();
}
@ -223,7 +223,7 @@ Irq_session_component::~Irq_session_component()
msi_alloc.clear(_irq_number, 1);
} else {
Genode::addr_t free_irq = _irq_number;
_irq_alloc->free((void *)free_irq);
_irq_alloc.free((void *)free_irq);
}
}

View File

@ -16,7 +16,7 @@
/* core includes */
#include <native_cpu_component.h>
#include <cpu_session_irqs.h>
#include <cpu_session_component.h>
#include <platform.h>
/* Fiasco.OC includes */
@ -54,7 +54,7 @@ Genode::Native_cpu_component::thread_state(Genode::Thread_capability cap)
Genode::Native_cpu_component::Native_cpu_component(Cpu_session_component &cpu_session, char const *)
:
_cpu_session(cpu_session), _thread_ep(*_cpu_session._thread_ep)
_cpu_session(cpu_session), _thread_ep(_cpu_session._thread_ep)
{
_thread_ep.manage(this);
}

View File

@ -59,7 +59,7 @@ void Pager_entrypoint::entry()
{
if (_pager.exception()) {
Lock::Guard guard(obj->state.lock);
_pager.get_regs(&obj->state);
_pager.get_regs(obj->state);
obj->state.exceptions++;
obj->state.in_exception = true;
obj->submit_exception_signal();
@ -115,7 +115,7 @@ void Pager_entrypoint::entry()
case Ipc_pager::PAUSE:
{
Lock::Guard guard(obj->state.lock);
_pager.get_regs(&obj->state);
_pager.get_regs(obj->state);
obj->state.exceptions++;
obj->state.in_exception = true;
@ -139,24 +139,24 @@ void Pager_entrypoint::entry()
}
void Pager_entrypoint::dissolve(Pager_object *obj)
void Pager_entrypoint::dissolve(Pager_object &obj)
{
/* cleanup at cap session */
_cap_factory.free(obj->Object_pool<Pager_object>::Entry::cap());
_cap_factory.free(obj.Object_pool<Pager_object>::Entry::cap());
remove(obj);
remove(&obj);
}
Pager_capability Pager_entrypoint::manage(Pager_object *obj)
Pager_capability Pager_entrypoint::manage(Pager_object &obj)
{
using namespace Fiasco;
Native_capability cap(_cap_factory.alloc(Thread::_thread_cap));
/* add server object to object pool */
obj->cap(cap);
insert(obj);
obj.cap(cap);
insert(&obj);
/* return capability that uses the object id as badge */
return reinterpret_cap_cast<Pager_object>(cap);

View File

@ -137,7 +137,7 @@ Platform::Sigma0::Sigma0(Cap_index* i)
}
Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0)
Platform::Core_pager::Core_pager(Platform_pd &core_pd, Sigma0 &sigma0)
:
Platform_thread("core.pager"),
Pager_object(Cpu_session_capability(), Thread_capability(),
@ -146,7 +146,7 @@ Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0)
{
Platform_thread::pager(sigma0);
core_pd->bind_thread(this);
core_pd.bind_thread(*this);
cap(thread().local);
/* stack begins at the top end of the '_core_pager_stack' array */
@ -164,10 +164,10 @@ Platform::Core_pager::Core_pager(Platform_pd *core_pd, Sigma0 *sigma0)
}
Platform::Core_pager *Platform::core_pager()
Platform::Core_pager &Platform::core_pager()
{
static Core_pager _core_pager(core_pd(), &_sigma0);
return &_core_pager;
static Core_pager _core_pager(core_pd(), _sigma0);
return _core_pager;
}
@ -248,13 +248,13 @@ static inline int sigma0_req_region(addr_t *addr, unsigned log2size)
}
static Fiasco::l4_kernel_info_t *sigma0_map_kip()
static Fiasco::l4_kernel_info_t &sigma0_map_kip()
{
using namespace Fiasco;
static l4_kernel_info_t *kip = nullptr;
static l4_kernel_info_t *kip_ptr = nullptr;
if (kip) return kip;
if (kip_ptr) return *kip_ptr;
/* signal we want to map the KIP */
l4_utcb_mr()->mr[0] = SIGMA0_REQ_KIP;
@ -270,15 +270,15 @@ static Fiasco::l4_kernel_info_t *sigma0_map_kip()
l4_msgtag(L4_PROTO_SIGMA0, 1, 0, 0),
L4_IPC_NEVER);
if (l4_ipc_error(tag, l4_utcb()))
return 0;
panic("kip request to sigma0 failed");
l4_addr_t ret = l4_trunc_page(l4_utcb_mr()->mr[0]);
if (!ret)
panic("kip mapping failed");
else
kip = (l4_kernel_info_t*) ret;
return kip;
kip_ptr = (l4_kernel_info_t*)ret;
return *kip_ptr;
}
@ -347,21 +347,21 @@ void Platform::_setup_basics()
{
using namespace Fiasco;
l4_kernel_info_t * kip = sigma0_map_kip();
l4_kernel_info_t const &kip = sigma0_map_kip();
if (kip->magic != L4_KERNEL_INFO_MAGIC)
if (kip.magic != L4_KERNEL_INFO_MAGIC)
panic("Sigma0 mapped something but not the KIP");
log("");
log("KIP @ ", kip);
log(" magic: ", Hex(kip->magic));
log(" version: ", Hex(kip->version));
log("KIP @ ", &kip);
log(" magic: ", Hex(kip.magic));
log(" version: ", Hex(kip.version));
/* add KIP as ROM module */
_rom_fs.insert(&_kip_rom);
/* update multi-boot info pointer from KIP */
addr_t mb_info_addr = kip->user_ptr;
addr_t mb_info_addr = kip.user_ptr;
log("MBI @ ", Hex(mb_info_addr));
/* parse memory descriptors - look for virtual memory configuration */
@ -369,9 +369,9 @@ void Platform::_setup_basics()
using Fiasco::L4::Kip::Mem_desc;
_vm_start = 0; _vm_size = 0;
Mem_desc *desc = Mem_desc::first(kip);
Mem_desc const * const desc = Mem_desc::first(&kip);
for (unsigned i = 0; i < Mem_desc::count(kip); ++i)
for (unsigned i = 0; i < Mem_desc::count(&kip); ++i)
if (desc[i].is_virtual()) {
_vm_start = round_page(desc[i].start());
_vm_size = trunc_page(desc[i].end() - _vm_start + 1);
@ -398,8 +398,8 @@ void Platform::_setup_basics()
_io_mem_alloc.add_range(0, ~0);
/* remove KIP and MBI area from region and IO_MEM allocator */
remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _region_alloc);
remove_region(Region((addr_t)kip, (addr_t)kip + L4_PAGESIZE), _io_mem_alloc);
remove_region(Region((addr_t)&kip, (addr_t)&kip + L4_PAGESIZE), _region_alloc);
remove_region(Region((addr_t)&kip, (addr_t)&kip + L4_PAGESIZE), _io_mem_alloc);
/* remove core program image memory from region and IO_MEM allocator */
addr_t img_start = (addr_t) &_prog_img_beg;
@ -413,11 +413,11 @@ void Platform::_setup_basics()
Platform::Platform() :
_ram_alloc(nullptr), _io_mem_alloc(core_mem_alloc()),
_io_port_alloc(core_mem_alloc()), _irq_alloc(core_mem_alloc()),
_region_alloc(core_mem_alloc()), _cap_id_alloc(core_mem_alloc()),
_kip_rom((addr_t)sigma0_map_kip(), L4_PAGESIZE, "l4v2_kip"),
_sigma0(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_PAGER_CAP))
_ram_alloc(nullptr), _io_mem_alloc(&core_mem_alloc()),
_io_port_alloc(&core_mem_alloc()), _irq_alloc(&core_mem_alloc()),
_region_alloc(&core_mem_alloc()), _cap_id_alloc(core_mem_alloc()),
_kip_rom((addr_t)&sigma0_map_kip(), L4_PAGESIZE, "l4v2_kip"),
_sigma0(cap_map().insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_PAGER_CAP))
{
/*
* We must be single-threaded at this stage and so this is safe.
@ -434,31 +434,33 @@ Platform::Platform() :
log(_rom_fs);
Core_cap_index* pdi =
reinterpret_cast<Core_cap_index*>(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_TASK_CAP));
Core_cap_index* thi =
reinterpret_cast<Core_cap_index*>(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_THREAD_CAP));
Core_cap_index* irqi =
reinterpret_cast<Core_cap_index*>(cap_map()->insert(_cap_id_alloc.alloc()));
Core_cap_index &pdi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc(),
Fiasco::L4_BASE_TASK_CAP));
Core_cap_index &thi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc(),
Fiasco::L4_BASE_THREAD_CAP));
Core_cap_index &irqi =
*reinterpret_cast<Core_cap_index*>(cap_map().insert(_cap_id_alloc.alloc()));
/* setup pd object for core pd */
_core_pd = new(core_mem_alloc()) Platform_pd(pdi);
_core_pd = new (core_mem_alloc()) Platform_pd(pdi);
/*
* We setup the thread object for thread0 in core pd using a special
* interface that allows us to specify the capability slot.
*/
Platform_thread *core_thread = new(core_mem_alloc())
Platform_thread &core_thread = *new (core_mem_alloc())
Platform_thread(thi, irqi, "core.main");
core_thread->pager(&_sigma0);
core_thread.pager(_sigma0);
_core_pd->bind_thread(core_thread);
{
/* export x86 platform specific infos */
void * phys_ptr = nullptr;
if (ram_alloc()->alloc_aligned(get_page_size(), &phys_ptr,
get_page_size_log2()).ok()) {
if (ram_alloc().alloc_aligned(get_page_size(), &phys_ptr,
get_page_size_log2()).ok()) {
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
/* empty for now */
_rom_fs.insert(new (core_mem_alloc()) Rom_module(phys_addr,
@ -474,11 +476,11 @@ Platform::Platform() :
unsigned const pages = 1;
size_t const log_size = pages << get_page_size_log2();
ram_alloc()->alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
ram_alloc().alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
/* let one page free after the log buffer */
region_alloc()->alloc_aligned(log_size, &core_local_ptr, get_page_size_log2());
region_alloc().alloc_aligned(log_size, &core_local_ptr, get_page_size_log2());
addr_t const core_local_addr = reinterpret_cast<addr_t>(core_local_ptr);
map_local(phys_addr, core_local_addr, pages);

View File

@ -42,42 +42,42 @@ static addr_t core_utcb_base() {
** Public object members **
***************************/
bool Platform_pd::bind_thread(Platform_thread *thread)
bool Platform_pd::bind_thread(Platform_thread &thread)
{
/*
* Fiasco.OC limits the UTCB area for roottask to 16K. Therefore, the
* number of threads is limited to 16K / L4_UTCB_OFFSET.
* (see kernel/fiasco/src/kern/kernel_thread-std.cpp:94)
*/
unsigned const thread_max = thread->core_thread() ? 16*1024/L4_UTCB_OFFSET : THREAD_MAX;
unsigned const thread_max = thread.core_thread() ? 16*1024/L4_UTCB_OFFSET : THREAD_MAX;
for (unsigned i = 0; i < thread_max; i++) {
if (_threads[i])
continue;
_threads[i] = thread;
_threads[i] = &thread;
if (thread->core_thread())
thread->_utcb = (addr_t) (core_utcb_base() + i * L4_UTCB_OFFSET);
if (thread.core_thread())
thread._utcb = (addr_t) (core_utcb_base() + i * L4_UTCB_OFFSET);
else
thread->_utcb =
thread._utcb =
reinterpret_cast<addr_t>(utcb_area_start() + i * L4_UTCB_OFFSET);
Fiasco::l4_cap_idx_t cap_offset = THREAD_AREA_BASE + i * THREAD_AREA_SLOT;
thread->_gate.remote = cap_offset + THREAD_GATE_CAP;
thread->_pager.remote = cap_offset + THREAD_PAGER_CAP;
thread->_irq.remote = cap_offset + THREAD_IRQ_CAP;
thread._gate.remote = cap_offset + THREAD_GATE_CAP;
thread._pager.remote = cap_offset + THREAD_PAGER_CAP;
thread._irq.remote = cap_offset + THREAD_IRQ_CAP;
/* if it's no core-thread we have to map parent and pager gate cap */
if (!thread->core_thread()) {
if (!thread.core_thread()) {
_task.map(_task.local.data()->kcap());
// FIXME: there is no debug cap anymore
// _debug.map(_task.local.data()->kcap());
}
/* inform thread about binding */
thread->bind(this);
thread.bind(*this);
return true;
}
@ -86,14 +86,14 @@ bool Platform_pd::bind_thread(Platform_thread *thread)
}
void Platform_pd::unbind_thread(Platform_thread *thread)
void Platform_pd::unbind_thread(Platform_thread &thread)
{
/* inform thread about unbinding */
thread->unbind();
thread.unbind();
for (unsigned i = 0; i < THREAD_MAX; i++)
if (_threads[i] == thread) {
_threads[i] = (Platform_thread*) 0;
if (_threads[i] == &thread) {
_threads[i] = (Platform_thread*)nullptr;
return;
}
}
@ -117,25 +117,19 @@ void Platform_pd::flush(addr_t, size_t size, Core_local_addr core_local)
static Core_cap_index * debug_cap()
{
unsigned long id = platform_specific()->cap_id_alloc()->alloc();
static Cap_index * idx = cap_map()->insert(id, DEBUG_CAP);
unsigned long const id = platform_specific().cap_id_alloc().alloc();
static Cap_index * idx = cap_map().insert(id, DEBUG_CAP);
return reinterpret_cast<Core_cap_index*>(idx);
}
Platform_pd::Platform_pd(Core_cap_index* i)
: _task(Native_capability(i), TASK_CAP)
{
for (unsigned i = 0; i < THREAD_MAX; i++)
_threads[i] = (Platform_thread*) 0;
}
Platform_pd::Platform_pd(Core_cap_index &ci)
: _task(Native_capability(&ci), TASK_CAP)
{ }
Platform_pd::Platform_pd(Allocator *, char const *)
Platform_pd::Platform_pd(Allocator &, char const *)
: _task(true, TASK_CAP), _debug(debug_cap(), DEBUG_CAP)
{
for (unsigned i = 0; i < THREAD_MAX; i++)
_threads[i] = (Platform_thread*) 0;
l4_fpage_t utcb_area = l4_fpage(utcb_area_start(),
log2<unsigned>(UTCB_AREA_SIZE), 0);
l4_msgtag_t tag = l4_factory_create_task(L4_BASE_FACTORY_CAP,

View File

@ -153,11 +153,11 @@ void Platform_thread::resume()
}
void Platform_thread::bind(Platform_pd *pd)
void Platform_thread::bind(Platform_pd &pd)
{
_platform_pd = pd;
_gate.map(pd->native_task().data()->kcap());
_irq.map(pd->native_task().data()->kcap());
_platform_pd = &pd;
_gate.map(pd.native_task().data()->kcap());
_irq.map(pd.native_task().data()->kcap());
}
@ -180,11 +180,11 @@ void Platform_thread::unbind()
}
void Platform_thread::pager(Pager_object *pager_obj)
void Platform_thread::pager(Pager_object &pager_obj)
{
_pager_obj = pager_obj;
_pager_obj = &pager_obj;
if (_pager_obj)
_pager.local = pager_obj->cap();
_pager.local = pager_obj.cap();
else
_pager.local = Native_capability();
}
@ -240,7 +240,7 @@ Affinity::Location Platform_thread::affinity() const
static Rpc_cap_factory &thread_cap_factory()
{
static Rpc_cap_factory inst(*platform()->core_mem_alloc());
static Rpc_cap_factory inst(platform().core_mem_alloc());
return inst;
}
@ -257,7 +257,7 @@ void Platform_thread::_create_thread()
}
void Platform_thread::_finalize_construction(const char *name)
void Platform_thread::_finalize_construction()
{
/* create irq for new thread */
l4_msgtag_t tag = l4_factory_create_irq(L4_BASE_FACTORY_CAP,
@ -271,8 +271,7 @@ void Platform_thread::_finalize_construction(const char *name)
warning("attaching thread's irq failed");
/* set human readable name in kernel debugger */
strncpy(_name, name, sizeof(_name));
Fiasco::l4_debugger_set_object_name(_thread.local.data()->kcap(), name);
Fiasco::l4_debugger_set_object_name(_thread.local.data()->kcap(), _name.string());
/* set priority of thread */
l4_sched_param_t params = l4_sched_param(_prio);
@ -283,7 +282,8 @@ void Platform_thread::_finalize_construction(const char *name)
Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
Affinity::Location location, addr_t)
: _state(DEAD),
: _name(name),
_state(DEAD),
_core_thread(false),
_thread(true),
_irq(true),
@ -295,17 +295,18 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned prio,
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
_create_thread();
_finalize_construction(name);
_finalize_construction();
affinity(location);
}
Platform_thread::Platform_thread(Core_cap_index* thread,
Core_cap_index* irq, const char *name)
: _state(RUNNING),
Platform_thread::Platform_thread(Core_cap_index &thread,
Core_cap_index &irq, const char *name)
: _name(name),
_state(RUNNING),
_core_thread(true),
_thread(Native_capability(thread), L4_BASE_THREAD_CAP),
_irq(Native_capability(irq)),
_thread(Native_capability(&thread), L4_BASE_THREAD_CAP),
_irq(Native_capability(&irq)),
_utcb(0),
_platform_pd(0),
_pager_obj(0),
@ -313,12 +314,13 @@ Platform_thread::Platform_thread(Core_cap_index* thread,
{
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
_finalize_construction(name);
_finalize_construction();
}
Platform_thread::Platform_thread(const char *name)
: _state(DEAD),
: _name(name),
_state(DEAD),
_core_thread(true),
_thread(true),
_irq(true),
@ -330,7 +332,7 @@ Platform_thread::Platform_thread(const char *name)
/* XXX remove const cast */
((Core_cap_index *)_thread.local.data())->pt(this);
_create_thread();
_finalize_construction(name);
_finalize_construction();
}
@ -343,5 +345,5 @@ Platform_thread::~Platform_thread()
* Thread::unbind()
*/
if (_platform_pd)
_platform_pd->unbind_thread(this);
_platform_pd->unbind_thread(*this);
}

View File

@ -21,15 +21,15 @@ namespace Fiasco {
using namespace Genode;
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_clear_ds(Dataspace_component *ds)
void Ram_dataspace_factory::_clear_ds(Dataspace_component &ds)
{
memset((void *)ds->phys_addr(), 0, ds->size());
memset((void *)ds.phys_addr(), 0, ds.size());
if (ds->cacheability() != CACHED)
Fiasco::l4_cache_dma_coherent(ds->phys_addr(), ds->phys_addr() + ds->size());
if (ds.cacheability() != CACHED)
Fiasco::l4_cache_dma_coherent(ds.phys_addr(), ds.phys_addr() + ds.size());
}

View File

@ -43,10 +43,10 @@ using namespace Genode;
** Cap_index_allocator **
***************************/
Genode::Cap_index_allocator* Genode::cap_idx_alloc()
Genode::Cap_index_allocator &Genode::cap_idx_alloc()
{
static Genode::Cap_index_allocator_tpl<Core_cap_index,10*1024> alloc;
return &alloc;
return alloc;
}
@ -54,10 +54,10 @@ Genode::Cap_index_allocator* Genode::cap_idx_alloc()
** Cap_mapping **
*******************/
Core_cap_index* Cap_mapping::_get_cap()
Core_cap_index *Cap_mapping::_get_cap()
{
int id = platform_specific()->cap_id_alloc()->alloc();
return static_cast<Core_cap_index*>(cap_map()->insert(id));
int const id = platform_specific().cap_id_alloc().alloc();
return static_cast<Core_cap_index*>(cap_map().insert(id));
}
@ -107,12 +107,12 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
/*
* Allocate new id, and ipc-gate and set id as gate-label
*/
unsigned long id = platform_specific()->cap_id_alloc()->alloc();
Core_cap_index* idx = static_cast<Core_cap_index*>(cap_map()->insert(id));
unsigned long const id = platform_specific().cap_id_alloc().alloc();
Core_cap_index *idx = static_cast<Core_cap_index*>(cap_map().insert(id));
if (!idx) {
warning("Out of capability indices!");
platform_specific()->cap_id_alloc()->free(id);
platform_specific().cap_id_alloc().free(id);
return cap;
}
@ -121,12 +121,12 @@ Native_capability Rpc_cap_factory::alloc(Native_capability ep)
ref->pt()->thread().local.data()->kcap(), id);
if (l4_msgtag_has_error(tag)) {
error("l4_factory_create_gate failed!");
cap_map()->remove(idx);
platform_specific()->cap_id_alloc()->free(id);
cap_map().remove(idx);
platform_specific().cap_id_alloc().free(id);
return cap;
} else
/* set debugger-name of ipc-gate to thread's name */
Fiasco::l4_debugger_set_object_name(idx->kcap(), ref->pt()->name());
Fiasco::l4_debugger_set_object_name(idx->kcap(), ref->pt()->name().string());
// XXX remove cast
idx->session((Pd_session_component *)this);
@ -159,7 +159,7 @@ void Rpc_cap_factory::free(Native_capability cap)
if (static_cast<Core_cap_index const *>(cap.data())->session() != (Pd_session_component *)this)
return;
Entry * entry;
Entry * entry = nullptr;
_pool.apply(cap, [&] (Entry *e) {
entry = e;
if (e) {
@ -184,8 +184,8 @@ Rpc_cap_factory::~Rpc_cap_factory()
** Capability ID Allocator **
*******************************/
Cap_id_allocator::Cap_id_allocator(Allocator* alloc)
: _id_alloc(alloc)
Cap_id_allocator::Cap_id_allocator(Allocator &alloc)
: _id_alloc(&alloc)
{
_id_alloc.add_range(CAP_ID_OFFSET, CAP_ID_RANGE);
}
@ -195,7 +195,7 @@ unsigned long Cap_id_allocator::alloc()
{
Lock::Guard lock_guard(_lock);
void *id;
void *id = nullptr;
if (_id_alloc.alloc(CAP_ID_OFFSET, &id))
return (unsigned long) id;
throw Out_of_ids();
@ -211,7 +211,7 @@ void Cap_id_allocator::free(unsigned long id)
}
void Genode::Capability_map::remove(Genode::Cap_index* i)
void Genode::Capability_map::remove(Genode::Cap_index *i)
{
using namespace Genode;
using namespace Fiasco;
@ -228,9 +228,9 @@ void Genode::Capability_map::remove(Genode::Cap_index* i)
error("destruction of ipc-gate ", i->kcap(), " failed!");
platform_specific()->cap_id_alloc()->free(i->id());
platform_specific().cap_id_alloc().free(i->id());
_tree.remove(i);
}
cap_idx_alloc()->free(i, 1);
cap_idx_alloc().free(i, 1);
}
}

View File

@ -32,20 +32,20 @@ using namespace Genode;
** Signal-source component **
*****************************/
void Signal_source_component::release(Signal_context_component *context)
void Signal_source_component::release(Signal_context_component &context)
{
if (context && context->enqueued())
_signal_queue.remove(context);
if (context.enqueued())
_signal_queue.remove(&context);
}
void Signal_source_component::submit(Signal_context_component *context,
void Signal_source_component::submit(Signal_context_component &context,
unsigned long cnt)
{
/* enqueue signal to context */
context->increment_signal_cnt(cnt);
context.increment_signal_cnt(cnt);
if (!context->enqueued()) {
_signal_queue.enqueue(context);
if (!context.enqueued()) {
_signal_queue.enqueue(&context);
/* wake up client */
Fiasco::l4_irq_trigger(_blocking_semaphore.data()->kcap());
@ -61,16 +61,16 @@ Signal_source::Signal Signal_source_component::wait_for_signal()
}
/* dequeue and return pending signal */
Signal_context_component *context = _signal_queue.dequeue();
Signal result(context->imprint(), context->cnt());
context->reset_signal_cnt();
Signal_context_component &context = *_signal_queue.dequeue();
Signal result(context.imprint(), context.cnt());
context.reset_signal_cnt();
return result;
}
Signal_source_component::Signal_source_component(Rpc_entrypoint *ep)
Signal_source_component::Signal_source_component(Rpc_entrypoint &ep)
:
Signal_source_rpc_object(cap_map()->insert(platform_specific()->cap_id_alloc()->alloc())),
Signal_source_rpc_object(cap_map().insert(platform_specific().cap_id_alloc().alloc())),
_entrypoint(ep)
{
using namespace Fiasco;

View File

@ -32,29 +32,29 @@ void Genode::Ipc_pager::_parse_exception()
}
void Genode::Ipc_pager::get_regs(Foc_thread_state *state)
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
{
state->ip = _regs.pc;
state->sp = _regs.sp;
state->r0 = _regs.r[0];
state->r1 = _regs.r[1];
state->r2 = _regs.r[2];
state->r3 = _regs.r[3];
state->r4 = _regs.r[4];
state->r5 = _regs.r[5];
state->r6 = _regs.r[6];
state->r7 = _regs.r[7];
state->r8 = _regs.r[8];
state->r9 = _regs.r[9];
state->r10 = _regs.r[10];
state->r11 = _regs.r[11];
state->r12 = _regs.r[12];
state->lr = _regs.ulr;
state->cpsr = _regs.cpsr;
state.ip = _regs.pc;
state.sp = _regs.sp;
state.r0 = _regs.r[0];
state.r1 = _regs.r[1];
state.r2 = _regs.r[2];
state.r3 = _regs.r[3];
state.r4 = _regs.r[4];
state.r5 = _regs.r[5];
state.r6 = _regs.r[6];
state.r7 = _regs.r[7];
state.r8 = _regs.r[8];
state.r9 = _regs.r[9];
state.r10 = _regs.r[10];
state.r11 = _regs.r[11];
state.r12 = _regs.r[12];
state.lr = _regs.ulr;
state.cpsr = _regs.cpsr;
}
void Genode::Ipc_pager::set_regs(Foc_thread_state state)
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.pc = state.ip;
_regs.sp = state.sp;

View File

@ -17,25 +17,25 @@
#include <ipc_pager.h>
void Genode::Ipc_pager::get_regs(Foc_thread_state *state)
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
{
state->ip = _regs.ip;
state->sp = _regs.sp;
state->edi = _regs.edi;
state->esi = _regs.esi;
state->ebp = _regs.ebp;
state->ebx = _regs.ebx;
state->edx = _regs.edx;
state->ecx = _regs.ecx;
state->eax = _regs.eax;
state->gs = _regs.gs;
state->fs = _regs.fs;
state->eflags = _regs.flags;
state->trapno = _regs.trapno;
state.ip = _regs.ip;
state.sp = _regs.sp;
state.edi = _regs.edi;
state.esi = _regs.esi;
state.ebp = _regs.ebp;
state.ebx = _regs.ebx;
state.edx = _regs.edx;
state.ecx = _regs.ecx;
state.eax = _regs.eax;
state.gs = _regs.gs;
state.fs = _regs.fs;
state.eflags = _regs.flags;
state.trapno = _regs.trapno;
}
void Genode::Ipc_pager::set_regs(Foc_thread_state state)
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.ip = state.ip;
_regs.sp = state.sp;

View File

@ -17,32 +17,32 @@
#include <ipc_pager.h>
void Genode::Ipc_pager::get_regs(Foc_thread_state *state)
void Genode::Ipc_pager::get_regs(Foc_thread_state &state) const
{
state->ip = _regs.ip;
state->sp = _regs.sp;
state->r8 = _regs.r8;
state->r9 = _regs.r9;
state->r10 = _regs.r10;
state->r11 = _regs.r11;
state->r12 = _regs.r12;
state->r13 = _regs.r13;
state->r14 = _regs.r14;
state->r15 = _regs.r15;
state->rax = _regs.rax;
state->rbx = _regs.rbx;
state->rcx = _regs.rcx;
state->rdx = _regs.rdx;
state->rdi = _regs.rdi;
state->rsi = _regs.rsi;
state->rbp = _regs.rbp;
state->ss = _regs.ss;
state->eflags = _regs.flags;
state->trapno = _regs.trapno;
state.ip = _regs.ip;
state.sp = _regs.sp;
state.r8 = _regs.r8;
state.r9 = _regs.r9;
state.r10 = _regs.r10;
state.r11 = _regs.r11;
state.r12 = _regs.r12;
state.r13 = _regs.r13;
state.r14 = _regs.r14;
state.r15 = _regs.r15;
state.rax = _regs.rax;
state.rbx = _regs.rbx;
state.rcx = _regs.rcx;
state.rdx = _regs.rdx;
state.rdi = _regs.rdi;
state.rsi = _regs.rsi;
state.rbp = _regs.rbp;
state.ss = _regs.ss;
state.eflags = _regs.flags;
state.trapno = _regs.trapno;
}
void Genode::Ipc_pager::set_regs(Foc_thread_state state)
void Genode::Ipc_pager::set_regs(Foc_thread_state const &state)
{
_regs.ip = state.ip;
_regs.sp = state.sp;

View File

@ -45,26 +45,26 @@ void Thread::start()
using namespace Fiasco;
/* create and start platform thread */
Platform_thread *pt =
new(platform()->core_mem_alloc()) Platform_thread(_stack->name().string());
Platform_thread &pt = *new (platform().core_mem_alloc())
Platform_thread(_stack->name().string());
platform_specific()->core_pd()->bind_thread(pt);
platform_specific().core_pd().bind_thread(pt);
l4_utcb_t *foc_utcb = (l4_utcb_t *)(pt->utcb());
l4_utcb_t *foc_utcb = (l4_utcb_t *)(pt.utcb());
native_thread() = Native_thread(pt->gate().remote);
native_thread() = Native_thread(pt.gate().remote);
utcb()->foc_utcb = foc_utcb;
_thread_cap =
reinterpret_cap_cast<Cpu_thread>(Native_capability(pt->thread().local));
reinterpret_cap_cast<Cpu_thread>(Native_capability(pt.thread().local));
pt->pager(platform_specific()->core_pager());
pt.pager(platform_specific().core_pager());
l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_BADGE] = (unsigned long) pt->gate().local.data();
l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_BADGE] = (unsigned long) pt.gate().local.data();
l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
pt->start((void *)_thread_start, stack_top());
pt.start((void *)_thread_start, stack_top());
}

View File

@ -124,7 +124,7 @@ namespace Genode {
/**
* Get the global Cap_index_allocator of the process.
*/
Cap_index_allocator *cap_idx_alloc();
Cap_index_allocator &cap_idx_alloc();
/**
@ -245,7 +245,7 @@ namespace Genode {
/**
* Get the global Capability_map of the process.
*/
Capability_map *cap_map();
Capability_map &cap_map();
}
#endif /* _INCLUDE__BASE__CAP_MAP_H_ */

View File

@ -33,15 +33,14 @@ namespace Genode {
{
unsigned long const local_name = _parent_cap;
static Cap_index *i = cap_map()->insert(local_name,
Fiasco::PARENT_CAP);
static Cap_index *i = cap_map().insert(local_name, Fiasco::PARENT_CAP);
/*
* Update local name after a parent capability got reloaded via
* 'Platform_env::reload_parent_cap()'.
*/
if (i->id() != local_name) {
cap_map()->remove(i);
i = cap_map()->insert(local_name, Fiasco::PARENT_CAP);
cap_map().remove(i);
i = cap_map().insert(local_name, Fiasco::PARENT_CAP);
}
return reinterpret_cap_cast<Parent>(Native_capability(i));

View File

@ -13,8 +13,8 @@
#include <base/internal/cap_alloc.h>
Genode::Cap_index_allocator* Genode::cap_idx_alloc()
Genode::Cap_index_allocator &Genode::cap_idx_alloc()
{
static Genode::Cap_index_allocator_tpl<Cap_index,4096> alloc;
return &alloc;
return alloc;
}

View File

@ -71,13 +71,13 @@ Genode::Cap_index* Genode::Cap_index::find_by_id(Genode::uint16_t id)
Genode::addr_t Genode::Cap_index::kcap() const {
return cap_idx_alloc()->idx_to_kcap(this); }
return cap_idx_alloc().idx_to_kcap(this); }
Genode::uint8_t Genode::Cap_index::inc()
{
/* con't ref-count index that are controlled by core */
if (cap_idx_alloc()->static_idx(this))
if (cap_idx_alloc().static_idx(this))
return 1;
spinlock_lock(&_cap_index_spinlock);
@ -90,7 +90,7 @@ Genode::uint8_t Genode::Cap_index::inc()
Genode::uint8_t Genode::Cap_index::dec()
{
/* con't ref-count index that are controlled by core */
if (cap_idx_alloc()->static_idx(this))
if (cap_idx_alloc().static_idx(this))
return 1;
spinlock_lock(&_cap_index_spinlock);
@ -121,7 +121,7 @@ Genode::Cap_index* Genode::Capability_map::insert(int id)
ASSERT(!_tree.first() || !_tree.first()->find_by_id(id),
"Double insertion in cap_map()!");
Cap_index *i = cap_idx_alloc()->alloc_range(1);
Cap_index * const i = cap_idx_alloc().alloc_range(1);
if (i) {
i->id(id);
_tree.insert(i);
@ -141,7 +141,7 @@ Genode::Cap_index* Genode::Capability_map::insert(int id, addr_t kcap)
if (i)
_tree.remove(i);
i = cap_idx_alloc()->alloc(kcap);
i = cap_idx_alloc().alloc(kcap);
if (i) {
i->id(id);
_tree.insert(i);
@ -180,7 +180,7 @@ Genode::Cap_index* Genode::Capability_map::insert_map(int id, addr_t kcap)
}
/* the capability doesn't exists in the map so allocate a new one */
i = cap_idx_alloc()->alloc_range(1);
i = cap_idx_alloc().alloc_range(1);
if (!i)
return 0;
@ -196,10 +196,10 @@ Genode::Cap_index* Genode::Capability_map::insert_map(int id, addr_t kcap)
}
Genode::Capability_map* Genode::cap_map()
Genode::Capability_map &Genode::cap_map()
{
static Genode::Capability_map map;
return &map;
return map;
}
@ -209,14 +209,14 @@ Genode::Capability_map* Genode::cap_map()
Fiasco::l4_cap_idx_t Genode::Capability_space::alloc_kcap()
{
return cap_idx_alloc()->alloc_range(1)->kcap();
return cap_idx_alloc().alloc_range(1)->kcap();
}
void Genode::Capability_space::free_kcap(Fiasco::l4_cap_idx_t kcap)
{
Genode::Cap_index* idx = Genode::cap_idx_alloc()->kcap_to_idx(kcap);
Genode::cap_idx_alloc()->free(idx, 1);
Genode::Cap_index *idx = Genode::cap_idx_alloc().kcap_to_idx(kcap);
Genode::cap_idx_alloc().free(idx, 1);
}

View File

@ -22,9 +22,9 @@ void Genode::Capability_map::remove(Genode::Cap_index* i)
Lock_guard<Spin_lock> guard(_lock);
if (i) {
Cap_index* e = _tree.first() ? _tree.first()->find_by_id(i->id()) : 0;
Cap_index *e = _tree.first() ? _tree.first()->find_by_id(i->id()) : 0;
if (e == i)
_tree.remove(i);
cap_idx_alloc()->free(i, 1);
cap_idx_alloc().free(i, 1);
}
}

View File

@ -36,7 +36,7 @@ void Native_capability::_inc()
void Native_capability::_dec()
{
if (_data && !_data->dec())
cap_map()->remove(_data);
cap_map().remove(_data);
}

View File

@ -159,8 +159,8 @@ static unsigned long extract_msg_from_utcb(l4_msgtag_t tag,
*/
for (unsigned i = 0; i < num_caps; i++) {
if (caps[i].valid) {
rcv_msg.insert(Native_capability(cap_map()->insert_map(caps[i].badge,
caps[i].sel)));
rcv_msg.insert(Native_capability(cap_map().insert_map(caps[i].badge,
caps[i].sel)));
} else {
rcv_msg.insert(Native_capability());
}
@ -383,13 +383,13 @@ Ipc_server::~Ipc_server() { }
Receive_window::~Receive_window()
{
if (_rcv_idx_base)
cap_idx_alloc()->free(_rcv_idx_base, MAX_CAPS_PER_MSG);
cap_idx_alloc().free(_rcv_idx_base, MAX_CAPS_PER_MSG);
}
void Receive_window::init()
{
_rcv_idx_base = cap_idx_alloc()->alloc_range(MAX_CAPS_PER_MSG);
_rcv_idx_base = cap_idx_alloc().alloc_range(MAX_CAPS_PER_MSG);
}

View File

@ -31,7 +31,7 @@ void prepare_init_main_thread()
{
using namespace Genode;
enum { THREAD_CAP_ID = 1 };
Cap_index * ci(cap_map()->insert(THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP));
Cap_index * ci(cap_map().insert(THREAD_CAP_ID, Fiasco::MAIN_THREAD_CAP));
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_BADGE] = (unsigned long)ci;
Fiasco::l4_utcb_tcr()->user[Fiasco::UTCB_TCR_THREAD_OBJ] = 0;
}
@ -40,8 +40,8 @@ void prepare_init_main_thread()
void prepare_reinit_main_thread()
{
using namespace Genode;
construct_at<Capability_map>(cap_map());
cap_idx_alloc()->reinit();
construct_at<Capability_map>(&cap_map());
cap_idx_alloc().reinit();
prepare_init_main_thread();
}

View File

@ -40,7 +40,7 @@ void Thread::_deinit_platform_thread()
if (native_thread().kcap && _thread_cap.valid()) {
Cap_index *i = (Cap_index*)l4_utcb_tcr_u(utcb()->foc_utcb)->user[UTCB_TCR_BADGE];
cap_map()->remove(i);
cap_map().remove(i);
_cpu_session->kill_thread(_thread_cap);
}
}
@ -93,7 +93,7 @@ void Thread::start()
native_thread() = Native_thread(state.kcap);
Cap_index *i = cap_map()->insert(state.id, state.kcap);
Cap_index *i = cap_map().insert(state.id, state.kcap);
l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_BADGE] = (unsigned long) i;
l4_utcb_tcr_u(foc_utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;

View File

@ -34,7 +34,7 @@ Main::Main(Env &env)
enum { COUNT = 1000 };
Cap_index* idx = cap_idx_alloc()->alloc_range(COUNT);
Cap_index* idx = cap_idx_alloc().alloc_range(COUNT);
Fiasco::l4_cap_idx_t tid = Capability_space::kcap(env.ram_session_cap());
/* try the first 1000 local name IDs */

View File

@ -49,9 +49,8 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size,
/* allocate range in core's virtual address space */
void *virt_addr;
if (!platform()->region_alloc()->alloc_aligned(page_rounded_size,
&virt_addr,
get_page_size_log2()).ok()) {
if (!platform().region_alloc().alloc_aligned(page_rounded_size, &virt_addr,
get_page_size_log2()).ok()) {
error("could not allocate virtual address range in core of size ",
page_rounded_size);
return nullptr;

View File

@ -14,9 +14,13 @@
#ifndef _CORE__CPU_THREAD_ALLOCATOR_H_
#define _CORE__CPU_THREAD_ALLOCATOR_H_
/* Genode includes */
#include <base/log.h>
#include <base/allocator.h>
/* core includes */
#include <assertion.h>
namespace Genode
{
/**
@ -36,7 +40,7 @@ namespace Genode
Cpu_thread_allocator(Cpu_thread_allocator const &);
Cpu_thread_allocator &operator = (Cpu_thread_allocator const &);
Allocator * const _alloc;
Allocator &_alloc;
public:
@ -45,34 +49,25 @@ namespace Genode
*
* \param alloc allocator backend
*/
Cpu_thread_allocator(Allocator * alloc) : _alloc(alloc) { }
Cpu_thread_allocator(Allocator &alloc) : _alloc(alloc) { }
/*************************
** Allocator interface **
*************************/
bool alloc(size_t size, void **out_addr) override {
return _alloc->alloc(size, out_addr); }
return _alloc.alloc(size, out_addr); }
void free(void *addr, size_t size) override {
_alloc->free(addr, size); }
_alloc.free(addr, size); }
size_t consumed() const override
{
warning(__func__, "unexpectedly called");
while (1) ;
return 0;
}
size_t consumed() const override { ASSERT_NEVER_CALLED; }
size_t overhead(size_t) const override
{
warning(__func__, "unexpectedly called");
while (1) ;
return 0;
}
size_t overhead(size_t) const override { ASSERT_NEVER_CALLED; }
bool need_size_for_free() const override {
return _alloc->need_size_for_free(); }
return _alloc.need_size_for_free(); }
};
}

View File

@ -62,14 +62,14 @@ Irq_session_component::~Irq_session_component()
using namespace Kernel;
User_irq * kirq = reinterpret_cast<User_irq*>(&_kernel_object);
_irq_alloc->free((void *)(addr_t)_irq_number);
_irq_alloc.free((void *)(addr_t)_irq_number);
if (_sig_cap.valid())
Kernel::delete_irq(kirq);
}
Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc,
const char * const args)
Irq_session_component::Irq_session_component(Range_allocator &irq_alloc,
const char * const args)
:
_irq_number(Platform::irq(_find_irq_number(args))), _irq_alloc(irq_alloc),
_is_msi(false), _address(0), _value(0)
@ -85,7 +85,7 @@ Irq_session_component::Irq_session_component(Range_allocator * const irq_alloc,
}
/* allocate interrupt */
if (_irq_alloc->alloc_addr(1, _irq_number).error()) {
if (_irq_alloc.alloc_addr(1, _irq_number).error()) {
error("unavailable interrupt ", _irq_number, " requested");
throw Service_denied();
}

View File

@ -31,14 +31,8 @@ class Genode::Irq_session_component : public Rpc_object<Irq_session>,
friend class List<Irq_session_component>;
/*
* Noncopyable
*/
Irq_session_component(Irq_session_component const &);
Irq_session_component &operator = (Irq_session_component const &);
unsigned _irq_number;
Range_allocator *_irq_alloc;
Range_allocator &_irq_alloc;
Genode::uint8_t _kernel_object[sizeof(Kernel::User_irq)];
bool _is_msi;
addr_t _address, _value;
@ -55,7 +49,7 @@ class Genode::Irq_session_component : public Rpc_object<Irq_session>,
* \param irq_alloc platform-dependent IRQ allocator
* \param args session construction arguments
*/
Irq_session_component(Range_allocator *irq_alloc,
Irq_session_component(Range_allocator &irq_alloc,
const char *args);
/**

View File

@ -27,10 +27,7 @@
using namespace Kernel;
namespace Kernel
{
Cpu_pool * cpu_pool() { return unmanaged_singleton<Cpu_pool>(); }
}
Kernel::Cpu_pool &Kernel::cpu_pool() { return *unmanaged_singleton<Cpu_pool>(); }
/*************
@ -64,14 +61,14 @@ void Cpu_job::_activate_own_share() { _cpu->schedule(this); }
void Cpu_job::_deactivate_own_share()
{
assert(_cpu->id() == Cpu::executing_id());
_cpu->scheduler()->unready(this);
_cpu->scheduler().unready(this);
}
void Cpu_job::_yield()
{
assert(_cpu->id() == Cpu::executing_id());
_cpu->scheduler()->yield();
_cpu->scheduler().yield();
}
@ -79,7 +76,7 @@ void Cpu_job::_interrupt(unsigned const /* cpu_id */)
{
/* determine handling for specific interrupt */
unsigned irq_id;
if (pic()->take_request(irq_id))
if (pic().take_request(irq_id))
/* is the interrupt a cpu-local one */
if (!_cpu->interrupt(irq_id)) {
@ -91,20 +88,20 @@ void Cpu_job::_interrupt(unsigned const /* cpu_id */)
}
/* end interrupt request at controller */
pic()->finish_request();
pic().finish_request();
}
void Cpu_job::affinity(Cpu * const cpu)
void Cpu_job::affinity(Cpu &cpu)
{
_cpu = cpu;
_cpu->scheduler()->insert(this);
_cpu = &cpu;
_cpu->scheduler().insert(this);
}
void Cpu_job::quota(unsigned const q)
{
if (_cpu) { _cpu->scheduler()->quota(this, q); }
if (_cpu) { _cpu->scheduler().quota(this, q); }
else { Cpu_share::quota(q); }
}
@ -117,7 +114,7 @@ Cpu_job::Cpu_job(Cpu_priority const p, unsigned const q)
Cpu_job::~Cpu_job()
{
if (!_cpu) { return; }
_cpu->scheduler()->remove(this);
_cpu->scheduler().remove(this);
}
@ -127,13 +124,13 @@ Cpu_job::~Cpu_job()
extern "C" void idle_thread_main(void);
Cpu::Idle_thread::Idle_thread(Cpu * const cpu)
Cpu::Idle_thread::Idle_thread(Cpu &cpu)
: Thread("idle")
{
regs->ip = (addr_t)&idle_thread_main;
affinity(cpu);
Thread::_pd = core_pd();
Thread::_pd = &core_pd();
}
@ -199,7 +196,7 @@ Cpu::Cpu(unsigned const id, Pic & pic,
Inter_processor_work_list & global_work_list)
:
_id(id), _pic(pic), _timer(_id),
_scheduler(&_idle, _quota(), _fill()), _idle(this),
_scheduler(&_idle, _quota(), _fill()), _idle(*this),
_ipi_irq(*this), _timer_irq(_timer.interrupt_id(), *this),
_global_work_list(global_work_list)
{ _arch_init(); }

View File

@ -38,7 +38,7 @@ namespace Kernel
/**
* Return singleton of CPU pool
*/
Cpu_pool * cpu_pool();
Cpu_pool &cpu_pool();
}
@ -106,7 +106,7 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout
/**
* Construct idle context for CPU 'cpu'
*/
Idle_thread(Cpu * const cpu);
Idle_thread(Cpu &cpu);
};
@ -175,7 +175,7 @@ class Kernel::Cpu : public Genode::Cpu, private Irq::Pool, private Timeout
return *static_cast<Job *>(_scheduler.head())->helping_sink(); }
unsigned id() const { return _id; }
Cpu_scheduler * scheduler() { return &_scheduler; }
Cpu_scheduler &scheduler() { return _scheduler; }
time_t us_to_ticks(time_t const us) const { return _timer.us_to_ticks(us); };

View File

@ -68,7 +68,7 @@ class Kernel::Cpu_job : private Cpu_share
/**
* Return wether we are allowed to help job 'j' with our CPU-share
*/
bool _helping_possible(Cpu_job * const j) { return j->_cpu == _cpu; }
bool _helping_possible(Cpu_job const &j) const { return j._cpu == _cpu; }
public:
@ -100,7 +100,7 @@ class Kernel::Cpu_job : private Cpu_share
/**
* Link job to CPU 'cpu'
*/
void affinity(Cpu * const cpu);
void affinity(Cpu &cpu);
/**
* Set CPU quota of the job to 'q'
@ -124,7 +124,7 @@ class Kernel::Cpu_job : private Cpu_share
** Accessors **
***************/
void cpu(Cpu * const cpu) { _cpu = cpu; }
void cpu(Cpu &cpu) { _cpu = &cpu; }
Cpu_share &share() { return *this; }
};

View File

@ -41,7 +41,7 @@ void Cpu::trigger_ip_interrupt()
/* check whether there is still an IPI send */
if (_ipi_irq.pending) return;
pic()->send_ipi(_id);
pic().send_ipi(_id);
_ipi_irq.pending = true;
}

View File

@ -30,11 +30,11 @@ using namespace Kernel;
static_assert(sizeof(Genode::sizet_arithm_t) >= 2 * sizeof(size_t),
"Bad result type for size_t arithmetics.");
Pd * Kernel::core_pd() {
return &unmanaged_singleton<Genode::Core_platform_pd>()->kernel_pd(); }
Pd &Kernel::core_pd() {
return unmanaged_singleton<Genode::Core_platform_pd>()->kernel_pd(); }
Pic * Kernel::pic() { return unmanaged_singleton<Pic>(); }
Pic &Kernel::pic() { return *unmanaged_singleton<Pic>(); }
extern "C" void kernel_init();
@ -50,7 +50,7 @@ extern "C" void kernel_init()
Lock::Guard guard(data_lock());
/* initialize current cpu */
pool_ready = cpu_pool()->initialize(*pic());
pool_ready = cpu_pool().initialize(pic());
};
/* wait until all cpus have initialized their corresponding cpu object */

View File

@ -28,35 +28,35 @@
using namespace Kernel;
static inline void free_obj_id_ref(Pd *pd, void *ptr)
static inline void free_obj_id_ref(Pd &pd, void *ptr)
{
pd->platform_pd()->capability_slab().free(ptr, sizeof(Object_identity_reference));
pd.platform_pd().capability_slab().free(ptr, sizeof(Object_identity_reference));
}
void Ipc_node::copy_msg(Ipc_node * const sender)
void Ipc_node::copy_msg(Ipc_node &sender)
{
using namespace Genode;
using Reference = Object_identity_reference;
/* copy payload and set destination capability id */
*_utcb = *sender->_utcb;
_utcb->destination(sender->_capid);
*_utcb = *sender._utcb;
_utcb->destination(sender._capid);
/* translate capabilities */
for (unsigned i = 0; i < _rcv_caps; i++) {
capid_t id = sender->_utcb->cap_get(i);
capid_t id = sender._utcb->cap_get(i);
/* if there is no capability to send, just free the pre-allocation */
if (i >= sender->_utcb->cap_cnt()) {
if (i >= sender._utcb->cap_cnt()) {
free_obj_id_ref(pd(), _obj_id_ref_ptr[i]);
continue;
}
/* lookup the capability id within the caller's cap space */
Reference *oir = (id == cap_id_invalid())
? nullptr : sender->pd()->cap_tree().find(id);
? nullptr : sender.pd().cap_tree().find(id);
/* if the caller's capability is invalid, free the pre-allocation */
if (!oir) {
@ -69,8 +69,8 @@ void Ipc_node::copy_msg(Ipc_node * const sender)
Reference *dst_oir = oir->find(pd());
/* if it is not found, and the target is not core, create a reference */
if (!dst_oir && (pd() != core_pd())) {
dst_oir = oir->factory(_obj_id_ref_ptr[i], *pd());
if (!dst_oir && (&pd() != &core_pd())) {
dst_oir = oir->factory(_obj_id_ref_ptr[i], pd());
if (!dst_oir)
free_obj_id_ref(pd(), _obj_id_ref_ptr[i]);
} else /* otherwise free the pre-allocation */
@ -84,15 +84,15 @@ void Ipc_node::copy_msg(Ipc_node * const sender)
}
void Ipc_node::_receive_request(Ipc_node * const caller)
void Ipc_node::_receive_request(Ipc_node &caller)
{
copy_msg(caller);
_caller = caller;
_state = INACTIVE;
_caller = &caller;
_state = INACTIVE;
}
void Ipc_node::_receive_reply(Ipc_node * callee)
void Ipc_node::_receive_reply(Ipc_node &callee)
{
copy_msg(callee);
_state = INACTIVE;
@ -100,7 +100,7 @@ void Ipc_node::_receive_reply(Ipc_node * callee)
}
void Ipc_node::_announce_request(Ipc_node * const node)
void Ipc_node::_announce_request(Ipc_node &node)
{
/* directly receive request if we've awaited it */
if (_state == AWAIT_REQUEST) {
@ -110,7 +110,7 @@ void Ipc_node::_announce_request(Ipc_node * const node)
}
/* cannot receive yet, so queue request */
_request_queue.enqueue(node);
_request_queue.enqueue(&node);
}
@ -125,7 +125,7 @@ void Ipc_node::_cancel_request_queue()
void Ipc_node::_cancel_outbuf_request()
{
if (_callee) {
_callee->_announced_request_cancelled(this);
_callee->_announced_request_cancelled(*this);
_callee = nullptr;
}
}
@ -140,10 +140,10 @@ void Ipc_node::_cancel_inbuf_request()
}
void Ipc_node::_announced_request_cancelled(Ipc_node * const node)
void Ipc_node::_announced_request_cancelled(Ipc_node &node)
{
if (_caller == node) _caller = nullptr;
else _request_queue.remove(node);
if (_caller == &node) _caller = nullptr;
else _request_queue.remove(&node);
}
@ -160,36 +160,36 @@ void Ipc_node::_outbuf_request_cancelled()
bool Ipc_node::_helps_outbuf_dst() { return (_state == AWAIT_REPLY) && _help; }
void Ipc_node::_init(Genode::Native_utcb * utcb, Ipc_node * starter)
void Ipc_node::_init(Genode::Native_utcb &utcb, Ipc_node &starter)
{
_utcb = utcb;
_rcv_caps = starter->_utcb->cap_cnt();
Genode::Allocator &slab = pd()->platform_pd()->capability_slab();
_utcb = &utcb;
_rcv_caps = starter._utcb->cap_cnt();
Genode::Allocator &slab = pd().platform_pd().capability_slab();
for (unsigned i = 0; i < _rcv_caps; i++)
_obj_id_ref_ptr[i] = slab.alloc(sizeof(Object_identity_reference));
copy_msg(starter);
}
void Ipc_node::send_request(Ipc_node * const callee, capid_t capid, bool help,
void Ipc_node::send_request(Ipc_node &callee, capid_t capid, bool help,
unsigned rcv_caps)
{
if (_state != INACTIVE) {
Genode::error("IPC send request: bad state");
return;
}
Genode::Allocator &slab = pd()->platform_pd()->capability_slab();
Genode::Allocator &slab = pd().platform_pd().capability_slab();
for (unsigned i = 0; i < rcv_caps; i++)
_obj_id_ref_ptr[i] = slab.alloc(sizeof(Object_identity_reference));
_state = AWAIT_REPLY;
_callee = callee;
_callee = &callee;
_capid = capid;
_help = false;
_rcv_caps = rcv_caps;
/* announce request */
_callee->_announce_request(this);
_callee->_announce_request(*this);
_help = help;
}
@ -205,7 +205,7 @@ bool Ipc_node::await_request(unsigned rcv_caps)
Genode::error("IPC await request: bad state");
return true;
}
Genode::Allocator &slab = pd()->platform_pd()->capability_slab();
Genode::Allocator &slab = pd().platform_pd().capability_slab();
for (unsigned i = 0; i < rcv_caps; i++)
_obj_id_ref_ptr[i] = slab.alloc(sizeof(Object_identity_reference));
@ -213,7 +213,7 @@ bool Ipc_node::await_request(unsigned rcv_caps)
/* if anybody already announced a request receive it */
if (!_request_queue.empty()) {
_receive_request(_request_queue.dequeue());
_receive_request(*_request_queue.dequeue());
return true;
}
@ -227,7 +227,7 @@ void Ipc_node::send_reply()
{
/* reply to the last request if we have to */
if (_state == INACTIVE && _caller) {
_caller->_receive_reply(this);
_caller->_receive_reply(*this);
_caller = nullptr;
}
}

View File

@ -24,6 +24,7 @@
/* core includes */
#include <kernel/fifo.h>
#include <kernel/interface.h>
#include <assertion.h>
namespace Genode { class Msgbuf_base; };
@ -50,7 +51,7 @@ class Kernel::Ipc_node : private Ipc_node_queue::Element
AWAIT_REQUEST = 3,
};
void _init(Genode::Native_utcb * utcb, Ipc_node * callee);
void _init(Genode::Native_utcb &utcb, Ipc_node &callee);
private:
@ -70,22 +71,22 @@ class Kernel::Ipc_node : private Ipc_node_queue::Element
/* pre-allocation array for obkject identity references */
void * _obj_id_ref_ptr[Genode::Msgbuf_base::MAX_CAPS_PER_MSG];
inline void copy_msg(Ipc_node * const sender);
inline void copy_msg(Ipc_node &sender);
/**
* Buffer next request from request queue in 'r' to handle it
*/
void _receive_request(Ipc_node * const caller);
void _receive_request(Ipc_node &caller);
/**
* Receive a given reply if one is expected
*/
void _receive_reply(Ipc_node * callee);
void _receive_reply(Ipc_node &callee);
/**
* Insert 'r' into request queue, buffer it if we were waiting for it
*/
void _announce_request(Ipc_node * const node);
void _announce_request(Ipc_node &node);
/**
* Cancel all requests in request queue
@ -105,7 +106,7 @@ class Kernel::Ipc_node : private Ipc_node_queue::Element
/**
* A request 'r' in inbuf or request queue was cancelled by sender
*/
void _announced_request_cancelled(Ipc_node * const node);
void _announced_request_cancelled(Ipc_node &node);
/**
* The request in the outbuf was cancelled by receiver
@ -159,7 +160,7 @@ class Kernel::Ipc_node : private Ipc_node_queue::Element
* \param callee targeted IPC node
* \param help wether the request implies a helping relationship
*/
void send_request(Ipc_node * const callee, capid_t capid, bool help,
void send_request(Ipc_node &callee, capid_t capid, bool help,
unsigned rcv_caps);
/**
@ -202,8 +203,15 @@ class Kernel::Ipc_node : private Ipc_node_queue::Element
** Accessors **
***************/
Pd *pd() const { return _pd; }
Genode::Native_utcb *utcb() { return _utcb; }
Pd &pd() const
{
if (_pd)
return *_pd;
ASSERT_NEVER_CALLED;
}
Genode::Native_utcb *utcb() { return _utcb; }
};
#endif /* _CORE__KERNEL__IPC_NODE_H_ */

View File

@ -18,14 +18,14 @@
#include <pic.h>
void Kernel::Irq::disable() const { pic()->mask(_irq_nr); }
void Kernel::Irq::disable() const { pic().mask(_irq_nr); }
void Kernel::Irq::enable() const { pic()->unmask(_irq_nr, Cpu::executing_id()); }
void Kernel::Irq::enable() const { pic().unmask(_irq_nr, Cpu::executing_id()); }
Kernel::Irq::Pool * Kernel::User_irq::_pool()
Kernel::Irq::Pool &Kernel::User_irq::_pool()
{
static Irq::Pool p;
return &p;
return p;
}

View File

@ -128,7 +128,7 @@ class Kernel::User_irq : public Kernel::Irq, public Kernel::Object
/**
* Get map that provides all user interrupts by their kernel names
*/
static Irq::Pool * _pool();
static Irq::Pool &_pool();
public:
@ -136,7 +136,7 @@ class Kernel::User_irq : public Kernel::Irq, public Kernel::Object
* Construct object that signals interrupt 'irq' via signal 'context'
*/
User_irq(unsigned const irq, Signal_context &context)
: Irq(irq, *_pool()), _context(context) { disable(); }
: Irq(irq, _pool()), _context(context) { disable(); }
/**
* Destructor
@ -156,7 +156,7 @@ class Kernel::User_irq : public Kernel::Irq, public Kernel::Object
* Handle occurence of interrupt 'irq'
*/
static User_irq * object(unsigned const irq) {
return dynamic_cast<User_irq*>(_pool()->object(irq)); }
return dynamic_cast<User_irq*>(_pool().object(irq)); }
};
#endif /* _CORE__KERNEL__IRQ_H_ */

View File

@ -22,7 +22,7 @@ extern "C" void kernel()
{
using namespace Kernel;
Cpu & cpu = cpu_pool()->cpu(Cpu::executing_id());
Cpu &cpu = cpu_pool().cpu(Cpu::executing_id());
Cpu_job * new_job;
{

View File

@ -27,8 +27,8 @@ namespace Kernel {
class Pd;
Pd * core_pd();
Pic * pic();
Pd &core_pd();
Pic &pic();
}
#endif /* _CORE__KERNEL__KERNEL_H_ */

View File

@ -46,13 +46,13 @@ Object_identity::~Object_identity() { invalidate(); }
*******************************/
Object_identity_reference *
Object_identity_reference::find(Pd * pd)
Object_identity_reference::find(Pd &pd)
{
if (!_identity) return nullptr;
for (Object_identity_reference * oir = _identity->first();
oir; oir = oir->next())
if (pd == &(oir->_pd)) return oir;
if (&pd == &(oir->_pd)) return oir;
return nullptr;
}

View File

@ -160,7 +160,7 @@ class Kernel::Object_identity_reference
** Lookup functions **
**********************/
Object_identity_reference * find(Pd * pd);
Object_identity_reference * find(Pd &pd);
Object_identity_reference * find(capid_t capid);
};
@ -189,7 +189,7 @@ class Kernel::Core_object_identity : public Object_identity,
Core_object_identity(T & object)
: Object_identity(object),
Object_identity_reference(this, *core_pd()) { }
Object_identity_reference(this, core_pd()) { }
capid_t core_capid() { return capid(); }
};

View File

@ -47,14 +47,8 @@ class Kernel::Pd : public Kernel::Object
private:
/*
* Noncopyable
*/
Pd(Pd const &);
Pd &operator = (Pd const &);
Hw::Page_table * const _table;
Genode::Platform_pd * const _platform_pd;
Hw::Page_table &_table;
Genode::Platform_pd &_platform_pd;
Capid_allocator _capid_alloc { };
Object_identity_reference_tree _cap_tree { };
@ -68,10 +62,10 @@ class Kernel::Pd : public Kernel::Object
* \param table translation table of the PD
* \param platform_pd core object of the PD
*/
Pd(Hw::Page_table * const table,
Genode::Platform_pd * const platform_pd)
Pd(Hw::Page_table &table,
Genode::Platform_pd &platform_pd)
: _table(table), _platform_pd(platform_pd),
mmu_regs((addr_t)table)
mmu_regs((addr_t)&table)
{
capid_t invalid = _capid_alloc.alloc();
assert(invalid == cap_id_invalid());
@ -84,11 +78,11 @@ class Kernel::Pd : public Kernel::Object
}
static capid_t syscall_create(void * const dst,
Hw::Page_table * tt,
Genode::Platform_pd * const pd)
Hw::Page_table &tt,
Genode::Platform_pd &pd)
{
return call(call_id_new_pd(), (Call_arg)dst,
(Call_arg)tt, (Call_arg)pd);
(Call_arg)&tt, (Call_arg)&pd);
}
static void syscall_destroy(Pd * const pd) {
@ -105,10 +99,10 @@ class Kernel::Pd : public Kernel::Object
** Accessors **
***************/
Genode::Platform_pd * platform_pd() const { return _platform_pd; }
Hw::Page_table * translation_table() const { return _table; }
Capid_allocator & capid_alloc() { return _capid_alloc; }
Object_identity_reference_tree & cap_tree() { return _cap_tree; }
Genode::Platform_pd &platform_pd() { return _platform_pd; }
Hw::Page_table &translation_table() { return _table; }
Capid_allocator &capid_alloc() { return _capid_alloc; }
Object_identity_reference_tree &cap_tree() { return _cap_tree; }
};
#endif /* _CORE__KERNEL__PD_H_ */

View File

@ -41,7 +41,7 @@ using namespace Kernel;
Thread::Pd_update::Pd_update(Thread & caller, Pd & pd, unsigned cnt)
: caller(caller), pd(pd), cnt(cnt)
{
cpu_pool()->work_list().insert(&_le);
cpu_pool().work_list().insert(&_le);
caller._become_inactive(AWAITS_RESTART);
}
@ -57,7 +57,7 @@ Thread::Destroy::Destroy(Thread & caller, Thread & to_delete)
void Thread::Destroy::execute()
{
thread_to_destroy.~Thread();
cpu_pool()->executing_cpu().work_list().remove(&_le);
cpu_pool().executing_cpu().work_list().remove(&_le);
caller._restart();
}
@ -224,18 +224,18 @@ void Thread::_call_thread_quota()
void Thread::_call_start_thread()
{
/* lookup CPU */
Cpu & cpu = cpu_pool()->cpu(user_arg_2());
Cpu & cpu = cpu_pool().cpu(user_arg_2());
user_arg_0(0);
Thread * const thread = (Thread*) user_arg_1();
Thread &thread = *(Thread *)user_arg_1();
assert(thread->_state == AWAITS_START);
assert(thread._state == AWAITS_START);
thread->affinity(&cpu);
thread.affinity(cpu);
/* join protection domain */
thread->_pd = (Pd *) user_arg_3();
thread->Ipc_node::_init((Native_utcb *)user_arg_4(), this);
thread->_become_active();
thread._pd = (Pd *) user_arg_3();
thread.Ipc_node::_init(*(Native_utcb *)user_arg_4(), *this);
thread._become_active();
}
@ -268,17 +268,20 @@ void Thread::_call_stop_thread()
void Thread::_call_restart_thread()
{
if (!pd()) {
return; }
Thread *thread_ptr = pd().cap_tree().find<Thread>(user_arg_1());
Thread * const thread = pd()->cap_tree().find<Thread>(user_arg_1());
if (!thread || (!_core && (pd() != thread->pd()))) {
if (!thread_ptr)
return;
Thread &thread = *thread_ptr;
if (!_core && (&pd() != &thread.pd())) {
warning(*this, ": failed to lookup thread ", (unsigned)user_arg_1(),
" to restart it");
_die();
return;
}
user_arg_0(thread->_restart());
user_arg_0(thread._restart());
}
@ -386,7 +389,7 @@ void Thread::_call_timeout_max_us()
void Thread::timeout_triggered()
{
Signal_context * const c =
pd()->cap_tree().find<Signal_context>(_timeout_sigid);
pd().cap_tree().find<Signal_context>(_timeout_sigid);
if (!c || c->submit(1))
Genode::warning(*this, ": failed to submit timeout signal");
}
@ -394,7 +397,7 @@ void Thread::timeout_triggered()
void Thread::_call_send_request_msg()
{
Object_identity_reference * oir = pd()->cap_tree().find(user_arg_1());
Object_identity_reference * oir = pd().cap_tree().find(user_arg_1());
Thread * const dst = (oir) ? oir->object<Thread>() : nullptr;
if (!dst) {
Genode::warning(*this, ": cannot send to unknown recipient ",
@ -402,10 +405,10 @@ void Thread::_call_send_request_msg()
_become_inactive(AWAITS_IPC);
return;
}
bool const help = Cpu_job::_helping_possible(dst);
bool const help = Cpu_job::_helping_possible(*dst);
oir = oir->find(dst->pd());
Ipc_node::send_request(dst, oir ? oir->capid() : cap_id_invalid(),
Ipc_node::send_request(*dst, oir ? oir->capid() : cap_id_invalid(),
help, user_arg_2());
_state = AWAITS_IPC;
if (!help || !dst->own_share_active()) { _deactivate_used_shares(); }
@ -424,8 +427,8 @@ void Thread::_call_send_reply_msg()
void Thread::_call_pager()
{
/* override event route */
Thread * const t = (Thread*) user_arg_1();
t->_pager = pd()->cap_tree().find<Signal_context>(user_arg_2());
Thread &thread = *(Thread *)user_arg_1();
thread._pager = pd().cap_tree().find<Signal_context>(user_arg_2());
}
@ -441,7 +444,7 @@ void Thread::_call_await_signal()
return;
}
/* lookup receiver */
Signal_receiver * const r = pd()->cap_tree().find<Signal_receiver>(user_arg_1());
Signal_receiver * const r = pd().cap_tree().find<Signal_receiver>(user_arg_1());
if (!r) {
Genode::warning(*this, ": cannot await, unknown signal receiver ",
(unsigned)user_arg_1());
@ -460,15 +463,9 @@ void Thread::_call_await_signal()
void Thread::_call_cancel_next_await_signal()
{
/* kill the caller if he has no protection domain */
if (!pd()) {
error(*this, ": PD not set");
_die();
return;
}
/* kill the caller if the capability of the target thread is invalid */
Thread * const thread = pd()->cap_tree().find<Thread>(user_arg_1());
if (!thread || pd() != thread->pd()) {
Thread * const thread = pd().cap_tree().find<Thread>(user_arg_1());
if (!thread || (&pd() != &thread->pd())) {
error(*this, ": failed to lookup thread ", (unsigned)user_arg_1());
_die();
return;
@ -486,7 +483,7 @@ void Thread::_call_cancel_next_await_signal()
void Thread::_call_submit_signal()
{
/* lookup signal context */
Signal_context * const c = pd()->cap_tree().find<Signal_context>(user_arg_1());
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
if(!c) {
Genode::warning(*this, ": cannot submit unknown signal context");
user_arg_0(-1);
@ -506,7 +503,7 @@ void Thread::_call_submit_signal()
void Thread::_call_ack_signal()
{
/* lookup signal context */
Signal_context * const c = pd()->cap_tree().find<Signal_context>(user_arg_1());
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
if (!c) {
Genode::warning(*this, ": cannot ack unknown signal context");
return;
@ -520,7 +517,7 @@ void Thread::_call_ack_signal()
void Thread::_call_kill_signal_context()
{
/* lookup signal context */
Signal_context * const c = pd()->cap_tree().find<Signal_context>(user_arg_1());
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_1());
if (!c) {
Genode::warning(*this, ": cannot kill unknown signal context");
user_arg_0(-1);
@ -538,7 +535,7 @@ void Thread::_call_kill_signal_context()
void Thread::_call_new_irq()
{
Signal_context * const c = pd()->cap_tree().find<Signal_context>(user_arg_3());
Signal_context * const c = pd().cap_tree().find<Signal_context>(user_arg_3());
if (!c) {
Genode::warning(*this, ": invalid signal context for interrupt");
user_arg_0(-1);
@ -557,7 +554,7 @@ void Thread::_call_ack_irq() {
void Thread::_call_new_obj()
{
/* lookup thread */
Object_identity_reference * ref = pd()->cap_tree().find(user_arg_2());
Object_identity_reference * ref = pd().cap_tree().find(user_arg_2());
Thread * thread = ref ? ref->object<Thread>() : nullptr;
if (!thread ||
(static_cast<Core_object<Thread>*>(thread)->capid() != ref->capid())) {
@ -583,19 +580,19 @@ void Thread::_call_delete_obj()
void Thread::_call_ack_cap()
{
Object_identity_reference * oir = pd()->cap_tree().find(user_arg_1());
Object_identity_reference * oir = pd().cap_tree().find(user_arg_1());
if (oir) oir->remove_from_utcb();
}
void Thread::_call_delete_cap()
{
Object_identity_reference * oir = pd()->cap_tree().find(user_arg_1());
Object_identity_reference * oir = pd().cap_tree().find(user_arg_1());
if (!oir) return;
if (oir->in_utcb()) return;
destroy(pd()->platform_pd()->capability_slab(), oir);
destroy(pd().platform_pd().capability_slab(), oir);
}
@ -604,7 +601,7 @@ void Kernel::Thread::_call_update_pd()
Pd * const pd = (Pd *) user_arg_1();
unsigned cnt = 0;
cpu_pool()->for_each_cpu([&] (Cpu & cpu) {
cpu_pool().for_each_cpu([&] (Cpu & cpu) {
/* if a cpu needs to update increase the counter */
if (pd->update(cpu)) cnt++; });
@ -660,8 +657,8 @@ void Thread::_call()
case call_id_thread_pager(): _call_pager(); return;
case call_id_update_pd(): _call_update_pd(); return;
case call_id_new_pd():
_call_new<Pd>((Hw::Page_table *) user_arg_2(),
(Genode::Platform_pd *) user_arg_3());
_call_new<Pd>(*(Hw::Page_table *) user_arg_2(),
*(Genode::Platform_pd *) user_arg_3());
return;
case call_id_delete_pd(): _call_delete<Pd>(); return;
case call_id_new_signal_receiver(): _call_new<Signal_receiver>(); return;
@ -717,7 +714,7 @@ Thread::Thread(unsigned const priority, unsigned const quota,
void Thread::print(Genode::Output &out) const
{
Genode::print(out, (_pd) ? _pd->platform_pd()->label() : "?");
Genode::print(out, _pd ? _pd->platform_pd().label() : "?");
Genode::print(out, " -> ");
Genode::print(out, label());
}
@ -751,9 +748,9 @@ Core_thread::Core_thread()
regs->sp = (addr_t)&__initial_stack_base[0] + DEFAULT_STACK_SIZE;
regs->ip = (addr_t)&_core_start;
affinity(&cpu_pool()->primary_cpu());
affinity(cpu_pool().primary_cpu());
_utcb = utcb;
Thread::_pd = core_pd();
Thread::_pd = &core_pd();
_become_active();
}

View File

@ -18,7 +18,7 @@
void Kernel::Thread::_call_new_vm()
{
Signal_context * context =
pd()->cap_tree().find<Signal_context>(user_arg_4());
pd().cap_tree().find<Signal_context>(user_arg_4());
if (!context) {
user_arg_0(cap_id_invalid());
return;

View File

@ -65,6 +65,8 @@ class Genode::Kernel_object
T * kernel_object() { return reinterpret_cast<T*>(_data); }
Untyped_capability cap() { return _cap; }
/**
* Create the kernel object explicitely via this function
*/

View File

@ -69,7 +69,7 @@ void Pager_object::unresolved_page_fault_occurred()
Platform_thread * const pt = (Platform_thread *)badge();
if (pt && pt->pd())
warning("page fault, pager_object: pd='", pt->pd()->label(),
"' thread='", pt->label(), "' ", pt->kernel_object()->fault());
"' thread='", pt->label(), "' ", pt->fault_info());
}
void Pager_object::print(Output &out) const
@ -94,12 +94,10 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
** Pager_entrypoint **
**********************/
void Pager_entrypoint::dissolve(Pager_object * const o)
void Pager_entrypoint::dissolve(Pager_object &o)
{
if (o) {
Kernel::kill_signal_context(Capability_space::capid(o->cap()));
remove(o);
}
Kernel::kill_signal_context(Capability_space::capid(o.cap()));
remove(&o);
}
@ -109,9 +107,9 @@ Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
{ start(); }
Pager_capability Pager_entrypoint::manage(Pager_object * const o)
Pager_capability Pager_entrypoint::manage(Pager_object &o)
{
o->start_paging(kernel_object());
insert(o);
return reinterpret_cap_cast<Pager_object>(o->cap());
o.start_paging(kernel_object());
insert(&o);
return reinterpret_cap_cast<Pager_object>(o.cap());
}

View File

@ -208,12 +208,12 @@ class Genode::Pager_entrypoint : public Object_pool<Pager_object>,
/**
* Associate pager object 'obj' with entry point
*/
Pager_capability manage(Pager_object * const obj);
Pager_capability manage(Pager_object &obj);
/**
* Dissolve pager object 'obj' from entry point
*/
void dissolve(Pager_object * const obj);
void dissolve(Pager_object &obj);
/**********************

View File

@ -97,27 +97,27 @@ addr_t Platform::_rom_module_phys(addr_t virt)
Platform::Platform()
:
_io_mem_alloc(core_mem_alloc()),
_io_port_alloc(core_mem_alloc()),
_irq_alloc(core_mem_alloc())
_io_mem_alloc(&core_mem_alloc()),
_io_port_alloc(&core_mem_alloc()),
_irq_alloc(&core_mem_alloc())
{
struct Kernel_resource : Exception { };
_core_mem_alloc.virt_alloc()->add_range(Hw::Mm::core_heap().base,
Hw::Mm::core_heap().size);
_core_mem_alloc.virt_alloc().add_range(Hw::Mm::core_heap().base,
Hw::Mm::core_heap().size);
_core_virt_regions().for_each([this] (Hw::Memory_region const & r) {
_core_mem_alloc.virt_alloc()->remove_range(r.base, r.size); });
_core_mem_alloc.virt_alloc().remove_range(r.base, r.size); });
_boot_info().elf_mappings.for_each([this] (Hw::Mapping const & m) {
_core_mem_alloc.virt_alloc()->remove_range(m.virt(), m.size()); });
_core_mem_alloc.virt_alloc().remove_range(m.virt(), m.size()); });
_boot_info().ram_regions.for_each([this] (Hw::Memory_region const & region) {
_core_mem_alloc.phys_alloc()->add_range(region.base, region.size); });
_core_mem_alloc.phys_alloc().add_range(region.base, region.size); });
_init_io_port_alloc();
/* make all non-kernel interrupts available to the interrupt allocator */
for (unsigned i = 0; i < Kernel::Pic::NR_OF_IRQ; i++) {
bool kernel_resource = false;
Kernel::cpu_pool()->for_each_cpu([&] (Kernel::Cpu const &cpu) {
Kernel::cpu_pool().for_each_cpu([&] (Kernel::Cpu const &cpu) {
if (i == cpu.timer_interrupt_id()) {
kernel_resource = true;
}
@ -142,11 +142,11 @@ Platform::Platform()
unsigned const pages = 1;
size_t const log_size = pages << get_page_size_log2();
ram_alloc()->alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
ram_alloc().alloc_aligned(log_size, &phys_ptr, get_page_size_log2());
addr_t const phys_addr = reinterpret_cast<addr_t>(phys_ptr);
/* let one page free after the log buffer */
region_alloc()->alloc_aligned(log_size, &core_local_ptr, get_page_size_log2());
region_alloc().alloc_aligned(log_size, &core_local_ptr, get_page_size_log2());
addr_t const core_local_addr = reinterpret_cast<addr_t>(core_local_ptr);
map_local(phys_addr, core_local_addr, pages);
@ -169,16 +169,16 @@ Platform::Platform()
bool Genode::map_local(addr_t from_phys, addr_t to_virt, size_t num_pages,
Page_flags flags)
{
Platform_pd * pd = Kernel::core_pd()->platform_pd();
return pd->insert_translation(to_virt, from_phys,
num_pages * get_page_size(), flags);
Platform_pd &pd = Kernel::core_pd().platform_pd();
return pd.insert_translation(to_virt, from_phys,
num_pages * get_page_size(), flags);
}
bool Genode::unmap_local(addr_t virt_addr, size_t num_pages)
{
Platform_pd * pd = Kernel::core_pd()->platform_pd();
pd->flush(virt_addr, num_pages * get_page_size());
Platform_pd &pd = Kernel::core_pd().platform_pd();
pd.flush(virt_addr, num_pages * get_page_size());
return true;
}

View File

@ -32,6 +32,7 @@
#include <core_region_map.h>
#include <core_mem_alloc.h>
#include <translation_table.h>
#include <assertion.h>
namespace Genode {
class Address_space;
@ -48,7 +49,7 @@ class Genode::Platform : public Genode::Platform_generic
Phys_allocator _irq_alloc; /* IRQ allocator */
Rom_fs _rom_fs { }; /* ROM file system */
static Hw::Boot_info const & _boot_info();
static Hw::Boot_info const &_boot_info();
static Hw::Memory_region_array const & _core_virt_regions();
/**
@ -120,34 +121,23 @@ class Genode::Platform : public Genode::Platform_generic
** Platform_generic interface **
********************************/
Range_allocator * core_mem_alloc() {
return &_core_mem_alloc; }
Range_allocator * ram_alloc() {
return _core_mem_alloc.phys_alloc(); }
Range_allocator * region_alloc() {
return _core_mem_alloc.virt_alloc(); }
Range_allocator * io_mem_alloc() { return &_io_mem_alloc; }
Range_allocator * io_port_alloc() { return &_io_port_alloc; }
Range_allocator * irq_alloc() { return &_irq_alloc; }
addr_t vm_start() const { return Hw::Mm::user().base; }
size_t vm_size() const { return Hw::Mm::user().size; }
Rom_fs *rom_fs() { return &_rom_fs; }
Range_allocator &core_mem_alloc() override { return _core_mem_alloc; }
Range_allocator &ram_alloc() override { return _core_mem_alloc.phys_alloc(); }
Range_allocator &region_alloc() override { return _core_mem_alloc.virt_alloc(); }
Range_allocator &io_mem_alloc() override { return _io_mem_alloc; }
Range_allocator &io_port_alloc() override { return _io_port_alloc; }
Range_allocator &irq_alloc() override { return _irq_alloc; }
addr_t vm_start() const override { return Hw::Mm::user().base; }
size_t vm_size() const override { return Hw::Mm::user().size; }
Rom_fs &rom_fs() override { return _rom_fs; }
inline void wait_for_exit() {
while (1) { Kernel::stop_thread(); } };
bool supports_direct_unmap() const { return 1; }
Address_space * core_pd() { return nullptr; }
bool supports_direct_unmap() const override { return true; }
Address_space &core_pd() { ASSERT_NEVER_CALLED; }
Affinity::Space affinity_space() const {
Affinity::Space affinity_space() const override {
return Affinity::Space(_boot_info().cpus); }
/*

View File

@ -29,15 +29,15 @@ using Hw::Page_table;
** Hw::Address_space implementation **
**************************************/
Core_mem_allocator * Hw::Address_space::_cma() {
return static_cast<Core_mem_allocator*>(platform()->core_mem_alloc()); }
Core_mem_allocator &Hw::Address_space::_cma() {
return static_cast<Core_mem_allocator &>(platform().core_mem_alloc()); }
void * Hw::Address_space::_table_alloc()
void *Hw::Address_space::_table_alloc()
{
void * ret;
if (!_cma()->alloc_aligned(sizeof(Page_table), (void**)&ret,
Page_table::ALIGNM_LOG2).ok())
void * ret = nullptr;
if (!_cma().alloc_aligned(sizeof(Page_table), (void**)&ret,
Page_table::ALIGNM_LOG2).ok())
throw Insufficient_ram_quota();
return ret;
}
@ -53,7 +53,7 @@ bool Hw::Address_space::insert_translation(addr_t virt, addr_t phys,
_tt.insert_translation(virt, phys, size, flags, _tt_alloc);
return true;
} catch(Hw::Out_of_tables &) {
flush(platform()->vm_start(), platform()->vm_size());
flush(platform().vm_start(), platform().vm_size());
}
}
} catch(...) {
@ -86,16 +86,16 @@ Hw::Address_space::Address_space(Kernel::Pd & pd, Page_table & tt,
Hw::Address_space::Address_space(Kernel::Pd & pd)
: _tt(*construct_at<Page_table>(_table_alloc(), *((Page_table*)Hw::Mm::core_page_tables().base))),
_tt_phys((addr_t)_cma()->phys_addr(&_tt)),
_tt_phys((addr_t)_cma().phys_addr(&_tt)),
_tt_array(new (_cma()) Array([this] (void * virt) {
return (addr_t)_cma()->phys_addr(virt);})),
return (addr_t)_cma().phys_addr(virt);})),
_tt_alloc(_tt_array->alloc()),
_kernel_pd(pd) { }
Hw::Address_space::~Address_space()
{
flush(platform()->vm_start(), platform()->vm_size());
flush(platform().vm_start(), platform().vm_size());
destroy(_cma(), _tt_array);
destroy(_cma(), &_tt);
}
@ -121,18 +121,18 @@ void Cap_space::upgrade_slab(Allocator &alloc)
** Platform_pd implementation **
********************************/
bool Platform_pd::bind_thread(Platform_thread * t)
bool Platform_pd::bind_thread(Platform_thread &t)
{
/* is this the first and therefore main thread in this PD? */
bool main_thread = !_thread_associated;
_thread_associated = true;
t->join_pd(this, main_thread, Address_space::weak_ptr());
t.join_pd(this, main_thread, Address_space::weak_ptr());
return true;
}
void Platform_pd::unbind_thread(Platform_thread *t) {
t->join_pd(nullptr, false, Address_space::weak_ptr()); }
void Platform_pd::unbind_thread(Platform_thread &t) {
t.join_pd(nullptr, false, Address_space::weak_ptr()); }
void Platform_pd::assign_parent(Native_capability parent)
@ -144,15 +144,18 @@ void Platform_pd::assign_parent(Native_capability parent)
Platform_pd::Platform_pd(Page_table & tt,
Page_table::Allocator & alloc)
: Hw::Address_space(*kernel_object(), tt, alloc),
Kernel_object<Kernel::Pd>(false, (Page_table*)translation_table_phys(), this),
_label("core") { }
:
Hw::Address_space(*kernel_object(), tt, alloc),
Kernel_object<Kernel::Pd>(false, *(Page_table*)translation_table_phys(), *this),
_label("core")
{ }
Platform_pd::Platform_pd(Allocator *, char const *label)
: Hw::Address_space(*kernel_object()),
Kernel_object<Kernel::Pd>(true, (Page_table*)translation_table_phys(), this),
_label(label)
Platform_pd::Platform_pd(Allocator &, char const *label)
:
Hw::Address_space(*kernel_object()),
Kernel_object<Kernel::Pd>(true, *(Page_table*)translation_table_phys(), *this),
_label(label)
{
if (!_cap.valid()) {
error("failed to create kernel object");

View File

@ -76,11 +76,12 @@ class Hw::Address_space : public Genode::Address_space
Table & _tt; /* table virt addr */
Genode::addr_t _tt_phys; /* table phys addr */
Array * _tt_array = nullptr;
Table::Allocator & _tt_alloc; /* table allocator */
Table::Allocator & _tt_alloc; /* table allocator */
Kernel::Pd & _kernel_pd;
static inline Genode::Core_mem_allocator * _cma();
static inline void * _table_alloc();
static inline Genode::Core_mem_allocator &_cma();
static inline void *_table_alloc();
protected:
@ -193,7 +194,7 @@ class Genode::Platform_pd : public Hw::Address_space,
*
* \param label name of protection domain
*/
Platform_pd(Allocator * md_alloc, char const *label);
Platform_pd(Allocator &md_alloc, char const *label);
/**
* Destructor
@ -204,14 +205,14 @@ class Genode::Platform_pd : public Hw::Address_space,
using Cap_space::upgrade_slab;
/**
* Bind thread 't' to protection domain
* Bind thread to protection domain
*/
bool bind_thread(Platform_thread * t);
bool bind_thread(Platform_thread &);
/**
* Unbind thread 't' from protection domain
* Unbind thread from protection domain
*/
void unbind_thread(Platform_thread *t);
void unbind_thread(Platform_thread &);
/**
* Assign parent interface to protection domain

View File

@ -47,28 +47,27 @@ Platform_thread::~Platform_thread()
}
/* free UTCB */
core_env()->ram_session()->free(_utcb);
core_env().ram_session()->free(_utcb);
}
void Platform_thread::quota(size_t const quota) {
Kernel::thread_quota(kernel_object(), quota); }
Kernel::thread_quota(_kobj.kernel_object(), quota); }
Platform_thread::Platform_thread(const char * const label,
Native_utcb * utcb)
: Kernel_object<Kernel::Thread>(true, _label),
_pd(Kernel::core_pd()->platform_pd()),
_pager(nullptr),
_utcb_core_addr(utcb),
_utcb_pd_addr(utcb),
_main_thread(false)
Platform_thread::Platform_thread(Label const &label, Native_utcb &utcb)
:
_label(label),
_pd(&Kernel::core_pd().platform_pd()),
_pager(nullptr),
_utcb_core_addr(&utcb),
_utcb_pd_addr(&utcb),
_main_thread(false),
_kobj(true, _label.string())
{
strncpy(_label, label, LABEL_MAX_LEN);
/* create UTCB for a core thread */
void *utcb_phys;
if (!platform()->ram_alloc()->alloc(sizeof(Native_utcb), &utcb_phys)) {
if (!platform().ram_alloc().alloc(sizeof(Native_utcb), &utcb_phys)) {
error("failed to allocate UTCB");
throw Out_of_ram();
}
@ -77,27 +76,26 @@ Platform_thread::Platform_thread(const char * const label,
}
Platform_thread::Platform_thread(size_t const quota,
const char * const label,
unsigned const virt_prio,
Affinity::Location location,
addr_t const utcb)
: Kernel_object<Kernel::Thread>(true, _priority(virt_prio), quota, _label),
_pd(nullptr),
_pager(nullptr),
_utcb_pd_addr((Native_utcb *)utcb),
_main_thread(false)
Platform_thread::Platform_thread(size_t const quota,
Label const &label,
unsigned const virt_prio,
Affinity::Location const location,
addr_t const utcb)
:
_label(label),
_pd(nullptr),
_pager(nullptr),
_utcb_pd_addr((Native_utcb *)utcb),
_main_thread(false),
_kobj(true, _priority(virt_prio), quota, _label.string())
{
strncpy(_label, label, LABEL_MAX_LEN);
try {
_utcb = core_env()->ram_session()->alloc(sizeof(Native_utcb),
CACHED);
_utcb = core_env().ram_session()->alloc(sizeof(Native_utcb), CACHED);
} catch (...) {
error("failed to allocate UTCB");
throw Out_of_ram();
}
_utcb_core_addr = (Native_utcb *)core_env()->rm_session()->attach(_utcb);
_utcb_core_addr = (Native_utcb *)core_env().rm_session()->attach(_utcb);
affinity(location);
}
@ -151,12 +149,12 @@ int Platform_thread::start(void * const ip, void * const sp)
}
return 0;
};
if (core_env()->entrypoint()->apply(_utcb, lambda)) return -1;
if (core_env().entrypoint().apply(_utcb, lambda)) return -1;
}
/* initialize thread registers */
kernel_object()->regs->ip = reinterpret_cast<addr_t>(ip);
kernel_object()->regs->sp = reinterpret_cast<addr_t>(sp);
_kobj.kernel_object()->regs->ip = reinterpret_cast<addr_t>(ip);
_kobj.kernel_object()->regs->sp = reinterpret_cast<addr_t>(sp);
/* start executing new thread */
if (!_pd) {
@ -167,49 +165,54 @@ int Platform_thread::start(void * const ip, void * const sp)
unsigned const cpu =
_location.valid() ? _location.xpos() : Cpu::primary_id();
Native_utcb * utcb = Thread::myself()->utcb();
Native_utcb &utcb = *Thread::myself()->utcb();
/* reset capability counter */
utcb->cap_cnt(0);
utcb->cap_add(Capability_space::capid(_cap));
utcb.cap_cnt(0);
utcb.cap_add(Capability_space::capid(_kobj.cap()));
if (_main_thread) {
utcb->cap_add(Capability_space::capid(_pd->parent()));
utcb->cap_add(Capability_space::capid(_utcb));
utcb.cap_add(Capability_space::capid(_pd->parent()));
utcb.cap_add(Capability_space::capid(_utcb));
}
Kernel::start_thread(kernel_object(), cpu, &_pd->kernel_pd(),
Kernel::start_thread(_kobj.kernel_object(), cpu, &_pd->kernel_pd(),
_utcb_core_addr);
return 0;
}
void Platform_thread::pager(Pager_object * const pager)
void Platform_thread::pager(Pager_object &pager)
{
using namespace Kernel;
thread_pager(kernel_object(), pager ? Capability_space::capid(pager->cap())
: cap_id_invalid());
_pager = pager;
thread_pager(_kobj.kernel_object(), Capability_space::capid(pager.cap()));
_pager = &pager;
}
Genode::Pager_object * Platform_thread::pager() { return _pager; }
Genode::Pager_object &Platform_thread::pager()
{
if (_pager)
return *_pager;
ASSERT_NEVER_CALLED;
}
Thread_state Platform_thread::state()
{
Thread_state_base bstate(*kernel_object()->regs);
Thread_state_base bstate(*_kobj.kernel_object()->regs);
return Thread_state(bstate);
}
void Platform_thread::state(Thread_state thread_state)
{
Cpu_state * cstate = static_cast<Cpu_state *>(&*kernel_object()->regs);
Cpu_state * cstate = static_cast<Cpu_state *>(&*_kobj.kernel_object()->regs);
*cstate = static_cast<Cpu_state>(thread_state);
}
void Platform_thread::restart()
{
Kernel::restart_thread(Capability_space::capid(_cap));
Kernel::restart_thread(Capability_space::capid(_kobj.cap()));
}

View File

@ -41,7 +41,7 @@ namespace Genode {
/**
* Userland interface for the management of kernel thread-objects
*/
class Platform_thread : public Kernel_object<Kernel::Thread>
class Platform_thread : Noncopyable
{
/*
* Noncopyable
@ -49,15 +49,15 @@ namespace Genode {
Platform_thread(Platform_thread const &);
Platform_thread &operator = (Platform_thread const &);
enum { LABEL_MAX_LEN = 32 };
typedef String<32> Label;
Label const _label;
Platform_pd * _pd;
Weak_ptr<Address_space> _address_space { };
Pager_object * _pager;
Native_utcb * _utcb_core_addr { }; /* UTCB addr in core */
Native_utcb * _utcb_pd_addr; /* UTCB addr in pd */
Ram_dataspace_capability _utcb { }; /* UTCB dataspace */
char _label[LABEL_MAX_LEN];
/*
* Wether this thread is the main thread of a program.
@ -71,6 +71,8 @@ namespace Genode {
Affinity::Location _location { };
Kernel_object<Kernel::Thread> _kobj;
/**
* Common construction part
*/
@ -95,7 +97,7 @@ namespace Genode {
* \param label debugging label
* \param utcb virtual address of UTCB within core
*/
Platform_thread(const char * const label, Native_utcb * utcb);
Platform_thread(Label const &label, Native_utcb &utcb);
/**
* Constructor for threads outside of core
@ -105,7 +107,7 @@ namespace Genode {
* \param virt_prio unscaled processor-scheduling priority
* \param utcb core local pointer to userland stack
*/
Platform_thread(size_t const quota, const char * const label,
Platform_thread(size_t const quota, Label const &label,
unsigned const virt_prio, Affinity::Location,
addr_t const utcb);
@ -114,6 +116,11 @@ namespace Genode {
*/
~Platform_thread();
/**
* Return information about current fault
*/
Kernel::Thread_fault fault_info() { return _kobj.kernel_object()->fault(); }
/**
* Join a protection domain
*
@ -124,7 +131,7 @@ namespace Genode {
* This function has no effect when called more twice for a
* given thread.
*/
void join_pd(Platform_pd * const pd, bool const main_thread,
void join_pd(Platform_pd *const pd, bool const main_thread,
Weak_ptr<Address_space> address_space);
/**
@ -140,7 +147,7 @@ namespace Genode {
/**
* Pause this thread
*/
void pause() { Kernel::pause_thread(kernel_object()); }
void pause() { Kernel::pause_thread(_kobj.kernel_object()); }
/**
* Enable/disable single stepping
@ -150,13 +157,13 @@ namespace Genode {
/**
* Resume this thread
*/
void resume() { Kernel::resume_thread(kernel_object()); }
void resume() { Kernel::resume_thread(_kobj.kernel_object()); }
/**
* Cancel currently blocking operation
*/
void cancel_blocking() {
Kernel::cancel_thread_blocking(kernel_object()); }
Kernel::cancel_thread_blocking(_kobj.kernel_object()); }
/**
* Set CPU quota of the thread to 'quota'
@ -205,11 +212,11 @@ namespace Genode {
** Accessors **
***************/
char const * label() const { return _label; };
Label label() const { return _label; };
void pager(Pager_object * const pager);
void pager(Pager_object &pager);
Pager_object * pager();
Pager_object &pager();
Platform_pd * pd() const { return _pd; }

View File

@ -3,9 +3,6 @@
* \author Martin Stein
* \author Stefan Kalkowski
* \date 2012-02-12
*
* TODO: this file is almost identical to
* base-okl4/src/core/ram_dataspace_support.cc, we should merge them
*/
/*
@ -25,16 +22,16 @@
using namespace Genode;
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component *) { }
void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &) { }
void Ram_dataspace_factory::_clear_ds (Dataspace_component * ds)
void Ram_dataspace_factory::_clear_ds (Dataspace_component &ds)
{
size_t page_rounded_size = (ds->size() + get_page_size() - 1) & get_page_mask();
size_t page_rounded_size = (ds.size() + get_page_size() - 1) & get_page_mask();
/* allocate range in core's virtual address space */
void *virt_addr;
if (!platform()->region_alloc()->alloc(page_rounded_size, &virt_addr)) {
if (!platform().region_alloc().alloc(page_rounded_size, &virt_addr)) {
error("could not allocate virtual address range in core of size ",
page_rounded_size);
return;
@ -42,7 +39,7 @@ void Ram_dataspace_factory::_clear_ds (Dataspace_component * ds)
/* map the dataspace's physical pages to corresponding virtual addresses */
size_t num_pages = page_rounded_size >> get_page_size_log2();
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages)) {
if (!map_local(ds.phys_addr(), (addr_t)virt_addr, num_pages)) {
error("core-local memory mapping failed");
return;
}
@ -51,7 +48,7 @@ void Ram_dataspace_factory::_clear_ds (Dataspace_component * ds)
memset(virt_addr, 0, page_rounded_size);
/* uncached dataspaces need to be flushed from the data cache */
if (ds->cacheability() != CACHED)
if (ds.cacheability() != CACHED)
Kernel::update_data_region((addr_t)virt_addr, page_rounded_size);
/* invalidate the dataspace memory from instruction cache */
@ -62,6 +59,6 @@ void Ram_dataspace_factory::_clear_ds (Dataspace_component * ds)
error("could not unmap core-local address range at ", virt_addr);
/* free core's virtual address space */
platform()->region_alloc()->free(virt_addr, page_rounded_size);
platform().region_alloc().free(virt_addr, page_rounded_size);
}

View File

@ -50,7 +50,7 @@ void Pager_entrypoint::entry()
continue;
}
_fault = pt->kernel_object()->fault();
_fault = pt->fault_info();
/* try to resolve fault directly via local region managers */
if (po->pager(*this)) continue;

View File

@ -54,7 +54,7 @@ void Thread::exception(Cpu & cpu)
void Kernel::Thread::_call_update_data_region()
{
Cpu & cpu = cpu_pool()->cpu(Cpu::executing_id());
Cpu &cpu = cpu_pool().cpu(Cpu::executing_id());
/*
* FIXME: If the caller is not a core thread, the kernel operates in a
@ -78,7 +78,7 @@ void Kernel::Thread::_call_update_data_region()
void Kernel::Thread::_call_update_instr_region()
{
Cpu & cpu = cpu_pool()->cpu(Cpu::executing_id());
Cpu &cpu = cpu_pool().cpu(Cpu::executing_id());
/*
* FIXME: If the caller is not a core thread, the kernel operates in a
@ -112,7 +112,7 @@ void Kernel::Thread::Pd_update::execute() { };
void Thread::proceed(Cpu & cpu)
{
cpu.switch_to(*regs, pd()->mmu_regs);
cpu.switch_to(*regs, pd().mmu_regs);
regs->cpu_exception = cpu.stack_start();
kernel_to_user_context_switch((static_cast<Cpu::Context*>(&*regs)),

View File

@ -22,10 +22,13 @@ using namespace Kernel;
Kernel::Vm::Vm(void * const state,
Kernel::Signal_context * const context,
void * const /* table */)
: Cpu_job(Cpu_priority::MIN, 0),
_state((Genode::Vm_state * const)state),
_context(context), _table(0) {
affinity(&cpu_pool()->primary_cpu()); }
:
Cpu_job(Cpu_priority::MIN, 0),
_state((Genode::Vm_state * const)state),
_context(context), _table(0)
{
affinity(cpu_pool().primary_cpu());
}
Kernel::Vm::~Vm() {}
@ -58,10 +61,10 @@ void Vm::proceed(Cpu & cpu)
{
unsigned const irq = _state->irq_injection;
if (irq) {
if (pic()->secure(irq)) {
if (pic().secure(irq)) {
Genode::warning("Refuse to inject secure IRQ into VM");
} else {
pic()->trigger(irq);
pic().trigger(irq);
_state->irq_injection = 0;
}
}

View File

@ -34,7 +34,7 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint *ds_ep,
: _ds_ep(ds_ep), _ds(_ds_size(), _alloc_ds(ram_quota), UNCACHED, true, 0),
_ds_cap(static_cap_cast<Dataspace>(_ds_ep->manage(&_ds)))
{
_ds.assign_core_local_addr(core_env()->rm_session()->attach(_ds_cap));
_ds.assign_core_local_addr(core_env().rm_session()->attach(_ds_cap));
}
@ -44,6 +44,6 @@ Vm_session_component::~Vm_session_component()
_ds_ep->dissolve(&_ds);
/* free region in allocator */
core_env()->rm_session()->detach(_ds.core_local_addr());
platform()->ram_alloc()->free((void*)_ds.phys_addr());
core_env().rm_session()->detach(_ds.core_local_addr());
platform().ram_alloc().free((void*)_ds.phys_addr());
}

View File

@ -58,6 +58,8 @@ class Genode::Vm_session_component : public Genode::Rpc_object<Genode::Vm_sessi
size_t ram_quota);
~Vm_session_component();
using Rpc_object<Vm_session>::cap;
/**************************
** Vm session interface **

View File

@ -58,7 +58,7 @@ struct Kernel::Vm_irq : Kernel::Irq
{
Vm_irq(unsigned const irq)
:
Kernel::Irq(irq, cpu_pool()->executing_cpu().irq_pool())
Kernel::Irq(irq, cpu_pool().executing_cpu().irq_pool())
{ }
/**
@ -66,7 +66,7 @@ struct Kernel::Vm_irq : Kernel::Irq
*/
void occurred()
{
Cpu_job & job = cpu_pool()->executing_cpu().scheduled_job();
Cpu_job & job = cpu_pool().executing_cpu().scheduled_job();
Vm *vm = dynamic_cast<Vm*>(&job);
if (!vm)
Genode::error("VM timer interrupt while VM is not runnning!");
@ -213,7 +213,7 @@ Kernel::Vm::Vm(void * const state,
_context(context),
_table(table)
{
affinity(&cpu_pool()->primary_cpu());
affinity(cpu_pool().primary_cpu());
Virtual_pic::pic().irq.enable();
vt_host_context.sp = _cpu->stack_start();

View File

@ -22,14 +22,14 @@
using namespace Genode;
static Core_mem_allocator * cma() {
return static_cast<Core_mem_allocator*>(platform()->core_mem_alloc()); }
static Core_mem_allocator & cma() {
return static_cast<Core_mem_allocator&>(platform().core_mem_alloc()); }
void Vm_session_component::exception_handler(Signal_context_capability handler)
{
if (!create((void*)_ds.core_local_addr(), Capability_space::capid(handler),
cma()->phys_addr(&_table)))
cma().phys_addr(&_table)))
Genode::warning("Cannot instantiate vm kernel object, invalid signal context?");
}
@ -84,8 +84,8 @@ void * Vm_session_component::_alloc_table()
{
void * table;
/* get some aligned space for the translation table */
if (!cma()->alloc_aligned(sizeof(Table), (void**)&table,
Table::ALIGNM_LOG2).ok()) {
if (!cma().alloc_aligned(sizeof(Table), (void**)&table,
Table::ALIGNM_LOG2).ok()) {
error("failed to allocate kernel object");
throw Insufficient_ram_quota();
}
@ -99,9 +99,9 @@ Vm_session_component::Vm_session_component(Rpc_entrypoint *ds_ep,
_ds_cap(static_cap_cast<Dataspace>(_ds_ep->manage(&_ds))),
_table(*construct_at<Table>(_alloc_table())),
_table_array(*(new (cma()) Array([this] (void * virt) {
return (addr_t)cma()->phys_addr(virt);})))
return (addr_t)cma().phys_addr(virt);})))
{
_ds.assign_core_local_addr(core_env()->rm_session()->attach(_ds_cap));
_ds.assign_core_local_addr(core_env().rm_session()->attach(_ds_cap));
}
@ -111,10 +111,10 @@ Vm_session_component::~Vm_session_component()
_ds_ep->dissolve(&_ds);
/* free region in allocator */
core_env()->rm_session()->detach(_ds.core_local_addr());
platform()->ram_alloc()->free((void*)_ds.phys_addr());
core_env().rm_session()->detach(_ds.core_local_addr());
platform().ram_alloc().free((void*)_ds.phys_addr());
/* free guest-to-host page tables */
destroy(platform()->core_mem_alloc(), &_table);
destroy(platform()->core_mem_alloc(), &_table_array);
destroy(platform().core_mem_alloc(), &_table);
destroy(platform().core_mem_alloc(), &_table_array);
}

View File

@ -67,6 +67,8 @@ class Genode::Vm_session_component : public Genode::Rpc_object<Genode::Vm_sessio
size_t ram_quota);
~Vm_session_component();
using Rpc_object<Vm_session>::cap;
/**************************
** Vm session interface **

View File

@ -22,8 +22,8 @@ addr_t Vm_session_component::_alloc_ds(size_t &ram_quota)
{
addr_t addr;
if (_ds_size() > ram_quota ||
platform()->ram_alloc()->alloc_aligned(_ds_size(), (void**)&addr,
get_page_size_log2()).error())
platform().ram_alloc().alloc_aligned(_ds_size(), (void**)&addr,
get_page_size_log2()).error())
throw Insufficient_ram_quota();
ram_quota -= _ds_size();
return addr;

View File

@ -28,9 +28,9 @@ extern Genode::addr_t hypervisor_exception_vector;
/*
* Add ARM virtualization specific vm service
*/
void Genode::platform_add_local_services(Rpc_entrypoint *ep,
Sliced_heap *sh,
Registry<Service> *services)
void Genode::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sh,
Registry<Service> &services)
{
using namespace Genode;
@ -39,5 +39,5 @@ void Genode::platform_add_local_services(Rpc_entrypoint *ep,
Hw::PAGE_FLAGS_KERN_TEXT);
static Vm_root vm_root(ep, sh);
static Core_service<Vm_session_component> vm_service(*services, vm_root);
static Core_service<Vm_session_component> vm_service(services, vm_root);
}

View File

@ -27,14 +27,14 @@ extern int monitor_mode_exception_vector;
/*
* Add TrustZone specific vm service
*/
void Genode::platform_add_local_services(Rpc_entrypoint *ep,
Sliced_heap *sliced_heap,
Registry<Service> *local_services)
void Genode::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sliced_heap,
Registry<Service> &local_services)
{
static addr_t const phys_base =
Platform::core_phys_addr((addr_t)&monitor_mode_exception_vector);
map_local(phys_base, Hw::Mm::system_exception_vector().base, 1,
Hw::PAGE_FLAGS_KERN_TEXT);
static Vm_root vm_root(ep, sliced_heap);
static Core_service<Vm_session_component> vm_service(*local_services, vm_root);
static Core_service<Vm_session_component> vm_service(local_services, vm_root);
}

View File

@ -25,7 +25,7 @@ void Kernel::Thread::Pd_update::execute()
/* if this is the last cpu, wake up the caller thread */
if (--cnt == 0) {
cpu_pool()->work_list().remove(&_le);
cpu_pool().work_list().remove(&_le);
caller._restart();
}
};
@ -39,7 +39,7 @@ void Kernel::Thread::_call_update_instr_region() { }
void Kernel::Thread::proceed(Cpu & cpu)
{
cpu.switch_to(*regs, pd()->mmu_regs);
cpu.switch_to(*regs, pd().mmu_regs);
asm volatile("mov %0, %%rsp \n"
"popq %%r8 \n"

View File

@ -40,7 +40,7 @@ void Thread::exception(Cpu & cpu)
}
if (regs->trapno >= Cpu::Context::INTERRUPTS_START &&
regs->trapno <= Cpu::Context::INTERRUPTS_END) {
pic()->irq_occurred(regs->trapno);
pic().irq_occurred(regs->trapno);
_interrupt(cpu.id());
return;
}

View File

@ -27,7 +27,7 @@ Kernel::Vm::Vm(void * const state, Kernel::Signal_context * const context,
_context(context),
_table(nullptr)
{
affinity(&cpu_pool()->primary_cpu());
affinity(cpu_pool().primary_cpu());
}
@ -44,7 +44,7 @@ void Kernel::Vm::exception(Cpu & cpu)
if (_state->trapno >= Genode::Cpu_state::INTERRUPTS_START &&
_state->trapno <= Genode::Cpu_state::INTERRUPTS_END) {
pic()->irq_occurred(_state->trapno);
pic().irq_occurred(_state->trapno);
_interrupt(cpu.id());
_context->submit(1);
return;

View File

@ -24,15 +24,15 @@
/*
* Add I/O port service and virtualization specific vm service
*/
void Genode::platform_add_local_services(Rpc_entrypoint *ep,
Sliced_heap *sh,
Registry<Service> *services)
void Genode::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sliced_heap,
Registry<Service> &services)
{
static Vm_root vm_root(ep, sh);
static Core_service<Vm_session_component> vm_ls(*services, vm_root);
static Vm_root vm_root(ep, sliced_heap);
static Core_service<Vm_session_component> vm_ls(services, vm_root);
static Io_port_root io_port_root(core_env()->pd_session(),
platform()->io_port_alloc(), sh);
static Core_service<Io_port_session_component> io_port_ls(*services,
static Io_port_root io_port_root(*core_env().pd_session(),
platform().io_port_alloc(), sliced_heap);
static Core_service<Io_port_session_component> io_port_ls(services,
io_port_root);
}

View File

@ -42,6 +42,8 @@ class Genode::Vm_session_component
Vm_session_component(Rpc_entrypoint*, size_t) : _state() { }
~Vm_session_component() { }
using Genode::Rpc_object<Genode::Vm_session>::cap;
/**************************
** Vm session interface **

View File

@ -31,14 +31,14 @@ void Platform::_init_additional()
void *virt_ptr = nullptr;
const char *rom_name = "platform_info";
if (!ram_alloc()->alloc(get_page_size(), &phys_ptr)) {
if (!ram_alloc().alloc(get_page_size(), &phys_ptr)) {
error("could not setup platform_info ROM - ram allocation error");
return;
}
if (!region_alloc()->alloc(rom_size, &virt_ptr)) {
if (!region_alloc().alloc(rom_size, &virt_ptr)) {
error("could not setup platform_info ROM - region allocation error");
ram_alloc()->free(phys_ptr);
ram_alloc().free(phys_ptr);
return;
}
@ -47,8 +47,8 @@ void Platform::_init_additional()
if (!map_local(phys_addr, virt_addr, pages, Hw::PAGE_FLAGS_KERN_DATA)) {
error("could not setup platform_info ROM - map error");
region_alloc()->free(virt_ptr);
ram_alloc()->free(phys_ptr);
region_alloc().free(virt_ptr);
ram_alloc().free(phys_ptr);
return;
}
@ -93,7 +93,7 @@ void Platform::_init_additional()
return;
}
region_alloc()->free(virt_ptr);
region_alloc().free(virt_ptr);
_rom_fs.insert(
new (core_mem_alloc()) Rom_module(phys_addr, rom_size, rom_name));
@ -102,7 +102,7 @@ void Platform::_init_additional()
void Platform::setup_irq_mode(unsigned irq_number, unsigned trigger,
unsigned polarity) {
Kernel::pic()->ioapic.setup_irq_mode(irq_number, trigger, polarity); }
Kernel::pic().ioapic.setup_irq_mode(irq_number, trigger, polarity); }
bool Platform::get_msi_params(addr_t, addr_t &, addr_t &, unsigned &) {

View File

@ -51,15 +51,15 @@ void Thread::cancel_blocking()
void Thread::_deinit_platform_thread()
{
/* destruct platform thread */
destroy(platform()->core_mem_alloc(), native_thread().platform_thread);
destroy(platform().core_mem_alloc(), native_thread().platform_thread);
}
void Thread::_init_platform_thread(size_t, Type type)
{
if (type == NORMAL) {
native_thread().platform_thread = new (platform()->core_mem_alloc())
Platform_thread(_stack->name().string(), &_stack->utcb());
native_thread().platform_thread = new (platform().core_mem_alloc())
Platform_thread(_stack->name(), _stack->utcb());
return;
}

View File

@ -38,15 +38,15 @@ namespace Genode {
{
private:
Filename _fname { }; /* filename for mmap */
size_t _size { 0 }; /* size of dataspace in bytes */
addr_t _addr { 0 }; /* meaningless on linux */
int _fd { -1 }; /* file descriptor */
bool _writable { false }; /* false if read-only */
Filename _fname { }; /* filename for mmap */
size_t const _size; /* size of dataspace in bytes */
addr_t const _addr; /* meaningless on linux */
int _fd { -1 }; /* file descriptor */
bool const _writable; /* false if read-only */
/* Holds the dataspace owner if a distinction between owner and
* others is necessary on the dataspace, otherwise it is 0 */
Dataspace_owner * _owner;
Dataspace_owner const * const _owner;
static Filename _file_name(const char *args);
size_t _file_size();
@ -72,7 +72,7 @@ namespace Genode {
* Default constructor returns invalid dataspace
*/
Dataspace_component()
: _size(0), _addr(0), _fd(-1), _writable(false), _owner(0) { }
: _size(0), _addr(0), _fd(-1), _writable(false), _owner(nullptr) { }
/**
* This constructor is only provided for compatibility
@ -81,7 +81,8 @@ namespace Genode {
Dataspace_component(size_t size, addr_t, addr_t phys_addr,
Cache_attribute, bool, Dataspace_owner *_owner)
:
_size(size), _addr(phys_addr), _fd(-1), _owner(_owner)
_size(size), _addr(phys_addr), _fd(-1), _writable(false),
_owner(_owner)
{
warning("Should only be used for IOMEM and not within Linux.");
_fname.buf[0] = 0;
@ -105,20 +106,21 @@ namespace Genode {
/**
* Check if dataspace is owned by a specified object
*/
bool owner(Dataspace_owner const *o) const { return _owner == o; }
bool owner(Dataspace_owner const &o) const { return _owner == &o; }
/**
* Detach dataspace from all rm sessions.
*/
void detach_from_rm_sessions() { }
/*************************
** Dataspace interface **
*************************/
size_t size() { return _size; }
addr_t phys_addr() { return _addr; }
bool writable() { return _writable; }
size_t size() override { return _size; }
addr_t phys_addr() override { return _addr; }
bool writable() override { return _writable; }
/****************************************

View File

@ -40,9 +40,9 @@ namespace Genode {
* particular MMIO region base, size and
* caching demands
*/
Io_mem_session_component(Range_allocator *io_mem_alloc,
Range_allocator *ram_alloc,
Rpc_entrypoint *ds_ep,
Io_mem_session_component(Range_allocator &io_mem_alloc,
Range_allocator &ram_alloc,
Rpc_entrypoint &ds_ep,
const char *args);
/**

View File

@ -34,7 +34,7 @@ class Genode::Irq_session_component : public Rpc_object<Irq_session>,
/**
* Constructor
*/
Irq_session_component(Range_allocator *, const char *) { }
Irq_session_component(Range_allocator &, const char *) { }
/**
* Destructor
@ -49,8 +49,9 @@ class Genode::Irq_session_component : public Rpc_object<Irq_session>,
void ack_irq() override { }
void sigh(Signal_context_capability) override { }
Info info() override {
return { .type = Genode::Irq_session::Info::Type::INVALID,
.address = 0, .value = 0 }; }
return { .type = Genode::Irq_session::Info::Type::INVALID,
.address = 0,
.value = 0 }; }
};
#endif /* _CORE__INCLUDE__IRQ_SESSION_COMPONENT_H_ */

View File

@ -52,9 +52,9 @@ namespace Genode {
auto apply(Pager_capability, FUNC f) -> decltype(f(nullptr)) {
return f(nullptr); }
Pager_capability manage(Pager_object *) { return Pager_capability(); }
Pager_capability manage(Pager_object &) { return Pager_capability(); }
void dissolve(Pager_object *) { }
void dissolve(Pager_object &) { }
};
}

View File

@ -22,6 +22,7 @@
#include <platform_pd.h>
#include <platform_thread.h>
#include <synced_range_allocator.h>
#include <assertion.h>
namespace Genode {
@ -36,6 +37,29 @@ namespace Genode {
*/
Synced_range_allocator<Allocator_avl> _core_mem_alloc;
Rom_fs _dummy_rom_fs { };
struct Dummy_allocator : Range_allocator
{
void free(void *, size_t) override { ASSERT_NEVER_CALLED; }
bool need_size_for_free() const override { ASSERT_NEVER_CALLED; }
size_t consumed() const override { ASSERT_NEVER_CALLED; }
size_t overhead(size_t) const override { ASSERT_NEVER_CALLED; }
int add_range (addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
int remove_range(addr_t, size_t ) override { ASSERT_NEVER_CALLED; }
void free(void *) override { ASSERT_NEVER_CALLED; }
size_t avail() const override { ASSERT_NEVER_CALLED; }
bool valid_addr(addr_t ) const override { ASSERT_NEVER_CALLED; }
bool alloc(size_t, void **) override { ASSERT_NEVER_CALLED; }
Alloc_return alloc_aligned(size_t, void **, int, addr_t, addr_t) override
{ ASSERT_NEVER_CALLED; }
Alloc_return alloc_addr(size_t, addr_t) override
{ ASSERT_NEVER_CALLED; }
} _dummy_alloc { };
/**
* Allocator for pseudo physical memory
*/
@ -61,15 +85,14 @@ namespace Genode {
int add_range(addr_t, size_t) override { return 0; }
int remove_range(addr_t, size_t) override { return 0; }
void free(void *) override { }
void free(void *, size_t) override { }
size_t avail() const override { return ~0; }
bool valid_addr(addr_t) const override { return true; }
size_t overhead(size_t) const override { return 0; }
bool need_size_for_free() const override { return true; }
};
void free(void *) override { }
void free(void *, size_t) override { }
size_t avail() const override { return ~0; }
bool valid_addr(addr_t) const override { return true; }
size_t overhead(size_t) const override { return 0; }
bool need_size_for_free() const override { return true; }
Pseudo_ram_allocator _ram_alloc { };
} _ram_alloc { };
public:
@ -83,15 +106,15 @@ namespace Genode {
** Generic platform interface **
********************************/
Range_allocator *core_mem_alloc() override { return &_core_mem_alloc; }
Range_allocator *ram_alloc() override { return &_ram_alloc; }
Range_allocator *io_mem_alloc() override { return 0; }
Range_allocator *io_port_alloc() override { return 0; }
Range_allocator *irq_alloc() override { return 0; }
Range_allocator *region_alloc() override { return 0; }
Range_allocator &core_mem_alloc() override { return _core_mem_alloc; }
Range_allocator &ram_alloc() override { return _ram_alloc; }
Range_allocator &io_mem_alloc() override { return _dummy_alloc; }
Range_allocator &io_port_alloc() override { return _dummy_alloc; }
Range_allocator &irq_alloc() override { return _dummy_alloc; }
Range_allocator &region_alloc() override { return _dummy_alloc; }
addr_t vm_start() const override { return 0; }
size_t vm_size() const override { return 0; }
Rom_fs *rom_fs() override { return 0; }
Rom_fs &rom_fs() override { return _dummy_rom_fs; }
/*
* On Linux, the maximum number of capabilities is primarily

View File

@ -26,9 +26,9 @@ namespace Genode {
struct Genode::Platform_pd
{
Platform_pd(Allocator *, char const *) { }
Platform_pd(Allocator &, char const *) { }
bool bind_thread(Platform_thread *) { return true; }
bool bind_thread(Platform_thread &) { return true; }
void assign_parent(Capability<Parent>) { }
};

View File

@ -60,7 +60,7 @@ namespace Genode {
/**
* Return singleton instance of 'Platform_thread::Registry'
*/
static Registry *_registry();
static Registry &_registry();
unsigned long _tid = -1;
unsigned long _pid = -1;
@ -110,8 +110,8 @@ namespace Genode {
/**
* Dummy implementation of platform-thread interface
*/
Pager_object *pager() { return &_pager; }
void pager(Pager_object *) { }
Pager_object &pager() { return _pager; }
void pager(Pager_object &) { }
int start(void *, void *) { return 0; }
Thread_state state()
@ -164,7 +164,7 @@ namespace Genode {
*/
static void submit_exception(int pid)
{
_registry()->submit_exception(pid);
_registry().submit_exception(pid);
}
/**

View File

@ -65,22 +65,16 @@ class Genode::Region_map_component : public Rpc_object<Region_map>,
Dataspace_capability dataspace() { return Dataspace_capability(); }
Rm_dataspace_component *dataspace_component() { return 0; }
Rm_dataspace_component *dataspace_component() { return nullptr; }
void address_space(Platform_pd *) { }
};
struct Genode::Rm_member : Interface
struct Genode::Rm_client : Pager_object
{
Region_map_component *member_rm() { return 0; }
};
struct Genode::Rm_client : Pager_object, Rm_member
{
Rm_client(Cpu_session_capability, Thread_capability,
Region_map_component *, unsigned long,
Rm_client(Cpu_session_capability, Thread_capability,
Region_map_component &, unsigned long,
Affinity::Location, Cpu_session::Name const&,
Session_label const&)
{ }

View File

@ -24,7 +24,7 @@ class Genode::Rpc_cap_factory
{
private:
static Native_capability _alloc(Rpc_cap_factory *owner,
static Native_capability _alloc(Rpc_cap_factory &owner,
Native_capability ep);
public:

Some files were not shown because too many files have changed in this diff Show More