From 441186468cb8e0e3be7cd2439d067e6d85b9d74b Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 10 Mar 2023 14:09:14 +0100 Subject: [PATCH] base: remove env_deprecated from rpc_cap_alloc Issue #4784 --- .../base-linux/src/core/core_rpc_cap_alloc.cc | 7 +++--- repos/base-linux/src/lib/base/platform_env.cc | 2 ++ .../base-linux/src/lib/base/rpc_cap_alloc.cc | 22 +++++++++++++---- .../base-nova/src/core/core_rpc_cap_alloc.cc | 12 +++++++--- repos/base-nova/src/lib/base/rpc_cap_alloc.cc | 21 ++++++++++++---- repos/base/src/core/core_rpc_cap_alloc.cc | 12 +++++++--- .../base/src/include/base/internal/globals.h | 1 + repos/base/src/lib/base/rpc_cap_alloc.cc | 24 +++++++++++++++---- .../base/src/lib/startup/init_main_thread.cc | 1 + 9 files changed, 81 insertions(+), 21 deletions(-) diff --git a/repos/base-linux/src/core/core_rpc_cap_alloc.cc b/repos/base-linux/src/core/core_rpc_cap_alloc.cc index eab7e2a804..f086920b74 100644 --- a/repos/base-linux/src/core/core_rpc_cap_alloc.cc +++ b/repos/base-linux/src/core/core_rpc_cap_alloc.cc @@ -16,11 +16,12 @@ /* base-internal includes */ #include +#include -/* core includes */ -#include +using namespace Genode; -using namespace Core; + +void Genode::init_rpc_cap_alloc(Parent &) { } Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session &, Native_capability, diff --git a/repos/base-linux/src/lib/base/platform_env.cc b/repos/base-linux/src/lib/base/platform_env.cc index 8d0c5fd78a..da038c1905 100644 --- a/repos/base-linux/src/lib/base/platform_env.cc +++ b/repos/base-linux/src/lib/base/platform_env.cc @@ -174,5 +174,7 @@ Platform_env::Platform_env() /* register TID and PID of the main thread at core */ Linux_native_cpu_client native_cpu(cpu_session()->native_cpu()); native_cpu.thread_id(parent()->main_thread_cap(), lx_getpid(), lx_gettid()); + + init_rpc_cap_alloc(_parent()); } diff --git a/repos/base-linux/src/lib/base/rpc_cap_alloc.cc b/repos/base-linux/src/lib/base/rpc_cap_alloc.cc index 9645fd4968..981624d4ff 100644 --- a/repos/base-linux/src/lib/base/rpc_cap_alloc.cc +++ b/repos/base-linux/src/lib/base/rpc_cap_alloc.cc @@ -14,14 +14,28 @@ /* Genode includes */ #include #include -#include /* base-internal includes */ #include +#include using namespace Genode; +static Parent *_parent_ptr; +static Parent &_parent() +{ + if (_parent_ptr) + return *_parent_ptr; + + error("missing call of init_rpc_cap_alloc"); + for (;;); +} + + +void Genode::init_rpc_cap_alloc(Parent &parent) { _parent_ptr = &parent; } + + Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session& pd, Native_capability, addr_t) { @@ -34,9 +48,9 @@ Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session& pd, Native_capabili catch (Out_of_ram) { ram_upgrade = Ram_quota { 2*1024*sizeof(long) }; } catch (Out_of_caps) { cap_upgrade = Cap_quota { 4 }; } - env_deprecated()->parent()->upgrade(Parent::Env::pd(), - String<100>("ram_quota=", ram_upgrade, ", " - "cap_quota=", cap_upgrade).string()); + _parent().upgrade(Parent::Env::pd(), + String<100>("ram_quota=", ram_upgrade, ", " + "cap_quota=", cap_upgrade).string()); } return Thread::native_thread().epoll.alloc_rpc_cap(); diff --git a/repos/base-nova/src/core/core_rpc_cap_alloc.cc b/repos/base-nova/src/core/core_rpc_cap_alloc.cc index 039eb24bff..a4b1c37613 100644 --- a/repos/base-nova/src/core/core_rpc_cap_alloc.cc +++ b/repos/base-nova/src/core/core_rpc_cap_alloc.cc @@ -19,12 +19,18 @@ #include #include -using namespace Core; +/* base-internal includes */ +#include + +using namespace Genode; -static Rpc_cap_factory &rpc_cap_factory() +void Genode::init_rpc_cap_alloc(Parent &) { } + + +static Core::Rpc_cap_factory &rpc_cap_factory() { - static Rpc_cap_factory inst(platform().core_mem_alloc()); + static Core::Rpc_cap_factory inst(Core::platform().core_mem_alloc()); return inst; } diff --git a/repos/base-nova/src/lib/base/rpc_cap_alloc.cc b/repos/base-nova/src/lib/base/rpc_cap_alloc.cc index 8f0e0ad97c..d5bd988ab9 100644 --- a/repos/base-nova/src/lib/base/rpc_cap_alloc.cc +++ b/repos/base-nova/src/lib/base/rpc_cap_alloc.cc @@ -16,7 +16,6 @@ #include #include #include -#include /* base-internal includes */ #include @@ -27,6 +26,20 @@ using namespace Genode; +static Parent *_parent_ptr; +static Parent &_parent() +{ + if (_parent_ptr) + return *_parent_ptr; + + error("missing call of init_rpc_cap_alloc"); + for (;;); +} + + +void Genode::init_rpc_cap_alloc(Parent &parent) { _parent_ptr = &parent; } + + Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session &pd, Native_capability ep, addr_t entry) { @@ -48,9 +61,9 @@ Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session &pd, Native_capabili catch (Out_of_ram) { ram_upgrade = Ram_quota { 2*1024*sizeof(long) }; } catch (Out_of_caps) { cap_upgrade = Cap_quota { 4 }; } - env_deprecated()->parent()->upgrade(Parent::Env::pd(), - String<100>("ram_quota=", ram_upgrade, ", " - "cap_quota=", cap_upgrade).string()); + _parent().upgrade(Parent::Env::pd(), + String<100>("ram_quota=", ram_upgrade, ", " + "cap_quota=", cap_upgrade).string()); } } diff --git a/repos/base/src/core/core_rpc_cap_alloc.cc b/repos/base/src/core/core_rpc_cap_alloc.cc index b8203279b6..b6d22d2ac8 100644 --- a/repos/base/src/core/core_rpc_cap_alloc.cc +++ b/repos/base/src/core/core_rpc_cap_alloc.cc @@ -18,12 +18,18 @@ #include #include -using namespace Core; +/* base-internal includes */ +#include + +using namespace Genode; -static Rpc_cap_factory &rpc_cap_factory() +void Genode::init_rpc_cap_alloc(Parent &) { } + + +static Core::Rpc_cap_factory &rpc_cap_factory() { - static Rpc_cap_factory inst(platform().core_mem_alloc()); + static Core::Rpc_cap_factory inst(Core::platform().core_mem_alloc()); return inst; } diff --git a/repos/base/src/include/base/internal/globals.h b/repos/base/src/include/base/internal/globals.h index 4eeb3aa8c2..78d3c347db 100644 --- a/repos/base/src/include/base/internal/globals.h +++ b/repos/base/src/include/base/internal/globals.h @@ -38,6 +38,7 @@ namespace Genode { void init_root_proxy(Env &); void init_tracing(Env &); void init_log(Parent &); + void init_rpc_cap_alloc(Parent &); void init_parent_resource_requests(Env &); void init_heartbeat_monitoring(Env &); void deinit_heartbeat_monitoring(); diff --git a/repos/base/src/lib/base/rpc_cap_alloc.cc b/repos/base/src/lib/base/rpc_cap_alloc.cc index 8d5bd3365e..2ed5628e82 100644 --- a/repos/base/src/lib/base/rpc_cap_alloc.cc +++ b/repos/base/src/lib/base/rpc_cap_alloc.cc @@ -16,11 +16,27 @@ #include #include #include -#include + +/* base-internal includes */ +#include using namespace Genode; +static Parent *_parent_ptr; +static Parent &_parent() +{ + if (_parent_ptr) + return *_parent_ptr; + + error("missing call of init_rpc_cap_alloc"); + for (;;); +} + + +void Genode::init_rpc_cap_alloc(Parent &parent) { _parent_ptr = &parent; } + + Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session &pd, Native_capability, addr_t) { @@ -33,9 +49,9 @@ Native_capability Rpc_entrypoint::_alloc_rpc_cap(Pd_session &pd, catch (Out_of_ram) { ram_upgrade = Ram_quota { 2*1024*sizeof(long) }; } catch (Out_of_caps) { cap_upgrade = Cap_quota { 4 }; } - env_deprecated()->parent()->upgrade(Parent::Env::pd(), - String<100>("ram_quota=", ram_upgrade, ", " - "cap_quota=", cap_upgrade).string()); + _parent().upgrade(Parent::Env::pd(), + String<100>("ram_quota=", ram_upgrade, ", " + "cap_quota=", cap_upgrade).string()); } } diff --git a/repos/base/src/lib/startup/init_main_thread.cc b/repos/base/src/lib/startup/init_main_thread.cc index fcd7209eaa..a8aa05a09c 100644 --- a/repos/base/src/lib/startup/init_main_thread.cc +++ b/repos/base/src/lib/startup/init_main_thread.cc @@ -99,6 +99,7 @@ extern "C" void init_main_thread() */ (void)env_deprecated(); init_log(*env_deprecated()->parent()); + init_rpc_cap_alloc(*env_deprecated()->parent()); /* create a thread object for the main thread */ main_thread();