From d603ea90c0631152335a0e84f08f940bc2f35ed7 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 7 Aug 2023 18:03:11 +0200 Subject: [PATCH] hoitaja: Added class representing Cells. --- repos/os/src/hoitaja/cell.h | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 repos/os/src/hoitaja/cell.h diff --git a/repos/os/src/hoitaja/cell.h b/repos/os/src/hoitaja/cell.h new file mode 100644 index 0000000000..1019207932 --- /dev/null +++ b/repos/os/src/hoitaja/cell.h @@ -0,0 +1,80 @@ +#pragma once +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace Hoitaja { + class Cell; +} + +class Hoitaja::Cell : public ::Sandbox::Child +{ + private: + State_handler &_state_handler; + + public: + friend class Habitat; + + Cell(Genode::Env &env, + Genode::Allocator &alloc, + ::Sandbox::Verbose const &verbose, + ::Sandbox::Child::Id id, + ::Sandbox::Report_update_trigger &report_update_trigger, + Genode::Xml_node start_node, + ::Sandbox::Child::Default_route_accessor &default_route_accessor, + ::Sandbox::Child::Default_caps_accessor &default_caps_accessor, + ::Sandbox::Name_registry &name_registry, + ::Sandbox::Child::Ram_limit_accessor &ram_limit_accessor, + ::Sandbox::Child::Cap_limit_accessor &cap_limit_accessor, + ::Sandbox::Child::Cpu_limit_accessor &cpu_limit_accessor, + ::Sandbox::Child::Cpu_quota_transfer &cpu_quota_transfer, + ::Sandbox::Prio_levels prio_levels, + Genode::Affinity::Space const &affinity_space, + Genode::Affinity::Location const &location, + Genode::Registry<::Sandbox::Parent_service> &parent_services, + Genode::Registry<::Sandbox::Routed_service> &child_services, + Genode::Registry<::Sandbox::Child::Local_service> &local_services, + State_handler &state_handler) + : ::Sandbox::Child(env, alloc, verbose, id, report_update_trigger, start_node, default_route_accessor, default_caps_accessor, name_registry, ram_limit_accessor, cap_limit_accessor, cpu_limit_accessor, cpu_quota_transfer, prio_levels, affinity_space, location, parent_services, child_services, local_services), _state_handler(state_handler) + { } + + virtual ~Cell() { }; + + struct Resources &resources() { return _resources; } + + void update_affinity(Genode::Affinity affinity) { + Genode::log("Updating affinity to ", affinity.location(), " in space ", affinity.space()); + _resources.affinity = affinity; + Genode::log("Moving CPU session ", _env.cpu_session_cap()); + _env.cpu().move(affinity.location()); + if (_child.active()) { + _child.cpu().move(affinity.location()); + _child.topo().reconstruct(affinity); + } + } + + void exit(int exit_value) override + { + ::Sandbox::Child::exit(exit_value); + _state_handler.handle_habitat_state(*this); + } + + void yield(Genode::Parent::Resource_args &args) { + _child.yield(args); + } +}; \ No newline at end of file