Implemented cell creation in Hoitaja using the new API.

This commit is contained in:
Michael Mueller
2025-02-21 15:37:28 +01:00
parent 1970c59077
commit a682e20b7a
4 changed files with 34 additions and 7 deletions

View File

@@ -17,6 +17,7 @@
#include <sandbox/sandbox.h>
#include <os/reporter.h>
#include <base/log.h>
#include <tukija/syscall-generic.h>
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<const void *>(tip));
_handle_config();
}
};

View File

@@ -754,7 +754,8 @@ Sandbox::Child::Child(Env &env,
Registry<Parent_service> &parent_services,
Registry<Routed_service> &child_services,
Registry<Local_service> &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()) {

View File

@@ -14,6 +14,11 @@
#ifndef _LIB__SANDBOX__CHILD_H_
#define _LIB__SANDBOX__CHILD_H_
/* Tukija includes */
#include <tukija_native_pd/client.h>
#include <tukija/syscall-generic.h>
#include <tukija/syscalls.h>
/* Genode includes */
#include <base/log.h>
#include <base/child.h>
@@ -31,6 +36,9 @@
#include <utils.h>
#include <route_model.h>
/* EalánOS includes */
#include <habitat/connection.h>
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_service> &parent_services,
Registry<Routed_service> &child_services,
Registry<Local_service> &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<uint16_t>(_priority));
_state = State::ALIVE;
else
} else
_uncertain_dependencies = true;
}
}
/*

View File

@@ -23,6 +23,9 @@
#include <config_model.h>
#include <core_allocator.h>
/* EalánOS includes */
#include <habitat/connection.h>
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_service> &_local_services;
Child_registry _children { };
Constructible<Ealan::Habitat_connection> _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);