From a682e20b7abb8da9fcb6761e517e45225d3dacf1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Fri, 21 Feb 2025 15:37:28 +0100 Subject: [PATCH] Implemented cell creation in Hoitaja using the new API. --- repos/ealanos/src/hoitaja/main.cc | 5 +++++ repos/ealanos/src/lib/sandbox/child.cc | 6 ++++-- repos/ealanos/src/lib/sandbox/child.h | 19 ++++++++++++++++--- repos/ealanos/src/lib/sandbox/library.cc | 11 +++++++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/repos/ealanos/src/hoitaja/main.cc b/repos/ealanos/src/hoitaja/main.cc index b00425b7b9..29924e0a8a 100644 --- a/repos/ealanos/src/hoitaja/main.cc +++ b/repos/ealanos/src/hoitaja/main.cc @@ -17,6 +17,7 @@ #include #include #include +#include namespace Init { @@ -104,6 +105,10 @@ struct Init::Main : Sandbox::State_handler /* prevent init to block for resource upgrades (never satisfied by core) */ _env.parent().resource_avail_sigh(_resource_avail_handler); + Tukija::Tip const *tip = Tukija::Tip::tip(); + + Genode::log("Found topology model of size ", tip->length, " at ", static_cast(tip)); + _handle_config(); } }; diff --git a/repos/ealanos/src/lib/sandbox/child.cc b/repos/ealanos/src/lib/sandbox/child.cc index 9fdf759666..a86a0ef417 100644 --- a/repos/ealanos/src/lib/sandbox/child.cc +++ b/repos/ealanos/src/lib/sandbox/child.cc @@ -754,7 +754,8 @@ Sandbox::Child::Child(Env &env, Registry &parent_services, Registry &child_services, Registry &local_services, - Pd_intrinsics &pd_intrinsics) + Pd_intrinsics &pd_intrinsics, + Ealan::Habitat_connection &habitat) : _env(env), _alloc(alloc), _verbose(verbose), _id(id), _report_update_trigger(report_update_trigger), @@ -774,7 +775,8 @@ Sandbox::Child::Child(Env &env, _parent_services(parent_services), _child_services(child_services), _local_services(local_services), - _session_requester(_env.ep().rpc_ep(), _env.ram(), _env.rm()) + _session_requester(_env.ep().rpc_ep(), _env.ram(), _env.rm()), + _habitat(habitat) { log("Creating new cell <", _unique_name, ">"); if (_verbose.enabled()) { diff --git a/repos/ealanos/src/lib/sandbox/child.h b/repos/ealanos/src/lib/sandbox/child.h index 6e1545ccbc..54e45f5662 100644 --- a/repos/ealanos/src/lib/sandbox/child.h +++ b/repos/ealanos/src/lib/sandbox/child.h @@ -14,6 +14,11 @@ #ifndef _LIB__SANDBOX__CHILD_H_ #define _LIB__SANDBOX__CHILD_H_ +/* Tukija includes */ +#include +#include +#include + /* Genode includes */ #include #include @@ -31,6 +36,9 @@ #include #include +/* EalánOS includes */ +#include + namespace Sandbox { class Child; } class Sandbox::Child : Child_policy, Routed_service::Wakeup @@ -375,6 +383,8 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup Session_requester _session_requester; + Ealan::Habitat_connection &_habitat; + /** * CPU-session priority parameters */ @@ -595,7 +605,8 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup Registry &parent_services, Registry &child_services, Registry &local_services, - Pd_intrinsics &pd_intrinsics); + Pd_intrinsics &pd_intrinsics, + Ealan::Habitat_connection &habitat); virtual ~Child(); @@ -628,11 +639,13 @@ class Sandbox::Child : Child_policy, Routed_service::Wakeup if (_state == State::RAM_INITIALIZED) { _child.initiate_env_sessions(); - if (_child.active()) + if (_child.active()) { + _habitat.create_cell(_child.pd_session_cap(), _resources.affinity, static_cast(_priority)); _state = State::ALIVE; - else + } else _uncertain_dependencies = true; } + } /* diff --git a/repos/ealanos/src/lib/sandbox/library.cc b/repos/ealanos/src/lib/sandbox/library.cc index 557733f958..422ddeef42 100644 --- a/repos/ealanos/src/lib/sandbox/library.cc +++ b/repos/ealanos/src/lib/sandbox/library.cc @@ -23,6 +23,9 @@ #include #include +/* EalánOS includes */ +#include + struct Genode::Sandbox::Library : ::Sandbox::State_reporter::Producer, ::Sandbox::Child::Default_route_accessor, ::Sandbox::Child::Default_caps_accessor, @@ -64,6 +67,7 @@ struct Genode::Sandbox::Library : ::Sandbox::State_reporter::Producer, Registry &_local_services; Child_registry _children { }; + Constructible _habitat { }; /* * Global parameters obtained from config */ @@ -376,8 +380,11 @@ bool Genode::Sandbox::Library::ready_to_create_child(Start_model::Name const "but affinity defined for child ", start_node.attribute_value("name", Child_policy::Name())); - if (_affinity_space.constructed() && !_core_allocator.constructed()) + if (_affinity_space.constructed() && !_core_allocator.constructed()) { + log("Creating new core allocator for ", _affinity_space->total(), " cores."); _core_allocator.construct(*_affinity_space, _prio_levels); + _habitat.construct(_env, Affinity(*_affinity_space, Affinity::Location(0,0))); + } Affinity::Location allocation = _core_allocator->allocate_cores_for_cell(start_node); @@ -393,7 +400,7 @@ bool Genode::Sandbox::Library::ready_to_create_child(Start_model::Name const start_node, *this, *this, _children, *this, *this, *this, *this, _prio_levels, _effective_affinity_space(), allocation, _parent_services, _child_services, _local_services, - _pd_intrinsics); + _pd_intrinsics, *_habitat); _children.insert(&child); _avail_cpu.percent -= min(_avail_cpu.percent, child.cpu_quota().percent);