diff --git a/repos/base-fiasco/src/core/include/map_local.h b/repos/base-fiasco/src/core/include/map_local.h
index c905eacfd5..c28bca4f28 100644
--- a/repos/base-fiasco/src/core/include/map_local.h
+++ b/repos/base-fiasco/src/core/include/map_local.h
@@ -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();
diff --git a/repos/base-fiasco/src/core/include/platform.h b/repos/base-fiasco/src/core/include/platform.h
index 58d28e9f57..ffb163cf4c 100644
--- a/repos/base-fiasco/src/core/include/platform.h
+++ b/repos/base-fiasco/src/core/include/platform.h
@@ -18,11 +18,12 @@
#include
#include
-#include "synced_range_allocator.h"
-#include "platform_generic.h"
-#include "platform_thread.h"
-#include "platform_pd.h"
-#include "boot_modules.h"
+#include
+#include
+#include
+#include
+#include
+#include
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 ®ion_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(); }
diff --git a/repos/base-fiasco/src/core/include/platform_pd.h b/repos/base-fiasco/src/core/include/platform_pd.h
index a899dfda71..8dbd4c415c 100644
--- a/repos/base-fiasco/src/core/include/platform_pd.h
+++ b/repos/base-fiasco/src/core/include/platform_pd.h
@@ -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
diff --git a/repos/base-fiasco/src/core/include/platform_thread.h b/repos/base-fiasco/src/core/include/platform_thread.h
index c7dc8f033b..10591cbf42 100644
--- a/repos/base-fiasco/src/core/include/platform_thread.h
+++ b/repos/base-fiasco/src/core/include/platform_thread.h
@@ -21,6 +21,7 @@
/* core includes */
#include
#include
+#include
/* 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; }
};
}
diff --git a/repos/base-fiasco/src/core/include/rpc_cap_factory.h b/repos/base-fiasco/src/core/include/rpc_cap_factory.h
index 9b6000c008..eb5d68a8f0 100644
--- a/repos/base-fiasco/src/core/include/rpc_cap_factory.h
+++ b/repos/base-fiasco/src/core/include/rpc_cap_factory.h
@@ -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:
diff --git a/repos/base-fiasco/src/core/io_mem_session_support.cc b/repos/base-fiasco/src/core/io_mem_session_support.cc
index 609d8d995d..993dce6c41 100644
--- a/repos/base-fiasco/src/core/io_mem_session_support.cc
+++ b/repos/base-fiasco/src/core/io_mem_session_support.cc
@@ -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(base));
+ platform().region_alloc().free(reinterpret_cast(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 */
diff --git a/repos/base-fiasco/src/core/irq_session_component.cc b/repos/base-fiasco/src/core/irq_session_component.cc
index fc7cb10bb5..8e4cfba338 100644
--- a/repos/base-fiasco/src/core/irq_session_component.cc
+++ b/repos/base-fiasco/src/core/irq_session_component.cc
@@ -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();
}
diff --git a/repos/base-fiasco/src/core/platform.cc b/repos/base-fiasco/src/core/platform.cc
index 66159c60df..7b6af01ae5 100644
--- a/repos/base-fiasco/src/core/platform.cc
+++ b/repos/base-fiasco/src/core/platform.cc
@@ -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(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);
diff --git a/repos/base-fiasco/src/core/platform_pd.cc b/repos/base-fiasco/src/core/platform_pd.cc
index a972c68ec3..3051799286 100644
--- a/repos/base-fiasco/src/core/platform_pd.cc
+++ b/repos/base-fiasco/src/core/platform_pd.cc
@@ -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();
diff --git a/repos/base-fiasco/src/core/platform_thread.cc b/repos/base-fiasco/src/core/platform_thread.cc
index c422416307..6e57981b7c 100644
--- a/repos/base-fiasco/src/core/platform_thread.cc
+++ b/repos/base-fiasco/src/core/platform_thread.cc
@@ -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);
}
diff --git a/repos/base-fiasco/src/core/ram_dataspace_support.cc b/repos/base-fiasco/src/core/ram_dataspace_support.cc
index b1e0ebb19e..18e63f332d 100644
--- a/repos/base-fiasco/src/core/ram_dataspace_support.cc
+++ b/repos/base-fiasco/src/core/ram_dataspace_support.cc
@@ -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());
}
diff --git a/repos/base-fiasco/src/core/thread_start.cc b/repos/base-fiasco/src/core/thread_start.cc
index 34903e189a..53eebe162d 100644
--- a/repos/base-fiasco/src/core/thread_start.cc
+++ b/repos/base-fiasco/src/core/thread_start.cc
@@ -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);
}
diff --git a/repos/base-foc/src/core/include/cap_id_alloc.h b/repos/base-foc/src/core/include/cap_id_alloc.h
index f4c42e6f4a..5187286299 100644
--- a/repos/base-foc/src/core/include/cap_id_alloc.h
+++ b/repos/base-foc/src/core/include/cap_id_alloc.h
@@ -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);
diff --git a/repos/base-foc/src/core/include/cap_mapping.h b/repos/base-foc/src/core/include/cap_mapping.h
index d796559315..e134a10794 100644
--- a/repos/base-foc/src/core/include/cap_mapping.h
+++ b/repos/base-foc/src/core/include/cap_mapping.h
@@ -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:
diff --git a/repos/base-foc/src/core/include/cpu_session_irqs.h b/repos/base-foc/src/core/include/cpu_session_irqs.h
deleted file mode 100644
index a6e39068f4..0000000000
--- a/repos/base-foc/src/core/include/cpu_session_irqs.h
+++ /dev/null
@@ -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
-
-/* core includes */
-#include
-
-namespace Genode { class Cpu_session_irqs; }
-
-
-class Genode::Cpu_session_irqs : public Avl_node
-{
- 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::child(o > _owner);
- return c ? c->find_by_session(o) : 0;
- }
-};
-
-#endif /* _CORE__INCLUDE__CPU_SESSION_COMPONENT_H_ */
diff --git a/repos/base-foc/src/core/include/ipc_pager.h b/repos/base-foc/src/core/include/ipc_pager.h
index 4da549889e..9016d0a308 100644
--- a/repos/base-foc/src/core/include/ipc_pager.h
+++ b/repos/base-foc/src/core/include/ipc_pager.h
@@ -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_ */
diff --git a/repos/base-foc/src/core/include/platform.h b/repos/base-foc/src/core/include/platform.h
index 0cd4e96fc4..709c89d222 100644
--- a/repos/base-foc/src/core/include/platform.h
+++ b/repos/base-foc/src/core/include/platform.h
@@ -26,6 +26,7 @@
#include
#include
#include
+#include
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 ®ion_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();
};
diff --git a/repos/base-foc/src/core/include/platform_pd.h b/repos/base-foc/src/core/include/platform_pd.h
index e15496c4fc..8fd42514df 100644
--- a/repos/base-foc/src/core/include/platform_pd.h
+++ b/repos/base-foc/src/core/include/platform_pd.h
@@ -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
diff --git a/repos/base-foc/src/core/include/platform_thread.h b/repos/base-foc/src/core/include/platform_thread.h
index 2ccc03c5ba..b7f3d92d11 100644
--- a/repos/base-foc/src/core/include/platform_thread.h
+++ b/repos/base-foc/src/core/include/platform_thread.h
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
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; }
};
diff --git a/repos/base-foc/src/core/io_mem_session_support.cc b/repos/base-foc/src/core/io_mem_session_support.cc
index 81658a8411..8755182eb4 100644
--- a/repos/base-foc/src/core/io_mem_session_support.cc
+++ b/repos/base-foc/src/core/io_mem_session_support.cc
@@ -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(base));
+ platform().region_alloc().free(reinterpret_cast(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())) {
diff --git a/repos/base-foc/src/core/irq_session_component.cc b/repos/base-foc/src/core/irq_session_component.cc
index c0fb347317..7766c822d9 100644
--- a/repos/base-foc/src/core/irq_session_component.cc
+++ b/repos/base-foc/src/core/irq_session_component.cc
@@ -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);
}
}
diff --git a/repos/base-foc/src/core/native_cpu_component.cc b/repos/base-foc/src/core/native_cpu_component.cc
index 815f96b2d8..595b960b1c 100644
--- a/repos/base-foc/src/core/native_cpu_component.cc
+++ b/repos/base-foc/src/core/native_cpu_component.cc
@@ -16,7 +16,7 @@
/* core includes */
#include
-#include
+#include
#include
/* 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);
}
diff --git a/repos/base-foc/src/core/pager.cc b/repos/base-foc/src/core/pager.cc
index 5a96723f6f..06a70514d2 100644
--- a/repos/base-foc/src/core/pager.cc
+++ b/repos/base-foc/src/core/pager.cc
@@ -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::Entry::cap());
+ _cap_factory.free(obj.Object_pool::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(cap);
diff --git a/repos/base-foc/src/core/platform.cc b/repos/base-foc/src/core/platform.cc
index 058531b14c..8a009b454f 100644
--- a/repos/base-foc/src/core/platform.cc
+++ b/repos/base-foc/src/core/platform.cc
@@ -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(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_TASK_CAP));
- Core_cap_index* thi =
- reinterpret_cast(cap_map()->insert(_cap_id_alloc.alloc(), Fiasco::L4_BASE_THREAD_CAP));
- Core_cap_index* irqi =
- reinterpret_cast(cap_map()->insert(_cap_id_alloc.alloc()));
+ Core_cap_index &pdi =
+ *reinterpret_cast(cap_map().insert(_cap_id_alloc.alloc(),
+ Fiasco::L4_BASE_TASK_CAP));
+ Core_cap_index &thi =
+ *reinterpret_cast(cap_map().insert(_cap_id_alloc.alloc(),
+ Fiasco::L4_BASE_THREAD_CAP));
+ Core_cap_index &irqi =
+ *reinterpret_cast(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(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(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(core_local_ptr);
map_local(phys_addr, core_local_addr, pages);
diff --git a/repos/base-foc/src/core/platform_pd.cc b/repos/base-foc/src/core/platform_pd.cc
index 3528bbf975..28a851271a 100644
--- a/repos/base-foc/src/core/platform_pd.cc
+++ b/repos/base-foc/src/core/platform_pd.cc
@@ -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(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(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(UTCB_AREA_SIZE), 0);
l4_msgtag_t tag = l4_factory_create_task(L4_BASE_FACTORY_CAP,
diff --git a/repos/base-foc/src/core/platform_thread.cc b/repos/base-foc/src/core/platform_thread.cc
index bf3cddb72c..28c9dc16e1 100644
--- a/repos/base-foc/src/core/platform_thread.cc
+++ b/repos/base-foc/src/core/platform_thread.cc
@@ -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);
}
diff --git a/repos/base-foc/src/core/ram_dataspace_support.cc b/repos/base-foc/src/core/ram_dataspace_support.cc
index 179366012a..535bc1365d 100644
--- a/repos/base-foc/src/core/ram_dataspace_support.cc
+++ b/repos/base-foc/src/core/ram_dataspace_support.cc
@@ -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());
}
diff --git a/repos/base-foc/src/core/rpc_cap_factory.cc b/repos/base-foc/src/core/rpc_cap_factory.cc
index 2bca4066d2..60baf669db 100644
--- a/repos/base-foc/src/core/rpc_cap_factory.cc
+++ b/repos/base-foc/src/core/rpc_cap_factory.cc
@@ -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 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(cap_map()->insert(id));
+ int const id = platform_specific().cap_id_alloc().alloc();
+ return static_cast(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(cap_map()->insert(id));
+ unsigned long const id = platform_specific().cap_id_alloc().alloc();
+ Core_cap_index *idx = static_cast(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(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);
}
}
diff --git a/repos/base-foc/src/core/signal_source_component.cc b/repos/base-foc/src/core/signal_source_component.cc
index d047ca2083..383b806d41 100644
--- a/repos/base-foc/src/core/signal_source_component.cc
+++ b/repos/base-foc/src/core/signal_source_component.cc
@@ -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;
diff --git a/repos/base-foc/src/core/spec/arm/ipc_pager.cc b/repos/base-foc/src/core/spec/arm/ipc_pager.cc
index 86c46ff977..aff98a0e9c 100644
--- a/repos/base-foc/src/core/spec/arm/ipc_pager.cc
+++ b/repos/base-foc/src/core/spec/arm/ipc_pager.cc
@@ -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;
diff --git a/repos/base-foc/src/core/spec/x86_32/ipc_pager.cc b/repos/base-foc/src/core/spec/x86_32/ipc_pager.cc
index f592da2e77..97df1ffef1 100644
--- a/repos/base-foc/src/core/spec/x86_32/ipc_pager.cc
+++ b/repos/base-foc/src/core/spec/x86_32/ipc_pager.cc
@@ -17,25 +17,25 @@
#include
-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;
diff --git a/repos/base-foc/src/core/spec/x86_64/ipc_pager.cc b/repos/base-foc/src/core/spec/x86_64/ipc_pager.cc
index 1fd94169d0..b254089050 100644
--- a/repos/base-foc/src/core/spec/x86_64/ipc_pager.cc
+++ b/repos/base-foc/src/core/spec/x86_64/ipc_pager.cc
@@ -17,32 +17,32 @@
#include
-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;
diff --git a/repos/base-foc/src/core/thread_start.cc b/repos/base-foc/src/core/thread_start.cc
index dbbd49c071..3cd60c7a36 100644
--- a/repos/base-foc/src/core/thread_start.cc
+++ b/repos/base-foc/src/core/thread_start.cc
@@ -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(Native_capability(pt->thread().local));
+ reinterpret_cap_cast(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());
}
diff --git a/repos/base-foc/src/include/base/internal/cap_map.h b/repos/base-foc/src/include/base/internal/cap_map.h
index f76ef283d5..c02d3484a4 100644
--- a/repos/base-foc/src/include/base/internal/cap_map.h
+++ b/repos/base-foc/src/include/base/internal/cap_map.h
@@ -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_ */
diff --git a/repos/base-foc/src/include/base/internal/parent_cap.h b/repos/base-foc/src/include/base/internal/parent_cap.h
index 1d44767b60..1feb3e0f19 100644
--- a/repos/base-foc/src/include/base/internal/parent_cap.h
+++ b/repos/base-foc/src/include/base/internal/parent_cap.h
@@ -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(Native_capability(i));
diff --git a/repos/base-foc/src/lib/base/cap_alloc.cc b/repos/base-foc/src/lib/base/cap_alloc.cc
index d282b80916..0cb34b669d 100644
--- a/repos/base-foc/src/lib/base/cap_alloc.cc
+++ b/repos/base-foc/src/lib/base/cap_alloc.cc
@@ -13,8 +13,8 @@
#include
-Genode::Cap_index_allocator* Genode::cap_idx_alloc()
+Genode::Cap_index_allocator &Genode::cap_idx_alloc()
{
static Genode::Cap_index_allocator_tpl alloc;
- return &alloc;
+ return alloc;
}
diff --git a/repos/base-foc/src/lib/base/cap_map.cc b/repos/base-foc/src/lib/base/cap_map.cc
index 00fc54179a..7f55d1b96c 100644
--- a/repos/base-foc/src/lib/base/cap_map.cc
+++ b/repos/base-foc/src/lib/base/cap_map.cc
@@ -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 ↦
+ 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);
}
diff --git a/repos/base-foc/src/lib/base/cap_map_remove.cc b/repos/base-foc/src/lib/base/cap_map_remove.cc
index 0342ec0130..8f196ffbb0 100644
--- a/repos/base-foc/src/lib/base/cap_map_remove.cc
+++ b/repos/base-foc/src/lib/base/cap_map_remove.cc
@@ -22,9 +22,9 @@ void Genode::Capability_map::remove(Genode::Cap_index* i)
Lock_guard 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);
}
}
diff --git a/repos/base-foc/src/lib/base/capability.cc b/repos/base-foc/src/lib/base/capability.cc
index d840440cb7..88305b90cc 100644
--- a/repos/base-foc/src/lib/base/capability.cc
+++ b/repos/base-foc/src/lib/base/capability.cc
@@ -36,7 +36,7 @@ void Native_capability::_inc()
void Native_capability::_dec()
{
if (_data && !_data->dec())
- cap_map()->remove(_data);
+ cap_map().remove(_data);
}
diff --git a/repos/base-foc/src/lib/base/ipc.cc b/repos/base-foc/src/lib/base/ipc.cc
index f377c737e1..061b817e38 100644
--- a/repos/base-foc/src/lib/base/ipc.cc
+++ b/repos/base-foc/src/lib/base/ipc.cc
@@ -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);
}
diff --git a/repos/base-foc/src/lib/base/thread_bootstrap.cc b/repos/base-foc/src/lib/base/thread_bootstrap.cc
index e300a4ef41..19b94367c0 100644
--- a/repos/base-foc/src/lib/base/thread_bootstrap.cc
+++ b/repos/base-foc/src/lib/base/thread_bootstrap.cc
@@ -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(cap_map());
- cap_idx_alloc()->reinit();
+ construct_at(&cap_map());
+ cap_idx_alloc().reinit();
prepare_init_main_thread();
}
diff --git a/repos/base-foc/src/lib/base/thread_start.cc b/repos/base-foc/src/lib/base/thread_start.cc
index 26b7744a17..ba41c6f265 100644
--- a/repos/base-foc/src/lib/base/thread_start.cc
+++ b/repos/base-foc/src/lib/base/thread_start.cc
@@ -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;
diff --git a/repos/base-foc/src/test/cap_integrity/main.cc b/repos/base-foc/src/test/cap_integrity/main.cc
index 39b9fcff4e..16ec50ea63 100644
--- a/repos/base-foc/src/test/cap_integrity/main.cc
+++ b/repos/base-foc/src/test/cap_integrity/main.cc
@@ -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 */
diff --git a/repos/base-hw/src/core/core_region_map.cc b/repos/base-hw/src/core/core_region_map.cc
index dd0f9663da..1defc1368b 100644
--- a/repos/base-hw/src/core/core_region_map.cc
+++ b/repos/base-hw/src/core/core_region_map.cc
@@ -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;
diff --git a/repos/base-hw/src/core/cpu_thread_allocator.h b/repos/base-hw/src/core/cpu_thread_allocator.h
index c57eab0b88..834cfe028f 100644
--- a/repos/base-hw/src/core/cpu_thread_allocator.h
+++ b/repos/base-hw/src/core/cpu_thread_allocator.h
@@ -14,9 +14,13 @@
#ifndef _CORE__CPU_THREAD_ALLOCATOR_H_
#define _CORE__CPU_THREAD_ALLOCATOR_H_
+/* Genode includes */
#include
#include
+/* core includes */
+#include
+
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(); }
};
}
diff --git a/repos/base-hw/src/core/irq_session_component.cc b/repos/base-hw/src/core/irq_session_component.cc
index e8d15a0b77..333241ef74 100644
--- a/repos/base-hw/src/core/irq_session_component.cc
+++ b/repos/base-hw/src/core/irq_session_component.cc
@@ -62,14 +62,14 @@ Irq_session_component::~Irq_session_component()
using namespace Kernel;
User_irq * kirq = reinterpret_cast(&_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();
}
diff --git a/repos/base-hw/src/core/irq_session_component.h b/repos/base-hw/src/core/irq_session_component.h
index e21aa5ddb9..911322e7dc 100644
--- a/repos/base-hw/src/core/irq_session_component.h
+++ b/repos/base-hw/src/core/irq_session_component.h
@@ -31,14 +31,8 @@ class Genode::Irq_session_component : public Rpc_object,
friend class List;
- /*
- * 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,
* \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);
/**
diff --git a/repos/base-hw/src/core/kernel/cpu.cc b/repos/base-hw/src/core/kernel/cpu.cc
index 701cbdd11d..e8c5babea3 100644
--- a/repos/base-hw/src/core/kernel/cpu.cc
+++ b/repos/base-hw/src/core/kernel/cpu.cc
@@ -27,10 +27,7 @@
using namespace Kernel;
-namespace Kernel
-{
- Cpu_pool * cpu_pool() { return unmanaged_singleton(); }
-}
+Kernel::Cpu_pool &Kernel::cpu_pool() { return *unmanaged_singleton(); }
/*************
@@ -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(); }
diff --git a/repos/base-hw/src/core/kernel/cpu.h b/repos/base-hw/src/core/kernel/cpu.h
index 274c40fbbd..ca9f8267a2 100644
--- a/repos/base-hw/src/core/kernel/cpu.h
+++ b/repos/base-hw/src/core/kernel/cpu.h
@@ -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(_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); };
diff --git a/repos/base-hw/src/core/kernel/cpu_context.h b/repos/base-hw/src/core/kernel/cpu_context.h
index 792a375692..20f9939c3d 100644
--- a/repos/base-hw/src/core/kernel/cpu_context.h
+++ b/repos/base-hw/src/core/kernel/cpu_context.h
@@ -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; }
};
diff --git a/repos/base-hw/src/core/kernel/cpu_mp.cc b/repos/base-hw/src/core/kernel/cpu_mp.cc
index ced77609d0..3fd3ed68e5 100644
--- a/repos/base-hw/src/core/kernel/cpu_mp.cc
+++ b/repos/base-hw/src/core/kernel/cpu_mp.cc
@@ -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;
}
diff --git a/repos/base-hw/src/core/kernel/init.cc b/repos/base-hw/src/core/kernel/init.cc
index 85a9f3a864..3f027e4662 100644
--- a/repos/base-hw/src/core/kernel/init.cc
+++ b/repos/base-hw/src/core/kernel/init.cc
@@ -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()->kernel_pd(); }
+Pd &Kernel::core_pd() {
+ return unmanaged_singleton()->kernel_pd(); }
-Pic * Kernel::pic() { return unmanaged_singleton(); }
+Pic &Kernel::pic() { return *unmanaged_singleton(); }
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 */
diff --git a/repos/base-hw/src/core/kernel/ipc_node.cc b/repos/base-hw/src/core/kernel/ipc_node.cc
index 925a22e3fa..4b9c78511a 100644
--- a/repos/base-hw/src/core/kernel/ipc_node.cc
+++ b/repos/base-hw/src/core/kernel/ipc_node.cc
@@ -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;
}
}
diff --git a/repos/base-hw/src/core/kernel/ipc_node.h b/repos/base-hw/src/core/kernel/ipc_node.h
index c52d5d4467..38661663e9 100644
--- a/repos/base-hw/src/core/kernel/ipc_node.h
+++ b/repos/base-hw/src/core/kernel/ipc_node.h
@@ -24,6 +24,7 @@
/* core includes */
#include
#include
+#include
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_ */
diff --git a/repos/base-hw/src/core/kernel/irq.cc b/repos/base-hw/src/core/kernel/irq.cc
index 5e1a405387..19003018c5 100644
--- a/repos/base-hw/src/core/kernel/irq.cc
+++ b/repos/base-hw/src/core/kernel/irq.cc
@@ -18,14 +18,14 @@
#include
-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;
}
diff --git a/repos/base-hw/src/core/kernel/irq.h b/repos/base-hw/src/core/kernel/irq.h
index 5f17851721..d77e65a785 100644
--- a/repos/base-hw/src/core/kernel/irq.h
+++ b/repos/base-hw/src/core/kernel/irq.h
@@ -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(_pool()->object(irq)); }
+ return dynamic_cast(_pool().object(irq)); }
};
#endif /* _CORE__KERNEL__IRQ_H_ */
diff --git a/repos/base-hw/src/core/kernel/kernel.cc b/repos/base-hw/src/core/kernel/kernel.cc
index 4f2d8b1cbe..43b22012f1 100644
--- a/repos/base-hw/src/core/kernel/kernel.cc
+++ b/repos/base-hw/src/core/kernel/kernel.cc
@@ -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;
{
diff --git a/repos/base-hw/src/core/kernel/kernel.h b/repos/base-hw/src/core/kernel/kernel.h
index 56e30fe448..c32403e14b 100644
--- a/repos/base-hw/src/core/kernel/kernel.h
+++ b/repos/base-hw/src/core/kernel/kernel.h
@@ -27,8 +27,8 @@ namespace Kernel {
class Pd;
- Pd * core_pd();
- Pic * pic();
+ Pd &core_pd();
+ Pic &pic();
}
#endif /* _CORE__KERNEL__KERNEL_H_ */
diff --git a/repos/base-hw/src/core/kernel/object.cc b/repos/base-hw/src/core/kernel/object.cc
index 9312961be7..8e445cf327 100644
--- a/repos/base-hw/src/core/kernel/object.cc
+++ b/repos/base-hw/src/core/kernel/object.cc
@@ -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;
}
diff --git a/repos/base-hw/src/core/kernel/object.h b/repos/base-hw/src/core/kernel/object.h
index fe5cc9645f..3d4fbb71bf 100644
--- a/repos/base-hw/src/core/kernel/object.h
+++ b/repos/base-hw/src/core/kernel/object.h
@@ -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(); }
};
diff --git a/repos/base-hw/src/core/kernel/pd.h b/repos/base-hw/src/core/kernel/pd.h
index af464b1064..3ffd5f1377 100644
--- a/repos/base-hw/src/core/kernel/pd.h
+++ b/repos/base-hw/src/core/kernel/pd.h
@@ -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_ */
diff --git a/repos/base-hw/src/core/kernel/thread.cc b/repos/base-hw/src/core/kernel/thread.cc
index 6a8ba8fb51..13c0b3e5d0 100644
--- a/repos/base-hw/src/core/kernel/thread.cc
+++ b/repos/base-hw/src/core/kernel/thread.cc
@@ -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(user_arg_1());
- Thread * const thread = pd()->cap_tree().find(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(_timeout_sigid);
+ pd().cap_tree().find(_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() : 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(user_arg_2());
+ Thread &thread = *(Thread *)user_arg_1();
+ thread._pager = pd().cap_tree().find(user_arg_2());
}
@@ -441,7 +444,7 @@ void Thread::_call_await_signal()
return;
}
/* lookup receiver */
- Signal_receiver * const r = pd()->cap_tree().find(user_arg_1());
+ Signal_receiver * const r = pd().cap_tree().find(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(user_arg_1());
- if (!thread || pd() != thread->pd()) {
+ Thread * const thread = pd().cap_tree().find(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(user_arg_1());
+ Signal_context * const c = pd().cap_tree().find(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(user_arg_1());
+ Signal_context * const c = pd().cap_tree().find(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(user_arg_1());
+ Signal_context * const c = pd().cap_tree().find(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(user_arg_3());
+ Signal_context * const c = pd().cap_tree().find(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() : nullptr;
if (!thread ||
(static_cast*>(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((Hw::Page_table *) user_arg_2(),
- (Genode::Platform_pd *) user_arg_3());
+ _call_new(*(Hw::Page_table *) user_arg_2(),
+ *(Genode::Platform_pd *) user_arg_3());
return;
case call_id_delete_pd(): _call_delete(); return;
case call_id_new_signal_receiver(): _call_new(); 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();
}
diff --git a/repos/base-hw/src/core/kernel/vm_thread_on.cc b/repos/base-hw/src/core/kernel/vm_thread_on.cc
index 69947e1e7f..a35f815bc5 100644
--- a/repos/base-hw/src/core/kernel/vm_thread_on.cc
+++ b/repos/base-hw/src/core/kernel/vm_thread_on.cc
@@ -18,7 +18,7 @@
void Kernel::Thread::_call_new_vm()
{
Signal_context * context =
- pd()->cap_tree().find(user_arg_4());
+ pd().cap_tree().find(user_arg_4());
if (!context) {
user_arg_0(cap_id_invalid());
return;
diff --git a/repos/base-hw/src/core/object.h b/repos/base-hw/src/core/object.h
index 9cfada59ff..7ca449ce2c 100644
--- a/repos/base-hw/src/core/object.h
+++ b/repos/base-hw/src/core/object.h
@@ -65,6 +65,8 @@ class Genode::Kernel_object
T * kernel_object() { return reinterpret_cast(_data); }
+ Untyped_capability cap() { return _cap; }
+
/**
* Create the kernel object explicitely via this function
*/
diff --git a/repos/base-hw/src/core/pager.cc b/repos/base-hw/src/core/pager.cc
index 41a91a910b..43da9bdc74 100644
--- a/repos/base-hw/src/core/pager.cc
+++ b/repos/base-hw/src/core/pager.cc
@@ -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(o->cap());
+ o.start_paging(kernel_object());
+ insert(&o);
+ return reinterpret_cap_cast(o.cap());
}
diff --git a/repos/base-hw/src/core/pager.h b/repos/base-hw/src/core/pager.h
index 2c46061911..2375e139a2 100644
--- a/repos/base-hw/src/core/pager.h
+++ b/repos/base-hw/src/core/pager.h
@@ -208,12 +208,12 @@ class Genode::Pager_entrypoint : public Object_pool,
/**
* 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);
/**********************
diff --git a/repos/base-hw/src/core/platform.cc b/repos/base-hw/src/core/platform.cc
index 42d6b7e447..526448e9c1 100644
--- a/repos/base-hw/src/core/platform.cc
+++ b/repos/base-hw/src/core/platform.cc
@@ -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(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(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;
}
diff --git a/repos/base-hw/src/core/platform.h b/repos/base-hw/src/core/platform.h
index 2e0c52dbe4..59119b64cb 100644
--- a/repos/base-hw/src/core/platform.h
+++ b/repos/base-hw/src/core/platform.h
@@ -32,6 +32,7 @@
#include
#include
#include
+#include
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 ®ion_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); }
/*
diff --git a/repos/base-hw/src/core/platform_pd.cc b/repos/base-hw/src/core/platform_pd.cc
index cbabbf6aae..ebeb1c504b 100644
--- a/repos/base-hw/src/core/platform_pd.cc
+++ b/repos/base-hw/src/core/platform_pd.cc
@@ -29,15 +29,15 @@ using Hw::Page_table;
** Hw::Address_space implementation **
**************************************/
-Core_mem_allocator * Hw::Address_space::_cma() {
- return static_cast(platform()->core_mem_alloc()); }
+Core_mem_allocator &Hw::Address_space::_cma() {
+ return static_cast(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(_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(false, (Page_table*)translation_table_phys(), this),
- _label("core") { }
+:
+ Hw::Address_space(*kernel_object(), tt, alloc),
+ Kernel_object(false, *(Page_table*)translation_table_phys(), *this),
+ _label("core")
+{ }
-Platform_pd::Platform_pd(Allocator *, char const *label)
-: Hw::Address_space(*kernel_object()),
- Kernel_object(true, (Page_table*)translation_table_phys(), this),
- _label(label)
+Platform_pd::Platform_pd(Allocator &, char const *label)
+:
+ Hw::Address_space(*kernel_object()),
+ Kernel_object(true, *(Page_table*)translation_table_phys(), *this),
+ _label(label)
{
if (!_cap.valid()) {
error("failed to create kernel object");
diff --git a/repos/base-hw/src/core/platform_pd.h b/repos/base-hw/src/core/platform_pd.h
index 6df3b4b8e7..1f6b5f638c 100644
--- a/repos/base-hw/src/core/platform_pd.h
+++ b/repos/base-hw/src/core/platform_pd.h
@@ -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
diff --git a/repos/base-hw/src/core/platform_thread.cc b/repos/base-hw/src/core/platform_thread.cc
index a577af5074..ac74195ba8 100644
--- a/repos/base-hw/src/core/platform_thread.cc
+++ b/repos/base-hw/src/core/platform_thread.cc
@@ -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(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(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(ip);
- kernel_object()->regs->sp = reinterpret_cast(sp);
+ _kobj.kernel_object()->regs->ip = reinterpret_cast(ip);
+ _kobj.kernel_object()->regs->sp = reinterpret_cast(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(&*kernel_object()->regs);
+ Cpu_state * cstate = static_cast(&*_kobj.kernel_object()->regs);
*cstate = static_cast(thread_state);
}
void Platform_thread::restart()
{
- Kernel::restart_thread(Capability_space::capid(_cap));
+ Kernel::restart_thread(Capability_space::capid(_kobj.cap()));
}
diff --git a/repos/base-hw/src/core/platform_thread.h b/repos/base-hw/src/core/platform_thread.h
index f75361603e..a6f296893c 100644
--- a/repos/base-hw/src/core/platform_thread.h
+++ b/repos/base-hw/src/core/platform_thread.h
@@ -41,7 +41,7 @@ namespace Genode {
/**
* Userland interface for the management of kernel thread-objects
*/
- class Platform_thread : public Kernel_object
+ 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 { };
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 _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);
/**
@@ -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; }
diff --git a/repos/base-hw/src/core/ram_dataspace_support.cc b/repos/base-hw/src/core/ram_dataspace_support.cc
index 8f2b5653ed..cabb03b98c 100644
--- a/repos/base-hw/src/core/ram_dataspace_support.cc
+++ b/repos/base-hw/src/core/ram_dataspace_support.cc
@@ -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);
}
diff --git a/repos/base-hw/src/core/region_map_support.cc b/repos/base-hw/src/core/region_map_support.cc
index aa840e127e..d14c5058b0 100644
--- a/repos/base-hw/src/core/region_map_support.cc
+++ b/repos/base-hw/src/core/region_map_support.cc
@@ -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;
diff --git a/repos/base-hw/src/core/spec/arm/kernel/thread.cc b/repos/base-hw/src/core/spec/arm/kernel/thread.cc
index 8473cc5f57..79126e9b32 100644
--- a/repos/base-hw/src/core/spec/arm/kernel/thread.cc
+++ b/repos/base-hw/src/core/spec/arm/kernel/thread.cc
@@ -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(&*regs)),
diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc b/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc
index 7edc55ba9f..78469c77e6 100644
--- a/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc
@@ -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;
}
}
diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc
index a0bd6f7c01..ae99993f78 100644
--- a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.cc
@@ -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(_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());
}
diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.h b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.h
index 45bba287d2..4571f629bf 100644
--- a/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.h
+++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/vm_session_component.h
@@ -58,6 +58,8 @@ class Genode::Vm_session_component : public Genode::Rpc_object::cap;
+
/**************************
** Vm session interface **
diff --git a/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc b/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc
index 770fc17a72..7c26ea2620 100644
--- a/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/virtualization/kernel/vm.cc
@@ -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(&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();
diff --git a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc
index 48d8497602..fff0631e66 100644
--- a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.cc
@@ -22,14 +22,14 @@
using namespace Genode;
-static Core_mem_allocator * cma() {
- return static_cast(platform()->core_mem_alloc()); }
+static Core_mem_allocator & cma() {
+ return static_cast(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(_ds_ep->manage(&_ds))),
_table(*construct_at(_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);
}
diff --git a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.h b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.h
index b7ed552c6a..c99a16882e 100644
--- a/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.h
+++ b/repos/base-hw/src/core/spec/arm_v7/virtualization/vm_session_component.h
@@ -67,6 +67,8 @@ class Genode::Vm_session_component : public Genode::Rpc_object::cap;
+
/**************************
** Vm session interface **
diff --git a/repos/base-hw/src/core/spec/arm_v7/vm_session_component.cc b/repos/base-hw/src/core/spec/arm_v7/vm_session_component.cc
index a1564c42a7..0ce25f3f40 100644
--- a/repos/base-hw/src/core/spec/arm_v7/vm_session_component.cc
+++ b/repos/base-hw/src/core/spec/arm_v7/vm_session_component.cc
@@ -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;
diff --git a/repos/base-hw/src/core/spec/arndale/platform_services.cc b/repos/base-hw/src/core/spec/arndale/platform_services.cc
index be4120a847..b34ad48bf0 100644
--- a/repos/base-hw/src/core/spec/arndale/platform_services.cc
+++ b/repos/base-hw/src/core/spec/arndale/platform_services.cc
@@ -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 *services)
+void Genode::platform_add_local_services(Rpc_entrypoint &ep,
+ Sliced_heap &sh,
+ Registry &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_service(*services, vm_root);
+ static Core_service vm_service(services, vm_root);
}
diff --git a/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc b/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
index c53353ede1..19e0ddf98d 100644
--- a/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
+++ b/repos/base-hw/src/core/spec/imx53/trustzone/platform_services.cc
@@ -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 *local_services)
+void Genode::platform_add_local_services(Rpc_entrypoint &ep,
+ Sliced_heap &sliced_heap,
+ Registry &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_service(*local_services, vm_root);
+ static Core_service vm_service(local_services, vm_root);
}
diff --git a/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc b/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc
index 91b1bef8bb..f0d701fbf0 100644
--- a/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc
+++ b/repos/base-hw/src/core/spec/x86_64/kernel/thread.cc
@@ -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"
diff --git a/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc b/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc
index 0843217c59..729fe98e81 100644
--- a/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc
+++ b/repos/base-hw/src/core/spec/x86_64/muen/kernel/thread_exception.cc
@@ -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;
}
diff --git a/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc b/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc
index 99ab0cebac..959601ad52 100644
--- a/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc
+++ b/repos/base-hw/src/core/spec/x86_64/muen/kernel/vm.cc
@@ -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;
diff --git a/repos/base-hw/src/core/spec/x86_64/muen/platform_services.cc b/repos/base-hw/src/core/spec/x86_64/muen/platform_services.cc
index fce2a96a54..49c54d1987 100644
--- a/repos/base-hw/src/core/spec/x86_64/muen/platform_services.cc
+++ b/repos/base-hw/src/core/spec/x86_64/muen/platform_services.cc
@@ -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 *services)
+void Genode::platform_add_local_services(Rpc_entrypoint &ep,
+ Sliced_heap &sliced_heap,
+ Registry &services)
{
- static Vm_root vm_root(ep, sh);
- static Core_service vm_ls(*services, vm_root);
+ static Vm_root vm_root(ep, sliced_heap);
+ static Core_service 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_ls(*services,
+ static Io_port_root io_port_root(*core_env().pd_session(),
+ platform().io_port_alloc(), sliced_heap);
+ static Core_service io_port_ls(services,
io_port_root);
}
diff --git a/repos/base-hw/src/core/spec/x86_64/muen/vm_session_component.h b/repos/base-hw/src/core/spec/x86_64/muen/vm_session_component.h
index 08609c51a8..938046c61e 100644
--- a/repos/base-hw/src/core/spec/x86_64/muen/vm_session_component.h
+++ b/repos/base-hw/src/core/spec/x86_64/muen/vm_session_component.h
@@ -42,6 +42,8 @@ class Genode::Vm_session_component
Vm_session_component(Rpc_entrypoint*, size_t) : _state() { }
~Vm_session_component() { }
+ using Genode::Rpc_object::cap;
+
/**************************
** Vm session interface **
diff --git a/repos/base-hw/src/core/spec/x86_64/platform_support.cc b/repos/base-hw/src/core/spec/x86_64/platform_support.cc
index cb6f4cdd68..a92e4d45c3 100644
--- a/repos/base-hw/src/core/spec/x86_64/platform_support.cc
+++ b/repos/base-hw/src/core/spec/x86_64/platform_support.cc
@@ -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 &) {
diff --git a/repos/base-hw/src/core/thread_start.cc b/repos/base-hw/src/core/thread_start.cc
index 16926918ec..8f2f981d46 100644
--- a/repos/base-hw/src/core/thread_start.cc
+++ b/repos/base-hw/src/core/thread_start.cc
@@ -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;
}
diff --git a/repos/base-linux/src/core/include/dataspace_component.h b/repos/base-linux/src/core/include/dataspace_component.h
index 0f01bc001e..524c440f25 100644
--- a/repos/base-linux/src/core/include/dataspace_component.h
+++ b/repos/base-linux/src/core/include/dataspace_component.h
@@ -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; }
/****************************************
diff --git a/repos/base-linux/src/core/include/io_mem_session_component.h b/repos/base-linux/src/core/include/io_mem_session_component.h
index 0b30408fc7..648d5a1642 100644
--- a/repos/base-linux/src/core/include/io_mem_session_component.h
+++ b/repos/base-linux/src/core/include/io_mem_session_component.h
@@ -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);
/**
diff --git a/repos/base-linux/src/core/include/irq_session_component.h b/repos/base-linux/src/core/include/irq_session_component.h
index 96ccebec5a..c2af409517 100644
--- a/repos/base-linux/src/core/include/irq_session_component.h
+++ b/repos/base-linux/src/core/include/irq_session_component.h
@@ -34,7 +34,7 @@ class Genode::Irq_session_component : public Rpc_object,
/**
* 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,
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_ */
diff --git a/repos/base-linux/src/core/include/pager.h b/repos/base-linux/src/core/include/pager.h
index e17e6ed6a1..9639d1b011 100644
--- a/repos/base-linux/src/core/include/pager.h
+++ b/repos/base-linux/src/core/include/pager.h
@@ -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 &) { }
};
}
diff --git a/repos/base-linux/src/core/include/platform.h b/repos/base-linux/src/core/include/platform.h
index 78c3e4d021..d187f29808 100644
--- a/repos/base-linux/src/core/include/platform.h
+++ b/repos/base-linux/src/core/include/platform.h
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
namespace Genode {
@@ -36,6 +37,29 @@ namespace Genode {
*/
Synced_range_allocator _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 ®ion_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
diff --git a/repos/base-linux/src/core/include/platform_pd.h b/repos/base-linux/src/core/include/platform_pd.h
index b2dcb8103a..f61930afdd 100644
--- a/repos/base-linux/src/core/include/platform_pd.h
+++ b/repos/base-linux/src/core/include/platform_pd.h
@@ -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) { }
};
diff --git a/repos/base-linux/src/core/include/platform_thread.h b/repos/base-linux/src/core/include/platform_thread.h
index ebccd765ba..bad3c2033e 100644
--- a/repos/base-linux/src/core/include/platform_thread.h
+++ b/repos/base-linux/src/core/include/platform_thread.h
@@ -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);
}
/**
diff --git a/repos/base-linux/src/core/include/region_map_component.h b/repos/base-linux/src/core/include/region_map_component.h
index 65e105bd89..28d51d82c1 100644
--- a/repos/base-linux/src/core/include/region_map_component.h
+++ b/repos/base-linux/src/core/include/region_map_component.h
@@ -65,22 +65,16 @@ class Genode::Region_map_component : public Rpc_object,
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&)
{ }
diff --git a/repos/base-linux/src/core/include/rpc_cap_factory.h b/repos/base-linux/src/core/include/rpc_cap_factory.h
index 9b6000c008..eb5d68a8f0 100644
--- a/repos/base-linux/src/core/include/rpc_cap_factory.h
+++ b/repos/base-linux/src/core/include/rpc_cap_factory.h
@@ -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:
diff --git a/repos/base-linux/src/core/include/server_socket_pair.h b/repos/base-linux/src/core/include/server_socket_pair.h
index 0b73275bfd..5ce82dc20e 100644
--- a/repos/base-linux/src/core/include/server_socket_pair.h
+++ b/repos/base-linux/src/core/include/server_socket_pair.h
@@ -95,7 +95,7 @@ static inline Genode::Socket_pair create_server_socket_pair(long id)
throw Connect_failed();
}
- socket_pair.client_sd = Genode::ep_sd_registry()->try_associate(socket_pair.client_sd, id);
+ socket_pair.client_sd = Genode::ep_sd_registry().try_associate(socket_pair.client_sd, id);
/*
* Wipe Unix domain socket from the file system. It will live as long as
diff --git a/repos/base-linux/src/core/io_mem_session_component.cc b/repos/base-linux/src/core/io_mem_session_component.cc
index 25e064cb16..6b7ac87ecb 100644
--- a/repos/base-linux/src/core/io_mem_session_component.cc
+++ b/repos/base-linux/src/core/io_mem_session_component.cc
@@ -18,8 +18,8 @@
using namespace Genode;
-Io_mem_session_component::Io_mem_session_component(Range_allocator *,
- Range_allocator *,
- Rpc_entrypoint *,
+Io_mem_session_component::Io_mem_session_component(Range_allocator &,
+ Range_allocator &,
+ Rpc_entrypoint &,
const char *args) {
warning("no io_mem support on Linux (args=\"", args, "\")"); }
diff --git a/repos/base-linux/src/core/native_cpu_component.cc b/repos/base-linux/src/core/native_cpu_component.cc
index f90736e723..20b1275b93 100644
--- a/repos/base-linux/src/core/native_cpu_component.cc
+++ b/repos/base-linux/src/core/native_cpu_component.cc
@@ -54,7 +54,7 @@ Untyped_capability Native_cpu_component::client_sd(Thread_capability thread_cap)
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);
}
diff --git a/repos/base-linux/src/core/platform.cc b/repos/base-linux/src/core/platform.cc
index aa1867fe4f..ea8fe69d62 100644
--- a/repos/base-linux/src/core/platform.cc
+++ b/repos/base-linux/src/core/platform.cc
@@ -183,7 +183,7 @@ size_t Region_map_mmap::_dataspace_size(Capability ds_cap)
return Local_capability::deref(ds_cap)->size();
/* use local function call if called from the entrypoint */
- return core_env()->entrypoint()->apply(ds_cap, [] (Dataspace *ds) {
+ return core_env().entrypoint().apply(ds_cap, [] (Dataspace *ds) {
return ds ? ds->size() : 0; });
}
@@ -201,13 +201,13 @@ int Region_map_mmap::_dataspace_fd(Capability ds_cap)
* socket descriptor during the RPC handling). When later destroying the
* dataspace, the descriptor would unexpectedly be closed again.
*/
- return core_env()->entrypoint()->apply(lx_ds_cap, [] (Linux_dataspace *ds) {
+ return core_env().entrypoint().apply(lx_ds_cap, [] (Linux_dataspace *ds) {
return ds ? lx_dup(Capability_space::ipc_cap_data(ds->fd()).dst.socket) : -1; });
}
bool Region_map_mmap::_dataspace_writable(Dataspace_capability ds_cap)
{
- return core_env()->entrypoint()->apply(ds_cap, [] (Dataspace *ds) {
+ return core_env().entrypoint().apply(ds_cap, [] (Dataspace *ds) {
return ds ? ds->writable() : false; });
}
diff --git a/repos/base-linux/src/core/platform_thread.cc b/repos/base-linux/src/core/platform_thread.cc
index 2f602dbdf6..08bf2ffb55 100644
--- a/repos/base-linux/src/core/platform_thread.cc
+++ b/repos/base-linux/src/core/platform_thread.cc
@@ -63,10 +63,10 @@ void Platform_thread::Registry::submit_exception(unsigned long pid)
}
-Platform_thread::Registry *Platform_thread::_registry()
+Platform_thread::Registry &Platform_thread::_registry()
{
static Platform_thread::Registry registry;
- return ®istry;
+ return registry;
}
@@ -79,13 +79,13 @@ Platform_thread::Platform_thread(size_t, const char *name, unsigned,
{
strncpy(_name, name, min(sizeof(_name), strlen(name) + 1));
- _registry()->insert(this);
+ _registry().insert(this);
}
Platform_thread::~Platform_thread()
{
- ep_sd_registry()->disassociate(_socket_pair.client_sd);
+ ep_sd_registry().disassociate(_socket_pair.client_sd);
if (_socket_pair.client_sd)
lx_close(_socket_pair.client_sd);
@@ -93,7 +93,7 @@ Platform_thread::~Platform_thread()
if (_socket_pair.server_sd)
lx_close(_socket_pair.server_sd);
- _registry()->remove(this);
+ _registry().remove(this);
}
diff --git a/repos/base-linux/src/core/ram_dataspace_support.cc b/repos/base-linux/src/core/ram_dataspace_support.cc
index 572e741ea6..1fe478bda9 100644
--- a/repos/base-linux/src/core/ram_dataspace_support.cc
+++ b/repos/base-linux/src/core/ram_dataspace_support.cc
@@ -33,7 +33,7 @@ using namespace Genode;
static int ram_ds_cnt = 0; /* counter for creating unique dataspace IDs */
-void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *ds)
+void Ram_dataspace_factory::_export_ram_ds(Dataspace_component &ds)
{
char fname[Linux_dataspace::FNAME_LEN];
@@ -41,10 +41,10 @@ void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *ds)
snprintf(fname, sizeof(fname), "%s/ds-%d", resource_path(), ram_ds_cnt++);
lx_unlink(fname);
int const fd = lx_open(fname, O_CREAT|O_RDWR|O_TRUNC|LX_O_CLOEXEC, S_IRWXU);
- lx_ftruncate(fd, ds->size());
+ lx_ftruncate(fd, ds.size());
/* remember file descriptor in dataspace component object */
- ds->fd(fd);
+ ds.fd(fd);
/*
* Wipe the file from the Linux file system. The kernel will still keep the
@@ -56,12 +56,12 @@ void Ram_dataspace_factory::_export_ram_ds(Dataspace_component *ds)
}
-void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component *ds)
+void Ram_dataspace_factory::_revoke_ram_ds(Dataspace_component &ds)
{
- int const fd = Capability_space::ipc_cap_data(ds->fd()).dst.socket;
+ int const fd = Capability_space::ipc_cap_data(ds.fd()).dst.socket;
if (fd != -1)
lx_close(fd);
}
-void Ram_dataspace_factory::_clear_ds(Dataspace_component *) { }
+void Ram_dataspace_factory::_clear_ds(Dataspace_component &) { }
diff --git a/repos/base-linux/src/core/rom_session_component.cc b/repos/base-linux/src/core/rom_session_component.cc
index 0292f35a9b..46f7045211 100644
--- a/repos/base-linux/src/core/rom_session_component.cc
+++ b/repos/base-linux/src/core/rom_session_component.cc
@@ -33,19 +33,29 @@
using namespace Genode;
-Rom_session_component::Rom_session_component(Rom_fs *,
- Rpc_entrypoint *ds_ep,
- const char *args)
-: _ds(args), _ds_ep(ds_ep)
+/**
+ * Convert 'Capability' to 'Capability'
+ *
+ * The downcast from 'Linux_dataspace' to 'Dataspace' happens implicitly by
+ * passing the argument. To upcast to 'Linux_dataspace' happens explicitly.
+ */
+static Capability rom_ds_cap(Capability cap)
{
- Dataspace_capability ds_cap = _ds_ep->manage(&_ds);
- _ds_cap = static_cap_cast(ds_cap);
+ return static_cap_cast(cap);
}
+Rom_session_component::Rom_session_component(Rom_fs &,
+ Rpc_entrypoint &ds_ep,
+ const char *args)
+:
+ _ds(args), _ds_ep(ds_ep), _ds_cap(rom_ds_cap(_ds_ep.manage(&_ds)))
+{ }
+
+
Rom_session_component::~Rom_session_component()
{
- _ds_ep->dissolve(&_ds);
+ _ds_ep.dissolve(&_ds);
int const fd = Capability_space::ipc_cap_data(_ds.fd()).dst.socket;
if (fd != -1)
diff --git a/repos/base-linux/src/core/thread_linux.cc b/repos/base-linux/src/core/thread_linux.cc
index 523fc6ba3a..b272a0ac0a 100644
--- a/repos/base-linux/src/core/thread_linux.cc
+++ b/repos/base-linux/src/core/thread_linux.cc
@@ -30,11 +30,11 @@ static void empty_signal_handler(int) { }
void Thread::_thread_start()
{
- Thread * const thread = Thread::myself();
+ Thread * const thread_ptr = Thread::myself();
/* use primary stack as alternate stack for fatal signals (exceptions) */
- void *stack_base = (void *)thread->_stack->base();
- size_t stack_size = thread->_stack->top() - thread->_stack->base();
+ void *stack_base = (void *)thread_ptr->_stack->base();
+ size_t stack_size = thread_ptr->_stack->top() - thread_ptr->_stack->base();
lx_sigaltstack(stack_base, stack_size);
diff --git a/repos/base-linux/src/include/base/internal/socket_descriptor_registry.h b/repos/base-linux/src/include/base/internal/socket_descriptor_registry.h
index c858448651..189c6970ab 100644
--- a/repos/base-linux/src/include/base/internal/socket_descriptor_registry.h
+++ b/repos/base-linux/src/include/base/internal/socket_descriptor_registry.h
@@ -33,7 +33,7 @@ namespace Genode
/**
* Return singleton instance of registry for tracking entrypoint sockets
*/
- Ep_socket_descriptor_registry *ep_sd_registry();
+ Ep_socket_descriptor_registry &ep_sd_registry();
}
diff --git a/repos/base-linux/src/lib/base/ipc.cc b/repos/base-linux/src/lib/base/ipc.cc
index 2ab0d75b00..3c9b63b4d2 100644
--- a/repos/base-linux/src/lib/base/ipc.cc
+++ b/repos/base-linux/src/lib/base/ipc.cc
@@ -91,10 +91,10 @@ static_assert((int)Protocol_header::INVALID_BADGE != (int)Rpc_obj_key::INVALID,
** File-descriptor registry **
******************************/
-Genode::Ep_socket_descriptor_registry *Genode::ep_sd_registry()
+Genode::Ep_socket_descriptor_registry &Genode::ep_sd_registry()
{
static Genode::Ep_socket_descriptor_registry registry;
- return ®istry;
+ return registry;
}
@@ -299,7 +299,7 @@ static void extract_sds_from_message(unsigned start_index,
int const sd = msg.socket_at_index(start_index + sd_cnt++);
int const id = lookup_tid_by_client_socket(sd);
- int const associated_sd = Genode::ep_sd_registry()->try_associate(sd, id);
+ int const associated_sd = Genode::ep_sd_registry().try_associate(sd, id);
Native_capability arg_cap = Capability_space::lookup(Rpc_obj_key(badge));
@@ -556,7 +556,7 @@ Ipc_server::~Ipc_server()
*/
Native_thread &native_thread = Thread::myself()->native_thread();
- Genode::ep_sd_registry()->disassociate(native_thread.socket_pair.client_sd);
+ Genode::ep_sd_registry().disassociate(native_thread.socket_pair.client_sd);
native_thread.is_ipc_server = false;
destroy_server_socket_pair(native_thread.socket_pair);
diff --git a/repos/base-nova/include/nova/cap_map.h b/repos/base-nova/include/nova/cap_map.h
index eda569c9a3..d87a93c632 100644
--- a/repos/base-nova/include/nova/cap_map.h
+++ b/repos/base-nova/include/nova/cap_map.h
@@ -115,7 +115,7 @@ namespace Genode {
Cap_index find(addr_t local_sel);
- void insert(Cap_range * range) { _tree.insert(range); }
+ void insert(Cap_range &range) { _tree.insert(&range); }
addr_t insert(size_t num_log_2 = 0, addr_t cap = ~0UL);
@@ -126,7 +126,7 @@ namespace Genode {
/**
* Get the global Capability_map of the process.
*/
- Capability_map *cap_map();
+ Capability_map &cap_map();
}
#endif /* _INCLUDE__NOVA__CAP_MAP_H_ */
diff --git a/repos/base-nova/src/core/core_region_map.cc b/repos/base-nova/src/core/core_region_map.cc
index b63bdb99be..6f7f544bd5 100644
--- a/repos/base-nova/src/core/core_region_map.cc
+++ b/repos/base-nova/src/core/core_region_map.cc
@@ -28,7 +28,7 @@ using namespace Genode;
/**
* Map dataspace core-locally
*/
-static inline void * alloc_region(Dataspace_component *ds, const size_t size)
+static inline void * alloc_region(Dataspace_component &ds, const size_t size)
{
/*
* Allocate range in core's virtual address space
@@ -37,10 +37,10 @@ static inline void * alloc_region(Dataspace_component *ds, const size_t size)
* successively weaken the alignment constraint until we hit the page size.
*/
void *virt_addr = 0;
- size_t align_log2 = log2(ds->size());
+ size_t align_log2 = log2(ds.size());
for (; align_log2 >= get_page_size_log2(); align_log2--) {
- if (platform()->region_alloc()->alloc_aligned(size,
- &virt_addr, align_log2).ok())
+ if (platform().region_alloc().alloc_aligned(size,
+ &virt_addr, align_log2).ok())
break;
}
@@ -53,10 +53,12 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t,
Region_map::Local_addr,
bool executable, bool writeable)
{
- auto lambda = [&] (Dataspace_component *ds) -> Local_addr {
- if (!ds)
+ auto lambda = [&] (Dataspace_component *ds_ptr) -> Local_addr {
+ if (!ds_ptr)
throw Invalid_dataspace();
+ Dataspace_component &ds = *ds_ptr;
+
if (use_local_addr) {
error("Parameter 'use_local_addr' not supported within core");
return nullptr;
@@ -67,7 +69,7 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t,
return nullptr;
}
- const size_t page_rounded_size = align_addr(ds->size(), get_page_size_log2());
+ const size_t page_rounded_size = align_addr(ds.size(), get_page_size_log2());
/* allocate the virtual region contiguous for the dataspace */
void * virt_ptr = alloc_region(ds, page_rounded_size);
@@ -75,13 +77,13 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t,
throw Out_of_ram();
/* map it */
- Nova::Utcb * const utcb = reinterpret_cast(Thread::myself()->utcb());
- const Nova::Rights rights(true, writeable && ds->writable(), executable);
+ Nova::Utcb &utcb = *reinterpret_cast(Thread::myself()->utcb());
+ const Nova::Rights rights(true, writeable && ds.writable(), executable);
- if (map_local(platform_specific()->core_pd_sel(), utcb,
- ds->phys_addr(), reinterpret_cast(virt_ptr),
+ if (map_local(platform_specific().core_pd_sel(), utcb,
+ ds.phys_addr(), reinterpret_cast(virt_ptr),
page_rounded_size >> get_page_size_log2(), rights, true)) {
- platform()->region_alloc()->free(virt_ptr, page_rounded_size);
+ platform().region_alloc().free(virt_ptr, page_rounded_size);
throw Out_of_ram();
}
@@ -93,10 +95,10 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t,
void Core_region_map::detach(Local_addr core_local_addr)
{
- size_t size = platform_specific()->region_alloc_size_at(core_local_addr);
+ size_t size = platform_specific().region_alloc_size_at(core_local_addr);
- unmap_local(reinterpret_cast(Thread::myself()->utcb()),
+ unmap_local(*reinterpret_cast(Thread::myself()->utcb()),
core_local_addr, size >> get_page_size_log2());
- platform()->region_alloc()->free(core_local_addr);
+ platform().region_alloc().free(core_local_addr);
}
diff --git a/repos/base-nova/src/core/core_rpc_cap_alloc.cc b/repos/base-nova/src/core/core_rpc_cap_alloc.cc
index b3b8a51d8a..395cabf125 100644
--- a/repos/base-nova/src/core/core_rpc_cap_alloc.cc
+++ b/repos/base-nova/src/core/core_rpc_cap_alloc.cc
@@ -24,7 +24,7 @@ using namespace Genode;
static Rpc_cap_factory &rpc_cap_factory()
{
- static Rpc_cap_factory inst(*platform()->core_mem_alloc());
+ static Rpc_cap_factory inst(platform().core_mem_alloc());
return inst;
}
diff --git a/repos/base-nova/src/core/include/ipc_pager.h b/repos/base-nova/src/core/include/ipc_pager.h
index 3b1008616b..9c113ec3ed 100644
--- a/repos/base-nova/src/core/include/ipc_pager.h
+++ b/repos/base-nova/src/core/include/ipc_pager.h
@@ -80,7 +80,7 @@ class Genode::Ipc_pager
public:
- Ipc_pager (Nova::Utcb *, addr_t pd_dst, addr_t pd_core);
+ Ipc_pager (Nova::Utcb &, addr_t pd_dst, addr_t pd_core);
/*
* Intel manual: 6.15 EXCEPTION AND INTERRUPT REFERENCE
diff --git a/repos/base-nova/src/core/include/map_local.h b/repos/base-nova/src/core/include/map_local.h
index b05bb22b0e..b8ee65928f 100644
--- a/repos/base-nova/src/core/include/map_local.h
+++ b/repos/base-nova/src/core/include/map_local.h
@@ -37,8 +37,8 @@ namespace Genode {
inline bool map_local(addr_t from_phys, addr_t to_virt, size_t num_pages,
bool read = true, bool write = true, bool exec = true)
{
- return (::map_local(platform_specific()->core_pd_sel(),
- (Nova::Utcb *)Thread::myself()->utcb(),
+ return (::map_local(platform_specific().core_pd_sel(),
+ *(Nova::Utcb *)Thread::myself()->utcb(),
from_phys, to_virt, num_pages,
Nova::Rights(read, write, exec), true) == 0);
}
@@ -51,8 +51,7 @@ namespace Genode {
*/
inline void unmap_local(addr_t virt, size_t num_pages)
{
- ::unmap_local((Nova::Utcb *)Thread::myself()->utcb(),
- virt, num_pages);
+ ::unmap_local(*(Nova::Utcb *)Thread::myself()->utcb(), virt, num_pages);
}
}
diff --git a/repos/base-nova/src/core/include/nova_util.h b/repos/base-nova/src/core/include/nova_util.h
index ab6a7b2615..37f5c594cd 100644
--- a/repos/base-nova/src/core/include/nova_util.h
+++ b/repos/base-nova/src/core/include/nova_util.h
@@ -55,17 +55,17 @@ inline Genode::addr_t boot_cpu()
* \param kern_pd Whether to map the items from the kernel or from core
* \param dma_mem Whether the memory is usable for DMA or not
*/
-static int map_local(Genode::addr_t const pd, Nova::Utcb * const utcb,
+static int map_local(Genode::addr_t const pd, Nova::Utcb &utcb,
Nova::Crd const src_crd, Nova::Crd const dst_crd,
bool const kern_pd = false, bool const dma_mem = false,
bool const write_combined = false)
{
/* asynchronously map capabilities */
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
/* ignore return value as one item always fits into the utcb */
- bool const ok = utcb->append_item(src_crd, 0, kern_pd, false, false,
- dma_mem, write_combined);
+ bool const ok = utcb.append_item(src_crd, 0, kern_pd, false, false,
+ dma_mem, write_combined);
(void)ok;
Nova::uint8_t res = Nova::delegate(pd, pd, dst_crd);
@@ -76,15 +76,15 @@ static int map_local(Genode::addr_t const pd, Nova::Utcb * const utcb,
Hex(src_crd.addr()), ":", Hex(src_crd.order()), ":", Hex(src_crd.type()), "->",
Hex(dst_crd.addr()), ":", Hex(dst_crd.order()), ":", Hex(dst_crd.type()), " - ",
"result=", Hex(res), " "
- "msg=", Hex(utcb->msg_items()), ":",
- Hex(utcb->msg_words()), ":",
- Hex(utcb->msg()[0]), " !!! "
- "utcb=", utcb, " "
+ "msg=", Hex(utcb.msg_items()), ":",
+ Hex(utcb.msg_words()), ":",
+ Hex(utcb.msg()[0]), " !!! "
+ "utcb=", &utcb, " "
"kern=", kern_pd);
return res > 0 ? res : -1;
}
/* clear receive window */
- utcb->crd_rcv = 0;
+ utcb.crd_rcv = 0;
return 0;
}
@@ -93,13 +93,13 @@ static int map_local(Genode::addr_t const pd, Nova::Utcb * const utcb,
static inline int unmap_local(Nova::Crd crd, bool self = true) {
return Nova::revoke(crd, self); }
-inline int map_local_phys_to_virt(Nova::Utcb * const utcb, Nova::Crd const src,
+inline int map_local_phys_to_virt(Nova::Utcb &utcb, Nova::Crd const src,
Nova::Crd const dst, Genode::addr_t const pd)
{
return map_local(pd, utcb, src, dst, true);
}
-inline int map_local_one_to_one(Nova::Utcb * const utcb, Nova::Crd const crd,
+inline int map_local_one_to_one(Nova::Utcb &utcb, Nova::Crd const crd,
Genode::addr_t const pd)
{
return map_local(pd, utcb, crd, crd, true);
@@ -128,7 +128,7 @@ lsb_bit(unsigned long const &value, unsigned char const shift = 0)
* \param to_start local virtual destination address
* \param num_pages number of pages to map
*/
-inline int map_local(Genode::addr_t const pd, Nova::Utcb *utcb,
+inline int map_local(Genode::addr_t const pd, Nova::Utcb &utcb,
Genode::addr_t from_start, Genode::addr_t to_start,
Genode::size_t num_pages,
Nova::Rights const &permission,
@@ -190,7 +190,7 @@ inline int map_local(Genode::addr_t const pd, Nova::Utcb *utcb,
* \param self map from this pd or solely from other pds
* \param rights rights to be revoked, default: all rwx
*/
-inline void unmap_local(Nova::Utcb *, Genode::addr_t start,
+inline void unmap_local(Nova::Utcb &, Genode::addr_t start,
Genode::size_t num_pages,
bool const self = true,
Nova::Rights const rwx = Nova::Rights(true, true, true))
@@ -236,13 +236,13 @@ inline Nova::uint8_t async_map(Genode::Pager_object &pager,
Genode::addr_t const target_pd,
Nova::Obj_crd const &source_initial_caps,
Nova::Obj_crd const &target_initial_caps,
- Nova::Utcb *utcb)
+ Nova::Utcb &utcb)
{
/* asynchronously map capabilities */
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
/* ignore return value as one item always fits into the utcb */
- bool const ok = utcb->append_item(source_initial_caps, 0);
+ bool const ok = utcb.append_item(source_initial_caps, 0);
(void)ok;
return syscall_retry(pager,
@@ -254,7 +254,7 @@ inline Nova::uint8_t async_map(Genode::Pager_object &pager,
inline Nova::uint8_t map_vcpu_portals(Genode::Pager_object &pager,
Genode::addr_t const source_exc_base,
Genode::addr_t const target_exc_base,
- Nova::Utcb *utcb,
+ Nova::Utcb &utcb,
Genode::addr_t const source_pd)
{
using Nova::Obj_crd;
@@ -271,12 +271,12 @@ inline Nova::uint8_t map_pagefault_portal(Genode::Pager_object &pager,
Genode::addr_t const source_exc_base,
Genode::addr_t const target_exc_base,
Genode::addr_t const target_pd,
- Nova::Utcb *utcb)
+ Nova::Utcb &utcb)
{
using Nova::Obj_crd;
using Nova::PT_SEL_PAGE_FAULT;
- Genode::addr_t const source_pd = Genode::platform_specific()->core_pd_sel();
+ Genode::addr_t const source_pd = Genode::platform_specific().core_pd_sel();
Obj_crd const source_initial_caps(source_exc_base + PT_SEL_PAGE_FAULT, 0);
Obj_crd const target_initial_caps(target_exc_base + PT_SEL_PAGE_FAULT, 0);
diff --git a/repos/base-nova/src/core/include/pager.h b/repos/base-nova/src/core/include/pager.h
index 1e79a909b7..f672203b8a 100644
--- a/repos/base-nova/src/core/include/pager.h
+++ b/repos/base-nova/src/core/include/pager.h
@@ -42,15 +42,15 @@ namespace Genode {
private:
template
- __attribute__((regparm(1))) static void _handler(addr_t);
+ __attribute__((regparm(1))) static void _handler(Pager_object &);
public:
- Exception_handlers(Pager_object *);
+ Exception_handlers(Pager_object &);
template
- void register_handler(Pager_object *, Nova::Mtd,
- void (__attribute__((regparm(1)))*)(addr_t) = nullptr);
+ void register_handler(Pager_object &, Nova::Mtd,
+ void (__attribute__((regparm(1)))*)(Pager_object &) = nullptr);
};
@@ -128,8 +128,8 @@ namespace Genode {
addr_t _pd_target;
- void _copy_state_from_utcb(Nova::Utcb * utcb);
- void _copy_state_to_utcb(Nova::Utcb * utcb);
+ void _copy_state_from_utcb(Nova::Utcb const &utcb);
+ void _copy_state_to_utcb(Nova::Utcb &utcb) const;
uint8_t _unsynchronized_client_recall(bool get_state_and_block);
@@ -139,16 +139,16 @@ namespace Genode {
addr_t sel_oom_portal() const { return _selectors + 3; }
__attribute__((regparm(1)))
- static void _page_fault_handler(addr_t pager_obj);
+ static void _page_fault_handler(Pager_object &);
__attribute__((regparm(1)))
- static void _startup_handler(addr_t pager_obj);
+ static void _startup_handler(Pager_object &);
__attribute__((regparm(1)))
- static void _invoke_handler(addr_t pager_obj);
+ static void _invoke_handler(Pager_object &);
__attribute__((regparm(1)))
- static void _recall_handler(addr_t pager_obj);
+ static void _recall_handler(Pager_object &);
__attribute__((regparm(3)))
static void _oom_handler(addr_t, addr_t, addr_t);
@@ -439,13 +439,13 @@ namespace Genode {
/**
* Associate Pager_object with the entry point
*/
- Pager_capability manage(Pager_object *) {
+ Pager_capability manage(Pager_object &) {
return Pager_capability(); }
/**
* Dissolve Pager_object from entry point
*/
- void dissolve(Pager_object *obj);
+ void dissolve(Pager_object &obj);
};
diff --git a/repos/base-nova/src/core/include/platform.h b/repos/base-nova/src/core/include/platform.h
index 303ba924e8..30c92693c3 100644
--- a/repos/base-nova/src/core/include/platform.h
+++ b/repos/base-nova/src/core/include/platform.h
@@ -72,21 +72,21 @@ namespace Genode {
** Generic platform interface **
********************************/
- Range_allocator *ram_alloc() override { return _core_mem_alloc.phys_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 _core_mem_alloc.virt_alloc(); }
- Range_allocator *core_mem_alloc() override { return &_core_mem_alloc; }
+ Range_allocator &ram_alloc() override { return _core_mem_alloc.phys_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 ®ion_alloc() override { return _core_mem_alloc.virt_alloc(); }
+ Range_allocator &core_mem_alloc() override { return _core_mem_alloc; }
addr_t vm_start() const override { return _vm_base; }
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 override { return _max_caps; }
+ void wait_for_exit() override;
- void wait_for_exit() override;
bool supports_direct_unmap() const override { return true; }
- Address_space * core_pd() { return nullptr; }
+ Address_space &core_pd() { ASSERT_NEVER_CALLED; }
Affinity::Space affinity_space() const override { return _cpus; }
@@ -105,7 +105,7 @@ namespace Genode {
* core_rm_session detach().
*/
size_t region_alloc_size_at(void * addr) {
- return (*_core_mem_alloc.virt_alloc())()->size_at(addr); }
+ return (_core_mem_alloc.virt_alloc())()->size_at(addr); }
/**
* Return kernel CPU ID for given Genode CPU
diff --git a/repos/base-nova/src/core/include/platform_pd.h b/repos/base-nova/src/core/include/platform_pd.h
index 0c80468d51..3525b5de63 100644
--- a/repos/base-nova/src/core/include/platform_pd.h
+++ b/repos/base-nova/src/core/include/platform_pd.h
@@ -42,7 +42,7 @@ namespace Genode {
/**
* Constructors
*/
- Platform_pd(Allocator * md_alloc, char const *,
+ Platform_pd(Allocator &md_alloc, char const *,
signed pd_id = -1, bool create = true);
/**
@@ -53,14 +53,14 @@ namespace Genode {
/**
* Bind thread to protection domain
*/
- 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
diff --git a/repos/base-nova/src/core/include/platform_thread.h b/repos/base-nova/src/core/include/platform_thread.h
index cdbd4d0b24..bef720d8b0 100644
--- a/repos/base-nova/src/core/include/platform_thread.h
+++ b/repos/base-nova/src/core/include/platform_thread.h
@@ -26,6 +26,7 @@
/* core includes */
#include
+#include
namespace Genode {
@@ -154,12 +155,18 @@ namespace Genode {
/**
* Set pager
*/
- void pager(Pager_object *pager);
+ void pager(Pager_object &pager);
/**
* Return pager object
*/
- Pager_object *pager() { return _pager; }
+ Pager_object &pager()
+ {
+ if (_pager)
+ return *_pager;
+
+ ASSERT_NEVER_CALLED;
+ }
/**
* Return identification of thread when faulting
diff --git a/repos/base-nova/src/core/include/signal_broker.h b/repos/base-nova/src/core/include/signal_broker.h
index 0380b02cbc..b61ee82e9f 100644
--- a/repos/base-nova/src/core/include/signal_broker.h
+++ b/repos/base-nova/src/core/include/signal_broker.h
@@ -89,11 +89,11 @@ class Genode::Signal_broker
return Signal_context_capability();
}
- Native_capability si = Capability_space::import(cap_map()->insert());
+ Native_capability si = Capability_space::import(cap_map().insert());
Signal_context_capability cap = reinterpret_cap_cast(si);
uint8_t res = Nova::create_si(cap.local_name(),
- platform_specific()->core_pd_sel(),
+ platform_specific().core_pd_sel(),
imprint, sm.local_name());
if (res != Nova::NOVA_OK) {
warning("creating signal failed - error ", res);
@@ -124,7 +124,7 @@ class Genode::Signal_broker
destroy(&_context_slab, context);
Nova::revoke(Nova::Obj_crd(context_cap.local_name(), 0));
- cap_map()->remove(context_cap.local_name(), 0);
+ cap_map().remove(context_cap.local_name(), 0);
}
void submit(Signal_context_capability, unsigned)
diff --git a/repos/base-nova/src/core/ipc_pager.cc b/repos/base-nova/src/core/ipc_pager.cc
index c772cb3262..1574d2ace5 100644
--- a/repos/base-nova/src/core/ipc_pager.cc
+++ b/repos/base-nova/src/core/ipc_pager.cc
@@ -23,17 +23,17 @@
using namespace Genode;
-Ipc_pager::Ipc_pager(Nova::Utcb * utcb, addr_t pd_dst, addr_t pd_core)
+Ipc_pager::Ipc_pager(Nova::Utcb &utcb, addr_t pd_dst, addr_t pd_core)
:
_pd_dst(pd_dst),
_pd_core(pd_core),
- _fault_ip(utcb->ip),
- _fault_addr(utcb->qual[1]),
- _sp(utcb->sp),
- _fault_type(utcb->qual[0]),
+ _fault_ip(utcb.ip),
+ _fault_addr(utcb.qual[1]),
+ _sp(utcb.sp),
+ _fault_type(utcb.qual[0]),
_syscall_res(Nova::NOVA_OK),
- _normal_ipc((((addr_t)&utcb->qual[2] - (addr_t)utcb->msg()) / sizeof(addr_t))
- == utcb->msg_words())
+ _normal_ipc((((addr_t)&utcb.qual[2] - (addr_t)utcb.msg()) / sizeof(addr_t))
+ == utcb.msg_words())
{
/*
@@ -46,10 +46,11 @@ Ipc_pager::Ipc_pager(Nova::Utcb * utcb, addr_t pd_dst, addr_t pd_core)
void Ipc_pager::set_reply_mapping(Mapping m)
{
- Nova::Utcb *utcb = (Nova::Utcb *)Thread::myself()->utcb();
- utcb->set_msg_word(0);
- bool res = utcb->append_item(m.mem_crd(), 0, true, false,
- false, m.dma(), m.write_combined());
+ Nova::Utcb &utcb = *(Nova::Utcb *)Thread::myself()->utcb();
+
+ utcb.set_msg_word(0);
+ bool res = utcb.append_item(m.mem_crd(), 0, true, false,
+ false, m.dma(), m.write_combined());
/* one item ever fits on the UTCB */
(void)res;
@@ -65,16 +66,16 @@ void Ipc_pager::set_reply_mapping(Mapping m)
void Ipc_pager::reply_and_wait_for_fault(addr_t sm)
{
- Thread * myself = Thread::myself();
- Nova::Utcb * utcb = reinterpret_cast(myself->utcb());
+ Thread &myself = *Thread::myself();
+ Nova::Utcb &utcb = *reinterpret_cast(myself.utcb());
- utcb->mtd = 0;
+ utcb.mtd = 0;
/*
* If it was a normal IPC and the mapping failed, caller may re-try.
* Otherwise nothing left to be delegated - done asynchronously beforehand.
*/
- utcb->set_msg_word((_normal_ipc && _syscall_res != Nova::NOVA_OK) ? 1 : 0);
+ utcb.set_msg_word((_normal_ipc && _syscall_res != Nova::NOVA_OK) ? 1 : 0);
- Nova::reply(myself->stack_top(), sm);
+ Nova::reply(myself.stack_top(), sm);
}
diff --git a/repos/base-nova/src/core/irq_session_component.cc b/repos/base-nova/src/core/irq_session_component.cc
index ce29d55e36..5e8dc711ca 100644
--- a/repos/base-nova/src/core/irq_session_component.cc
+++ b/repos/base-nova/src/core/irq_session_component.cc
@@ -70,7 +70,7 @@ static bool msi(Genode::addr_t irq_sel, Genode::addr_t phys_mem,
Genode::Signal_context_capability sig_cap)
{
void * virt = 0;
- if (platform()->region_alloc()->alloc_aligned(4096, &virt, 12).error())
+ if (platform().region_alloc().alloc_aligned(4096, &virt, 12).error())
return false;
Genode::addr_t virt_addr = reinterpret_cast(virt);
@@ -82,10 +82,10 @@ static bool msi(Genode::addr_t irq_sel, Genode::addr_t phys_mem,
Nova::Mem_crd phys_crd(phys_mem >> 12, 0, Rights(true, false, false));
Nova::Mem_crd virt_crd(virt_addr >> 12, 0, Rights(true, false, false));
- Utcb * utcb = reinterpret_cast(Thread::myself()->utcb());
+ Utcb &utcb = *reinterpret_cast(Thread::myself()->utcb());
- if (map_local_phys_to_virt(utcb, phys_crd, virt_crd, platform_specific()->core_pd_sel())) {
- platform()->region_alloc()->free(virt, 4096);
+ if (map_local_phys_to_virt(utcb, phys_crd, virt_crd, platform_specific().core_pd_sel())) {
+ platform().region_alloc().free(virt, 4096);
return false;
}
@@ -93,7 +93,7 @@ static bool msi(Genode::addr_t irq_sel, Genode::addr_t phys_mem,
bool res = associate(irq_sel, msi_addr, msi_data, sig_cap, virt_addr);
unmap_local(Nova::Mem_crd(virt_addr >> 12, 0, Rights(true, true, true)));
- platform()->region_alloc()->free(virt, 4096);
+ platform().region_alloc().free(virt, 4096);
return res;
}
@@ -138,12 +138,12 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys)
/* map IRQ SM cap from kernel to core at irq_sel selector */
using Nova::Obj_crd;
- Obj_crd src(platform_specific()->gsi_base_sel() + irq, 0);
+ Obj_crd src(platform_specific().gsi_base_sel() + irq, 0);
Obj_crd dst(irq_sel(), 0);
enum { MAP_FROM_KERNEL_TO_CORE = true };
- int ret = map_local(platform_specific()->core_pd_sel(),
- (Nova::Utcb *)Thread::myself()->utcb(),
+ int ret = map_local(platform_specific().core_pd_sel(),
+ *(Nova::Utcb *)Thread::myself()->utcb(),
src, dst, MAP_FROM_KERNEL_TO_CORE);
if (ret) {
error("getting IRQ from kernel failed - ", irq);
@@ -166,7 +166,7 @@ void Irq_object::start(unsigned irq, Genode::addr_t const device_phys)
Irq_object::Irq_object()
:
- _kernel_caps(cap_map()->insert(KERNEL_CAP_COUNT_LOG2)),
+ _kernel_caps(cap_map().insert(KERNEL_CAP_COUNT_LOG2)),
_msi_addr(0UL), _msi_data(0UL)
{ }
@@ -179,7 +179,7 @@ Irq_object::~Irq_object()
/* revoke IRQ SM */
Nova::revoke(Nova::Obj_crd(_kernel_caps, KERNEL_CAP_COUNT_LOG2));
enum { NO_REVOKE_REQUIRED = false };
- cap_map()->remove(_kernel_caps, KERNEL_CAP_COUNT_LOG2, NO_REVOKE_REQUIRED);
+ cap_map().remove(_kernel_caps, KERNEL_CAP_COUNT_LOG2, NO_REVOKE_REQUIRED);
}
@@ -188,18 +188,18 @@ Irq_object::~Irq_object()
***************************/
-static Nova::Hip * kernel_hip()
+static Nova::Hip const &kernel_hip()
{
/**
* Initial value of esp register, saved by the crt0 startup code.
* This value contains the address of the hypervisor information page.
*/
extern addr_t __initial_sp;
- return reinterpret_cast(__initial_sp);
+ return *reinterpret_cast(__initial_sp);
}
-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(~0U), _irq_alloc(irq_alloc), _irq_object()
@@ -208,16 +208,16 @@ Irq_session_component::Irq_session_component(Range_allocator *irq_alloc,
long device_phys = Arg_string::find_arg(args, "device_config_phys").long_value(0);
if (device_phys) {
- if ((unsigned long)irq_number >= kernel_hip()->sel_gsi)
+ if ((unsigned long)irq_number >= kernel_hip().sel_gsi)
throw Service_denied();
- irq_number = kernel_hip()->sel_gsi - 1 - irq_number;
+ irq_number = kernel_hip().sel_gsi - 1 - irq_number;
/* XXX last GSI number unknown - assume 40 GSIs (depends on IO-APIC) */
if (irq_number < 40)
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();
}
@@ -234,7 +234,7 @@ Irq_session_component::~Irq_session_component()
return;
Genode::addr_t free_irq = _irq_number;
- _irq_alloc->free((void *)free_irq);
+ _irq_alloc.free((void *)free_irq);
}
diff --git a/repos/base-nova/src/core/native_cpu_component.cc b/repos/base-nova/src/core/native_cpu_component.cc
index 0461edb150..f40b38e385 100644
--- a/repos/base-nova/src/core/native_cpu_component.cc
+++ b/repos/base-nova/src/core/native_cpu_component.cc
@@ -37,7 +37,7 @@ void Native_cpu_component::thread_type(Thread_capability thread_cap,
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);
}
diff --git a/repos/base-nova/src/core/pager.cc b/repos/base-nova/src/core/pager.cc
index b7711a5d85..9b0ac1f8c5 100644
--- a/repos/base-nova/src/core/pager.cc
+++ b/repos/base-nova/src/core/pager.cc
@@ -39,14 +39,14 @@ using namespace Genode;
using namespace Nova;
-static Nova::Hip * kernel_hip()
+static Nova::Hip const &kernel_hip()
{
/**
* Initial value of esp register, saved by the crt0 startup code.
* This value contains the address of the hypervisor information page.
*/
extern addr_t __initial_sp;
- return reinterpret_cast(__initial_sp);
+ return *reinterpret_cast(__initial_sp);
}
/* pager activation threads storage and handling - one thread per CPU */
@@ -56,14 +56,14 @@ static char pager_activation_mem[sizeof (Pager_activation) * P
static Pager_activation_base * pager_threads[PAGER_CPUS];
-static unsigned which_cpu(Pager_activation_base * pager)
+static unsigned which_cpu(Pager_activation_base &pager)
{
Pager_activation_base * start = reinterpret_cast(&pager_activation_mem);
Pager_activation_base * end = start + PAGER_CPUS;
- if (start <= pager && pager < end) {
+ if (start <= &pager && &pager < end) {
/* pager of one of the non boot CPUs */
- unsigned cpu_id = pager - start;
+ unsigned cpu_id = &pager - start;
return cpu_id;
}
@@ -106,40 +106,38 @@ struct Page_fault_info
};
-void Pager_object::_page_fault_handler(addr_t pager_obj)
+void Pager_object::_page_fault_handler(Pager_object &obj)
{
- Thread * myself = Thread::myself();
- Pager_object * obj = reinterpret_cast(pager_obj);
- Utcb * utcb = reinterpret_cast(myself->utcb());
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
- Ipc_pager ipc_pager(reinterpret_cast(utcb), obj->pd_sel(),
- platform_specific()->core_pd_sel());
+ Ipc_pager ipc_pager(utcb, obj.pd_sel(), platform_specific().core_pd_sel());
- Pager_activation_base * pager_thread = static_cast(myself);
+ Pager_activation_base &pager_thread = static_cast(myself);
/* potential request to ask for EC cap or signal SM cap */
- if (utcb->msg_words() == 1)
- _invoke_handler(pager_obj);
+ if (utcb.msg_words() == 1)
+ _invoke_handler(obj);
/*
- * obj->pager() (pager thread) may issue a signal to the remote region
+ * obj.pager() (pager thread) may issue a signal to the remote region
* handler thread which may respond via wake_up() (ep thread) before
* we are done here - we have to lock the whole page lookup procedure
*/
- obj->_state_lock.lock();
+ obj._state_lock.lock();
- obj->_state.thread.ip = ipc_pager.fault_ip();
- obj->_state.thread.sp = 0;
- obj->_state.thread.trapno = PT_SEL_PAGE_FAULT;
+ obj._state.thread.ip = ipc_pager.fault_ip();
+ obj._state.thread.sp = 0;
+ obj._state.thread.trapno = PT_SEL_PAGE_FAULT;
- obj->_state.block();
- obj->_state.block_pause_sm();
+ obj._state.block();
+ obj._state.block_pause_sm();
/* lookup fault address and decide what to do */
- int error = obj->pager(ipc_pager);
+ int error = obj.pager(ipc_pager);
/* don't open receive window for pager threads */
- if (utcb->crd_rcv.value())
+ if (utcb.crd_rcv.value())
nova_die();
if (!error && ipc_pager.syscall_result() != Nova::NOVA_OK) {
@@ -148,13 +146,14 @@ void Pager_object::_page_fault_handler(addr_t pager_obj)
/* dst pd has not enough kernel quota ? - try to recover */
if (ipc_pager.syscall_result() == Nova::NOVA_PD_OOM) {
- uint8_t res = obj->handle_oom();
+ uint8_t res = obj.handle_oom();
if (res == Nova::NOVA_PD_OOM) {
- obj->_state.unblock_pause_sm();
- obj->_state.unblock();
- obj->_state_lock.unlock();
+ obj._state.unblock_pause_sm();
+ obj._state.unblock();
+ obj._state_lock.unlock();
+
/* block until revoke is due */
- ipc_pager.reply_and_wait_for_fault(obj->sel_sm_block_oom());
+ ipc_pager.reply_and_wait_for_fault(obj.sel_sm_block_oom());
} else if (res == Nova::NOVA_OK)
/* succeeded to recover - continue normally */
error = 0;
@@ -163,14 +162,14 @@ void Pager_object::_page_fault_handler(addr_t pager_obj)
/* good case - found a valid region which is mappable */
if (!error) {
- obj->_state.unblock_pause_sm();
- obj->_state.unblock();
- obj->_state_lock.unlock();
+ obj._state.unblock_pause_sm();
+ obj._state.unblock();
+ obj._state_lock.unlock();
ipc_pager.reply_and_wait_for_fault();
}
- const char * client_thread = obj->client_thread();
- const char * client_pd = obj->client_pd();
+ char const * const client_thread = obj.client_thread();
+ char const * const client_pd = obj.client_pd();
Page_fault_info const fault_info(client_pd, client_thread,
which_cpu(pager_thread),
@@ -182,29 +181,30 @@ void Pager_object::_page_fault_handler(addr_t pager_obj)
/* region manager fault - to be handled */
log("page fault, ", fault_info, " reason=", error);
- obj->_state_lock.unlock();
+ obj._state_lock.unlock();
/* block the faulting thread until region manager is done */
- ipc_pager.reply_and_wait_for_fault(obj->sel_sm_block_pause());
+ ipc_pager.reply_and_wait_for_fault(obj.sel_sm_block_pause());
}
void Pager_object::exception(uint8_t exit_id)
{
- Thread *myself = Thread::myself();
- Utcb * utcb = reinterpret_cast(myself->utcb());
- Pager_activation_base * pager_thread = static_cast(myself);
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
+ Pager_activation_base &pager_thread = static_cast(myself);
- if (exit_id > PT_SEL_PARENT || !pager_thread)
+ if (exit_id > PT_SEL_PARENT)
nova_die();
- addr_t fault_ip = utcb->ip;
- uint8_t res = 0xFF;
- addr_t mtd = 0;
+ addr_t const fault_ip = utcb.ip;
+
+ uint8_t res = 0xFF;
+ addr_t mtd = 0;
_state_lock.lock();
- /* remember exception type for cpu_session()->state() calls */
+ /* remember exception type for Cpu_session::state() calls */
_state.thread.trapno = exit_id;
if (_exception_sigh.valid()) {
@@ -229,117 +229,113 @@ void Pager_object::exception(uint8_t exit_id)
enum { TRAP_BREAKPOINT = 3 };
if (exit_id == TRAP_BREAKPOINT) {
- utcb->ip = fault_ip - 1;
- mtd = Mtd::EIP;
+ utcb.ip = fault_ip - 1;
+ mtd = Mtd::EIP;
}
}
_state_lock.unlock();
- utcb->set_msg_word(0);
- utcb->mtd = mtd;
+ utcb.set_msg_word(0);
+ utcb.mtd = mtd;
- reply(myself->stack_top());
+ reply(myself.stack_top());
}
-void Pager_object::_recall_handler(addr_t pager_obj)
+void Pager_object::_recall_handler(Pager_object &obj)
{
- Thread * myself = Thread::myself();
- Pager_object * obj = reinterpret_cast(pager_obj);
- Utcb * utcb = reinterpret_cast(myself->utcb());
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
- obj->_state_lock.lock();
+ obj._state_lock.lock();
- if (obj->_state.modified) {
- obj->_copy_state_to_utcb(utcb);
- obj->_state.modified = false;
+ if (obj._state.modified) {
+ obj._copy_state_to_utcb(utcb);
+ obj._state.modified = false;
} else
- utcb->mtd = 0;
+ utcb.mtd = 0;
/* switch on/off single step */
- bool singlestep_state = obj->_state.thread.eflags & 0x100UL;
- if (obj->_state.singlestep() && !singlestep_state) {
- utcb->flags |= 0x100UL;
- utcb->mtd |= Mtd::EFL;
- } else if (!obj->_state.singlestep() && singlestep_state) {
- utcb->flags &= ~0x100UL;
- utcb->mtd |= Mtd::EFL;
+ bool singlestep_state = obj._state.thread.eflags & 0x100UL;
+ if (obj._state.singlestep() && !singlestep_state) {
+ utcb.flags |= 0x100UL;
+ utcb.mtd |= Mtd::EFL;
+ } else if (!obj._state.singlestep() && singlestep_state) {
+ utcb.flags &= ~0x100UL;
+ utcb.mtd |= Mtd::EFL;
}
/* deliver signal if it was requested */
- if (obj->_state.to_submit())
- obj->submit_exception_signal();
+ if (obj._state.to_submit())
+ obj.submit_exception_signal();
- /* block until cpu_session()->resume() respectively wake_up() call */
+ /* block until Cpu_session()::resume() respectively wake_up() call */
unsigned long sm = 0;
- if (obj->_state.blocked()) {
- sm = obj->sel_sm_block_pause();
- obj->_state.block_pause_sm();
+ if (obj._state.blocked()) {
+ sm = obj.sel_sm_block_pause();
+ obj._state.block_pause_sm();
}
- obj->_state_lock.unlock();
+ obj._state_lock.unlock();
- utcb->set_msg_word(0);
- reply(myself->stack_top(), sm);
+ utcb.set_msg_word(0);
+ reply(myself.stack_top(), sm);
}
-void Pager_object::_startup_handler(addr_t pager_obj)
+void Pager_object::_startup_handler(Pager_object &obj)
{
- Thread *myself = Thread::myself();
- Pager_object * obj = reinterpret_cast(pager_obj);
- Utcb * utcb = reinterpret_cast(myself->utcb());
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
- utcb->ip = obj->_initial_eip;
- utcb->sp = obj->_initial_esp;
+ utcb.ip = obj._initial_eip;
+ utcb.sp = obj._initial_esp;
+ utcb.mtd = Mtd::EIP | Mtd::ESP;
- utcb->mtd = Mtd::EIP | Mtd::ESP;
-
- if (obj->_state.singlestep()) {
- utcb->flags = 0x100UL;
- utcb->mtd |= Mtd::EFL;
+ if (obj._state.singlestep()) {
+ utcb.flags = 0x100UL;
+ utcb.mtd |= Mtd::EFL;
}
- obj->_state.unblock();
+ obj._state.unblock();
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
- reply(myself->stack_top());
+ reply(myself.stack_top());
}
-void Pager_object::_invoke_handler(addr_t pager_obj)
+void Pager_object::_invoke_handler(Pager_object &obj)
{
- Thread *myself = Thread::myself();
- Pager_object * obj = reinterpret_cast(pager_obj);
- Utcb * utcb = reinterpret_cast(myself->utcb());
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
/* receive window must be closed - otherwise implementation bug */
- if (utcb->crd_rcv.value())
+ if (utcb.crd_rcv.value())
nova_die();
/* if protocol is violated ignore request */
- if (utcb->msg_words() != 1) {
- utcb->mtd = 0;
- utcb->set_msg_word(0);
- reply(myself->stack_top());
+ if (utcb.msg_words() != 1) {
+ utcb.mtd = 0;
+ utcb.set_msg_word(0);
+ reply(myself.stack_top());
}
- addr_t const event = utcb->msg()[0];
+ addr_t const event = utcb.msg()[0];
/* check for translated pager portals - required for vCPU in remote PDs */
- if (utcb->msg_items() == 1 && utcb->msg_words() == 1 && event == 0xaffe) {
+ if (utcb.msg_items() == 1 && utcb.msg_words() == 1 && event == 0xaffe) {
- Nova::Utcb::Item const * const item = utcb->get_item(0);
- Nova::Crd const cap(item->crd);
+ Nova::Utcb::Item const &item = *utcb.get_item(0);
+ Nova::Crd const cap(item.crd);
/* valid item which got translated ? */
- if (!cap.is_null() && !item->is_del()) {
- Rpc_entrypoint *e = core_env()->entrypoint();
- e->apply(cap.base(),
+ if (!cap.is_null() && !item.is_del()) {
+ Rpc_entrypoint &e = core_env().entrypoint();
+ e.apply(cap.base(),
[&] (Cpu_thread_component *source) {
if (!source)
return;
@@ -350,22 +346,22 @@ void Pager_object::_invoke_handler(addr_t pager_obj)
return;
/* delegate VM-exit portals */
- map_vcpu_portals(*p.pager(), sel_exc_base, sel_exc_base,
- utcb, obj->pd_sel());
+ map_vcpu_portals(p.pager(), sel_exc_base, sel_exc_base,
+ utcb, obj.pd_sel());
/* delegate portal to contact pager */
- map_pagefault_portal(*obj, p.pager()->exc_pt_sel_client(),
- sel_exc_base, obj->pd_sel(), utcb);
+ map_pagefault_portal(obj, p.pager().exc_pt_sel_client(),
+ sel_exc_base, obj.pd_sel(), utcb);
});
}
- utcb->mtd = 0;
- utcb->set_msg_word(0);
- reply(myself->stack_top());
+ utcb.mtd = 0;
+ utcb.set_msg_word(0);
+ reply(myself.stack_top());
}
- utcb->mtd = 0;
- utcb->set_msg_word(0);
+ utcb.mtd = 0;
+ utcb.set_msg_word(0);
/* native ec cap requested */
if (event == ~0UL) {
@@ -382,32 +378,32 @@ void Pager_object::_invoke_handler(addr_t pager_obj)
* takes care that the EC cap itself contains
* no usable rights for the clients.
*/
- bool res = utcb->append_item(Obj_crd(obj->_state.sel_client_ec, 0,
- Obj_crd::RIGHT_EC_RECALL), 0);
+ bool res = utcb.append_item(Obj_crd(obj._state.sel_client_ec, 0,
+ Obj_crd::RIGHT_EC_RECALL), 0);
(void)res;
}
/* semaphore for signaling thread is requested, reuse PT_SEL_STARTUP. */
if (event == ~0UL - 1) {
/* create semaphore only once */
- if (!obj->_state.has_signal_sm()) {
+ if (!obj._state.has_signal_sm()) {
- revoke(Obj_crd(obj->exc_pt_sel_client() + PT_SEL_STARTUP, 0));
+ revoke(Obj_crd(obj.exc_pt_sel_client() + PT_SEL_STARTUP, 0));
- bool res = Nova::create_sm(obj->exc_pt_sel_client() + PT_SEL_STARTUP,
- platform_specific()->core_pd_sel(), 0);
+ bool res = Nova::create_sm(obj.exc_pt_sel_client() + PT_SEL_STARTUP,
+ platform_specific().core_pd_sel(), 0);
if (res != Nova::NOVA_OK)
- reply(myself->stack_top());
+ reply(myself.stack_top());
- obj->_state.mark_signal_sm();
+ obj._state.mark_signal_sm();
}
- bool res = utcb->append_item(Obj_crd(obj->exc_pt_sel_client() +
- PT_SEL_STARTUP, 0), 0);
+ bool res = utcb.append_item(Obj_crd(obj.exc_pt_sel_client() +
+ PT_SEL_STARTUP, 0), 0);
(void)res;
}
- reply(myself->stack_top());
+ reply(myself.stack_top());
}
@@ -467,7 +463,7 @@ uint8_t Pager_object::_unsynchronized_client_recall(bool get_state_and_block)
return res;
if (get_state_and_block) {
- Utcb *utcb = reinterpret_cast(Thread::myself()->utcb());
+ Utcb &utcb = *reinterpret_cast(Thread::myself()->utcb());
_copy_state_from_utcb(utcb);
_state.block();
}
@@ -487,17 +483,17 @@ void Pager_object::cleanup_call()
/* revoke all portals handling the client. */
revoke(Obj_crd(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2));
- Utcb *utcb = reinterpret_cast(Thread::myself()->utcb());
- utcb->set_msg_word(0);
- utcb->mtd = 0;
+ Utcb &utcb = *reinterpret_cast(Thread::myself()->utcb());
+ utcb.set_msg_word(0);
+ utcb.mtd = 0;
if (uint8_t res = call(sel_pt_cleanup()))
- error(utcb, " - cleanup call to pager failed res=", res);
+ error(&utcb, " - cleanup call to pager failed res=", res);
}
void Pager_object::print(Output &out) const
{
- Platform_thread * faulter = reinterpret_cast(_badge);
+ Platform_thread const * const faulter = reinterpret_cast(_badge);
Genode::print(out, "pager_object: pd='",
faulter ? faulter->pd_name() : "unknown", "' thread='",
faulter ? faulter->name() : "unknown", "'");
@@ -530,13 +526,13 @@ static uint8_t create_portal(addr_t pt, addr_t pd, addr_t ec, Mtd mtd,
************************/
template
-void Exception_handlers::register_handler(Pager_object *obj, Mtd mtd,
- void (* __attribute__((regparm(1))) func)(addr_t))
+void Exception_handlers::register_handler(Pager_object &obj, Mtd mtd,
+ void (* __attribute__((regparm(1))) func)(Pager_object &))
{
- unsigned const genode_cpu_id = obj->location().xpos();
- unsigned const kernel_cpu_id = platform_specific()->kernel_cpu_id(genode_cpu_id);
+ unsigned const genode_cpu_id = obj.location().xpos();
+ unsigned const kernel_cpu_id = platform_specific().kernel_cpu_id(genode_cpu_id);
- if (!kernel_hip()->is_cpu_enabled(kernel_cpu_id) ||
+ if (!kernel_hip().is_cpu_enabled(kernel_cpu_id) ||
!pager_threads[genode_cpu_id]) {
warning("invalid CPU parameter used in pager object");
throw Invalid_thread();
@@ -546,22 +542,21 @@ void Exception_handlers::register_handler(Pager_object *obj, Mtd mtd,
/* compiler generates instance of exception entry if not specified */
addr_t entry = func ? (addr_t)func : (addr_t)(&_handler);
- uint8_t res = create_portal(obj->exc_pt_sel_client() + EV,
- platform_specific()->core_pd_sel(), ec_sel, mtd, entry, obj);
+ uint8_t res = create_portal(obj.exc_pt_sel_client() + EV,
+ platform_specific().core_pd_sel(), ec_sel, mtd, entry, &obj);
if (res != Nova::NOVA_OK)
throw Invalid_thread();
}
template
-void Exception_handlers::_handler(addr_t obj)
+void Exception_handlers::_handler(Pager_object &obj)
{
- Pager_object * pager_obj = reinterpret_cast(obj);
- pager_obj->exception(EV);
+ obj.exception(EV);
}
-Exception_handlers::Exception_handlers(Pager_object *obj)
+Exception_handlers::Exception_handlers(Pager_object &obj)
{
register_handler<0>(obj, Mtd(Mtd::EIP));
register_handler<1>(obj, Mtd(Mtd::EIP));
@@ -603,16 +598,16 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
Cpu_session::Name const &)
:
_badge(badge),
- _selectors(cap_map()->insert(2)),
- _client_exc_pt_sel(cap_map()->insert(NUM_INITIAL_PT_LOG2)),
+ _selectors(cap_map().insert(2)),
+ _client_exc_pt_sel(cap_map().insert(NUM_INITIAL_PT_LOG2)),
_cpu_session_cap(cpu_session_cap), _thread_cap(thread_cap),
_location(location),
- _exceptions(this),
+ _exceptions(*this),
_pd_target(Native_thread::INVALID_INDEX)
{
uint8_t res;
- addr_t const pd_sel = platform_specific()->core_pd_sel();
+ addr_t const pd_sel = platform_specific().core_pd_sel();
_state._status = 0;
_state.modified = false;
_state.sel_client_ec = Native_thread::INVALID_INDEX;
@@ -630,8 +625,8 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
/* place Pager_object on specified CPU by selecting proper pager thread */
unsigned const genode_cpu_id = location.xpos();
- unsigned const kernel_cpu_id = platform_specific()->kernel_cpu_id(genode_cpu_id);
- if (!kernel_hip()->is_cpu_enabled(kernel_cpu_id) ||
+ unsigned const kernel_cpu_id = platform_specific().kernel_cpu_id(genode_cpu_id);
+ if (!kernel_hip().is_cpu_enabled(kernel_cpu_id) ||
!pager_threads[genode_cpu_id]) {
warning("invalid CPU parameter used in pager object");
throw Invalid_thread();
@@ -640,18 +635,18 @@ Pager_object::Pager_object(Cpu_session_capability cpu_session_cap,
addr_t ec_sel = pager_threads[genode_cpu_id]->native_thread().ec_sel;
/* create portal for page-fault handler - 14 */
- _exceptions.register_handler<14>(this, Mtd::QUAL | Mtd::EIP,
+ _exceptions.register_handler<14>(*this, Mtd::QUAL | Mtd::EIP,
_page_fault_handler);
/* create portal for startup handler - 26 */
Mtd const mtd_startup(Mtd::ESP | Mtd::EIP);
- _exceptions.register_handler(this, mtd_startup,
+ _exceptions.register_handler(*this, mtd_startup,
_startup_handler);
/* create portal for recall handler - 31 */
Mtd const mtd_recall(Mtd::ESP | Mtd::EIP | Mtd::ACDB | Mtd::EFL |
Mtd::EBSD | Mtd::FSGS);
- _exceptions.register_handler(this, mtd_recall,
+ _exceptions.register_handler(*this, mtd_recall,
_recall_handler);
/*
@@ -693,8 +688,8 @@ Pager_object::~Pager_object()
/* revoke portal used for the cleanup call and sm cap for blocking state */
revoke(Obj_crd(_selectors, 2));
- cap_map()->remove(_selectors, 2, false);
- cap_map()->remove(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2, false);
+ cap_map().remove(_selectors, 2, false);
+ cap_map().remove(exc_pt_sel_client(), NUM_INITIAL_PT_LOG2, false);
}
@@ -711,7 +706,7 @@ uint8_t Pager_object::handle_oom(addr_t pd_from, addr_t pd_to,
Policy policy, addr_t sm_notify,
char const * dst_pd, char const * dst_thread)
{
- addr_t const core_pd_sel = platform_specific()->core_pd_sel();
+ addr_t const core_pd_sel = platform_specific().core_pd_sel();
enum { QUOTA_TRANSFER_PAGES = 2 };
@@ -794,10 +789,10 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
asm volatile ("" : "=S" (reason));
}
- Thread * myself = Thread::myself();
- Utcb * utcb = reinterpret_cast(myself->utcb());
- Pager_object * obj_dst = reinterpret_cast(pager_dst);
- Pager_object * obj_src = reinterpret_cast(pager_src);
+ Thread &myself = *Thread::myself();
+ Utcb &utcb = *reinterpret_cast(myself.utcb());
+ Pager_object &obj_dst = *reinterpret_cast(pager_dst);
+ Pager_object &obj_src = *reinterpret_cast(pager_src);
/* Policy used if the Process of the paged thread runs out of memory */
enum Policy policy = Policy::UPGRADE_CORE_TO_DST;
@@ -819,19 +814,19 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
* This pager thread should never send words (untyped items) - it just
* answers page faults by typed items (memory mappings).
*/
- assert |= utcb->msg_words();
+ assert |= utcb.msg_words();
if (assert) {
error("unknown OOM case - stop core pager thread");
- utcb->set_msg_word(0);
- reply(myself->stack_top(), myself->native_thread().exc_pt_sel + Nova::SM_SEL_EC);
+ utcb.set_msg_word(0);
+ reply(myself.stack_top(), myself.native_thread().exc_pt_sel + Nova::SM_SEL_EC);
}
/* be strict in case of the -strict- STOP policy - stop causing thread */
if (policy == STOP) {
error("PD has insufficient kernel memory left - stop thread");
- utcb->set_msg_word(0);
- reply(myself->stack_top(), obj_dst->sel_sm_block_pause());
+ utcb.set_msg_word(0);
+ reply(myself.stack_top(), obj_dst.sel_sm_block_pause());
}
char const * src_pd = "core";
@@ -843,8 +838,8 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
case SRC_PD_UNKNOWN:
/* should not happen on Genode - we create and know every PD in core */
error("Unknown PD has insufficient kernel memory left - stop thread");
- utcb->set_msg_word(0);
- reply(myself->stack_top(), myself->native_thread().exc_pt_sel + Nova::SM_SEL_EC);
+ utcb.set_msg_word(0);
+ reply(myself.stack_top(), myself.native_thread().exc_pt_sel + Nova::SM_SEL_EC);
case SRC_CORE_PD:
/* core PD -> other PD, which has insufficient kernel resources */
@@ -852,33 +847,32 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
if (!(reason & SELF)) {
/* case that src thread != this thread in core */
src_thread = "unknown";
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
}
- transfer_from = platform_specific()->core_pd_sel();
+ transfer_from = platform_specific().core_pd_sel();
break;
default:
/* non core PD -> non core PD */
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
if (pager_src == pager_dst || policy == UPGRADE_CORE_TO_DST)
- transfer_from = platform_specific()->core_pd_sel();
+ transfer_from = platform_specific().core_pd_sel();
else {
/* delegation of items between different PDs */
- src_pd = obj_src->client_pd();
- src_thread = obj_src->client_thread();
- transfer_from = obj_src->pd_sel();
+ src_pd = obj_src.client_pd();
+ src_thread = obj_src.client_thread();
+ transfer_from = obj_src.pd_sel();
}
}
- uint8_t res = obj_dst->handle_oom(transfer_from, src_pd, src_thread,
- policy);
+ uint8_t res = obj_dst.handle_oom(transfer_from, src_pd, src_thread, policy);
if (res == Nova::NOVA_OK)
/* handling succeeded - continue with original IPC */
- reply(myself->stack_top());
+ reply(myself.stack_top());
/* transfer nothing */
- utcb->set_msg_word(0);
+ utcb.set_msg_word(0);
if (res != Nova::NOVA_PD_OOM)
error("upgrading kernel memory failed, policy ", (int)policy, ", "
@@ -887,7 +881,7 @@ void Pager_object::_oom_handler(addr_t pager_dst, addr_t pager_src,
/* else: caller will get blocked until RCU period is over */
/* block caller in semaphore */
- reply(myself->stack_top(), obj_dst->sel_sm_block_oom());
+ reply(myself.stack_top(), obj_dst.sel_sm_block_oom());
}
@@ -895,10 +889,10 @@ addr_t Pager_object::get_oom_portal()
{
addr_t const pt_oom = sel_oom_portal();
unsigned const genode_cpu_id = _location.xpos();
- unsigned const kernel_cpu_id = platform_specific()->kernel_cpu_id(genode_cpu_id);
- addr_t const core_pd_sel = platform_specific()->core_pd_sel();
+ unsigned const kernel_cpu_id = platform_specific().kernel_cpu_id(genode_cpu_id);
+ addr_t const core_pd_sel = platform_specific().core_pd_sel();
- if (kernel_hip()->is_cpu_enabled(kernel_cpu_id) &&
+ if (kernel_hip().is_cpu_enabled(kernel_cpu_id) &&
pager_threads[genode_cpu_id]) {
addr_t const ec_sel = pager_threads[genode_cpu_id]->native_thread().ec_sel;
@@ -934,7 +928,7 @@ const char * Pager_object::client_pd() const
Pager_activation_base::Pager_activation_base(const char *name, size_t stack_size)
:
Thread(Cpu_session::Weight::DEFAULT_WEIGHT, name, stack_size,
- Affinity::Location(which_cpu(this), 0)),
+ Affinity::Location(which_cpu(*this), 0)),
_cap(Native_capability()), _ep(0), _cap_valid(Lock::LOCKED)
{
/* creates local EC */
@@ -954,8 +948,8 @@ void Pager_activation_base::entry() { }
Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
{
/* sanity check for pager threads */
- if (kernel_hip()->cpu_max() > PAGER_CPUS) {
- error("kernel supports more CPUs (", kernel_hip()->cpu_max(), ") "
+ if (kernel_hip().cpu_max() > PAGER_CPUS) {
+ error("kernel supports more CPUs (", kernel_hip().cpu_max(), ") "
"than Genode (", (unsigned)PAGER_CPUS, ")");
nova_die();
}
@@ -964,9 +958,9 @@ Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
typedef Pager_activation Pager;
Pager * pager_of_cpu = reinterpret_cast(&pager_activation_mem);
- for (unsigned i = 0; i < kernel_hip()->cpus(); i++, pager_of_cpu++) {
- unsigned const kernel_cpu_id = platform_specific()->kernel_cpu_id(i);
- if (!kernel_hip()->is_cpu_enabled(kernel_cpu_id))
+ for (unsigned i = 0; i < kernel_hip().cpus(); i++, pager_of_cpu++) {
+ unsigned const kernel_cpu_id = platform_specific().kernel_cpu_id(i);
+ if (!kernel_hip().is_cpu_enabled(kernel_cpu_id))
continue;
pager_threads[i] = pager_of_cpu;
@@ -975,8 +969,8 @@ Pager_entrypoint::Pager_entrypoint(Rpc_cap_factory &)
}
-void Pager_entrypoint::dissolve(Pager_object *obj)
+void Pager_entrypoint::dissolve(Pager_object &obj)
{
/* take care that no faults are in-flight */
- obj->cleanup_call();
+ obj.cleanup_call();
}
diff --git a/repos/base-nova/src/core/pd_session_support.cc b/repos/base-nova/src/core/pd_session_support.cc
index 204fb09ad0..99a25a0a30 100644
--- a/repos/base-nova/src/core/pd_session_support.cc
+++ b/repos/base-nova/src/core/pd_session_support.cc
@@ -11,8 +11,9 @@
* under the terms of the GNU Affero General Public License version 3.
*/
-/* Core */
+/* core */
#include
+#include
using namespace Genode;
@@ -34,10 +35,10 @@ bool Pd_session_component::assign_pci(addr_t pci_config_memory, uint16_t bdf)
void Pd_session_component::map(addr_t virt, addr_t size)
{
- Genode::addr_t const pd_core = platform_specific()->core_pd_sel();
+ Genode::addr_t const pd_core = platform_specific().core_pd_sel();
Platform_pd &target_pd = *_pd;
Genode::addr_t const pd_dst = target_pd.pd_sel();
- Nova::Utcb *utcb = reinterpret_cast(Thread::myself()->utcb());
+ Nova::Utcb &utcb = *reinterpret_cast(Thread::myself()->utcb());
auto lambda = [&] (Region_map_component *region_map,
Rm_region *region,
@@ -45,26 +46,29 @@ void Pd_session_component::map(addr_t virt, addr_t size)
addr_t const region_offset,
addr_t const dst_region_size) -> addr_t
{
- Dataspace_component * dsc = region ? region->dataspace() : nullptr;
+ Dataspace_component * dsc = region ? ®ion->dataspace() : nullptr;
if (!dsc) {
struct No_dataspace{};
throw No_dataspace();
}
+ if (!region_map) {
+ ASSERT_NEVER_CALLED;
+ }
Mapping mapping = Region_map_component::create_map_item(region_map,
- region,
+ *region,
ds_offset,
region_offset,
- dsc, virt,
+ *dsc, virt,
dst_region_size);
/* asynchronously map memory */
uint8_t err = Nova::NOVA_PD_OOM;
do {
- utcb->set_msg_word(0);
- bool res = utcb->append_item(mapping.mem_crd(), 0, true, false,
- false, mapping.dma(),
- mapping.write_combined());
+ utcb.set_msg_word(0);
+ bool res = utcb.append_item(mapping.mem_crd(), 0, true, false,
+ false, mapping.dma(),
+ mapping.write_combined());
/* one item ever fits on the UTCB */
(void)res;
diff --git a/repos/base-nova/src/core/platform.cc b/repos/base-nova/src/core/platform.cc
index 7535207683..ec4247afbc 100644
--- a/repos/base-nova/src/core/platform.cc
+++ b/repos/base-nova/src/core/platform.cc
@@ -58,7 +58,7 @@ extern addr_t __initial_sp;
/**
* Pointer to the UTCB of the main thread
*/
-Utcb *__main_thread_utcb;
+static Utcb *__main_thread_utcb;
/**
@@ -79,14 +79,14 @@ addr_t Platform::_map_pages(addr_t const phys_addr, addr_t const pages,
addr_t const size = pages << get_page_size_log2();
/* try to reserve contiguous virtual area */
- void *core_local_ptr = 0;
- if (region_alloc()->alloc_aligned(size + (guard_page ? get_page_size() : 0),
- &core_local_ptr, get_page_size_log2()).error())
+ void *core_local_ptr = nullptr;
+ if (region_alloc().alloc_aligned(size + (guard_page ? get_page_size() : 0),
+ &core_local_ptr, get_page_size_log2()).error())
return 0;
addr_t const core_local_addr = reinterpret_cast(core_local_ptr);
- int res = map_local(_core_pd_sel, __main_thread_utcb, phys_addr,
+ int res = map_local(_core_pd_sel, *__main_thread_utcb, phys_addr,
core_local_addr, pages,
Nova::Rights(true, true, false), true);
@@ -226,7 +226,7 @@ static addr_t init_core_page_fault_handler(addr_t const core_pd_sel)
EXC_BASE = 0
};
- addr_t ec_sel = cap_map()->insert(1);
+ addr_t ec_sel = cap_map().insert(1);
uint8_t ret = create_ec(ec_sel, core_pd_sel, boot_cpu(),
CORE_PAGER_UTCB_ADDR, core_pager_stack_top(),
@@ -276,14 +276,15 @@ struct Resolution : Register<64>
** Platform **
**************/
-Platform::Platform() :
- _io_mem_alloc(core_mem_alloc()), _io_port_alloc(core_mem_alloc()),
- _irq_alloc(core_mem_alloc()),
+Platform::Platform()
+:
+ _io_mem_alloc(&core_mem_alloc()), _io_port_alloc(&core_mem_alloc()),
+ _irq_alloc(&core_mem_alloc()),
_vm_base(0x1000), _vm_size(0), _cpus(Affinity::Space(1,1))
{
- Hip *hip = (Hip *)__initial_sp;
+ Hip const &hip = *(Hip *)__initial_sp;
/* check for right API version */
- if (hip->api_version != 8)
+ if (hip.api_version != 8)
nova_die();
/*
@@ -295,23 +296,23 @@ Platform::Platform() :
* 'Platform_thread::_location' in 'platform_thread.cc'. Also look
* at the 'Thread::start' function in core/thread_start.cc.
*/
- _cpus = Affinity::Space(hip->cpus(), 1);
+ _cpus = Affinity::Space(hip.cpus(), 1);
/* register UTCB of main thread */
__main_thread_utcb = (Utcb *)(__initial_sp - get_page_size());
/* set core pd selector */
- _core_pd_sel = hip->sel_exc;
+ _core_pd_sel = hip.sel_exc;
/* create lock used by capability allocator */
Nova::create_sm(Nova::SM_SEL_EC, core_pd_sel(), 0);
/* locally map the whole I/O port range */
enum { ORDER_64K = 16 };
- map_local_one_to_one(__main_thread_utcb, Io_crd(0, ORDER_64K), _core_pd_sel);
+ map_local_one_to_one(*__main_thread_utcb, Io_crd(0, ORDER_64K), _core_pd_sel);
/* map BDA region, console reads IO ports at BDA_VIRT_ADDR + 0x400 */
enum { BDA_PHY = 0x0U, BDA_VIRT = 0x1U, BDA_VIRT_ADDR = 0x1000U };
- map_local_phys_to_virt(__main_thread_utcb,
+ map_local_phys_to_virt(*__main_thread_utcb,
Mem_crd(BDA_PHY, 0, Rights(true, false, false)),
Mem_crd(BDA_VIRT, 0, Rights(true, false, false)),
_core_pd_sel);
@@ -326,50 +327,50 @@ Platform::Platform() :
* we do this that early, because Core_mem_allocator uses
* the main_thread_utcb very early to establish mappings
*/
- if (map_local(_core_pd_sel, __main_thread_utcb, (addr_t)__main_thread_utcb,
+ if (map_local(_core_pd_sel, *__main_thread_utcb, (addr_t)__main_thread_utcb,
(addr_t)main_thread_utcb(), 1, Rights(true, true, false))) {
error("could not remap utcb of main thread");
nova_die();
}
/* sanity checks */
- if (hip->sel_exc + 3 > NUM_INITIAL_PT_RESERVED) {
+ if (hip.sel_exc + 3 > NUM_INITIAL_PT_RESERVED) {
error("configuration error (NUM_INITIAL_PT_RESERVED)");
nova_die();
}
/* init genode cpu ids based on kernel cpu ids (used for syscalls) */
- if (sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0]) < hip->cpu_max()) {
- error("number of max CPUs is larger than expected - ", hip->cpu_max(),
+ if (sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0]) < hip.cpu_max()) {
+ error("number of max CPUs is larger than expected - ", hip.cpu_max(),
" vs ", sizeof(map_cpu_ids) / sizeof(map_cpu_ids[0]));
nova_die();
}
- if (!hip->remap_cpu_ids(map_cpu_ids, boot_cpu())) {
+ if (!hip.remap_cpu_ids(map_cpu_ids, boot_cpu())) {
error("re-ording cpu_id failed");
nova_die();
}
/* map idle SCs */
- unsigned const log2cpu = log2(hip->cpu_max());
- if ((1U << log2cpu) != hip->cpu_max()) {
+ unsigned const log2cpu = log2(hip.cpu_max());
+ if ((1U << log2cpu) != hip.cpu_max()) {
error("number of max CPUs is not of power of 2");
nova_die();
}
- addr_t sc_idle_base = cap_map()->insert(log2cpu + 1);
+ addr_t sc_idle_base = cap_map().insert(log2cpu + 1);
if (sc_idle_base & ((1UL << log2cpu) - 1)) {
error("unaligned sc_idle_base value ", Hex(sc_idle_base));
nova_die();
}
- if (map_local(_core_pd_sel, __main_thread_utcb, Obj_crd(0, log2cpu),
+ if (map_local(_core_pd_sel, *__main_thread_utcb, Obj_crd(0, log2cpu),
Obj_crd(sc_idle_base, log2cpu), true))
nova_die();
/* test reading out idle SCs */
bool sc_init = true;
- for (unsigned i = 0; i < hip->cpu_max(); i++) {
+ for (unsigned i = 0; i < hip.cpu_max(); i++) {
- if (!hip->is_cpu_enabled(i))
+ if (!hip.is_cpu_enabled(i))
continue;
uint64_t n_time;
@@ -393,9 +394,9 @@ Platform::Platform() :
addr_t const ec_core_exc_sel = init_core_page_fault_handler(core_pd_sel());
if (verbose_boot_info) {
- if (hip->has_feature_vmx())
+ if (hip.has_feature_vmx())
log("Hypervisor features VMX");
- if (hip->has_feature_svm())
+ if (hip.has_feature_svm())
log("Hypervisor features SVM");
log("Hypervisor reports ", _cpus.width(), "x", _cpus.height(), " "
"CPU", _cpus.total() > 1 ? "s" : " ");
@@ -403,28 +404,36 @@ Platform::Platform() :
warning("CPU has no invariant TSC.");
log("CPU ID (genode->kernel:package:core:thread) remapping");
- unsigned const cpus = hip->cpus();
- for (unsigned i = 0; i < cpus; i++)
- log(" remap (", i, "->", map_cpu_ids[i], ":",
- hip->cpu_desc_of_cpu(map_cpu_ids[i])->package, ":",
- hip->cpu_desc_of_cpu(map_cpu_ids[i])->core, ":",
- hip->cpu_desc_of_cpu(map_cpu_ids[i])->thread, ") ",
- boot_cpu() == map_cpu_ids[i] ? "boot cpu" : "");
+ unsigned const cpus = hip.cpus();
+ for (unsigned i = 0; i < cpus; i++) {
+
+ Hip::Cpu_desc const * const cpu_desc_ptr = hip.cpu_desc_of_cpu(map_cpu_ids[i]);
+
+ if (cpu_desc_ptr) {
+ log(" remap (", i, "->", map_cpu_ids[i], ":",
+ cpu_desc_ptr->package, ":",
+ cpu_desc_ptr->core, ":",
+ cpu_desc_ptr->thread, ") ",
+ boot_cpu() == map_cpu_ids[i] ? "boot cpu" : "");
+ } else {
+ error("missing descriptor for CPU ", i);
+ }
+ }
}
/* initialize core allocators */
- size_t const num_mem_desc = (hip->hip_length - hip->mem_desc_offset)
- / hip->mem_desc_size;
+ size_t const num_mem_desc = (hip.hip_length - hip.mem_desc_offset)
+ / hip.mem_desc_size;
if (verbose_boot_info)
log("Hypervisor info page contains ", num_mem_desc, " memory descriptors:");
- addr_t mem_desc_base = ((addr_t)hip + hip->mem_desc_offset);
+ addr_t mem_desc_base = ((addr_t)&hip + hip.mem_desc_offset);
/* define core's virtual address space */
addr_t virt_beg = _vm_base;
addr_t virt_end = _vm_size;
- _core_mem_alloc.virt_alloc()->add_range(virt_beg, virt_end - virt_beg);
+ _core_mem_alloc.virt_alloc().add_range(virt_beg, virt_end - virt_beg);
/* exclude core image from core's virtual address allocator */
addr_t const core_virt_beg = trunc_page((addr_t)&_prog_img_beg);
@@ -433,7 +442,7 @@ Platform::Platform() :
addr_t const binaries_end = round_page((addr_t)&_boot_modules_binaries_end);
size_t const core_size = binaries_beg - core_virt_beg;
- region_alloc()->remove_range(core_virt_beg, core_size);
+ region_alloc().remove_range(core_virt_beg, core_size);
if (verbose_boot_info || binaries_end != core_virt_end) {
log("core image ",
@@ -447,22 +456,22 @@ Platform::Platform() :
/* ROM modules are un-used by core - de-detach region */
addr_t const binaries_size = binaries_end - binaries_beg;
- unmap_local(__main_thread_utcb, binaries_beg, binaries_size >> 12);
+ unmap_local(*__main_thread_utcb, binaries_beg, binaries_size >> 12);
/* preserve Bios Data Area (BDA) in core's virtual address space */
- region_alloc()->remove_range(BDA_VIRT_ADDR, 0x1000);
+ region_alloc().remove_range(BDA_VIRT_ADDR, 0x1000);
/* preserve stack area in core's virtual address space */
- region_alloc()->remove_range(stack_area_virtual_base(),
- stack_area_virtual_size());
+ region_alloc().remove_range(stack_area_virtual_base(),
+ stack_area_virtual_size());
/* exclude utcb of core pager thread + empty guard pages before and after */
- region_alloc()->remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
- get_page_size() * 3);
+ region_alloc().remove_range(CORE_PAGER_UTCB_ADDR - get_page_size(),
+ get_page_size() * 3);
/* exclude utcb of main thread and hip + empty guard pages before and after */
- region_alloc()->remove_range((addr_t)__main_thread_utcb - get_page_size(),
- get_page_size() * 4);
+ region_alloc().remove_range((addr_t)__main_thread_utcb - get_page_size(),
+ get_page_size() * 4);
/* sanity checks */
addr_t check [] = {
@@ -532,7 +541,7 @@ Platform::Platform() :
" - size: ", Hex(size, Hex::PREFIX, Hex::PAD));
_io_mem_alloc.remove_range(base, size);
- ram_alloc()->add_range(base, size);
+ ram_alloc().add_range(base, size);
}
uint64_t hyp_log = 0;
@@ -583,12 +592,12 @@ Platform::Platform() :
mem_desc->type == Hip::Mem_desc::ACPI_NVS_MEMORY)
_io_mem_alloc.add_range(base, size);
- ram_alloc()->remove_range(base, size);
+ ram_alloc().remove_range(base, size);
}
/* needed as I/O memory by the VESA driver */
_io_mem_alloc.add_range(0, 0x1000);
- ram_alloc()->remove_range(0, 0x1000);
+ ram_alloc().remove_range(0, 0x1000);
/* exclude pages holding multi-boot command lines from core allocators */
mem_desc = (Hip::Mem_desc *)mem_desc_base;
@@ -600,8 +609,8 @@ Platform::Platform() :
curr_cmd_line_page = mem_desc->aux >> get_page_size_log2();
if (curr_cmd_line_page == prev_cmd_line_page) continue;
- ram_alloc()->remove_range(curr_cmd_line_page << get_page_size_log2(),
- get_page_size() * 2);
+ ram_alloc().remove_range(curr_cmd_line_page << get_page_size_log2(),
+ get_page_size() * 2);
prev_cmd_line_page = curr_cmd_line_page;
}
@@ -661,14 +670,14 @@ Platform::Platform() :
unsigned const pages = 1;
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(phys_ptr);
addr_t const core_local_addr = _map_pages(phys_addr, pages);
if (!core_local_addr) {
- ram_alloc()->free(phys_ptr);
+ ram_alloc().free(phys_ptr);
} else {
Genode::Xml_generator xml(reinterpret_cast(core_local_addr),
@@ -703,35 +712,44 @@ Platform::Platform() :
});
xml.node("hardware", [&] () {
xml.node("features", [&] () {
- xml.attribute("svm", hip->has_feature_svm());
- xml.attribute("vmx", hip->has_feature_vmx());
+ xml.attribute("svm", hip.has_feature_svm());
+ xml.attribute("vmx", hip.has_feature_vmx());
});
xml.node("tsc", [&] () {
xml.attribute("invariant", cpuid_invariant_tsc());
- xml.attribute("freq_khz" , hip->tsc_freq);
+ xml.attribute("freq_khz" , hip.tsc_freq);
});
xml.node("cpus", [&] () {
- unsigned const cpus = hip->cpus();
+ unsigned const cpus = hip.cpus();
for (unsigned i = 0; i < cpus; i++) {
+
+ Hip::Cpu_desc const * const cpu_desc_ptr =
+ hip.cpu_desc_of_cpu(Platform::kernel_cpu_id(i));
+
+ if (!cpu_desc_ptr)
+ continue;
+
+ Hip::Cpu_desc const &cpu_desc = *cpu_desc_ptr;
+
xml.node("cpu", [&] () {
- unsigned const kernel_cpu_id = Platform::kernel_cpu_id(i);
xml.attribute("id", i);
- xml.attribute("package", hip->cpu_desc_of_cpu(kernel_cpu_id)->package);
- xml.attribute("core", hip->cpu_desc_of_cpu(kernel_cpu_id)->core);
- xml.attribute("thread", hip->cpu_desc_of_cpu(kernel_cpu_id)->thread);
- xml.attribute("family", String<5>(Hex(hip->cpu_desc_of_cpu(kernel_cpu_id)->family)));
- xml.attribute("model", String<5>(Hex(hip->cpu_desc_of_cpu(kernel_cpu_id)->model)));
- xml.attribute("stepping", String<5>(Hex(hip->cpu_desc_of_cpu(kernel_cpu_id)->stepping)));
- xml.attribute("platform", String<5>(Hex(hip->cpu_desc_of_cpu(kernel_cpu_id)->platform)));
- xml.attribute("patch", String<12>(Hex(hip->cpu_desc_of_cpu(kernel_cpu_id)->patch)));
+ xml.attribute("package", cpu_desc.package);
+ xml.attribute("core", cpu_desc.core);
+ xml.attribute("thread", cpu_desc.thread);
+ xml.attribute("family", String<5>(Hex(cpu_desc.family)));
+ xml.attribute("model", String<5>(Hex(cpu_desc.model)));
+ xml.attribute("stepping", String<5>(Hex(cpu_desc.stepping)));
+ xml.attribute("platform", String<5>(Hex(cpu_desc.platform)));
+ xml.attribute("patch", String<12>(Hex(cpu_desc.patch)));
});
}
});
});
});
- unmap_local(__main_thread_utcb, core_local_addr, pages);
- region_alloc()->free(reinterpret_cast(core_local_addr), pages * get_page_size());
+ unmap_local(*__main_thread_utcb, core_local_addr, pages);
+ region_alloc().free(reinterpret_cast(core_local_addr),
+ pages * get_page_size());
_rom_fs.insert(new (core_mem_alloc())
Rom_module(phys_addr, pages * get_page_size(),
@@ -746,8 +764,8 @@ Platform::Platform() :
unsigned const pages = 4;
size_t const log_size = pages << get_page_size_log2();
- if (ram_alloc()->alloc_aligned(log_size, &phys_ptr,
- get_page_size_log2()).ok()) {
+ if (ram_alloc().alloc_aligned(log_size, &phys_ptr,
+ get_page_size_log2()).ok()) {
addr_t const phys_addr = reinterpret_cast(phys_ptr);
@@ -760,7 +778,7 @@ Platform::Platform() :
init_core_log( Core_log_range { virt, log_size } );
} else
- ram_alloc()->free(phys_ptr);
+ ram_alloc().free(phys_ptr);
}
}
@@ -773,8 +791,8 @@ Platform::Platform() :
_io_port_alloc.add_range(0, 0x10000);
/* IRQ allocator */
- _irq_alloc.add_range(0, hip->sel_gsi);
- _gsi_base_sel = (hip->mem_desc_offset - hip->cpu_desc_offset) / hip->cpu_desc_size;
+ _irq_alloc.add_range(0, hip.sel_gsi);
+ _gsi_base_sel = (hip.mem_desc_offset - hip.cpu_desc_offset) / hip.cpu_desc_size;
log(_rom_fs);
@@ -786,24 +804,24 @@ Platform::Platform() :
for (unsigned i = 0; i < 32; i++)
{
void * phys_ptr = nullptr;
- if (ram_alloc()->alloc_aligned(get_page_size(), &phys_ptr,
- get_page_size_log2()).error())
+ if (ram_alloc().alloc_aligned(get_page_size(), &phys_ptr,
+ get_page_size_log2()).error())
break;
addr_t phys_addr = reinterpret_cast(phys_ptr);
addr_t core_local_addr = _map_pages(phys_addr, 1);
if (!core_local_addr) {
- ram_alloc()->free(phys_ptr);
+ ram_alloc().free(phys_ptr);
break;
}
- Cap_range * range = reinterpret_cast(core_local_addr);
- construct_at(range, index);
+ Cap_range &range = *reinterpret_cast(core_local_addr);
+ construct_at