core: don't rely on Core_env in platform.cc

Replace the use of the global 'core_env()' accessor by the explicit
delegation of interfaces.

- For allocating UTCBs in base-hw, 'Platform_thread' requires
  a way to allocate dataspaces ('Ram_allocator') accounted to the
  corresponding CPU session, a way to locally map the allocated
  dataspaces (core's 'Region_map'), and a way to determine the
  physical address (via 'Rpc_entrypoint') used for the initial
  UTCB mapping of main threads. Hence those interfaces must be
  passed to 'Platform_thread'.

- NOVA's pager code needs to look up 'Cpu_thread_component'
  objects using a map item as key. The lookup requires the
  'Rpc_entrypoint' that hold the 'Cpu_thread_component' objects.
  To make this 'Rpc_entrypoint' available, this patch adds
  the 'init_page_fault_handing' function.

- The 'Region_map_mmap' for Linux requires a way to look up
  'Linux_dataspace' objects for given dataspace capabilities.
  This lookup requires the 'Rpc_entrypoint' holding the dataspaces,
  which is now passed to 'platform.cc' via the new Linux-specific
  'Core_region_map::init' function.

Issue #5408
This commit is contained in:
Norman Feske 2024-12-16 12:17:09 +01:00 committed by Christian Helmuth
parent ac5cfb59ea
commit 43d7c3bd11
43 changed files with 222 additions and 150 deletions

View File

@ -61,8 +61,9 @@ class Core::Platform_thread : Interface
/**
* Constructor
*/
Platform_thread(Platform_pd &pd, size_t, const char *name,
unsigned, Affinity::Location, addr_t)
Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name, unsigned,
Affinity::Location, addr_t)
: _name(name), _pd(pd) { }
/**

View File

@ -103,3 +103,6 @@ Untyped_capability Pager_entrypoint::_pager_object_cap(unsigned long badge)
{
return Capability_space::import(native_thread().l4id, Rpc_obj_key(badge));
}
void Core::init_page_fault_handling(Rpc_entrypoint &) { }

View File

@ -20,7 +20,6 @@
/* core includes */
#include <platform.h>
#include <core_env.h>
using namespace Core;

View File

@ -75,8 +75,8 @@ class Core::Platform_thread : Interface
/**
* Constructor for non-core threads
*/
Platform_thread(Platform_pd &, size_t, const char *name, unsigned priority,
Affinity::Location, addr_t);
Platform_thread(Platform_pd &, Rpc_entrypoint &, Ram_allocator &, Region_map &,
size_t, const char *name, unsigned priority, Affinity::Location, addr_t);
/**
* Constructor for core main-thread

View File

@ -153,3 +153,6 @@ Pager_capability Pager_entrypoint::manage(Pager_object &obj)
},
[&] (Cpu_session::Create_thread_error) { return Pager_capability(); });
}
void Core::init_page_fault_handling(Rpc_entrypoint &) { }

View File

@ -18,7 +18,6 @@
/* core includes */
#include <platform_thread.h>
#include <platform.h>
#include <core_env.h>
/* Fiasco.OC includes */
#include <foc/syscall.h>
@ -278,7 +277,8 @@ void Platform_thread::_finalize_construction()
}
Platform_thread::Platform_thread(Platform_pd &pd, size_t, const char *name, unsigned prio,
Platform_thread::Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name, unsigned prio,
Affinity::Location location, addr_t)
:
_name(name),

View File

@ -22,7 +22,6 @@
/* core includes */
#include <platform.h>
#include <core_env.h>
/* Fiasco.OC includes */
#include <foc/syscall.h>

View File

@ -18,7 +18,7 @@
/* core includes */
#include <kernel/irq.h>
#include <irq_root.h>
#include <core_env.h>
#include <platform.h>
/* base-internal includes */
#include <base/internal/capability_space.h>

View File

@ -23,6 +23,9 @@
using namespace Core;
void Core::init_page_fault_handling(Rpc_entrypoint &) { }
/***************
** Ipc_pager **
***************/

View File

@ -53,6 +53,8 @@ namespace Core {
using Pager_capability = Capability<Pager_object>;
enum { PAGER_EP_STACK_SIZE = sizeof(addr_t) * 2048 };
extern void init_page_fault_handling(Rpc_entrypoint &);
}

View File

@ -15,7 +15,6 @@
/* core includes */
#include <platform_thread.h>
#include <platform_pd.h>
#include <core_env.h>
#include <rm_session_component.h>
#include <map_local.h>
@ -30,48 +29,19 @@
using namespace Core;
Ram_dataspace_capability Platform_thread::Utcb::_allocate_utcb(bool core_thread)
addr_t Platform_thread::Utcb::_attach(Region_map &core_rm)
{
Ram_dataspace_capability ds;
if (core_thread)
return ds;
try {
ds = core_env().pd_session()->alloc(sizeof(Native_utcb), CACHED);
} catch (...) {
error("failed to allocate UTCB");
throw Out_of_ram();
}
return ds;
}
addr_t Platform_thread::Utcb::_core_local_address(addr_t utcb_addr,
bool core_thread)
{
if (core_thread)
return utcb_addr;
addr_t ret = 0;
Region_map::Attr attr { };
attr.writeable = true;
core_env().rm_session()->attach(_ds, attr).with_result(
[&] (Region_map::Range range) {
ret = range.start; },
[&] (Region_map::Attach_error) {
error("failed to attach UTCB of new thread within core"); });
return ret;
return core_rm.attach(_ds, attr).convert<addr_t>(
[&] (Region_map::Range range) { return range.start; },
[&] (Region_map::Attach_error) {
error("failed to attach UTCB of new thread within core");
return 0ul; });
}
Platform_thread::Utcb::Utcb(addr_t pd_addr, bool core_thread)
:
_ds(_allocate_utcb(core_thread)),
_core_addr(_core_local_address(pd_addr, core_thread))
static addr_t _alloc_core_local_utcb(addr_t core_addr)
{
/*
* All non-core threads use the typical dataspace/rm_session
@ -80,27 +50,25 @@ Platform_thread::Utcb::Utcb(addr_t pd_addr, bool core_thread)
* physical and virtual memory allocators to create/attach its
* UTCBs. Therefore, we've to allocate and map those here.
*/
if (core_thread) {
platform().ram_alloc().try_alloc(sizeof(Native_utcb)).with_result(
return platform().ram_alloc().try_alloc(sizeof(Native_utcb)).convert<addr_t>(
[&] (void *utcb_phys) {
map_local((addr_t)utcb_phys, _core_addr,
sizeof(Native_utcb) / get_page_size());
},
[&] (Range_allocator::Alloc_error) {
error("failed to allocate UTCB for core/kernel thread!");
throw Out_of_ram();
}
);
}
[&] (void *utcb_phys) {
map_local((addr_t)utcb_phys, core_addr,
sizeof(Native_utcb) / get_page_size());
return addr_t(utcb_phys);
},
[&] (Range_allocator::Alloc_error) {
error("failed to allocate UTCB for core/kernel thread!");
return 0ul;
});
}
Platform_thread::Utcb::~Utcb()
{
/* detach UTCB from core/kernel */
core_env().rm_session()->detach((addr_t)_core_addr);
}
Platform_thread::Utcb::Utcb(addr_t core_addr)
:
core_addr(core_addr),
phys_addr(_alloc_core_local_utcb(core_addr))
{ }
void Platform_thread::_init() { }
@ -122,23 +90,27 @@ Platform_thread::Platform_thread(Label const &label, Native_utcb &utcb)
_label(label),
_pd(_kernel_main_get_core_platform_pd()),
_pager(nullptr),
_utcb((addr_t)&utcb, true),
_utcb((addr_t)&utcb),
_main_thread(false),
_location(Affinity::Location()),
_kobj(_kobj.CALLED_FROM_CORE, _label.string()) { }
_kobj(_kobj.CALLED_FROM_CORE, _label.string())
{ }
Platform_thread::Platform_thread(Platform_pd &pd,
Rpc_entrypoint &ep,
Ram_allocator &ram,
Region_map &core_rm,
size_t const quota,
Label const &label,
unsigned const virt_prio,
Affinity::Location const location,
addr_t const utcb)
addr_t /* utcb */)
:
_label(label),
_pd(pd),
_pager(nullptr),
_utcb(utcb, false),
_utcb(ep, ram, core_rm),
_priority(_scale_priority(virt_prio)),
_quota((unsigned)quota),
_main_thread(!pd.has_any_thread),
@ -165,9 +137,6 @@ Platform_thread::~Platform_thread()
locked_ptr->flush(user_utcb_main_thread(), sizeof(Native_utcb),
Address_space::Core_local_addr{0});
}
/* free UTCB */
core_env().pd_session()->free(_utcb._ds);
}
@ -185,26 +154,17 @@ void Platform_thread::start(void * const ip, void * const sp)
/* attach UTCB in case of a main thread */
if (_main_thread) {
/* lookup dataspace component for physical address */
auto lambda = [&] (Dataspace_component *dsc) {
if (!dsc) return -1;
/* lock the address space */
Locked_ptr<Address_space> locked_ptr(_address_space);
if (!locked_ptr.valid()) {
error("invalid RM client");
return -1;
};
Hw::Address_space * as = static_cast<Hw::Address_space*>(&*locked_ptr);
if (!as->insert_translation(user_utcb_main_thread(), dsc->phys_addr(),
sizeof(Native_utcb), Hw::PAGE_FLAGS_UTCB)) {
error("failed to attach UTCB");
return -1;
}
return 0;
};
if (core_env().entrypoint().apply(_utcb._ds, lambda))
Locked_ptr<Address_space> locked_ptr(_address_space);
if (!locked_ptr.valid()) {
error("unable to start thread in invalid address space");
return;
};
Hw::Address_space * as = static_cast<Hw::Address_space*>(&*locked_ptr);
if (!as->insert_translation(user_utcb_main_thread(), _utcb.phys_addr,
sizeof(Native_utcb), Hw::PAGE_FLAGS_UTCB)) {
error("failed to attach UTCB");
return;
}
}
/* initialize thread registers */
@ -223,7 +183,7 @@ void Platform_thread::start(void * const ip, void * const sp)
utcb.cap_add(Capability_space::capid(_pd.parent()));
utcb.cap_add(Capability_space::capid(_utcb._ds));
}
Kernel::start_thread(*_kobj, cpu, _pd.kernel_pd(), *(Native_utcb*)_utcb._core_addr);
Kernel::start_thread(*_kobj, cpu, _pd.kernel_pd(), *(Native_utcb*)_utcb.core_addr);
}

View File

@ -19,6 +19,7 @@
#include <base/ram_allocator.h>
#include <base/thread.h>
#include <base/trace/types.h>
#include <base/rpc_server.h>
/* base-internal includes */
#include <base/internal/native_utcb.h>
@ -26,6 +27,7 @@
/* core includes */
#include <address_space.h>
#include <object.h>
#include <dataspace_component.h>
/* kernel includes */
#include <kernel/core_interface.h>
@ -55,17 +57,59 @@ class Core::Platform_thread : Noncopyable
using Label = String<32>;
struct Utcb
struct Utcb : Noncopyable
{
struct {
Ram_allocator *_ram_ptr = nullptr;
Region_map *_core_rm_ptr = nullptr;
};
Ram_dataspace_capability _ds { }; /* UTCB ds of non-core threads */
addr_t const _core_addr; /* UTCB address within core/kernel */
addr_t const core_addr; /* UTCB address within core/kernel */
addr_t const phys_addr;
Ram_dataspace_capability _allocate_utcb(bool core_thread);
addr_t _core_local_address(addr_t utcb_addr, bool core_thread);
/*
* \throw Out_of_ram
* \throw Out_of_caps
*/
Ram_dataspace_capability _allocate(Ram_allocator &ram)
{
return ram.alloc(sizeof(Native_utcb), CACHED);
}
Utcb(addr_t pd_addr, bool core_thread);
~Utcb();
addr_t _attach(Region_map &);
static addr_t _ds_phys(Rpc_entrypoint &ep, Dataspace_capability ds)
{
return ep.apply(ds, [&] (Dataspace_component *dsc) {
return dsc ? dsc->phys_addr() : 0; });
}
/**
* Constructor used for core-local threads
*/
Utcb(addr_t core_addr);
/**
* Constructor used for threads outside of core
*/
Utcb(Rpc_entrypoint &ep, Ram_allocator &ram, Region_map &core_rm)
:
_core_rm_ptr(&core_rm),
_ds(_allocate(ram)),
core_addr(_attach(core_rm)),
phys_addr(_ds_phys(ep, _ds))
{ }
~Utcb()
{
if (_core_rm_ptr)
_core_rm_ptr->detach(core_addr);
if (_ram_ptr && _ds.valid())
_ram_ptr->free(_ds);
}
};
Label const _label;
@ -126,7 +170,8 @@ class Core::Platform_thread : Noncopyable
* \param virt_prio unscaled processor-scheduling priority
* \param utcb core local pointer to userland stack
*/
Platform_thread(Platform_pd &, size_t const quota, Label const &label,
Platform_thread(Platform_pd &, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t const quota, Label const &label,
unsigned const virt_prio, Affinity::Location,
addr_t const utcb);

View File

@ -22,7 +22,6 @@
#include <vm_session_component.h>
#include <platform.h>
#include <cpu_thread_component.h>
#include <core_env.h>
using namespace Core;

View File

@ -23,7 +23,6 @@
#include <vm_session_component.h>
#include <platform.h>
#include <cpu_thread_component.h>
#include <core_env.h>
using namespace Core;

View File

@ -19,7 +19,6 @@
#include <vm_session_component.h>
#include <platform.h>
#include <cpu_thread_component.h>
#include <core_env.h>
using namespace Core;

View File

@ -25,7 +25,9 @@ namespace Core { class Core_region_map; }
struct Core::Core_region_map : Region_map_mmap
{
Core_region_map(Rpc_entrypoint &) : Region_map_mmap(false) { }
static void init(Rpc_entrypoint &);
Core_region_map(Rpc_entrypoint &ep) : Region_map_mmap(false) { init(ep); }
};
#endif /* _CORE__INCLUDE__CORE_REGION_MAP_H_ */

View File

@ -29,6 +29,8 @@ namespace Core {
struct Pager_entrypoint;
using Pager_capability = Capability<Pager_object>;
extern void init_page_fault_handling(Rpc_entrypoint &);
}

View File

@ -69,7 +69,8 @@ class Core::Platform_thread : Noncopyable
/**
* Constructor
*/
Platform_thread(Platform_pd &, size_t, auto const &name, auto...)
Platform_thread(Platform_pd &, Rpc_entrypoint &, Ram_allocator &, Region_map &,
size_t, auto const &name, auto...)
: _name(name) { }
/**

View File

@ -160,25 +160,48 @@ void Core::Platform::wait_for_exit()
}
void Core::init_page_fault_handling(Rpc_entrypoint &) { }
/*********************************
** Support for Region_map_mmap **
*********************************/
static Rpc_entrypoint *_core_ep_ptr;
void Core_region_map::init(Rpc_entrypoint &ep) { _core_ep_ptr = &ep; }
static auto with_linux_dataspace(Capability<Dataspace> ds,
auto const &fn, auto const &missing_fn) -> decltype(missing_fn())
{
if (!_core_ep_ptr)
error("missing call of Core_region_map::init");
Capability<Linux_dataspace> lx_ds = static_cap_cast<Linux_dataspace>(ds);
if (_core_ep_ptr)
return _core_ep_ptr->apply(lx_ds, [&] (Linux_dataspace *ds_ptr) {
return ds_ptr ? fn(*ds_ptr) : missing_fn(); });
return missing_fn();
}
size_t Region_map_mmap::_dataspace_size(Capability<Dataspace> ds_cap)
{
if (!ds_cap.valid())
return Local_capability<Dataspace>::deref(ds_cap)->size();
/* use local function call if called from the entrypoint */
return core_env().entrypoint().apply(ds_cap, [] (Dataspace *ds) {
return ds ? ds->size() : 0; });
return with_linux_dataspace(ds_cap,
[&] (Linux_dataspace &ds) -> size_t { return ds.size(); },
[&] () /* missing */ -> size_t { return 0; });
}
int Region_map_mmap::_dataspace_fd(Capability<Dataspace> ds_cap)
{
Capability<Linux_dataspace> lx_ds_cap = static_cap_cast<Linux_dataspace>(ds_cap);
/*
* Return a duplicate of the dataspace file descriptor, which will be freed
* immediately after mmap'ing the file (see 'Region_map_mmap').
@ -188,13 +211,19 @@ int Region_map_mmap::_dataspace_fd(Capability<Dataspace> 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 ds ? lx_dup(Capability_space::ipc_cap_data(ds->fd()).dst.socket.value) : -1; });
return with_linux_dataspace(ds_cap,
[&] (Linux_dataspace &ds)
{
return lx_dup(Capability_space::ipc_cap_data(ds.fd()).dst.socket.value);
},
[&] /* missing */ { return -1; });
}
bool Region_map_mmap::_dataspace_writeable(Dataspace_capability ds_cap)
{
return core_env().entrypoint().apply(ds_cap, [] (Dataspace *ds) {
return ds ? ds->writeable() : false; });
return with_linux_dataspace(ds_cap,
[&] (Linux_dataspace &ds) { return ds.writeable(); },
[&] /* missing */ { return false; });
}

View File

@ -36,6 +36,8 @@ namespace Core {
class Exception_handlers;
using Pager_capability = Capability<Pager_object>;
extern void init_page_fault_handling(Rpc_entrypoint &);
}

View File

@ -93,10 +93,9 @@ class Core::Platform_thread
/**
* Constructor
*/
Platform_thread(Platform_pd &, size_t quota, char const *name,
unsigned priority,
Affinity::Location affinity,
addr_t utcb);
Platform_thread(Platform_pd &, Rpc_entrypoint &, Ram_allocator &, Region_map &,
size_t quota, char const *name, unsigned priority,
Affinity::Location affinity, addr_t utcb);
/**
* Destructor

View File

@ -38,6 +38,11 @@ using namespace Core;
using namespace Nova;
static Rpc_entrypoint *_core_ep_ptr;
void Core::init_page_fault_handling(Rpc_entrypoint &ep) { _core_ep_ptr = &ep; }
/**
* Pager threads - one thread per CPU
*/
@ -397,9 +402,8 @@ void Pager_object::_invoke_handler(Pager_object &obj)
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() && _core_ep_ptr) {
_core_ep_ptr->apply(cap.base(),
[&] (Cpu_thread_component *source) {
if (!source)
return;

View File

@ -343,7 +343,8 @@ void Platform_thread::thread_type(Cpu_session::Native_cpu::Thread_type thread_ty
}
Platform_thread::Platform_thread(Platform_pd &pd, size_t, const char *name,
Platform_thread::Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name,
unsigned prio, Affinity::Location affinity, addr_t)
:
_pd(pd), _pager(0), _id_base(cap_map().insert(2)),

View File

@ -42,14 +42,14 @@ class Core::Platform_thread
int _thread_id = THREAD_INVALID; /* plain thread number */
Okl4::L4_ThreadId_t _l4_thread_id; /* L4 thread ID */
Okl4::L4_ThreadId_t _l4_thread_id = Okl4::L4_nilthread;
char _name[32]; /* thread name that will be
registered at the kernel
debugger */
Platform_pd &_pd;
unsigned _priority; /* thread priority */
Pager_object *_pager;
unsigned _priority = 0; /* thread priority */
Pager_object *_pager = nullptr;
bool _bound_to_pd = false;
@ -61,16 +61,24 @@ class Core::Platform_thread
/**
* Constructor
*/
Platform_thread(Platform_pd &pd, size_t, const char *name,
unsigned priority,
Affinity::Location,
addr_t utcb);
Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name,
unsigned prio, Affinity::Location, addr_t)
:
_pd(pd), _priority(prio)
{
copy_cstring(_name, name, sizeof(_name));
_bound_to_pd = pd.bind_thread(*this);
}
/**
* Constructor used for core-internal threads
*/
Platform_thread(Platform_pd &pd, char const *name)
: Platform_thread(pd, 0, name, 0, Affinity::Location(), 0) { }
Platform_thread(Platform_pd &pd, char const *name) : _pd(pd)
{
copy_cstring(_name, name, sizeof(_name));
_bound_to_pd = pd.bind_thread(*this);
}
/**
* Destructor

View File

@ -146,3 +146,6 @@ Untyped_capability Pager_entrypoint::_pager_object_cap(unsigned long badge)
{
return Capability_space::import(native_thread().l4id, Rpc_obj_key(badge));
}
void Core::init_page_fault_handling(Rpc_entrypoint &) { }

View File

@ -139,17 +139,6 @@ unsigned long Platform_thread::pager_object_badge() const
}
Platform_thread::Platform_thread(Platform_pd &pd, size_t, const char *name,
unsigned prio, Affinity::Location, addr_t)
:
_l4_thread_id(L4_nilthread), _pd(pd), _priority(prio), _pager(0)
{
copy_cstring(_name, name, sizeof(_name));
_bound_to_pd = pd.bind_thread(*this);
}
Platform_thread::~Platform_thread()
{
/*

View File

@ -20,7 +20,6 @@
/* core includes */
#include <platform.h>
#include <core_env.h>
using namespace Genode;

View File

@ -86,7 +86,8 @@ class Core::Platform_thread : Interface
/**
* Constructor
*/
Platform_thread(Platform_pd &pd, size_t, char const *name, unsigned priority,
Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, char const *name, unsigned priority,
Affinity::Location location, addr_t)
:
_name(name), _pd(pd), _priority(priority), _location(location)

View File

@ -132,3 +132,6 @@ Untyped_capability Pager_entrypoint::_pager_object_cap(unsigned long badge)
{
return Capability_space::import(native_thread().l4id, Rpc_obj_key(badge));
}
void Core::init_page_fault_handling(Rpc_entrypoint &) { }

View File

@ -18,7 +18,6 @@
/* core includes */
#include <platform.h>
#include <platform_thread.h>
#include <core_env.h>
/* base-internal includes */
#include <base/internal/stack.h>

View File

@ -46,6 +46,8 @@ namespace Core {
using Pager_capability = Capability<Pager_object>;
enum { PAGER_EP_STACK_SIZE = sizeof(addr_t) * 2048 };
extern void init_page_fault_handling(Rpc_entrypoint &);
}

View File

@ -88,7 +88,8 @@ class Core::Platform_thread : public List<Platform_thread>::Element
/**
* Constructor
*/
Platform_thread(Platform_pd &pd, size_t, const char *name, unsigned priority,
Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name, unsigned priority,
Affinity::Location, addr_t utcb);
/**

View File

@ -16,9 +16,11 @@
/* Genode includes */
#include <base/rpc_server.h>
#include <base/registry.h>
#include <vm_session/vm_session.h>
/* core includes */
#include <region_map_component.h>
#include <trace/source_registry.h>
#include <sel4_native_vcpu/sel4_native_vcpu.h>

View File

@ -31,6 +31,9 @@ using namespace Core;
void Mapping::prepare_map_operation() const { }
void Core::init_page_fault_handling(Rpc_entrypoint &) { }
/***************
** IPC pager **
***************/

View File

@ -209,7 +209,8 @@ bool Platform_thread::install_mapping(Mapping const &mapping)
}
Platform_thread::Platform_thread(Platform_pd &pd, size_t, const char *name,
Platform_thread::Platform_thread(Platform_pd &pd, Rpc_entrypoint &, Ram_allocator &,
Region_map &, size_t, const char *name,
unsigned priority, Affinity::Location location,
addr_t utcb)
:

View File

@ -16,7 +16,6 @@
#include <cpu/vcpu_state.h>
/* core includes */
#include <core_env.h>
#include <vm_session_component.h>
#include <pd_session_component.h>
#include <cpu_thread_component.h>

View File

@ -62,9 +62,9 @@ Cpu_session_component::create_thread(Capability<Pd_session> pd_cap,
try {
Cpu_thread_component &thread = *new (&_thread_alloc)
Cpu_thread_component(
cap(), *this, _thread_ep, _pager_ep, *pd, platform_pd,
pd_threads, _trace_control_area, _trace_sources,
weight, _weight_to_quota(weight.value),
cap(), *this, _thread_ep, _local_rm, _pager_ep,
*pd, _ram_alloc, platform_pd, pd_threads, _trace_control_area,
_trace_sources, weight, _weight_to_quota(weight.value),
_thread_affinity(affinity), _label, name,
_priority, utcb);
@ -261,6 +261,7 @@ Cpu_session_component::Cpu_session_component(Rpc_entrypoint &session_ep,
:
Session_object(session_ep, resources, label, diag),
_session_ep(session_ep), _thread_ep(thread_ep), _pager_ep(pager_ep),
_local_rm(local_rm),
_ram_alloc(ram_alloc, _ram_quota_guard(), _cap_quota_guard()),
_md_alloc(_ram_alloc, local_rm),
_thread_alloc(_md_alloc), _priority(0),

View File

@ -43,6 +43,7 @@ class Core::Cpu_session_component : public Session_object<Cpu_session>,
Rpc_entrypoint &_session_ep;
Rpc_entrypoint &_thread_ep;
Pager_entrypoint &_pager_ep;
Region_map &_local_rm;
Constrained_ram_allocator _ram_alloc;
Sliced_heap _md_alloc; /* guarded meta-data allocator */
Cpu_thread_allocator _thread_alloc; /* meta-data allocator */

View File

@ -141,8 +141,10 @@ class Core::Cpu_thread_component : public Rpc_object<Cpu_thread>,
Cpu_thread_component(Cpu_session_capability cpu_session_cap,
Cpu_session_component &cpu,
Rpc_entrypoint &ep,
Region_map &core_rm,
Pager_entrypoint &pager_ep,
Pd_session_component &pd,
Ram_allocator &cpu_ram,
Platform_pd &platform_pd,
Pd_threads &pd_threads,
Trace::Control_area &trace_control_area,
@ -160,7 +162,8 @@ class Core::Cpu_thread_component : public Rpc_object<Cpu_thread>,
_weight(weight),
_session_label(label), _name(name),
_pd_element(pd_threads, *this),
_platform_thread(platform_pd, quota, name.string(), priority, location, utcb),
_platform_thread(platform_pd, ep, cpu_ram, core_rm, quota, name.string(),
priority, location, utcb),
_trace_control_slot(trace_control_area),
_trace_sources(trace_sources),
_managed_thread_cap(_ep, *this),

View File

@ -47,6 +47,8 @@ namespace Core {
using Pager_capability = Capability<Pager_object>;
enum { PAGER_EP_STACK_SIZE = sizeof(addr_t) * 2048 };
extern void init_page_fault_handling(Rpc_entrypoint &);
}

View File

@ -39,6 +39,7 @@
#include <irq_root.h>
#include <trace/root.h>
#include <platform_services.h>
#include <pager.h>
using namespace Core;
@ -228,6 +229,7 @@ namespace Genode {
void Genode::bootstrap_component(Genode::Platform &)
{
init_exception_handling(*core_env().pd_session(), core_env().local_rm());
init_page_fault_handling(core_env().entrypoint());
/* disable tracing within core because it is not fully implemented */
inhibit_tracing = true;

View File

@ -23,4 +23,5 @@ using namespace Core;
void Core::init_core_signal_transmitter(Rpc_entrypoint &) { }
Rpc_entrypoint &Core_env::signal_ep() { return _entrypoint; }

View File

@ -27,7 +27,7 @@
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<start name="test-pthread" caps="200">
<start name="test-pthread" caps="600">
<resource name="RAM" quantum="64M"/>
<config>
<vfs> <dir name="dev"> <log/> </dir> </vfs>