diff --git a/repos/os/src/hoitaja/main.cc b/repos/os/src/hoitaja/main.cc index 26839672d6..22e06e8d00 100644 --- a/repos/os/src/hoitaja/main.cc +++ b/repos/os/src/hoitaja/main.cc @@ -28,6 +28,8 @@ #include "numa_controller.h" /* Core Allocator */ #include "core_allocator.h" +/* State Handler */ +#include "state_handler.h" namespace Hoitaja { @@ -37,11 +39,11 @@ namespace Hoitaja { } -struct Hoitaja::Main : Genode::Sandbox::State_handler +struct Hoitaja::Main : Genode::Sandbox::State_handler, Hoitaja::State_handler { Env &_env; - Habitat _sandbox { _env, *this }; + Habitat _sandbox { _env, *this, *this }; Timer::Connection _timer{_env}; @@ -90,8 +92,8 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler { //log("Hoitaja's entering its maintance cycle"); // For now just print all cells created by Hoitaja - //_sandbox.maintain_cells(); - _timer.trigger_once(1000 * 1000); + //_handle_config(); + //_timer.trigger_once(1000 * 1000); } Signal_handler
_timeout_handler{ @@ -102,7 +104,8 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler */ void handle_sandbox_state() override { - + Genode::log("Habitat state changed"); + /* try { Reporter::Xml_generator xml(*_reporter, [&] () { _sandbox.generate_state_report(xml); }); @@ -111,13 +114,19 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler error("state report exceeds maximum size"); - /* try to reflect the error condition as state report */ + 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) @@ -133,12 +142,5 @@ struct Hoitaja::Main : Genode::Sandbox::State_handler } }; -void Hoitaja::Habitat::maintain_cells() -{ - log("My current children are:"); - _children.for_each_child([&](Child &child) - { log(child.name(), " ram: ", child.ram_quota()); }); -} - void Component::construct(Genode::Env &env) { static Hoitaja::Main main(env); } diff --git a/repos/os/src/hoitaja/state_handler.h b/repos/os/src/hoitaja/state_handler.h new file mode 100644 index 0000000000..e25a24d8b9 --- /dev/null +++ b/repos/os/src/hoitaja/state_handler.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +namespace Hoitaja { + struct State_handler; + class Cell; +} + +struct Hoitaja::State_handler : Genode::Interface +{ + virtual void handle_habitat_state(Cell &cell) = 0; +}; \ No newline at end of file