From 5cbac9f1284ad0d1bcdf6d6edef648c4a0d3b0f3 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 18 Jan 2024 18:51:49 +0100 Subject: [PATCH] base: New RPCs to allow to associate a PD with a Cell and growing and shrinking a cell's core allocation. --- .../base-nova/src/core/pd_session_support.cc | 23 +++++++++++++++++++ repos/base/include/pd_session/client.h | 15 ++++++++++++ repos/base/include/pd_session/pd_session.h | 19 ++++++++++++--- .../src/core/include/pd_session_component.h | 8 +++++++ 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/repos/base-nova/src/core/pd_session_support.cc b/repos/base-nova/src/core/pd_session_support.cc index 99b0726c4f..0dab7c66d7 100644 --- a/repos/base-nova/src/core/pd_session_support.cc +++ b/repos/base-nova/src/core/pd_session_support.cc @@ -106,6 +106,29 @@ void Pd_session_component::map(addr_t virt, addr_t size) } } +void Pd_session_component::create_cell(long prioritiy, const Affinity::Location &loc) +{ + Nova::uint8_t err = Nova::NOVA_OK; + if ((err = Nova::create_cell(_pd->pd_sel(), prioritiy, loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { + error("Could not create new cell: ", err); + } +} + +void Pd_session_component::grow_cell(const Affinity::Location &loc) +{ + Nova::uint8_t err = Nova::NOVA_OK; + if ((err = Nova::grow_cell(_pd->pd_sel(), loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { + error("Could not enlarge cell: ", err); + } +} + +void Pd_session_component::shrink_cell(const Affinity::Location &loc) +{ + Nova::uint8_t err = Nova::NOVA_OK; + if ((err = Nova::shrink_cell(_pd->pd_sel(), loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { + error("Could not shrink down cell: ", err); + } +} using State = Genode::Pd_session::Managing_system_state; diff --git a/repos/base/include/pd_session/client.h b/repos/base/include/pd_session/client.h index 9ee05e3700..7327c84563 100644 --- a/repos/base/include/pd_session/client.h +++ b/repos/base/include/pd_session/client.h @@ -105,6 +105,21 @@ struct Genode::Pd_session_client : Rpc_client Attach_dma_result attach_dma(Dataspace_capability ds, addr_t at) override { return call(ds, at); } + + void create_cell(long prioritiy, const Affinity::Location &loc) override + { + call(prioritiy, loc); + } + + void grow_cell(const Affinity::Location &loc) override + { + call(loc); + } + + void shrink_cell(const Affinity::Location &loc) override + { + call(loc); + } }; #endif /* _INCLUDE__PD_SESSION__CLIENT_H_ */ diff --git a/repos/base/include/pd_session/pd_session.h b/repos/base/include/pd_session/pd_session.h index c6baa209e5..ccc75d5488 100644 --- a/repos/base/include/pd_session/pd_session.h +++ b/repos/base/include/pd_session/pd_session.h @@ -21,7 +21,7 @@ #include #include #include - +#include namespace Genode { struct Pd_session; struct Pd_session_client; @@ -29,7 +29,6 @@ namespace Genode { struct Signal_context; } - struct Genode::Pd_session : Session, Ram_allocator { /** @@ -347,6 +346,14 @@ struct Genode::Pd_session : Session, Ram_allocator */ virtual Attach_dma_result attach_dma(Dataspace_capability, addr_t at) = 0; + /* + * Create a new cell at the kernel for this protection domain + */ + virtual void create_cell(long prioritiy, const Affinity::Location &loc) = 0; + + virtual void shrink_cell(const Affinity::Location &loc) = 0; + + virtual void grow_cell(const Affinity::Location &loc) = 0; /********************* ** RPC declaration ** @@ -402,6 +409,11 @@ struct Genode::Pd_session : Session, Ram_allocator GENODE_RPC(Rpc_attach_dma, Attach_dma_result, attach_dma, Dataspace_capability, addr_t); + GENODE_RPC(Rpc_create_cell, void, create_cell, long, Affinity::Location const &); + + GENODE_RPC(Rpc_shrink_cell, void, shrink_cell, Affinity::Location const &); + GENODE_RPC(Rpc_grow_cell, void, grow_cell, Affinity::Location const &); + GENODE_RPC_INTERFACE(Rpc_assign_parent, Rpc_assign_pci, Rpc_map, Rpc_alloc_signal_source, Rpc_free_signal_source, Rpc_alloc_context, Rpc_free_context, Rpc_submit, @@ -411,7 +423,8 @@ struct Genode::Pd_session : Session, Ram_allocator Rpc_try_alloc, Rpc_try_alloc_numa, Rpc_free, Rpc_transfer_ram_quota, Rpc_ram_quota, Rpc_used_ram, Rpc_native_pd, Rpc_managing_system, - Rpc_dma_addr, Rpc_attach_dma); + Rpc_dma_addr, Rpc_attach_dma, + Rpc_create_cell, Rpc_grow_cell, Rpc_shrink_cell); }; #endif /* _INCLUDE__PD_SESSION__PD_SESSION_H_ */ diff --git a/repos/base/src/core/include/pd_session_component.h b/repos/base/src/core/include/pd_session_component.h index 182ec8a1f5..0763814fea 100644 --- a/repos/base/src/core/include/pd_session_component.h +++ b/repos/base/src/core/include/pd_session_component.h @@ -346,6 +346,14 @@ class Genode::Pd_session_component : public Session_object addr_t dma_addr(Ram_dataspace_capability) override; Attach_dma_result attach_dma(Dataspace_capability, addr_t) override; + + /****************************************** + ** Support for EalánOS cells ** + ******************************************/ + void create_cell(long prioritiy, const Affinity::Location &loc) override; + + void grow_cell(const Affinity::Location &loc) override; + void shrink_cell(const Affinity::Location &loc) override; }; #endif /* _CORE__INCLUDE__PD_SESSION_COMPONENT_H_ */