mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-20 11:39:14 +00:00
core: remove Core_env
This patch adjusts the last remaining callers of 'core_env' and removes the 'Core_env' interface. - Core's RAM/cap accounts are now represented by 'Core_account' implementing the 'Pd_account' interface. - The former parts of 'Core_env' are now initialized in sequence in 'bootstrap_component'. - 'Core_child' has been moved to a header to reduce the code in 'main.cc' to a bare minimum. This as a preparation for the plan of making 'main.cc' specific for each kernel. Fixes #5408
This commit is contained in:
parent
4aabe39e36
commit
44860e89be
@ -20,9 +20,9 @@
|
||||
#include <base/internal/capability_space_tpl.h>
|
||||
|
||||
/* local includes */
|
||||
#include "platform.h"
|
||||
#include "core_env.h"
|
||||
#include "resource_path.h"
|
||||
#include <platform.h>
|
||||
#include <core_region_map.h>
|
||||
#include <resource_path.h>
|
||||
|
||||
/* Linux includes */
|
||||
#include <core_linux_syscalls.h>
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <platform_thread.h>
|
||||
#include <imprint_badge.h>
|
||||
#include <cpu_thread_component.h>
|
||||
#include <core_env.h>
|
||||
|
||||
/* NOVA includes */
|
||||
#include <nova/syscalls.h>
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include <util/flex_iterator.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_env.h>
|
||||
#include <cpu_thread_component.h>
|
||||
#include <dataspace_component.h>
|
||||
#include <vm_session_component.h>
|
||||
|
60
repos/base/src/core/include/core_account.h
Normal file
60
repos/base/src/core/include/core_account.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* \brief RAM and cap account of the core component
|
||||
* \author Norman Feske
|
||||
* \date 2024-12-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2024 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__CORE_ACCOUNT_H_
|
||||
#define _CORE__INCLUDE__CORE_ACCOUNT_H_
|
||||
|
||||
namespace Core { struct Core_account; }
|
||||
|
||||
|
||||
struct Core::Core_account : Rpc_object<Pd_account>
|
||||
{
|
||||
Rpc_entrypoint &_ep;
|
||||
|
||||
Ram_quota_guard ram_quota_guard;
|
||||
Cap_quota_guard cap_quota_guard;
|
||||
|
||||
Core::Account<Ram_quota> ram_account { ram_quota_guard, "core" };
|
||||
Core::Account<Cap_quota> cap_account { cap_quota_guard, "core" };
|
||||
|
||||
Core_account(Rpc_entrypoint &ep, Ram_quota ram, Cap_quota caps)
|
||||
: _ep(ep), ram_quota_guard(ram), cap_quota_guard(caps) { ep.manage(this); }
|
||||
|
||||
Transfer_result _with_pd(Capability<Pd_account> cap, auto const &fn)
|
||||
{
|
||||
if (this->cap() == cap)
|
||||
return Transfer_result::OK;
|
||||
|
||||
return _ep.apply(cap, [&] (Pd_session_component *pd_ptr) {
|
||||
Transfer_result result = Transfer_result::INVALID;
|
||||
if (pd_ptr)
|
||||
fn(*pd_ptr, result);
|
||||
return result; });
|
||||
}
|
||||
|
||||
Transfer_result transfer_quota(Capability<Pd_account> to, Cap_quota amount) override
|
||||
{
|
||||
return _with_pd(to, [&] (Pd_session_component &pd, Transfer_result &result) {
|
||||
pd.with_cap_account([&] (Account<Cap_quota> &to) {
|
||||
result = cap_account.transfer_quota(to, amount); }); });
|
||||
}
|
||||
|
||||
Transfer_result transfer_quota(Capability<Pd_account> to, Ram_quota amount) override
|
||||
{
|
||||
return _with_pd(to, [&] (Pd_session_component &pd, Transfer_result &result) {
|
||||
pd.with_ram_account([&] (Account<Ram_quota> &to) {
|
||||
result = ram_account.transfer_quota(to, amount); }); });
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_ACCOUNT_H_ */
|
113
repos/base/src/core/include/core_child.h
Normal file
113
repos/base/src/core/include/core_child.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* \brief Child policy for the init component
|
||||
* \author Norman Feske
|
||||
* \date 2024-12-17
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2024 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__CORE_CHILD_H_
|
||||
#define _CORE__INCLUDE__CORE_CHILD_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/service.h>
|
||||
#include <base/child.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_account.h>
|
||||
|
||||
namespace Core { class Core_child; }
|
||||
|
||||
|
||||
class Core::Core_child : public Child_policy
|
||||
{
|
||||
private:
|
||||
|
||||
Registry<Service> &_services;
|
||||
Rpc_entrypoint &_ep;
|
||||
Region_map &_core_rm;
|
||||
Ram_allocator &_core_ram;
|
||||
Core_account &_core_account;
|
||||
|
||||
Capability<Cpu_session> _core_cpu_cap;
|
||||
Cpu_session &_core_cpu;
|
||||
|
||||
Cap_quota const _cap_quota;
|
||||
Ram_quota const _ram_quota;
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
Child _child { _core_rm, _ep, *this };
|
||||
|
||||
public:
|
||||
|
||||
Core_child(Registry<Service> &services, Rpc_entrypoint &ep,
|
||||
Region_map &core_rm, Ram_allocator &core_ram,
|
||||
Core_account &core_account,
|
||||
Cpu_session &core_cpu, Capability<Cpu_session> core_cpu_cap,
|
||||
Cap_quota cap_quota, Ram_quota ram_quota)
|
||||
:
|
||||
_services(services), _ep(ep), _core_rm(core_rm), _core_ram(core_ram),
|
||||
_core_account(core_account),
|
||||
_core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu),
|
||||
_cap_quota(Child::effective_quota(cap_quota)),
|
||||
_ram_quota(Child::effective_quota(ram_quota))
|
||||
{ }
|
||||
|
||||
|
||||
/****************************
|
||||
** Child-policy interface **
|
||||
****************************/
|
||||
|
||||
Name name() const override { return "init"; }
|
||||
|
||||
Route resolve_session_request(Service::Name const &name,
|
||||
Session_label const &label,
|
||||
Session::Diag const diag) override
|
||||
{
|
||||
Service *service = nullptr;
|
||||
_services.for_each([&] (Service &s) {
|
||||
if (!service && s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (!service)
|
||||
throw Service_denied();
|
||||
|
||||
return Route { .service = *service,
|
||||
.label = label,
|
||||
.diag = diag };
|
||||
}
|
||||
|
||||
void init(Pd_session &, Capability<Pd_session> cap) override
|
||||
{
|
||||
_ep.apply(cap, [&] (Pd_session_component *pd_ptr) {
|
||||
if (pd_ptr)
|
||||
pd_ptr->ref_accounts(_core_account.ram_account,
|
||||
_core_account.cap_account); });
|
||||
|
||||
_core_account.transfer_quota(cap, _cap_quota);
|
||||
_core_account.transfer_quota(cap, _ram_quota);
|
||||
}
|
||||
|
||||
void init(Cpu_session &session, Capability<Cpu_session> cap) override
|
||||
{
|
||||
session.ref_account(_core_cpu_cap);
|
||||
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
|
||||
}
|
||||
|
||||
Ram_allocator &session_md_ram() override { return _core_ram; }
|
||||
|
||||
Pd_account &ref_account() override { return _core_account; }
|
||||
Capability<Pd_account> ref_account_cap() const override { return _core_account.cap(); }
|
||||
|
||||
size_t session_alloc_batch_size() const override { return 128; }
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_CHILD_H_ */
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* \brief Core-specific environment
|
||||
* \author Norman Feske
|
||||
* \author Christian Helmuth
|
||||
* \date 2006-07-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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__CORE_ENV_H_
|
||||
#define _CORE__INCLUDE__CORE_ENV_H_
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/env.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <core_region_map.h>
|
||||
#include <pd_session_component.h>
|
||||
#include <synced_ram_allocator.h>
|
||||
#include <assertion.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class Core_env;
|
||||
extern Core_env &core_env();
|
||||
}
|
||||
|
||||
|
||||
class Core::Core_env : public Noncopyable
|
||||
{
|
||||
private:
|
||||
|
||||
enum { ENTRYPOINT_STACK_SIZE = 20 * 1024 };
|
||||
|
||||
/*
|
||||
* Initialize the stack area before creating the first thread,
|
||||
* which happens to be the '_entrypoint'.
|
||||
*/
|
||||
bool _init_stack_area() { init_stack_area(); return true; }
|
||||
bool _stack_area_initialized = _init_stack_area();
|
||||
|
||||
Rpc_entrypoint _entrypoint;
|
||||
Core_region_map _region_map;
|
||||
Pd_session_component _pd_session;
|
||||
Synced_ram_allocator _synced_ram_allocator { _pd_session };
|
||||
|
||||
public:
|
||||
|
||||
Core_env()
|
||||
:
|
||||
_entrypoint(nullptr, ENTRYPOINT_STACK_SIZE, "entrypoint",
|
||||
Affinity::Location()),
|
||||
_region_map(_entrypoint),
|
||||
_pd_session(_entrypoint,
|
||||
_entrypoint,
|
||||
Session::Resources {
|
||||
Ram_quota { platform().ram_alloc().avail() },
|
||||
Cap_quota { platform().max_caps() } },
|
||||
Session::Label("core"),
|
||||
Session::Diag{false},
|
||||
platform().ram_alloc(),
|
||||
Ram_dataspace_factory::any_phys_range(),
|
||||
Ram_dataspace_factory::Virt_range { platform().vm_start(),
|
||||
platform().vm_size() },
|
||||
Pd_session_component::Managing_system::PERMITTED,
|
||||
_region_map,
|
||||
*((Pager_entrypoint *)nullptr),
|
||||
"" /* args to native PD */,
|
||||
platform_specific().core_mem_alloc(),
|
||||
*((Core::System_control *)nullptr))
|
||||
{
|
||||
_pd_session.init_cap_and_ram_accounts();
|
||||
}
|
||||
|
||||
Rpc_entrypoint &entrypoint() { return _entrypoint; }
|
||||
Ram_allocator &ram_allocator() { return _synced_ram_allocator; }
|
||||
Region_map &local_rm() { return _region_map; }
|
||||
|
||||
Rpc_entrypoint &signal_ep();
|
||||
|
||||
Parent *parent() { return nullptr; }
|
||||
Region_map *rm_session() { return &_region_map; }
|
||||
Pd_session *pd_session() { return &_pd_session; }
|
||||
Cpu_session *cpu_session() { ASSERT_NEVER_CALLED; }
|
||||
Cpu_session_capability cpu_session_cap() { ASSERT_NEVER_CALLED; }
|
||||
Pd_session_capability pd_session_cap() { return _pd_session.cap(); }
|
||||
};
|
||||
|
||||
#endif /* _CORE__INCLUDE__CORE_ENV_H_ */
|
@ -14,10 +14,11 @@
|
||||
#ifndef _CORE__INCLUDE__PD_ROOT_H_
|
||||
#define _CORE__INCLUDE__PD_ROOT_H_
|
||||
|
||||
/* Genode */
|
||||
/* Genode includes */
|
||||
#include <root/component.h>
|
||||
#include <pd_session/connection.h>
|
||||
|
||||
/* Core */
|
||||
/* core includes */
|
||||
#include <pd_session_component.h>
|
||||
|
||||
namespace Core { class Pd_root; }
|
||||
|
@ -149,7 +149,7 @@ class Core::Pd_session_component : public Session_object<Pd_session>
|
||||
_constrained_md_ram_alloc(*this, _ram_quota_guard(), _cap_quota_guard()),
|
||||
_constrained_core_ram_alloc(_ram_quota_guard(), _cap_quota_guard(), core_mem),
|
||||
_sliced_heap(_constrained_md_ram_alloc, local_rm),
|
||||
_ram_ds_factory(ep, phys_alloc, phys_range, local_rm,
|
||||
_ram_ds_factory(ep, phys_alloc, phys_range,
|
||||
_constrained_core_ram_alloc),
|
||||
_signal_broker(_sliced_heap, signal_ep, signal_ep),
|
||||
_rpc_cap_factory(_sliced_heap),
|
||||
@ -168,6 +168,22 @@ class Core::Pd_session_component : public Session_object<Pd_session>
|
||||
|
||||
~Pd_session_component();
|
||||
|
||||
void ref_accounts(Account<Ram_quota> &ram_ref, Account<Cap_quota> &cap_ref)
|
||||
{
|
||||
_ram_account.construct(_ram_quota_guard(), _label, ram_ref);
|
||||
_cap_account.construct(_cap_quota_guard(), _label, cap_ref);
|
||||
}
|
||||
|
||||
void with_ram_account(auto const &fn)
|
||||
{
|
||||
if (_ram_account.constructed()) fn(*_ram_account);
|
||||
}
|
||||
|
||||
void with_cap_account(auto const &fn)
|
||||
{
|
||||
if (_cap_account.constructed()) fn(*_cap_account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize cap and RAM accounts without providing a reference account
|
||||
*
|
||||
|
@ -87,7 +87,6 @@ class Core::Ram_dataspace_factory : public Ram_allocator,
|
||||
Ram_dataspace_factory(Rpc_entrypoint &ep,
|
||||
Range_allocator &phys_alloc,
|
||||
Phys_range phys_range,
|
||||
Region_map &,
|
||||
Allocator &allocator)
|
||||
:
|
||||
_ep(ep), _phys_alloc(phys_alloc), _phys_range(phys_range),
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <base/rpc_server.h>
|
||||
#include <rm_session/rm_session.h>
|
||||
#include <base/session_object.h>
|
||||
#include <base/heap.h>
|
||||
|
||||
/* core includes */
|
||||
#include <region_map_component.h>
|
||||
|
@ -39,6 +39,9 @@ namespace Core {
|
||||
* argument.
|
||||
*/
|
||||
void init_core_signal_transmitter(Rpc_entrypoint &ep);
|
||||
|
||||
|
||||
Rpc_entrypoint &core_signal_ep(Rpc_entrypoint &core_ep);
|
||||
}
|
||||
|
||||
#endif /* _CORE__INCLUDE__SIGNAL_TRANSMITTER_H_ */
|
||||
|
@ -13,20 +13,13 @@
|
||||
|
||||
/* Genode includes */
|
||||
#include <base/sleep.h>
|
||||
#include <base/service.h>
|
||||
#include <base/child.h>
|
||||
#include <base/component.h>
|
||||
#include <rm_session/connection.h>
|
||||
#include <pd_session/connection.h>
|
||||
#include <rom_session/connection.h>
|
||||
#include <cpu_session/connection.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
|
||||
/* core includes */
|
||||
#include <platform.h>
|
||||
#include <core_env.h>
|
||||
#include <core_region_map.h>
|
||||
#include <core_service.h>
|
||||
#include <signal_transmitter.h>
|
||||
#include <system_control.h>
|
||||
@ -39,43 +32,9 @@
|
||||
#include <irq_root.h>
|
||||
#include <trace/root.h>
|
||||
#include <platform_services.h>
|
||||
#include <core_child.h>
|
||||
#include <pager.h>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
||||
/***************************************
|
||||
** Core environment/platform support **
|
||||
***************************************/
|
||||
|
||||
Core_env &Core::core_env()
|
||||
{
|
||||
/*
|
||||
* Make sure to initialize the platform before constructing the core
|
||||
* environment.
|
||||
*/
|
||||
platform();
|
||||
|
||||
/*
|
||||
* By placing the environment as static object here, we ensure that its
|
||||
* constructor gets called when this function is used the first time.
|
||||
*/
|
||||
static Core_env _env;
|
||||
|
||||
/*
|
||||
* Register signal-source entrypoint at core-local signal-transmitter back
|
||||
* end
|
||||
*/
|
||||
static bool signal_transmitter_initialized;
|
||||
|
||||
if (!signal_transmitter_initialized)
|
||||
signal_transmitter_initialized =
|
||||
(init_core_signal_transmitter(_env.signal_ep()), true);
|
||||
|
||||
return _env;
|
||||
}
|
||||
|
||||
|
||||
Core::Platform &Core::platform_specific()
|
||||
{
|
||||
static Platform _platform;
|
||||
@ -83,134 +42,9 @@ Core::Platform &Core::platform_specific()
|
||||
}
|
||||
|
||||
|
||||
Platform_generic &Core::platform() { return platform_specific(); }
|
||||
Core::Platform_generic &Core::platform() { return platform_specific(); }
|
||||
|
||||
|
||||
struct Genode::Platform { };
|
||||
|
||||
|
||||
Genode::Platform &Genode::init_platform()
|
||||
{
|
||||
core_env();
|
||||
static Genode::Platform platform { };
|
||||
return platform;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dummy implementation for core that has no parent to ask for resources
|
||||
*/
|
||||
void Genode::init_parent_resource_requests(Genode::Env &) {};
|
||||
|
||||
|
||||
/****************
|
||||
** Core child **
|
||||
****************/
|
||||
|
||||
class Core_child : public Child_policy
|
||||
{
|
||||
private:
|
||||
|
||||
Registry<Service> &_services;
|
||||
|
||||
Capability<Pd_session> _core_pd_cap;
|
||||
Pd_session &_core_pd;
|
||||
|
||||
Capability<Cpu_session> _core_cpu_cap;
|
||||
Cpu_session &_core_cpu;
|
||||
|
||||
Cap_quota const _cap_quota;
|
||||
Ram_quota const _ram_quota;
|
||||
|
||||
Id_space<Parent::Server> _server_ids { };
|
||||
|
||||
Child _child;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Core_child(Registry<Service> &services, Region_map &local_rm,
|
||||
Pd_session &core_pd, Capability<Pd_session> core_pd_cap,
|
||||
Cpu_session &core_cpu, Capability<Cpu_session> core_cpu_cap,
|
||||
Cap_quota cap_quota, Ram_quota ram_quota,
|
||||
Rpc_entrypoint &ep)
|
||||
:
|
||||
_services(services),
|
||||
_core_pd_cap (core_pd_cap), _core_pd (core_pd),
|
||||
_core_cpu_cap(core_cpu_cap), _core_cpu(core_cpu),
|
||||
_cap_quota(Child::effective_quota(cap_quota)),
|
||||
_ram_quota(Child::effective_quota(ram_quota)),
|
||||
_child(local_rm, ep, *this)
|
||||
{ }
|
||||
|
||||
|
||||
/****************************
|
||||
** Child-policy interface **
|
||||
****************************/
|
||||
|
||||
Name name() const override { return "init"; }
|
||||
|
||||
Route resolve_session_request(Service::Name const &name,
|
||||
Session_label const &label,
|
||||
Session::Diag const diag) override
|
||||
{
|
||||
Service *service = nullptr;
|
||||
_services.for_each([&] (Service &s) {
|
||||
if (!service && s.name() == name)
|
||||
service = &s; });
|
||||
|
||||
if (!service)
|
||||
throw Service_denied();
|
||||
|
||||
return Route { .service = *service,
|
||||
.label = label,
|
||||
.diag = diag };
|
||||
}
|
||||
|
||||
void init(Pd_session &session, Capability<Pd_session> cap) override
|
||||
{
|
||||
session.ref_account(_core_pd_cap);
|
||||
_core_pd.transfer_quota(cap, _cap_quota);
|
||||
_core_pd.transfer_quota(cap, _ram_quota);
|
||||
}
|
||||
|
||||
void init(Cpu_session &session, Capability<Cpu_session> cap) override
|
||||
{
|
||||
session.ref_account(_core_cpu_cap);
|
||||
_core_cpu.transfer_quota(cap, Cpu_session::quota_lim_upscale(100, 100));
|
||||
}
|
||||
|
||||
Ram_allocator &session_md_ram() override { return _core_pd; }
|
||||
|
||||
Pd_account &ref_account() override { return _core_pd; }
|
||||
Capability<Pd_account> ref_account_cap() const override { return _core_pd_cap; }
|
||||
|
||||
size_t session_alloc_batch_size() const override { return 128; }
|
||||
|
||||
Id_space<Parent::Server> &server_id_space() override { return _server_ids; }
|
||||
};
|
||||
|
||||
|
||||
/****************
|
||||
** Signal API **
|
||||
****************/
|
||||
|
||||
/*
|
||||
* In contrast to non-core components, core disables the signal thread by
|
||||
* overriding 'Genode::init_signal_thread' with a dummy. Within core, the
|
||||
* signal thread is not needed as core is never supposed to receive any
|
||||
* signals.
|
||||
*/
|
||||
|
||||
void Genode::init_signal_thread(Env &) { }
|
||||
|
||||
|
||||
/*******************
|
||||
** Trace support **
|
||||
*******************/
|
||||
|
||||
Core::Trace::Source_registry &Core::Trace::sources()
|
||||
{
|
||||
static Source_registry inst;
|
||||
@ -218,20 +52,57 @@ Core::Trace::Source_registry &Core::Trace::sources()
|
||||
}
|
||||
|
||||
|
||||
/***************
|
||||
** Core main **
|
||||
***************/
|
||||
namespace Genode { extern char const *version_string; }
|
||||
|
||||
namespace Genode {
|
||||
extern bool inhibit_tracing;
|
||||
extern char const *version_string;
|
||||
|
||||
struct Genode::Platform { };
|
||||
|
||||
|
||||
/*
|
||||
* Executed on the initial stack
|
||||
*/
|
||||
Genode::Platform &Genode::init_platform()
|
||||
{
|
||||
init_stack_area();
|
||||
|
||||
static Platform platform { };
|
||||
return platform;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Executed on a stack located within the stack area
|
||||
*/
|
||||
void Genode::bootstrap_component(Genode::Platform &)
|
||||
{
|
||||
init_exception_handling(*core_env().pd_session(), core_env().local_rm());
|
||||
init_page_fault_handling(core_env().entrypoint());
|
||||
using namespace Core;
|
||||
|
||||
Range_allocator &ram_ranges = Core::platform().ram_alloc();
|
||||
Rom_fs &rom_modules = Core::platform().rom_fs();
|
||||
Range_allocator &io_mem_ranges = Core::platform().io_mem_alloc();
|
||||
Range_allocator &io_port_ranges = Core::platform().io_port_alloc();
|
||||
Range_allocator &irq_ranges = Core::platform().irq_alloc();
|
||||
Allocator &core_alloc = platform_specific().core_mem_alloc();
|
||||
|
||||
Ram_quota const avail_ram { ram_ranges.avail() };
|
||||
Cap_quota const avail_caps { Core::platform().max_caps() };
|
||||
|
||||
static constexpr size_t STACK_SIZE = 20 * 1024;
|
||||
|
||||
static Rpc_entrypoint ep { nullptr, STACK_SIZE, "entrypoint", Affinity::Location() };
|
||||
|
||||
static Core::Core_account core_account { ep, avail_ram, avail_caps };
|
||||
|
||||
static Ram_dataspace_factory core_ram {
|
||||
ep, ram_ranges, Ram_dataspace_factory::any_phys_range(), core_alloc };
|
||||
|
||||
static Core_region_map core_rm { ep };
|
||||
|
||||
static Rpc_entrypoint &signal_ep = core_signal_ep(ep);
|
||||
|
||||
init_exception_handling(core_ram, core_rm);
|
||||
init_core_signal_transmitter(signal_ep);
|
||||
init_page_fault_handling(ep);
|
||||
|
||||
/* disable tracing within core because it is not fully implemented */
|
||||
inhibit_tracing = true;
|
||||
@ -240,24 +111,18 @@ void Genode::bootstrap_component(Genode::Platform &)
|
||||
|
||||
static Core::Trace::Policy_registry trace_policies;
|
||||
|
||||
static Rpc_entrypoint &ep = core_env().entrypoint();
|
||||
static Ram_allocator &core_ram_alloc = core_env().ram_allocator();
|
||||
static Region_map &local_rm = core_env().local_rm();
|
||||
Pd_session &core_pd = *core_env().pd_session();
|
||||
Capability<Pd_session> core_pd_cap = core_env().pd_session_cap();
|
||||
|
||||
static Registry<Service> services;
|
||||
|
||||
/*
|
||||
* Allocate session meta data on distinct dataspaces to enable independent
|
||||
* destruction (to enable quota trading) of session component objects.
|
||||
*/
|
||||
static Sliced_heap sliced_heap(core_ram_alloc, local_rm);
|
||||
static Sliced_heap sliced_heap { core_ram, core_rm };
|
||||
|
||||
/*
|
||||
* Factory for creating RPC capabilities within core
|
||||
*/
|
||||
static Rpc_cap_factory rpc_cap_factory(sliced_heap);
|
||||
static Rpc_cap_factory rpc_cap_factory { sliced_heap };
|
||||
|
||||
static Pager_entrypoint pager_ep(rpc_cap_factory);
|
||||
|
||||
@ -266,20 +131,17 @@ void Genode::bootstrap_component(Genode::Platform &)
|
||||
|
||||
static Core::System_control &system_control = init_system_control(sliced_heap, ep);
|
||||
|
||||
static Rom_root rom_root (ep, ep, platform().rom_fs(), sliced_heap);
|
||||
static Rm_root rm_root (ep, sliced_heap, core_ram_alloc, local_rm, pager_ep);
|
||||
static Cpu_root cpu_root (core_ram_alloc, local_rm, ep, ep, pager_ep,
|
||||
static Rom_root rom_root (ep, ep, rom_modules, sliced_heap);
|
||||
static Rm_root rm_root (ep, sliced_heap, core_ram, core_rm, pager_ep);
|
||||
static Cpu_root cpu_root (core_ram, core_rm, ep, ep, pager_ep,
|
||||
sliced_heap, Core::Trace::sources());
|
||||
static Pd_root pd_root (ep, core_env().signal_ep(), pager_ep,
|
||||
platform().ram_alloc(),
|
||||
local_rm, sliced_heap,
|
||||
static Pd_root pd_root (ep, signal_ep, pager_ep, ram_ranges, core_rm, sliced_heap,
|
||||
platform_specific().core_mem_alloc(),
|
||||
system_control);
|
||||
static Log_root log_root (ep, sliced_heap);
|
||||
static Io_mem_root io_mem_root (ep, ep, platform().io_mem_alloc(),
|
||||
platform().ram_alloc(), sliced_heap);
|
||||
static Irq_root irq_root (platform().irq_alloc(), sliced_heap);
|
||||
static Trace_root trace_root (core_ram_alloc, local_rm, ep, sliced_heap,
|
||||
static Io_mem_root io_mem_root (ep, ep, io_mem_ranges, ram_ranges, sliced_heap);
|
||||
static Irq_root irq_root (irq_ranges, sliced_heap);
|
||||
static Trace_root trace_root (core_ram, core_rm, ep, sliced_heap,
|
||||
Core::Trace::sources(), trace_policies);
|
||||
|
||||
static Core_service<Rom_session_component> rom_service (services, rom_root);
|
||||
@ -293,26 +155,20 @@ void Genode::bootstrap_component(Genode::Platform &)
|
||||
|
||||
/* make platform-specific services known to service pool */
|
||||
platform_add_local_services(ep, sliced_heap, services, Core::Trace::sources(),
|
||||
core_ram_alloc, local_rm, platform().io_port_alloc());
|
||||
core_ram, core_rm, io_port_ranges);
|
||||
|
||||
size_t const avail_ram_quota = core_pd.avail_ram().value;
|
||||
size_t const avail_cap_quota = core_pd.avail_caps().value;
|
||||
|
||||
size_t const preserved_ram_quota = 224*1024;
|
||||
size_t const preserved_cap_quota = 1000;
|
||||
|
||||
if (avail_ram_quota < preserved_ram_quota) {
|
||||
error("core preservation exceeds platform RAM limit");
|
||||
if (!core_account.ram_account.try_withdraw({ 224*1024 })) {
|
||||
error("core preservation exceeds available RAM");
|
||||
return;
|
||||
}
|
||||
|
||||
if (avail_cap_quota < preserved_cap_quota) {
|
||||
error("core preservation exceeds platform cap quota limit");
|
||||
if (!core_account.cap_account.try_withdraw({ 1000 })) {
|
||||
error("core preservation exceeds available caps");
|
||||
return;
|
||||
}
|
||||
|
||||
Ram_quota const init_ram_quota { avail_ram_quota - preserved_ram_quota };
|
||||
Cap_quota const init_cap_quota { avail_cap_quota - preserved_cap_quota };
|
||||
Ram_quota const init_ram_quota = core_account.ram_account.avail();
|
||||
Cap_quota const init_cap_quota = core_account.cap_account.avail();
|
||||
|
||||
/* CPU session representing core */
|
||||
static Cpu_session_component
|
||||
@ -320,19 +176,17 @@ void Genode::bootstrap_component(Genode::Platform &)
|
||||
Session::Resources{{Cpu_session::RAM_QUOTA},
|
||||
{Cpu_session::CAP_QUOTA}},
|
||||
"core", Session::Diag{false},
|
||||
core_ram_alloc, local_rm, ep, pager_ep, Core::Trace::sources(), "",
|
||||
core_ram, core_rm, ep, pager_ep, Core::Trace::sources(), "",
|
||||
Affinity::unrestricted(), Cpu_session::QUOTA_LIMIT);
|
||||
|
||||
Cpu_session_capability core_cpu_cap = core_cpu.cap();
|
||||
log(init_ram_quota.value / (1024*1024), " MiB RAM and ",
|
||||
init_cap_quota, " caps assigned to init");
|
||||
|
||||
log("", init_ram_quota.value / (1024*1024), " MiB RAM and ", init_cap_quota, " caps "
|
||||
"assigned to init");
|
||||
static Reconstructible<Core::Core_child>
|
||||
init(services, ep, core_rm, core_ram, core_account,
|
||||
core_cpu, core_cpu.cap(), init_cap_quota, init_ram_quota);
|
||||
|
||||
static Reconstructible<Core_child>
|
||||
init(services, local_rm, core_pd, core_pd_cap, core_cpu, core_cpu_cap,
|
||||
init_cap_quota, init_ram_quota, ep);
|
||||
|
||||
platform().wait_for_exit();
|
||||
Core::platform().wait_for_exit();
|
||||
|
||||
init.destruct();
|
||||
}
|
||||
|
@ -116,8 +116,7 @@ Pd_session::Ref_account_result Pd_session_component::ref_account(Capability<Pd_a
|
||||
if (!pd || !pd->_ram_account.constructed())
|
||||
return;
|
||||
|
||||
_cap_account.construct(_cap_quota_guard(), _label, *pd->_cap_account);
|
||||
_ram_account.construct(_ram_quota_guard(), _label, *pd->_ram_account);
|
||||
ref_accounts(*pd->_ram_account, *pd->_cap_account);
|
||||
|
||||
result = Ref_account_result::OK;
|
||||
});
|
||||
|
@ -15,7 +15,6 @@
|
||||
*/
|
||||
|
||||
/* core includes */
|
||||
#include <core_env.h>
|
||||
#include <signal_transmitter.h>
|
||||
|
||||
using namespace Core;
|
||||
@ -24,4 +23,4 @@ using namespace Core;
|
||||
void Core::init_core_signal_transmitter(Rpc_entrypoint &) { }
|
||||
|
||||
|
||||
Rpc_entrypoint &Core_env::signal_ep() { return _entrypoint; }
|
||||
Rpc_entrypoint &Core::core_signal_ep(Rpc_entrypoint &core_ep) { return core_ep; }
|
||||
|
@ -17,9 +17,9 @@
|
||||
#include <base/trace/events.h>
|
||||
|
||||
/* core includes */
|
||||
#include <core_env.h>
|
||||
#include <signal_source_component.h>
|
||||
#include <signal_transmitter.h>
|
||||
#include <signal_delivery_proxy.h>
|
||||
|
||||
/* base-internal includes */
|
||||
#include <base/internal/globals.h>
|
||||
@ -46,9 +46,10 @@ void Signal_transmitter::submit(unsigned cnt)
|
||||
}
|
||||
|
||||
|
||||
Rpc_entrypoint &Core_env::signal_ep()
|
||||
Rpc_entrypoint &Core::core_signal_ep(Rpc_entrypoint &)
|
||||
{
|
||||
static Rpc_entrypoint ep(nullptr, ENTRYPOINT_STACK_SIZE,
|
||||
size_t const STACK_SIZE = 20 * 1024;
|
||||
static Rpc_entrypoint ep(nullptr, STACK_SIZE,
|
||||
"signal_entrypoint", Affinity::Location());
|
||||
return ep;
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ namespace Genode {
|
||||
void prepare_init_main_thread();
|
||||
void bootstrap_component(Platform &);
|
||||
void binary_ready_hook_for_platform();
|
||||
|
||||
extern bool inhibit_tracing;
|
||||
}
|
||||
|
||||
void genode_exit(int);
|
||||
|
Loading…
Reference in New Issue
Block a user