From 404e21017a04879b647012f0390c985711b7b39d Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 18 Dec 2024 12:12:04 +0100 Subject: [PATCH] core: pass ram, rm, io-ports to local services This patch replaces the use of 'core_env()' in 'platform_services.cc' by the function arguments 'core_ram', 'core_rm', and 'io_port_ranges'. It also removes the 'Pd_session' argument from 'Io_port_root' and 'Irq_root' to avoid the reliance on the 'Pd_session' interface within core, Issue #5408 --- .../src/core/spec/x86/platform_services.cc | 11 ++++---- .../arm/virtualization/platform_services.cc | 18 ++++++------- .../arm_v7/trustzone/platform_services.cc | 18 ++++++------- .../virtualization/platform_services.cc | 14 +++++----- .../src/core/spec/linux/platform_services.cc | 4 ++- .../src/core/spec/pc/platform_services.cc | 21 +++++++-------- .../src/core/include/vm_session_component.h | 1 + repos/base-nova/src/core/platform_services.cc | 11 ++++---- .../src/core/spec/x86/platform_services.cc | 20 +++++++------- repos/base/src/core/include/io_port_root.h | 27 +++++-------------- repos/base/src/core/include/irq_root.h | 6 ++--- .../base/src/core/include/platform_services.h | 11 +++++--- repos/base/src/core/main.cc | 6 ++--- repos/base/src/core/platform_services.cc | 7 +++-- .../src/core/spec/x86/platform_services.cc | 13 ++++----- 15 files changed, 89 insertions(+), 99 deletions(-) diff --git a/repos/base-foc/src/core/spec/x86/platform_services.cc b/repos/base-foc/src/core/spec/x86/platform_services.cc index 82db2061034..051c42bc310 100644 --- a/repos/base-foc/src/core/spec/x86/platform_services.cc +++ b/repos/base-foc/src/core/spec/x86/platform_services.cc @@ -12,7 +12,6 @@ */ /* core includes */ -#include #include #include #include @@ -24,15 +23,15 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep, Sliced_heap &heap, Registry &services, Trace::Source_registry &trace_sources, - Ram_allocator &) + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &io_port_ranges) { - static Vm_root vm_root(ep, heap, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, heap, core_ram, core_rm, trace_sources); static Core_service vm(services, vm_root); - static Io_port_root io_root(*core_env().pd_session(), - platform().io_port_alloc(), heap); + static Io_port_root io_root(io_port_ranges, heap); static Core_service io_port(services, io_root); } diff --git a/repos/base-hw/src/core/spec/arm/virtualization/platform_services.cc b/repos/base-hw/src/core/spec/arm/virtualization/platform_services.cc index 262d4f2e86f..a7d355235d8 100644 --- a/repos/base-hw/src/core/spec/arm/virtualization/platform_services.cc +++ b/repos/base-hw/src/core/spec/arm/virtualization/platform_services.cc @@ -16,12 +16,11 @@ /* core includes */ #include +#include #include -#include #include #include #include -#include using namespace Core; @@ -32,11 +31,13 @@ extern addr_t hypervisor_exception_vector; /* * Add ARM virtualization specific vm service */ -void Core::platform_add_local_services(Rpc_entrypoint &ep, - Sliced_heap &sh, - Registry &services, - Core::Trace::Source_registry &trace_sources, - Ram_allocator &) +void Core::platform_add_local_services(Rpc_entrypoint &ep, + Sliced_heap &sh, + Registry &services, + Trace::Source_registry &trace_sources, + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &) { map_local(Platform::core_phys_addr((addr_t)&hypervisor_exception_vector), Hw::Mm::hypervisor_exception_vector().base, @@ -51,8 +52,7 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep, Hw::Mm::hypervisor_stack().size / get_page_size(), Hw::PAGE_FLAGS_KERN_DATA); - static Vm_root vm_root(ep, sh, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, sh, core_ram, core_rm, trace_sources); static Core_service vm_service(services, vm_root); }, [&] (Range_allocator::Alloc_error) { diff --git a/repos/base-hw/src/core/spec/arm_v7/trustzone/platform_services.cc b/repos/base-hw/src/core/spec/arm_v7/trustzone/platform_services.cc index 7623cc82290..3d121ef192b 100644 --- a/repos/base-hw/src/core/spec/arm_v7/trustzone/platform_services.cc +++ b/repos/base-hw/src/core/spec/arm_v7/trustzone/platform_services.cc @@ -17,7 +17,6 @@ /* core includes */ #include #include -#include #include #include #include @@ -29,11 +28,13 @@ extern int monitor_mode_exception_vector; /* * Add TrustZone specific vm service */ -void Core::platform_add_local_services(Rpc_entrypoint &ep, - Sliced_heap &sliced_heap, - Registry &local_services, - Core::Trace::Source_registry &trace_sources, - Ram_allocator &) +void Core::platform_add_local_services(Rpc_entrypoint &ep, + Sliced_heap &sliced_heap, + Registry &services, + Trace::Source_registry &trace_sources, + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &) { static addr_t const phys_base = Platform::core_phys_addr((addr_t)&monitor_mode_exception_vector); @@ -41,8 +42,7 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep, map_local(phys_base, Hw::Mm::system_exception_vector().base, 1, Hw::PAGE_FLAGS_KERN_TEXT); - static Vm_root vm_root(ep, sliced_heap, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, sliced_heap, core_ram, core_rm, trace_sources); - static Core_service vm_service(local_services, vm_root); + static Core_service vm_service(services, vm_root); } diff --git a/repos/base-hw/src/core/spec/x86_64/virtualization/platform_services.cc b/repos/base-hw/src/core/spec/x86_64/virtualization/platform_services.cc index b5ca2578f4c..11d9308b82e 100644 --- a/repos/base-hw/src/core/spec/x86_64/virtualization/platform_services.cc +++ b/repos/base-hw/src/core/spec/x86_64/virtualization/platform_services.cc @@ -16,7 +16,6 @@ #include /* core includes */ -#include #include #include #include @@ -30,16 +29,15 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep, Sliced_heap &sliced_heap, Registry &local_services, Trace::Source_registry &trace_sources, - Ram_allocator &) + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &io_port_ranges) { - static Io_port_root io_port_root(*core_env().pd_session(), - platform().io_port_alloc(), sliced_heap); + static Io_port_root io_port_root(io_port_ranges, sliced_heap); - static Vm_root vm_root(ep, sliced_heap, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, sliced_heap, core_ram, core_rm, trace_sources); static Core_service vm_service(local_services, vm_root); - static Core_service - io_port_ls(local_services, io_port_root); + static Core_service io_port_ls(local_services, io_port_root); } diff --git a/repos/base-linux/src/core/spec/linux/platform_services.cc b/repos/base-linux/src/core/spec/linux/platform_services.cc index 25551c35e3f..db4cff08804 100644 --- a/repos/base-linux/src/core/spec/linux/platform_services.cc +++ b/repos/base-linux/src/core/spec/linux/platform_services.cc @@ -23,5 +23,7 @@ void Core::platform_add_local_services(Rpc_entrypoint &, Sliced_heap &, Registry &, Trace::Source_registry &, - Ram_allocator &) + Ram_allocator &, + Region_map &, + Range_allocator &) { } diff --git a/repos/base-linux/src/core/spec/pc/platform_services.cc b/repos/base-linux/src/core/spec/pc/platform_services.cc index 18c464b04c8..825f458d306 100644 --- a/repos/base-linux/src/core/spec/pc/platform_services.cc +++ b/repos/base-linux/src/core/spec/pc/platform_services.cc @@ -14,9 +14,9 @@ /* Genode includes */ #include +#include /* core includes */ -#include #include #include #include @@ -25,18 +25,17 @@ using namespace Core; -void Core::platform_add_local_services(Rpc_entrypoint &, - Sliced_heap &md, - Registry ®, - Core::Trace::Source_registry &, - Ram_allocator &) +void Core::platform_add_local_services(Rpc_entrypoint &, + Sliced_heap &md, + Registry &services, + Trace::Source_registry &, + Ram_allocator &, + Region_map &, + Range_allocator &io_port_ranges) { if (!lx_iopl(3)) { - static Io_port_root io_port_root(*core_env().pd_session(), - platform().io_port_alloc(), md); + static Io_port_root io_port_root(io_port_ranges, md); - static Core_service - - io_port_ls(reg, io_port_root); + static Core_service io_port_ls(services, io_port_root); } } diff --git a/repos/base-nova/src/core/include/vm_session_component.h b/repos/base-nova/src/core/include/vm_session_component.h index 5624ee10e4d..c2eb55a54aa 100644 --- a/repos/base-nova/src/core/include/vm_session_component.h +++ b/repos/base-nova/src/core/include/vm_session_component.h @@ -24,6 +24,7 @@ /* core includes */ #include +#include namespace Core { class Vm_session_component; } diff --git a/repos/base-nova/src/core/platform_services.cc b/repos/base-nova/src/core/platform_services.cc index 740b134097c..cc53dc48c0a 100644 --- a/repos/base-nova/src/core/platform_services.cc +++ b/repos/base-nova/src/core/platform_services.cc @@ -12,7 +12,6 @@ */ /* core includes */ -#include #include #include #include @@ -24,14 +23,14 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep, Sliced_heap &heap, Registry &services, Trace::Source_registry &trace_sources, - Ram_allocator &) + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &io_port_ranges) { - static Vm_root vm_root(ep, heap, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, heap, core_ram, core_rm, trace_sources); static Core_service vm(services, vm_root); - static Io_port_root io_root(*core_env().pd_session(), - platform().io_port_alloc(), heap); + static Io_port_root io_root(io_port_ranges, heap); static Core_service io_port(services, io_root); } diff --git a/repos/base-sel4/src/core/spec/x86/platform_services.cc b/repos/base-sel4/src/core/spec/x86/platform_services.cc index d7fc1f8769c..2f768b8663d 100644 --- a/repos/base-sel4/src/core/spec/x86/platform_services.cc +++ b/repos/base-sel4/src/core/spec/x86/platform_services.cc @@ -12,7 +12,6 @@ */ /* core includes */ -#include #include #include #include @@ -20,18 +19,19 @@ /* * Add x86 specific services */ -void Core::platform_add_local_services(Rpc_entrypoint &ep, - Sliced_heap &heap, - Registry &services, - Core::Trace::Source_registry &trace_sources, - Ram_allocator &) +void Core::platform_add_local_services(Rpc_entrypoint &ep, + Sliced_heap &heap, + Registry &services, + Trace::Source_registry &trace_sources, + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &io_port_ranges) { - static Vm_root vm_root(ep, heap, core_env().ram_allocator(), - core_env().local_rm(), trace_sources); + static Vm_root vm_root(ep, heap, core_ram, core_rm, trace_sources); + static Core_service vm(services, vm_root); - static Io_port_root io_root(*core_env().pd_session(), - platform().io_port_alloc(), heap); + static Io_port_root io_root(io_port_ranges, heap); static Core_service io_port(services, io_root); } diff --git a/repos/base/src/core/include/io_port_root.h b/repos/base/src/core/include/io_port_root.h index 76eae53aa36..68bd43c259b 100644 --- a/repos/base/src/core/include/io_port_root.h +++ b/repos/base/src/core/include/io_port_root.h @@ -25,27 +25,17 @@ namespace Core { } -class Core::Io_port_handler +struct Core::Io_port_handler { - private: - - enum { STACK_SIZE = 4096 }; - Rpc_entrypoint _ep; - - public: + static constexpr size_t STACK_SIZE = 4096; - Io_port_handler(Pd_session &pd_session) : - _ep(&pd_session, STACK_SIZE, "ioport", Affinity::Location()) - { } - - Rpc_entrypoint &entrypoint() { return _ep; } + Rpc_entrypoint handler_ep { nullptr, STACK_SIZE, "ioport", Affinity::Location() }; }; class Core::Io_port_root : private Io_port_handler, public Root_component { - private: Range_allocator &_io_port_alloc; /* I/O port allocator */ @@ -60,17 +50,14 @@ class Core::Io_port_root : private Io_port_handler, /** * Constructor * - * \param cap_session capability allocator * \param io_port_alloc platform IO_PORT allocator * \param md_alloc meta-data allocator to be used by root component */ - Io_port_root(Pd_session &pd_session, - Range_allocator &io_port_alloc, - Allocator &md_alloc) + Io_port_root(Range_allocator &io_port_alloc, Allocator &md_alloc) : - Io_port_handler(pd_session), - Root_component(&entrypoint(), &md_alloc), - _io_port_alloc(io_port_alloc) { } + Root_component(&handler_ep, &md_alloc), + _io_port_alloc(io_port_alloc) + { } }; #endif /* _CORE__INCLUDE__IO_PORT_ROOT_H_ */ diff --git a/repos/base/src/core/include/irq_root.h b/repos/base/src/core/include/irq_root.h index 6db7b8510cf..bc28bae3cd0 100644 --- a/repos/base/src/core/include/irq_root.h +++ b/repos/base/src/core/include/irq_root.h @@ -50,15 +50,13 @@ class Core::Irq_root : public Root_component /** * Constructor * - * \param pd_session capability allocator * \param irq_alloc IRQ range that can be assigned to clients * \param md_alloc meta-data allocator to be used by root component */ - Irq_root(Pd_session &pd_session, - Range_allocator &irq_alloc, Allocator &md_alloc) + Irq_root(Range_allocator &irq_alloc, Allocator &md_alloc) : Root_component(&_session_ep, &md_alloc), - _session_ep(&pd_session, STACK_SIZE, "irq", Affinity::Location()), + _session_ep(nullptr, STACK_SIZE, "irq", Affinity::Location()), _irq_alloc(irq_alloc) { } }; diff --git a/repos/base/src/core/include/platform_services.h b/repos/base/src/core/include/platform_services.h index 95e3b8c7de1..fa4ea494b1a 100644 --- a/repos/base/src/core/include/platform_services.h +++ b/repos/base/src/core/include/platform_services.h @@ -14,8 +14,10 @@ #ifndef _CORE__INCLUDE__PLATFORM_SERVICES_H_ #define _CORE__INCLUDE__PLATFORM_SERVICES_H_ +/* Genode includes */ +#include + /* core includes */ -#include "base/ram_allocator.h" #include #include @@ -28,8 +30,7 @@ namespace Genode { namespace Core { /** - * Register platform-specific services at entrypoint, and service - * registry + * Register platform-specific services at entrypoint, and service registry * * \param ep entrypoint used for session components of platform-services * \param md metadata allocator for session components @@ -40,7 +41,9 @@ namespace Core { Sliced_heap &md, Registry ®, Trace::Source_registry &trace, - Ram_allocator &core_ram_alloc); + Ram_allocator &core_ram, + Region_map &core_rm, + Range_allocator &io_port_ranges); } #endif /* _CORE__INCLUDE__PLATFORM_SERVICES_H_ */ diff --git a/repos/base/src/core/main.cc b/repos/base/src/core/main.cc index 0a44468599f..f6b717d957f 100644 --- a/repos/base/src/core/main.cc +++ b/repos/base/src/core/main.cc @@ -276,8 +276,7 @@ void Genode::bootstrap_component(Genode::Platform &) static Log_root log_root (ep, sliced_heap); static Io_mem_root io_mem_root (ep, ep, platform().io_mem_alloc(), platform().ram_alloc(), sliced_heap); - static Irq_root irq_root (*core_env().pd_session(), - platform().irq_alloc(), sliced_heap); + static Irq_root irq_root (platform().irq_alloc(), sliced_heap); static Trace_root trace_root (core_ram_alloc, local_rm, ep, sliced_heap, Core::Trace::sources(), trace_policies); @@ -291,7 +290,8 @@ void Genode::bootstrap_component(Genode::Platform &) static Core_service trace_service (services, trace_root); /* make platform-specific services known to service pool */ - platform_add_local_services(ep, sliced_heap, services, Core::Trace::sources(), core_ram_alloc); + platform_add_local_services(ep, sliced_heap, services, Core::Trace::sources(), + core_ram_alloc, local_rm, platform().io_port_alloc()); size_t const avail_ram_quota = core_pd.avail_ram().value; size_t const avail_cap_quota = core_pd.avail_caps().value; diff --git a/repos/base/src/core/platform_services.cc b/repos/base/src/core/platform_services.cc index ca4c4e98d06..3b7482726e0 100644 --- a/repos/base/src/core/platform_services.cc +++ b/repos/base/src/core/platform_services.cc @@ -16,6 +16,9 @@ void Core::platform_add_local_services(Rpc_entrypoint &, Sliced_heap &, - Registry &, + Registry &, Trace::Source_registry &, - Ram_allocator &) { } + Ram_allocator &, + Region_map &, + Range_allocator &) +{ } diff --git a/repos/base/src/core/spec/x86/platform_services.cc b/repos/base/src/core/spec/x86/platform_services.cc index 47bd233327b..8679bb43f57 100644 --- a/repos/base/src/core/spec/x86/platform_services.cc +++ b/repos/base/src/core/spec/x86/platform_services.cc @@ -13,9 +13,9 @@ /* Genode includes */ #include +#include /* core includes */ -#include #include #include #include @@ -28,11 +28,12 @@ void Core::platform_add_local_services(Rpc_entrypoint &, Sliced_heap &sliced_heap, Registry &local_services, Trace::Source_registry &, - Ram_allocator &) + Ram_allocator &, + Region_map &, + Range_allocator &io_port_ranges) { - static Io_port_root io_port_root(*core_env().pd_session(), - platform().io_port_alloc(), sliced_heap); + static Io_port_root io_port_root(io_port_ranges, sliced_heap); - static Core_service - io_port_ls(local_services, io_port_root); + static Core_service io_port_ls(local_services, + io_port_root); }