hoitaja: Added class representing Cells.

This commit is contained in:
Michael Mueller
2023-08-07 18:03:11 +02:00
parent 6f3449f568
commit d603ea90c0

View File

@@ -0,0 +1,80 @@
#pragma once
#include <base/log.h>
#include <base/child.h>
#include <os/session_requester.h>
#include <os/session_policy.h>
#include <os/buffered_xml.h>
#include <sandbox/sandbox.h>
#include <sandbox/child.h>
#include <sandbox/service.h>
#include <sandbox/types.h>
#include <sandbox/verbose.h>
#include <sandbox/report.h>
#include <sandbox/name_registry.h>
#include <sandbox/service.h>
#include <sandbox/utils.h>
#include <sandbox/route_model.h>
#include <state_handler.h>
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);
}
};