/* * \brief Hoitaja — Cell Management Component based on Init * \author Michael Müller, Norman Feske (Init) * \date 2023-04-20 */ /* * Copyright (C) 2010-2017 Genode Labs GmbH * Copyright (C) 2023 Michael Müller, Osnabrück University * * This file is part of EalánOS, which is distributed * under the terms of the GNU Affero General Public License version 3. */ /* Genode includes */ #include #include #include #include #include /** Hoitaja components **/ /* Filtering components */ #include "load_controller.h" #include "cell_controller.h" #include "hyperthread_controller.h" #include "memory_controller.h" #include "numa_controller.h" /* Core Allocator */ #include "core_allocator.h" /* State Handler */ #include "state_handler.h" /* Tasking Service Suoritin */ #include namespace Hoitaja { using namespace Genode; struct Main; } struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler { Env &_env; Habitat _sandbox { _env, *this, *this }; Entrypoint suoritin_ep{_env, 4 * 4096, "suoritin", Affinity::Location()}; Timer::Connection _timer{_env}; Attached_rom_dataspace _config { _env, "config" }; void _handle_resource_avail() { } Signal_handler
_resource_avail_handler { _env.ep(), *this, &Main::_handle_resource_avail }; Constructible _reporter { }; size_t _report_buffer_size = 0; void _handle_config() { _config.update(); Xml_node const config = _config.xml(); bool reporter_enabled = false; config.with_optional_sub_node("report", [&] (Xml_node report) { reporter_enabled = true; /* (re-)construct reporter whenever the buffer size is changed */ Number_of_bytes const buffer_size = report.attribute_value("buffer", Number_of_bytes(4096)); if (buffer_size != _report_buffer_size || !_reporter.constructed()) { _report_buffer_size = buffer_size; _reporter.construct(_env, "state", "state", _report_buffer_size); } }); if (_reporter.constructed()) _reporter->enabled(reporter_enabled); _sandbox.apply_config(config); } Signal_handler
_config_handler { _env.ep(), *this, &Main::_handle_config }; void _handle_timeout() { //log("Hoitaja's entering its maintance cycle"); // For now just print all cells created by Hoitaja //_handle_config(); //_timer.trigger_once(1000 * 1000); } Signal_handler
_timeout_handler{ _env.ep(), *this, &Main::_handle_timeout}; /** * Sandbox::State_handler interface */ void handle_sandbox_state() override { Genode::log("Habitat state changed"); /* try { Reporter::Xml_generator xml(*_reporter, [&] () { _sandbox.generate_state_report(xml); }); } catch (Xml_generator::Buffer_exceeded) { error("state report exceeds maximum size"); try to reflect the error condition as state report try { Reporter::Xml_generator xml(*_reporter, [&] () { xml.attribute("error", "report buffer exceeded"); }); } catch (...) { } }*/ } void handle_habitat_state(Cell &cell) override { Genode::log("Habitat changed"); _sandbox.update(cell); } Main(Env &env) : _env(env) { _config.sigh(_config_handler); _timer.sigh(_timeout_handler); /* prevent init to block for resource upgrades (never satisfied by core) */ _env.parent().resource_avail_sigh(_resource_avail_handler); _handle_config(); Genode::log("Starting TASKING service"); static Genode::Sliced_heap sliced_heap{env.ram(), env.rm()}; static Tukija::Suoritin::Root_component suoritin(env, sliced_heap); env.parent().announce(suoritin_ep.manage(suoritin)); //_timer.trigger_once(1000 * 1000); } }; void Component::construct(Genode::Env &env) { static Hoitaja::Main main(env); }