forked from genodelabs/genode
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 genodelabs#5408
- Loading branch information
Showing
16 changed files
with
270 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ */ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.