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
This commit is contained in:
Norman Feske 2024-12-18 12:12:04 +01:00 committed by Christian Helmuth
parent 43d7c3bd11
commit fc11e26511
15 changed files with 89 additions and 99 deletions

View File

@ -12,7 +12,6 @@
*/
/* core includes */
#include <core_env.h>
#include <platform_services.h>
#include <vm_root.h>
#include <io_port_root.h>
@ -24,15 +23,15 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &heap,
Registry<Service> &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_session_component> 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_session_component> io_port(services, io_root);
}

View File

@ -16,12 +16,11 @@
/* core includes */
#include <platform.h>
#include <platform_pd.h>
#include <platform_services.h>
#include <core_env.h>
#include <core_service.h>
#include <map_local.h>
#include <vm_root.h>
#include <platform.h>
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<Service> &services,
Core::Trace::Source_registry &trace_sources,
Ram_allocator &)
void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sh,
Registry<Service> &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_session_component> vm_service(services, vm_root);
},
[&] (Range_allocator::Alloc_error) {

View File

@ -17,7 +17,6 @@
/* core includes */
#include <platform.h>
#include <platform_services.h>
#include <core_env.h>
#include <core_service.h>
#include <vm_root.h>
#include <map_local.h>
@ -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<Service> &local_services,
Core::Trace::Source_registry &trace_sources,
Ram_allocator &)
void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sliced_heap,
Registry<Service> &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_session_component> vm_service(local_services, vm_root);
static Core_service<Vm_session_component> vm_service(services, vm_root);
}

View File

@ -16,7 +16,6 @@
#include <base/service.h>
/* core includes */
#include <core_env.h>
#include <platform.h>
#include <platform_services.h>
#include <vm_root.h>
@ -30,16 +29,15 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &sliced_heap,
Registry<Service> &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_session_component> vm_service(local_services, vm_root);
static Core_service<Io_port_session_component>
io_port_ls(local_services, io_port_root);
static Core_service<Io_port_session_component> io_port_ls(local_services, io_port_root);
}

View File

@ -23,5 +23,7 @@ void Core::platform_add_local_services(Rpc_entrypoint &,
Sliced_heap &,
Registry<Service> &,
Trace::Source_registry &,
Ram_allocator &)
Ram_allocator &,
Region_map &,
Range_allocator &)
{ }

View File

@ -14,9 +14,9 @@
/* Genode includes */
#include <base/service.h>
#include <base/heap.h>
/* core includes */
#include <core_env.h>
#include <platform.h>
#include <platform_services.h>
#include <io_port_root.h>
@ -25,18 +25,17 @@
using namespace Core;
void Core::platform_add_local_services(Rpc_entrypoint &,
Sliced_heap &md,
Registry<Service> &reg,
Core::Trace::Source_registry &,
Ram_allocator &)
void Core::platform_add_local_services(Rpc_entrypoint &,
Sliced_heap &md,
Registry<Service> &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_session_component>
io_port_ls(reg, io_port_root);
static Core_service<Io_port_session_component> io_port_ls(services, io_port_root);
}
}

View File

@ -24,6 +24,7 @@
/* core includes */
#include <types.h>
#include <pd_session_component.h>
namespace Core { class Vm_session_component; }

View File

@ -12,7 +12,6 @@
*/
/* core includes */
#include <core_env.h>
#include <platform_services.h>
#include <vm_root.h>
#include <io_port_root.h>
@ -24,14 +23,14 @@ void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &heap,
Registry<Service> &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_session_component> 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_session_component> io_port(services, io_root);
}

View File

@ -12,7 +12,6 @@
*/
/* core includes */
#include <core_env.h>
#include <platform_services.h>
#include <vm_root.h>
#include <io_port_root.h>
@ -20,18 +19,19 @@
/*
* Add x86 specific services
*/
void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &heap,
Registry<Service> &services,
Core::Trace::Source_registry &trace_sources,
Ram_allocator &)
void Core::platform_add_local_services(Rpc_entrypoint &ep,
Sliced_heap &heap,
Registry<Service> &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_session_component> 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_session_component> io_port(services, io_root);
}

View File

@ -25,27 +25,17 @@ namespace Core {
}
class Core::Io_port_handler
struct Core::Io_port_handler
{
private:
static constexpr size_t STACK_SIZE = 4096;
enum { STACK_SIZE = 4096 };
Rpc_entrypoint _ep;
public:
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<Io_port_session_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<Io_port_session_component>(&entrypoint(), &md_alloc),
_io_port_alloc(io_port_alloc) { }
Root_component<Io_port_session_component>(&handler_ep, &md_alloc),
_io_port_alloc(io_port_alloc)
{ }
};
#endif /* _CORE__INCLUDE__IO_PORT_ROOT_H_ */

View File

@ -50,15 +50,13 @@ class Core::Irq_root : public Root_component<Irq_session_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<Irq_session_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)
{ }
};

View File

@ -14,8 +14,10 @@
#ifndef _CORE__INCLUDE__PLATFORM_SERVICES_H_
#define _CORE__INCLUDE__PLATFORM_SERVICES_H_
/* Genode includes */
#include <base/ram_allocator.h>
/* core includes */
#include "base/ram_allocator.h"
#include <core_service.h>
#include <trace/source_registry.h>
@ -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<Service> &reg,
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_ */

View File

@ -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_session_component> 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;

View File

@ -16,6 +16,9 @@
void Core::platform_add_local_services(Rpc_entrypoint &, Sliced_heap &,
Registry<Service> &,
Registry<Service> &,
Trace::Source_registry &,
Ram_allocator &) { }
Ram_allocator &,
Region_map &,
Range_allocator &)
{ }

View File

@ -13,9 +13,9 @@
/* Genode includes */
#include <base/service.h>
#include <base/heap.h>
/* core includes */
#include <core_env.h>
#include <platform.h>
#include <platform_services.h>
#include <io_port_root.h>
@ -28,11 +28,12 @@ void Core::platform_add_local_services(Rpc_entrypoint &,
Sliced_heap &sliced_heap,
Registry<Service> &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_session_component>
io_port_ls(local_services, io_port_root);
static Core_service<Io_port_session_component> io_port_ls(local_services,
io_port_root);
}